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

Last change on this file since 8392 was 8392, checked in by schlegel, 14 years ago

change melting rate to basal melting rate for clarity

File size: 4.1 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
[3994]14if ~md.dim==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.
[3760]21md.drag_coefficient=project2d(md,md.drag_coefficient,1);
[1]22
23%p and q (same deal, except for element that are on the bedrock: )
[3760]24md.drag_p=project2d(md,md.drag_p,1);
25md.drag_q=project2d(md,md.drag_q,1);
[1]26
27%observations
[6335]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.accumulation_rate), md.accumulation_rate=project2d(md,md.accumulation_rate,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;
[1]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);
[8298]48md.nodeonbed=ones(md.numberofnodes2d,1);
49md.nodeonsurface=ones(md.numberofnodes2d,1);
[1]50
51%elementstype
52if ~isnan(md.elements_type2d)
53 md.elements_type=md.elements_type2d;
[2689]54elseif ~isnan(md.elements_type)
[5898]55 md.elements_type=project2d(md,md.elements_type,1);
[1]56end
[8298]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);
[1]61
62%boundary conditions
[1755]63md.spcvelocity=project2d(md,md.spcvelocity,md.numlayers);
64md.spcthickness=project2d(md,md.spcthickness,md.numlayers);
65md.spctemperature=project2d(md,md.spctemperature,md.numlayers);
[1]66
67%Extrusion of Neumann BC
[6412]68if ~isnan(md.pressureload),
69 numberofneumann2d=size(md.pressureload,1)/md.numlayers;
70 md.pressureload=[md.pressureload(1:numberofneumann2d,1:2) md.pressureload(1:numberofneumann2d,5:6)]; %Add two columns on the first layer
71end
[1]72
73%materials
[3760]74md.rheology_B=DepthAverage(md,md.rheology_B);
75md.rheology_n=project2d(md,md.rheology_n,1);
[1]76
77%special for thermal modeling:
[8392]78md.basal_melting_rate=project2d(md,md.basal_melting_rate,1);
[1]79md.observed_temperature=DepthAverage(md,md.observed_temperature);
80md.geothermalflux=project2d(md,md.geothermalflux,1); %bedrock only gets geothermal flux
81
82%update of connectivity matrix
83md.connectivity=25;
84
85%Collapse the mesh
[8298]86nodes2d=md.numberofnodes2d;
[1]87elements2d=md.numberofelements2d;
88
89%parameters
90md.surface=project2d(md,md.surface,1);
91md.thickness=project2d(md,md.thickness,1);
92md.bed=project2d(md,md.bed,1);
[8298]93md.nodeonboundary=project2d(md,md.nodeonboundary,1);
[1]94md.elementoniceshelf=project2d(md,md.elementoniceshelf,1);
[8298]95md.nodeoniceshelf=project2d(md,md.nodeoniceshelf,1);
[1]96md.elementonicesheet=project2d(md,md.elementonicesheet,1);
[8298]97md.nodeonicesheet=project2d(md,md.nodeonicesheet,1);
[1]98
99%Initialize with the 2d mesh
100md.x=md.x2d;
101md.y=md.y2d;
102md.z=md.z2d;
[8298]103md.numberofnodes=md.numberofnodes2d;
[1]104md.numberofelements=md.numberofelements2d;
105md.elements=md.elements2d;
106
[8298]107%Keep a trace of lower and upper nodes
108md.lowernodes=NaN;
109md.uppernodes=NaN;
[1]110
111%Remove old mesh
112md.x2d=NaN;
113md.y2d=NaN;
114md.z2d=NaN;
115md.elements2d=NaN;
116md.elements_type2d=md.elements_type;
117md.numberofelements2d=md.numberofelements;
[8298]118md.numberofnodes2d=md.numberofnodes;
[1]119md.numlayers=0;
120
121%Update mesh type
[3994]122md.dim=2;
Note: See TracBrowser for help on using the repository browser.