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
Line 
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
14if ~md.mesh.dimension==3,
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
20%drag is limited to nodes that are on the bedrock.
21md.friction.coefficient=project2d(md,md.friction.coefficient,1);
22
23%p and q (same deal, except for element that are on the bedrock: )
24md.friction.p=project2d(md,md.friction.p,1);
25md.friction.q=project2d(md,md.friction.q,1);
26
27%observations
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;
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;
34if ~isnan(md.surfaceforcings.mass_balance),
35 md.surfaceforcings.mass_balance=project2d(md,md.surfaceforcings.mass_balance,md.mesh.numberoflayers);
36end;
37if ~isnan(md.balancethickness.thickening_rate), md.balancethickness.thickening_rate=project2d(md,md.balancethickness.thickening_rate,md.mesh.numberoflayers); end;
38
39%results
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;
44
45%bedinfo and surface info
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);
50
51%elementstype
52if ~isnan(md.flowequation.element_equation)
53 md.flowequation.element_equation=project2d(md,md.flowequation.element_equation,1);
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);
58end
59
60%boundary conditions
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);
64md.diagnostic.referential=project2d(md,md.diagnostic.referential,md.mesh.numberoflayers);
65md.prognostic.spcthickness=project2d(md,md.prognostic.spcthickness,md.mesh.numberoflayers);
66md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.mesh.numberoflayers);
67
68%Extrusion of Neumann BC
69if ~isnan(md.diagnostic.icefront),
70 numberofneumann2d=size(md.diagnostic.icefront,1)/(md.mesh.numberoflayers-1);
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
72end
73
74%materials
75md.materials.rheology_B=DepthAverage(md,md.materials.rheology_B);
76md.materials.rheology_n=project2d(md,md.materials.rheology_n,1);
77
78%special for thermal modeling:
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
81
82%update of connectivity matrix
83md.mesh.average_vertex_connectivity=25;
84
85%Collapse the mesh
86nodes2d=md.mesh.numberofvertices2d;
87elements2d=md.mesh.numberofelements2d;
88
89%parameters
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);
93md.mesh.vertexonboundary=project2d(md,md.mesh.vertexonboundary,1);
94md.mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1);
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);
99md.mask.elementonwater=project2d(md,md.mask.elementonwater,1);
100md.mask.vertexonwater=project2d(md,md.mask.vertexonwater,1);
101
102%lat long
103md.mesh.lat=project2d(md,md.mesh.lat,1);
104md.mesh.long=project2d(md,md.mesh.long,1);
105
106%Initialize with the 2d mesh
107md.mesh.x=md.mesh.x2d;
108md.mesh.y=md.mesh.y2d;
109md.mesh.z=zeros(size(md.mesh.x2d));
110md.mesh.numberofvertices=md.mesh.numberofvertices2d;
111md.mesh.numberofelements=md.mesh.numberofelements2d;
112md.mesh.elements=md.mesh.elements2d;
113
114%Keep a trace of lower and upper nodes
115md.mesh.lowervertex=NaN;
116md.mesh.uppervertex=NaN;
117md.mesh.lowerelements=NaN;
118md.mesh.upperelements=NaN;
119
120%Remove old mesh
121md.mesh.x2d=NaN;
122md.mesh.y2d=NaN;
123md.mesh.elements2d=NaN;
124md.mesh.numberofelements2d=md.mesh.numberofelements;
125md.mesh.numberofvertices2d=md.mesh.numberofvertices;
126md.mesh.numberoflayers=0;
127
128%Update mesh type
129md.mesh.dimension=2;
Note: See TracBrowser for help on using the repository browser.