Index: issm/trunk/src/m/classes/mesh.m
===================================================================
--- issm/trunk/src/m/classes/mesh.m	(revision 9854)
+++ issm/trunk/src/m/classes/mesh.m	(revision 9860)
@@ -80,39 +80,29 @@
 		function checkconsistency(obj,md,solution,analyses) % {{{
 
-			fields={'x','y','z','elements','elementonbed','elementonsurface','vertexonbed','vertexonsurface','elementconnectivity'};
-			checknan(md,'mesh',fields);
-
-			fields={'elements','elementonbed','elementonsurface','vertexonbed','vertexonsurface','elementconnectivity'};
-			checkgreater(md,'mesh',fields,0);
-
-			fields={'dimension','elements','numberofelements','numberofvertices'};
-			checkgreaterstrict(md,'mesh',fields,0);
-			
-			fields={'vertexonbed','vertexonsurface','x','y','z'};
-			checksize(md,'mesh',fields,[md.mesh.numberofvertices 1]);
-
-			fields={'elementonbed','elementonsurface'};
-			checksize(md,'mesh',fields,[md.mesh.numberofelements 1]);
-
-			fields={'elements'};
+			checkfield(md,'mesh.x','NaN',1,'size',[md.mesh.numberofvertices 1]);
+			checkfield(md,'mesh.y','NaN',1,'size',[md.mesh.numberofvertices 1]);
+			checkfield(md,'mesh.z','NaN',1,'size',[md.mesh.numberofvertices 1]);
+			checkfield(md,'mesh.elements','NaN',1,'>',0,'values',1:md.mesh.numberofvertices);
 			if(md.mesh.dimension==2),
-				checksize(md,'mesh',fields,[md.mesh.numberofelements 3]);
+				checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 3]);
 			else
-				checksize(md,'mesh',fields,[md.mesh.numberofelements 6]);
+				checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 6]);
 			end
 			if any(~ismember(1:md.mesh.numberofvertices,sort(unique(md.mesh.elements(:)))));
-				checkmessage('orphan nodes have been found. Check the mesh');
+				checkmessage('orphan nodes have been found. Check the mesh outline');
 			end
-
-
+			checkfield(md,'mesh.dimension','values',[2 3]);
+			checkfield(md,'mesh.numberoflayers','>=',0);
+			checkfield(md,'mesh.numberofelements','>',0);
+			checkfield(md,'mesh.numberofvertices','>',0);
+			%no checks for numberofedges lat long and hemisphere
+			checkfield(md,'mesh.elementonbed','size',[md.mesh.numberofelements 1],'values',[0 1]);
+			checkfield(md,'mesh.elementonsurface','size',[md.mesh.numberofelements 1],'values',[0 1]);
+			checkfield(md,'mesh.vertexonbed','size',[md.mesh.numberofvertices 1],'values',[0 1]);
+			checkfield(md,'mesh.vertexonsurface','size',[md.mesh.numberofvertices 1],'values',[0 1]);
 			if (md.mesh.dimension==2),
-				if md.mesh.average_vertex_connectivity<9, 
-					checkmessage('model not consistent: connectivity should be at least 9 for 2d models');
-				end
-			end
-			if md.mesh.dimension==3,
-				if md.mesh.average_vertex_connectivity<24, 
-					checkmessage('model not consistent: connectivity should be at least 24 for 3d models');
-				end
+				checkfield(md,'mesh.average_vertex_connectivity','>=',9,'message','''mesh.average_vertex_connectivity'' should be at least 9 in 2d');
+			else
+				checkfield(md,'mesh.average_vertex_connectivity','>=',24,'message','''mesh.average_vertex_connectivity'' should be at least 24 in 3d');
 			end
 
@@ -121,31 +111,22 @@
 				case PrognosticSolutionEnum,
 					if md.prognostic.stabilization==3,
-						if md.mesh.dimension~=2, checkmessage('Discontinuous Galerkin only supported for 2d meshes'); end
-						fields={'edges'};
-						checksize(md,'mesh',fields,[NaN 4]);
-						fields={'edges(:,1:3)'};
-						checknan(md,'mesh',fields);
-						checkgreaterstrict(md,'mesh',fields,0);
+						checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
+						checkfield(md,'mesh.edges','size',[NaN 4]);
+						checkfield(md,'mesh.edges(:,1:3)','>',0);
 					end
 				case BalancethicknessSolutionEnum,
 					if md.balancethickness.stabilization==3,
-						if md.mesh.dimension~=2, checkmessage('Discontinuous Galerkin only supported for 2d meshes'); end
-						fields={'edges'};
-						checksize(md,'mesh',fields,[NaN 4]);
-						fields={'edges(:,1:3)'};
-						checknan(md,'mesh',fields);
-						checkgreaterstrict(md,'mesh',fields,0);
+						checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
+						checkfield(md,'mesh.edges','size',[NaN 4]);
+						checkfield(md,'mesh.edges(:,1:3)','>',0);
 					end
 				case TransientSolutionEnum,
 					if md.transient.isprognostic & md.prognostic.stabilization==3,
-						if md.mesh.dimension~=2, checkmessage('Discontinuous Galerkin only supported for 2d meshes'); end
-						fields={'edges'};
-						checksize(md,'mesh',fields,[NaN 4]);
-						fields={'edges(:,1:3)'};
-						checknan(md,'mesh',fields);
-						checkgreaterstrict(md,'mesh',fields,0);
+						checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
+						checkfield(md,'mesh.edges','size',[NaN 4]);
+						checkfield(md,'mesh.edges(:,1:3)','>',0);
 					end
 				case ThermalSolutionEnum,
-					if md.mesh.dimension~=3, checkmessage('thermal solution only supported on 3d meshes'); end
+					checkfield(md,'mesh.dimension','values',3,'message','thermal solution only supported on 3d meshes');
 			end
 		end % }}}
