Index: /issm/trunk/src/m/classes/public/plot/plot_basaldrag.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_basaldrag.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_basaldrag.m	(revision 4330)
@@ -39,10 +39,10 @@
 
 	%process data and model
-	[x y z elements is2d]=processmesh(md,options);
-	[basal_drag isongrid isquiver]=processdata(md,drag,options);
+	[x y z elements is2d]=processmesh(md,[],options);
+	[basal_drag datatype]=processdata(md,drag,options);
 
 	%plot basaldrag
 	subplot(width,width,i); 
-	plot_unit(x,y,z,elements,basal_drag,isongrid,is2d,isquiver,options);
+	plot_unit(x,y,z,elements,basal_drag,is2d,datatype,options);
 
 	%apply options
Index: /issm/trunk/src/m/classes/public/plot/plot_boundaries.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_boundaries.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_boundaries.m	(revision 4330)
@@ -13,5 +13,5 @@
 	options=removefield(options,'layer',1);
 end
-[x y z elements is2d]=processmesh(md,options);
+[x y z elements is2d]=processmesh(md,[],options);
 
 for i=1:size(md.segments,1),
Index: /issm/trunk/src/m/classes/public/plot/plot_contour.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_contour.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_contour.m	(revision 4330)
@@ -8,6 +8,6 @@
 
 %process data and model
-[x y z index is2d]=processmesh(md,options);
-[data isongrid isquiver]=processdata(md,datain,options);
+[x y z index is2d]=processmesh(md,[],options);
+[data datatype]=processdata(md,datain,options);
 
 %check is2d
@@ -17,11 +17,12 @@
 
 %first, process data: must be on grids
-if isquiver
+if datatype==2,
 	%take norm
 	data=sqrt(sum(datain.*datain,2));
-end
-if ~isongrid
+elseif datatype==1,
 	%take average
 	data=averaging(md,data,0);
+else
+	error('datatype not supported yet');
 end
 
Index: /issm/trunk/src/m/classes/public/plot/plot_drivingstress.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_drivingstress.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_drivingstress.m	(revision 4330)
@@ -11,11 +11,11 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
-[dstress isongrid isquiver]=processdata(md,s,options);
+[x y z elements is2d]=processmesh(md,[],options);
+[dstress datatype]=processdata(md,s,options);
 dstress=dstress/1000;
 
 %plot mesh quivervel
 subplot(width,width,i); 
-plot_unit(x,y,z,elements,dstress,isongrid,is2d,isquiver,options)
+plot_unit(x,y,z,elements,dstress,is2d,datatype,options)
 
 %apply options
