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

Last change on this file since 9646 was 9646, checked in by seroussi, 14 years ago

added class balancethickness

File size: 3.9 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.dim==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.vx_obs), md.vx_obs=project2d(md,md.vx_obs,md.numlayers); end;
29if ~isnan(md.vy_obs), md.vy_obs=project2d(md,md.vy_obs,md.numlayers); end;
30if ~isnan(md.vel_obs), md.vel_obs=project2d(md,md.vel_obs,md.numlayers); end;
31if ~isnan(md.surfaceforcings.mass_balance),
32 md.surfaceforcings.mass_balance=project2d(md,md.surfaceforcings.mass_balance,md.numlayers);
33end;
34if ~isnan(md.balancethickness.thickening_rate), md.balancethickness.thickening_rate=project2d(md,md.balancethickness.thickening_rate,md.numlayers); end;
35
36%results
37if ~isnan(md.vx),md.vx=DepthAverage(md,md.vx);end;
38if ~isnan(md.vy),md.vy=DepthAverage(md,md.vy);end;
39if ~isnan(md.vz),md.vz=DepthAverage(md,md.vz);end;
40if ~isnan(md.vel),md.vel=DepthAverage(md,md.vel);end;
41
42%bedinfo and surface info
43md.elementonbed=ones(md.numberofelements2d,1);
44md.elementonsurface=ones(md.numberofelements2d,1);
45md.nodeonbed=ones(md.numberofnodes2d,1);
46md.nodeonsurface=ones(md.numberofnodes2d,1);
47
48%elementstype
49if ~isnan(md.elements_type)
50 md.elements_type=project2d(md,md.elements_type,1);
51end
52md.nodeonhutter=project2d(md,md.nodeonhutter,1);
53md.nodeonmacayeal=project2d(md,md.nodeonmacayeal,1);
54md.nodeonpattyn=project2d(md,md.nodeonpattyn,1);
55md.nodeonstokes=project2d(md,md.nodeonstokes,1);
56
57%boundary conditions
58md.spcvx=project2d(md,md.spcvx,md.numlayers);
59md.spcvy=project2d(md,md.spcvy,md.numlayers);
60md.spcvz=project2d(md,md.spcvz,md.numlayers);
61md.prognostic.spcthickness=project2d(md,md.prognostic.spcthickness,md.numlayers);
62md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.numlayers);
63
64%Extrusion of Neumann BC
65if ~isnan(md.pressureload),
66 numberofneumann2d=size(md.pressureload,1)/md.numlayers;
67 md.pressureload=[md.pressureload(1:numberofneumann2d,1:2) md.pressureload(1:numberofneumann2d,5:6)]; %Add two columns on the first layer
68end
69
70%materials
71md.materials.rheology_B=DepthAverage(md,md.materials.rheology_B);
72md.materials.rheology_n=project2d(md,md.materials.rheology_n,1);
73
74%special for thermal modeling:
75md.basalforcings.melting_rate=project2d(md,md.basalforcings.melting_rate,1);
76md.basalforcings.geothermalflux=project2d(md,md.basalforcings.geothermalflux,1); %bedrock only gets geothermal flux
77
78%update of connectivity matrix
79md.connectivity=25;
80
81%Collapse the mesh
82nodes2d=md.numberofnodes2d;
83elements2d=md.numberofelements2d;
84
85%parameters
86md.surface=project2d(md,md.surface,1);
87md.thickness=project2d(md,md.thickness,1);
88md.bed=project2d(md,md.bed,1);
89md.nodeonboundary=project2d(md,md.nodeonboundary,1);
90md.mask.elementonfloatingice=project2d(md,md.mask.elementonfloatingice,1);
91md.mask.vertexonfloatingice=project2d(md,md.mask.vertexonfloatingice,1);
92md.mask.elementongroundedice=project2d(md,md.mask.elementongroundedice,1);
93md.mask.vertexongroundedice=project2d(md,md.mask.vertexongroundedice,1);
94
95%Initialize with the 2d mesh
96md.x=md.x2d;
97md.y=md.y2d;
98md.z=zeros(size(md.x2d));
99md.numberofnodes=md.numberofnodes2d;
100md.numberofelements=md.numberofelements2d;
101md.elements=md.elements2d;
102
103%Keep a trace of lower and upper nodes
104md.lowernodes=NaN;
105md.uppernodes=NaN;
106
107%Remove old mesh
108md.x2d=NaN;
109md.y2d=NaN;
110md.elements2d=NaN;
111md.numberofelements2d=md.numberofelements;
112md.numberofnodes2d=md.numberofnodes;
113md.numlayers=0;
114
115%Update mesh type
116md.dim=2;
Note: See TracBrowser for help on using the repository browser.