Index: issm/trunk-jpl/src/m/classes/model.m
===================================================================
--- issm/trunk-jpl/src/m/classes/model.m	(revision 19040)
+++ issm/trunk-jpl/src/m/classes/model.m	(revision 19048)
@@ -750,103 +750,25 @@
 			%Ok, now deal with the other fields from the 2d mesh:
 
+			%bedinfo and surface info
+			md.mesh.vertexonbase=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',1);
+			md.mesh.vertexonsurface=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',md.mesh.numberoflayers);
+			md.mesh.vertexonboundary=project3d(md,'vector',md.mesh.vertexonboundary,'type','node');
+
 			%lat long
 			md.mesh.lat=project3d(md,'vector',md.mesh.lat,'type','node');
 			md.mesh.long=project3d(md,'vector',md.mesh.long,'type','node');
 
-			%drag coefficient is limited to nodes that are on the bedrock.
-			if isa(md.friction,'friction'),
-				md.friction.coefficient=project3d(md,'vector',md.friction.coefficient,'type','node','layer',1);
-				md.friction.p=project3d(md,'vector',md.friction.p,'type','element');
-				md.friction.q=project3d(md,'vector',md.friction.q,'type','element');
-			elseif isa(md.friction,'frictionhydro'),
-				md.friction.q=project3d(md,'vector',md.friction.q,'type','element');
-				md.friction.C=project3d(md,'vector',md.friction.C,'type','element');
-				md.friction.As=project3d(md,'vector',md.friction.As,'type','element');
-				md.friction.effective_pressure=project3d(md,'vector',md.friction.effective_pressure,'type','node','layer',1);
-			elseif isa(md.friction,'frictionwaterlayer'),
-				md.friction.coefficient=project3d(md,'vector',md.friction.coefficient,'type','node','layer',1);
-				md.friction.p=project3d(md,'vector',md.friction.p,'type','element');
-				md.friction.q=project3d(md,'vector',md.friction.q,'type','element');
-				md.friction.water_layer=project3d(md,'vector',md.friction.water_layer,'type','node','layer',1);
-			elseif isa(md.friction,'frictionweertman'),
-				md.friction.C=project3d(md,'vector',md.friction.C,'type','node','layer',1);
-				md.friction.m=project3d(md,'vector',md.friction.m,'type','element');
-	    end
-	 
-			%observations
-			md.inversion.vx_obs=project3d(md,'vector',md.inversion.vx_obs,'type','node');
-			md.inversion.vy_obs=project3d(md,'vector',md.inversion.vy_obs,'type','node');
-			md.inversion.vel_obs=project3d(md,'vector',md.inversion.vel_obs,'type','node');
-			md.inversion.thickness_obs=project3d(md,'vector',md.inversion.thickness_obs,'type','node');
+			md.geometry=extrude(md.geometry,md);
+			md.friction  = extrude(md.friction,md);
+			md.inversion = extrude(md.inversion,md);
 			md.surfaceforcings = extrude(md.surfaceforcings,md);
