[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;
|
---|
[12329] | 32 | if numel(md.inversion.min_parameters)>1, md.inversion.min_parameters=project2d(md,md.inversion.min_parameters,md.mesh.numberoflayers); end;
|
---|
| 33 | if numel(md.inversion.max_parameters)>1, 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;
|
---|
[12706] | 44 | if ~isnan(md.initialization.temperature),md.initialization.temperature=DepthAverage(md,md.initialization.temperature);end;
|
---|
[1] | 45 |
|
---|
| 46 | %bedinfo and surface info
|
---|
[9729] | 47 | md.mesh.elementonbed=ones(md.mesh.numberofelements2d,1);
|
---|
| 48 | md.mesh.elementonsurface=ones(md.mesh.numberofelements2d,1);
|
---|
| 49 | md.mesh.vertexonbed=ones(md.mesh.numberofvertices2d,1);
|
---|
| 50 | md.mesh.vertexonsurface=ones(md.mesh.numberofvertices2d,1);
|
---|
[1] | 51 |
|
---|
| 52 | %elementstype
|
---|
[9661] | 53 | if ~isnan(md.flowequation.element_equation)
|
---|
| 54 | md.flowequation.element_equation=project2d(md,md.flowequation.element_equation,1);
|
---|
[11527] | 55 | md.flowequation.vertex_equation=project2d(md,md.flowequation.vertex_equation,1);
|
---|
| 56 | md.flowequation.bordermacayeal=project2d(md,md.flowequation.bordermacayeal,1);
|
---|
| 57 | md.flowequation.borderpattyn=project2d(md,md.flowequation.borderpattyn,1);
|
---|
| 58 | md.flowequation.borderstokes=project2d(md,md.flowequation.borderstokes,1);
|
---|
[1] | 59 | end
|
---|
| 60 |
|
---|
| 61 | %boundary conditions
|
---|
[9725] | 62 | md.diagnostic.spcvx=project2d(md,md.diagnostic.spcvx,md.mesh.numberoflayers);
|
---|
| 63 | md.diagnostic.spcvy=project2d(md,md.diagnostic.spcvy,md.mesh.numberoflayers);
|
---|
| 64 | md.diagnostic.spcvz=project2d(md,md.diagnostic.spcvz,md.mesh.numberoflayers);
|
---|
[11527] | 65 | md.diagnostic.referential=project2d(md,md.diagnostic.referential,md.mesh.numberoflayers);
|
---|
[9725] | 66 | md.prognostic.spcthickness=project2d(md,md.prognostic.spcthickness,md.mesh.numberoflayers);
|
---|
| 67 | md.thermal.spctemperature=project2d(md,md.thermal.spctemperature,md.mesh.numberoflayers);
|
---|
[1] | 68 |
|
---|
| 69 | %Extrusion of Neumann BC
|
---|
[9679] | 70 | if ~isnan(md.diagnostic.icefront),
|
---|
[11527] | 71 | numberofneumann2d=size(md.diagnostic.icefront,1)/(md.mesh.numberoflayers-1);
|
---|
[9679] | 72 | 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] | 73 | end
|
---|
[1] | 74 |
|
---|
| 75 | %materials
|
---|
[9636] | 76 | md.materials.rheology_B=DepthAverage(md,md.materials.rheology_B);
|
---|
| 77 | md.materials.rheology_n=project2d(md,md.materials.rheology_n,1);
|
---|
[1] | 78 |
|
---|
| 79 | %special for thermal modeling:
|
---|
[9612] | 80 | md.basalforcings.melting_rate=project2d(md,md.basalforcings.melting_rate,1);
|
---|
| 81 | md.basalforcings.geothermalflux=project2d(md,md.basalforcings.geothermalflux,1); %bedrock only gets geothermal flux
|
---|
[1] | 82 |
|
---|
| 83 | %update of connectivity matrix
|
---|
[9705] | 84 | md.mesh.average_vertex_connectivity=25;
|
---|
[1] | 85 |
|
---|
| 86 | %Collapse the mesh
|
---|
[9725] | 87 | nodes2d=md.mesh.numberofvertices2d;
|
---|
| 88 | elements2d=md.mesh.numberofelements2d;
|
---|
[1] | 89 |
|
---|
| 90 | %parameters
|
---|
[9691] | 91 | md.geometry.surface=project2d(md,md.geometry.surface,1);
|
---|
| 92 | md.geometry.thickness=project2d(md,md.geometry.thickness,1);
|
---|
| 93 | md.geometry.bed=project2d(md,md.geometry.bed,1);
|
---|
[12706] | 94 | md.geometry.bathymetry=project2d(md,md.geometry.bathymetry,1);
|
---|
[9714] | 95 | md.mesh.vertexonboundary=project2d(md,md.mesh.vertexonboundary,1);
|
---|
[11995] | 96 | md.mesh.elementconnectivity=project2d(md,md.mesh.elementconnectivity,1);
|
---|
[9641] | 97 | md.mask.elementonfloatingice=project2d(md,md.mask.elementonfloatingice,1);
|
---|
| 98 | md.mask.vertexonfloatingice=project2d(md,md.mask.vertexonfloatingice,1);
|
---|
| 99 | md.mask.elementongroundedice=project2d(md,md.mask.elementongroundedice,1);
|
---|
| 100 | md.mask.vertexongroundedice=project2d(md,md.mask.vertexongroundedice,1);
|
---|
[11527] | 101 | md.mask.elementonwater=project2d(md,md.mask.elementonwater,1);
|
---|
| 102 | md.mask.vertexonwater=project2d(md,md.mask.vertexonwater,1);
|
---|
[1] | 103 |
|
---|
[11995] | 104 | %lat long
|
---|
[12329] | 105 | if numel(md.mesh.lat) ==md.mesh.numberofvertices, md.mesh.lat=project2d(md,md.mesh.lat,1); end
|
---|
| 106 | if numel(md.mesh.long)==md.mesh.numberofvertices, md.mesh.long=project2d(md,md.mesh.long,1); end
|
---|
[11995] | 107 |
|
---|
[1] | 108 | %Initialize with the 2d mesh
|
---|
[9734] | 109 | md.mesh.x=md.mesh.x2d;
|
---|
| 110 | md.mesh.y=md.mesh.y2d;
|
---|
| 111 | md.mesh.z=zeros(size(md.mesh.x2d));
|
---|
[9725] | 112 | md.mesh.numberofvertices=md.mesh.numberofvertices2d;
|
---|
| 113 | md.mesh.numberofelements=md.mesh.numberofelements2d;
|
---|
[9733] | 114 | md.mesh.elements=md.mesh.elements2d;
|
---|
[1] | 115 |
|
---|
[8298] | 116 | %Keep a trace of lower and upper nodes
|
---|
[9729] | 117 | md.mesh.lowervertex=NaN;
|
---|
| 118 | md.mesh.uppervertex=NaN;
|
---|
[11995] | 119 | md.mesh.lowerelements=NaN;
|
---|
| 120 | md.mesh.upperelements=NaN;
|
---|
[1] | 121 |
|
---|
| 122 | %Remove old mesh
|
---|
[9731] | 123 | md.mesh.x2d=NaN;
|
---|
| 124 | md.mesh.y2d=NaN;
|
---|
| 125 | md.mesh.elements2d=NaN;
|
---|
[9725] | 126 | md.mesh.numberofelements2d=md.mesh.numberofelements;
|
---|
| 127 | md.mesh.numberofvertices2d=md.mesh.numberofvertices;
|
---|
| 128 | md.mesh.numberoflayers=0;
|
---|
[1] | 129 |
|
---|
| 130 | %Update mesh type
|
---|
[9719] | 131 | md.mesh.dimension=2;
|
---|