[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
|
---|
[9719] | 14 | if ~md.mesh.dimension==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.
|
---|
[9610] | 21 | md.friction.coefficient=project2d(md,md.friction.coefficient,1);
|
---|
[1] | 22 |
|
---|
| 23 | %p and q (same deal, except for element that are on the bedrock: )
|
---|
[9610] | 24 | md.friction.p=project2d(md,md.friction.p,1);
|
---|
| 25 | md.friction.q=project2d(md,md.friction.q,1);
|
---|
[1] | 26 |
|
---|
| 27 | %observations
|
---|
[9725] | 28 | if ~isnan(md.inversion.vx_obs), md.inversion.vx_obs=project2d(md,md.inversion.vx_obs,md.mesh.numberoflayers); end;
|
---|
| 29 | if ~isnan(md.inversion.vy_obs), md.inversion.vy_obs=project2d(md,md.inversion.vy_obs,md.mesh.numberoflayers); end;
|
---|
| 30 | if ~isnan(md.inversion.vel_obs), md.inversion.vel_obs=project2d(md,md.inversion.vel_obs,md.mesh.numberoflayers); end;
|
---|
[11527] | 31 | if ~isnan(md.inversion.cost_functions_coefficients), md.inversion.cost_functions_coefficients=project2d(md,md.inversion.cost_functions_coefficients,md.mesh.numberoflayers); end;
|
---|
| 32 | if ~isnan(md.inversion.min_parameters), md.inversion.min_parameters=project2d(md,md.inversion.min_parameters,md.mesh.numberoflayers); end;
|
---|
| 33 | if ~isnan(md.inversion.max_parameters), md.inversion.max_parameters=project2d(md,md.inversion.max_parameters,md.mesh.numberoflayers); end;
|
---|
[9607] | 34 | if ~isnan(md.surfaceforcings.mass_balance),
|
---|
[9725] | 35 | md.surfaceforcings.mass_balance=project2d(md,md.surfaceforcings.mass_balance,md.mesh.numberoflayers);
|
---|
[9607] | 36 | end;
|
---|
[9725] | 37 | if ~isnan(md.balancethickness.thickening_rate), md.balancethickness.thickening_rate=project2d(md,md.balancethickness.thickening_rate,md.mesh.numberoflayers); end;
|
---|
[1] | 38 |
|
---|
| 39 | %results
|
---|
[9684] | 40 | if ~isnan(md.initialization.vx),md.initialization.vx=DepthAverage(md,md.initialization.vx);end;
|
---|
| 41 | if ~isnan(md.initialization.vy),md.initialization.vy=DepthAverage(md,md.initialization.vy);end;
|
---|
| 42 | if ~isnan(md.initialization.vz),md.initialization.vz=DepthAverage(md,md.initialization.vz);end;
|
---|
| 43 | if ~isnan(md.initialization.vel),md.initialization.vel=DepthAverage(md,md.initialization.vel);end;
|
---|
[1] | 44 |
|
---|
| 45 | %bedinfo and surface info
|
---|
[9729] | 46 | md.mesh.elementonbed=ones(md.mesh.numberofelements2d,1);
|
---|
| 47 | md.mesh.elementonsurface=ones(md.mesh.numberofelements2d,1);
|
---|
| 48 | md.mesh.vertexonbed=ones(md.mesh.numberofvertices2d,1);
|
---|
| 49 | md.mesh.vertexonsurface=ones(md.mesh.numberofvertices2d,1);
|
---|
[1] | 50 |
|
---|
| 51 | %elementstype
|
---|
[9661] | 52 | if ~isnan(md.flowequation.element_equation)
|
---|
| 53 | md.flowequation.element_equation=project2d(md,md.flowequation.element_equation,1);
|
---|
[11527] | 54 | md.flowequation.vertex_equation=project2d(md,md.flowequation.vertex_equation,1);
|
---|
| 55 | md.flowequation.bordermacayeal=project2d(md,md.flowequation.bordermacayeal,1);
|
---|
| 56 | md.flowequation.borderpattyn=project2d(md,md.flowequation.borderpattyn,1);
|
---|
| 57 | md.flowequation.borderstokes=project2d(md,md.flowequation.borderstokes,1);
|
---|
[1] | 58 | end
|
---|
| 59 |
|
---|
| 60 | %boundary conditions
|
---|
[9725] | 61 | md.diagnostic.spcvx=project2d(md,md.diagnostic.spcvx,md.mesh.numberoflayers);
|
---|
| 62 | md.diagnostic.spcvy=project2d(md,md.diagnostic.spcvy,md.mesh.numberoflayers);
|
---|
| 63 | md.diagnostic.spcvz=project2d(md,md.diagnostic.spcvz,md.mesh.numberoflayers);
|
---|
[11527] | 64 | md.diagnostic.referential=project2d(md,md.diagnostic.referential,md.mesh.numberoflayers);
|
---|
[9725] | 65 | md.prognostic.spcthickness=project2d(md,md.prognostic.spcthickness,md.mesh.numberoflayers);
|
---|
| 66 | md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.mesh.numberoflayers);
|
---|
[1] | 67 |
|
---|
| 68 | %Extrusion of Neumann BC
|
---|
[9679] | 69 | if ~isnan(md.diagnostic.icefront),
|
---|
[11527] | 70 | numberofneumann2d=size(md.diagnostic.icefront,1)/(md.mesh.numberoflayers-1);
|
---|
[9679] | 71 | md.diagnostic.icefront=[md.diagnostic.icefront(1:numberofneumann2d,1:2) md.diagnostic.icefront(1:numberofneumann2d,5:6)]; %Add two columns on the first layer
|
---|
[6412] | 72 | end
|
---|
[1] | 73 |
|
---|
| 74 | %materials
|
---|
[9636] | 75 | md.materials.rheology_B=DepthAverage(md,md.materials.rheology_B);
|
---|
| 76 | md.materials.rheology_n=project2d(md,md.materials.rheology_n,1);
|
---|
[1] | 77 |
|
---|
| 78 | %special for thermal modeling:
|
---|
[9612] | 79 | md.basalforcings.melting_rate=project2d(md,md.basalforcings.melting_rate,1);
|
---|
| 80 | md.basalforcings.geothermalflux=project2d(md,md.basalforcings.geothermalflux,1); %bedrock only gets geothermal flux
|
---|
[1] | 81 |
|
---|
| 82 | %update of connectivity matrix
|
---|
[9705] | 83 | md.mesh.average_vertex_connectivity=25;
|
---|
[1] | 84 |
|
---|
| 85 | %Collapse the mesh
|
---|
[9725] | 86 | nodes2d=md.mesh.numberofvertices2d;
|
---|
| 87 | elements2d=md.mesh.numberofelements2d;
|
---|
[1] | 88 |
|
---|
| 89 | %parameters
|
---|
[9691] | 90 | md.geometry.surface=project2d(md,md.geometry.surface,1);
|
---|
| 91 | md.geometry.thickness=project2d(md,md.geometry.thickness,1);
|
---|
| 92 | md.geometry.bed=project2d(md,md.geometry.bed,1);
|
---|
[9714] | 93 | md.mesh.vertexonboundary=project2d(md,md.mesh.vertexonboundary,1);
|
---|
[11995] | 94 | md.mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1);
|
---|
[9641] | 95 | md.mask.elementonfloatingice=project2d(md,md.mask.elementonfloatingice,1);
|
---|
| 96 | md.mask.vertexonfloatingice=project2d(md,md.mask.vertexonfloatingice,1);
|
---|
| 97 | md.mask.elementongroundedice=project2d(md,md.mask.elementongroundedice,1);
|
---|
| 98 | md.mask.vertexongroundedice=project2d(md,md.mask.vertexongroundedice,1);
|
---|
[11527] | 99 | md.mask.elementonwater=project2d(md,md.mask.elementonwater,1);
|
---|
| 100 | md.mask.vertexonwater=project2d(md,md.mask.vertexonwater,1);
|
---|
[1] | 101 |
|
---|
[11995] | 102 | %lat long
|
---|
| 103 | md.mesh.lat=project2d(md,md.mesh.lat,1);
|
---|
| 104 | md.mesh.long=project2d(md,md.mesh.long,1);
|
---|
| 105 |
|
---|
[1] | 106 | %Initialize with the 2d mesh
|
---|
[9734] | 107 | md.mesh.x=md.mesh.x2d;
|
---|
| 108 | md.mesh.y=md.mesh.y2d;
|
---|
| 109 | md.mesh.z=zeros(size(md.mesh.x2d));
|
---|
[9725] | 110 | md.mesh.numberofvertices=md.mesh.numberofvertices2d;
|
---|
| 111 | md.mesh.numberofelements=md.mesh.numberofelements2d;
|
---|
[9733] | 112 | md.mesh.elements=md.mesh.elements2d;
|
---|
[1] | 113 |
|
---|
[8298] | 114 | %Keep a trace of lower and upper nodes
|
---|
[9729] | 115 | md.mesh.lowervertex=NaN;
|
---|
| 116 | md.mesh.uppervertex=NaN;
|
---|
[11995] | 117 | md.mesh.lowerelements=NaN;
|
---|
| 118 | md.mesh.upperelements=NaN;
|
---|
[1] | 119 |
|
---|
| 120 | %Remove old mesh
|
---|
[9731] | 121 | md.mesh.x2d=NaN;
|
---|
| 122 | md.mesh.y2d=NaN;
|
---|
| 123 | md.mesh.elements2d=NaN;
|
---|
[9725] | 124 | md.mesh.numberofelements2d=md.mesh.numberofelements;
|
---|
| 125 | md.mesh.numberofvertices2d=md.mesh.numberofvertices;
|
---|
| 126 | md.mesh.numberoflayers=0;
|
---|
[1] | 127 |
|
---|
| 128 | %Update mesh type
|
---|
[9719] | 129 | md.mesh.dimension=2;
|
---|