Index: /issm/trunk-jpl/examples/AMR/domain.exp
===================================================================
--- /issm/trunk-jpl/examples/AMR/domain.exp	(revision 23096)
+++ /issm/trunk-jpl/examples/AMR/domain.exp	(revision 23096)
@@ -0,0 +1,10 @@
+## Name:domainoutline
+## Icon:0
+# Points Count  Value
+5 1.
+# X pos Y pos
+0 0
+800000 0
+800000 50000
+0 50000
+0 0
Index: /issm/trunk-jpl/examples/AMR/front.exp
===================================================================
--- /issm/trunk-jpl/examples/AMR/front.exp	(revision 23096)
+++ /issm/trunk-jpl/examples/AMR/front.exp	(revision 23096)
@@ -0,0 +1,10 @@
+## Name:icefront
+## Icon:0
+# Points Count  Value
+5 1.
+# X pos Y pos
+799900 -100
+800100 -100
+800100 50100
+799900 50100
+799900 -100
Index: /issm/trunk-jpl/examples/AMR/mismip.par
===================================================================
--- /issm/trunk-jpl/examples/AMR/mismip.par	(revision 23096)
+++ /issm/trunk-jpl/examples/AMR/mismip.par	(revision 23096)
@@ -0,0 +1,51 @@
+% creating thickness
+md.geometry.bed=-100-abs(md.mesh.x)/1000;
+md.geometry.base=-90*ones(md.mesh.numberofvertices,1);
+md.geometry.surface=10*ones(md.mesh.numberofvertices,1);
+md.geometry.thickness=md.geometry.surface-md.geometry.base;
+md.mask.groundedice_levelset=-1*ones(md.mesh.numberofvertices,1);
+
+% creating basal drag
+md.friction.coefficient=sqrt(10^7)*ones(md.mesh.numberofvertices,1); %q=1.
+md.friction.p=3*ones(md.mesh.numberofelements,1);
+md.friction.q=zeros(md.mesh.numberofelements,1);
+
+% creating flow law paramter
+md.materials.rheology_B=1/((10^-25)^(1/3))*ones(md.mesh.numberofvertices,1);
+md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
+md.materials.rheology_law='None';
+
+% creating boundary conditions
+md=SetIceShelfBC(md,'./front.exp');
+md.stressbalance.spcvx=NaN*ones(md.mesh.numberofvertices,1);
+md.stressbalance.spcvy=NaN*ones(md.mesh.numberofvertices,1);
+md.stressbalance.spcvz=NaN*ones(md.mesh.numberofvertices,1);
+pos=find((md.mesh.y<50000.1 & md.mesh.y>49999.9) | (md.mesh.y<0.1 & md.mesh.y>-0.1));
+md.stressbalance.spcvy(pos)=0;
+pos2=find(md.mesh.x<0.1 & md.mesh.x>-0.1);
+md.stressbalance.spcvx(pos2)=0;
+md.stressbalance.spcvz(pos)=NaN;
+md.stressbalance.spcvz(pos2)=NaN;
+
+% creating forcing conditions
+md.smb.mass_balance=0.5*ones(md.mesh.numberofvertices,1);
+md.basalforcings.geothermalflux=0.5*ones(md.mesh.numberofvertices,1);
+md.thermal.spctemperature=NaN*ones(md.mesh.numberofvertices,1);
+md.groundingline.migration='SubelementMigration';
+
+% setting parameters
+md.materials.rho_ice=900;
+md.materials.rho_water=1000;
+md.constants.g=9.8;
+md.constants.yts=3600*24*365;
+md.transient.isthermal=0;
+md.transient.isgroundingline=1;
+md.stressbalance.isnewton=0;
+
+% setting inital condition
+md.initialization.vx=ones(md.mesh.numberofvertices,1);
+md.initialization.vy=ones(md.mesh.numberofvertices,1);
+md.initialization.vz=ones(md.mesh.numberofvertices,1);
+md.initialization.vel=sqrt(2)*ones(md.mesh.numberofvertices,1);
+md.initialization.pressure=md.constants.g*md.materials.rho_ice*md.geometry.thickness;
+md.initialization.temperature=273*ones(md.mesh.numberofvertices,1);
Index: /issm/trunk-jpl/examples/AMR/runme.m
===================================================================
--- /issm/trunk-jpl/examples/AMR/runme.m	(revision 23096)
+++ /issm/trunk-jpl/examples/AMR/runme.m	(revision 23096)
@@ -0,0 +1,66 @@
+% Mismip3D experiment with AMR using BAMG
+steps=[1:3]; 
+
+if any(steps==1)
+	disp('   Step 1: Coarse mesh');
+	
+	%Generate an unstructured coarse mesh on the MISMIP domain with typical element edge length equal to 10,000 m
+	md=bamg(model,'domain','./domain.exp','hmax',10000,'splitcorners',1);
+
+	save AMRCoarseMesh md
+end 
+if any(steps==2)
+	disp('   Step 2: Parameterization');
+
+	md=loadmodel('AMRCoarseMesh');
+
+	md=setmask(md,'','');
+	
+	% Run parameterization script to set up geometry, inital velocity, material properties, etc.
+	md=parameterize(md,'./mismip.par');
+
+	% Set the AMR properties and the refinement criteria
+	% Here, we are refining around the grounding line
+	% We impose the element resolution at grounding equal to 1000 m (1 km)
+	% The criterion used is the element distance to the grounding line.
+	% The distance used here is 10000 m (10 km), used in both side around the grouding line (upstream and downstream)
+	md.amr.groundingline_resolution=1000;
+	md.amr.groundingline_distance=10000;
+	md.amr.hmin=1000; % the same resolution used around the grounding line
+	md.amr.hmax=10000; % the same coase resolution used to generate the coarse mesh
+	md.amr.gradation=1.7; % this controls the ratio between two consecutive edges
+	md.amr.fieldname='None'; % no field used here
+	md.amr.keepmetric=0; % no field, no metric
+
+	save AMRParam md
+end
+if any(steps==3);
+   disp('   Step 3: Solve!');
+	 
+	md=loadmodel('AMRParam');
+
+	% Run transient with adaptive mesh refinement
+	md.timestepping.time_step=1;
+	md.timestepping.final_time=500; % here, as example, only 500 yr.
+	md.settings.output_frequency=10;% here, save results every 10 yr 
+	md.stressbalance.maxiter=30;
+	md.stressbalance.abstol=NaN;
+	md.stressbalance.restol=1;
+	md.verbose=verbose('convergence',false,'solution',true);
+	
+	% Specify that you want to run the model on your current (local host) computer
+	% Change the number of processors according to your machine (here np=2)
+	md.cluster=generic('np',2);
+
+	% Set the AMR frequency, i.e., can be 1 or larger depending on how often the mesh needs to be updated
+	md.transient.amr_frequency=1; % here, we are refining the mesh in every time step
+
+	% Set the flow equation (SSA) and run
+	md=setflowequation(md,'SSA','all');
+	md=solve(md,'Transient');
+
+	% Print the solutions and the mesh in VTK format (needs ParaView:	https://www.paraview.org)
+	AMRexportVTK('./VTK',md);
+
+	save AMRTransient md
+end% }}}