-			md.balancethickness.thickening_rate=project3d(md,'vector',md.balancethickness.thickening_rate,'type','node');
-
-			%results
-			if ~isnan(md.initialization.vx),md.initialization.vx=project3d(md,'vector',md.initialization.vx,'type','node');end;
-			if ~isnan(md.initialization.vy),md.initialization.vy=project3d(md,'vector',md.initialization.vy,'type','node');end;
-			if ~isnan(md.initialization.vz),md.initialization.vz=project3d(md,'vector',md.initialization.vz,'type','node');end;
-			if ~isnan(md.initialization.vel),md.initialization.vel=project3d(md,'vector',md.initialization.vel,'type','node');end;
-			if ~isnan(md.initialization.temperature),md.initialization.temperature=project3d(md,'vector',md.initialization.temperature,'type','node');end;
-			if ~isnan(md.initialization.waterfraction),md.initialization.waterfraction=project3d(md,'vector',md.initialization.waterfraction,'type','node');end;
-      if ~isnan(md.initialization.watercolumn),md.initialization.watercolumn=project3d(md,'vector',md.initialization.watercolumn,'type','node','layer',1);end;
-      if ~isnan(md.initialization.sediment_head),md.initialization.sediment_head=project3d(md,'vector',md.initialization.sediment_head,'type','node','layer',1);end;
-      if ~isnan(md.initialization.epl_head),md.initialization.epl_head=project3d(md,'vector',md.initialization.epl_head,'type','node','layer',1);end;
-      if ~isnan(md.initialization.epl_thickness),md.initialization.epl_thickness=project3d(md,'vector',md.initialization.epl_thickness,'type','node','layer',1);end;
-
-			%bedinfo and surface info
-			md.mesh.vertexonbase=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',1);
-			md.mesh.vertexonsurface=project3d(md,'vector',ones(md.mesh.numberofvertices2d,1),'type','node','layer',md.mesh.numberoflayers);
-
-			%elementstype
-			if ~isnan(md.flowequation.element_equation)
-				oldelements_type=md.flowequation.element_equation;
-				md.flowequation.element_equation=zeros(number_el3d,1);
-				md.flowequation.element_equation=project3d(md,'vector',oldelements_type,'type','element');
-			end
-
-			%verticestype
-			if ~isnan(md.flowequation.vertex_equation)
-				oldvertices_type=md.flowequation.vertex_equation;
-				md.flowequation.vertex_equation=zeros(number_nodes3d,1);
-				md.flowequation.vertex_equation=project3d(md,'vector',oldvertices_type,'type','node');
-			end
-			md.flowequation.borderSSA=project3d(md,'vector',md.flowequation.borderSSA,'type','node');
-			md.flowequation.borderHO=project3d(md,'vector',md.flowequation.borderHO,'type','node');
-			md.flowequation.borderFS=project3d(md,'vector',md.flowequation.borderFS,'type','node');
-
-			%boundary conditions
-			md.stressbalance.spcvx=project3d(md,'vector',md.stressbalance.spcvx,'type','node');
-			md.stressbalance.spcvy=project3d(md,'vector',md.stressbalance.spcvy,'type','node');
-			md.stressbalance.spcvz=project3d(md,'vector',md.stressbalance.spcvz,'type','node');
-			md.thermal.spctemperature=project3d(md,'vector',md.thermal.spctemperature,'type','node','layer',md.mesh.numberoflayers,'padding',NaN);
-			if (length(md.initialization.temperature)==md.mesh.numberofvertices),
-				md.thermal.spctemperature=NaN*ones(md.mesh.numberofvertices,1);
-				if isprop(md.mesh,'vertexonsurface'),
-					pos=find(md.mesh.vertexonsurface);
-					md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface
-				end
-			end
-			md.masstransport.spcthickness=project3d(md,'vector',md.masstransport.spcthickness,'type','node');
-			md.balancethickness.spcthickness=project3d(md,'vector',md.balancethickness.spcthickness,'type','node');
-			md.damage.spcdamage=project3d(md,'vector',md.damage.spcdamage,'type','node');
-			md.stressbalance.referential=project3d(md,'vector',md.stressbalance.referential,'type','node');
-			md.stressbalance.loadingforce=project3d(md,'vector',md.stressbalance.loadingforce,'type','node');
-
-			% Calving variables
-			if isa(md.calving,'calving'),md.calving.calvingrate=project3d(md,'vector',md.calving.calvingrate,'type','node');end;
-			if ~isnan(md.calving.meltingrate),md.calving.meltingrate=project3d(md,'vector',md.calving.meltingrate,'type','node');end;
-			if isa(md.calving,'calvinglevermann'),md.calving.coeff=project3d(md,'vector',md.calving.coeff,'type','node');end;
-			if isa(md.calving,'calvingpi'),md.calving.coeff=project3d(md,'vector',md.calving.coeff,'type','node');end;
-
-			% Hydrologydc variables
-			if isa(md.hydrology,'hydrologydc');
-				md.hydrology.spcsediment_head=project3d(md,'vector',md.hydrology.spcsediment_head,'type','node','layer',1);
-				md.hydrology.mask_eplactive_node=project3d(md,'vector',md.hydrology.mask_eplactive_node,'type','node','layer',1);
-				md.hydrology.sediment_transmitivity=project3d(md,'vector',md.hydrology.sediment_transmitivity,'type','node','layer',1);
-				md.hydrology.basal_moulin_input=project3d(md,'vector',md.hydrology.basal_moulin_input,'type','node','layer',1);
-				if(md.hydrology.isefficientlayer==1);
-					md.hydrology.spcepl_head=project3d(md,'vector',md.hydrology.spcepl_head,'type','node','layer',1);
-		    end
-	    end
+			md.initialization = extrude(md.initialization,md);
+
+			md.flowequation.extrude(md);
+			md.stressbalance=extrude(md.stressbalance,md);
+			md.thermal.extrude(md);
+			md.masstransport.extrude(md);
+			md.calving=extrude(md.calving,md);
+			md.hydrology = extrude(md.hydrology,md);
 
 			%connectivity
