[1] | 1 | function md=extrude(md,numlayers,extrusionexponent)
|
---|
| 2 | %EXTRUDE - vertically extrude a 2d mesh
|
---|
| 3 | %
|
---|
| 4 | % vertically extrude a 2d mesh and create corresponding 3d mesh following the extrusionexponent,
|
---|
| 5 | % the vertical distribution follows a polynomial law:');
|
---|
| 6 | % extrusionexponent>1 refinement at the base');
|
---|
| 7 | % 0<extrusionexponent<1 refinement at the surface');
|
---|
| 8 | % extrusionexponent=1 linear extrusion');
|
---|
| 9 | %
|
---|
| 10 | % Usage:
|
---|
| 11 | % md=extrude(md,numlayers,extrusionexponent);
|
---|
| 12 | %
|
---|
| 13 | % Example:
|
---|
| 14 | % md=extrude(md,8,3);
|
---|
| 15 | %
|
---|
| 16 | % See also: MODELEXTRACT, COLLAPSE
|
---|
| 17 |
|
---|
| 18 | %some checks on list of arguments
|
---|
| 19 | if ((nargin~=3) | (nargout~=1)),
|
---|
[1241] | 20 | help extrude;
|
---|
[1] | 21 | error('extrude error message');
|
---|
| 22 | end
|
---|
| 23 |
|
---|
| 24 | if md.counter<3,
|
---|
[1241] | 25 | help extrude;
|
---|
[1] | 26 | error('only fully parameterized 2d models can be extruded');
|
---|
| 27 | end
|
---|
| 28 |
|
---|
| 29 | if md.counter>=4,
|
---|
| 30 | error('This model has already been extruded!','s');
|
---|
| 31 | end
|
---|
| 32 |
|
---|
| 33 | if numlayers<2,
|
---|
[1241] | 34 | help extrude;
|
---|
[1] | 35 | error('number of layers should be at least 2');
|
---|
| 36 | end
|
---|
| 37 |
|
---|
[1338] | 38 | if extrusionexponent<=0,
|
---|
[1241] | 39 | help extrude;
|
---|
[1338] | 40 | error('extrusionexponent must be >=0');
|
---|
[1] | 41 | end
|
---|
| 42 |
|
---|
| 43 | %Extrude the mesh
|
---|
| 44 | %Initialize with the 2d mesh
|
---|
| 45 | x3d=md.x;
|
---|
| 46 | y3d=md.y;
|
---|
| 47 | z3d=md.bed; %the lower grid is on the bed
|
---|
| 48 | thickness3d=md.thickness; %thickness and bed for these grids
|
---|
| 49 | bed3d=md.bed;
|
---|
[512] | 50 |
|
---|
[1] | 51 | %Create the new layers
|
---|
[512] | 52 | for i=1:numlayers-1,
|
---|
| 53 | x3d=[x3d; md.x];
|
---|
[1] | 54 | y3d=[y3d; md.y];
|
---|
[512] | 55 | %grids are distributed between bed and surface accordingly to the given exponent
|
---|
| 56 | z3d=[z3d; bed3d+thickness3d*(i/(numlayers-1))^extrusionexponent];
|
---|
[1] | 57 | end
|
---|
| 58 | number_grids3d=size(x3d,1); %number of 3d grids for the non extruded part of the mesh
|
---|
| 59 |
|
---|
| 60 | %Extrude elements
|
---|
| 61 | elements3d=[];
|
---|
| 62 | for i=1:numlayers-1,
|
---|
| 63 | elements3d=[elements3d;[md.elements+(i-1)*md.numberofgrids md.elements+i*md.numberofgrids]]; %Create the elements of the 3d mesh for the non extruded part
|
---|
| 64 | end
|
---|
| 65 | number_el3d=size(elements3d,1); %number of 3d grids for the non extruded part of the mesh
|
---|
| 66 |
|
---|
| 67 | %Keep a trace of lower and upper grids
|
---|
| 68 | lowergrids=NaN*ones(number_grids3d,1);
|
---|
| 69 | uppergrids=NaN*ones(number_grids3d,1);
|
---|
| 70 | lowergrids(md.numberofgrids+1:end)=1:(numlayers-1)*md.numberofgrids;
|
---|
| 71 | uppergrids(1:(numlayers-1)*md.numberofgrids)=md.numberofgrids+1:number_grids3d;
|
---|
| 72 | md.lowergrids=lowergrids;
|
---|
| 73 | md.uppergrids=uppergrids;
|
---|
| 74 |
|
---|
| 75 | %Save old mesh
|
---|
| 76 | md.x2d=md.x;
|
---|
| 77 | md.y2d=md.y;
|
---|
| 78 | md.z2d=md.z;
|
---|
| 79 | md.elements2d=md.elements;
|
---|
| 80 | md.elements_type2d=md.elements_type;
|
---|
| 81 | md.numberofelements2d=md.numberofelements;
|
---|
| 82 | md.numberofgrids2d=md.numberofgrids;
|
---|
| 83 |
|
---|
| 84 | %Update mesh type
|
---|
| 85 | md.type='3d';
|
---|
| 86 |
|
---|
| 87 | %Build global 3d mesh
|
---|
| 88 | md.elements=elements3d;
|
---|
| 89 | md.x=x3d;
|
---|
| 90 | md.y=y3d;
|
---|
| 91 | md.z=z3d;
|
---|
| 92 | md.numberofelements=number_el3d;
|
---|
| 93 | md.numberofgrids=number_grids3d;
|
---|
| 94 | md.numlayers=numlayers;
|
---|
| 95 |
|
---|
| 96 | %Ok, now deal with the other fields from the 2d mesh:
|
---|
| 97 |
|
---|
| 98 | %drag is limited to grids that are on the bedrock.
|
---|
| 99 | md.drag=project3d(md,md.drag,'node',1);
|
---|
| 100 |
|
---|
| 101 | %p and q (same deal, except for element that are on the bedrock: )
|
---|
| 102 | md.p=project3d(md,md.p,'element');
|
---|
| 103 | md.q=project3d(md,md.q,'element');
|
---|
| 104 |
|
---|
| 105 | %observations
|
---|
[510] | 106 | md.vx_obs=project3d(md,md.vx_obs,'node');
|
---|
| 107 | md.vy_obs=project3d(md,md.vy_obs,'node');
|
---|
| 108 | md.vel_obs=project3d(md,md.vel_obs,'node');
|
---|
| 109 | md.accumulation=project3d(md,md.accumulation,'node');
|
---|
[1] | 110 | md.firn_layer=project3d(md,md.firn_layer,'node',md.numlayers);
|
---|
| 111 |
|
---|
| 112 | %results
|
---|
| 113 | if ~isnan(md.vx),md.vx=project3d(md,md.vx,'node');end;
|
---|
| 114 | if ~isnan(md.vy),md.vy=project3d(md,md.vy,'node');end;
|
---|
| 115 | if ~isnan(md.vz),md.vz=project3d(md,md.vz,'node');end;
|
---|
| 116 | if ~isnan(md.vel),md.vel=project3d(md,md.vel,'node');end;
|
---|
[1240] | 117 | if ~isnan(md.temperature),md.temperature=project3d(md,md.temperature,'node');end;
|
---|
[1] | 118 | if ~isnan(md.surface_slopex),md.surface_slopex=project3d(md,md.surface_slopex,'node');end;
|
---|
| 119 | if ~isnan(md.surface_slopey),md.surface_slopey=project3d(md,md.surface_slopey,'node');end;
|
---|
| 120 | if ~isnan(md.bed_slopex),md.bed_slopex=project3d(md,md.bed_slopex,'node');end;
|
---|
| 121 | if ~isnan(md.bed_slopey),md.bed_slopey=project3d(md,md.bed_slopey,'node');end;
|
---|
| 122 |
|
---|
| 123 | %bedinfo and surface info
|
---|
| 124 | md.elementonbed=project3d(md,ones(md.numberofelements2d,1),'element',1);
|
---|
| 125 | md.elementonsurface=project3d(md,ones(md.numberofelements2d,1),'element',md.numlayers-1);
|
---|
| 126 | md.gridonbed=project3d(md,ones(md.numberofgrids2d,1),'node',1);
|
---|
| 127 | md.gridonsurface=project3d(md,ones(md.numberofgrids2d,1),'node',md.numlayers);
|
---|
| 128 |
|
---|
| 129 | %elementstype
|
---|
| 130 | if ~isnan(md.elements_type)
|
---|
| 131 | oldelements_type=md.elements_type2d;
|
---|
| 132 | md.elements_type=zeros(number_el3d,2);
|
---|
| 133 | md.elements_type(:,1)=project3d(md,oldelements_type(:,1),'element');
|
---|
| 134 | md.elements_type(:,2)=project3d(md,oldelements_type(:,2),'element');
|
---|
| 135 | md.gridonhutter=project3d(md,md.gridonhutter,'node');
|
---|
| 136 | md.gridonmacayeal=project3d(md,md.gridonmacayeal,'node');
|
---|
| 137 | md.gridonpattyn=project3d(md,md.gridonpattyn,'node');
|
---|
| 138 | md.gridonstokes=project3d(md,md.gridonstokes,'node');
|
---|
[440] | 139 |
|
---|
| 140 | %dead grids
|
---|
| 141 | md.deadgrids=ones(md.numberofgrids,1);
|
---|
[1651] | 142 | md.deadgrids(md.elements(md.elements_type(:,1)~=MacAyealFormulationEnum,:))=0;%non macayeal grids are not dead
|
---|
[440] | 143 | md.deadgrids(find(md.gridonbed))=0;%grids from elements on bed are not dead
|
---|
[1] | 144 | end
|
---|
| 145 |
|
---|
| 146 | %boundary conditions
|
---|
[1755] | 147 | md.spcvelocity=project3d(md,md.spcvelovity,'node');
|
---|
| 148 | md.spctemperature=project3d(md,md.spcvelovity,'node');
|
---|
| 149 | md.spcthickness=project3d(md,md.spcvelovity,'node');
|
---|
[1] | 150 |
|
---|
| 151 | %Extrusion of Neumann BC
|
---|
| 152 | %in 3d, segmentonnumann is: [grid1 grid2 grid3 grid4 element]
|
---|
[1755] | 153 | oldpressureload=md.pressureload;
|
---|
| 154 | pressureload_layer1=[oldpressureload(:,1:2) oldpressureload(:,2)+md.numberofgrids2d oldpressureload(:,1)+md.numberofgrids2d oldpressureload(:,3)]; %Add two columns on the first layer
|
---|
| 155 | pressureload=[];
|
---|
[1] | 156 | for i=1:numlayers-1,
|
---|
[1755] | 157 | pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.numberofgrids2d pressureload_layer1(:,5)+(i-1)*md.numberofelements2d ];
|
---|
[1] | 158 | end
|
---|
| 159 |
|
---|
| 160 | %plug into md
|
---|
[1755] | 161 | md.pressureload=pressureload;
|
---|
[1] | 162 |
|
---|
| 163 | %materials
|
---|
| 164 | md.B=project3d(md,md.B,'node');
|
---|
| 165 | md.n=project3d(md,md.n,'element');
|
---|
| 166 |
|
---|
| 167 | %parameters
|
---|
| 168 | md.surface=project3d(md,md.surface,'node');
|
---|
| 169 | md.thickness=project3d(md,md.thickness,'node');
|
---|
| 170 | md.bed=project3d(md,md.bed,'node');
|
---|
| 171 | md.gridonboundary=project3d(md,md.gridonboundary,'node');
|
---|
| 172 | md.elementoniceshelf=project3d(md,md.elementoniceshelf,'element');
|
---|
| 173 | md.gridoniceshelf=project3d(md,md.gridoniceshelf,'node');
|
---|
| 174 | md.elementonicesheet=project3d(md,md.elementonicesheet,'element');
|
---|
| 175 | md.gridonicesheet=project3d(md,md.gridonicesheet,'node');
|
---|
[1241] | 176 | md.elementonwater=project3d(md,md.elementonwater,'element');
|
---|
| 177 | md.gridonwater=project3d(md,md.gridonwater,'node');
|
---|
[1] | 178 |
|
---|
| 179 | %special for thermal modeling:
|
---|
| 180 | md.melting=project3d(md,md.melting,'node',1);
|
---|
| 181 | md.observed_temperature=project3d(md,md.observed_temperature,'node');
|
---|
| 182 | md.geothermalflux=project3d(md,md.geothermalflux,'node',1); %bedrock only gets geothermal flux
|
---|
| 183 |
|
---|
[867] | 184 | %increase connectivity if less than 25:
|
---|
| 185 | if md.connectivity<25,
|
---|
[1755] | 186 | md.connectivity=70;
|
---|
[867] | 187 | end
|
---|
| 188 |
|
---|
[1] | 189 | %augment counter keeping track of what has been done to this model
|
---|
| 190 | md.counter=4;
|
---|