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

Last change on this file since 8823 was 8823, checked in by Eric.Larour, 14 years ago

Split spcvelocity into spcvx, spcvy and spcvz

File size: 4.2 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.drag_coefficient=project2d(md,md.drag_coefficient,1);
22
23%p and q (same deal, except for element that are on the bedrock: )
24md.drag_p=project2d(md,md.drag_p,1);
25md.drag_q=project2d(md,md.drag_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.surface_mass_balance), md.surface_mass_balance=project2d(md,md.surface_mass_balance,md.numlayers); end;
32if ~isnan(md.dhdt), md.dhdt=project2d(md,md.dhdt,md.numlayers); end;
33if ~isnan(md.firn_layer), md.firn_layer=project2d(md,md.firn_layer,md.numlayers); end;
34
35%results
36if ~isnan(md.vx),md.vx=DepthAverage(md,md.vx);end;
37if ~isnan(md.vy),md.vy=DepthAverage(md,md.vy);end;
38if ~isnan(md.vz),md.vz=DepthAverage(md,md.vz);end;
39if ~isnan(md.vel),md.vel=DepthAverage(md,md.vel);end;
40if ~isnan(md.surface_slopex),md.surface_slopex=project2d(md,md.surface_slopex,md.numlayers);end;
41if ~isnan(md.surface_slopey),md.surface_slopey=project2d(md,md.surface_slopey,md.numlayers);end;
42if ~isnan(md.bed_slopex),md.bed_slopex=project2d(md,md.bed_slopex,1);end;
43if ~isnan(md.bed_slopey),md.bed_slopey=project2d(md,md.bed_slopey,1);end;
44
45%bedinfo and surface info
46md.elementonbed=ones(md.numberofelements2d,1);
47md.elementonsurface=ones(md.numberofelements2d,1);
48md.nodeonbed=ones(md.numberofnodes2d,1);
49md.nodeonsurface=ones(md.numberofnodes2d,1);
50
51%elementstype
52if ~isnan(md.elements_type2d)
53 md.elements_type=md.elements_type2d;
54elseif ~isnan(md.elements_type)
55 md.elements_type=project2d(md,md.elements_type,1);
56end
57md.nodeonhutter=project2d(md,md.nodeonhutter,1);
58md.nodeonmacayeal=project2d(md,md.nodeonmacayeal,1);
59md.nodeonpattyn=project2d(md,md.nodeonpattyn,1);
60md.nodeonstokes=project2d(md,md.nodeonstokes,1);
61
62%boundary conditions
63md.spcvx=project2d(md,md.spcvx,md.numlayers);
64md.spcvy=project2d(md,md.spcvy,md.numlayers);
65md.spcvz=project2d(md,md.spcvz,md.numlayers);
66md.spcthickness=project2d(md,md.spcthickness,md.numlayers);
67md.spctemperature=project2d(md,md.spctemperature,md.numlayers);
68
69%Extrusion of Neumann BC
70if ~isnan(md.pressureload),
71 numberofneumann2d=size(md.pressureload,1)/md.numlayers;
72 md.pressureload=[md.pressureload(1:numberofneumann2d,1:2) md.pressureload(1:numberofneumann2d,5:6)]; %Add two columns on the first layer
73end
74
75%materials
76md.rheology_B=DepthAverage(md,md.rheology_B);
77md.rheology_n=project2d(md,md.rheology_n,1);
78
79%special for thermal modeling:
80md.basal_melting_rate=project2d(md,md.basal_melting_rate,1);
81md.observed_temperature=DepthAverage(md,md.observed_temperature);
82md.geothermalflux=project2d(md,md.geothermalflux,1); %bedrock only gets geothermal flux
83
84%update of connectivity matrix
85md.connectivity=25;
86
87%Collapse the mesh
88nodes2d=md.numberofnodes2d;
89elements2d=md.numberofelements2d;
90
91%parameters
92md.surface=project2d(md,md.surface,1);
93md.thickness=project2d(md,md.thickness,1);
94md.bed=project2d(md,md.bed,1);
95md.nodeonboundary=project2d(md,md.nodeonboundary,1);
96md.elementoniceshelf=project2d(md,md.elementoniceshelf,1);
97md.nodeoniceshelf=project2d(md,md.nodeoniceshelf,1);
98md.elementonicesheet=project2d(md,md.elementonicesheet,1);
99md.nodeonicesheet=project2d(md,md.nodeonicesheet,1);
100
101%Initialize with the 2d mesh
102md.x=md.x2d;
103md.y=md.y2d;
104md.z=md.z2d;
105md.numberofnodes=md.numberofnodes2d;
106md.numberofelements=md.numberofelements2d;
107md.elements=md.elements2d;
108
109%Keep a trace of lower and upper nodes
110md.lowernodes=NaN;
111md.uppernodes=NaN;
112
113%Remove old mesh
114md.x2d=NaN;
115md.y2d=NaN;
116md.z2d=NaN;
117md.elements2d=NaN;
118md.elements_type2d=md.elements_type;
119md.numberofelements2d=md.numberofelements;
120md.numberofnodes2d=md.numberofnodes;
121md.numlayers=0;
122
123%Update mesh type
124md.dim=2;
Note: See TracBrowser for help on using the repository browser.