Index: /issm/trunk/src/m/classes/public/plot/plot_elementnumbering.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_elementnumbering.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_elementnumbering.m	(revision 4330)
@@ -10,6 +10,6 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
-[elementnumbers isgrid]=processdata(md,[1:md.numberofelements]',options);
+[x y z elements is2d]=processmesh(md,[],options);
+[elementnumbers datatype]=processdata(md,[1:md.numberofelements]',options);
 
 %plot
Index: /issm/trunk/src/m/classes/public/plot/plot_elementstype.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_elementstype.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_elementstype.m	(revision 4330)
@@ -8,7 +8,7 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
-[data1 isongrid isquiver]=processdata(md,md.elements_type(:,1),options);
-[data2 isongrid isquiver]=processdata(md,md.elements_type(:,2),options);
+[x y z elements is2d]=processmesh(md,[],options);
+[data1 datatype]=processdata(md,md.elements_type(:,1),options);
+[data2 datatype]=processdata(md,md.elements_type(:,2),options);
 data=[data1 data2];
 
Index: /issm/trunk/src/m/classes/public/plot/plot_gridnumbering.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_gridnumbering.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_gridnumbering.m	(revision 4330)
@@ -8,6 +8,6 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
-[gridnumbers isongrid isquiver]=processdata(md,[1:md.numberofgrids]',options);
+[x y z elements is2d]=processmesh(md,[],options);
+[gridnumbers datatype]=processdata(md,[1:md.numberofgrids]',options);
 
 %plot
Index: /issm/trunk/src/m/classes/public/plot/plot_highlightelements.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_highlightelements.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_highlightelements.m	(revision 4330)
@@ -11,6 +11,6 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
-[elementnumbers isgrid]=processdata(md,[1:md.numberofelements]',options);
+[x y z elements is2d]=processmesh(md,[],options);
+[elementnumbers datatype]=processdata(md,[1:md.numberofelements]',options);
 
 %plot
Index: /issm/trunk/src/m/classes/public/plot/plot_highlightgrids.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_highlightgrids.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_highlightgrids.m	(revision 4330)
@@ -8,6 +8,6 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
-[gridnumbers isongrid isquiver]=processdata(md,[1:md.numberofgrids]',options);
+[x y z elements is2d]=processmesh(md,[],options);
+[gridnumbers datatype]=processdata(md,[1:md.numberofgrids]',options);
 
 %plot
Index: /issm/trunk/src/m/classes/public/plot/plot_importancefactors.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_importancefactors.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_importancefactors.m	(revision 4330)
@@ -64,5 +64,5 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
+[x y z elements is2d]=processmesh(md,[],options);
 
 %edgecolor
Index: /issm/trunk/src/m/classes/public/plot/plot_manager.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_manager.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_manager.m	(revision 4330)
@@ -127,6 +127,6 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
-[data2 isongrid isquiver]=processdata(md,data,options);
+[x y z elements is2d]=processmesh(md,data,options);
+[data2 datatype]=processdata(md,data,options);
 
 %standard plot:
@@ -139,13 +139,14 @@
 
 %plot unit
-plot_unit(x,y,z,elements,data2,isongrid,is2d,isquiver,options);
+plot_unit(x,y,z,elements,data2,is2d,datatype,options);
 
 %apply all options
-if isquiver
+if datatype==3,
 	options=changefieldvalue(options,'colorbar',2);
+	if exist(options,'contourlevels'),
+		data2=data;
+	end
 end
-if isquiver & exist(options,'contourlevels'),
-	data2=data;
-end
+
 applyoptions(md,data2,options);
 
@@ -169,5 +170,5 @@
 	axes('pos',PosInset);
 	box('on')
-	plot_unit(x,y,z,elements,data2,isongrid,is2d,isquiver,options);
+	plot_unit(x,y,z,elements,data2,is2d,datatype,options);
 
 	%applay options
Index: /issm/trunk/src/m/classes/public/plot/plot_mesh.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_mesh.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_mesh.m	(revision 4330)
@@ -8,5 +8,5 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
+[x y z elements is2d]=processmesh(md,[],options);
 
 %plot mesh
Index: /issm/trunk/src/m/classes/public/plot/plot_overlay.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_overlay.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_overlay.m	(revision 4330)
@@ -8,6 +8,6 @@
 
 %process mesh and data
-[x y z elements is2d]=processmesh(md,options);
-[data isongrid isquiver]=processdata(md,data,options);
+[x y z elements is2d]=processmesh(md,[],options);
+[data datatype]=processdata(md,data,options);
 
 %check is2d
@@ -15,5 +15,5 @@
 	error('buildoverlay error message: overlay not supported for 3d meshes, project on a layer');
 end
-if isquiver
+if datatype==3,
 	error('buildoverlay error message: overlay not supported for quiver plots');
 end
Index: /issm/trunk/src/m/classes/public/plot/plot_penalties.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_penalties.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_penalties.m	(revision 4330)
@@ -8,5 +8,5 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
+[x y z elements is2d]=processmesh(md,[],options);
 
 %plot mesh penalties
Index: /issm/trunk/src/m/classes/public/plot/plot_pressureload.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_pressureload.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_pressureload.m	(revision 4330)
@@ -11,5 +11,5 @@
 
 %process mesh and data
-[x y z elements is2d]=processmesh(md,options);
+[x y z elements is2d]=processmesh(md,[],options);
 pressureload=md.pressureload;
 
Index: /issm/trunk/src/m/classes/public/plot/plot_riftfraction.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_riftfraction.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_riftfraction.m	(revision 4330)
@@ -13,5 +13,5 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
+[x y z elements is2d]=processmesh(md,[],options);
 
 subplot(nlines,ncols,index); 
Index: /issm/trunk/src/m/classes/public/plot/plot_riftpenetration.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_riftpenetration.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_riftpenetration.m	(revision 4330)
@@ -8,5 +8,5 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
+[x y z elements is2d]=processmesh(md,[],options);
 
 subplot(nlines,ncols,index); 
Index: /issm/trunk/src/m/classes/public/plot/plot_riftrelvel.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_riftrelvel.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_riftrelvel.m	(revision 4330)
@@ -26,6 +26,6 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
-[vel isongrid isquiver]=processdata(md,[u v],options);
+[x y z elements is2d]=processmesh(md,[],options);
+[vel datatype]=processdata(md,[u v],options);
 [quivers,palette]=quiver_process(x,y,vel(:,1),vel(:,2),options);
 
Index: /issm/trunk/src/m/classes/public/plot/plot_rifts.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_rifts.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_rifts.m	(revision 4330)
@@ -8,5 +8,5 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
+[x y z elements is2d]=processmesh(md,[],options);
 
 %plot mesh
Index: /issm/trunk/src/m/classes/public/plot/plot_riftvel.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_riftvel.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_riftvel.m	(revision 4330)
@@ -26,6 +26,6 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
-[vel isongrid isquiver]=processdata(md,[u v],options);
+[x y z elements is2d]=processmesh(md,[],options);
+[vel datatype]=processdata(md,[u v],options);
 [quivers,palette]=quiver_process(x,y,vel(:,1),vel(:,2),options);
 
Index: /issm/trunk/src/m/classes/public/plot/plot_section.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_section.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_section.m	(revision 4330)
@@ -21,6 +21,6 @@
 
 %process data and model
-[x_m y_m z_m elements_m is2d]=processmesh(md,options);
-[data isongrid isquiver]=processdata(md,data,options);
+[x_m y_m z_m elements_m is2d]=processmesh(md,[],options);
+[data datatype]=processdata(md,data,options);
 
 %replug x and y onto model so that SectionValue treats the problem correctly
@@ -38,5 +38,5 @@
 
 %Compute section value
-if isquiver
+if datatype==3,
 	[elements,x,y,z,s,data_s1]=SectionValues(md,data(:,1),getfieldvalue(options,'sectionvalue'),resolution);
 	[elements,x,y,z,s,data_s2]=SectionValues(md,data(:,2),getfieldvalue(options,'sectionvalue'),resolution);
@@ -65,5 +65,5 @@
 		%plot section only with labels
 		subplot(width,width,index2)
-		plot_unit(x_m,y_m,z_m,elements_m,data,isongrid,is2d,isquiver,options)
+		plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options)
 		hold on
 		text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
@@ -79,5 +79,5 @@
 	%plot section value
 	subplot(width,width,index1)
-	if isquiver
+	if datatype==3,
 		plot(s,data_s1,s,data_s2);
 	else
@@ -108,5 +108,5 @@
 			%plot section only with labels
 			subplot(width,width,index2)
-			plot_unit(x_m,y_m,z_m,elements_m,data,isongrid,is2d,isquiver,options)
+			plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options)
 			hold on
 			text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
@@ -143,5 +143,5 @@
 			%plot section only with labels
 			subplot(width,width,index2)
-			plot_unit(x_m,y_m,z_m,elements_m,data,isongrid,is2d,isquiver,options)
+			plot_unit(x_m,y_m,z_m,elements_m,data,is2d,datatype,options)
 			hold on
 			text(x(1),y(1),'1','backgroundcolor',[0.8 0.9 0.8])
Index: /issm/trunk/src/m/classes/public/plot/plot_segmentnumbering.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_segmentnumbering.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_segmentnumbering.m	(revision 4330)
@@ -11,5 +11,5 @@
 
 %process data and model
-[x y z segments is2d]=processmesh(md,options);
+[x y z segments is2d]=processmesh(md,[],options);
 
 error('not implemented yet');
Index: /issm/trunk/src/m/classes/public/plot/plot_segments.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_segments.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_segments.m	(revision 4330)
@@ -11,5 +11,5 @@
 
 %process mesh and data
-[x y z elements is2d]=processmesh(md,options);
+[x y z elements is2d]=processmesh(md,[],options);
 segments=md.segments;
 
Index: /issm/trunk/src/m/classes/public/plot/plot_streamlines.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_streamlines.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_streamlines.m	(revision 4330)
@@ -6,7 +6,7 @@
 
 %process data and model
-[x y z index is2d]=processmesh(md,options);
-[u isongrid isquiver]=processdata(md,md.vx,options);
-[v isongrid isquiver]=processdata(md,md.vy,options);
+[x y z index is2d]=processmesh(md,[],options);
+[u datatype]=processdata(md,md.vx,options);
+[v datatype]=processdata(md,md.vy,options);
 
 %some checks
Index: /issm/trunk/src/m/classes/public/plot/plot_tensor_components.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_tensor_components.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_tensor_components.m	(revision 4330)
@@ -24,42 +24,42 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
-[tensor.xx isongrid isquiver]=processdata(md,tensor.xx,options);
-[tensor.yy isongrid isquiver]=processdata(md,tensor.yy,options);
-[tensor.xy isongrid isquiver]=processdata(md,tensor.xy,options);
+[x y z elements is2d]=processmesh(md,[],options);
+[tensor.xx datatype]=processdata(md,tensor.xx,options);
+[tensor.yy datatype]=processdata(md,tensor.yy,options);
+[tensor.xy datatype]=processdata(md,tensor.xy,options);
 if  md.dim==3
-	[tensor.xz isongrid isquiver]=processdata(md,tensor.xz,options);
-	[tensor.yz isongrid isquiver]=processdata(md,tensor.yz,options);
-	[tensor.zz isongrid isquiver]=processdata(md,tensor.zz,options);
+	[tensor.xz datatype]=processdata(md,tensor.xz,options);
+	[tensor.yz datatype]=processdata(md,tensor.yz,options);
+	[tensor.zz datatype]=processdata(md,tensor.zz,options);
 end
 
 if ((md.dim==2)),
 	subplot(2*width,2*width,index1),
-	plot_unit(x,y,z,elements,tensor.xx,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.xx,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'xx')
 	subplot(2*width,2*width,index2),
-	plot_unit(x,y,z,elements,tensor.yy,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.yy,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'yy')
 	subplot(2*width,2*width,index3),
-	plot_unit(x,y,z,elements,tensor.xy,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.xy,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'xy')
 else
 	subplot(3*width,3*width,index1),
-	plot_unit(x,y,z,elements,tensor.xx,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.xx,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'xx')
 	subplot(3*width,3*width,index2),
-	plot_unit(x,y,z,elements,tensor.yy,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.yy,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'yy')
 	subplot(3*width,3*width,index3),
-	plot_unit(x,y,z,elements,tensor.zz,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.zz,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'zz')
 	subplot(3*width,3*width,index4),
-	plot_unit(x,y,z,elements,tensor.xy,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.xy,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'xy')
 	subplot(3*width,3*width,index5),
-	plot_unit(x,y,z,elements,tensor.xz,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.xz,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'xz')
 	subplot(3*width,3*width,index6),
-	plot_unit(x,y,z,elements,tensor.yz,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.yz,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'yz')
 end
Index: /issm/trunk/src/m/classes/public/plot/plot_tensor_principal.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_tensor_principal.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_tensor_principal.m	(revision 4330)
@@ -37,27 +37,27 @@
 
 %now plot principal values
-[x y z elements is2d]=processmesh(md,options);
-[tensor.principalvalue1 isongrid isquiver]=processdata(md,tensor.principalvalue1,options);
-[tensor.principalvalue2 isongrid isquiver]=processdata(md,tensor.principalvalue2,options);
+[x y z elements is2d]=processmesh(md,[],options);
+[tensor.principalvalue1 datatype]=processdata(md,tensor.principalvalue1,options);
+[tensor.principalvalue2 datatype]=processdata(md,tensor.principalvalue2,options);
 if  md.dim==3
-	[tensor.principalvalue3 isongrid isquiver]=processdata(md,tensor.principalvalue3,options);
+	[tensor.principalvalue3 datatype]=processdata(md,tensor.principalvalue3,options);
 end
 
 if ((md.dim==2)),
 	subplot(2*width,2*width,index3)
-	plot_unit(x,y,z,elements,tensor.principalvalue1,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.principalvalue1,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'principal value 1')
 	subplot(2*width,2*width,index4)
-	plot_unit(x,y,z,elements,tensor.principalvalue2,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.principalvalue2,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'principal value 2')
 else
 	subplot(3*width,3*width,index4)
-	plot_unit(x,y,z,elements,tensor.principalvalue1,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.principalvalue1,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'principal value 1')
 	subplot(3*width,3*width,index5)
-	plot_unit(x,y,z,elements,tensor.principalvalue2,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.principalvalue2,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'principal value 2')
 	subplot(3*width,3*width,index6)
-	plot_unit(x,y,z,elements,tensor.principalvalue3,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,tensor.principalvalue3,is2d,datatype,options)
 	Apply_options_tensor(md,options,type,'principal value 3')
 end
Index: /issm/trunk/src/m/classes/public/plot/plot_tensor_principalaxis.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_tensor_principalaxis.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_tensor_principalaxis.m	(revision 4330)
@@ -11,22 +11,22 @@
 
 %process data and model
-[x y z elements is2d]=processmesh(md,options);
+[x y z elements is2d]=processmesh(md,[],options);
 
 if ((md.dim==2)),
 	eval(['Vx=tensor.principalaxis' type(end) '(:,1); Vy=tensor.principalaxis' type(end) '(:,2);'])
 	eval(['value=tensor.principalvalue' type(end) ';']);
-	[Vx isongrid isquiver]=processdata(md,Vx,options);
-	[Vy isongrid isquiver]=processdata(md,Vy,options);
-	[value isongrid isquiver]=processdata(md,value,options);
+	[Vx datatype]=processdata(md,Vx,options);
+	[Vy datatype]=processdata(md,Vy,options);
+	[value datatype]=processdata(md,value,options);
 else
 	eval(['Vx=tensor.principalaxis' type(end) '(:,1); Vy=tensor.principalaxis' type(end) '(:,2); Vz=tensor.principalaxis' type(end) '(:,3);'])
-	[Vx isongrid isquiver]=processdata(md,Vx,options);
-	[Vy isongrid isquiver]=processdata(md,Vy,options);
-	[Vz isongrid isquiver]=processdata(md,Vz,options);
-	[value isongrid isquiver]=processdata(md,value,options);
+	[Vx datatype]=processdata(md,Vx,options);
+	[Vy datatype]=processdata(md,Vy,options);
+	[Vz datatype]=processdata(md,Vz,options);
+	[value datatype]=processdata(md,value,options);
 end
 
 %take the center of each element if ~isongrid
-if ~isongrid
+if datatype==1,
 	x=mean(md.x(md.elements'))'; y=mean(md.y(md.elements'))'; z=mean(md.z(md.elements'))';
 end
Index: /issm/trunk/src/m/classes/public/plot/plot_transient_field.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_transient_field.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_transient_field.m	(revision 4330)
@@ -44,5 +44,5 @@
 
 %process mes only once
-[x y z elements is2d]=processmesh(md,options);
+[x y z elements is2d]=processmesh(md,[],options);
 
 %plot data for all steps
@@ -50,10 +50,10 @@
 
 	%process data and change title if needed
-	[data isongrid isquiver]=processdata(md,md.results.transient(steps(i)).(field),options);
+	[data datatype]=processdata(md,md.results.transient(steps(i)).(field),options);
 	options=changefieldvalue(options,'title',[field ' at time ' num2str(md.results.transient(steps(i)).time) ' a']);
 
 	%create plot of step i
 	subplot(subplotwidth,subplotwidth,i);
-	plot_unit(x,y,z,elements,data,isongrid,is2d,isquiver,options)
+	plot_unit(x,y,z,elements,data,is2d,datatype,options)
 	applyoptions(md,data,options);
 
Index: /issm/trunk/src/m/classes/public/plot/plot_transient_movie.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_transient_movie.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_transient_movie.m	(revision 4330)
@@ -17,5 +17,5 @@
 
 	%process model
-	[x y z elements is2d]=processmesh(md,options);
+	[x y z elements is2d]=processmesh(md,[],options);
 
 	%loop over the time steps
@@ -24,7 +24,7 @@
 
 		%process data
-		[data isongrid isquiver]=processdata(md,data,options);
+		[data datatype]=processdata(md,data,options);
 		titlestring=[field ' at time ' num2str(md.results.transient(i).time) ' year'];
-		plot_unit(x,y,z,elements,data,isongrid,is2d,isquiver,options)
+		plot_unit(x,y,z,elements,data,is2d,datatype,options)
 		apply_options_movie(md,options,titlestring);
 		
Index: /issm/trunk/src/m/classes/public/plot/plot_unit.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/plot_unit.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/plot_unit.m	(revision 4330)
@@ -1,7 +1,7 @@
-function plot_unit(x,y,z,elements,data,isongrid,is2d,isquiver,options)
+function plot_unit(x,y,z,elements,data,is2d,datatype,options)
 %PLOT_UNIT - unit plot, display data
 %
 %   Usage:
-%      plot_unit(x,y,z,elements,data,isongrid,is2d,isquiver,options);
+%      plot_unit(x,y,z,elements,data,is2d,datatype,options);
 %
 %   See also: PLOTMODEL, PLOT_MANAGER
@@ -14,9 +14,9 @@
 %set(gca,'pos',P);
 
-%regular plot
-if ~isquiver,
+switch datatype,
 
-	%element data
-	if ~isongrid
+	%element plot
+	case 1,
+
 		pos=find(~isnan(data)); %needed fpr element on water
 		if is2d,
@@ -32,6 +32,7 @@
 		end
 
-	%grid data
-	elseif isongrid
+	%node plot
+	case 2,
+
 		if is2d,
 			A=elements(:,1); B=elements(:,2); C=elements(:,3); 
@@ -45,11 +46,8 @@
 			patch( 'Faces', [C A D F ], 'Vertices', [x y z],'FaceVertexCData', data(:),'FaceColor','interp','EdgeColor',edgecolor);
 		end
-	end
 
-%quiver
-elseif isquiver,
+	%quiver plot
+	case 3,
 
-	%grid data
-	if isongrid,
 		if is2d,
 			plot_quiver(x,y,data(:,1),data(:,2),options);
@@ -57,6 +55,22 @@
 			plot_quiver3(x,y,z,data(:,1),data(:,2),data(:,3),options);
 		end
-	else
-		error('plot_unit error message: element quiver not implemented yet')
+
+	%Patch plot
+	case 4,
+
+		if is2d,
+			patch( 'Faces',elements,'Vertices',[x y],'CData',data,'FaceColor','interp','EdgeColor',edgecolor);
+		else
+			A=elements(:,1); B=elements(:,2); C=elements(:,3); D=elements(:,4); E=elements(:,5); F=elements(:,6);
+			patch( 'Faces', [A B C], 'Vertices', [x y z],'CData', data,'FaceColor','flat','EdgeColor',edgecolor);
+			patch( 'Faces', [D E F], 'Vertices', [x y z],'CData', data,'FaceColor','flat','EdgeColor',edgecolor);
+			patch( 'Faces', [A B E D], 'Vertices', [x y z],'CData', data,'FaceColor','flat','EdgeColor',edgecolor);
+			patch( 'Faces', [B E F C ], 'Vertices', [x y z],'CData', data,'FaceColor','flat','EdgeColor',edgecolor);
+			patch( 'Faces', [C A D F ], 'Vertices', [x y z],'CData', data,'FaceColor','flat','EdgeColor',edgecolor);
+		end
+
+	otherwise,
+		error(['case ' num2str(datatype) ' not supported']);
+
 	end
 end
Index: /issm/trunk/src/m/classes/public/plot/processdata.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/processdata.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/processdata.m	(revision 4330)
@@ -1,85 +1,113 @@
-function [data isongrid isquiver]=processdata(md,data,options);
+function [data datatype]=processdata(md,data,options);
 %PROCESSDATA - process data to be plotted
 %
+%   datatype = 1 -> elements
+%   datatype = 2 -> nodes
+%   datatype = 3 -> node quivers
+%   datatype = 4 -> patch
+%
 %   Usage:
-%      [data isongrid isquiver]=processdata(md,data,options);
+%      [data datatype]=processdata(md,data,options);
 %
 %   See also: PLOTMODEL, PROCESSMESH
 
 %check format
-if (iscell(data) | isempty(data) | length(data)==1),
+if (iscell(data) | isempty(data) | length(data)==0),
 	error('plotmodel error message: data provided is empty');
 end
 
-%transpose data if necessary
-if (size(data,2) > size(data,1)),
-	data=data';
+%Process Patch
+if isstruct(data) 
+	if (isfield(data,'index') & isfield(data,'value')),
+		data=data.value;
+		data=data';
+		data=data(:);
+		datatype=4;
+	else
+		error('structure other than Patch not supported yet');
+	end
+else
+	%initialize datatype
+	datatype=0;
 end
+
+%get datatype
 datasize=size(data);
 
-%convert to double if necessary
-if ~isnumeric(data);
-	disp('processdata info message: data is not numeric (logical?). Converted to double');
-	data=double(data);
-end
+%non patch processing
+if datatype~=4,
 
-%check length
-if datasize(1)~=md.numberofgrids & datasize(1)~=md.numberofelements & datasize(1)~=md.numberofgrids*6 & (md.dim==3 & ~(datasize(1)==md.numberofelements2d | datasize(1)==md.numberofgrids2d))
-	error('plotmodel error message: data not supported yet');
-end
+	%transpose data if necessary
+	if (size(data,2) > size(data,1)),
+		data=data';
+	end
+	datasize=size(data);
 
-%isquiver?
-if datasize(2)>1,
-	isquiver=1;
-
-	%check number of columns, add zeros if necessary,
-	if (md.dim==3)
-		if datasize(2)==2,
-			data=[data, zeros(datasize(1),1)];
-		elseif datasize(2)~=3,
-			error('plotmodel error message: data provided should have 2 or 3 columns for quiver plot, and 1 for regular plot');
-		end
-	elseif ((md.dim==2) & datasize(2)~=2),
-		error('plotmodel error message: data provided should have 2 columns for quiver plot, and 1 for regular plot');
+	%convert to double if necessary
+	if ~isnumeric(data);
+		disp('processdata info message: data is not numeric (logical?). Converted to double');
+		data=double(data);
 	end
 
-else
-	isquiver=0;
-end
+	%check length
+	if datasize(1)~=md.numberofgrids & datasize(1)~=md.numberofelements & datasize(1)~=md.numberofgrids*6 & (md.dim==3 & ~(datasize(1)==md.numberofelements2d | datasize(1)==md.numberofgrids2d))
+		error('plotmodel error message: data not supported yet');
+	end
 
-%treat the case datasize(1)=6*grids
-if datasize(1)==6*md.numberofgrids
-	%keep the only norm of data
-	data1=data(1:6:md.numberofgrids*6,:);
-	data2=data(2:6:md.numberofgrids*6,:);
-	data=sqrt(data1.^2+data2.^2);
-	datasize(1)=md.numberofgrids;
-	%---> go to grid data
-end
+	%quiver?
+	if datasize(2)>1,
+		datatype=3;
 
-%treat the case datasize(1)=grids2d
-if (md.dim==3 & datasize(1)==md.numberofgrids2d),
-	data=project3d(md,data,'node');
-	datasize(1)=md.numberofgrids;
-	%---> go to grid data
-end
+		%check number of columns, add zeros if necessary,
+		if (md.dim==3)
+			if datasize(2)==2,
+				data=[data, zeros(datasize(1),1)];
+			elseif datasize(2)~=3,
+				error('plotmodel error message: data provided should have 2 or 3 columns for quiver plot, and 1 for regular plot');
+			end
+		elseif ((md.dim==2) & datasize(2)~=2),
+			error('plotmodel error message: data provided should have 2 columns for quiver plot, and 1 for regular plot');
+		end
+	end
 
-%treat the case datasize(1)=grids2d
-if (md.dim==3 & datasize(1)==md.numberofelements2d),
-	data=project3d(md,data,'element');
-	datasize(1)=md.numberofelements;
-	%---> go to grid data
-end
+	%treat the case datasize(1)=6*grids
+	if datasize(1)==6*md.numberofgrids
+		%keep the only norm of data
+		data1=data(1:6:md.numberofgrids*6,:);
+		data2=data(2:6:md.numberofgrids*6,:);
+		data=sqrt(data1.^2+data2.^2);
+		datasize(1)=md.numberofgrids;
+		%---> go to grid data
+	end
 
-%smoothing?
-if exist(options,'smooth')
-	data=averaging(md,data,getfieldvalue(options,'smooth'));
-	datasize(1)=md.numberofgrids;
-	%---> go to grid data
+	%treat the case datasize(1)=grids2d
+	if (md.dim==3 & datasize(1)==md.numberofgrids2d),
+		data=project3d(md,data,'node');
+		datasize(1)=md.numberofgrids;
+		%---> go to grid data
+	end
+
+	%treat the case datasize(1)=grids2d
+	if (md.dim==3 & datasize(1)==md.numberofelements2d),
+		data=project3d(md,data,'element');
+		datasize(1)=md.numberofelements;
+		%---> go to grid data
+	end
+
+	%smoothing?
+	if exist(options,'smooth')
+		data=averaging(md,data,getfieldvalue(options,'smooth'));
+		datasize(1)=md.numberofgrids;
+		%---> go to grid data
+	end
 end
 
 %element data
 if datasize(1)==md.numberofelements;
-	isongrid=0;
+
+	%Initialize datatype if non patch
+	if datatype~=4,
+		datatype=1;
+	end
 
 	%ice sheet only?
@@ -104,5 +132,5 @@
 %grid data
 if datasize(1)==md.numberofgrids
-	isongrid=1;
+	datatype=1;
 	%ice sheet only?
 	if getfieldvalue(options,'iceshelf',1)==0,
@@ -133,5 +161,5 @@
 
 %control arrow density if quiverplot
-if isquiver & exist(options,'density')
+if datatype==3 & exist(options,'density')
 	databak=data;
 	data=NaN*ones(datasize);
Index: /issm/trunk/src/m/classes/public/plot/processmesh.m
===================================================================
--- /issm/trunk/src/m/classes/public/plot/processmesh.m	(revision 4329)
+++ /issm/trunk/src/m/classes/public/plot/processmesh.m	(revision 4330)
@@ -1,7 +1,7 @@
-function [x y z elements is2d]=processmesh(md,options);
+function [x y z elements is2d]=processmesh(md,data,options);
 %PROCESSMESH - process mesh to be plotted
 %
 %   Usage:
-%      [x y z elements is2d]=processmesh(md,options)
+%      [x y z elements is2d]=processmesh(md,data,options)
 %
 %   See also: PLOTMODEL, PROCESSDATA
@@ -12,34 +12,43 @@
 end
 
-%first load x,y, etc ... to speed up plot
-x=md.x;
-x2d=md.x2d;
-y=md.y;
-y2d=md.y2d;
-z=md.z;
-z2d=md.z2d;
-elements2d=md.elements2d;
-elements=md.elements;
-elements_type2d=md.elements_type2d;
+if (isempty(data) | ~isstruct(data)),
+	%first load x,y, etc ... to speed up plot
+	x=md.x;
+	x2d=md.x2d;
+	y=md.y;
+	y2d=md.y2d;
+	z=md.z;
+	z2d=md.z2d;
+	elements2d=md.elements2d;
+	elements=md.elements;
+	elements_type2d=md.elements_type2d;
 
-%is it a 2d plot?
-if (md.dim==2);
-	is2d=1;
-else
-	if getfieldvalue(options,'layer',0)>=1,
+	%is it a 2d plot?
+	if (md.dim==2);
 		is2d=1;
 	else
-		is2d=0;
+		if getfieldvalue(options,'layer',0)>=1,
+			is2d=1;
+		else
+			is2d=0;
+		end
 	end
-end
 
-%layer projection? 
-if getfieldvalue(options,'layer',0)>=1,
-	%we modify the mesh temporarily to a 2d mesh from which the 3d mesh was extruded. 
-	x=x2d;
-	y=y2d;
-	z=z2d;
-	elements=elements2d;
-	elements_type=elements_type2d;
+	%layer projection? 
+	if getfieldvalue(options,'layer',0)>=1,
+		%we modify the mesh temporarily to a 2d mesh from which the 3d mesh was extruded. 
+		x=x2d;
+		y=y2d;
+		z=z2d;
+		elements=elements2d;
+		elements_type=elements_type2d;
+	end
+else
+	%Process Patch
+	elements=transpose(reshape(1:3*md.numberofelements,3,md.numberofelements));
+	x=transpose(reshape(md.x(data.index)',1,3*md.numberofelements));
+	y=transpose(reshape(md.y(data.index)',1,3*md.numberofelements));
+	z=zeros(3*md.numberofelements,1);
+	is2d=1;
 end
 
