[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 |
|
---|
| 20 | %drag is limited to grids 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
|
---|
| 28 | md.vx_obs=project2d(md,md.vx_obs,md.numlayers);
|
---|
| 29 | md.vy_obs=project2d(md,md.vy_obs,md.numlayers);
|
---|
| 30 | md.vel_obs=project2d(md,md.vel_obs,md.numlayers);
|
---|
[3760] | 31 | md.accumulation_rate=project2d(md,md.accumulation_rate,md.numlayers);
|
---|
[6275] | 32 | md.dhdt=project2d(md,md.dhdt,md.numlayers);
|
---|
[1] | 33 | md.firn_layer=project2d(md,md.firn_layer,md.numlayers);
|
---|
| 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);
|
---|
| 48 | md.gridonbed=ones(md.numberofgrids2d,1);
|
---|
| 49 | md.gridonsurface=ones(md.numberofgrids2d,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
|
---|
| 57 | md.gridonhutter=project2d(md,md.gridonhutter,1);
|
---|
| 58 | md.gridonmacayeal=project2d(md,md.gridonmacayeal,1);
|
---|
| 59 | md.gridonpattyn=project2d(md,md.gridonpattyn,1);
|
---|
| 60 | md.gridonstokes=project2d(md,md.gridonstokes,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
|
---|
| 68 | %in 2d, segmentonnumann is: [grid1 grid2 element]
|
---|
[1755] | 69 | numberofneumann2d=size(md.pressureload,1)/md.numlayers;
|
---|
[3099] | 70 | md.pressureload=[md.pressureload(1:numberofneumann2d,1:2) md.pressureload(1:numberofneumann2d,5:6)]; %Add two columns on the first layer
|
---|
[1] | 71 |
|
---|
| 72 | %materials
|
---|
[3760] | 73 | md.rheology_B=DepthAverage(md,md.rheology_B);
|
---|
| 74 | md.rheology_n=project2d(md,md.rheology_n,1);
|
---|
[1] | 75 |
|
---|
| 76 | %special for thermal modeling:
|
---|
[3760] | 77 | md.melting_rate=project2d(md,md.melting_rate,1);
|
---|
[1] | 78 | md.observed_temperature=DepthAverage(md,md.observed_temperature);
|
---|
| 79 | md.geothermalflux=project2d(md,md.geothermalflux,1); %bedrock only gets geothermal flux
|
---|
| 80 |
|
---|
| 81 | %update of connectivity matrix
|
---|
| 82 | md.connectivity=25;
|
---|
| 83 |
|
---|
| 84 | %Collapse the mesh
|
---|
| 85 | grids2d=md.numberofgrids2d;
|
---|
| 86 | elements2d=md.numberofelements2d;
|
---|
| 87 |
|
---|
| 88 | %parameters
|
---|
| 89 | md.surface=project2d(md,md.surface,1);
|
---|
| 90 | md.thickness=project2d(md,md.thickness,1);
|
---|
| 91 | md.bed=project2d(md,md.bed,1);
|
---|
| 92 | md.gridonboundary=project2d(md,md.gridonboundary,1);
|
---|
| 93 | md.elementoniceshelf=project2d(md,md.elementoniceshelf,1);
|
---|
| 94 | md.gridoniceshelf=project2d(md,md.gridoniceshelf,1);
|
---|
| 95 | md.elementonicesheet=project2d(md,md.elementonicesheet,1);
|
---|
| 96 | md.gridonicesheet=project2d(md,md.gridonicesheet,1);
|
---|
| 97 |
|
---|
| 98 | %Initialize with the 2d mesh
|
---|
| 99 | md.x=md.x2d;
|
---|
| 100 | md.y=md.y2d;
|
---|
| 101 | md.z=md.z2d;
|
---|
| 102 | md.numberofgrids=md.numberofgrids2d;
|
---|
| 103 | md.numberofelements=md.numberofelements2d;
|
---|
| 104 | md.elements=md.elements2d;
|
---|
| 105 |
|
---|
| 106 | %Keep a trace of lower and upper grids
|
---|
| 107 | md.lowergrids=NaN;
|
---|
| 108 | md.uppergrids=NaN;
|
---|
| 109 |
|
---|
| 110 | %Remove old mesh
|
---|
| 111 | md.x2d=NaN;
|
---|
| 112 | md.y2d=NaN;
|
---|
| 113 | md.z2d=NaN;
|
---|
| 114 | md.elements2d=NaN;
|
---|
| 115 | md.elements_type2d=md.elements_type;
|
---|
| 116 | md.numberofelements2d=md.numberofelements;
|
---|
| 117 | md.numberofgrids2d=md.numberofgrids;
|
---|
| 118 | md.numlayers=0;
|
---|
| 119 |
|
---|
| 120 | %Update mesh type
|
---|
[3994] | 121 | md.dim=2;
|
---|