[1] | 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
|
---|
[3994] | 14 | if ~md.dim==3,
|
---|
[1] | 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 |
|
---|
[8298] | 20 | %drag is limited to nodes that are on the bedrock.
|
---|
[3760] | 21 | md.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] | 24 | md.drag_p=project2d(md,md.drag_p,1);
|
---|
| 25 | md.drag_q=project2d(md,md.drag_q,1);
|
---|
[1] | 26 |
|
---|
| 27 | %observations
|
---|
[6335] | 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;
|
---|
[8399] | 31 | if ~isnan(md.surface_mass_balance), md.surface_mass_balance=project2d(md,md.surface_mass_balance,md.numlayers); end;
|
---|
[6335] | 32 | if ~isnan(md.dhdt), md.dhdt=project2d(md,md.dhdt,md.numlayers); end;
|
---|
| 33 | if ~isnan(md.firn_layer), md.firn_layer=project2d(md,md.firn_layer,md.numlayers); end;
|
---|
[1] | 34 |
|
---|
| 35 | %results
|
---|
| 36 | if ~isnan(md.vx),md.vx=DepthAverage(md,md.vx);end;
|
---|
| 37 | if ~isnan(md.vy),md.vy=DepthAverage(md,md.vy);end;
|
---|
| 38 | if ~isnan(md.vz),md.vz=DepthAverage(md,md.vz);end;
|
---|
| 39 | if ~isnan(md.vel),md.vel=DepthAverage(md,md.vel);end;
|
---|
| 40 | if ~isnan(md.surface_slopex),md.surface_slopex=project2d(md,md.surface_slopex,md.numlayers);end;
|
---|
| 41 | if ~isnan(md.surface_slopey),md.surface_slopey=project2d(md,md.surface_slopey,md.numlayers);end;
|
---|
| 42 | if ~isnan(md.bed_slopex),md.bed_slopex=project2d(md,md.bed_slopex,1);end;
|
---|
| 43 | if ~isnan(md.bed_slopey),md.bed_slopey=project2d(md,md.bed_slopey,1);end;
|
---|
| 44 |
|
---|
| 45 | %bedinfo and surface info
|
---|
| 46 | md.elementonbed=ones(md.numberofelements2d,1);
|
---|
| 47 | md.elementonsurface=ones(md.numberofelements2d,1);
|
---|
[8298] | 48 | md.nodeonbed=ones(md.numberofnodes2d,1);
|
---|
| 49 | md.nodeonsurface=ones(md.numberofnodes2d,1);
|
---|
[1] | 50 |
|
---|
| 51 | %elementstype
|
---|
| 52 | if ~isnan(md.elements_type2d)
|
---|
| 53 | md.elements_type=md.elements_type2d;
|
---|
[2689] | 54 | elseif ~isnan(md.elements_type)
|
---|
[5898] | 55 | md.elements_type=project2d(md,md.elements_type,1);
|
---|
[1] | 56 | end
|
---|
[8298] | 57 | md.nodeonhutter=project2d(md,md.nodeonhutter,1);
|
---|
| 58 | md.nodeonmacayeal=project2d(md,md.nodeonmacayeal,1);
|
---|
| 59 | md.nodeonpattyn=project2d(md,md.nodeonpattyn,1);
|
---|
| 60 | md.nodeonstokes=project2d(md,md.nodeonstokes,1);
|
---|
[1] | 61 |
|
---|
| 62 | %boundary conditions
|
---|
[1755] | 63 | md.spcvelocity=project2d(md,md.spcvelocity,md.numlayers);
|
---|
| 64 | md.spcthickness=project2d(md,md.spcthickness,md.numlayers);
|
---|
| 65 | md.spctemperature=project2d(md,md.spctemperature,md.numlayers);
|
---|
[1] | 66 |
|
---|
| 67 | %Extrusion of Neumann BC
|
---|
[6412] | 68 | if ~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
|
---|
| 71 | end
|
---|
[1] | 72 |
|
---|
| 73 | %materials
|
---|
[3760] | 74 | md.rheology_B=DepthAverage(md,md.rheology_B);
|
---|
| 75 | md.rheology_n=project2d(md,md.rheology_n,1);
|
---|
[1] | 76 |
|
---|
| 77 | %special for thermal modeling:
|
---|
[8392] | 78 | md.basal_melting_rate=project2d(md,md.basal_melting_rate,1);
|
---|
[1] | 79 | md.observed_temperature=DepthAverage(md,md.observed_temperature);
|
---|
| 80 | md.geothermalflux=project2d(md,md.geothermalflux,1); %bedrock only gets geothermal flux
|
---|
| 81 |
|
---|
| 82 | %update of connectivity matrix
|
---|
| 83 | md.connectivity=25;
|
---|
| 84 |
|
---|
| 85 | %Collapse the mesh
|
---|
[8298] | 86 | nodes2d=md.numberofnodes2d;
|
---|
[1] | 87 | elements2d=md.numberofelements2d;
|
---|
| 88 |
|
---|
| 89 | %parameters
|
---|
| 90 | md.surface=project2d(md,md.surface,1);
|
---|
| 91 | md.thickness=project2d(md,md.thickness,1);
|
---|
| 92 | md.bed=project2d(md,md.bed,1);
|
---|
[8298] | 93 | md.nodeonboundary=project2d(md,md.nodeonboundary,1);
|
---|
[1] | 94 | md.elementoniceshelf=project2d(md,md.elementoniceshelf,1);
|
---|
[8298] | 95 | md.nodeoniceshelf=project2d(md,md.nodeoniceshelf,1);
|
---|
[1] | 96 | md.elementonicesheet=project2d(md,md.elementonicesheet,1);
|
---|
[8298] | 97 | md.nodeonicesheet=project2d(md,md.nodeonicesheet,1);
|
---|
[1] | 98 |
|
---|
| 99 | %Initialize with the 2d mesh
|
---|
| 100 | md.x=md.x2d;
|
---|
| 101 | md.y=md.y2d;
|
---|
| 102 | md.z=md.z2d;
|
---|
[8298] | 103 | md.numberofnodes=md.numberofnodes2d;
|
---|
[1] | 104 | md.numberofelements=md.numberofelements2d;
|
---|
| 105 | md.elements=md.elements2d;
|
---|
| 106 |
|
---|
[8298] | 107 | %Keep a trace of lower and upper nodes
|
---|
| 108 | md.lowernodes=NaN;
|
---|
| 109 | md.uppernodes=NaN;
|
---|
[1] | 110 |
|
---|
| 111 | %Remove old mesh
|
---|
| 112 | md.x2d=NaN;
|
---|
| 113 | md.y2d=NaN;
|
---|
| 114 | md.z2d=NaN;
|
---|
| 115 | md.elements2d=NaN;
|
---|
| 116 | md.elements_type2d=md.elements_type;
|
---|
| 117 | md.numberofelements2d=md.numberofelements;
|
---|
[8298] | 118 | md.numberofnodes2d=md.numberofnodes;
|
---|
[1] | 119 | md.numlayers=0;
|
---|
| 120 |
|
---|
| 121 | %Update mesh type
|
---|
[3994] | 122 | md.dim=2;
|
---|