Changeset 16832
- Timestamp:
- 11/19/13 14:25:55 (11 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/analyses/BalancethicknessAnalysis.cpp
r16811 r16832 136 136 /*Intermediaries */ 137 137 IssmDouble dhdt,mb,ms,Jdet; 138 IssmDouble* xyz_list ;138 IssmDouble* xyz_list = NULL; 139 139 140 140 /*Fetch number of nodes and dof for this finite element*/ … … 177 177 /*Intermediaries */ 178 178 IssmDouble dhdt,mb,ms,Jdet; 179 IssmDouble* xyz_list ;179 IssmDouble* xyz_list = NULL; 180 180 181 181 /*Fetch number of nodes and dof for this finite element*/ -
issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp
r16809 r16832 213 213 /*Finite Element Analysis*/ 214 214 ElementMatrix* MasstransportAnalysis::CreateKMatrix(Element* element){/*{{{*/ 215 _error_("not implemented yet"); 215 216 if(!element->IsOnBed()) return NULL; 217 Element* basalelement = element->SpawnBasalElement(); 218 219 int meshtype; 220 element->FindParam(&meshtype,MeshTypeEnum); 221 222 switch(element->FiniteElement()){ 223 case P1Enum: case P2Enum: 224 return CreateKMatrixCG(basalelement); 225 case P1DGEnum: 226 return CreateKMatrixDG(basalelement); 227 default: 228 _error_("Element type " << EnumToStringx(element->FiniteElement()) << " not supported yet"); 229 } 230 }/*}}}*/ 231 ElementMatrix* MasstransportAnalysis::CreateKMatrixCG(Element* element){/*{{{*/ 232 233 /*Intermediaries */ 234 int stabilization; 235 int meshtype; 236 IssmDouble Jdet,D_scalar,dt,h; 237 IssmDouble vel,vx,vy,dvxdx,dvydy; 238 IssmDouble dvx[2],dvy[2]; 239 IssmDouble* xyz_list = NULL; 240 241 /*Fetch number of nodes and dof for this finite element*/ 242 int numnodes = element->GetNumberOfNodes(); 243 244 /*Initialize Element vector and other vectors*/ 245 ElementMatrix* Ke = element->NewElementMatrix(); 246 IssmDouble* basis = xNew<IssmDouble>(numnodes); 247 IssmDouble* B = xNew<IssmDouble>(2*numnodes); 248 IssmDouble* Bprime = xNew<IssmDouble>(2*numnodes); 249 IssmDouble D[2][2]; 250 251 /*Retrieve all inputs and parameters*/ 252 element->GetVerticesCoordinates(&xyz_list); 253 element->FindParam(&dt,TimesteppingTimeStepEnum); 254 element->FindParam(&meshtype,MeshTypeEnum); 255 element->FindParam(&stabilization,MasstransportStabilizationEnum); 256 Input* vxaverage_input=NULL; 257 Input* vyaverage_input=NULL; 258 if(meshtype==Mesh2DhorizontalEnum){ 259 vxaverage_input=element->GetInput(VxEnum); _assert_(vxaverage_input); 260 vyaverage_input=element->GetInput(VyEnum); _assert_(vyaverage_input); 261 } 262 else{ 263 vxaverage_input=element->GetInput(VxAverageEnum); _assert_(vxaverage_input); 264 vyaverage_input=element->GetInput(VyAverageEnum); _assert_(vyaverage_input); 265 } 266 h = element->CharacteristicLength(); 267 268 /* Start looping on the number of gaussian points: */ 269 Gauss* gauss=element->NewGauss(2); 270 for(int ig=gauss->begin();ig<gauss->end();ig++){ 271 gauss->GaussPoint(ig); 272 273 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 274 element->NodalFunctions(basis,gauss); 275 276 vxaverage_input->GetInputValue(&vx,gauss); 277 vyaverage_input->GetInputValue(&vy,gauss); 278 vxaverage_input->GetInputDerivativeValue(&dvx[0],xyz_list,gauss); 279 vyaverage_input->GetInputDerivativeValue(&dvy[0],xyz_list,gauss); 280 281 D_scalar=gauss->weight*Jdet; 282 TripleMultiply(basis,1,numnodes,1, 283 &D_scalar,1,1,0, 284 basis,1,numnodes,0, 285 &Ke->values[0],1); 286 287 GetB(B,element,xyz_list,gauss); 288 GetBprime(Bprime,element,xyz_list,gauss); 289 290 dvxdx=dvx[0]; 291 dvydy=dvy[1]; 292 D_scalar=dt*gauss->weight*Jdet; 293 294 D[0][0]=D_scalar*dvxdx; 295 D[0][1]=0.; 296 D[1][0]=0.; 297 D[1][1]=D_scalar*dvydy; 298 TripleMultiply(B,2,numnodes,1, 299 &D[0][0],2,2,0, 300 B,2,numnodes,0, 301 &Ke->values[0],1); 302 303 D[0][0]=D_scalar*vx; 304 D[1][1]=D_scalar*vy; 305 TripleMultiply(B,2,numnodes,1, 306 &D[0][0],2,2,0, 307 Bprime,2,numnodes,0, 308 &Ke->values[0],1); 309 310 if(stabilization==2){ 311 /*Streamline upwinding*/ 312 vel=sqrt(vx*vx+vy*vy)+1.e-8; 313 D[0][0]=h/(2*vel)*vx*vx; 314 D[1][0]=h/(2*vel)*vy*vx; 315 D[0][1]=h/(2*vel)*vx*vy; 316 D[1][1]=h/(2*vel)*vy*vy; 317 } 318 else if(stabilization==1){ 319 /*SSA*/ 320 vxaverage_input->GetInputAverage(&vx); 321 vyaverage_input->GetInputAverage(&vy); 322 D[0][0]=h/2.0*fabs(vx); 323 D[0][1]=0.; 324 D[1][0]=0.; 325 D[1][1]=h/2.0*fabs(vy); 326 } 327 if(stabilization==1 || stabilization==2){ 328 D[0][0]=D_scalar*D[0][0]; 329 D[1][0]=D_scalar*D[1][0]; 330 D[0][1]=D_scalar*D[0][1]; 331 D[1][1]=D_scalar*D[1][1]; 332 TripleMultiply(Bprime,2,numnodes,1, 333 &D[0][0],2,2,0, 334 Bprime,2,numnodes,0, 335 &Ke->values[0],1); 336 } 337 } 338 339 /*Clean up and return*/ 340 xDelete<IssmDouble>(xyz_list); 341 xDelete<IssmDouble>(basis); 342 xDelete<IssmDouble>(B); 343 xDelete<IssmDouble>(Bprime); 344 delete gauss; 345 return Ke; 346 }/*}}}*/ 347 ElementMatrix* MasstransportAnalysis::CreateKMatrixDG(Element* element){/*{{{*/ 348 349 /*Intermediaries */ 350 int meshtype; 351 IssmDouble Jdet,D_scalar,dt,vx,vy; 352 IssmDouble* xyz_list = NULL; 353 354 /*Fetch number of nodes and dof for this finite element*/ 355 int numnodes = element->GetNumberOfNodes(); 356 357 /*Initialize Element vector and other vectors*/ 358 ElementMatrix* Ke = element->NewElementMatrix(); 359 IssmDouble* basis = xNew<IssmDouble>(numnodes); 360 IssmDouble* B = xNew<IssmDouble>(2*numnodes); 361 IssmDouble* Bprime = xNew<IssmDouble>(2*numnodes); 362 IssmDouble D[2][2]; 363 364 /*Retrieve all inputs and parameters*/ 365 element->GetVerticesCoordinates(&xyz_list); 366 element->FindParam(&dt,TimesteppingTimeStepEnum); 367 element->FindParam(&meshtype,MeshTypeEnum); 368 Input* vxaverage_input=NULL; 369 Input* vyaverage_input=NULL; 370 if(meshtype==Mesh2DhorizontalEnum){ 371 vxaverage_input=element->GetInput(VxEnum); _assert_(vxaverage_input); 372 vyaverage_input=element->GetInput(VyEnum); _assert_(vyaverage_input); 373 } 374 else{ 375 vxaverage_input=element->GetInput(VxAverageEnum); _assert_(vxaverage_input); 376 vyaverage_input=element->GetInput(VyAverageEnum); _assert_(vyaverage_input); 377 } 378 379 /* Start looping on the number of gaussian points: */ 380 Gauss* gauss=element->NewGauss(2); 381 for(int ig=gauss->begin();ig<gauss->end();ig++){ 382 gauss->GaussPoint(ig); 383 384 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 385 element->NodalFunctions(basis,gauss); 386 387 vxaverage_input->GetInputValue(&vx,gauss); 388 vyaverage_input->GetInputValue(&vy,gauss); 389 390 D_scalar=gauss->weight*Jdet; 391 TripleMultiply(basis,1,numnodes,1, 392 &D_scalar,1,1,0, 393 basis,1,numnodes,0, 394 &Ke->values[0],1); 395 396 /*WARNING: B and Bprime are inverted compared to CG*/ 397 GetB(Bprime,element,xyz_list,gauss); 398 GetBprime(B,element,xyz_list,gauss); 399 400 D_scalar = - dt*gauss->weight*Jdet; 401 D[0][0] = D_scalar*vx; 402 D[0][1] = 0.; 403 D[1][0] = 0.; 404 D[1][1] = D_scalar*vy; 405 TripleMultiply(B,2,numnodes,1, 406 &D[0][0],2,2,0, 407 Bprime,2,numnodes,0, 408 &Ke->values[0],1); 409 410 } 411 412 /*Clean up and return*/ 413 xDelete<IssmDouble>(xyz_list); 414 xDelete<IssmDouble>(basis); 415 xDelete<IssmDouble>(B); 416 xDelete<IssmDouble>(Bprime); 417 delete gauss; 418 return Ke; 216 419 }/*}}}*/ 217 420 ElementVector* MasstransportAnalysis::CreatePVector(Element* element){/*{{{*/ … … 235 438 IssmDouble Jdet,dt; 236 439 IssmDouble ms,mb,mb_correction=0.,thickness; 237 IssmDouble* xyz_list ;440 IssmDouble* xyz_list = NULL; 238 441 239 442 /*Fetch number of nodes and dof for this finite element*/ … … 281 484 IssmDouble Jdet,dt; 282 485 IssmDouble ms,mb,mb_correction=0.,thickness; 283 IssmDouble* xyz_list ;486 IssmDouble* xyz_list = NULL; 284 487 285 488 /*Fetch number of nodes and dof for this finite element*/ … … 321 524 delete gauss; 322 525 return pe; 526 }/*}}}*/ 527 void MasstransportAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 528 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 529 * For node i, Bi can be expressed in the actual coordinate system 530 * by: 531 * Bi=[ N ] 532 * [ N ] 533 * where N is the finiteelement function for node i. 534 * 535 * We assume B_prog has been allocated already, of size: 2x(NDOF1*numnodes) 536 */ 537 538 /*Fetch number of nodes for this finite element*/ 539 int numnodes = element->GetNumberOfNodes(); 540 541 /*Get nodal functions*/ 542 IssmDouble* basis=xNew<IssmDouble>(numnodes); 543 element->NodalFunctions(basis,gauss); 544 545 /*Build B: */ 546 for(int i=0;i<numnodes;i++){ 547 B[numnodes*0+i] = basis[i]; 548 B[numnodes*1+i] = basis[i]; 549 } 550 551 /*Clean-up*/ 552 xDelete<IssmDouble>(basis); 553 }/*}}}*/ 554 void MasstransportAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 555 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 556 * For node i, Bi' can be expressed in the actual coordinate system 557 * by: 558 * Bi_prime=[ dN/dx ] 559 * [ dN/dy ] 560 * where N is the finiteelement function for node i. 561 * 562 * We assume B' has been allocated already, of size: 3x(NDOF2*numnodes) 563 */ 564 565 /*Fetch number of nodes for this finite element*/ 566 int numnodes = element->GetNumberOfNodes(); 567 568 /*Get nodal functions derivatives*/ 569 IssmDouble* dbasis=xNew<IssmDouble>(2*numnodes); 570 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 571 572 /*Build B': */ 573 for(int i=0;i<numnodes;i++){ 574 Bprime[numnodes*0+i] = dbasis[0*numnodes+i]; 575 Bprime[numnodes*1+i] = dbasis[1*numnodes+i]; 576 } 577 578 /*Clean-up*/ 579 xDelete<IssmDouble>(dbasis); 580 323 581 }/*}}}*/ 324 582 void MasstransportAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ -
issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.h
r16809 r16832 22 22 /*Finite element Analysis*/ 23 23 ElementMatrix* CreateKMatrix(Element* element); 24 ElementMatrix* CreateKMatrixCG(Element* element); 25 ElementMatrix* CreateKMatrixDG(Element* element); 24 26 ElementVector* CreatePVector(Element* element); 25 27 ElementVector* CreatePVectorCG(Element* element); 26 28 ElementVector* CreatePVectorDG(Element* element); 29 void GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 30 void GetBprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss); 27 31 void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element); 28 32 void InputUpdateFromSolution(IssmDouble* solution,Element* element); -
issm/trunk-jpl/src/c/classes/Elements/Element.h
r16831 r16832 37 37 virtual ~Element(){}; 38 38 39 virtual IssmDouble CharacteristicLength(void)=0; 39 40 virtual void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0; 40 41 virtual void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters)=0; -
issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
r16831 r16832 3011 3011 this->InputDepthAverageAtBase(MaterialsRheologyBEnum,MaterialsRheologyBbarEnum,MaterialsEnum); 3012 3012 this->InputDepthAverageAtBase(DamageDEnum,DamageDbarEnum,MaterialsEnum); 3013 if(this->inputs->GetInput(VxEnum)) this->InputDepthAverageAtBase(VxEnum,VxAverageEnum); 3014 if(this->inputs->GetInput(VyEnum)) this->InputDepthAverageAtBase(VyEnum,VyAverageEnum); 3013 3015 Tria* tria=(Tria*)SpawnTria(0); //lower face is 0, upper face is 1. 3014 3016 this->material->inputs->DeleteInput(MaterialsRheologyBbarEnum); 3015 3017 this->material->inputs->DeleteInput(DamageDbarEnum); 3018 this->inputs->DeleteInput(VxAverageEnum); 3019 this->inputs->DeleteInput(VyAverageEnum); 3016 3020 3017 3021 return tria; -
issm/trunk-jpl/src/c/classes/Elements/Penta.h
r16831 r16832 69 69 /*Element virtual functions definitions: {{{*/ 70 70 void BasalFrictionCreateInput(void); 71 IssmDouble CharacteristicLength(void){_error_("not implemented yet");}; 71 72 void ComputeBasalStress(Vector<IssmDouble>* sigma_b); 72 73 void ComputeStrainRate(Vector<IssmDouble>* eps); -
issm/trunk-jpl/src/c/classes/Elements/Seg.h
r16831 r16832 70 70 void AddInput(int input_enum, IssmDouble* values, int interpolation_enum){_error_("not implemented yet");}; 71 71 void AddMaterialInput(int input_enum, IssmDouble* values, int interpolation_enum){_error_("not implemented yet");}; 72 IssmDouble CharacteristicLength(void){_error_("not implemented yet");}; 72 73 void ComputeBasalStress(Vector<IssmDouble>* sigma_b){_error_("not implemented yet");}; 73 74 void ComputeStrainRate(Vector<IssmDouble>* eps){_error_("not implemented yet");}; -
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r16831 r16832 196 196 _assert_(this->material); 197 197 this->material->inputs->AddInput(new TriaInput(input_enum,values,interpolation_enum)); 198 } 199 /*}}}*/ 200 /*FUNCTION Tria::AddInput{{{*/ 201 IssmDouble Tria::CharacteristicLength(void){ 202 203 return sqrt(2*this->GetArea()); 198 204 } 199 205 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Elements/Tria.h
r16831 r16832 67 67 /*}}}*/ 68 68 /*Element virtual functions definitions: {{{*/ 69 IssmDouble CharacteristicLength(void); 69 70 void ComputeBasalStress(Vector<IssmDouble>* sigma_b); 70 71 void ComputeStrainRate(Vector<IssmDouble>* eps);
Note:
See TracChangeset
for help on using the changeset viewer.