Changeset 21759 for issm/branches/trunk-larour-NatGeoScience2016/src/c/analyses/ExtrapolationAnalysis.cpp
- Timestamp:
- 06/07/17 10:50:54 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/branches/trunk-larour-NatGeoScience2016/src/c/analyses/ExtrapolationAnalysis.cpp
r20690 r21759 84 84 85 85 /*Intermediaries */ 86 int dim, domaintype, extrapolationcase;87 int i,row,col,stabilization;88 bool extrapolatebydiffusion;89 IssmDouble Jdet,D_scalar,h;90 IssmDouble norm_dlsf;91 IssmDouble hx,hy,hz,kappa;92 IssmDouble * xyz_list= NULL;93 Element * workelement=NULL;86 bool extrapolatebydiffusion = true; 87 int dim, domaintype, extrapolationcase; 88 int i,row,col,stabilization; 89 IssmDouble Jdet,D_scalar,h; 90 IssmDouble norm_dlsf; 91 IssmDouble hx,hy,hz,kappa; 92 IssmDouble *xyz_list = NULL; 93 Element *workelement = NULL; 94 94 95 95 /*Get problem case*/ … … 102 102 case 1: case 2: case 3: workelement=element; break; 103 103 } 104 104 105 /* get extrapolation dimension */ 105 106 workelement->FindParam(&domaintype,DomainTypeEnum); 106 107 switch(domaintype){ 107 case Domain2DverticalEnum: dim=1; break;108 case Domain2DverticalEnum: dim=1; break; 108 109 case Domain2DhorizontalEnum: dim=2; break; 109 case Domain3DEnum: dim=3; break; 110 case Domain3DEnum: dim=3; break; 111 default: _error_("not supported yet"); 110 112 } 111 113 … … 117 119 IssmDouble* B = xNew<IssmDouble>(dim*numnodes); 118 120 IssmDouble* Bprime = xNew<IssmDouble>(dim*numnodes); 119 IssmDouble* D = xNew<IssmDouble>(dim*dim);120 IssmDouble* dlsf= xNew<IssmDouble>(dim);121 IssmDouble* normal= xNew<IssmDouble>(dim);121 IssmDouble* dlsf = xNew<IssmDouble>(dim); 122 IssmDouble* normal = xNew<IssmDouble>(dim); 123 IssmDouble* D = xNewZeroInit<IssmDouble>(dim*dim); 122 124 123 125 /*Retrieve all inputs and parameters*/ … … 126 128 workelement->GetVerticesCoordinates(&xyz_list); 127 129 130 /* In 3d we are going to extrude using horizontal diffusion. Since the layers are 3d, 131 * we change the geometry of the element to make it flat. That way, the diffusion is 132 * handled along the layers 133 */ 134 if(element->ObjectEnum()==PentaEnum){ 135 for(i=0;i<3;i++) xyz_list[3*i+2] = 0.; 136 for(i=3;i<6;i++) xyz_list[3*i+2] = 1.; 137 } 138 128 139 /* Start looping on the number of gaussian points: */ 129 140 Gauss* gauss=workelement->NewGauss(2); 130 for(int ig=gauss->begin();ig<gauss->end();ig++){ /*{{{*/141 for(int ig=gauss->begin();ig<gauss->end();ig++){ 131 142 gauss->GaussPoint(ig); 132 143 … … 137 148 D_scalar=gauss->weight*Jdet; 138 149 139 extrapolatebydiffusion=true;140 150 if(extrapolatebydiffusion){ 141 /* diffuse values outward */ 142 for(row=0;row<dim;row++) 143 for(col=0;col<dim;col++) 144 if(row==col && row<2) //extrapolate only in xy-plane 145 D[row*dim+col] = D_scalar; 146 else 147 D[row*dim+col] = 0.; 151 152 /* diffuse values outward only along the xy-plane*/ 153 for(int i=0;i<2;i++) D[i*dim+i] = D_scalar; 148 154 149 155 TripleMultiply(Bprime,dim,numnodes,1, … … 180 186 &Ke->values[0],1); 181 187 182 /* stabilization */ /*{{{*/188 /* stabilization */ 183 189 /* do not use streamline upwinding for extrapolation: it yields oscillating results due to diffusion along normal direction, but none across */ 184 190 stabilization=1; … … 200 206 &Ke->values[0],1); 201 207 } 202 /*}}}*/203 208 } 204 } /*}}}*/209 } 205 210 206 211 /*Clean up and return*/ … … 217 222 }/*}}}*/ 218 223 ElementVector* ExtrapolationAnalysis::CreatePVector(Element* element){/*{{{*/ 219 220 /*Intermediaries */ 221 Element* workelement=NULL; 222 223 /*Get problem dimension*/ 224 int extrapolationcase=GetExtrapolationCase(element); 225 switch(extrapolationcase){ 226 case 0: 227 if(!element->IsOnBase()) return NULL; 228 workelement = element->SpawnBasalElement(); 229 break; 230 case 1: case 2: case 3: workelement=element; break; 231 } 232 233 /*Fetch number of nodes */ 234 int numnodes = workelement->GetNumberOfNodes(); 235 236 /*Initialize Element vector*/ 237 ElementVector* pe = workelement->NewElementVector(); 238 for(int i=0;i<numnodes;i++) 239 pe->values[i]=0.; 240 241 if(extrapolationcase==0){workelement->DeleteMaterials(); delete workelement;}; 242 return pe; 224 return NULL; 225 243 226 }/*}}}*/ 244 227 void ExtrapolationAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss, int dim){/*{{{*/ … … 326 309 int domaintype, extrapolationvariable; 327 310 int extrapolationcase; 311 328 312 element->FindParam(&domaintype,DomainTypeEnum); 329 313 switch(domaintype){ 330 case Domain2DverticalEnum: extrapolationcase=0; break;331 case Domain2DhorizontalEnum: extrapolationcase=1; break;332 case Domain3DEnum: 314 case Domain2DverticalEnum: extrapolationcase=0; break; 315 case Domain2DhorizontalEnum: extrapolationcase=1; break; 316 case Domain3DEnum: 333 317 element->FindParam(&extrapolationvariable, ExtrapolationVariableEnum); 334 if(extrapolationvariable==ThicknessEnum) extrapolationcase=2; // scalar fields that are constant along z-axis 335 else extrapolationcase=3; // scalar fields that vary along z-axis 318 if(extrapolationvariable==ThicknessEnum){ 319 extrapolationcase=2; // scalar fields that are constant along z-axis 320 } 321 else{ 322 extrapolationcase=3; // scalar fields that vary along z-axis 323 } 336 324 break; 337 325 }
Note:
See TracChangeset
for help on using the changeset viewer.