@@ -861,38 +783,9 @@
 			end
 
-			%materials
-			md.materials.rheology_B=project3d(md,'vector',md.materials.rheology_B,'type','node');
-			md.materials.rheology_n=project3d(md,'vector',md.materials.rheology_n,'type','element');
-				
-			%damage
-			md.damage.D=project3d(md,'vector',md.damage.D,'type','node');
-
-			%parameters
-			md.geometry.surface=project3d(md,'vector',md.geometry.surface,'type','node');
-			md.geometry.thickness=project3d(md,'vector',md.geometry.thickness,'type','node');
-			md.gia.mantle_viscosity=project3d(md,'vector',md.gia.mantle_viscosity,'type','node');
-			md.gia.lithosphere_thickness=project3d(md,'vector',md.gia.lithosphere_thickness,'type','node');
-			md.geometry.hydrostatic_ratio=project3d(md,'vector',md.geometry.hydrostatic_ratio,'type','node');
-			md.geometry.base=project3d(md,'vector',md.geometry.base,'type','node');
-			md.geometry.bed=project3d(md,'vector',md.geometry.bed,'type','node');
-			md.mesh.vertexonboundary=project3d(md,'vector',md.mesh.vertexonboundary,'type','node');
-			md.mask.groundedice_levelset=project3d(md,'vector',md.mask.groundedice_levelset,'type','node');
-			md.mask.ice_levelset=project3d(md,'vector',md.mask.ice_levelset,'type','node');
-			if ~isnan(md.inversion.cost_functions_coefficients),md.inversion.cost_functions_coefficients=project3d(md,'vector',md.inversion.cost_functions_coefficients,'type','node');end;
-			if ~isnan(md.inversion.min_parameters),md.inversion.min_parameters=project3d(md,'vector',md.inversion.min_parameters,'type','node');end;
-			if ~isnan(md.inversion.max_parameters),md.inversion.max_parameters=project3d(md,'vector',md.inversion.max_parameters,'type','node');end;
-			if ~isnan(md.qmu.partition),md.qmu.partition=project3d(md,'vector',md.qmu.partition','type','node');end
-
-			%Put lithostatic pressure if there is an existing pressure
-			if ~isnan(md.initialization.pressure),
-				md.initialization.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z);
-	    end
-
-			%special for thermal modeling:
-			md.basalforcings.groundedice_melting_rate=project3d(md,'vector',md.basalforcings.groundedice_melting_rate,'type','node','layer',1); 
-			md.basalforcings.floatingice_melting_rate=project3d(md,'vector',md.basalforcings.floatingice_melting_rate,'type','node','layer',1); 
-			if ~isnan(md.basalforcings.geothermalflux)
-				md.basalforcings.geothermalflux=project3d(md,'vector',md.basalforcings.geothermalflux,'type','node','layer',1); %bedrock only gets geothermal flux
-			end
+			md.materials=extrude(md.materials,md);
+			md.damage=extrude(md.damage,md);
+			md.mask=extrude(md.mask,md);
+			md.qmu=extrude(md.qmu,md);
+			md.basalforcings=extrude(md.basalforcings,md);
 
 			%increase connectivity if less than 25:
