Changeset 22758 for issm/trunk/src/c/analyses/EnthalpyAnalysis.cpp
- Timestamp:
- 05/10/18 10:24:27 (7 years ago)
- Location:
- issm/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:mergeinfo changed
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/c
- Property svn:ignore
-
old new 20 20 kriging 21 21 issm_slr 22 issm_ocean 23 lnb_param.mod 24 lovenb_sub.mod 25 model.mod 26 util.mod
-
- Property svn:ignore
-
issm/trunk/src/c/analyses/EnthalpyAnalysis.cpp
r21729 r22758 20 20 /*Output*/ 21 21 IssmDouble *spcvector = NULL; 22 IssmDouble *spcvectorstatic = NULL; 22 23 IssmDouble* times=NULL; 23 24 IssmDouble* values=NULL; 25 IssmDouble* issurface = NULL; 24 26 25 27 /*Fetch parameters: */ … … 32 34 33 35 /*Fetch data: */ 36 iomodel->FetchData(&issurface,&M,&N,"md.mesh.vertexonsurface"); _assert_(N>0); _assert_(M==iomodel->numberofvertices); 34 37 iomodel->FetchData(&spcvector,&M,&N,"md.thermal.spctemperature"); 35 36 /*Convert spcs from temperatures to enthalpy*/ 37 _assert_(N>0); _assert_(M>=iomodel->numberofvertices); 38 for(int i=0;i<iomodel->numberofvertices;i++){ 39 for(int j=0;j<N;j++){ 40 spcvector[i*N+j] = heatcapacity*(spcvector[i*N+j]-referencetemperature); 41 } 42 } 38 iomodel->FetchData(&spcvectorstatic,&M,&N,"md.thermal.spctemperature"); 43 39 44 40 /*Specific case for PDD, we want the constaints to be updated by the PDD scheme itself*/ … … 51 47 } 52 48 49 /*Convert spcs from temperatures to enthalpy*/ 50 _assert_(N>0); _assert_(M>=iomodel->numberofvertices); 51 for(int i=0;i<iomodel->numberofvertices;i++){ 52 for(int j=0;j<N;j++){ 53 if (isdynamic){ 54 if (issurface[i]==1){ 55 spcvector[i*N+j] = heatcapacity*(spcvector[i*N+j]-referencetemperature); 56 spcvectorstatic[i*N+j] = NAN; 57 } 58 else{ 59 spcvector[i*N+j] = NAN; 60 spcvectorstatic[i*N+j] = heatcapacity*(spcvectorstatic[i*N+j]-referencetemperature); 61 } 62 } 63 else{ 64 spcvector[i*N+j] = heatcapacity*(spcvector[i*N+j]-referencetemperature); 65 } 66 } 67 } 68 53 69 if(isdynamic){ 54 IoModelToDynamicConstraintsx(constraints,iomodel,spcvector,M,N,EnthalpyAnalysisEnum,finiteelement); 70 IoModelToDynamicConstraintsx(constraints,iomodel,spcvector,iomodel->numberofvertices,1,EnthalpyAnalysisEnum,finiteelement); 71 IoModelToConstraintsx(constraints,iomodel,spcvectorstatic,M,N,EnthalpyAnalysisEnum,finiteelement); 55 72 } 56 73 else{ … … 60 77 /*Free ressources:*/ 61 78 iomodel->DeleteData(spcvector,"md.thermal.spctemperature"); 79 iomodel->DeleteData(spcvectorstatic,"md.thermal.spctemperature"); 80 iomodel->DeleteData(issurface,"md.mesh.vertexonsurface"); 62 81 xDelete<IssmDouble>(times); 63 82 xDelete<IssmDouble>(values); … … 174 193 switch(frictionlaw){ 175 194 case 1: 195 iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling"); 176 196 iomodel->FetchDataToInput(elements,"md.friction.coefficient",FrictionCoefficientEnum); 177 197 iomodel->FetchDataToInput(elements,"md.friction.p",FrictionPEnum); 178 198 iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum); 199 if (FrictionCoupling==1){ 200 iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum); 201 } 179 202 break; 180 203 case 2: … … 187 210 iomodel->FetchDataToInput(elements,"md.friction.As",FrictionAsEnum); 188 211 iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum); 189 if (FrictionCoupling== 0){212 if (FrictionCoupling==1){ 190 213 iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum); 191 214 } … … 210 233 iomodel->FetchDataToInput(elements,"md.initialization.temperature",TemperatureEnum); 211 234 break; 235 case 7: 236 iomodel->FindConstant(&FrictionCoupling,"md.friction.coupling"); 237 iomodel->FetchDataToInput(elements,"md.friction.coefficient",FrictionCoefficientEnum); 238 iomodel->FetchDataToInput(elements,"md.friction.coefficientcoulomb",FrictionCoefficientcoulombEnum); 239 iomodel->FetchDataToInput(elements,"md.friction.p",FrictionPEnum); 240 iomodel->FetchDataToInput(elements,"md.friction.q",FrictionQEnum); 241 if (FrictionCoupling==1){ 242 iomodel->FetchDataToInput(elements,"md.friction.effective_pressure",FrictionEffectivePressureEnum); 243 } 244 break; 212 245 case 9: 213 246 iomodel->FetchDataToInput(elements,"md.friction.coefficient",FrictionCoefficientEnum); … … 217 250 break; 218 251 default: 219 _error_(" not supported");252 _error_("friction law not supported"); 220 253 } 221 254 … … 244 277 int frictionlaw; 245 278 iomodel->FindConstant(&frictionlaw,"md.friction.law"); 246 if(frictionlaw==4 || frictionlaw==6) parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum)); 247 if(frictionlaw==3) parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum)); 248 if(frictionlaw==9) parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum)); 279 if(frictionlaw==4 || frictionlaw==6){ 280 parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum)); 281 } 282 if(frictionlaw==3 || frictionlaw==1 || frictionlaw==7){ 283 parameters->AddObject(iomodel->CopyConstantObject("md.friction.coupling",FrictionCouplingEnum)); 284 } 285 if(frictionlaw==9){ 286 parameters->AddObject(iomodel->CopyConstantObject("md.friction.gamma",FrictionGammaEnum)); 287 parameters->AddObject(new IntParam(FrictionCouplingEnum,0)); 288 } 249 289 }/*}}}*/ 250 290 … … 302 342 ComputeBasalMeltingrate(element); 303 343 } 344 345 /*extrude inputs*/ 346 femmodel->parameters->SetParam(BasalforcingsGroundediceMeltingRateEnum,InputToExtrudeEnum); 347 extrudefrombase_core(femmodel); 304 348 }/*}}}*/ 305 349 void EnthalpyAnalysis::ComputeBasalMeltingrate(Element* element){/*{{{*/ … … 525 569 IssmDouble* basis = xNew<IssmDouble>(numnodes); 526 570 IssmDouble* dbasis = xNew<IssmDouble>(3*numnodes); 527 IssmDouble* B = xNew<IssmDouble>(3*numnodes);528 571 IssmDouble* Bprime = xNew<IssmDouble>(3*numnodes); 529 IssmDouble D[3][3] = {0.};530 572 IssmDouble K[3][3]; 531 573 … … 556 598 557 599 element->JacobianDeterminant(&Jdet,xyz_list,gauss); 600 element->NodalFunctions(basis,gauss); 601 element->NodalFunctionsDerivatives(dbasis,xyz_list,gauss); 602 558 603 D_scalar=gauss->weight*Jdet; 559 604 if(dt!=0.) D_scalar=D_scalar*dt; 560 605 561 606 /*Conduction: */ 562 GetBConduct(B,element,xyz_list,gauss); 563 D[0][0]=D_scalar*kappa/rho_ice; 564 D[1][1]=D_scalar*kappa/rho_ice; 565 D[2][2]=D_scalar*kappa/rho_ice; 566 TripleMultiply(B,3,numnodes,1, 567 &D[0][0],3,3,0, 568 B,3,numnodes,0, 569 &Ke->values[0],1); 607 for(int i=0;i<numnodes;i++){ 608 for(int j=0;j<numnodes;j++){ 609 Ke->values[i*numnodes+j] += D_scalar*kappa/rho_ice*( 610 dbasis[0*numnodes+j]*dbasis[0*numnodes+i] + dbasis[1*numnodes+j]*dbasis[1*numnodes+i] + dbasis[2*numnodes+j]*dbasis[2*numnodes+i] 611 ); 612 } 613 } 570 614 571 615 /*Advection: */ 572 GetBAdvec(B,element,xyz_list,gauss);573 GetBAdvecprime(Bprime,element,xyz_list,gauss);574 616 vx_input->GetInputValue(&u,gauss); vxm_input->GetInputValue(&um,gauss); vx=u-um; 575 617 vy_input->GetInputValue(&v,gauss); vym_input->GetInputValue(&vm,gauss); vy=v-vm; 576 618 vz_input->GetInputValue(&w,gauss); vzm_input->GetInputValue(&wm,gauss); vz=w-wm; 577 D[0][0]=D_scalar*vx;578 D[1][1]=D_scalar*vy;579 D[2][2]=D_scalar*vz;580 TripleMultiply(B,3,numnodes,1,581 &D[0][0],3,3,0,582 Bprime,3,numnodes,0,583 &Ke->values[0],1);619 for(int i=0;i<numnodes;i++){ 620 for(int j=0;j<numnodes;j++){ 621 Ke->values[i*numnodes+j] += D_scalar*( 622 vx*dbasis[0*numnodes+j]*basis[i] + vy*dbasis[1*numnodes+j]*basis[i] +vz*dbasis[2*numnodes+j]*basis[i] 623 ); 624 } 625 } 584 626 585 627 /*Transient: */ 586 628 if(dt!=0.){ 587 629 D_scalar=gauss->weight*Jdet; 588 element->NodalFunctions(basis,gauss);589 TripleMultiply(basis,numnodes,1,0,590 &D_scalar,1,1,0,591 basis,1,numnodes,0,592 &Ke->values[0],1);630 for(int i=0;i<numnodes;i++){ 631 for(int j=0;j<numnodes;j++){ 632 Ke->values[i*numnodes+j] += D_scalar*basis[j]*basis[i]; 633 } 634 } 593 635 D_scalar=D_scalar*dt; 594 636 } … … 634 676 xDelete<IssmDouble>(basis); 635 677 xDelete<IssmDouble>(dbasis); 636 xDelete<IssmDouble>(B);637 678 xDelete<IssmDouble>(Bprime); 638 679 delete gauss; … … 1063 1104 xDelete<IssmDouble>(watercolumn); 1064 1105 xDelete<IssmDouble>(drainage_int); 1065 }1066 xDelete<int>(basalnodeindices);1106 xDelete<int>(basalnodeindices); 1107 } 1067 1108 }/*}}}*/ 1068 1109 void EnthalpyAnalysis::DrainageUpdateEnthalpy(FemModel* femmodel){/*{{{*/ … … 1510 1551 /*Update Rheology only if converged (we must make sure that the temperature is below melting point 1511 1552 * otherwise the rheology could be negative*/ 1512 element->FindParam(&rheology_law,MaterialsRheologyLawEnum);1553 rheology_law=element->GetIntegerMaterialParameter(MaterialsRheologyLawEnum); 1513 1554 element->GetInputListOnNodes(&surface[0],SurfaceEnum); 1514 1555 switch(rheology_law){
Note:
See TracChangeset
for help on using the changeset viewer.