1 | function 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
|
---|
14 | if ~md.dim==3,
|
---|
15 | error('collapse error message: only 3d mesh can be collapsed')
|
---|
16 | end
|
---|
17 |
|
---|
18 | %Start with changing alle the fields from the 3d mesh
|
---|
19 |
|
---|
20 | %drag is limited to nodes that are on the bedrock.
|
---|
21 | md.friction.coefficient=project2d(md,md.friction.coefficient,1);
|
---|
22 |
|
---|
23 | %p and q (same deal, except for element that are on the bedrock: )
|
---|
24 | md.friction.p=project2d(md,md.friction.p,1);
|
---|
25 | md.friction.q=project2d(md,md.friction.q,1);
|
---|
26 |
|
---|
27 | %observations
|
---|
28 | if ~isnan(md.vx_obs), md.vx_obs=project2d(md,md.vx_obs,md.numlayers); end;
|
---|
29 | if ~isnan(md.vy_obs), md.vy_obs=project2d(md,md.vy_obs,md.numlayers); end;
|
---|
30 | if ~isnan(md.vel_obs), md.vel_obs=project2d(md,md.vel_obs,md.numlayers); end;
|
---|
31 | if ~isnan(md.surfaceforcings.mass_balance),
|
---|
32 | md.surfaceforcings.mass_balance=project2d(md,md.surfaceforcings.mass_balance,md.numlayers);
|
---|
33 | end;
|
---|
34 | if ~isnan(md.balancethickness.thickening_rate), md.balancethickness.thickening_rate=project2d(md,md.balancethickness.thickening_rate,md.numlayers); end;
|
---|
35 |
|
---|
36 | %results
|
---|
37 | if ~isnan(md.vx),md.vx=DepthAverage(md,md.vx);end;
|
---|
38 | if ~isnan(md.vy),md.vy=DepthAverage(md,md.vy);end;
|
---|
39 | if ~isnan(md.vz),md.vz=DepthAverage(md,md.vz);end;
|
---|
40 | if ~isnan(md.vel),md.vel=DepthAverage(md,md.vel);end;
|
---|
41 |
|
---|
42 | %bedinfo and surface info
|
---|
43 | md.elementonbed=ones(md.numberofelements2d,1);
|
---|
44 | md.elementonsurface=ones(md.numberofelements2d,1);
|
---|
45 | md.nodeonbed=ones(md.numberofnodes2d,1);
|
---|
46 | md.nodeonsurface=ones(md.numberofnodes2d,1);
|
---|
47 |
|
---|
48 | %elementstype
|
---|
49 | if ~isnan(md.flowequation.element_equation)
|
---|
50 | md.flowequation.element_equation=project2d(md,md.flowequation.element_equation,1);
|
---|
51 | end
|
---|
52 |
|
---|
53 | %boundary conditions
|
---|
54 | md.diagnostic.spcvx=project2d(md,md.diagnostic.spcvx,md.numlayers);
|
---|
55 | md.diagnostic.spcvy=project2d(md,md.diagnostic.spcvy,md.numlayers);
|
---|
56 | md.diagnostic.spcvz=project2d(md,md.diagnostic.spcvz,md.numlayers);
|
---|
57 | md.prognostic.spcthickness=project2d(md,md.prognostic.spcthickness,md.numlayers);
|
---|
58 | md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.numlayers);
|
---|
59 |
|
---|
60 | %Extrusion of Neumann BC
|
---|
61 | if ~isnan(md.diagnostic.icefront),
|
---|
62 | numberofneumann2d=size(md.diagnostic.icefront,1)/md.numlayers;
|
---|
63 | md.diagnostic.icefront=[md.diagnostic.icefront(1:numberofneumann2d,1:2) md.diagnostic.icefront(1:numberofneumann2d,5:6)]; %Add two columns on the first layer
|
---|
64 | end
|
---|
65 |
|
---|
66 | %materials
|
---|
67 | md.materials.rheology_B=DepthAverage(md,md.materials.rheology_B);
|
---|
68 | md.materials.rheology_n=project2d(md,md.materials.rheology_n,1);
|
---|
69 |
|
---|
70 | %special for thermal modeling:
|
---|
71 | md.basalforcings.melting_rate=project2d(md,md.basalforcings.melting_rate,1);
|
---|
72 | md.basalforcings.geothermalflux=project2d(md,md.basalforcings.geothermalflux,1); %bedrock only gets geothermal flux
|
---|
73 |
|
---|
74 | %update of connectivity matrix
|
---|
75 | md.connectivity=25;
|
---|
76 |
|
---|
77 | %Collapse the mesh
|
---|
78 | nodes2d=md.numberofnodes2d;
|
---|
79 | elements2d=md.numberofelements2d;
|
---|
80 |
|
---|
81 | %parameters
|
---|
82 | md.surface=project2d(md,md.surface,1);
|
---|
83 | md.thickness=project2d(md,md.thickness,1);
|
---|
84 | md.bed=project2d(md,md.bed,1);
|
---|
85 | md.nodeonboundary=project2d(md,md.nodeonboundary,1);
|
---|
86 | md.mask.elementonfloatingice=project2d(md,md.mask.elementonfloatingice,1);
|
---|
87 | md.mask.vertexonfloatingice=project2d(md,md.mask.vertexonfloatingice,1);
|
---|
88 | md.mask.elementongroundedice=project2d(md,md.mask.elementongroundedice,1);
|
---|
89 | md.mask.vertexongroundedice=project2d(md,md.mask.vertexongroundedice,1);
|
---|
90 |
|
---|
91 | %Initialize with the 2d mesh
|
---|
92 | md.x=md.x2d;
|
---|
93 | md.y=md.y2d;
|
---|
94 | md.z=zeros(size(md.x2d));
|
---|
95 | md.numberofnodes=md.numberofnodes2d;
|
---|
96 | md.numberofelements=md.numberofelements2d;
|
---|
97 | md.elements=md.elements2d;
|
---|
98 |
|
---|
99 | %Keep a trace of lower and upper nodes
|
---|
100 | md.lowernodes=NaN;
|
---|
101 | md.uppernodes=NaN;
|
---|
102 |
|
---|
103 | %Remove old mesh
|
---|
104 | md.x2d=NaN;
|
---|
105 | md.y2d=NaN;
|
---|
106 | md.elements2d=NaN;
|
---|
107 | md.numberofelements2d=md.numberofelements;
|
---|
108 | md.numberofnodes2d=md.numberofnodes;
|
---|
109 | md.numlayers=0;
|
---|
110 |
|
---|
111 | %Update mesh type
|
---|
112 | md.dim=2;
|
---|