Index: /issm/trunk/test/NightlyRun/IdToName.m
===================================================================
--- /issm/trunk/test/NightlyRun/IdToName.m	(revision 5181)
+++ /issm/trunk/test/NightlyRun/IdToName.m	(revision 5182)
@@ -214,3 +214,5 @@
 elseif (id==1303), name='ThermalConduction';
 elseif (id==1304), name='ThermalGeothermalFlux';
+elseif (id==1401), name='AdaptiveMeshRefinement1';
+elseif (id==1402), name='AdaptiveMeshRefinement2';
 else name='N/A'; end
Index: /issm/trunk/test/NightlyRun/test1401.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1401.m	(revision 5182)
+++ /issm/trunk/test/NightlyRun/test1401.m	(revision 5182)
@@ -0,0 +1,51 @@
+%test the anisotropic mesh adaptation
+%function to capture = exp(-(sqrt((md.x+0.1).^2+(md.y+0.1).^2)-0.75).^2*10^6)+((md.x+0.1).^2+(md.y+0.1).^2)/2;
+
+%create square mesh
+L=1; %in m
+nx=70; %numberof nodes in x direction
+ny=70;
+md=model;
+
+%mesh adaptation loop YAMS
+md=squaremesh(md,L,L,nx,ny);
+plotmodel(md,'data','mesh');pause(0.5);
+for i=1:1
+	md.vel_obs=exp(-(sqrt((md.x+0.1).^2+(md.y+0.1).^2)-0.75).^2*10^6)+((md.x+0.1).^2+(md.y+0.1).^2)/2;
+	md=YamsCall(md,md.vel_obs,0.001,0.3,1.3,10^-4);
+	plotmodel(md,'data','mesh');pause(0.5);
+end
+for i=1:1
+	md.vel_obs=exp(-(sqrt((md.x+0.1).^2+(md.y+0.1).^2)-0.75).^2*10^6)+((md.x+0.1).^2+(md.y+0.1).^2)/2;
+	md=YamsCall(md,md.vel_obs,0.001,0.3,2,10^-4);
+	plotmodel(md,'data','mesh');pause(0.5);
+end
+for i=1:3,
+	md.vel_obs=exp(-(sqrt((md.x+0.1).^2+(md.y+0.1).^2)-0.75).^2*10^6)+((md.x+0.1).^2+(md.y+0.1).^2)/2;
+	md=YamsCall(md,md.vel_obs,0.001,0.3,2,0.005);
+	plotmodel(md,'data','mesh');pause(0.5);
+end
+md.vel_obs=exp(-(sqrt((md.x+0.1).^2+(md.y+0.1).^2)-0.75).^2*10^6)+((md.x+0.1).^2+(md.y+0.1).^2)/2;
+
+%mesh adaptation loop BAMG
+md=squaremesh(md,L,L,nx,ny);
+plotmodel(md,'data','mesh');pause(0.5);
+for i=1:1
+	md.vel_obs=exp(-(sqrt((md.x+0.1).^2+(md.y+0.1).^2)-0.75).^2*10^6)+((md.x+0.1).^2+(md.y+0.1).^2)/2;
+	md.bamg=NaN;
+	md=bamg(md,'field',md.vel_obs,'hmin',0.001,'hmax',0.3,'gradation',1.3,'err',10^-4);
+	plotmodel(md,'data','mesh');pause(0.5);
+end
+for i=1:1
+	md.vel_obs=exp(-(sqrt((md.x+0.1).^2+(md.y+0.1).^2)-0.75).^2*10^6)+((md.x+0.1).^2+(md.y+0.1).^2)/2;
+	md.bamg=NaN;
+	md=bamg(md,'field',md.vel_obs,'hmin',0.001,'hmax',0.3,'gradation',2,'err',10^-4);
+	plotmodel(md,'data','mesh');pause(0.5);
+end
+for i=1:3,
+	md.vel_obs=exp(-(sqrt((md.x+0.1).^2+(md.y+0.1).^2)-0.75).^2*10^6)+((md.x+0.1).^2+(md.y+0.1).^2)/2;
+	md.bamg=NaN;
+	md=bamg(md,'field',md.vel_obs,'hmin',0.001,'hmax',0.3,'gradation',2,'err',0.005);
+	plotmodel(md,'data','mesh');pause(0.5);
+end
+md.vel_obs=exp(-(sqrt((md.x+0.1).^2+(md.y+0.1).^2)-0.75).^2*10^6)+((md.x+0.1).^2+(md.y+0.1).^2)/2;
Index: /issm/trunk/test/NightlyRun/test1402.m
===================================================================
--- /issm/trunk/test/NightlyRun/test1402.m	(revision 5182)
+++ /issm/trunk/test/NightlyRun/test1402.m	(revision 5182)
@@ -0,0 +1,76 @@
+%test the anisotropic mesh adaptation
+
+%create square mesh
+L=1; %in m
+nx=70; %numberof nodes in x direction
+ny=70;
+md=model;
+
+%mesh adaptation loop YAMS
+md=squaremesh(md,L,L,nx,ny);
+plotmodel(md,'data','mesh');pause(0.5);
+for i=1:1
+	u=4*md.x-2; v=4*md.y-2;
+	md.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
+		+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+		+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+	md=YamsCall(md,md.vel_obs,0.005,0.3,1.3,10^-4);
+	plotmodel(md,'data','mesh');pause(0.5);
+end
+for i=1:1
+	u=4*md.x-2; v=4*md.y-2;
+	md.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
+		+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+		+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+	md=YamsCall(md,md.vel_obs,0.005,0.3,2,10^-4);
+	plotmodel(md,'data','mesh');pause(0.5);
+end
+for i=1:3,
+	u=4*md.x-2; v=4*md.y-2;
+	md.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
+		+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+		+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+	md=YamsCall(md,md.vel_obs,0.005,0.3,2,0.001);
+	plotmodel(md,'data','mesh');pause(0.5);
+end
+md.vel_obs=tanh(30*((4*md.x-2).^2+(4*md.y-2).^2-0.25))+...
+	tanh(30*((4*md.x-2.75).^2+(4*md.y-1.25).^2-2.75))+...
+	tanh(30*((4*md.x-2.75).^2+(4*md.y-2).^2-1.25))+...
+	tanh(30*((4*md.x-1.25).^2+(4*md.y-2).^2-2.75))+...
+	tanh(30*((4*md.x-1.25).^2+(4*md.y-2).^2-1.25));
+
+%mesh adaptation loop BAMG
+md=squaremesh(md,L,L,nx,ny);
+plotmodel(md,'data','mesh');pause(0.5);
+for i=1:1
+	u=4*md.x-2; v=4*md.y-2;
+	md.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
+		+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+		+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+	md.bamg=NaN;
+	md=bamg(md,'field',md.vel_obs,'hmin',0.005,'hmax',0.3,'gradation',1.3,'err',10^-4);
+	plotmodel(md,'data','mesh');pause(0.5);
+end
+for i=1:1
+	u=4*md.x-2; v=4*md.y-2;
+	md.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
+		+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+		+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+	md.bamg=NaN;
+	md=bamg(md,'field',md.vel_obs,'hmin',0.005,'hmax',0.3,'gradation',2,'err',10^-4);
+	plotmodel(md,'data','mesh');pause(0.5);
+end
+for i=1:3,
+	u=4*md.x-2; v=4*md.y-2;
+	md.vel_obs=tanh(30*(u.^2+v.^2-0.25)) ...
+		+tanh(30*((u-0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u-0.75).^2+(v+0.75).^2-0.25)) ...
+		+tanh(30*((u+0.75).^2+(v-0.75).^2-0.25)) +tanh(30*((u+0.75).^2+(v+0.75).^2-0.25)) ;
+	md.bamg=NaN;
+	md=bamg(md,'field',md.vel_obs,'hmin',0.001,'hmax',0.3,'gradation',2,'err',10^-3);
+	plotmodel(md,'data','mesh');pause(0.5);
+end
+md.vel_obs=tanh(30*((4*md.x-2).^2+(4*md.y-2).^2-0.25))+...
+	tanh(30*((4*md.x-2.75).^2+(4*md.y-1.25).^2-2.75))+...
+	tanh(30*((4*md.x-2.75).^2+(4*md.y-2).^2-1.25))+...
+	tanh(30*((4*md.x-1.25).^2+(4*md.y-2).^2-2.75))+...
+	tanh(30*((4*md.x-1.25).^2+(4*md.y-2).^2-1.25));
