source: issm/trunk/src/m/model/collapse.m@ 11995

Last change on this file since 11995 was 11995, checked in by Mathieu Morlighem, 13 years ago

merged trunk-jpl and trunk for revision 11994M

File size: 5.7 KB
RevLine 
[1]1function md=collapse(md)
2%COLLAPSE - collapses a 3d mesh into a 2d mesh
3%
4% This routine collapses a 3d model into a 2d model
5% and collapses all the fileds of the 3d model by
6% taking their depth-averaged values
7%
8% Usage:
9% md=collapse(md)
10%
11% See also: EXTRUDE, MODELEXTRACT
12
13%Check that the model is really a 3d model
[9719]14if ~md.mesh.dimension==3,
[1]15 error('collapse error message: only 3d mesh can be collapsed')
16end
17
18%Start with changing alle the fields from the 3d mesh
19
[8298]20%drag is limited to nodes that are on the bedrock.
[9610]21md.friction.coefficient=project2d(md,md.friction.coefficient,1);
[1]22
23%p and q (same deal, except for element that are on the bedrock: )
[9610]24md.friction.p=project2d(md,md.friction.p,1);
25md.friction.q=project2d(md,md.friction.q,1);
[1]26
27%observations
[9725]28if ~isnan(md.inversion.vx_obs), md.inversion.vx_obs=project2d(md,md.inversion.vx_obs,md.mesh.numberoflayers); end;
29if ~isnan(md.inversion.vy_obs), md.inversion.vy_obs=project2d(md,md.inversion.vy_obs,md.mesh.numberoflayers); end;
30if ~isnan(md.inversion.vel_obs), md.inversion.vel_obs=project2d(md,md.inversion.vel_obs,md.mesh.numberoflayers); end;
[11527]31if ~isnan(md.inversion.cost_functions_coefficients), md.inversion.cost_functions_coefficients=project2d(md,md.inversion.cost_functions_coefficients,md.mesh.numberoflayers); end;
32if ~isnan(md.inversion.min_parameters), md.inversion.min_parameters=project2d(md,md.inversion.min_parameters,md.mesh.numberoflayers); end;
33if ~isnan(md.inversion.max_parameters), md.inversion.max_parameters=project2d(md,md.inversion.max_parameters,md.mesh.numberoflayers); end;
[9607]34if ~isnan(md.surfaceforcings.mass_balance),
[9725]35 md.surfaceforcings.mass_balance=project2d(md,md.surfaceforcings.mass_balance,md.mesh.numberoflayers);
[9607]36end;
[9725]37if ~isnan(md.balancethickness.thickening_rate), md.balancethickness.thickening_rate=project2d(md,md.balancethickness.thickening_rate,md.mesh.numberoflayers); end;
[1]38
39%results
[9684]40if ~isnan(md.initialization.vx),md.initialization.vx=DepthAverage(md,md.initialization.vx);end;
41if ~isnan(md.initialization.vy),md.initialization.vy=DepthAverage(md,md.initialization.vy);end;
42if ~isnan(md.initialization.vz),md.initialization.vz=DepthAverage(md,md.initialization.vz);end;
43if ~isnan(md.initialization.vel),md.initialization.vel=DepthAverage(md,md.initialization.vel);end;
[1]44
45%bedinfo and surface info
[9729]46md.mesh.elementonbed=ones(md.mesh.numberofelements2d,1);
47md.mesh.elementonsurface=ones(md.mesh.numberofelements2d,1);
48md.mesh.vertexonbed=ones(md.mesh.numberofvertices2d,1);
49md.mesh.vertexonsurface=ones(md.mesh.numberofvertices2d,1);
[1]50
51%elementstype
[9661]52if ~isnan(md.flowequation.element_equation)
53 md.flowequation.element_equation=project2d(md,md.flowequation.element_equation,1);
[11527]54 md.flowequation.vertex_equation=project2d(md,md.flowequation.vertex_equation,1);
55 md.flowequation.bordermacayeal=project2d(md,md.flowequation.bordermacayeal,1);
56 md.flowequation.borderpattyn=project2d(md,md.flowequation.borderpattyn,1);
57 md.flowequation.borderstokes=project2d(md,md.flowequation.borderstokes,1);
[1]58end
59
60%boundary conditions
[9725]61md.diagnostic.spcvx=project2d(md,md.diagnostic.spcvx,md.mesh.numberoflayers);
62md.diagnostic.spcvy=project2d(md,md.diagnostic.spcvy,md.mesh.numberoflayers);
63md.diagnostic.spcvz=project2d(md,md.diagnostic.spcvz,md.mesh.numberoflayers);
[11527]64md.diagnostic.referential=project2d(md,md.diagnostic.referential,md.mesh.numberoflayers);
[9725]65md.prognostic.spcthickness=project2d(md,md.prognostic.spcthickness,md.mesh.numberoflayers);
66md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.mesh.numberoflayers);
[1]67
68%Extrusion of Neumann BC
[9679]69if ~isnan(md.diagnostic.icefront),
[11527]70 numberofneumann2d=size(md.diagnostic.icefront,1)/(md.mesh.numberoflayers-1);
[9679]71 md.diagnostic.icefront=[md.diagnostic.icefront(1:numberofneumann2d,1:2) md.diagnostic.icefront(1:numberofneumann2d,5:6)]; %Add two columns on the first layer
[6412]72end
[1]73
74%materials
[9636]75md.materials.rheology_B=DepthAverage(md,md.materials.rheology_B);
76md.materials.rheology_n=project2d(md,md.materials.rheology_n,1);
[1]77
78%special for thermal modeling:
[9612]79md.basalforcings.melting_rate=project2d(md,md.basalforcings.melting_rate,1);
80md.basalforcings.geothermalflux=project2d(md,md.basalforcings.geothermalflux,1); %bedrock only gets geothermal flux
[1]81
82%update of connectivity matrix
[9705]83md.mesh.average_vertex_connectivity=25;
[1]84
85%Collapse the mesh
[9725]86nodes2d=md.mesh.numberofvertices2d;
87elements2d=md.mesh.numberofelements2d;
[1]88
89%parameters
[9691]90md.geometry.surface=project2d(md,md.geometry.surface,1);
91md.geometry.thickness=project2d(md,md.geometry.thickness,1);
92md.geometry.bed=project2d(md,md.geometry.bed,1);
[9714]93md.mesh.vertexonboundary=project2d(md,md.mesh.vertexonboundary,1);
[11995]94md.mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1);
[9641]95md.mask.elementonfloatingice=project2d(md,md.mask.elementonfloatingice,1);
96md.mask.vertexonfloatingice=project2d(md,md.mask.vertexonfloatingice,1);
97md.mask.elementongroundedice=project2d(md,md.mask.elementongroundedice,1);
98md.mask.vertexongroundedice=project2d(md,md.mask.vertexongroundedice,1);
[11527]99md.mask.elementonwater=project2d(md,md.mask.elementonwater,1);
100md.mask.vertexonwater=project2d(md,md.mask.vertexonwater,1);
[1]101
[11995]102%lat long
103md.mesh.lat=project2d(md,md.mesh.lat,1);
104md.mesh.long=project2d(md,md.mesh.long,1);
105
[1]106%Initialize with the 2d mesh
[9734]107md.mesh.x=md.mesh.x2d;
108md.mesh.y=md.mesh.y2d;
109md.mesh.z=zeros(size(md.mesh.x2d));
[9725]110md.mesh.numberofvertices=md.mesh.numberofvertices2d;
111md.mesh.numberofelements=md.mesh.numberofelements2d;
[9733]112md.mesh.elements=md.mesh.elements2d;
[1]113
[8298]114%Keep a trace of lower and upper nodes
[9729]115md.mesh.lowervertex=NaN;
116md.mesh.uppervertex=NaN;
[11995]117md.mesh.lowerelements=NaN;
118md.mesh.upperelements=NaN;
[1]119
120%Remove old mesh
[9731]121md.mesh.x2d=NaN;
122md.mesh.y2d=NaN;
123md.mesh.elements2d=NaN;
[9725]124md.mesh.numberofelements2d=md.mesh.numberofelements;
125md.mesh.numberofvertices2d=md.mesh.numberofvertices;
126md.mesh.numberoflayers=0;
[1]127
128%Update mesh type
[9719]129md.mesh.dimension=2;
Note: See TracBrowser for help on using the repository browser.