Changeset 24240
- Timestamp:
- 10/17/19 06:03:43 (5 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 96 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/analyses/DamageEvolutionAnalysis.cpp
r24146 r24240 549 549 D[1*dim+1]=h/2.0*fabs(vy); 550 550 } 551 else if(dim==3){ 551 else if(dim==3){ 552 552 element->ElementSizes(&hx,&hy,&hz); 553 553 vel=sqrt(vx*vx + vy*vy + vz*vz)+1.e-14; … … 665 665 }/*}}}*/ 666 666 void DamageEvolutionAnalysis::GetB(IssmDouble* B,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 667 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 667 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 668 668 * For node i, Bi can be expressed in the actual coordinate system 669 * by: 669 * by: 670 670 * Bi=[ N ] 671 671 * [ N ] … … 693 693 }/*}}}*/ 694 694 void DamageEvolutionAnalysis::GetBprime(IssmDouble* Bprime,Element* element,int dim,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 695 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 695 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 696 696 * For node i, Bi' can be expressed in the actual coordinate system 697 * by: 697 * by: 698 698 * Bi_prime=[ dN/dx ] 699 699 * [ dN/dy ] -
issm/trunk-jpl/src/c/analyses/EnthalpyAnalysis.cpp
r24140 r24240 414 414 element->VerticalSegmentIndicesBase(&pairindices,&numsegments); 415 415 IssmDouble* meltingrate_enthalpy = xNew<IssmDouble>(numsegments); 416 IssmDouble* heating = xNew<IssmDouble>(numsegments); 416 IssmDouble* heating = xNew<IssmDouble>(numsegments); 417 417 418 418 numnodes=element->GetNumberOfNodes(); … … 440 440 for(i=0;i<3;i++) vec_heatflux[i]=0.; 441 441 break; 442 case 1: case 2: case 3: 443 // case 1 : cold, wet base: keep at pressure melting point 442 case 1: case 2: case 3: 443 // case 1 : cold, wet base: keep at pressure melting point 444 444 // case 2: temperate, thin refreezing base: release spc 445 445 // case 3: temperate, thin melting base: set spc … … 478 478 nodeup = pairindices[is*2+1]; 479 479 if(dt!=0.){ 480 if(watercolumns[nodedown]+meltingrate_enthalpy[is]*dt<0.){ // prevent too much freeze on 480 if(watercolumns[nodedown]+meltingrate_enthalpy[is]*dt<0.){ // prevent too much freeze on 481 481 lambda = -watercolumns[nodedown]/(dt*meltingrate_enthalpy[is]); _assert_(lambda>=0.); _assert_(lambda<1.); 482 482 watercolumns[nodedown]=0.; … … 486 486 else{ 487 487 basalmeltingrates[nodedown]=meltingrate_enthalpy[is]; 488 watercolumns[nodedown]+=dt*meltingrate_enthalpy[is]; 488 watercolumns[nodedown]+=dt*meltingrate_enthalpy[is]; 489 489 } 490 490 if(watercolumns[nodedown]>watercolumnupperlimit) watercolumns[nodedown]=watercolumnupperlimit; … … 496 496 else 497 497 watercolumns[nodedown]+=meltingrate_enthalpy[is]; 498 } 498 } 499 499 basalmeltingrates[nodedown]*=rho_water/rho_ice; // convert meltingrate from water to ice equivalent 500 500 _assert_(watercolumns[nodedown]>=0.); … … 503 503 /*feed updated variables back into model*/ 504 504 if(dt!=0.){ 505 element->AddInput(enthalpy_enum,enthalpies,element->GetElementType()); 505 element->AddInput(enthalpy_enum,enthalpies,element->GetElementType()); 506 506 element->AddInput(WatercolumnEnum,watercolumns,element->GetElementType()); 507 507 } … … 659 659 for(int i=0;i<3;i++) for(int j=0;j<3;j++) K[i][j] = D_scalar*K[i][j]; 660 660 661 GetBAdvecprime(Bprime,element,xyz_list,gauss); 661 GetBAdvecprime(Bprime,element,xyz_list,gauss); 662 662 TripleMultiply(Bprime,3,numnodes,1, 663 663 &K[0][0],3,3,0, … … 860 860 if(dt!=0.) scalar_sens=scalar_sens*dt; 861 861 for(i=0;i<numnodes;i++) pe->values[i]+=scalar_sens*basis[i]; 862 } 862 } 863 863 864 864 /* Build transient now */ … … 977 977 switch (state) { 978 978 case 0: case 1: case 2: case 3: 979 // cold, dry base; cold, wet base; refreezing temperate base; thin temperate base: 979 // cold, dry base; cold, wet base; refreezing temperate base; thin temperate base: 980 980 // Apply basal surface forcing. 981 // Interpolated values of enthalpy on gauss nodes may indicate cold base, 981 // Interpolated values of enthalpy on gauss nodes may indicate cold base, 982 982 // although one node might have become temperate. So keep heat flux switched on. 983 983 geothermalflux_input->GetInputValue(&geothermalflux,gauss); … … 990 990 scalar=gauss->weight*Jdet*heatflux; 991 991 if(dt!=0.) scalar=dt*scalar; 992 for(i=0;i<numnodes;i++) 992 for(i=0;i<numnodes;i++) 993 993 pe->values[i]+=scalar*basis[i]; 994 994 break; 995 995 case 4: 996 996 // temperate, thick melting base: set grad H*n=0 997 for(i=0;i<numnodes;i++) 997 for(i=0;i<numnodes;i++) 998 998 pe->values[i]+=0.; 999 999 break; … … 1132 1132 /* Check if ice in element */ 1133 1133 if(!element->IsIceInElement()) continue; 1134 if(!element->IsOnBase()) continue; 1134 if(!element->IsOnBase()) continue; 1135 1135 1136 1136 numnodes=element->GetNumberOfNodes(); … … 1257 1257 else if(effectiveconductivity_averaging==1){ 1258 1258 /* return harmonic mean (reciprocal avarage) of thermal conductivities, weighted by fraction of cold/temperate ice, cf Patankar 1980, pp44 */ 1259 kappa=kappa_c*kappa_t/(lambda*kappa_t+(1.-lambda)*kappa_c); 1259 kappa=kappa_c*kappa_t/(lambda*kappa_t+(1.-lambda)*kappa_c); 1260 1260 } 1261 1261 else if(effectiveconductivity_averaging==2){ 1262 1262 /* return geometric mean (power law) of thermal conductivities, weighted by fraction of cold/temperate ice */ 1263 kappa=pow(kappa_c,lambda)*pow(kappa_t,1.-lambda); 1263 kappa=pow(kappa_c,lambda)*pow(kappa_t,1.-lambda); 1264 1264 } 1265 1265 else{ 1266 1266 _error_("effectiveconductivity_averaging not supported yet"); 1267 1267 } 1268 } 1268 } 1269 1269 1270 1270 /*Clean up and return*/ … … 1276 1276 }/*}}}*/ 1277 1277 void EnthalpyAnalysis::GetBAdvec(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1278 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 1278 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 1279 1279 * For node i, Bi' can be expressed in the actual coordinate system 1280 * by: 1280 * by: 1281 1281 * Bi_advec =[ h ] 1282 1282 * [ h ] … … 1305 1305 }/*}}}*/ 1306 1306 void EnthalpyAnalysis::GetBAdvecprime(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1307 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 1307 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 1308 1308 * For node i, Bi' can be expressed in the actual coordinate system 1309 * by: 1309 * by: 1310 1310 * Biprime_advec=[ dh/dx ] 1311 1311 * [ dh/dy ] … … 1356 1356 if(!element->IsIceInElement()) return; 1357 1357 1358 /* Only update constraints at the base. 1358 /* Only update constraints at the base. 1359 1359 * Floating ice is not affected by basal BC decision chart. */ 1360 1360 if(!(element->IsOnBase()) || element->IsFloating()) return; … … 1396 1396 break; 1397 1397 case 1: 1398 // cold, wet base: keep at pressure melting point 1398 // cold, wet base: keep at pressure melting point 1399 1399 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1400 1400 break; 1401 1401 case 2: 1402 // temperate, thin refreezing base: 1402 // temperate, thin refreezing base: 1403 1403 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1404 1404 break; … … 1427 1427 if(!element->IsIceInElement()) return; 1428 1428 1429 /* Only update constraints at the base. 1429 /* Only update constraints at the base. 1430 1430 * Floating ice is not affected by basal BC decision chart.*/ 1431 1431 if(!(element->IsOnBase()) || element->IsFloating()) return; … … 1469 1469 break; 1470 1470 case 1: 1471 // cold, wet base: keep at pressure melting point 1471 // cold, wet base: keep at pressure melting point 1472 1472 vec_spc->SetValue(element->nodes[i]->Sid(),1.,INS_VAL); 1473 1473 break; … … 1497 1497 }/*}}}*/ 1498 1498 void EnthalpyAnalysis::GetBConduct(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 1499 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 1499 /*Compute B matrix. B=[B1 B2 B3 B4 B5 B6] where Bi is of size 5*NDOF1. 1500 1500 * For node i, Bi' can be expressed in the actual coordinate system 1501 * by: 1501 * by: 1502 1502 * Bi_conduct=[ dh/dx ] 1503 1503 * [ dh/dy ] … … 1659 1659 } 1660 1660 case LliboutryDuvalEnum:{ 1661 for(i=0;i<numnodes;i++) B[i]=LliboutryDuval(values[i],pressure[i],n[i],element->FindParam(MaterialsBetaEnum),element->FindParam(ConstantsReferencetemperatureEnum),element->FindParam(MaterialsHeatcapacityEnum),element->FindParam(MaterialsLatentheatEnum)); 1662 element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType()); 1663 break; 1661 for(i=0;i<numnodes;i++) B[i]=LliboutryDuval(values[i],pressure[i],n[i],element->FindParam(MaterialsBetaEnum),element->FindParam(ConstantsReferencetemperatureEnum),element->FindParam(MaterialsHeatcapacityEnum),element->FindParam(MaterialsLatentheatEnum)); 1662 element->AddInput(MaterialsRheologyBEnum,&B[0],element->GetElementType()); 1663 break; 1664 1664 } 1665 1665 default: _error_("Rheology law " << EnumToStringx(rheology_law) << " not supported yet"); -
issm/trunk-jpl/src/c/analyses/HydrologyDCEfficientAnalysis.cpp
r24030 r24240 61 61 iomodel->FetchDataToInput(elements,"md.geometry.base",BaseEnum); 62 62 iomodel->FetchDataToInput(elements,"md.mask.ice_levelset",MaskIceLevelsetEnum); 63 iomodel->FetchDataToInput(elements,"md.initialization.epl_head",EplHead HydrostepEnum);64 iomodel->FetchDataToInput(elements,"md.initialization.sediment_head",SedimentHead HydrostepEnum);65 iomodel->FetchDataToInput(elements,"md.initialization.epl_thickness",HydrologydcEplThickness HydrostepEnum);63 iomodel->FetchDataToInput(elements,"md.initialization.epl_head",EplHeadSubstepEnum); 64 iomodel->FetchDataToInput(elements,"md.initialization.sediment_head",SedimentHeadSubstepEnum); 65 iomodel->FetchDataToInput(elements,"md.initialization.epl_thickness",HydrologydcEplThicknessSubstepEnum); 66 66 iomodel->FetchDataToInput(elements,"md.hydrology.basal_moulin_input",HydrologydcBasalMoulinInputEnum); 67 67 if(iomodel->domaintype!=Domain2DhorizontalEnum){ … … 223 223 /*Retrieve all inputs and parameters*/ 224 224 basalelement->GetVerticesCoordinates(&xyz_list); 225 //basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 226 basalelement ->FindParam(&dt,HydrologydtEnum); 227 228 Input* epl_thick_input = basalelement->GetInput(HydrologydcEplThicknessHydrostepEnum); _assert_(epl_thick_input); 229 Input* epl_head_input = basalelement->GetInput(EplHeadHydrostepEnum); _assert_(epl_head_input); 225 basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 226 227 Input* epl_thick_input = basalelement->GetInput(HydrologydcEplThicknessSubstepEnum); _assert_(epl_thick_input); 228 Input* epl_head_input = basalelement->GetInput(EplHeadSubstepEnum); _assert_(epl_head_input); 230 229 Input* base_input = basalelement->GetInput(BaseEnum); _assert_(base_input); 231 230 232 231 /* Start looping on the number of gaussian points: */ 233 Gauss* gauss 232 Gauss* gauss = basalelement->NewGauss(2); 234 233 for(int ig=gauss->begin();ig<gauss->end();ig++){ 235 234 gauss ->GaussPoint(ig); … … 320 319 IssmDouble residual,connectivity; 321 320 322 IssmDouble *xyz_list 323 Input* old_wh_input= NULL;324 Input* 321 IssmDouble *xyz_list = NULL; 322 Input* old_wh_input = NULL; 323 Input* surface_runoff_input = NULL; 325 324 326 325 /*Fetch number of nodes and dof for this finite element*/ … … 334 333 /*Retrieve all inputs and parameters*/ 335 334 basalelement->GetVerticesCoordinates(&xyz_list); 336 //basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 337 basalelement ->FindParam(&dt,HydrologydtEnum); 335 basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 338 336 basalelement ->FindParam(&smb_model,SmbEnum); 339 337 340 Input* epl_thick_input = basalelement->GetInput(HydrologydcEplThickness HydrostepEnum); _assert_(epl_thick_input);341 Input* sed_head_input = basalelement->GetInput(SedimentHead HydrostepEnum); _assert_(sed_head_input);342 Input* epl_head_input = basalelement->GetInput(EplHead HydrostepEnum); _assert_(epl_head_input);338 Input* epl_thick_input = basalelement->GetInput(HydrologydcEplThicknessSubstepEnum); _assert_(epl_thick_input); 339 Input* sed_head_input = basalelement->GetInput(SedimentHeadSubstepEnum); _assert_(sed_head_input); 340 Input* epl_head_input = basalelement->GetInput(EplHeadSubstepEnum); _assert_(epl_head_input); 343 341 Input* basal_melt_input = basalelement->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(basal_melt_input); 344 342 Input* residual_input = basalelement->GetInput(SedimentHeadResidualEnum); _assert_(residual_input); … … 353 351 354 352 /* Start looping on the number of gaussian points: */ 355 Gauss* gauss 353 Gauss* gauss = basalelement->NewGauss(2); 356 354 for(int ig=gauss->begin();ig<gauss->end();ig++){ 357 355 gauss->GaussPoint(ig); … … 383 381 384 382 /* Add residual if necessary*/ 385 gauss =basalelement->NewGauss();383 gauss = basalelement->NewGauss(); 386 384 for(int iv=0;iv<numvertices;iv++){ 387 385 gauss->GaussVertex(iv); … … 401 399 402 400 void HydrologyDCEfficientAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 403 element->GetSolutionFromInputsOneDof(solution,EplHead HydrostepEnum);401 element->GetSolutionFromInputsOneDof(solution,EplHeadSubstepEnum); 404 402 }/*}}}*/ 405 403 … … 443 441 } 444 442 /*Add input to the element: */ 445 element->AddBasalInput(EplHead HydrostepEnum,eplHeads,P1Enum);443 element->AddBasalInput(EplHeadSubstepEnum,eplHeads,P1Enum); 446 444 /*Free ressources:*/ 447 445 xDelete<IssmDouble>(eplHeads); … … 538 536 Input* active_element_input=element->GetInput(HydrologydcMaskEplactiveEltEnum); _assert_(active_element_input); 539 537 active_element_input->GetInputValue(&active_element); 540 //element->FindParam(&dt,TimesteppingTimeStepEnum); 541 element ->FindParam(&dt,HydrologydtEnum); 538 element->FindParam(&dt,TimesteppingTimeStepEnum); 542 539 543 540 /*For now, assuming just one way to compute EPL thickness*/ … … 556 553 } 557 554 558 element->GetInputListOnVertices(&eplhead[0],EplHead HydrostepEnum);555 element->GetInputListOnVertices(&eplhead[0],EplHeadSubstepEnum); 559 556 element->GetInputListOnVertices(&epl_slopeX[0],EplHeadSlopeXEnum); 560 557 element->GetInputListOnVertices(&epl_slopeY[0],EplHeadSlopeYEnum); … … 593 590 } 594 591 } 595 element->AddInput(HydrologydcEplThickness HydrostepEnum,thickness,element->GetElementType());592 element->AddInput(HydrologydcEplThicknessSubstepEnum,thickness,element->GetElementType()); 596 593 xDelete<IssmDouble>(thickness); 597 594 xDelete<IssmDouble>(eplhead); … … 670 667 671 668 basalelement-> GetInputListOnVertices(&old_active[0],HydrologydcMaskEplactiveNodeEnum); 672 basalelement-> GetInputListOnVertices(&epl_thickness[0],HydrologydcEplThickness HydrostepEnum);673 basalelement-> GetInputListOnVertices(&sedhead[0],SedimentHead HydrostepEnum);674 basalelement-> GetInputListOnVertices(&eplhead[0],EplHead HydrostepEnum);669 basalelement-> GetInputListOnVertices(&epl_thickness[0],HydrologydcEplThicknessSubstepEnum); 670 basalelement-> GetInputListOnVertices(&sedhead[0],SedimentHeadSubstepEnum); 671 basalelement-> GetInputListOnVertices(&eplhead[0],EplHeadSubstepEnum); 675 672 basalelement-> GetInputListOnVertices(&residual[0],SedimentHeadResidualEnum); 676 673 basalelement-> GetInputListOnVertices(&base[0],BaseEnum); … … 715 712 } 716 713 } 717 basalelement->AddInput(HydrologydcEplThickness HydrostepEnum,epl_thickness,basalelement->GetElementType());714 basalelement->AddInput(HydrologydcEplThicknessSubstepEnum,epl_thickness,basalelement->GetElementType()); 718 715 719 716 if(domaintype!=Domain2DhorizontalEnum){ -
issm/trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp
r24030 r24240 102 102 iomodel->FetchDataToInput(elements,"md.basalforcings.groundedice_melting_rate",BasalforcingsGroundediceMeltingRateEnum); 103 103 iomodel->FetchDataToInput(elements,"md.hydrology.basal_moulin_input",HydrologydcBasalMoulinInputEnum); 104 iomodel->FetchDataToInput(elements,"md.initialization.sediment_head",SedimentHead HydrostepEnum);104 iomodel->FetchDataToInput(elements,"md.initialization.sediment_head",SedimentHeadSubstepEnum); 105 105 iomodel->FetchDataToInput(elements,"md.hydrology.sediment_transmitivity",HydrologydcSedimentTransmitivityEnum); 106 106 iomodel->FetchDataToInput(elements,"md.hydrology.mask_thawed_node",HydrologydcMaskThawedNodeEnum); … … 111 111 if(isefficientlayer){ 112 112 iomodel->FetchDataToInput(elements,"md.hydrology.mask_eplactive_node",HydrologydcMaskEplactiveNodeEnum); 113 iomodel->FetchDataToInput(elements,"md.initialization.epl_head",EplHead HydrostepEnum);113 iomodel->FetchDataToInput(elements,"md.initialization.epl_head",EplHeadSubstepEnum); 114 114 } 115 115 … … 233 233 /*Retrieve all inputs and parameters*/ 234 234 basalelement ->GetVerticesCoordinates(&xyz_list); 235 //basalelement ->FindParam(&dt,TimesteppingTimeStepEnum); 236 basalelement ->FindParam(&dt,HydrologydtEnum); 235 basalelement ->FindParam(&dt,TimesteppingTimeStepEnum); 237 236 basalelement ->FindParam(&isefficientlayer,HydrologydcIsefficientlayerEnum); 238 237 Input* SedTrans_input = basalelement->GetInput(HydrologydcSedimentTransmitivityEnum); _assert_(SedTrans_input); 239 Input* sed_head_input = basalelement->GetInput(SedimentHead HydrostepEnum);238 Input* sed_head_input = basalelement->GetInput(SedimentHeadSubstepEnum); 240 239 Input* base_input = basalelement->GetInput(BaseEnum); 241 240 Input* old_wh_input = basalelement->GetInput(SedimentHeadOldEnum); _assert_(old_wh_input); … … 340 339 bool active_element,isefficientlayer; 341 340 int smb_model; 341 int smbsubstepping; 342 342 IssmDouble dt,scalar,sediment_storing; 343 343 IssmDouble water_head,sediment_transmitivity; … … 348 348 Input* active_element_input = NULL; 349 349 Input* old_wh_input = NULL; 350 Input* surface_runoff_input = NULL; 350 Input* dummy_input = NULL; 351 TransientInput* surface_runoff_input = NULL; 351 352 352 353 /*Fetch number of nodes and dof for this finite element*/ … … 359 360 /*Retrieve all inputs and parameters*/ 360 361 basalelement->GetVerticesCoordinates(&xyz_list); 361 //basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 362 basalelement->FindParam(&dt,HydrologydtEnum); 362 basalelement->FindParam(&dt,TimesteppingTimeStepEnum); 363 363 basalelement->FindParam(&isefficientlayer,HydrologydcIsefficientlayerEnum); 364 364 basalelement->FindParam(&smb_model,SmbEnum); 365 365 366 Input* sed_head_input = basalelement->GetInput(SedimentHeadHydrostepEnum); 367 Input* epl_head_input = basalelement->GetInput(EplHeadHydrostepEnum); 368 Input* base_input = basalelement->GetInput(BaseEnum); 369 Input* basal_melt_input = basalelement->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(basal_melt_input); 370 Input* SedTrans_input = basalelement->GetInput(HydrologydcSedimentTransmitivityEnum); _assert_(SedTrans_input); 366 Input* sed_head_input = basalelement->GetInput(SedimentHeadSubstepEnum); 367 Input* epl_head_input = basalelement->GetInput(EplHeadSubstepEnum); 368 Input* base_input = basalelement->GetInput(BaseEnum); 369 Input* basal_melt_input = basalelement->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(basal_melt_input); 370 Input* SedTrans_input = basalelement->GetInput(HydrologydcSedimentTransmitivityEnum); _assert_(SedTrans_input); 371 372 IssmDouble time; 373 basalelement->FindParam(&time,TimeEnum); 374 371 375 372 376 if(dt!= 0.){ … … 374 378 } 375 379 if(smb_model==SMBgradientscomponentsEnum){ 376 surface_runoff_input = basalelement->GetInput(SmbRunoffEnum); _assert_(surface_runoff_input); 380 basalelement->FindParam(&smbsubstepping,SmbStepsPerStepEnum); 381 if(smbsubstepping>1) { 382 dummy_input = basalelement->GetInput(SmbRunoffTransientEnum); _assert_(dummy_input); 383 } 384 else { 385 dummy_input = basalelement->GetInput(SmbRunoffEnum); _assert_(dummy_input); 386 } 387 surface_runoff_input=xDynamicCast<TransientInput*>(dummy_input); _assert_(surface_runoff_input); 377 388 } 378 389 … … 384 395 /* Start looping on the number of gaussian points: */ 385 396 Gauss* gauss=basalelement->NewGauss(2); 397 398 IssmDouble yts; 399 basalelement->FindParam(&yts,ConstantsYtsEnum); 400 386 401 for(int ig=gauss->begin();ig<gauss->end();ig++){ 387 402 gauss->GaussPoint(ig); … … 407 422 if(!active_element){ 408 423 basal_melt_input->GetInputValue(&water_load,gauss); 409 if(surface_runoff_input) 410 else 424 if(surface_runoff_input)surface_runoff_input->GetInputValue(&runoff_value,gauss); 425 else runoff_value = 0.; 411 426 scalar = Jdet*gauss->weight*(water_load+runoff_value); 412 427 //scalar = Jdet*gauss->weight*(water_load)/sediment_transmitivity; … … 480 495 }/*}}}*/ 481 496 void HydrologyDCInefficientAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/ 482 element->GetSolutionFromInputsOneDof(solution,SedimentHead HydrostepEnum);497 element->GetSolutionFromInputsOneDof(solution,SedimentHeadSubstepEnum); 483 498 }/*}}}*/ 484 499 void HydrologyDCInefficientAnalysis::GradientJ(Vector<IssmDouble>* gradient,Element* element,int control_type,int control_index){/*{{{*/ … … 514 529 IssmDouble* residual = xNew<IssmDouble>(numnodes); 515 530 516 /*Use the dof list to index into the solution vector reseting to base is done at the deactivate stage: */517 531 for(int i=0;i<numnodes;i++){ 518 532 values[i] =solution[doflist[i]]; 519 533 if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in solution vector"); 520 534 if(xIsInf<IssmDouble>(values[i])) _error_("Inf found in solution vector"); 535 521 536 } 522 537 … … 553 568 } 554 569 pressure[i]=(rho_ice*g*thickness[i])-(rho_freshwater*g*(values[i]-base[i])); 555 556 570 } 557 571 xDelete<IssmDouble>(thickness); … … 561 575 562 576 /*Add input to the element: */ 563 element->AddBasalInput(SedimentHead HydrostepEnum,values,P1Enum);564 element->AddBasalInput(EffectivePressure HydrostepEnum,pressure,P1Enum);577 element->AddBasalInput(SedimentHeadSubstepEnum,values,P1Enum); 578 element->AddBasalInput(EffectivePressureSubstepEnum,pressure,P1Enum); 565 579 element->AddBasalInput(SedimentHeadResidualEnum,residual,P1Enum); 566 580 -
issm/trunk-jpl/src/c/analyses/L2ProjectionEPLAnalysis.cpp
r23585 r24240 60 60 } 61 61 62 iomodel->FetchDataToInput(elements,"md.initialization.epl_head",EplHead HydrostepEnum);62 iomodel->FetchDataToInput(elements,"md.initialization.epl_head",EplHeadSubstepEnum); 63 63 iomodel->FetchDataToInput(elements,"md.mask.ice_levelset",MaskIceLevelsetEnum); 64 64 if(iomodel->domaintype!=Domain2DhorizontalEnum){ … … 202 202 basalelement->FindParam(&input_enum,InputToL2ProjectEnum); 203 203 switch(input_enum){ 204 case EplHeadSlopeXEnum: input = basalelement->GetInput(EplHead HydrostepEnum); index = 0; _assert_(input); break;205 case EplHeadSlopeYEnum: input = basalelement->GetInput(EplHead HydrostepEnum); index = 1; _assert_(input); break;204 case EplHeadSlopeXEnum: input = basalelement->GetInput(EplHeadSubstepEnum); index = 0; _assert_(input); break; 205 case EplHeadSlopeYEnum: input = basalelement->GetInput(EplHeadSubstepEnum); index = 1; _assert_(input); break; 206 206 default: _error_("not implemented"); 207 207 } -
issm/trunk-jpl/src/c/analyses/LevelsetAnalysis.cpp
r24040 r24240 107 107 parameters->AddObject(iomodel->CopyConstantObject("md.levelset.kill_icebergs",LevelsetKillIcebergsEnum)); 108 108 parameters->AddObject(iomodel->CopyConstantObject("md.levelset.calving_max",CalvingMaxEnum)); 109 109 110 110 int calvinglaw; 111 111 iomodel->FindConstant(&calvinglaw,"md.calving.law"); … … 168 168 169 169 if(save_results){ 170 if(VerboseSolution()) _printf0_(" saving results\n");170 if(VerboseSolution()) _printf0_(" saving levelset results\n"); 171 171 int outputs[1] = {MaskIceLevelsetEnum}; 172 172 femmodel->RequestedOutputsx(&femmodel->results,&outputs[0],1); … … 328 328 /* Advection */ 329 329 vx_input->GetInputValue(&v[0],gauss); 330 vy_input->GetInputValue(&v[1],gauss); 330 vy_input->GetInputValue(&v[1],gauss); 331 331 gr_input->GetInputValue(&groundedice,gauss); 332 332 … … 350 350 351 351 if(norm_dlsf>1.e-10) 352 for(i=0;i<dim;i++){ 352 for(i=0;i<dim;i++){ 353 353 c[i]=calvingrate*dlsf[i]/norm_dlsf; m[i]=meltingrate*dlsf[i]/norm_dlsf; 354 354 } … … 379 379 380 380 if(norm_dlsf>1.e-10) 381 for(i=0;i<dim;i++){ 381 for(i=0;i<dim;i++){ 382 382 c[i]=0.; 383 383 m[i]=meltingrate*dlsf[i]/norm_dlsf; … … 400 400 401 401 if(norm_dlsf>1.e-10) 402 for(i=0;i<dim;i++){ 402 for(i=0;i<dim;i++){ 403 403 c[i]=0.; 404 404 m[i]=meltingrate*dlsf[i]/norm_dlsf; … … 423 423 424 424 if(norm_dlsf>1.e-10) 425 for(i=0;i<dim;i++){ 425 for(i=0;i<dim;i++){ 426 426 c[i]=0.; 427 427 m[i]=meltingrate*dlsf[i]/norm_dlsf; … … 450 450 meltingrate=0.; 451 451 } 452 else if(groundedice-calvinghaf>=haf_eps){ 452 else if(groundedice-calvinghaf>=haf_eps){ 453 453 // ice is well above calvinghaf -> no calving back, i.e. limit calving rate to ice velocity 454 454 calvingrate=min(calvingrate,vel); … … 457 457 else{ // ice is close to calvinghaf: smooth transition between limitation and free calving. 458 458 //heaviside: 0 for floating, 1 for grounded 459 heaviside=(groundedice-calvinghaf+haf_eps)/(2.*haf_eps) + sin(PI*(groundedice-calvinghaf)/haf_eps)/(2.*PI); 459 heaviside=(groundedice-calvinghaf+haf_eps)/(2.*haf_eps) + sin(PI*(groundedice-calvinghaf)/haf_eps)/(2.*PI); 460 460 calvingrate=heaviside*(min(calvingrate,vel)-calvingrate)+calvingrate; 461 461 meltingrate=heaviside*meltingrate+0.; … … 467 467 468 468 if(norm_dlsf>1.e-10) 469 for(i=0;i<dim;i++){ 470 c[i]=calvingrate*dlsf[i]/norm_dlsf; 469 for(i=0;i<dim;i++){ 470 c[i]=calvingrate*dlsf[i]/norm_dlsf; 471 471 m[i]=meltingrate*dlsf[i]/norm_dlsf; 472 472 } 473 473 else 474 474 for(i=0;i<dim;i++){ 475 c[i]=0.; 475 c[i]=0.; 476 476 m[i]=0.; 477 477 } … … 506 506 /* Artificial Diffusion */ 507 507 basalelement->ElementSizes(&hx,&hy,&hz); 508 h=sqrt( pow(hx*w[0]/vel,2) + pow(hy*w[1]/vel,2) ); 508 h=sqrt( pow(hx*w[0]/vel,2) + pow(hy*w[1]/vel,2) ); 509 509 kappa=h*vel/2.; 510 510 for(i=0;i<numnodes;i++){ … … 515 515 } 516 516 } 517 break; 517 break; 518 518 case 2: 519 519 { … … 522 522 h=sqrt( pow(hx*w[0]/vel,2) + pow(hy*w[1]/vel,2) ); 523 523 IssmDouble D[9]; 524 for(row=0;row<dim;row++) 525 for(col=0;col<dim;col++) 524 for(row=0;row<dim;row++) 525 for(col=0;col<dim;col++) 526 526 D[row*dim+col] = D_scalar*h/(2.*vel)*w[row]*w[col]; 527 527 GetBprime(Bprime,basalelement,xyz_list,gauss); … … 597 597 }/*}}}*/ 598 598 void LevelsetAnalysis::GetB(IssmDouble* B,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 599 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 599 /*Compute B matrix. B=[B1 B2 B3] where Bi is of size 3*NDOF2. 600 600 * For node i, Bi can be expressed in the actual coordinate system 601 * by: 601 * by: 602 602 * Bi=[ N ] 603 603 * [ N ] … … 624 624 }/*}}}*/ 625 625 void LevelsetAnalysis::GetBprime(IssmDouble* Bprime,Element* element,IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 626 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 626 /*Compute B' matrix. B'=[B1' B2' B3'] where Bi' is of size 3*NDOF2. 627 627 * For node i, Bi' can be expressed in the actual coordinate system 628 * by: 628 * by: 629 629 * Bi_prime=[ dN/dx ] 630 630 * [ dN/dy ] … … 716 716 Element* element = xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i)); 717 717 718 int numnodes = element->GetNumberOfNodes(); 718 int numnodes = element->GetNumberOfNodes(); 719 719 Gauss* gauss = element->NewGauss(); 720 720 Input* H_input = element->GetInput(ThicknessEnum); _assert_(H_input); … … 736 736 else { 737 737 /* no ice, set no spc */ 738 node->DofInFSet(0); 738 node->DofInFSet(0); 739 739 } 740 740 } … … 779 779 else { 780 780 /* no ice, set no spc */ 781 node->DofInFSet(0); 781 node->DofInFSet(0); 782 782 } 783 783 } … … 795 795 femmodel->elements->InputDuplicate(MaskIceLevelsetEnum,DistanceToCalvingfrontEnum); 796 796 femmodel->DistanceToFieldValue(MaskIceLevelsetEnum,0,DistanceToCalvingfrontEnum); 797 797 798 798 /*Vector of size number of nodes*/ 799 799 vec_constraint_nodes=new Vector<IssmDouble>(femmodel->nodes->NumberOfNodes()); … … 821 821 thickness_input->GetInputValue(&thickness,gauss); 822 822 surface_input->GetInputValue(&surface,gauss); 823 823 824 824 if((surface_crevasse-surface>0. || crevassedepth-thickness>0.) && bed<0.){ 825 825 vec_constraint_nodes->SetValue(node->Sid(),1.0,INS_VAL); -
issm/trunk-jpl/src/c/analyses/SmbAnalysis.cpp
r23814 r24240 178 178 void SmbAnalysis::UpdateParameters(Parameters* parameters,IoModel* iomodel,int solution_enum,int analysis_enum){/*{{{*/ 179 179 180 printf("start param update\n"); 180 181 int numoutputs; 181 182 char** requestedoutputs = NULL; 182 183 bool isdelta18o,ismungsm,isd18opd,issetpddfac,interp,isfirnwarming; 183 int smb_model ;184 int smb_model, smbslices; 184 185 IssmDouble *temp = NULL; 185 186 int N,M; … … 189 190 iomodel->FindConstant(&smb_model,"md.smb.model"); 190 191 iomodel->FindConstant(&interp,"md.timestepping.interp_forcings"); 192 193 iomodel->FetchData(&smbslices,"md.smb.steps_per_step"); 194 parameters->AddObject(new IntParam(SmbStepsPerStepEnum,smbslices)); 191 195 192 196 switch(smb_model){ -
issm/trunk-jpl/src/c/classes/Elements/Element.cpp
r24189 r24240 512 512 case PentaEnum: 513 513 case TetraEnum: 514 515 516 514 this->InputExtrude(SmbMonthlytemperaturesEnum,-1); 515 this->InputExtrude(SmbPrecipitationEnum,-1); 516 break; 517 517 default: _error_("Not implemented yet"); 518 518 } … … 644 644 case PentaEnum: 645 645 case TetraEnum: 646 647 648 646 this->InputExtrude(SmbMonthlytemperaturesEnum,-1); 647 this->InputExtrude(SmbPrecipitationEnum,-1); 648 break; 649 649 default: _error_("Not implemented yet"); 650 650 } … … 673 673 IssmDouble accugrad, runoffgrad; //gradients from reference altitude 674 674 IssmDouble rho_water, rho_ice; 675 IssmDouble time ;675 IssmDouble time,yts; 676 676 677 677 IssmDouble* smb = xNew<IssmDouble>(NUM_VERTICES); … … 686 686 /*Recover parameters*/ 687 687 parameters->FindParam(&time,TimeEnum); 688 parameters->FindParam(&yts,ConstantsYtsEnum); 688 689 parameters->FindParam(&accualti,SmbAccualtiEnum); 689 690 parameters->FindParam(&accugrad,SmbAccugradEnum); … … 704 705 smb[iv]=(accu[iv]-runoff[iv])*rho_ice/rho_water; 705 706 } 707 706 708 switch(this->ObjectEnum()){ 707 case TriaEnum: 708 this->inputs->AddInput(new TriaInput(SmbMassBalanceEnum,&smb[0],P1Enum)); 709 this->inputs->AddInput(new TriaInput(SmbRunoffEnum,&runoff[0],P1Enum)); 710 break; 711 case PentaEnum: 712 this->inputs->AddInput(new PentaInput(SmbMassBalanceEnum,&smb[0],P1Enum)); 713 this->inputs->AddInput(new PentaInput(SmbRunoffEnum,&runoff[0],P1Enum)); 714 this->InputExtrude(SmbMassBalanceEnum,-1); 715 this->InputExtrude(SmbRunoffEnum,-1); 716 break; 717 case TetraEnum: 718 this->inputs->AddInput(new TetraInput(SmbMassBalanceEnum,&smb[0],P1Enum)); 719 this->inputs->AddInput(new TetraInput(SmbRunoffEnum,&runoff[0],P1Enum)); 720 this->InputExtrude(SmbMassBalanceEnum,-1); 721 this->InputExtrude(SmbRunoffEnum,-1); 722 break; 723 default: _error_("Not implemented yet"); 724 } 725 /* this->AddInput(SmbMassBalanceEnum,smb,P1Enum); */ 726 /* this->AddInput(SmbRunoffEnum,runoff,P1Enum); */ 709 case TriaEnum: 710 this->inputs->AddInput(new TriaInput(SmbMassBalanceSubstepEnum,&smb[0],P1Enum)); 711 this->inputs->AddInput(new TriaInput(SmbRunoffSubstepEnum,&runoff[0],P1Enum)); 712 break; 713 case PentaEnum: 714 this->inputs->AddInput(new PentaInput(SmbMassBalanceSubstepEnum,&smb[0],P1Enum)); 715 this->inputs->AddInput(new PentaInput(SmbRunoffSubstepEnum,&runoff[0],P1Enum)); 716 this->InputExtrude(SmbMassBalanceSubstepEnum,-1); 717 this->InputExtrude(SmbRunoffSubstepEnum,-1); 718 break; 719 case TetraEnum: 720 this->inputs->AddInput(new TetraInput(SmbMassBalanceSubstepEnum,&smb[0],P1Enum)); 721 this->inputs->AddInput(new TetraInput(SmbRunoffSubstepEnum,&runoff[0],P1Enum)); 722 this->InputExtrude(SmbMassBalanceSubstepEnum,-1); 723 this->InputExtrude(SmbRunoffSubstepEnum,-1); 724 break; 725 default: _error_("Not implemented yet"); 726 } 727 727 /*clean-up*/ 728 728 xDelete<IssmDouble>(surf); … … 1175 1175 Input* input=this->GetInput(enumtype); 1176 1176 if (!input) _error_("Input " << EnumToStringx(enumtype) << " not found in element"); 1177 1178 1177 /*Fetch number vertices for this element*/ 1179 1178 const int NUM_VERTICES = this->GetNumberOfVertices(); … … 2512 2511 IssmDouble rho_water = this->FindParam(MaterialsRhoSeawaterEnum); 2513 2512 IssmDouble rho_ice = this->FindParam(MaterialsRhoIceEnum); 2514 IssmDouble latentheat = this->FindParam(MaterialsLatentheatEnum); 2513 IssmDouble latentheat = this->FindParam(MaterialsLatentheatEnum); 2515 2514 IssmDouble mixed_layer_capacity = this->FindParam(MaterialsMixedLayerCapacityEnum); 2516 2515 IssmDouble thermal_exchange_vel = this->FindParam(MaterialsThermalExchangeVelocityEnum); -
issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
r24208 r24240 313 313 314 314 /*Calving rate proportionnal to the positive product of the strain rate along the ice flow direction and the strain rate perpendicular to the ice flow */ 315 calvingrate[iv]=propcoeff*strainparallel*strainperpendicular; 315 calvingrate[iv]=propcoeff*strainparallel*strainperpendicular; 316 316 if(calvingrate[iv]<0){ 317 317 calvingrate[iv]=0; … … 410 410 411 411 /*Some checks in debugging mode*/ 412 _assert_(s1>=0 && s1<=1.); 413 _assert_(s2>=0 && s2<=1.); 412 _assert_(s1>=0 && s1<=1.); 413 _assert_(s2>=0 && s2<=1.); 414 414 415 415 /*Get normal vector*/ … … 441 441 442 442 flux += rho_ice*Jdet*gauss->weight*thickness*(calvingratex*normal[0] + calvingratey*normal[1]); 443 area += Jdet*gauss->weight*thickness; 443 area += Jdet*gauss->weight*thickness; 444 444 445 445 flux_per_area=flux/area; … … 447 447 448 448 this->inputs->AddInput(new PentaInput(CalvingFluxLevelsetEnum,&flux_per_area,P0Enum)); 449 449 450 450 /*Clean up and return*/ 451 451 delete gauss; … … 532 532 533 533 /*Some checks in debugging mode*/ 534 _assert_(s1>=0 && s1<=1.); 535 _assert_(s2>=0 && s2<=1.); 534 _assert_(s1>=0 && s1<=1.); 535 _assert_(s2>=0 && s2<=1.); 536 536 537 537 /*Get normal vector*/ … … 569 569 vy_input->GetInputValue(&vy,gauss); 570 570 vel=vx*vx+vy*vy; 571 meltingrate_input->GetInputValue(&meltingrate,gauss); 571 meltingrate_input->GetInputValue(&meltingrate,gauss); 572 572 meltingratex=meltingrate*vx/(sqrt(vel)+1.e-14); 573 573 meltingratey=meltingrate*vy/(sqrt(vel)+1.e-14); … … 575 575 576 576 flux += rho_ice*Jdet*gauss->weight*thickness*((calvingratex+meltingratex)*normal[0] + (calvingratey+meltingratey)*normal[1]); 577 area += Jdet*gauss->weight*thickness; 577 area += Jdet*gauss->weight*thickness; 578 578 579 579 flux_per_area=flux/area; … … 581 581 582 582 this->inputs->AddInput(new PentaInput(CalvingMeltingFluxLevelsetEnum,&flux_per_area,P0Enum)); 583 583 584 584 /*Clean up and return*/ 585 585 delete gauss; … … 707 707 708 708 /*Compute Stress*/ 709 tau_xx[iv]=2*viscosity*epsilon[0]; // tau = nu eps 709 tau_xx[iv]=2*viscosity*epsilon[0]; // tau = nu eps 710 710 tau_yy[iv]=2*viscosity*epsilon[1]; 711 711 tau_zz[iv]=2*viscosity*epsilon[2]; … … 796 796 this->element_type=this->element_type_list[analysis_counter]; 797 797 798 /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 798 /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 799 799 * datasets, using internal ids and offsets hidden in hooks: */ 800 800 if (this->hnodes[analysis_counter]) this->hnodes[analysis_counter]->configure(nodesin); … … 887 887 int connectivity[NUMVERTICES]; 888 888 IssmPDouble values[NUMVERTICES]; 889 IssmPDouble gradients[NUMVERTICES]; 889 IssmPDouble gradients[NUMVERTICES]; 890 890 IssmDouble value,gradient; 891 891 … … 958 958 } 959 959 break; 960 default: 960 default: 961 961 _error_("Response type " << EnumToStringx(response_enum) << " not supported yet!"); 962 962 } … … 1106 1106 /*}}}*/ 1107 1107 void Penta::GetAreaCoordinates(IssmDouble* area_coordinates,IssmDouble* xyz_zero,IssmDouble* xyz_list,int numpoints){/*{{{*/ 1108 /*Computeportion of the element that is grounded*/ 1108 /*Computeportion of the element that is grounded*/ 1109 1109 1110 1110 int i,j,k; … … 1115 1115 1116 1116 /*Initialize xyz_list with original xyz_list of triangle coordinates*/ 1117 for(j=0;j<3;j++){ 1117 for(j=0;j<3;j++){ 1118 1118 for(k=0;k<3;k++){ 1119 1119 xyz_bis[j][k]=xyz_list[j*3+k]; … … 1121 1121 } 1122 1122 for(i=0;i<numpoints;i++){ 1123 for(j=0;j<3;j++){ 1123 for(j=0;j<3;j++){ 1124 1124 for(k=0;k<3;k++){ 1125 1125 /*Change appropriate line*/ … … 1174 1174 /*}}}*/ 1175 1175 void Penta::GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlyfloating){/*{{{*/ 1176 /*Computeportion of the element that is grounded*/ 1176 /*Computeportion of the element that is grounded*/ 1177 1177 1178 1178 bool floating=true; … … 1228 1228 /*}}}*/ 1229 1229 IssmDouble Penta::GetGroundedPortion(IssmDouble* xyz_list){/*{{{*/ 1230 /*Computeportion of the element that is grounded*/ 1230 /*Computeportion of the element that is grounded*/ 1231 1231 1232 1232 bool mainlyfloating = true; … … 1330 1330 /*}}}*/ 1331 1331 IssmDouble Penta::GetIcefrontArea(){/*{{{*/ 1332 1332 1333 1333 IssmDouble bed[NUMVERTICES]; //basinId[NUMVERTICES]; 1334 1334 IssmDouble Haverage,frontarea; … … 1359 1359 IssmDouble s[2],x[2],y[2]; 1360 1360 this->GetLevelsetIntersectionBase(&indices, &numiceverts,&s[0],MaskIceLevelsetEnum,0.); 1361 _assert_(numiceverts); 1361 _assert_(numiceverts); 1362 1362 1363 1363 /*3 Write coordinates*/ … … 1396 1396 x1=x[0]; y1=y[0]; x2=x[1]; y2=y[1]; 1397 1397 distance=sqrt(pow((x1-x2),2)+pow((y1-y2),2)); 1398 1398 1399 1399 int numthk=numiceverts+2; 1400 1400 H=xNew<IssmDouble>(numthk); … … 1421 1421 frontarea=distance*Haverage; 1422 1422 } 1423 else return 0; 1424 1423 else return 0; 1424 1425 1425 xDelete<int>(indices); 1426 1426 xDelete<IssmDouble>(H); 1427 1427 1428 1428 _assert_(frontarea>0); 1429 1429 return frontarea; … … 1456 1456 indicesfront[0]=indicesfront[1]; 1457 1457 indicesfront[1]=index; 1458 } 1458 } 1459 1459 1460 1460 IssmDouble* xyz_front = xNew<IssmDouble>(2*dim*nrfrontnodes); … … 1511 1511 void Penta::GetLevelsetIntersectionBase(int** pindices, int* pnumiceverts, IssmDouble* fraction, int levelset_enum, IssmDouble level){/*{{{*/ 1512 1512 1513 /* GetLevelsetIntersection computes: 1513 /* GetLevelsetIntersection computes: 1514 1514 * 1. indices of element, sorted in [iceverts, noiceverts] in counterclockwise fashion, 1515 1515 * 2. fraction of intersected triangle edges intersected by levelset, lying below level*/ … … 1553 1553 } 1554 1554 } 1555 //merge indices 1555 //merge indices 1556 1556 for(i=0;i<numiceverts;i++){indices[i]=indices_ice[i];} 1557 1557 for(i=0;i<numnoiceverts;i++){indices[numiceverts+i]=indices_noice[i];} … … 1586 1586 /*}}}*/ 1587 1587 int Penta::GetVertexIndex(Vertex* vertex){/*{{{*/ 1588 1589 1588 _assert_(vertices); 1590 1589 for(int i=0;i<NUMVERTICES;i++){ … … 1604 1603 /*}}}*/ 1605 1604 int Penta::GetNumberOfVertices(void){/*{{{*/ 1606 return NUMVERTICES; 1605 return NUMVERTICES; 1607 1606 } 1608 1607 /*}}}*/ … … 1768 1767 1769 1768 /*Scaled not implemented yet...*/ 1770 _assert_(!scaled); 1769 _assert_(!scaled); 1771 1770 1772 1771 int domaintype,index1,index2; … … 1842 1841 1843 1842 /*Some checks in debugging mode*/ 1844 _assert_(s1>=0 && s1<=1.); 1845 _assert_(s2>=0 && s2<=1.); 1843 _assert_(s1>=0 && s1<=1.); 1844 _assert_(s2>=0 && s2<=1.); 1846 1845 1847 1846 /*Get normal vector*/ … … 1850 1849 normal[0] = -normal[0]; 1851 1850 normal[1] = -normal[1]; 1852 1851 1853 1852 this->InputDepthAverageAtBase(VxEnum,VxAverageEnum); 1854 1853 this->InputDepthAverageAtBase(VyEnum,VyAverageEnum); … … 2002 2001 case PentaInputEnum: 2003 2002 case ControlInputEnum: 2004 depth_averaged_input=new PentaInput(average_enum,&total[0],P1Enum); 2003 depth_averaged_input=new PentaInput(average_enum,&total[0],P1Enum); 2005 2004 break; 2006 2005 default: … … 2069 2068 /*Recover vertices ids needed to initialize inputs*/ 2070 2069 _assert_(iomodel->elements); 2071 for(i=0;i<NUMVERTICES;i++){ 2070 for(i=0;i<NUMVERTICES;i++){ 2072 2071 penta_vertex_ids[i]=iomodel->elements[NUMVERTICES*index+i]; //ids for vertices are in the elements array from Matlab 2073 2072 } … … 2249 2248 2250 2249 switch(type){ 2251 case VertexLIdEnum: 2250 case VertexLIdEnum: 2252 2251 for (int i=0;i<NUMVERTICES;i++){ 2253 2252 values[i]=vector[this->vertices[i]->Lid()]; … … 2257 2256 return; 2258 2257 2259 case VertexPIdEnum: 2258 case VertexPIdEnum: 2260 2259 for (int i=0;i<NUMVERTICES;i++){ 2261 2260 values[i]=vector[this->vertices[i]->Pid()]; … … 2265 2264 return; 2266 2265 2267 case VertexSIdEnum: 2266 case VertexSIdEnum: 2268 2267 for (int i=0;i<NUMVERTICES;i++){ 2269 2268 values[i]=vector[this->vertices[i]->Sid()]; … … 2320 2319 isicefront=false; 2321 2320 if(IsIceInElement()){ 2322 nrice=0; 2321 nrice=0; 2323 2322 for(i=0;i<NUMVERTICES2D;i++) 2324 2323 if(ls[i]<0.) nrice++; … … 2618 2617 2619 2618 /*First, serarch the input: */ 2620 data=inputs->GetInput(natureofdataenum); 2619 data=inputs->GetInput(natureofdataenum); 2621 2620 2622 2621 /*figure out if we have the vertex id: */ … … 2851 2850 2852 2851 /*New X axis New Z axis*/ 2853 xz_plane[0]=1.; xz_plane[3]=-slopex; 2854 xz_plane[1]=0.; xz_plane[4]=-slopey; 2855 xz_plane[2]=slopex; xz_plane[5]=1.; 2852 xz_plane[0]=1.; xz_plane[3]=-slopex; 2853 xz_plane[1]=0.; xz_plane[4]=-slopey; 2854 xz_plane[2]=slopex; xz_plane[5]=1.; 2856 2855 2857 2856 if(groundedice>=0){ 2858 2857 if(this->nodes[indices[i]]->GetApproximation()==FSvelocityEnum){ 2859 this->nodes[indices[i]]->DofInSSet(2); //vz 2858 this->nodes[indices[i]]->DofInSSet(2); //vz 2860 2859 } 2861 2860 else if(this->nodes[indices[i]]->GetApproximation()==SSAFSApproximationEnum || this->nodes[indices[i]]->GetApproximation()==HOFSApproximationEnum){ 2862 this->nodes[indices[i]]->DofInSSet(4); //vz 2861 this->nodes[indices[i]]->DofInSSet(4); //vz 2863 2862 } 2864 2863 else _error_("Flow equation approximation"<<EnumToStringx(this->nodes[indices[i]]->GetApproximation())<<" not supported yet"); … … 2869 2868 } 2870 2869 else if(this->nodes[indices[i]]->GetApproximation()==SSAFSApproximationEnum || this->nodes[indices[i]]->GetApproximation()==HOFSApproximationEnum){ 2871 this->nodes[indices[i]]->DofInFSet(4); //vz 2870 this->nodes[indices[i]]->DofInFSet(4); //vz 2872 2871 } 2873 2872 else _error_("Flow equation approximation"<<EnumToStringx(this->nodes[indices[i]]->GetApproximation())<<" not supported yet"); … … 2902 2901 2903 2902 if(!this->IsOnBase()) return; 2904 2903 2905 2904 IssmDouble A, B, alpha, beta; 2906 2905 IssmDouble bed,qsg,qsg_basin,TF,yts; … … 2910 2909 2911 2910 /* Coefficients */ 2912 A = 3e-4; 2913 B = 0.15; 2911 A = 3e-4; 2912 B = 0.15; 2914 2913 alpha = 0.39; 2915 2914 beta = 1.18; 2916 2915 2917 2916 /*Get inputs*/ 2918 2917 Input* bed_input = this->GetInput(BedEnum); _assert_(bed_input); 2919 2918 Input* qsg_input = this->GetInput(FrontalForcingsSubglacialDischargeEnum); _assert_(qsg_input); 2920 2919 Input* TF_input = this->GetInput(FrontalForcingsThermalForcingEnum); _assert_(TF_input); 2921 GetInputListOnVertices(&basinid[0],FrontalForcingsBasinIdEnum); 2922 2920 GetInputListOnVertices(&basinid[0],FrontalForcingsBasinIdEnum); 2921 2923 2922 this->FindParam(&yts, ConstantsYtsEnum); 2924 2923 this->parameters->FindParam(&numbasins,FrontalForcingsNumberofBasinsEnum); … … 2926 2925 2927 2926 IssmDouble meltrates[NUMVERTICES2D]; //frontal melt-rate 2928 2927 2929 2928 /* Start looping on the number of vertices: */ 2930 2929 GaussPenta* gauss=new GaussPenta(); … … 2944 2943 /* calculate melt rates */ 2945 2944 meltrates[iv]=((A*max(-bed,0.)*pow(max(qsg_basin,0.),alpha)+B)*pow(max(TF,0.),beta))/86400; //[m/s] 2946 } 2945 } 2947 2946 2948 2947 if(xIsNan<IssmDouble>(meltrates[iv])) _error_("NaN found in vector"); … … 2952 2951 /*Add input*/ 2953 2952 this->inputs->AddInput(new PentaInput(CalvingMeltingrateEnum,&meltrates[0],P1Enum)); 2954 2953 2955 2954 this->InputExtrude(CalvingMeltingrateEnum,-1); 2956 2955 2957 2956 /*Cleanup and return*/ 2958 2957 xDelete<IssmDouble>(basin_icefront_area); … … 3085 3084 if(this->inputs->GetInput(CalvingratexEnum)) this->InputDepthAverageAtBase(CalvingratexEnum,CalvingratexAverageEnum); 3086 3085 if(this->inputs->GetInput(CalvingrateyEnum)) this->InputDepthAverageAtBase(CalvingrateyEnum,CalvingrateyAverageEnum); 3087 3086 3088 3087 Tria* tria=(Tria*)SpawnTria(0,1,2); 3089 3088 switch(this->material->ObjectEnum()){ … … 3149 3148 3150 3149 normu=pow(pow(u,2)+pow(v,2)+pow(w,2),0.5); 3151 if(normu*diameter/(3*2*kappa)<1){ 3150 if(normu*diameter/(3*2*kappa)<1){ 3152 3151 tau_parameter=pow(diameter,2)/(3*2*2*kappa); 3153 3152 } … … 3168 3167 hk=sqrt(pow(hx,2)+pow(hy,2)); 3169 3168 3170 if(normu*hk/(C*2*kappa)<1){ 3169 if(normu*hk/(C*2*kappa)<1){ 3171 3170 tau_parameter_anisotropic[0]=pow(hk,2)/(C*2*2*kappa); 3172 3171 } … … 3175 3174 /* compute tau for the vertical direction */ 3176 3175 hk=hz; 3177 if(normu*hk/(C*2*kappa)<1){ 3176 if(normu*hk/(C*2*kappa)<1){ 3178 3177 tau_parameter_anisotropic[1]=pow(hk,2)/(C*2*2*kappa); 3179 3178 } … … 3334 3333 3335 3334 if(prof<water_depth&prof<thickness){ 3336 /* Compute the local stress intensity factor*/ 3335 /* Compute the local stress intensity factor*/ 3337 3336 ki[ig]+=Jdet[ig]*gauss->weight*stress_xx*StressIntensityIntegralWeight(prof,min(water_depth,thickness),thickness); 3338 3337 } … … 3374 3373 else if (approximation==SSAApproximationEnum){ 3375 3374 3376 /*This element should be collapsed into a tria element at its base. Create this tria element, 3375 /*This element should be collapsed into a tria element at its base. Create this tria element, 3377 3376 * and compute SurfaceArea*/ 3378 3377 tria=(Tria*)SpawnTria(0,1,2); … … 3439 3438 3440 3439 /*Scaled not implemented yet...*/ 3441 _assert_(!scaled); 3440 _assert_(!scaled); 3442 3441 3443 3442 int domaintype,index1,index2; … … 3513 3512 3514 3513 /*Some checks in debugging mode*/ 3515 _assert_(s1>=0 && s1<=1.); 3516 _assert_(s2>=0 && s2<=1.); 3514 _assert_(s1>=0 && s1<=1.); 3515 _assert_(s2>=0 && s2<=1.); 3517 3516 3518 3517 /*Get normal vector*/ … … 3546 3545 3547 3546 return flux; 3548 3547 3549 3548 /*Clean up and return*/ 3550 3549 delete gauss; … … 3557 3556 3558 3557 /*Scaled not implemented yet...*/ 3559 _assert_(!scaled); 3558 _assert_(!scaled); 3560 3559 3561 3560 int domaintype,index1,index2; … … 3631 3630 3632 3631 /*Some checks in debugging mode*/ 3633 _assert_(s1>=0 && s1<=1.); 3634 _assert_(s2>=0 && s2<=1.); 3632 _assert_(s1>=0 && s1<=1.); 3633 _assert_(s2>=0 && s2<=1.); 3635 3634 3636 3635 /*Get normal vector*/ … … 3639 3638 normal[0] = -normal[0]; 3640 3639 normal[1] = -normal[1]; 3641 3640 3642 3641 this->InputDepthAverageAtBase(VxEnum,VxAverageEnum); 3643 3642 this->InputDepthAverageAtBase(VyEnum,VyAverageEnum); … … 3670 3669 vy_input->GetInputValue(&vy,gauss); 3671 3670 vel=vx*vx+vy*vy; 3672 meltingrate_input->GetInputValue(&meltingrate,gauss); 3671 meltingrate_input->GetInputValue(&meltingrate,gauss); 3673 3672 meltingratex=meltingrate*vx/(sqrt(vel)+1.e-14); 3674 3673 meltingratey=meltingrate*vy/(sqrt(vel)+1.e-14); … … 3679 3678 3680 3679 return flux; 3681 3680 3682 3681 /*Clean up and return*/ 3683 3682 delete gauss; … … 3699 3698 /*Get material parameters :*/ 3700 3699 rho_ice=FindParam(MaterialsRhoIceEnum); 3701 Input* floatingmelt_input = this->GetInput(BasalforcingsFloatingiceMeltingRateEnum); _assert_(floatingmelt_input); 3700 Input* floatingmelt_input = this->GetInput(BasalforcingsFloatingiceMeltingRateEnum); _assert_(floatingmelt_input); 3702 3701 Input* gllevelset_input = this->GetInput(MaskGroundediceLevelsetEnum); _assert_(gllevelset_input); 3703 3702 Input* scalefactor_input = NULL; 3704 3703 if(scaled==true){ 3705 scalefactor_input = this->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 3704 scalefactor_input = this->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 3706 3705 } 3707 3706 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); … … 3744 3743 /*Get material parameters :*/ 3745 3744 rho_ice=FindParam(MaterialsRhoIceEnum); 3746 Input* groundedmelt_input = this->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(groundedmelt_input); 3745 Input* groundedmelt_input = this->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(groundedmelt_input); 3747 3746 Input* gllevelset_input = this->GetInput(MaskGroundediceLevelsetEnum); _assert_(gllevelset_input); 3748 3747 Input* scalefactor_input = NULL; 3749 3748 if(scaled==true){ 3750 scalefactor_input = this->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 3749 scalefactor_input = this->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 3751 3750 } 3752 3751 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); … … 3799 3798 if(scaled==true){ 3800 3799 Input* scalefactor_input = inputs->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 3801 scalefactor_input->GetInputAverage(&scalefactor);// average scalefactor on element 3800 scalefactor_input->GetInputAverage(&scalefactor);// average scalefactor on element 3802 3801 } 3803 3802 else{ … … 3827 3826 /*Checks if debuging*/ 3828 3827 _assert_(iomodel->elements); 3829 _assert_(index==this->sid); 3828 _assert_(index==this->sid); 3830 3829 3831 3830 /*Recover element type*/ -
issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
r24186 r24240 245 245 IssmDouble B,sigma_max,sigma_max_floating,sigma_max_grounded,n; 246 246 IssmDouble epse_2,groundedice,bed,sealevel; // added sealevel 247 247 248 248 249 249 /* Get node coordinates and dof list: */ … … 260 260 Input* n_input = inputs->GetInput(MaterialsRheologyNEnum); _assert_(n_input); 261 261 Input* sl_input = inputs->GetInput(SealevelEnum); _assert_(sl_input); 262 262 263 263 264 264 … … 274 274 vy_input->GetInputValue(&vy,gauss); 275 275 gr_input->GetInputValue(&groundedice,gauss); 276 bs_input->GetInputValue(&bed,gauss); 276 bs_input->GetInputValue(&bed,gauss); 277 277 smax_fl_input->GetInputValue(&sigma_max_floating,gauss); 278 278 smax_gr_input->GetInputValue(&sigma_max_grounded,gauss); … … 316 316 } 317 317 calvingrate[iv] =sqrt(calvingratex[iv]*calvingratex[iv] + calvingratey[iv]*calvingratey[iv]); 318 318 319 319 } 320 320 … … 339 339 IssmDouble s_xx,s_xy,s_yy,s1,s2,stmp; 340 340 int crevasse_opening_stress; 341 341 342 342 /* Get node coordinates and dof list: */ 343 343 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); … … 397 397 basal_crevasse[iv] = (rho_ice/(rho_seawater-rho_ice)) * (B * strainparallel * pow(straineffective,((1/n)-1)) / (rho_ice*constant_g) - Ho); 398 398 } 399 else if(crevasse_opening_stress==1){ /*Benn2017,Todd2018: maximum principal stress */ 399 else if(crevasse_opening_stress==1){ /*Benn2017,Todd2018: maximum principal stress */ 400 400 surface_crevasse[iv] = s1 / (rho_ice*constant_g); 401 401 basal_crevasse[iv] = (rho_ice/(rho_seawater-rho_ice))* (s1/ (rho_ice*constant_g)-Ho); 402 } 403 402 } 403 404 404 /* some constraints */ 405 405 if (surface_crevasse[iv]<0.) { … … 408 408 } 409 409 if (basal_crevasse[iv]<0.) basal_crevasse[iv]=0.; 410 if (bed>0.) basal_crevasse[iv] = 0.; 411 410 if (bed>0.) basal_crevasse[iv] = 0.; 411 412 412 //if (surface_crevasse[iv]<water_height){ 413 413 // water_height = surface_crevasse[iv]; 414 414 //} 415 415 416 416 /* add water in surface crevasse */ 417 417 surface_crevasse[iv] = surface_crevasse[iv] + (rho_freshwater/rho_ice)*water_height; /* surface crevasse + water */ 418 418 crevasse_depth[iv] = surface_crevasse[iv] + (rho_freshwater/rho_ice)*water_height + basal_crevasse[iv]; /* surface crevasse + basal crevasse + water */ 419 419 420 420 } 421 421 … … 571 571 572 572 /*Some checks in debugging mode*/ 573 _assert_(s1>=0 && s1<=1.); 574 _assert_(s2>=0 && s2<=1.); 573 _assert_(s1>=0 && s1<=1.); 574 _assert_(s2>=0 && s2<=1.); 575 575 576 576 /*Get normal vector*/ … … 608 608 609 609 flux += rho_ice*Jdet*gauss->weight*thickness*(calvingratex*normal[0] + calvingratey*normal[1]); 610 area += Jdet*gauss->weight*thickness; 610 area += Jdet*gauss->weight*thickness; 611 611 612 612 flux_per_area=flux/area; … … 614 614 615 615 this->inputs->AddInput(new TriaInput(CalvingFluxLevelsetEnum,&flux_per_area,P0Enum)); 616 616 617 617 /*Clean up and return*/ 618 618 delete gauss; … … 708 708 709 709 /*Some checks in debugging mode*/ 710 _assert_(s1>=0 && s1<=1.); 711 _assert_(s2>=0 && s2<=1.); 710 _assert_(s1>=0 && s1<=1.); 711 _assert_(s2>=0 && s2<=1.); 712 712 713 713 /*Get normal vector*/ … … 751 751 vy_input->GetInputValue(&vy,gauss); 752 752 vel=vx*vx+vy*vy; 753 meltingrate_input->GetInputValue(&meltingrate,gauss); 753 meltingrate_input->GetInputValue(&meltingrate,gauss); 754 754 meltingratex=meltingrate*vx/(sqrt(vel)+1.e-14); 755 755 meltingratey=meltingrate*vy/(sqrt(vel)+1.e-14); … … 757 757 758 758 flux += rho_ice*Jdet*gauss->weight*thickness*((calvingratex+meltingratex)*normal[0] + (calvingratey+meltingratey)*normal[1]); 759 area += Jdet*gauss->weight*thickness; 759 area += Jdet*gauss->weight*thickness; 760 760 761 761 flux_per_area=flux/area; … … 763 763 764 764 this->inputs->AddInput(new TriaInput(CalvingMeltingFluxLevelsetEnum,&flux_per_area,P0Enum)); 765 765 766 766 /*Clean up and return*/ 767 767 delete gauss; … … 882 882 strain_yy[iv]=epsilon[1]; 883 883 strain_xy[iv]=epsilon[2]; 884 vorticity_xy[iv]=epsilon[3]; 884 vorticity_xy[iv]=epsilon[3]; 885 885 } 886 886 … … 909 909 IssmDouble sigma_xx,sigma_xy,sigma_yy; 910 910 IssmDouble epsilon[3]; /* epsilon=[exx,eyy,exy];*/ 911 IssmDouble base_normal[2]; 911 IssmDouble base_normal[2]; 912 912 int domaintype,dim=2; 913 913 … … 1016 1016 if (this->element_type_list) this->element_type=this->element_type_list[analysis_counter]; 1017 1017 1018 /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 1018 /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective 1019 1019 * datasets, using internal ids and offsets hidden in hooks: */ 1020 1020 if(this->hnodes){ … … 1022 1022 else this->hnodes[analysis_counter] = NULL; 1023 1023 } 1024 else this->hnodes = NULL; 1024 else this->hnodes = NULL; 1025 1025 this->hvertices->configure(verticesin); 1026 1026 this->hmaterial->configure(materialsin); … … 1098 1098 int connectivity[NUMVERTICES]; 1099 1099 IssmPDouble values[NUMVERTICES]; 1100 IssmPDouble gradients[NUMVERTICES]; 1100 IssmPDouble gradients[NUMVERTICES]; 1101 1101 IssmDouble value,gradient; 1102 1102 … … 1241 1241 *presponse=vel;} 1242 1242 break; 1243 default: 1243 default: 1244 1244 _error_("Response type " << EnumToStringx(response_enum) << " not supported yet!"); 1245 1245 } … … 1361 1361 } 1362 1362 /*If was floating*/ 1363 else{ 1363 else{ 1364 1364 /*Tricky part: 1365 1365 * 1. if base is now touching, we put 1 for sigma_nn and leave water pressure at 0 so that the rest of the module will reground this vertex … … 1452 1452 IssmDouble llr_list[NUMVERTICES][3]; 1453 1453 IssmDouble x1,y1,z1,x2,y2,z2,x3,y3,z3; 1454 IssmDouble arc12,arc23,arc31,semi_peri,excess; 1454 IssmDouble arc12,arc23,arc31,semi_peri,excess; 1455 1455 1456 1456 /*retrieve coordinates: lat,long,radius */ … … 1465 1465 arc31=2.*asin(sqrt(pow(sin((x1-x3)/2),2.0)+cos(x3)*cos(x1)*pow(sin((y1-y3)/2),2))); 1466 1466 1467 /*semi parameter */ 1468 semi_peri=(arc12+arc23+arc31)/2; 1467 /*semi parameter */ 1468 semi_peri=(arc12+arc23+arc31)/2; 1469 1469 1470 1470 /*spherical excess */ 1471 excess=4.*atan(sqrt(tan(semi_peri/2)*tan((semi_peri-arc12)/2)*tan((semi_peri-arc23)/2)*tan((semi_peri-arc31)/2))); 1471 excess=4.*atan(sqrt(tan(semi_peri/2)*tan((semi_peri-arc12)/2)*tan((semi_peri-arc23)/2)*tan((semi_peri-arc31)/2))); 1472 1472 1473 1473 /*area = excess*radius^2 */ 1474 return excess*pow((z1+z2+z3)/3,2); 1474 return excess*pow((z1+z2+z3)/3,2); 1475 1475 } 1476 1476 /*}}}*/ 1477 1477 void Tria::GetAreaCoordinates(IssmDouble* area_coordinates,IssmDouble* xyz_zero,IssmDouble* xyz_list,int numpoints){/*{{{*/ 1478 /*Computeportion of the element that is grounded*/ 1478 /*Computeportion of the element that is grounded*/ 1479 1479 1480 1480 int i,j,k; … … 1485 1485 1486 1486 /*Initialize xyz_list with original xyz_list of triangle coordinates*/ 1487 for(j=0;j<3;j++){ 1487 for(j=0;j<3;j++){ 1488 1488 for(k=0;k<3;k++){ 1489 1489 xyz_bis[j][k]=xyz_list[j*3+k]; … … 1491 1491 } 1492 1492 for(i=0;i<numpoints;i++){ 1493 for(j=0;j<3;j++){ 1493 for(j=0;j<3;j++){ 1494 1494 for(k=0;k<3;k++){ 1495 1495 /*Change appropriate line*/ … … 1518 1518 /*}}}*/ 1519 1519 void Tria::GetGroundedPart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlyfloating){/*{{{*/ 1520 /*Computeportion of the element that is grounded*/ 1520 /*Computeportion of the element that is grounded*/ 1521 1521 1522 1522 bool floating=true; … … 1572 1572 /*}}}*/ 1573 1573 IssmDouble Tria::GetGroundedPortion(IssmDouble* xyz_list){/*{{{*/ 1574 /*Computeportion of the element that is grounded*/ 1574 /*Computeportion of the element that is grounded*/ 1575 1575 1576 1576 bool mainlyfloating = true; … … 1697 1697 /*}}}*/ 1698 1698 IssmDouble Tria::GetIcefrontArea(){/*{{{*/ 1699 1699 1700 1700 IssmDouble bed[NUMVERTICES]; //basinId[NUMVERTICES]; 1701 1701 IssmDouble Haverage,frontarea; … … 1725 1725 IssmDouble s[2],x[2],y[2]; 1726 1726 this->GetLevelsetIntersection(&indices, &numiceverts,&s[0],MaskIceLevelsetEnum,0.); 1727 _assert_(numiceverts); 1727 _assert_(numiceverts); 1728 1728 1729 1729 /*3 Write coordinates*/ … … 1762 1762 x1=x[0]; y1=y[0]; x2=x[1]; y2=y[1]; 1763 1763 distance=sqrt(pow((x1-x2),2)+pow((y1-y2),2)); 1764 1764 1765 1765 int numthk=numiceverts+2; 1766 1766 H=xNew<IssmDouble>(numthk); … … 1787 1787 frontarea=distance*Haverage; 1788 1788 } 1789 else return 0; 1790 1789 else return 0; 1790 1791 1791 xDelete<int>(indices); 1792 1792 xDelete<IssmDouble>(H); 1793 1793 1794 1794 _assert_(frontarea>0); 1795 1795 return frontarea; … … 1820 1820 indicesfront[0]=indicesfront[1]; 1821 1821 indicesfront[1]=index; 1822 } 1822 } 1823 1823 1824 1824 IssmDouble* xyz_front = xNew<IssmDouble>(3*2); … … 1886 1886 indicesfront[0]=indicesfront[1]; 1887 1887 indicesfront[1]=index; 1888 } 1888 } 1889 1889 1890 1890 IssmDouble* xyz_front = xNew<IssmDouble>(3*nrfrontnodes); … … 1901 1901 void Tria::GetLevelsetIntersection(int** pindices, int* pnumiceverts, IssmDouble* fraction, int levelset_enum, IssmDouble level){/*{{{*/ 1902 1902 1903 /* GetLevelsetIntersection computes: 1903 /* GetLevelsetIntersection computes: 1904 1904 * 1. indices of element, sorted in [iceverts, noiceverts] in counterclockwise fashion, 1905 1905 * 2. fraction of intersected triangle edges intersected by levelset, lying below level*/ … … 1943 1943 } 1944 1944 } 1945 //merge indices 1945 //merge indices 1946 1946 for(i=0;i<numiceverts;i++){indices[i]=indices_ice[i];} 1947 1947 for(i=0;i<numnoiceverts;i++){indices[numiceverts+i]=indices_noice[i];} … … 1977 1977 void Tria::GetLevelsetPositivePart(int* point1,IssmDouble* fraction1,IssmDouble* fraction2, bool* mainlynegative,IssmDouble* gl){/*{{{*/ 1978 1978 1979 /*Computeportion of the element that has a positive levelset*/ 1979 /*Computeportion of the element that has a positive levelset*/ 1980 1980 1981 1981 bool negative=true; … … 2029 2029 /*}}}*/ 2030 2030 int Tria::GetVertexIndex(Vertex* vertex){/*{{{*/ 2031 2032 2031 _assert_(vertices); 2033 2032 for(int i=0;i<NUMVERTICES;i++){ … … 2258 2257 2259 2258 /*Scaled not implemented yet...*/ 2260 _assert_(!scaled); 2259 _assert_(!scaled); 2261 2260 2262 2261 /*Get domain type*/ … … 2314 2313 2315 2314 /*Scaled not implemented yet...*/ 2316 _assert_(!scaled); 2315 _assert_(!scaled); 2317 2316 2318 2317 int domaintype,index1,index2; … … 2396 2395 2397 2396 /*Some checks in debugging mode*/ 2398 _assert_(s1>=0 && s1<=1.); 2399 _assert_(s2>=0 && s2<=1.); 2397 _assert_(s1>=0 && s1<=1.); 2398 _assert_(s2>=0 && s2<=1.); 2400 2399 2401 2400 /*Get normal vector*/ … … 2444 2443 2445 2444 /*Scaled not implemented yet...*/ 2446 _assert_(!scaled); 2445 _assert_(!scaled); 2447 2446 2448 2447 int domaintype,index1,index2; … … 2525 2524 2526 2525 /*Some checks in debugging mode*/ 2527 _assert_(s1>=0 && s1<=1.); 2528 _assert_(s2>=0 && s2<=1.); 2526 _assert_(s1>=0 && s1<=1.); 2527 _assert_(s2>=0 && s2<=1.); 2529 2528 2530 2529 /*Get normal vector*/ … … 2585 2584 2586 2585 if(false && IsIcefront()){ 2587 //Assumption: linear ice thickness profile on element. 2586 //Assumption: linear ice thickness profile on element. 2588 2587 //Hence ice thickness at intersection of levelset function with triangle edge is linear interpolation of ice thickness at vertices. 2589 2588 this->GetLevelsetIntersection(&indices, &numiceverts, s, MaskIceLevelsetEnum, 0.); … … 2596 2595 for(i=0;i<NUMVERTICES;i++) SFaux[i]= scalefactors[indices[i]]; //sort thicknesses in ice/noice 2597 2596 switch(numiceverts){ 2598 case 1: // average over triangle 2597 case 1: // average over triangle 2599 2598 SF[0]=SFaux[0]; 2600 2599 SF[1]=SFaux[0]+s[0]*(SFaux[1]-SFaux[0]); … … 2620 2619 for(i=0;i<NUMVERTICES;i++) Haux[i]= surfaces[indices[i]]-bases[indices[i]]; //sort thicknesses in ice/noice 2621 2620 switch(numiceverts){ 2622 case 1: // average over triangle 2621 case 1: // average over triangle 2623 2622 H[0]=Haux[0]; 2624 2623 H[1]=Haux[0]+s[0]*(Haux[1]-Haux[0]); … … 2913 2912 2914 2913 switch(type){ 2915 case VertexLIdEnum: 2914 case VertexLIdEnum: 2916 2915 values = xNew<IssmDouble>(NUMVERTICES); 2917 2916 for(int i=0;i<NUMVERTICES;i++){ … … 2924 2923 break; 2925 2924 2926 case VertexPIdEnum: 2925 case VertexPIdEnum: 2927 2926 values = xNew<IssmDouble>(NUMVERTICES); 2928 2927 for(int i=0;i<NUMVERTICES;i++){ … … 2935 2934 break; 2936 2935 2937 case VertexSIdEnum: 2936 case VertexSIdEnum: 2938 2937 values = xNew<IssmDouble>(NUMVERTICES); 2939 2938 for(int i=0;i<NUMVERTICES;i++){ … … 2973 2972 break; 2974 2973 2975 case ElementEnum: 2974 case ElementEnum: 2976 2975 value=vector[this->Sid()]; 2977 2976 if(xIsNan<IssmDouble>(value)) _error_("NaN found in vector"); … … 3023 3022 isicefront=false; 3024 3023 if(IsIceInElement()){ 3025 nrice=0; 3024 nrice=0; 3026 3025 for(i=0;i<NUMVERTICES;i++) 3027 3026 if(ls[i]<0.) nrice++; … … 3220 3219 vy_input->GetInputValue(&vy2,gauss_2); 3221 3220 3222 mass_flux= rho_ice*length*( 3221 mass_flux= rho_ice*length*( 3223 3222 (1./3.*(h1-h2)*(vx1-vx2)+0.5*h2*(vx1-vx2)+0.5*(h1-h2)*vx2+h2*vx2)*nx+ 3224 3223 (1./3.*(h1-h2)*(vy1-vy2)+0.5*h2*(vy1-vy2)+0.5*(h1-h2)*vy2+h2*vy2)*ny … … 3430 3429 3431 3430 /*First, serarch the input: */ 3432 data=inputs->GetInput(natureofdataenum); 3431 data=inputs->GetInput(natureofdataenum); 3433 3432 3434 3433 /*figure out if we have the vertex id: */ … … 3467 3466 bed_normal[0]= + vector[1]/norm; 3468 3467 bed_normal[1]= - vector[0]/norm; 3469 _assert_(bed_normal[1]<0); 3468 _assert_(bed_normal[1]<0); 3470 3469 } 3471 3470 /*}}}*/ … … 3500 3499 top_normal[0]= + vector[1]/norm; 3501 3500 top_normal[1]= - vector[0]/norm; 3502 _assert_(top_normal[1]>0); 3501 _assert_(top_normal[1]>0); 3503 3502 } 3504 3503 /*}}}*/ … … 3615 3614 3616 3615 /*New X axis New Z axis*/ 3617 xz_plane[0]=cos(theta); xz_plane[3]=0.; 3618 xz_plane[1]=sin(theta); xz_plane[4]=0.; 3619 xz_plane[2]=0.; xz_plane[5]=1.; 3616 xz_plane[0]=cos(theta); xz_plane[3]=0.; 3617 xz_plane[1]=sin(theta); xz_plane[4]=0.; 3618 xz_plane[2]=0.; xz_plane[5]=1.; 3620 3619 3621 3620 if(groundedice>=0){ … … 3660 3659 3661 3660 /* Coefficients */ 3662 A = 3e-4; 3663 B = 0.15; 3661 A = 3e-4; 3662 B = 0.15; 3664 3663 alpha = 0.39; 3665 3664 beta = 1.18; 3666 3665 3667 3666 /*Get inputs*/ 3668 3667 Input* bed_input = this->GetInput(BedEnum); _assert_(bed_input); 3669 3668 Input* qsg_input = this->GetInput(FrontalForcingsSubglacialDischargeEnum); _assert_(qsg_input); 3670 3669 Input* TF_input = this->GetInput(FrontalForcingsThermalForcingEnum); _assert_(TF_input); 3671 GetInputListOnVertices(&basinid[0],FrontalForcingsBasinIdEnum); 3672 3670 GetInputListOnVertices(&basinid[0],FrontalForcingsBasinIdEnum); 3671 3673 3672 this->FindParam(&yts, ConstantsYtsEnum); 3674 3673 this->parameters->FindParam(&numbasins,FrontalForcingsNumberofBasinsEnum); … … 3676 3675 3677 3676 IssmDouble meltrates[NUMVERTICES]; //frontal melt-rate 3678 3677 3679 3678 /* Start looping on the number of vertices: */ 3680 3679 GaussTria* gauss=new GaussTria(); … … 3694 3693 /* calculate melt rates */ 3695 3694 meltrates[iv]=((A*max(-bed,0.)*pow(max(qsg_basin,0.),alpha)+B)*pow(max(TF,0.),beta))/86400; //[m/s] 3696 } 3695 } 3697 3696 3698 3697 if(xIsNan<IssmDouble>(meltrates[iv])) _error_("NaN found in vector"); … … 3702 3701 /*Add input*/ 3703 3702 this->inputs->AddInput(new TriaInput(CalvingMeltingrateEnum,&meltrates[0],P1Enum)); 3704 3703 3705 3704 /*Cleanup and return*/ 3706 3705 xDelete<IssmDouble>(basin_icefront_area); … … 4049 4048 4050 4049 /*Scaled not implemented yet...*/ 4051 _assert_(!scaled); 4050 _assert_(!scaled); 4052 4051 4053 4052 int domaintype,index1,index2; … … 4131 4130 4132 4131 /*Some checks in debugging mode*/ 4133 _assert_(s1>=0 && s1<=1.); 4134 _assert_(s2>=0 && s2<=1.); 4132 _assert_(s1>=0 && s1<=1.); 4133 _assert_(s2>=0 && s2<=1.); 4135 4134 4136 4135 /*Get normal vector*/ … … 4178 4177 4179 4178 /*Scaled not implemented yet...*/ 4180 _assert_(!scaled); 4179 _assert_(!scaled); 4181 4180 4182 4181 int domaintype,index1,index2; … … 4260 4259 4261 4260 /*Some checks in debugging mode*/ 4262 _assert_(s1>=0 && s1<=1.); 4263 _assert_(s2>=0 && s2<=1.); 4261 _assert_(s1>=0 && s1<=1.); 4262 _assert_(s2>=0 && s2<=1.); 4264 4263 4265 4264 /*Get normal vector*/ … … 4302 4301 vy_input->GetInputValue(&vy,gauss); 4303 4302 vel=vx*vx+vy*vy; 4304 meltingrate_input->GetInputValue(&meltingrate,gauss); 4303 meltingrate_input->GetInputValue(&meltingrate,gauss); 4305 4304 meltingratex=meltingrate*vx/(sqrt(vel)+1.e-14); 4306 4305 meltingratey=meltingrate*vy/(sqrt(vel)+1.e-14); … … 4328 4327 /*Get material parameters :*/ 4329 4328 rho_ice=FindParam(MaterialsRhoIceEnum); 4330 Input* floatingmelt_input = this->GetInput(BasalforcingsFloatingiceMeltingRateEnum); _assert_(floatingmelt_input); 4329 Input* floatingmelt_input = this->GetInput(BasalforcingsFloatingiceMeltingRateEnum); _assert_(floatingmelt_input); 4331 4330 Input* gllevelset_input = this->GetInput(MaskGroundediceLevelsetEnum); _assert_(gllevelset_input); 4332 4331 Input* scalefactor_input = NULL; 4333 4332 if(scaled==true){ 4334 scalefactor_input = this->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 4333 scalefactor_input = this->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 4335 4334 } 4336 4335 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); … … 4373 4372 /*Get material parameters :*/ 4374 4373 rho_ice=FindParam(MaterialsRhoIceEnum); 4375 Input* groundedmelt_input = this->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(groundedmelt_input); 4374 Input* groundedmelt_input = this->GetInput(BasalforcingsGroundediceMeltingRateEnum); _assert_(groundedmelt_input); 4376 4375 Input* gllevelset_input = this->GetInput(MaskGroundediceLevelsetEnum); _assert_(gllevelset_input); 4377 4376 Input* scalefactor_input = NULL; 4378 4377 if(scaled==true){ 4379 scalefactor_input = this->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 4378 scalefactor_input = this->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 4380 4379 } 4381 4380 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); … … 4427 4426 if(scaled==true){ 4428 4427 Input* scalefactor_input = inputs->GetInput(MeshScaleFactorEnum); _assert_(scalefactor_input); 4429 scalefactor_input->GetInputAverage(&scalefactor);// average scalefactor on element 4428 scalefactor_input->GetInputAverage(&scalefactor);// average scalefactor on element 4430 4429 } 4431 4430 else{ … … 4446 4445 /*Checks if debuging*/ 4447 4446 _assert_(iomodel->elements); 4448 _assert_(index==this->sid); 4447 _assert_(index==this->sid); 4449 4448 4450 4449 /*Recover element type*/ … … 4693 4692 int *indices = NULL; 4694 4693 this->GetLevelsetIntersection(&indices, &numiceverts,&s[0],fieldenum,fieldvalue); 4695 _assert_(numiceverts); 4694 _assert_(numiceverts); 4696 4695 4697 4696 /*3 Write coordinates*/ … … 4798 4797 4799 4798 /*pull thickness averages: */ 4800 thickness_input=inputs->GetInput(ThicknessEnum); 4799 thickness_input=inputs->GetInput(ThicknessEnum); 4801 4800 if (!thickness_input)_error_("thickness input needed to compute gia deflection!"); 4802 thickness_input->GetInput UpToCurrentTimeAverages(&hes,×,&numtimes,currenttime);4801 thickness_input->GetInputAveragesUpToCurrentTime(&hes,×,&numtimes,currenttime); 4803 4802 4804 4803 /*recover mantle viscosity: */ … … 4873 4872 IssmDouble area; 4874 4873 IssmDouble earth_radius = 6371012.0; // Earth's radius [m] 4875 IssmDouble I; //ice/water loading 4874 IssmDouble I; //ice/water loading 4876 4875 IssmDouble rho_ice, rho_earth; 4877 4876 … … 4879 4878 IssmDouble* U_elastic_precomputed = NULL; 4880 4879 IssmDouble* H_elastic_precomputed = NULL; 4881 int M, hemi; 4880 int M, hemi; 4882 4881 4883 4882 /*computation of Green functions:*/ … … 4892 4891 4893 4892 /*Compute ice thickness change: */ 4894 Input* deltathickness_input=inputs->GetInput(EsaDeltathicknessEnum); 4893 Input* deltathickness_input=inputs->GetInput(EsaDeltathicknessEnum); 4895 4894 if (!deltathickness_input)_error_("delta thickness input needed to compute elastic adjustment!"); 4896 4895 deltathickness_input->GetInputAverage(&I); 4897 4896 4898 /*early return if we are not on the (ice) loading point: */ 4899 if(I==0) return; 4897 /*early return if we are not on the (ice) loading point: */ 4898 if(I==0) return; 4900 4899 4901 4900 /*recover material parameters: */ … … 4907 4906 4908 4907 /*which hemisphere? for north-south, east-west components*/ 4909 this->parameters->FindParam(&hemi,EsaHemisphereEnum); 4908 this->parameters->FindParam(&hemi,EsaHemisphereEnum); 4910 4909 4911 4910 /*compute area of element:*/ … … 4913 4912 4914 4913 /*figure out gravity center of our element (Cartesian): */ 4915 IssmDouble x_element, y_element; 4914 IssmDouble x_element, y_element; 4916 4915 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 4917 4916 x_element=(xyz_list[0][0]+xyz_list[1][0]+xyz_list[2][0])/3.0; … … 4938 4937 IssmDouble* Y_values=xNewZeroInit<IssmDouble>(gsize); 4939 4938 IssmDouble dx, dy, dist, alpha, ang, ang2; 4940 IssmDouble N_azim, E_azim, X_azim, Y_azim; 4939 IssmDouble N_azim, E_azim, X_azim, Y_azim; 4941 4940 4942 4941 for(int i=0;i<gsize;i++){ 4943 4942 4944 indices[i]=i; 4945 4946 IssmDouble N_azim=0; 4943 indices[i]=i; 4944 4945 IssmDouble N_azim=0; 4947 4946 IssmDouble E_azim=0; 4948 4947 4949 4948 /*Compute alpha angle between centroid and current vertex: */ 4950 dx = x_element - xx[i]; dy = y_element - yy[i]; 4951 dist = sqrt(pow(dx,2)+pow(dy,2)); // distance between vertex and elemental centroid [m] 4952 alpha = dist*360.0/(2*PI*earth_radius) * PI/180.0; // [in radians] 360 degree = 2*pi*earth_radius 4949 dx = x_element - xx[i]; dy = y_element - yy[i]; 4950 dist = sqrt(pow(dx,2)+pow(dy,2)); // distance between vertex and elemental centroid [m] 4951 alpha = dist*360.0/(2*PI*earth_radius) * PI/180.0; // [in radians] 360 degree = 2*pi*earth_radius 4953 4952 4954 4953 /*Compute azimuths, both north and east components: */ 4955 ang = PI/2 - atan2(dy,dx); // this is bearing angle! 4956 Y_azim = cos(ang); 4957 X_azim = sin(ang); 4954 ang = PI/2 - atan2(dy,dx); // this is bearing angle! 4955 Y_azim = cos(ang); 4956 X_azim = sin(ang); 4958 4957 4959 4958 /*Elastic component (from Eq 17 in Adhikari et al, GMD 2015): */ … … 4968 4967 X_values[i]+=3*rho_ice/rho_earth*area/(4*PI*pow(earth_radius,2))*I*X_elastic[i]; 4969 4968 4970 /*North-south, East-west components */ 4969 /*North-south, East-west components */ 4971 4970 if (hemi == -1) { 4972 ang2 = PI/2 - atan2(yy[i],xx[i]); 4973 } 4971 ang2 = PI/2 - atan2(yy[i],xx[i]); 4972 } 4974 4973 else if (hemi == 1) { 4975 ang2 = PI/2 - atan2(-yy[i],-xx[i]); 4974 ang2 = PI/2 - atan2(-yy[i],-xx[i]); 4976 4975 } 4977 4976 if (hemi != 0){ … … 4992 4991 4993 4992 /*free ressources:*/ 4994 xDelete<int>(indices); 4993 xDelete<int>(indices); 4995 4994 xDelete<IssmDouble>(U_values); xDelete<IssmDouble>(N_values); xDelete<IssmDouble>(E_values); 4996 4995 xDelete<IssmDouble>(U_elastic); xDelete<IssmDouble>(N_elastic); xDelete<IssmDouble>(E_elastic); … … 5009 5008 IssmDouble xyz_list[NUMVERTICES][3]; 5010 5009 IssmDouble area; 5011 IssmDouble I; //ice/water loading 5010 IssmDouble I; //ice/water loading 5012 5011 IssmDouble late,longe,re; 5013 5012 IssmDouble lati,longi,ri; … … 5030 5029 5031 5030 /*Compute ice thickness change: */ 5032 Input* deltathickness_input=inputs->GetInput(EsaDeltathicknessEnum); 5031 Input* deltathickness_input=inputs->GetInput(EsaDeltathicknessEnum); 5033 5032 if (!deltathickness_input)_error_("delta thickness input needed to compute elastic adjustment!"); 5034 5033 deltathickness_input->GetInputAverage(&I); 5035 5034 5036 /*early return if we are not on the (ice) loading point: */ 5037 if(I==0) return; 5035 /*early return if we are not on the (ice) loading point: */ 5036 if(I==0) return; 5038 5037 5039 5038 /*recover material parameters: */ … … 5077 5076 longe=(llr_list[0][1]+llr_list[1][1]+llr_list[2][1])/3.0; 5078 5077 5079 late=90-late; 5078 late=90-late; 5080 5079 if(longe>180)longe=(longe-180)-180; 5081 5080 … … 5085 5084 5086 5085 /*figure out gravity center of our element (Cartesian): */ 5087 IssmDouble x_element, y_element, z_element; 5086 IssmDouble x_element, y_element, z_element; 5088 5087 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 5089 5088 x_element=(xyz_list[0][0]+xyz_list[1][0]+xyz_list[2][0])/3.0; … … 5108 5107 IssmDouble alpha; 5109 5108 IssmDouble delPhi,delLambda; 5110 IssmDouble dx, dy, dz, x, y, z; 5109 IssmDouble dx, dy, dz, x, y, z; 5111 5110 IssmDouble N_azim, E_azim; 5112 5111 5113 5112 for(int i=0;i<gsize;i++){ 5114 5113 5115 indices[i]=i; 5114 indices[i]=i; 5116 5115 5117 5116 /*Compute alpha angle between centroid and current vertex: */ … … 5122 5121 5123 5122 /*Compute azimuths, both north and east components: */ 5124 x = xx[i]; y = yy[i]; z = zz[i]; 5123 x = xx[i]; y = yy[i]; z = zz[i]; 5125 5124 if(latitude[i]==90){ 5126 x=1e-12; y=1e-12; 5125 x=1e-12; y=1e-12; 5127 5126 } 5128 5127 if(latitude[i]==-90){ 5129 x=1e-12; y=1e-12; 5130 } 5131 dx = x_element-x; dy = y_element-y; dz = z_element-z; 5128 x=1e-12; y=1e-12; 5129 } 5130 dx = x_element-x; dy = y_element-y; dz = z_element-z; 5132 5131 N_azim = (-z*x*dx-z*y*dy+(pow(x,2)+pow(y,2))*dz) /pow((pow(x,2)+pow(y,2))*(pow(x,2)+pow(y,2)+pow(z,2))*(pow(dx,2)+pow(dy,2)+pow(dz,2)),0.5); 5133 5132 E_azim = (-y*dx+x*dy) /pow((pow(x,2)+pow(y,2))*(pow(dx,2)+pow(dy,2)+pow(dz,2)),0.5); … … 5149 5148 5150 5149 /*free ressources:*/ 5151 xDelete<int>(indices); 5150 xDelete<int>(indices); 5152 5151 xDelete<IssmDouble>(U_values); xDelete<IssmDouble>(N_values); xDelete<IssmDouble>(E_values); 5153 5152 xDelete<IssmDouble>(U_elastic); xDelete<IssmDouble>(N_elastic); xDelete<IssmDouble>(E_elastic); … … 5187 5186 /*early return if we are not on an ice cap OR ocean:*/ 5188 5187 if(!(this->inputs->Max(MaskIceLevelsetEnum)<0) && !IsWaterInElement()){ 5189 dI_list[0] = 0.0; // this is important!!! 5190 dI_list[1] = 0.0; // this is important!!! 5191 dI_list[2] = 0.0; // this is important!!! 5192 return; 5188 dI_list[0] = 0.0; // this is important!!! 5189 dI_list[1] = 0.0; // this is important!!! 5190 dI_list[2] = 0.0; // this is important!!! 5191 return; 5193 5192 } 5194 5193 5195 5194 /*Compute area of element:*/ 5196 IssmDouble area; 5195 IssmDouble area; 5197 5196 area=GetAreaSpherical(); 5198 5197 … … 5231 5230 longe=(llr_list[0][1]+llr_list[1][1]+llr_list[2][1])/3.0; 5232 5231 5233 late=90-late; 5232 late=90-late; 5234 5233 if(longe>180)longe=(longe-180)-180; 5235 5234 … … 5240 5239 5241 5240 if(IsWaterInElement()){ 5242 IssmDouble rho_water, S; 5241 IssmDouble rho_water, S; 5243 5242 5244 5243 /*recover material parameters: */ … … 5248 5247 S=0; for(int i=0;i<NUMVERTICES;i++) S+=Sg_old[this->vertices[i]->Sid()]/NUMVERTICES; 5249 5248 5250 /* Perturbation terms for moment of inertia (moi_list): 5251 * computed analytically (see Wu & Peltier, eqs 10 & 32) 5249 /* Perturbation terms for moment of inertia (moi_list): 5250 * computed analytically (see Wu & Peltier, eqs 10 & 32) 5252 5251 * also consistent with my GMD formulation! 5253 * ALL in geographic coordinates 5252 * ALL in geographic coordinates 5254 5253 * */ 5255 dI_list[0] = -4*PI*(rho_water*S*area)*pow(re,4)*(sin(late)*cos(late)*cos(longe))/eartharea; 5256 dI_list[1] = -4*PI*(rho_water*S*area)*pow(re,4)*(sin(late)*cos(late)*sin(longe))/eartharea; 5257 dI_list[2] = +4*PI*(rho_water*S*area)*pow(re,4)*(1-pow(sin(late),2))/eartharea; 5254 dI_list[0] = -4*PI*(rho_water*S*area)*pow(re,4)*(sin(late)*cos(late)*cos(longe))/eartharea; 5255 dI_list[1] = -4*PI*(rho_water*S*area)*pow(re,4)*(sin(late)*cos(late)*sin(longe))/eartharea; 5256 dI_list[2] = +4*PI*(rho_water*S*area)*pow(re,4)*(1-pow(sin(late),2))/eartharea; 5258 5257 } 5259 5258 else if(this->inputs->Max(MaskIceLevelsetEnum)<0){ 5260 IssmDouble rho_ice, I; 5259 IssmDouble rho_ice, I; 5261 5260 5262 5261 /*recover material parameters: */ … … 5264 5263 5265 5264 /*Compute ice thickness change: */ 5266 Input* deltathickness_input=inputs->GetInput(SealevelriseDeltathicknessEnum); 5265 Input* deltathickness_input=inputs->GetInput(SealevelriseDeltathicknessEnum); 5267 5266 if (!deltathickness_input)_error_("delta thickness input needed to compute sea level rise!"); 5268 5267 deltathickness_input->GetInputAverage(&I); 5269 5268 5270 dI_list[0] = -4*PI*(rho_ice*I*area)*pow(re,4)*(sin(late)*cos(late)*cos(longe))/eartharea; 5271 dI_list[1] = -4*PI*(rho_ice*I*area)*pow(re,4)*(sin(late)*cos(late)*sin(longe))/eartharea; 5272 dI_list[2] = +4*PI*(rho_ice*I*area)*pow(re,4)*(1-pow(sin(late),2))/eartharea; 5273 } 5274 5275 return; 5269 dI_list[0] = -4*PI*(rho_ice*I*area)*pow(re,4)*(sin(late)*cos(late)*cos(longe))/eartharea; 5270 dI_list[1] = -4*PI*(rho_ice*I*area)*pow(re,4)*(sin(late)*cos(late)*sin(longe))/eartharea; 5271 dI_list[2] = +4*PI*(rho_ice*I*area)*pow(re,4)*(1-pow(sin(late),2))/eartharea; 5272 } 5273 5274 return; 5276 5275 }/*}}}*/ 5277 5276 void Tria::SealevelriseEustatic(Vector<IssmDouble>* pSgi,IssmDouble* peustatic,IssmDouble* latitude,IssmDouble* longitude,IssmDouble* radius,IssmDouble oceanarea,IssmDouble eartharea){ /*{{{*/ … … 5340 5339 /*recover elastic green function:*/ 5341 5340 if(computeelastic){ 5342 DoubleVecParam* parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelriseGElasticEnum)); 5341 DoubleVecParam* parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelriseGElasticEnum)); 5343 5342 _assert_(parameter); 5344 5343 parameter->GetParameterValueByPointer(&G_elastic_precomputed,&M); … … 5380 5379 longe=(llr_list[0][1]+llr_list[1][1]+llr_list[2][1])/3.0; 5381 5380 5382 late=90-late; 5381 late=90-late; 5383 5382 if(longe>180)longe=(longe-180)-180; 5384 5383 … … 5399 5398 5400 5399 /*Compute ice thickness change: */ 5401 Input* deltathickness_input=inputs->GetInput(SealevelriseDeltathicknessEnum); 5400 Input* deltathickness_input=inputs->GetInput(SealevelriseDeltathicknessEnum); 5402 5401 if (!deltathickness_input)_error_("delta thickness input needed to compute sea level rise!"); 5403 5402 5404 5403 /*If we are fully grounded, take the average over the element: */ 5405 5404 if(!notfullygrounded)deltathickness_input->GetInputAverage(&I); 5406 else{ 5405 else{ 5407 5406 IssmDouble total_weight=0; 5408 5407 bool mainlyfloating = true; … … 5430 5429 /*Compute eustatic compoent:*/ 5431 5430 _assert_(oceanarea>0.); 5432 if(scaleoceanarea) oceanarea=3.619e+14; // use true ocean area, m^2 5433 eustatic += rho_ice*area*I/(oceanarea*rho_water); 5431 if(scaleoceanarea) oceanarea=3.619e+14; // use true ocean area, m^2 5432 eustatic += rho_ice*area*I/(oceanarea*rho_water); 5434 5433 5435 5434 if(computeelastic | computerigid){ … … 5564 5563 longe=(llr_list[0][1]+llr_list[1][1]+llr_list[2][1])/3.0; 5565 5564 5566 late=90-late; 5565 late=90-late; 5567 5566 if(longe>180)longe=(longe-180)-180; 5568 5567 … … 5589 5588 for(int i=0;i<gsize;i++){ 5590 5589 5591 indices[i]=i; 5590 indices[i]=i; 5592 5591 5593 5592 /*Compute alpha angle between centroid and current vertex : */ … … 5598 5597 5599 5598 /*Rigid earth gravitational perturbation: */ 5600 if(computerigid){ 5601 G_rigid[i]=1.0/2.0/sin(alpha/2.0); 5599 if(computerigid){ 5600 G_rigid[i]=1.0/2.0/sin(alpha/2.0); 5602 5601 values[i]+=3*rho_water/rho_earth*area/eartharea*S*G_rigid[i]; 5603 5602 } … … 5662 5661 5663 5662 /*early return if we are not on the ocean or on an ice cap:*/ 5664 if(!(this->inputs->Max(MaskIceLevelsetEnum)<0) && !IsWaterInElement()) return; 5663 if(!(this->inputs->Max(MaskIceLevelsetEnum)<0) && !IsWaterInElement()) return; 5665 5664 5666 5665 /*early return if we are fully floating: */ … … 5715 5714 longe=(llr_list[0][1]+llr_list[1][1]+llr_list[2][1])/3.0; 5716 5715 5717 late=90-late; 5716 late=90-late; 5718 5717 if(longe>180)longe=(longe-180)-180; 5719 5718 … … 5723 5722 5724 5723 /*figure out gravity center of our element (Cartesian): */ 5725 IssmDouble x_element, y_element, z_element; 5724 IssmDouble x_element, y_element, z_element; 5726 5725 ::GetVerticesCoordinates(&xyz_list[0][0],vertices,NUMVERTICES); 5727 5726 x_element=(xyz_list[0][0]+xyz_list[1][0]+xyz_list[2][0])/3.0; … … 5741 5740 5742 5741 /*Compute ice thickness change: */ 5743 Input* deltathickness_input=inputs->GetInput(SealevelriseDeltathicknessEnum); 5742 Input* deltathickness_input=inputs->GetInput(SealevelriseDeltathicknessEnum); 5744 5743 if (!deltathickness_input)_error_("delta thickness input needed to compute sea level rise!"); 5745 5744 deltathickness_input->GetInputAverage(&I); … … 5755 5754 U_values=xNewZeroInit<IssmDouble>(gsize); 5756 5755 if(horiz){ 5757 N_values=xNewZeroInit<IssmDouble>(gsize); 5756 N_values=xNewZeroInit<IssmDouble>(gsize); 5758 5757 E_values=xNewZeroInit<IssmDouble>(gsize); 5759 5758 } 5760 5759 IssmDouble alpha; 5761 5760 IssmDouble delPhi,delLambda; 5762 IssmDouble dx, dy, dz, x, y, z; 5761 IssmDouble dx, dy, dz, x, y, z; 5763 5762 IssmDouble N_azim, E_azim; 5764 5763 5765 5764 for(int i=0;i<gsize;i++){ 5766 5765 5767 indices[i]=i; 5766 indices[i]=i; 5768 5767 5769 5768 /*Compute alpha angle between centroid and current vertex: */ … … 5774 5773 5775 5774 /*Compute azimuths, both north and east components: */ 5776 x = xx[i]; y = yy[i]; z = zz[i]; 5775 x = xx[i]; y = yy[i]; z = zz[i]; 5777 5776 if(latitude[i]==90){ 5778 x=1e-12; y=1e-12; 5777 x=1e-12; y=1e-12; 5779 5778 } 5780 5779 if(latitude[i]==-90){ 5781 x=1e-12; y=1e-12; 5782 } 5783 dx = x_element-x; dy = y_element-y; dz = z_element-z; 5780 x=1e-12; y=1e-12; 5781 } 5782 dx = x_element-x; dy = y_element-y; dz = z_element-z; 5784 5783 if(horiz){ 5785 5784 N_azim = (-z*x*dx-z*y*dy+(pow(x,2)+pow(y,2))*dz) /pow((pow(x,2)+pow(y,2))*(pow(x,2)+pow(y,2)+pow(z,2))*(pow(dx,2)+pow(dy,2)+pow(dz,2)),0.5); … … 5818 5817 5819 5818 /*free ressources:*/ 5820 xDelete<int>(indices); 5821 xDelete<IssmDouble>(U_values); 5822 xDelete<IssmDouble>(U_elastic); 5819 xDelete<int>(indices); 5820 xDelete<IssmDouble>(U_values); 5821 xDelete<IssmDouble>(U_elastic); 5823 5822 if(horiz){ 5824 5823 xDelete<IssmDouble>(N_values); xDelete<IssmDouble>(E_values); -
issm/trunk-jpl/src/c/classes/Elements/TriaRef.cpp
r24131 r24240 33 33 /*Reference Element numerics*/ 34 34 void TriaRef::GetInputDerivativeValue(IssmDouble* p, IssmDouble* plist,IssmDouble* xyz_list, Gauss* gauss,int finiteelement){/*{{{*/ 35 /*From node values of parameter p (plist[0],plist[1],plist[2]), return parameter derivative value at gaussian 35 /*From node values of parameter p (plist[0],plist[1],plist[2]), return parameter derivative value at gaussian 36 36 * point specified by gauss_basis: 37 37 * dp/dx=plist[0]*dh1/dx+plist[1]*dh2/dx+plist[2]*dh3/dx … … 89 89 /*}}}*/ 90 90 void TriaRef::GetJacobian(IssmDouble* J, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 91 /*The Jacobian is constant over the element, discard the gaussian points. 91 /*The Jacobian is constant over the element, discard the gaussian points. 92 92 * J is assumed to have been allocated of size NDOF2xNDOF2.*/ 93 93 … … 106 106 /*}}}*/ 107 107 void TriaRef::GetJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 108 /*The Jacobian determinant is constant over the element, discard the gaussian points. 108 /*The Jacobian determinant is constant over the element, discard the gaussian points. 109 109 * J is assumed to have been allocated of size NDOF2xNDOF2.*/ 110 110 IssmDouble J[2][2]; … … 120 120 /*}}}*/ 121 121 void TriaRef::GetJacobianDeterminant3D(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 122 /*The Jacobian determinant is constant over the element, discard the gaussian points. 122 /*The Jacobian determinant is constant over the element, discard the gaussian points. 123 123 * J is assumed to have been allocated of size NDOF2xNDOF2.*/ 124 124 IssmDouble J[2][2]; … … 202 202 void TriaRef::GetNodalFunctionsDerivatives(IssmDouble* dbasis,IssmDouble* xyz_list, Gauss* gauss,int finiteelement){/*{{{*/ 203 203 204 /*This routine returns the values of the nodal functions derivatives (with respect to the 204 /*This routine returns the values of the nodal functions derivatives (with respect to the 205 205 * actual coordinate system): */ 206 206 IssmDouble Jinv[2][2]; … … 211 211 /*Get nodal functions derivatives in reference triangle*/ 212 212 IssmDouble dbasis_ref[2*NUMNODESMAX]; 213 GetNodalFunctionsDerivativesReference(dbasis_ref,gauss,finiteelement); 213 GetNodalFunctionsDerivativesReference(dbasis_ref,gauss,finiteelement); 214 214 215 215 /*Get Jacobian invert: */ 216 216 GetJacobianInvert(&Jinv[0][0], xyz_list, gauss); 217 217 218 /*Build dbasis: 218 /*Build dbasis: 219 219 * [dhi/dx]= Jinv*[dhi/dr] 220 220 * [dhi/dy] [dhi/ds] … … 228 228 /*}}}*/ 229 229 void TriaRef::GetSegmentJacobianDeterminant(IssmDouble* Jdet, IssmDouble* xyz_list,Gauss* gauss){/*{{{*/ 230 /*The Jacobian determinant is constant over the element, discard the gaussian points. 230 /*The Jacobian determinant is constant over the element, discard the gaussian points. 231 231 * J is assumed to have been allocated*/ 232 232 … … 313 313 /*}}}*/ 314 314 void TriaRef::GetNodalFunctionsDerivativesReference(IssmDouble* dbasis,Gauss* gauss_in,int finiteelement){/*{{{*/ 315 /*This routine returns the values of the nodal functions derivatives (with respect to the 315 /*This routine returns the values of the nodal functions derivatives (with respect to the 316 316 * natural coordinate system) at the gaussian point. */ 317 317 -
issm/trunk-jpl/src/c/classes/FemModel.cpp
r24205 r24240 1534 1534 void FemModel::IcefrontAreax(){/*{{{*/ 1535 1535 1536 int numvertices = this->GetElementsWidth(); 1536 1537 int numbasins; 1538 IssmDouble* BasinId = xNew<IssmDouble>(numvertices); 1537 1539 this->parameters->FindParam(&numbasins,FrontalForcingsNumberofBasinsEnum); 1538 1540 IssmDouble* basin_icefront_area = xNewZeroInit<IssmDouble>(numbasins); … … 1544 1546 for(int i=0;i<this->elements->Size();i++){ 1545 1547 Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i)); 1546 if(!element->IsOnBase()) continue;1547 int numvertices = element->GetNumberOfVertices();1548 IssmDouble* BasinId = xNew<IssmDouble>(numvertices);1549 1548 element->GetInputListOnVertices(BasinId,FrontalForcingsBasinIdEnum); 1550 for(int j=0;j< 3;j++){1549 for(int j=0;j<numvertices;j++){ 1551 1550 if(BasinId[j]==basin){ 1552 1551 local_icefront_area+=element->GetIcefrontArea(); … … 1554 1553 } 1555 1554 } 1556 xDelete<IssmDouble>(BasinId);1557 1555 } 1558 1556 ISSM_MPI_Reduce(&local_icefront_area,&total_icefront_area,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm()); … … 1563 1561 1564 1562 this->parameters->AddObject(new DoubleVecParam(FrontalForcingsBasinIcefrontAreaEnum,basin_icefront_area,numbasins)); 1563 1565 1564 xDelete<IssmDouble>(basin_icefront_area); 1566 1565 xDelete<IssmDouble>(BasinId); 1567 1566 }/*}}}*/ 1568 1567 void FemModel::IcefrontMassFluxx(IssmDouble* pM, bool scaled){/*{{{*/ … … 2216 2215 /*}}}*/ 2217 2216 void FemModel::RequestedOutputsx(Results **presults,char** requested_outputs, int numoutputs, bool save_results){/*{{{*/ 2218 2217 2219 2218 /*Intermediaries*/ 2220 2219 bool isvec,results_on_nodes; … … 2235 2234 if(numonnodes) parameters->FindParam(&resultsonnodes,&numonnodes,SettingsResultsOnNodesEnum); 2236 2235 2236 2237 2237 /*Go through all requested output*/ 2238 2238 for(int i=0;i<numoutputs;i++){ 2239 2240 2239 output_string = requested_outputs[i]; 2241 2240 output_enum = StringToEnumx(output_string,false); 2242 2241 isvec = false; 2242 2243 2243 2244 2244 /*If string is not an enum, it is defined in output definitions*/ … … 5086 5086 } 5087 5087 /*}}}*/ 5088 void FemModel::Init MeanOutputx(int* stackedinput_enum,int numoutputs){ /*{{{*/5089 5090 5091 if( stackedinput_enum[i]<0){5088 void FemModel::InitTransientOutputx(int* transientinput_enum,int numoutputs){ /*{{{*/ 5089 5090 for(int i=0;i<numoutputs;i++){ 5091 if(transientinput_enum[i]<0){ 5092 5092 _error_("Can't deal with non enum fields for result Stack"); 5093 5093 } 5094 5094 else{ 5095 5095 for(int j=0;j<elements->Size();j++){ 5096 TransientInput* transient_input = new TransientInput(transientinput_enum[i]); 5096 5097 /*Intermediaries*/ 5097 Element* element = xDynamicCast<Element*>(elements->GetObjectByOffset(j)); 5098 int numvertices = element->GetNumberOfVertices(); 5099 IssmDouble* zeros = xNewZeroInit<IssmDouble>(numvertices); 5100 switch(element->ObjectEnum()){ 5101 case TriaEnum: 5102 element->inputs->AddInput(new TriaInput(stackedinput_enum[i],&zeros[0],P1Enum)); 5103 break; 5104 case PentaEnum: 5105 element->inputs->AddInput(new PentaInput(stackedinput_enum[i],&zeros[0],P1Enum)); 5106 break; 5107 case TetraEnum: 5108 element->inputs->AddInput(new TetraInput(stackedinput_enum[i],&zeros[0],P1Enum)); 5109 break; 5110 default: _error_("Not implemented yet"); 5111 } 5112 xDelete<IssmDouble>(zeros); 5113 } 5114 } 5115 } 5116 } 5117 /*}}}*/ 5118 void FemModel::SumOutputx(int* input_enum,int* stackedinput_enum,int numoutputs){ /*{{{*/ 5119 5120 //First get sub-timestep 5121 IssmDouble hydrodt; 5122 this->parameters->FindParam(&hydrodt,HydrologydtEnum); 5098 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(j)); 5099 element->inputs->AddInput(transient_input); 5100 } 5101 } 5102 } 5103 } 5104 /*}}}*/ 5105 void FemModel::StackTransientOutputx(int* input_enum,int* transientinput_enum,IssmDouble subtime,int numoutputs){ /*{{{*/ 5123 5106 5124 5107 for(int i=0;i<numoutputs;i++){ … … 5130 5113 /*Intermediaries*/ 5131 5114 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(j)); 5115 Input* input=element->inputs->GetInput(transientinput_enum[i]); _assert_(input); //this is the enum stack 5116 TransientInput* stacking_input=xDynamicCast<TransientInput*>(input); 5117 5132 5118 int numvertices = element->GetNumberOfVertices(); 5133 IssmDouble* values_to_add=xNew<IssmDouble>(numvertices); 5134 IssmDouble* existing_values=xNew<IssmDouble>(numvertices); 5135 element->GetInputListOnVertices(&values_to_add[0],input_enum[i]); //those are the values to add 5136 element->GetInputListOnVertices(&existing_values[0],stackedinput_enum[i]); //those are the values to add 5137 for(int k=0;k<numvertices;k++){ 5138 existing_values[k]+=values_to_add[k]*hydrodt; 5119 IssmDouble* N=xNew<IssmDouble>(numvertices); 5120 element->GetInputListOnVertices(&N[0],input_enum[i]); //this is the enum to stack 5121 switch(element->ObjectEnum()){ 5122 case TriaEnum: 5123 stacking_input->AddTimeInput(new TriaInput(transientinput_enum[i],&N[0],P1Enum),subtime); 5124 break; 5125 case PentaEnum: 5126 stacking_input->AddTimeInput(new PentaInput(transientinput_enum[i],&N[0],P1Enum),subtime); 5127 break; 5128 case TetraEnum: 5129 stacking_input->AddTimeInput(new TetraInput(transientinput_enum[i],&N[0],P1Enum),subtime); 5130 break; 5131 default: _error_("Not implemented yet"); 5139 5132 } 5140 element->AddInput(stackedinput_enum[i],&existing_values[0],P1Enum); 5141 xDelete<IssmDouble>(existing_values); 5142 xDelete<IssmDouble>(values_to_add); 5143 } 5144 } 5145 } 5146 } 5147 /*}}}*/ 5148 void FemModel::AverageSumOutputx(int* stackedinput_enum,int* averagedinput_enum,int numoutputs){ /*{{{*/ 5149 5150 //First get timestep 5151 IssmDouble maindt; 5152 this->parameters->FindParam(&maindt,TimesteppingTimeStepEnum); 5153 for(int i=0;i<numoutputs;i++){ 5154 if(stackedinput_enum[i]<0){ 5133 stacking_input->Configure(parameters); 5134 xDelete<IssmDouble>(N); 5135 } 5136 } 5137 } 5138 } 5139 /*}}}*/ 5140 void FemModel::AverageTransientOutputx(int* transientinput_enum,int* averagedinput_enum,IssmDouble init_time,IssmDouble end_time,int numoutputs){ /*{{{*/ 5141 5142 5143 IssmDouble yts; 5144 this->parameters->FindParam(&yts,ConstantsYtsEnum); 5145 for(int i=0;i<numoutputs;i++){ 5146 if(transientinput_enum[i]<0){ 5155 5147 _error_("Can't deal with non enum fields for result Stack"); 5156 5148 } 5157 5149 else{ 5158 5150 for(int j=0;j<elements->Size();j++){ 5159 /*Intermediaries*/ 5160 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(j)); 5161 int numvertices = element->GetNumberOfVertices(); 5162 IssmDouble* time_averaged=xNew<IssmDouble>(numvertices); 5163 IssmDouble* existing_values=xNew<IssmDouble>(numvertices); 5164 element->GetInputListOnVertices(&existing_values[0],stackedinput_enum[i]); //those are the values to add 5165 5166 for(int k=0;k<numvertices;k++){ 5167 time_averaged[k]=existing_values[k]/maindt; 5151 Element* element = xDynamicCast<Element*>(elements->GetObjectByOffset(j)); 5152 int numnodes = element->GetNumberOfNodes(); 5153 IssmDouble* time_averaged = xNew<IssmDouble>(numnodes); 5154 Gauss* gauss = element->NewGauss(); 5155 5156 Input* input = element->GetInput(transientinput_enum[i]); _assert_(input); 5157 TransientInput* transient_input=xDynamicCast<TransientInput*>(input); 5158 5159 for(int iv=0;iv<numnodes;iv++){ 5160 gauss->GaussNode(element->FiniteElement(),iv); 5161 transient_input->GetInputAverageOverTimeSlice(&time_averaged[iv],gauss,init_time,end_time); 5168 5162 } 5169 5170 element->AddInput(averagedinput_enum[i],&time_averaged[0],P1Enum); 5171 xDelete<IssmDouble>(time_averaged); 5172 xDelete<IssmDouble>(existing_values); 5163 element->AddInput(averagedinput_enum[i],&time_averaged[0],element->GetElementType()); 5164 delete gauss; 5173 5165 } 5174 5166 } -
issm/trunk-jpl/src/c/classes/FemModel.h
r24153 r24240 170 170 void UpdateConstraintsExtrudeFromTopx(); 171 171 void UpdateConstraintsL2ProjectionEPLx(IssmDouble* pL2count); 172 void Init MeanOutputx(int* stackedinput_enum,int numoutputs);173 void S umOutputx(int* input_enum,int* stackedinput_enum,int numoutputs);174 void Average SumOutputx(int* stackedinput_enum,int* averagedinput_enum,int numoutputs);172 void InitTransientOutputx(int* transientinput_enum,int numoutputs); 173 void StackTransientOutputx(int* input_enum,int* transientinput_enum,IssmDouble hydrotime,int numoutputs); 174 void AverageTransientOutputx(int* transientinput_enum,int* averagedinput_enum,IssmDouble init_time,IssmDouble end_time,int numoutputs); 175 175 void UpdateConstraintsx(void); 176 176 int UpdateVertexPositionsx(void); -
issm/trunk-jpl/src/c/classes/Inputs/BoolInput.cpp
r21872 r24240 153 153 } 154 154 /*}}}*/ 155 void BoolInput::PointwiseMult(Input* xinput){/*{{{*/ 156 /*That would compare to a AND operation*/ 157 BoolInput* xboolinput=NULL; 158 159 /*xinput is of the same type, so cast it: */ 160 xboolinput=(BoolInput*)xinput; 161 162 /*Carry out the PointwiseMult operation depending on type:*/ 163 switch(xinput->ObjectEnum()){ 164 165 case BoolInputEnum: 166 this->value=reCast<bool,IssmDouble>(this->value=this->value*xboolinput->value); 167 return; 168 169 default: 170 _error_("not implemented yet"); 171 } 172 } 173 /*}}}*/ 174 void BoolInput::Pow(IssmDouble exponent){/*{{{*/ 175 /* no power for Bools*/ 176 } 177 /*}}}*/ 155 178 void BoolInput::Scale(IssmDouble scale_factor){/*{{{*/ 156 179 /*a bool cannot be scaled: */ -
issm/trunk-jpl/src/c/classes/Inputs/BoolInput.h
r23998 r24240 1 /*! \file BoolInput.h 1 /*! \file BoolInput.h 2 2 * \brief: header file for triavertexinput object 3 3 */ … … 44 44 void ChangeEnum(int newenumtype); 45 45 void Extrude(int start); 46 void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};47 46 void GetInputAverage(IssmDouble* pvalue); 47 void GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");}; 48 48 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, Gauss* gauss){_error_("not implemented yet");}; 49 49 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");}; 50 void GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};50 void GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");}; 51 51 void GetInputValue(bool* pvalue); 52 52 void GetInputValue(int* pvalue); … … 61 61 IssmDouble Min(void){_error_("Min not implemented for booleans");}; 62 62 IssmDouble MinAbs(void){_error_("Min not implemented for booleans");}; 63 void PointwiseMult(Input* xinput); 64 void Pow(IssmDouble exponent); 63 65 void Scale(IssmDouble scale_factor); 64 66 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp
r22794 r24240 253 253 } 254 254 /*}}}*/ 255 void ControlInput::PointwiseMult(Input* xinput){/*{{{*/ 256 values->PointwiseMult(xinput); 257 }/*}}}*/ 255 258 void ControlInput::SaveValue(void){/*{{{*/ 256 259 if(!values) _error_("Values of " << EnumToStringx(this->enum_type) << " not found"); -
issm/trunk-jpl/src/c/classes/Inputs/ControlInput.h
r23998 r24240 1 /*! \file ControlInput.h 1 /*! \file ControlInput.h 2 2 * \brief: header file for triavertexinput object 3 3 */ … … 35 35 void DeepEcho(); 36 36 void Echo(); 37 int Id(); 37 int Id(); 38 38 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 39 39 int ObjectEnum(); … … 52 52 void GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist); 53 53 void GetGradientValue(IssmDouble* pvalue,Gauss* gauss); 54 void GetInputA llTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};54 void GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");}; 55 55 void GetInputAverage(IssmDouble* pvalue); 56 56 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss); 57 57 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");}; 58 void GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};58 void GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");}; 59 59 void GetInputValue(bool* pvalue); 60 60 void GetInputValue(int* pvalue); … … 75 75 void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");}; 76 76 void SaveValue(void); 77 void PointwiseMult(Input* xinput); 78 void Pow(IssmDouble exponent){_error_("not implemented yet");}; 77 79 void Scale(IssmDouble scale_factor){_error_("not implemented yet");}; 78 80 void SetGradient(Input* gradient_in,int timestep); -
issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.h
r23998 r24240 1 /*! \file DatasetInput.h 1 /*! \file DatasetInput.h 2 2 * \brief: header file for datasetinput object 3 3 */ … … 47 47 void Extrude(int start){_error_("not implemented yet");}; 48 48 void GetGradient(Vector<IssmDouble>* gradient_vec,int* doflist){_error_("not implemented yet");}; 49 void GetInputA llTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};49 void GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");}; 50 50 void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");}; 51 51 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");}; … … 57 57 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 58 58 void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index); 59 void GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};59 void GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");}; 60 60 int GetInputInterpolationType(){_error_("not implemented yet!");}; 61 61 int GetResultArraySize(void){_error_("not implemented yet");}; … … 69 69 void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");}; 70 70 void SaveValue(void){_error_("not implemented yet");}; 71 void PointwiseMult(Input* xinput){_error_("not implemented yet");}; 72 void Pow(IssmDouble exponent){_error_("not implemented yet");}; 71 73 void Scale(IssmDouble scale_factor){_error_("not implemented yet");}; 72 74 void SetGradient(Input* gradient_in){_error_("not implemented yet");}; -
issm/trunk-jpl/src/c/classes/Inputs/DoubleArrayInput.h
r23998 r24240 1 /*! \file DoubleArrayInput.h 1 /*! \file DoubleArrayInput.h 2 2 * \brief: header file for vector type input object 3 3 */ … … 27 27 void DeepEcho(); 28 28 void Echo(); 29 int Id(); 29 int Id(); 30 30 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 31 31 int ObjectEnum(); … … 46 46 void ChangeEnum(int newenumtype); 47 47 void Extrude(int start){_error_("not supported yet");}; 48 void GetInputA llTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};48 void GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");}; 49 49 void GetInputAverage(IssmDouble* pvalue){_error_("not implemented yet");}; 50 50 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");}; … … 56 56 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 57 57 void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");}; 58 void GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};58 void GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");}; 59 59 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");}; 60 60 int GetInputInterpolationType(){_error_("not implemented yet!");}; … … 63 63 IssmDouble Min(void){_error_("not implemented yet");}; 64 64 IssmDouble MinAbs(void){_error_("not implemented yet");}; 65 void PointwiseMult(Input* xinput){_error_("not implemented yet");}; 66 void Pow(IssmDouble exponent){_error_("not implemented yet");}; 65 67 void Scale(IssmDouble scale_factor){_error_("not implemented yet");}; 66 68 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.cpp
r21974 r24240 171 171 } 172 172 /*}}}*/ 173 void DoubleInput::PointwiseMult(Input* xinput){/*{{{*/ 174 175 DoubleInput* xIssmDoubleinput=NULL; 176 177 178 /*xinput is of the same type, so cast it: */ 179 xIssmDoubleinput=(DoubleInput*)xinput; 180 181 switch(xinput->ObjectEnum()){ 182 183 case DoubleInputEnum: 184 this->value=this->value*xIssmDoubleinput->value; 185 return; 186 187 default: 188 _error_("not implemented yet"); 189 } 190 } 191 /*}}}*/ 192 void DoubleInput::Pow(IssmDouble exponent){/*{{{*/ 193 194 if(exponent==0.0){ 195 /* Not-a-number left alone Infinity set to one */ 196 if (value==value)value=1.0; 197 } 198 else if(exponent==0.5){ 199 if(value>=0){ 200 value=sqrt(value); 201 } 202 else{ 203 value=INFINITY; 204 } 205 } 206 else if(exponent==1.0){ 207 /* do nothing */ 208 } 209 else if(exponent==-0.5){ 210 if(value>=0){ 211 value=1.0/sqrt(value); 212 } 213 else{ 214 value=INFINITY; 215 } 216 } 217 else if(exponent==-1.0){ 218 if(value!=0.){ 219 value=1.0/value; 220 } 221 else{ 222 value=INFINITY; 223 } 224 } 225 else { 226 value=pow(value,exponent); 227 } 228 } 229 /*}}}*/ 173 230 void DoubleInput::Scale(IssmDouble scale_factor){/*{{{*/ 174 231 value=value*scale_factor; -
issm/trunk-jpl/src/c/classes/Inputs/DoubleInput.h
r23998 r24240 1 /*! \file DoubleInput.h 1 /*! \file DoubleInput.h 2 2 * \brief: header file for triavertexinput object 3 3 */ … … 28 28 void DeepEcho(); 29 29 void Echo(); 30 int Id(); 30 int Id(); 31 31 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 32 32 int ObjectEnum(); … … 47 47 void ChangeEnum(int newenumtype); 48 48 void Extrude(int start){_error_("not supported yet");}; 49 void GetInputA llTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};49 void GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");}; 50 50 void GetInputAverage(IssmDouble* pvalue); 51 51 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");}; … … 57 57 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 58 58 void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");}; 59 void GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};59 void GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");}; 60 60 int GetInputInterpolationType(){return P0Enum; }; 61 61 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); … … 64 64 IssmDouble Min(void); 65 65 IssmDouble MinAbs(void); 66 void PointwiseMult(Input* xinput); 67 void Pow(IssmDouble exponent); 66 68 void Scale(IssmDouble scale_factor); 67 69 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Inputs/Input.h
r23998 r24240 1 1 /*!\file: Input.h 2 2 * \brief abstract class for Input object 3 */ 3 */ 4 4 5 5 #ifndef _INPUT_H_ … … 21 21 class Input: public Object{ 22 22 23 public: 23 public: 24 24 25 25 virtual ~Input(){}; … … 27 27 virtual void ChangeEnum(int newenumtype)=0; 28 28 virtual void Configure(Parameters* parameters)=0; 29 virtual void GetInputA llTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes)=0;29 virtual void GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes)=0; 30 30 virtual void GetInputAverage(IssmDouble* pvalue)=0; 31 31 virtual void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list)=0; … … 38 38 virtual void GetInputValue(IssmDouble* pvalue,Gauss* gauss,int index)=0; 39 39 virtual int GetInputInterpolationType()=0; 40 virtual void GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime)=0;41 virtual int InstanceEnum()=0; 40 virtual void GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime)=0; 41 virtual int InstanceEnum()=0; 42 42 43 43 virtual void AXPY(Input* xinput,IssmDouble scalar)=0; … … 48 48 virtual IssmDouble Min(void)=0; 49 49 virtual IssmDouble MinAbs(void)=0; 50 virtual void PointwiseMult(Input* xinput)=0; 51 virtual void Pow(IssmDouble exponent)=0; 50 52 virtual void Scale(IssmDouble scale_factor)=0; 51 53 … … 56 58 virtual Input* SpawnTriaInput(int index1,int index2,int index3)=0; 57 59 virtual void ResultToMatrix(IssmDouble* values,int ncols,int sid){_error_("not supported yet");}; 58 virtual void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");}; 60 virtual void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");}; 59 61 }; 60 62 #endif -
issm/trunk-jpl/src/c/classes/Inputs/IntInput.cpp
r21974 r24240 149 149 } 150 150 /*}}}*/ 151 void IntInput::PointwiseMult(Input* xinput){/*{{{*/ 152 153 IssmDouble dvalue; 154 IntInput* xintinput=NULL; 155 156 /*xinput is of the same type, so cast it: */ 157 xintinput=(IntInput*)xinput; 158 159 /*Carry out the PointwiseMult operation depending on type:*/ 160 switch(xinput->ObjectEnum()){ 161 162 case IntInputEnum: 163 dvalue=(IssmDouble)this->value*(IssmDouble)xintinput->value; 164 this->value=reCast<int>(dvalue); 165 return; 166 167 default: 168 _error_("not implemented yet"); 169 } 170 } 171 /*}}}*/ 172 void IntInput::Pow(IssmDouble exponent){/*{{{*/ 173 174 IssmDouble dvalue; 175 176 if(exponent==0.0){ 177 /* Not-a-number left alone Infinity set to one */ 178 if (dvalue==dvalue)dvalue=1.0; 179 } 180 else if(exponent==0.5){ 181 if(dvalue>=0){ 182 dvalue=sqrt(dvalue); 183 } 184 else{ 185 dvalue=INFINITY; 186 } 187 } 188 else if(exponent==1.0){ 189 /* do nothing */ 190 } 191 else if(exponent==-0.5){ 192 if(dvalue>=0){ 193 dvalue=1.0/sqrt(dvalue); 194 } 195 else{ 196 dvalue=INFINITY; 197 } 198 } 199 else if(exponent==-1.0){ 200 if(dvalue!=0.){ 201 dvalue=1.0/dvalue; 202 } 203 else{ 204 dvalue=INFINITY; 205 } 206 } 207 else { 208 dvalue=pow(dvalue,exponent); 209 } 210 value=reCast<int>(dvalue); 211 } 212 /*}}}*/ 151 213 void IntInput::Scale(IssmDouble scale_factor){/*{{{*/ 152 214 IssmDouble dvalue=(IssmDouble)value*scale_factor; -
issm/trunk-jpl/src/c/classes/Inputs/IntInput.h
r23998 r24240 1 /*! \file IntInput.h 1 /*! \file IntInput.h 2 2 * \brief: header file for triavertexinput object 3 3 */ … … 29 29 void DeepEcho(); 30 30 void Echo(); 31 int Id(); 31 int Id(); 32 32 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 33 33 int ObjectEnum(); … … 48 48 void ChangeEnum(int newenumtype); 49 49 void Extrude(int start){_error_("not supported yet");}; 50 void GetInputA llTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};50 void GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");}; 51 51 void GetInputAverage(IssmDouble* pvalue); 52 52 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");}; … … 58 58 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 59 59 void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");}; 60 void GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};60 void GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");}; 61 61 int GetInputInterpolationType(){_error_("not implemented yet!");}; 62 62 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); … … 65 65 IssmDouble Min(void){_error_("Min not implemented for integers");}; 66 66 IssmDouble MinAbs(void){_error_("Min not implemented for integers");}; 67 void PointwiseMult(Input* xinput); 68 void Pow(IssmDouble exponent); 67 69 void Scale(IssmDouble scale_factor); 68 70 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Inputs/PentaInput.cpp
r22519 r24240 126 126 TriaInput* outinput=NULL; 127 127 128 if(this->interpolation_type==P0Enum){ 128 if(this->interpolation_type==P0Enum){ 129 129 outinput=new TriaInput(this->enum_type,&this->values[0],P0Enum); 130 130 } 131 131 else{ 132 132 /*Assume P1 interpolation only for now*/ 133 IssmDouble newvalues[3]; 133 IssmDouble newvalues[3]; 134 134 135 135 /*Create array of indices depending on location (0=base 1=surface)*/ … … 319 319 } 320 320 /*}}}*/ 321 void PentaInput::PointwiseMult(Input* xinput){/*{{{*/ 322 323 const int numnodes=this->NumberofNodes(this->interpolation_type); 324 PentaInput* xpentainput=NULL; 325 326 /*If xinput is a ControlInput, take its values directly*/ 327 if(xinput->ObjectEnum()==ControlInputEnum){ 328 xinput=((ControlInput*)xinput)->values; 329 } 330 331 /*xinput is of the same type, so cast it: */ 332 if(xinput->ObjectEnum()!=PentaInputEnum) 333 _error_("Operation not permitted because xinput is of type " << EnumToStringx(xinput->ObjectEnum())); 334 xpentainput=(PentaInput*)xinput; 335 if(xpentainput->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because xinput is of type " << EnumToStringx(xpentainput->interpolation_type)); 336 337 /*Carry out the PointwiseMult operation depending on type:*/ 338 for(int i=0;i<numnodes;i++)this->values[i]=this->values[i]*xpentainput->values[i]; 339 340 } 341 /*}}}*/ 342 void PentaInput::Pow(IssmDouble exponent){/*{{{*/ 343 344 const int numnodes=this->NumberofNodes(this->interpolation_type); 345 if(exponent==0.0){ 346 /* Not-a-number left alone Infinity set to one */ 347 for(int i=0;i<numnodes;i++){ 348 if (this->values[i]==this->values[i])this->values[i]=1.0; 349 } 350 } 351 else if(exponent==0.5){ 352 for(int i=0;i<numnodes;i++){ 353 if(this->values[i]>=0){ 354 this->values[i]=sqrt(this->values[i]); 355 } 356 else{ 357 this->values[i]=INFINITY; 358 } 359 } 360 } 361 else if(exponent==1.0){ 362 /* do nothing */ 363 } 364 else if(exponent==-0.5){ 365 for(int i=0;i<numnodes;i++){ 366 if(this->values[i]>=0){ 367 this->values[i]=1.0/sqrt(this->values[i]); 368 } 369 else{ 370 this->values[i]=INFINITY; 371 } 372 } 373 } 374 else if(exponent==-1.0){ 375 for(int i=0;i<numnodes;i++){ 376 if(this->values[i]!=0.){ 377 this->values[i]=1.0/this->values[i]; 378 } 379 else{ 380 this->values[i]=INFINITY; 381 } 382 } 383 } 384 else { 385 for(int i=0;i<numnodes;i++)this->values[i]=pow(this->values[i],exponent); 386 } 387 } 388 /*}}}*/ 321 389 void PentaInput::Scale(IssmDouble scale_factor){/*{{{*/ 322 390 -
issm/trunk-jpl/src/c/classes/Inputs/PentaInput.h
r23998 r24240 1 /*! \file PentaInput.h 1 /*! \file PentaInput.h 2 2 * \brief: header file for PentaInput object 3 3 */ … … 46 46 void ChangeEnum(int newenumtype); 47 47 void Extrude(int start); 48 void GetInputA llTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};48 void GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");}; 49 49 void GetInputAverage(IssmDouble* pvalue); 50 50 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");}; … … 56 56 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 57 57 void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");}; 58 void GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};58 void GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");}; 59 59 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); 60 60 int GetInputInterpolationType(){_error_("not implemented yet!");}; … … 63 63 IssmDouble Min(void); 64 64 IssmDouble MinAbs(void); 65 void PointwiseMult(Input* xinput); 66 void Pow(IssmDouble exponent); 65 67 void Scale(IssmDouble scale_factor); 66 68 Input* SpawnTriaInput(int index1,int index2,int index3); -
issm/trunk-jpl/src/c/classes/Inputs/SegInput.h
r23998 r24240 1 /*! \file SegInput.h 1 /*! \file SegInput.h 2 2 * \brief: header file for SegInput object 3 3 */ … … 49 49 void ChangeEnum(int newenumtype){_error_("not implemented yet");}; 50 50 void Extrude(int start){_error_("not supported yet");}; 51 void GetInputA llTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");};51 void GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){_error_("not implemented yet");}; 52 52 void GetInputAverage(IssmDouble* pvalue); 53 53 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");}; … … 59 59 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 60 60 void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");}; 61 void GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");};61 void GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){_error_("not implemented yet");}; 62 62 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){_error_("not implemented yet");}; 63 63 int GetInputInterpolationType(){_error_("not implemented yet!");}; … … 66 66 IssmDouble Min(void); 67 67 IssmDouble MinAbs(void){_error_("not implemented yet");}; 68 void PointwiseMult(Input* xinput){_error_("not implemented yet");}; 69 void Pow(IssmDouble exponent){_error_("not implemented yet");}; 68 70 void Scale(IssmDouble scale_factor){_error_("not implemented yet");}; 69 71 -
issm/trunk-jpl/src/c/classes/Inputs/TetraInput.cpp
r23998 r24240 122 122 } 123 123 /*}}}*/ 124 void TetraInput::GetInputA llTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/124 void TetraInput::GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/ 125 125 126 126 IssmDouble* outvalues=NULL; … … 160 160 } 161 161 /*}}}*/ 162 void TetraInput::GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/162 void TetraInput::GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/ 163 163 164 164 IssmDouble* outvalues=NULL; … … 192 192 TriaInput* outinput=NULL; 193 193 194 if(this->interpolation_type==P0Enum){ 194 if(this->interpolation_type==P0Enum){ 195 195 outinput=new TriaInput(this->enum_type,&this->values[0],P0Enum); 196 196 } 197 197 else{ 198 198 /*Assume P1 interpolation only for now*/ 199 IssmDouble newvalues[3]; 199 IssmDouble newvalues[3]; 200 200 201 201 /*Create array of indices depending on location (0=base 1=surface)*/ … … 286 286 } 287 287 /*}}}*/ 288 void TetraInput::PointwiseMult(Input* xinput){/*{{{*/ 289 290 const int numnodes=this->NumberofNodes(this->interpolation_type); 291 TetraInput* xtetrainput=NULL; 292 293 /*xinput is of the same type, so cast it: */ 294 if(xinput->ObjectEnum()!=TetraInputEnum) _error_("Operation not permitted because xinput is of type " << EnumToStringx(xinput->ObjectEnum())); 295 xtetrainput=(TetraInput*)xinput; 296 if(xtetrainput->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because xinput is of type " << EnumToStringx(xtetrainput->interpolation_type)); 297 298 /*Carry out the PointwiseMult operation depending on type:*/ 299 for(int i=0;i<numnodes;i++)this->values[i]=this->values[i]*xtetrainput->values[i]; 300 301 } 302 /*}}}*/ 303 void TetraInput::Pow(IssmDouble exponent){/*{{{*/ 304 305 const int numnodes=this->NumberofNodes(this->interpolation_type); 306 if(exponent==0.0){ 307 /* Not-a-number left alone Infinity set to one */ 308 for(int i=0;i<numnodes;i++){ 309 if (this->values[i]==this->values[i])this->values[i]=1.0; 310 } 311 } 312 else if(exponent==0.5){ 313 for(int i=0;i<numnodes;i++){ 314 if(this->values[i]>=0){ 315 this->values[i]=sqrt(this->values[i]); 316 } 317 else{ 318 this->values[i]=INFINITY; 319 } 320 } 321 } 322 else if(exponent==1.0){ 323 /* do nothing */ 324 } 325 else if(exponent==-0.5){ 326 for(int i=0;i<numnodes;i++){ 327 if(this->values[i]>=0){ 328 this->values[i]=1.0/sqrt(this->values[i]); 329 } 330 else{ 331 this->values[i]=INFINITY; 332 } 333 } 334 } 335 else if(exponent==-1.0){ 336 for(int i=0;i<numnodes;i++){ 337 if(this->values[i]!=0.){ 338 this->values[i]=1.0/this->values[i]; 339 } 340 else{ 341 this->values[i]=INFINITY; 342 } 343 } 344 } 345 else { 346 for(int i=0;i<numnodes;i++)this->values[i]=pow(this->values[i],exponent); 347 } 348 } 349 /*}}}*/ 288 350 void TetraInput::Scale(IssmDouble scale_factor){/*{{{*/ 289 351 -
issm/trunk-jpl/src/c/classes/Inputs/TetraInput.h
r23998 r24240 1 /*! \file TetraInput.h 1 /*! \file TetraInput.h 2 2 * \brief: header file for TetraInput object 3 3 */ … … 49 49 void ChangeEnum(int newenumtype); 50 50 void Extrude(int start){_error_("not supported yet");}; 51 void GetInputA llTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);51 void GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes); 52 52 void GetInputAverage(IssmDouble* pvalue); 53 53 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");}; … … 59 59 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 60 60 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,int index){_error_("not implemented yet");}; 61 void GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime);61 void GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime); 62 62 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); 63 63 int GetInputInterpolationType(){_error_("not implemented yet!");}; … … 66 66 IssmDouble Min(void); 67 67 IssmDouble MinAbs(void); 68 void PointwiseMult(Input* xinput); 69 void Pow(IssmDouble exponent); 68 70 void Scale(IssmDouble scale_factor); 69 71 -
issm/trunk-jpl/src/c/classes/Inputs/TransientInput.cpp
r23797 r24240 60 60 } 61 61 /*}}}*/ 62 void TransientInput::AddTimeInput(Input* input,IssmDouble time){/*{{{*/ 63 64 /*insert values at time step: */ 65 if (this->numtimesteps>0 && time<=this->timesteps[this->numtimesteps-1]) _error_("timestep values must increase sequentially"); 66 67 //copy timesteps, add the new time, delete previous timesteps, and add the new input: inputs->AddObject(input); 68 IssmDouble* old_timesteps=NULL; 69 70 if (this->numtimesteps > 0){ 71 old_timesteps=xNew<IssmDouble>(this->numtimesteps); 72 xMemCpy(old_timesteps,this->timesteps,this->numtimesteps); 73 xDelete(this->timesteps); 74 } 75 76 this->numtimesteps=this->numtimesteps+1; 77 this->timesteps=xNew<IssmDouble>(this->numtimesteps); 78 79 if (this->numtimesteps > 1){ 80 xMemCpy(this->timesteps,old_timesteps,this->numtimesteps-1); 81 xDelete(old_timesteps); 82 } 83 84 /*go ahead and plug: */ 85 this->timesteps[this->numtimesteps-1]=time; 86 inputs->AddObject(input); 87 88 } 89 /*}}}*/ 90 void TransientInput::AddTimeInput(Input* input){/*{{{*/ 91 92 _assert_(this->inputs->Size()<this->numtimesteps); 93 inputs->AddObject(input); 94 95 } 96 /*}}}*/ 62 97 63 98 /*Object virtual functions definitions:*/ … … 120 155 121 156 /*TransientInput management*/ 157 void TransientInput::Configure(Parameters* parameters){/*{{{*/ 158 this->parameters=parameters; 159 } 160 /*}}}*/ 161 int TransientInput::GetResultArraySize(void){/*{{{*/ 162 163 return 1; 164 } 165 /*}}}*/ 166 int TransientInput::GetResultInterpolation(void){/*{{{*/ 167 168 IssmDouble time; 169 int output; 170 171 parameters->FindParam(&time,TimeEnum); 172 Input* input=GetTimeInput(time); 173 output = input->GetResultInterpolation(); 174 175 /*Clean up and return*/ 176 delete input; 177 return output; 178 179 } 180 /*}}}*/ 181 int TransientInput::GetResultNumberOfNodes(void){/*{{{*/ 182 183 IssmDouble time; 184 int output; 185 186 parameters->FindParam(&time,TimeEnum); 187 Input* input=GetTimeInput(time); 188 output = input->GetResultNumberOfNodes(); 189 190 /*Clean up and return*/ 191 delete input; 192 return output; 193 194 } 195 /*}}}*/ 122 196 int TransientInput::InstanceEnum(void){/*{{{*/ 123 197 … … 174 248 } 175 249 /*}}}*/ 176 void TransientInput::GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/ 250 void TransientInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/ 251 252 IssmDouble time; 253 254 /*First, recover current time from parameters: */ 255 parameters->FindParam(&time,TimeEnum); 256 257 /*Retrieve interpolated values for this time step: */ 258 Input* input=GetTimeInput(time); 259 260 /*Call input function*/ 261 input->GetInputAverage(pvalue); 262 263 delete input; 264 265 } 266 /*}}}*/ 267 void TransientInput::GetInputAverageOverTimeSlice(IssmDouble* pvalue, Gauss* gauss, IssmDouble start_time,IssmDouble end_time){/*{{{*/ 268 269 int averaging = 0; 270 271 Input* input=GetInputAverageOverTime(start_time,end_time,averaging); 272 273 /*Call input function*/ 274 input->GetInputValue(pvalue, gauss); 275 276 //*pvalues=values; 277 delete input; 278 } 279 /*}}}*/ 280 Input* TransientInput::GetInputAverageOverTime(IssmDouble start_time,IssmDouble end_time,int averaging){/*{{{*/ 281 282 int found; 283 int offset,start_offset,end_offset; 284 IssmDouble subdt,yts; 285 IssmDouble slice_duration; 286 287 IssmDouble time; 288 289 this->parameters->FindParam(&time,TimeEnum); 290 this->parameters->FindParam(&yts,ConstantsYtsEnum); 291 this->parameters->FindParam(&subdt,TimesteppingTimeStepEnum); //duration of each substeps 292 293 Input *averageinput = NULL; 294 Input *currentinput = NULL; 295 296 slice_duration=end_time-start_time; 297 start_time+=subdt; //because time is actually considered at the end of the timestep 298 299 /*go through the timesteps, and grab offset for the start of the slice*/ 300 found=binary_search(&offset,start_time,this->timesteps,this->numtimesteps); 301 if(!found) _error_("Input not found (is TransientInput sorted ?)"); 302 /*go through the timesteps, and grab offset for the end of the slice*/ 303 found=binary_search(&end_offset,end_time,this->timesteps,this->numtimesteps); 304 if(!found) _error_("Input not found (is TransientInput sorted ?)"); 305 306 start_offset = offset; 307 //stack the input for each timestep in the slice 308 while(offset <= end_offset ){ 309 if (offset==-1){ 310 /*get values for the first time: */ 311 _assert_(start_time<this->timesteps[0]); 312 currentinput=(Input*)((Input*)this->inputs->GetObjectByOffset(0))->copy(); 313 } 314 else if(offset==(this->numtimesteps-1)){ 315 /*get values for the last time: */ 316 _assert_(end_time>=this->timesteps[offset]); 317 currentinput=(Input*)((Input*)this->inputs->GetObjectByOffset(offset))->copy(); 318 } 319 else{ 320 currentinput=(Input*)((Input*)this->inputs->GetObjectByOffset(offset))->copy(); 321 } 322 switch(averaging){ 323 case 0: //Arithmetic mean 324 if (offset==start_offset){ 325 averageinput=(Input*)currentinput->copy(); 326 averageinput->Scale(subdt); 327 } 328 else{ 329 averageinput->AXPY(currentinput,subdt); 330 } 331 break; 332 case 1: //Geometric mean 333 if (offset==start_offset){ 334 averageinput=(Input*)currentinput->copy(); 335 averageinput->Scale(subdt); 336 } 337 else{ 338 currentinput->Scale(subdt); 339 averageinput->PointwiseMult(currentinput); 340 } 341 break; 342 case 2: //Harmonic mean 343 if (offset==start_offset){ 344 averageinput=(Input*)currentinput->copy(); 345 averageinput->Pow(-1); 346 averageinput->Scale(subdt); 347 } 348 else{ 349 currentinput->Pow(-1); 350 averageinput->AXPY(currentinput,subdt); 351 } 352 break; 353 default: 354 _error_("averaging method is not recognised"); 355 } 356 offset+=1; 357 } 358 359 //summation is done, now we normalise 360 switch(averaging){ 361 case 0: //Arithmetic mean 362 averageinput->Scale(1.0/slice_duration); 363 break; 364 case 1: //Geometric mean 365 averageinput->Pow(1.0/slice_duration); 366 break; 367 case 2: //Harmonic mean 368 averageinput->Scale(1.0/slice_duration); 369 averageinput->Pow(-1.0); 370 break; 371 default: 372 _error_("averaging method is not recognised"); 373 } 374 return averageinput; 375 } 376 /*}}}*/ 377 void TransientInput::GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/ 177 378 178 379 int i; … … 195 396 } 196 397 /*}}}*/ 197 void TransientInput::GetInputAverage(IssmDouble* pvalue){/*{{{*/ 198 199 IssmDouble time; 200 201 /*First, recover current time from parameters: */ 202 parameters->FindParam(&time,TimeEnum); 203 204 /*Retrieve interpolated values for this time step: */ 205 Input* input=GetTimeInput(time); 206 207 /*Call input function*/ 208 input->GetInputAverage(pvalue); 209 210 delete input; 211 212 } 213 /*}}}*/ 214 void TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/ 215 216 IssmDouble time; 217 218 /*First, recover current time from parameters: */ 219 parameters->FindParam(&time,TimeEnum); 220 221 /*Retrieve interpolated values for this time step: */ 222 Input* input=GetTimeInput(time); 223 224 /*Call input function*/ 225 input->GetInputDerivativeValue(p,xyz_list,gauss); 226 227 delete input; 228 } 229 /*}}}*/ 230 void TransientInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/ 231 IssmDouble time; 232 233 /*First, recover current time from parameters: */ 234 parameters->FindParam(&time,TimeEnum); 235 236 /*Retrieve interpolated values for this time step: */ 237 Input* input=GetTimeInput(time); 238 239 /*Call input function*/ 240 input->GetInputValue(pvalue,gauss); 241 242 delete input; 243 } 244 /*}}}*/ 245 void TransientInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){/*{{{*/ 246 247 /*Retrieve interpolated values for this time step: */ 248 Input* input=GetTimeInput(time); 249 250 /*Call input function*/ 251 input->GetInputValue(pvalue,gauss); 252 253 delete input; 254 } 255 /*}}}*/ 256 int TransientInput::GetTimeInputOffset(IssmDouble time){/*{{{*/ 257 258 int offset; 259 260 /*go through the timesteps, and figure out which interval we 261 * *fall within. Then interpolate the values on this interval: */ 262 int found=binary_search(&offset,time,this->timesteps,this->numtimesteps); 263 if(!found) _error_("Input not found (is TransientInput sorted ?)"); 264 265 return offset; 266 } 267 /*}}}*/ 268 IssmDouble TransientInput::GetTimeByOffset(int offset){/*{{{*/ 269 if (offset < 0) offset=0; 270 _assert_(offset<(this->numtimesteps)); 271 return this->timesteps[offset]; 272 } 273 /*}}}*/ 274 void TransientInput::GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/ 398 void TransientInput::GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/ 275 399 276 400 int i; … … 312 436 } 313 437 /*}}}*/ 314 438 void TransientInput::GetInputDerivativeValue(IssmDouble* p, IssmDouble* xyz_list, Gauss* gauss){/*{{{*/ 439 440 IssmDouble time; 441 442 /*First, recover current time from parameters: */ 443 parameters->FindParam(&time,TimeEnum); 444 445 /*Retrieve interpolated values for this time step: */ 446 Input* input=GetTimeInput(time); 447 448 /*Call input function*/ 449 input->GetInputDerivativeValue(p,xyz_list,gauss); 450 451 delete input; 452 } 453 /*}}}*/ 454 void TransientInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){/*{{{*/ 455 IssmDouble time; 456 457 /*First, recover current time from parameters: */ 458 parameters->FindParam(&time,TimeEnum); 459 460 /*Retrieve interpolated values for this time step: */ 461 Input* input=GetTimeInput(time); 462 463 /*Call input function*/ 464 input->GetInputValue(pvalue,gauss); 465 466 delete input; 467 } 468 /*}}}*/ 469 void TransientInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){/*{{{*/ 470 471 /*Retrieve interpolated values for this time step: */ 472 Input* input=GetTimeInput(time); 473 474 /*Call input function*/ 475 input->GetInputValue(pvalue,gauss); 476 477 delete input; 478 } 479 /*}}}*/ 480 IssmDouble TransientInput::GetTimeByOffset(int offset){/*{{{*/ 481 if (offset < 0) offset=0; 482 _assert_(offset<(this->numtimesteps)); 483 return this->timesteps[offset]; 484 } 485 /*}}}*/ 486 int TransientInput::GetTimeInputOffset(IssmDouble time){/*{{{*/ 487 488 int offset; 489 490 /*go through the timesteps, and figure out which interval we 491 * *fall within. Then interpolate the values on this interval: */ 492 int found=binary_search(&offset,time,this->timesteps,this->numtimesteps); 493 if(!found) _error_("Input not found (is TransientInput sorted ?)"); 494 495 return offset; 496 } 497 /*}}}*/ 315 498 /*Intermediary*/ 316 void TransientInput::AddTimeInput(Input* input,IssmDouble time){/*{{{*/317 318 /*insert values at time step: */319 if (this->numtimesteps>0 && time<=this->timesteps[this->numtimesteps-1]) _error_("timestep values must increase sequentially");320 321 //copy timesteps, add the new time, delete previous timesteps, and add the new input: inputs->AddObject(input);322 IssmDouble* old_timesteps=NULL;323 324 if (this->numtimesteps > 0){325 old_timesteps=xNew<IssmDouble>(this->numtimesteps);326 xMemCpy(old_timesteps,this->timesteps,this->numtimesteps);327 xDelete(this->timesteps);328 }329 330 this->numtimesteps=this->numtimesteps+1;331 this->timesteps=xNew<IssmDouble>(this->numtimesteps);332 333 if (this->numtimesteps > 1){334 xMemCpy(this->timesteps,old_timesteps,this->numtimesteps-1);335 xDelete(old_timesteps);336 }337 338 /*go ahead and plug: */339 this->timesteps[this->numtimesteps-1]=time;340 inputs->AddObject(input);341 342 }343 /*}}}*/344 void TransientInput::AddTimeInput(Input* input){/*{{{*/345 346 _assert_(this->inputs->Size()<this->numtimesteps);347 inputs->AddObject(input);348 349 }350 /*}}}*/351 void TransientInput::Configure(Parameters* parameters){/*{{{*/352 this->parameters=parameters;353 }354 /*}}}*/355 499 void TransientInput::Extrude(int start){/*{{{*/ 356 500 … … 358 502 ((Input*)this->inputs->GetObjectByOffset(i))->Extrude(start); 359 503 } 360 }361 /*}}}*/362 int TransientInput::GetResultArraySize(void){/*{{{*/363 364 return 1;365 }366 /*}}}*/367 int TransientInput::GetResultInterpolation(void){/*{{{*/368 369 IssmDouble time;370 int output;371 372 parameters->FindParam(&time,TimeEnum);373 Input* input=GetTimeInput(time);374 output = input->GetResultInterpolation();375 376 /*Clean up and return*/377 delete input;378 return output;379 380 }381 /*}}}*/382 int TransientInput::GetResultNumberOfNodes(void){/*{{{*/383 384 IssmDouble time;385 int output;386 387 parameters->FindParam(&time,TimeEnum);388 Input* input=GetTimeInput(time);389 output = input->GetResultNumberOfNodes();390 391 /*Clean up and return*/392 delete input;393 return output;394 395 504 } 396 505 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Inputs/TransientInput.h
r23998 r24240 44 44 int GetResultInterpolation(void); 45 45 int GetResultNumberOfNodes(void); 46 int 46 int InstanceEnum(); 47 47 void ResultToPatch(IssmDouble* values,int nodesperelement,int sid){_error_("not supported yet");}; 48 48 Input* SpawnSegInput(int index1,int index2); 49 49 Input* SpawnTriaInput(int index1,int index2,int index3); 50 50 /*}}}*/ 51 /* numerics: {{{*/51 /*Object Functions: {{{*/ 52 52 void AXPY(Input* xforcing,IssmDouble scalar){_error_("not implemented yet");}; 53 53 void ChangeEnum(int newenumtype); 54 void Extrude(int start);55 void GetInputAllTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);56 54 void GetInputAverage(IssmDouble* pvalue); 55 void GetInputAverageOverTimeSlice(IssmDouble* pvalue, Gauss* gauss, IssmDouble init_time, IssmDouble end_time); 56 Input* GetInputAverageOverTime(IssmDouble start_time,IssmDouble end_time,int averaging); 57 void GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes); 58 void GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime); 57 59 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list){_error_("not implemented yet");}; 58 60 void GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list,Gauss* gauss); 61 int GetInputInterpolationType(){_error_("not implemented yet!");}; 62 void GetTimeValues(IssmDouble* values,IssmDouble time){_error_("not implemented yet");}; 59 63 void GetInputValue(bool* pvalue){_error_("not implemented yet");}; 60 64 void GetInputValue(int* pvalue){_error_("not implemented yet");}; … … 63 67 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time); 64 68 void GetInputValue(IssmDouble* pvalue,Gauss* gauss ,int index){_error_("not implemented yet");}; 65 void GetInputUpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime);66 int GetInputInterpolationType(){_error_("not implemented yet!");};67 69 IssmDouble GetTimeByOffset(int offset); 70 int GetTimeInputOffset(IssmDouble time); 71 void PointwiseMult(Input* xforcing){_error_("not implemented yet");}; 72 void Pow(IssmDouble exponent){_error_("not implemented yet");}; 73 void Scale(IssmDouble scale_factor){_error_("not implemented yet");}; 74 /*}}}*/ 75 /*Intermiadaries: {{{*/ 76 void Extrude(int start); 68 77 Input* GetTimeInput(IssmDouble time); 69 int GetTimeInputOffset(IssmDouble time);70 void GetTimeValues(IssmDouble* values,IssmDouble time){_error_("not implemented yet");};71 78 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); 72 79 IssmDouble Max(void); … … 74 81 IssmDouble Min(void); 75 82 IssmDouble MinAbs(void); 76 void Scale(IssmDouble scale_factor){_error_("not implemented yet");};77 83 /*}}}*/ 78 84 -
issm/trunk-jpl/src/c/classes/Inputs/TriaInput.cpp
r24091 r24240 126 126 SegInput* outinput=NULL; 127 127 128 if(this->interpolation_type==P0Enum){ 128 if(this->interpolation_type==P0Enum){ 129 129 outinput=new SegInput(this->enum_type,&this->values[0],P0Enum); 130 130 } … … 165 165 } 166 166 /*}}}*/ 167 void TriaInput::GetInputA llTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/167 void TriaInput::GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes){/*{{{*/ 168 168 169 169 IssmDouble* outvalues=NULL; … … 224 224 /*}}}*/ 225 225 226 void TriaInput::GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/226 void TriaInput::GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime){/*{{{*/ 227 227 228 228 IssmDouble* outvalues=NULL; … … 320 320 } 321 321 /*}}}*/ 322 void TriaInput::PointwiseMult(Input* xinput){/*{{{*/ 323 324 const int numnodes=this->NumberofNodes(this->interpolation_type); 325 TriaInput* xtriainput=NULL; 326 327 328 /*xinput is of the same type, so cast it: */ 329 if(xinput->ObjectEnum()!=TriaInputEnum) _error_("Operation not permitted because xinput is of type " << EnumToStringx(xinput->ObjectEnum())); 330 xtriainput=(TriaInput*)xinput; 331 if(xtriainput->interpolation_type!=this->interpolation_type) _error_("Operation not permitted because xinput is of type " << EnumToStringx(xtriainput->interpolation_type)); 332 333 /*Carry out the PointwiseMult operation depending on type:*/ 334 for(int i=0;i<numnodes;i++)this->values[i]=this->values[i]*xtriainput->values[i]; 335 336 } 337 /*}}}*/ 338 void TriaInput::Pow(IssmDouble exponent){/*{{{*/ 339 340 const int numnodes=this->NumberofNodes(this->interpolation_type); 341 if(exponent==0.0){ 342 /* Not-a-number left alone Infinity set to one */ 343 for(int i=0;i<numnodes;i++){ 344 if (this->values[i]==this->values[i])this->values[i]=1.0; 345 } 346 } 347 else if(exponent==0.5){ 348 for(int i=0;i<numnodes;i++){ 349 if(this->values[i]>=0){ 350 this->values[i]=sqrt(this->values[i]); 351 } 352 else{ 353 this->values[i]=INFINITY; 354 } 355 } 356 } 357 else if(exponent==1.0){ 358 /* do nothing */ 359 } 360 else if(exponent==-0.5){ 361 for(int i=0;i<numnodes;i++){ 362 if(this->values[i]>=0){ 363 this->values[i]=1.0/sqrt(this->values[i]); 364 } 365 else{ 366 this->values[i]=INFINITY; 367 } 368 } 369 } 370 else if(exponent==-1.0){ 371 for(int i=0;i<numnodes;i++){ 372 if(this->values[i]!=0.){ 373 this->values[i]=1.0/this->values[i]; 374 } 375 else{ 376 this->values[i]=INFINITY; 377 } 378 } 379 } 380 else { 381 for(int i=0;i<numnodes;i++)this->values[i]=pow(this->values[i],exponent); 382 } 383 } 384 /*}}}*/ 322 385 void TriaInput::Scale(IssmDouble scale_factor){/*{{{*/ 323 386 -
issm/trunk-jpl/src/c/classes/Inputs/TriaInput.h
r23998 r24240 1 /*! \file TriaInput.h 1 /*! \file TriaInput.h 2 2 * \brief: header file for TriaInput object 3 3 */ … … 49 49 void ChangeEnum(int newenumtype); 50 50 void Extrude(int start){_error_("not supported yet");}; 51 void GetInputA llTimeAverages(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes);51 void GetInputAveragesOnAllTime(IssmDouble** pvalues,IssmDouble** ptimes, int* pnumtimes); 52 52 void GetInputAverage(IssmDouble* pvalue); 53 53 void GetInputDerivativeAverageValue(IssmDouble* derivativevalues, IssmDouble* xyz_list); … … 59 59 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,IssmDouble time){_error_("not implemented yet");}; 60 60 void GetInputValue(IssmDouble* pvalue,Gauss* gauss,int index){_error_("not implemented yet");}; 61 void GetInput UpToCurrentTimeAverages(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime);61 void GetInputAveragesUpToCurrentTime(IssmDouble** pvalues, IssmDouble** ptimes, int* pnumtimes, IssmDouble currenttime); 62 62 int GetInputInterpolationType(){return interpolation_type;}; 63 63 void GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist); … … 66 66 IssmDouble Min(void); 67 67 IssmDouble MinAbs(void); 68 void PointwiseMult(Input* xinput); 69 void Pow(IssmDouble exponent); 68 70 void Scale(IssmDouble scale_factor); 69 71 -
issm/trunk-jpl/src/c/classes/IoModel.cpp
r24066 r24240 953 953 /*recover my_rank:*/ 954 954 int my_rank=IssmComm::GetRank(); 955 956 955 /*Set file pointer to beginning of the data: */ 957 956 fid=this->SetFilePointerToData(&code,NULL,data_name); -
issm/trunk-jpl/src/c/classes/Loads/Pengrid.cpp
r23959 r24240 381 381 /*Get sediment water head h*/ 382 382 inefanalysis = new HydrologyDCInefficientAnalysis(); 383 element->GetInputValue(&h,node,SedimentHead HydrostepEnum);383 element->GetInputValue(&h,node,SedimentHeadSubstepEnum); 384 384 inefanalysis->GetHydrologyDCInefficientHmax(&h_max,element,node); 385 385 parameters->FindParam(&penalty_lock,HydrologydcPenaltyLockEnum); -
issm/trunk-jpl/src/c/classes/Params/Parameters.cpp
r24152 r24240 467 467 /*first, figure out if the param has already been created: */ 468 468 param=xDynamicCast<Param*>(this->FindParamObject(enum_type)); 469 470 469 if(param) param->SetValue(scalar); //already exists, just set it. 471 470 else this->AddObject(new DoubleParam(enum_type,scalar)); //just add the new parameter. -
issm/trunk-jpl/src/c/cores/bedslope_core.cpp
r17700 r24240 1 1 /*!\file: bedslope_core.cpp 2 * \brief: core of the slope solution 3 */ 2 * \brief: core of the slope solution 3 */ 4 4 5 5 #include "./cores.h" … … 34 34 35 35 if(save_results){ 36 if(VerboseSolution()) _printf0_(" saving results\n");36 if(VerboseSolution()) _printf0_(" saving bedslopes results\n"); 37 37 if(domaintype!=Domain2DverticalEnum){ 38 38 int outputs[2] = {BedSlopeXEnum,BedSlopeYEnum}; -
issm/trunk-jpl/src/c/cores/damage_core.cpp
r23232 r24240 1 /* 1 /* 2 2 * \brief: damage_core.cpp: core for the damage solution 3 */ 3 */ 4 4 5 5 #include "./cores.h" … … 11 11 12 12 void damage_core(FemModel* femmodel){ 13 13 14 14 /*Start profiler*/ 15 15 femmodel->profiler->Start(DAMAGECORE); 16 16 17 17 /*intermediary*/ 18 18 bool save_results; 19 19 bool dakota_analysis = false; 20 20 int solution_type,stabilization; 21 int numoutputs = 0; 21 int numoutputs = 0; 22 22 char **requested_outputs = NULL; 23 23 … … 40 40 41 41 if(save_results){ 42 if(VerboseSolution()) _printf0_(" saving results\n");42 if(VerboseSolution()) _printf0_(" saving damage results\n"); 43 43 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs); 44 44 } 45 45 46 /*Free resources:*/ 46 /*Free resources:*/ 47 47 if(numoutputs){ 48 48 for(int i=0;i<numoutputs;i++){ 49 49 xDelete<char>(requested_outputs[i]); 50 } 50 } 51 51 xDelete<char*>(requested_outputs); 52 52 } 53 53 54 54 /*End profiler*/ 55 55 femmodel->profiler->Stop(DAMAGECORE); -
issm/trunk-jpl/src/c/cores/hydrology_core.cpp
r24080 r24240 19 19 int solution_type; 20 20 int numoutputs = 0; 21 int smboutputs;22 21 bool save_results; 23 22 bool modify_loads = true; 24 bool issmb;25 23 char **requested_outputs = NULL; 26 char **requested_smb_outputs = NULL;27 24 IssmDouble ThawedNodes; 28 25 … … 33 30 femmodel->parameters->FindParam(&numoutputs,HydrologyNumRequestedOutputsEnum); 34 31 if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,HydrologyRequestedOutputsEnum); 35 femmodel->parameters->FindParam(&issmb,TransientIssmbEnum);36 32 37 33 /*Using the Shreve based Model*/ … … 54 50 /*intermediary: */ 55 51 bool isefficientlayer; 56 int hydrostep,hydroslices,numaveragedinput;57 IssmDouble time,hydrotime,yts;58 IssmDouble dt,hydrodt;59 /*SMB related */60 int smb_model;61 62 52 /*recover parameters: */ 63 53 femmodel->parameters->FindParam(&isefficientlayer,HydrologydcIsefficientlayerEnum); 64 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum);65 femmodel->parameters->FindParam(&time,TimeEnum);66 femmodel->parameters->FindParam(&hydroslices,HydrologyStepsPerStepEnum);67 femmodel->parameters->FindParam(&yts,ConstantsYtsEnum);68 69 /*recover SMB related parameters: */70 if(issmb){71 femmodel->parameters->FindParam(&smb_model,SmbEnum);72 femmodel->parameters->FindParam(&smboutputs,SmbNumRequestedOutputsEnum);73 if(smboutputs) femmodel->parameters->FindParam(&requested_smb_outputs,&smboutputs,SmbRequestedOutputsEnum);74 }75 54 76 55 /*first we exclude frozen nodes of the solved nodes*/ … … 79 58 80 59 if(ThawedNodes>0){ 81 hydrotime=time-dt; //getting the time back to the start of the timestep 82 hydrodt=dt/hydroslices; //computing hydro dt from dt and a divider 83 hydrostep=0; 84 femmodel->parameters->AddObject(new DoubleParam(HydrologydtEnum,hydrodt)); 85 86 if(hydroslices>1){ 60 /*check if we need sub steps*/ 61 int dtslices; 62 femmodel->parameters->FindParam(&dtslices,HydrologyStepsPerStepEnum); 63 64 if(dtslices>1){ 65 int substep, numaveragedinput; 66 IssmDouble global_time, subtime, yts; 67 IssmDouble dt, subdt; 68 69 femmodel->parameters->FindParam(&global_time,TimeEnum); 70 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 71 femmodel->parameters->FindParam(&yts,ConstantsYtsEnum); 72 73 subtime=global_time-dt; //getting the time back to the start of the timestep 74 subdt=dt/dtslices; //computing hydro dt from dt and a divider 75 substep=0; 76 femmodel->parameters->SetParam(subdt,TimesteppingTimeStepEnum); 77 78 /*intermiedaries to deal with averaging*/ 79 static const int substeplist[4] = {EffectivePressureSubstepEnum,SedimentHeadSubstepEnum,EplHeadSubstepEnum,HydrologydcEplThicknessSubstepEnum}; 80 static const int transientlist[4] = {EffectivePressureTransientEnum,SedimentHeadTransientEnum,EplHeadTransientEnum,HydrologydcEplThicknessTransientEnum}; 81 static const int averagelist[4] = {EffectivePressureEnum,SedimentHeadEnum,EplHeadEnum,HydrologydcEplThicknessEnum}; 82 std::vector<int> substepinput; 83 std::vector<int> transientinput; 84 std::vector<int> averagedinput; 85 87 86 if (isefficientlayer){ 88 87 /*define which variable needs to be averaged on the sub-timestep and initialize as needed*/ 89 88 numaveragedinput = 4; 90 int inputtostack[4] = {EffectivePressureHydrostepEnum,SedimentHeadHydrostepEnum,EplHeadHydrostepEnum,HydrologydcEplThicknessHydrostepEnum}; 91 int stackedinput[4] = {EffectivePressureStackedEnum,SedimentHeadStackedEnum,EplHeadStackedEnum,HydrologydcEplThicknessStackedEnum}; 92 int averagedinput[4] = {EffectivePressureEnum,SedimentHeadEnum,EplHeadEnum,HydrologydcEplThicknessEnum}; 93 femmodel->InitMeanOutputx(&stackedinput[0],numaveragedinput); 94 95 //while(hydrotime<time-(yts*DBL_EPSILON)){ //loop on hydro dts 96 while(hydrostep<hydroslices){ //loop on hydro dts 97 hydrostep+=1; 98 hydrotime+=hydrodt; 99 /*Setting substep time as global time*/ 100 femmodel->parameters->SetParam(hydrotime,TimeEnum); 101 if(VerboseSolution()) _printf0_("sub iteration " << hydrostep << "/" << hydroslices << " time [yr]: " << setprecision(4) << hydrotime/yts << " (time step: " << hydrodt/yts << ")\n"); 102 if(issmb){ 103 if(VerboseSolution()) _printf0_(" computing mass balance\n"); 104 SmbAnalysis* analysis = new SmbAnalysis(); 105 analysis->Core(femmodel); 106 delete analysis; 107 } 108 if(VerboseSolution()) _printf0_(" computing water heads\n"); 109 /*save preceding timestep*/ 110 InputDuplicatex(femmodel,SedimentHeadHydrostepEnum,SedimentHeadOldEnum); 111 InputDuplicatex(femmodel,EplHeadHydrostepEnum,EplHeadOldEnum); 112 InputDuplicatex(femmodel,HydrologydcEplThicknessHydrostepEnum,HydrologydcEplThicknessOldEnum); 113 /*Proceed now to heads computations*/ 114 solutionsequence_hydro_nonlinear(femmodel); 115 /*If we have a sub-timestep we stack the variables here*/ 116 femmodel->SumOutputx(&inputtostack[0],&stackedinput[0],numaveragedinput); 89 substepinput.assign(substeplist,substeplist+4); 90 transientinput.assign(transientlist,transientlist+4); 91 averagedinput.assign(averagelist,averagelist+4); 92 } 93 else{ 94 numaveragedinput = 2; 95 substepinput.assign(substeplist,substeplist+2); 96 transientinput.assign(transientlist,transientlist+2); 97 averagedinput.assign(averagelist,averagelist+2); 98 } 99 femmodel->InitTransientOutputx(&transientinput[0],numaveragedinput); 100 while(substep<dtslices){ //loop on hydro dts 101 substep+=1; 102 subtime+=subdt; 103 /*Setting substep time as global time*/ 104 femmodel->parameters->SetParam(subtime,TimeEnum); 105 if(VerboseSolution()) _printf0_("sub iteration " << substep << "/" << dtslices << " time [yr]: " << setprecision(4) << subtime/yts << " (time step: " << subdt/yts << ")\n"); 106 if(VerboseSolution()) _printf0_(" computing water heads\n"); 107 /*save preceding timestep*/ 108 InputDuplicatex(femmodel,SedimentHeadSubstepEnum,SedimentHeadOldEnum); 109 if (isefficientlayer){ 110 InputDuplicatex(femmodel,EplHeadSubstepEnum,EplHeadOldEnum); 111 InputDuplicatex(femmodel,HydrologydcEplThicknessSubstepEnum,HydrologydcEplThicknessOldEnum); 117 112 } 118 /*Reseting to global time*/ 119 femmodel->parameters->SetParam(time,TimeEnum); 120 femmodel->AverageSumOutputx(&stackedinput[0],&averagedinput[0],numaveragedinput); 121 } 122 else{ 123 /*define which variable needs to be averaged on the sub-timestep and initialize as needed*/ 124 numaveragedinput = 2; 125 int inputtostack[2] = {EffectivePressureHydrostepEnum,SedimentHeadHydrostepEnum}; 126 int stackedinput[2] = {EffectivePressureStackedEnum,SedimentHeadStackedEnum}; 127 int averagedinput[2] = {EffectivePressureEnum,SedimentHeadEnum}; 128 femmodel->InitMeanOutputx(&stackedinput[0],numaveragedinput); 129 while(hydrotime<time-(yts*DBL_EPSILON)){ //loop on hydro dts 130 hydrostep+=1; 131 hydrotime+=hydrodt; 132 /*Setting substep time as global time*/ 133 femmodel->parameters->SetParam(hydrotime,TimeEnum); 134 if(VerboseSolution()) _printf0_("sub iteration " << hydrostep << "/" << hydroslices << " time [yr]: " << setprecision(4) << hydrotime/yts << " (time step: " << hydrodt/yts << ")\n"); 135 if(issmb){ 136 if(VerboseSolution()) _printf0_(" computing mass balance\n"); 137 SmbAnalysis* analysis = new SmbAnalysis(); 138 analysis->Core(femmodel); 139 delete analysis; 140 } 141 if(VerboseSolution()) _printf0_(" computing water heads\n"); 142 /*save preceding timestep*/ 143 InputDuplicatex(femmodel,SedimentHeadHydrostepEnum,SedimentHeadOldEnum); 144 /*Proceed now to heads computations*/ 145 solutionsequence_hydro_nonlinear(femmodel); 146 /*If we have a sub-timestep we stack the variables here*/ 147 femmodel->SumOutputx(&inputtostack[0],&stackedinput[0],numaveragedinput); 148 } 149 /*Reseting to global time*/ 150 femmodel->parameters->SetParam(time,TimeEnum); 151 femmodel->AverageSumOutputx(&stackedinput[0],&averagedinput[0],numaveragedinput); 152 } 113 /*Proceed now to heads computations*/ 114 solutionsequence_hydro_nonlinear(femmodel); 115 /*If we have a sub-timestep we store the substep inputs in a transient input here*/ 116 femmodel->StackTransientOutputx(&substepinput[0],&transientinput[0],subtime,numaveragedinput); 117 } 118 /*averaging the stack*/ 119 femmodel->AverageTransientOutputx(&transientinput[0],&averagedinput[0],global_time-dt,subtime,numaveragedinput); 120 121 /*And reseting to global time*/ 122 femmodel->parameters->SetParam(dt,TimesteppingTimeStepEnum); 123 femmodel->parameters->SetParam(global_time,TimeEnum); 153 124 } 154 125 else{ 155 if(issmb){ 156 if(VerboseSolution()) _printf0_(" computing mass balance\n"); 157 SmbAnalysis* analysis = new SmbAnalysis(); 158 analysis->Core(femmodel); 159 delete analysis; 160 } 161 InputDuplicatex(femmodel,SedimentHeadHydrostepEnum,SedimentHeadOldEnum); 126 InputDuplicatex(femmodel,SedimentHeadSubstepEnum,SedimentHeadOldEnum); 162 127 if (isefficientlayer){ 163 InputDuplicatex(femmodel,EplHead HydrostepEnum,EplHeadOldEnum);164 InputDuplicatex(femmodel,HydrologydcEplThickness HydrostepEnum,HydrologydcEplThicknessOldEnum);128 InputDuplicatex(femmodel,EplHeadSubstepEnum,EplHeadOldEnum); 129 InputDuplicatex(femmodel,HydrologydcEplThicknessSubstepEnum,HydrologydcEplThicknessOldEnum); 165 130 } 166 131 /*Proceed now to heads computations*/ 167 132 if(VerboseSolution()) _printf0_(" computing water heads\n"); 168 133 solutionsequence_hydro_nonlinear(femmodel); 134 /*If no substeps are present we want to duplicate the results for coupling purposes*/ 135 InputDuplicatex(femmodel,SedimentHeadSubstepEnum,SedimentHeadEnum); 136 InputDuplicatex(femmodel,EffectivePressureSubstepEnum,EffectivePressureEnum); 137 if (isefficientlayer){ 138 InputDuplicatex(femmodel,EplHeadSubstepEnum,EplHeadEnum); 139 InputDuplicatex(femmodel,HydrologydcEplThicknessSubstepEnum,HydrologydcEplThicknessEnum); 140 } 169 141 } 170 142 } 171 else{ 172 /* If everything is frozen we still need smb */ 173 if(issmb){ 174 if(VerboseSolution()) _printf0_(" computing mass balance\n"); 175 SmbAnalysis* analysis = new SmbAnalysis(); 176 analysis->Core(femmodel); 177 delete analysis; 178 } 179 } 143 if(VerboseSolution()) printf(" hydroDC done\n"); 180 144 } 181 145 … … 221 185 } 222 186 if(save_results){ 223 if(VerboseSolution()) _printf0_(" saving results \n");187 if(VerboseSolution()) _printf0_(" saving hydrology results \n"); 224 188 if(hydrology_model==HydrologydcEnum && ThawedNodes==0){ 225 189 if(VerboseSolution()) _printf0_(" No thawed node hydro is skiped \n");} 226 else if (hydrology_model==HydrologydcEnum && issmb){227 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs);228 femmodel->RequestedOutputsx(&femmodel->results,requested_smb_outputs,smboutputs);229 }230 190 else{ 231 191 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs); … … 239 199 xDelete<char*>(requested_outputs); 240 200 } 241 if(issmb){242 if(smboutputs){243 for(int i=0;i<smboutputs;i++){244 xDelete<char>(requested_smb_outputs[i]);245 }246 xDelete<char*>(requested_smb_outputs);247 }248 }249 201 /*End profiler*/ 250 202 femmodel->profiler->Stop(HYDROLOGYCORE); -
issm/trunk-jpl/src/c/cores/smb_core.cpp
r23232 r24240 1 1 /*!\file: smb_core.cpp 2 * \brief: core of the smb solution 3 */ 2 * \brief: core of the smb solution 3 */ 4 4 5 5 #include "./cores.h" … … 11 11 12 12 void smb_core(FemModel* femmodel){ 13 13 14 14 /*Start profiler*/ 15 15 femmodel->profiler->Start(SMBCORE); 16 16 17 17 /*parameters: */ 18 18 Analysis* analysis=NULL; … … 33 33 if(numoutputs) femmodel->parameters->FindParam(&requested_outputs,&numoutputs,SmbRequestedOutputsEnum); 34 34 35 if(VerboseSolution()) _printf0_(" computing smb \n"); 35 /*sub steping specifics*/ 36 int dtslices; 37 int numaveragedinput; 38 femmodel->parameters->FindParam(&dtslices,SmbStepsPerStepEnum); 39 /*intermiedaries to deal with averaging*/ 40 static const int substeplist[2] = {SmbMassBalanceSubstepEnum,SmbRunoffSubstepEnum}; 41 static const int transientlist[2] = {SmbMassBalanceTransientEnum,SmbRunoffTransientEnum}; 42 static const int averagelist[2] = {SmbMassBalanceEnum,SmbRunoffEnum}; 43 std::vector<int> substepinput; 44 std::vector<int> transientinput; 45 std::vector<int> averagedinput; 36 46 37 analysis = new SmbAnalysis(); 38 analysis->Core(femmodel); 39 delete analysis; 47 /*define which variable needs to be averaged on the sub-timestep and initialize as needed*/ 48 if(smb_model==SMBgradientscomponentsEnum){ 49 numaveragedinput = 2; 50 substepinput.assign(substeplist,substeplist+2); 51 transientinput.assign(transientlist,transientlist+2); 52 averagedinput.assign(averagelist,averagelist+2); 53 } 54 55 /*if yes compute necessary intermiedaries and start looping*/ 56 if (dtslices>1){ 57 int substep; 58 IssmDouble global_time,subtime,yts; 59 IssmDouble dt,subdt; 60 61 femmodel->parameters->FindParam(&global_time,TimeEnum); 62 femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum); 63 femmodel->parameters->FindParam(&yts,ConstantsYtsEnum); 64 65 subtime=global_time-dt; //getting the time back to the start of the timestep 66 subdt=dt/dtslices; //computing substep from dt and a divider 67 substep=0; 68 femmodel->parameters->SetParam(subdt,TimesteppingTimeStepEnum); 69 70 femmodel->InitTransientOutputx(&transientinput[0],numaveragedinput); 71 while(substep<dtslices){ //loop on sub dts 72 substep+=1; 73 subtime+=subdt; 74 femmodel->parameters->SetParam(subtime,TimeEnum); 75 if(VerboseSolution()) _printf0_("sub iteration " << substep << "/" << dtslices << " time [yr]: " << setprecision(4) << subtime/yts << " (time step: " << subdt/yts << ")\n"); 76 if(VerboseSolution()) _printf0_(" computing smb\n"); 77 analysis = new SmbAnalysis(); 78 if(VerboseSolution()) _printf0_(" Calling core\n"); 79 analysis->Core(femmodel); 80 /*If we have a sub-timestep we store the substep inputs in a transient input here*/ 81 femmodel->StackTransientOutputx(&substepinput[0],&transientinput[0],subtime,numaveragedinput); 82 delete analysis; 83 } 84 /*averaging the transient input*/ 85 femmodel->AverageTransientOutputx(&transientinput[0],&averagedinput[0],global_time-dt,subtime,numaveragedinput); 86 /*and reset timesteping variables to original*/ 87 femmodel->parameters->SetParam(global_time,TimeEnum); 88 femmodel->parameters->SetParam(dt,TimesteppingTimeStepEnum); 89 } 90 else{ 91 if(VerboseSolution()) _printf0_(" computing smb \n"); 92 analysis = new SmbAnalysis(); 93 analysis->Core(femmodel); 94 /*If no substeps are present we want to duplicate the computed substep enum for coupling purposes*/ 95 if(smb_model==SMBgradientscomponentsEnum){ 96 for(int i=0;i<numaveragedinput;i++){ 97 InputDuplicatex(femmodel,substepinput[i],averagedinput[i]); 98 } 99 } 100 delete analysis; 101 } 40 102 41 103 if(save_results){ 42 if(VerboseSolution()) _printf0_(" saving results\n");104 if(VerboseSolution()) _printf0_(" saving smb results\n"); 43 105 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs); 44 106 } -
issm/trunk-jpl/src/c/cores/stressbalance_core.cpp
r23484 r24240 1 1 /*!\file: stressbalance_core.cpp 2 * \brief: core of the stressbalance solution 3 */ 2 * \brief: core of the stressbalance solution 3 */ 4 4 5 5 #include "./cores.h" … … 91 91 92 92 if(save_results){ 93 if(VerboseSolution()) _printf0_(" saving results\n");93 if(VerboseSolution()) _printf0_(" saving stressbalance results\n"); 94 94 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs); 95 if(VerboseSolution()) _printf0_(" results saved\n"); 95 96 } 96 97 97 98 if(solution_type==StressbalanceSolutionEnum && !control_analysis)femmodel->RequestedDependentsx(); 98 99 99 /*Free ressources:*/ 100 /*Free ressources:*/ 100 101 if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);} 101 102 -
issm/trunk-jpl/src/c/cores/surfaceslope_core.cpp
r17700 r24240 1 1 /*!\file: surfaceslope_core.cpp 2 * \brief: core of the slope solution 3 */ 2 * \brief: core of the slope solution 3 */ 4 4 5 5 #include "./cores.h" … … 38 38 39 39 if(save_results){ 40 if(VerboseSolution()) _printf0_("saving results:\n");40 if(VerboseSolution()) _printf0_("saving surface slopes results:\n"); 41 41 if(domaintype!=Domain2DverticalEnum){ 42 42 int outputs[2] = {SurfaceSlopeXEnum,SurfaceSlopeYEnum}; -
issm/trunk-jpl/src/c/cores/thermal_core.cpp
r23228 r24240 1 1 /*!\file: thermal_core.cpp 2 * \brief: core of the thermal solution 3 */ 2 * \brief: core of the thermal solution 3 */ 4 4 5 5 #include "./cores.h" … … 12 12 13 13 void thermal_core(FemModel* femmodel){ 14 14 15 15 /*Start profiler*/ 16 16 femmodel->profiler->Start(THERMALCORE); 17 17 18 18 /*intermediary*/ 19 19 bool save_results,isenthalpy; … … 49 49 50 50 if(save_results){ 51 if(VerboseSolution()) _printf0_(" saving results\n");51 if(VerboseSolution()) _printf0_(" saving thermal results\n"); 52 52 femmodel->RequestedOutputsx(&femmodel->results,requested_outputs,numoutputs); 53 53 } 54 54 55 /*Free ressources:*/ 55 /*Free ressources:*/ 56 56 if(numoutputs){for(int i=0;i<numoutputs;i++){xDelete<char>(requested_outputs[i]);} xDelete<char*>(requested_outputs);} 57 57 58 58 /*End profiler*/ 59 59 femmodel->profiler->Stop(THERMALCORE); -
issm/trunk-jpl/src/c/cores/transient_core.cpp
r23717 r24240 151 151 } 152 152 /* Using Hydrology dc coupled we need to compute smb in the hydrology inner time loop*/ 153 if(issmb) { 154 if(VerboseSolution()) _printf0_(" computing smb\n"); 155 smb_core(femmodel); 156 } 157 153 158 if(ishydrology){ 159 if(VerboseSolution()) _printf0_(" computing hydrology\n"); 154 160 int hydrology_model; 155 161 hydrology_core(femmodel); … … 157 163 if(hydrology_model!=HydrologydcEnum && issmb)smb_core(femmodel); 158 164 } 159 else{ 160 if(issmb) smb_core(femmodel); 161 } 162 163 if(isstressbalance && (step%sb_coupling_frequency==0 || step==1) ) stressbalance_core(femmodel); 164 165 if(isdamageevolution) damage_core(femmodel); 166 167 if(ismovingfront) movingfront_core(femmodel); 165 166 if(isstressbalance && (step%sb_coupling_frequency==0 || step==1) ) { 167 if(VerboseSolution()) _printf0_(" computing stress balance\n"); 168 stressbalance_core(femmodel); 169 } 170 171 if(isdamageevolution) { 172 if(VerboseSolution()) _printf0_(" computing damage\n"); 173 damage_core(femmodel); 174 } 175 176 if(ismovingfront) { 177 if(VerboseSolution()) _printf0_(" computing moving front\n"); 178 movingfront_core(femmodel); 179 } 168 180 169 181 /* from here on, prepare geometry for next time step*/ … … 171 183 172 184 if(ismasstransport){ 185 if(VerboseSolution()) _printf0_(" computing mass transport\n"); 173 186 bmb_core(femmodel); 174 187 masstransport_core(femmodel); -
issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
r24205 r24240 182 182 HydrologydcRelTolEnum, 183 183 HydrologydcSedimentCompressibilityEnum, 184 HydrologydcSedimentlimitEnum, 185 HydrologydcSedimentlimitFlagEnum, 184 186 HydrologydcSedimentPorosityEnum, 185 187 HydrologydcSedimentThicknessEnum, 186 HydrologydcSedimentlimitEnum,187 HydrologydcSedimentlimitFlagEnum,188 188 HydrologydcTransferFlagEnum, 189 189 HydrologydcUnconfinedFlagEnum, 190 190 HydrologydcWaterCompressibilityEnum, 191 HydrologydtEnum,192 191 HydrologyshreveStabilizationEnum, 193 192 IcecapToEarthCommEnum, … … 331 330 SmbAccurefEnum, 332 331 SmbAdThreshEnum, 332 SmbDesfacEnum, 333 SmbDpermilEnum, 334 SmbDsnowIdxEnum, 333 335 SmbCldFracEnum, 334 336 SmbDelta18oEnum, 335 337 SmbDelta18oSurfaceEnum, 336 338 SmbDenIdxEnum, 337 SmbDesfacEnum,338 SmbDpermilEnum,339 SmbDsnowIdxEnum,340 339 SmbDtEnum, 341 340 SmbEnum, … … 369 368 SmbRunoffrefEnum, 370 369 SmbSealevEnum, 370 SmbStepsPerStepEnum, 371 371 SmbSwIdxEnum, 372 372 SmbT0dryEnum, … … 494 494 DamageFEnum, 495 495 DegreeOfChannelizationEnum, 496 DepthBelowSurfaceEnum, 496 DepthBelowSurfaceEnum, 497 497 DeviatoricStresseffectiveEnum, 498 498 DeviatoricStressxxEnum, … … 512 512 DrivingStressXEnum, 513 513 DrivingStressYEnum, 514 515 EffectivePressure HydrostepEnum,516 EffectivePressure StackedEnum,514 EffectivePressureEnum, 515 EffectivePressureSubstepEnum, 516 EffectivePressureTransientEnum, 517 517 EnthalpyEnum, 518 518 EnthalpyPicardEnum, 519 519 EplHeadEnum, 520 EplHeadHydrostepEnum, 521 EplHeadOldEnum, 520 EplHeadOldEnum, 522 521 EplHeadSlopeXEnum, 523 522 EplHeadSlopeYEnum, 524 EplHeadStackedEnum, 523 EplHeadSubstepEnum, 524 EplHeadTransientEnum, 525 525 EsaDeltathicknessEnum, 526 526 EsaEmotionEnum, … … 564 564 HydrologyBumpHeightEnum, 565 565 HydrologyBumpSpacingEnum, 566 HydrologyDrainageRateEnum, 567 HydrologyEnglacialInputEnum, 566 HydrologydcBasalMoulinInputEnum, 567 HydrologydcEplThicknessEnum, 568 HydrologydcEplThicknessOldEnum, 569 HydrologydcEplThicknessSubstepEnum, 570 HydrologydcEplThicknessTransientEnum, 571 HydrologydcMaskEplactiveEltEnum, 572 HydrologydcMaskEplactiveNodeEnum, 573 HydrologydcMaskThawedEltEnum, 574 HydrologydcMaskThawedNodeEnum, 575 HydrologydcSedimentTransmitivityEnum, 576 HydrologyDrainageRateEnum, 577 HydrologyEnglacialInputEnum, 568 578 HydrologyGapHeightEnum, 569 579 HydrologyHeadEnum, … … 575 585 HydrologySheetThicknessEnum, 576 586 HydrologySheetThicknessOldEnum, 587 HydrologyWatercolumnMaxEnum, 577 588 HydrologyWaterVxEnum, 578 589 HydrologyWaterVyEnum, 579 HydrologyWatercolumnMaxEnum,580 HydrologydcBasalMoulinInputEnum,581 HydrologydcEplThicknessEnum,582 HydrologydcEplThicknessHydrostepEnum,583 HydrologydcEplThicknessOldEnum,584 HydrologydcEplThicknessStackedEnum,585 HydrologydcMaskEplactiveEltEnum,586 HydrologydcMaskEplactiveNodeEnum,587 HydrologydcMaskThawedEltEnum,588 HydrologydcMaskThawedNodeEnum,589 HydrologydcSedimentTransmitivityEnum,590 590 IceEnum, 591 591 IceMaskNodeActivationEnum, … … 628 628 P1Enum, 629 629 PressureEnum, 630 RadarEnum, 631 RadarAttenuationMacGregorEnum, 630 RadarEnum, 631 RadarAttenuationMacGregorEnum, 632 632 RadarAttenuationWolffEnum, 633 RadarIcePeriodEnum, 633 RadarIcePeriodEnum, 634 634 RadarPowerMacGregorEnum, 635 RadarPowerWolffEnum, 635 RadarPowerWolffEnum, 636 636 RheologyBAbsGradientEnum, 637 637 RheologyBInitialguessEnum, … … 659 659 SealevelriseSpcthicknessEnum, 660 660 SealevelriseStericRateEnum, 661 SedimentHeadEnum, 662 SedimentHeadHydrostepEnum, 663 SedimentHeadOldEnum, 661 SedimentHeadEnum, 662 SedimentHeadOldEnum, 663 SedimentHeadSubstepEnum, 664 SedimentHeadTransientEnum, 664 665 SedimentHeadResidualEnum, 665 666 SedimentHeadStackedEnum, … … 708 709 SmbMassBalanceClimateEnum, 709 710 SmbMassBalanceEnum, 711 SmbMassBalanceSubstepEnum, 712 SmbMassBalanceTransientEnum, 710 713 SmbMeanLHFEnum, 711 714 SmbMeanSHFEnum, … … 728 731 SmbReiniEnum, 729 732 SmbRunoffEnum, 733 SmbRunoffSubstepEnum, 734 SmbRunoffTransientEnum, 730 735 SmbS0gcmEnum, 731 736 SmbS0pEnum, … … 941 946 BasalforcingsIsmip6Enum, 942 947 BasalforcingsPicoEnum, 943 BeckmannGoosseFloatingMeltRateEnum, 948 BeckmannGoosseFloatingMeltRateEnum, 944 949 BedSlopeSolutionEnum, 945 950 BoolExternalResultEnum, -
issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp
r24205 r24240 190 190 case HydrologydcRelTolEnum : return "HydrologydcRelTol"; 191 191 case HydrologydcSedimentCompressibilityEnum : return "HydrologydcSedimentCompressibility"; 192 case HydrologydcSedimentlimitEnum : return "HydrologydcSedimentlimit"; 193 case HydrologydcSedimentlimitFlagEnum : return "HydrologydcSedimentlimitFlag"; 192 194 case HydrologydcSedimentPorosityEnum : return "HydrologydcSedimentPorosity"; 193 195 case HydrologydcSedimentThicknessEnum : return "HydrologydcSedimentThickness"; 194 case HydrologydcSedimentlimitEnum : return "HydrologydcSedimentlimit";195 case HydrologydcSedimentlimitFlagEnum : return "HydrologydcSedimentlimitFlag";196 196 case HydrologydcTransferFlagEnum : return "HydrologydcTransferFlag"; 197 197 case HydrologydcUnconfinedFlagEnum : return "HydrologydcUnconfinedFlag"; 198 198 case HydrologydcWaterCompressibilityEnum : return "HydrologydcWaterCompressibility"; 199 case HydrologydtEnum : return "Hydrologydt";200 199 case HydrologyshreveStabilizationEnum : return "HydrologyshreveStabilization"; 201 200 case IcecapToEarthCommEnum : return "IcecapToEarthComm"; … … 339 338 case SmbAccurefEnum : return "SmbAccuref"; 340 339 case SmbAdThreshEnum : return "SmbAdThresh"; 340 case SmbDesfacEnum : return "SmbDesfac"; 341 case SmbDpermilEnum : return "SmbDpermil"; 342 case SmbDsnowIdxEnum : return "SmbDsnowIdx"; 341 343 case SmbCldFracEnum : return "SmbCldFrac"; 342 344 case SmbDelta18oEnum : return "SmbDelta18o"; 343 345 case SmbDelta18oSurfaceEnum : return "SmbDelta18oSurface"; 344 346 case SmbDenIdxEnum : return "SmbDenIdx"; 345 case SmbDesfacEnum : return "SmbDesfac";346 case SmbDpermilEnum : return "SmbDpermil";347 case SmbDsnowIdxEnum : return "SmbDsnowIdx";348 347 case SmbDtEnum : return "SmbDt"; 349 348 case SmbEnum : return "Smb"; … … 377 376 case SmbRunoffrefEnum : return "SmbRunoffref"; 378 377 case SmbSealevEnum : return "SmbSealev"; 378 case SmbStepsPerStepEnum : return "SmbStepsPerStep"; 379 379 case SmbSwIdxEnum : return "SmbSwIdx"; 380 380 case SmbT0dryEnum : return "SmbT0dry"; … … 519 519 case DrivingStressYEnum : return "DrivingStressY"; 520 520 case EffectivePressureEnum : return "EffectivePressure"; 521 case EffectivePressure HydrostepEnum : return "EffectivePressureHydrostep";522 case EffectivePressure StackedEnum : return "EffectivePressureStacked";521 case EffectivePressureSubstepEnum : return "EffectivePressureSubstep"; 522 case EffectivePressureTransientEnum : return "EffectivePressureTransient"; 523 523 case EnthalpyEnum : return "Enthalpy"; 524 524 case EnthalpyPicardEnum : return "EnthalpyPicard"; 525 525 case EplHeadEnum : return "EplHead"; 526 case EplHeadHydrostepEnum : return "EplHeadHydrostep";527 526 case EplHeadOldEnum : return "EplHeadOld"; 528 527 case EplHeadSlopeXEnum : return "EplHeadSlopeX"; 529 528 case EplHeadSlopeYEnum : return "EplHeadSlopeY"; 530 case EplHeadStackedEnum : return "EplHeadStacked"; 529 case EplHeadSubstepEnum : return "EplHeadSubstep"; 530 case EplHeadTransientEnum : return "EplHeadTransient"; 531 531 case EsaDeltathicknessEnum : return "EsaDeltathickness"; 532 532 case EsaEmotionEnum : return "EsaEmotion"; … … 570 570 case HydrologyBumpHeightEnum : return "HydrologyBumpHeight"; 571 571 case HydrologyBumpSpacingEnum : return "HydrologyBumpSpacing"; 572 case HydrologydcBasalMoulinInputEnum : return "HydrologydcBasalMoulinInput"; 573 case HydrologydcEplThicknessEnum : return "HydrologydcEplThickness"; 574 case HydrologydcEplThicknessOldEnum : return "HydrologydcEplThicknessOld"; 575 case HydrologydcEplThicknessSubstepEnum : return "HydrologydcEplThicknessSubstep"; 576 case HydrologydcEplThicknessTransientEnum : return "HydrologydcEplThicknessTransient"; 577 case HydrologydcMaskEplactiveEltEnum : return "HydrologydcMaskEplactiveElt"; 578 case HydrologydcMaskEplactiveNodeEnum : return "HydrologydcMaskEplactiveNode"; 579 case HydrologydcMaskThawedEltEnum : return "HydrologydcMaskThawedElt"; 580 case HydrologydcMaskThawedNodeEnum : return "HydrologydcMaskThawedNode"; 581 case HydrologydcSedimentTransmitivityEnum : return "HydrologydcSedimentTransmitivity"; 572 582 case HydrologyDrainageRateEnum : return "HydrologyDrainageRate"; 573 583 case HydrologyEnglacialInputEnum : return "HydrologyEnglacialInput"; … … 581 591 case HydrologySheetThicknessEnum : return "HydrologySheetThickness"; 582 592 case HydrologySheetThicknessOldEnum : return "HydrologySheetThicknessOld"; 593 case HydrologyWatercolumnMaxEnum : return "HydrologyWatercolumnMax"; 583 594 case HydrologyWaterVxEnum : return "HydrologyWaterVx"; 584 595 case HydrologyWaterVyEnum : return "HydrologyWaterVy"; 585 case HydrologyWatercolumnMaxEnum : return "HydrologyWatercolumnMax";586 case HydrologydcBasalMoulinInputEnum : return "HydrologydcBasalMoulinInput";587 case HydrologydcEplThicknessEnum : return "HydrologydcEplThickness";588 case HydrologydcEplThicknessHydrostepEnum : return "HydrologydcEplThicknessHydrostep";589 case HydrologydcEplThicknessOldEnum : return "HydrologydcEplThicknessOld";590 case HydrologydcEplThicknessStackedEnum : return "HydrologydcEplThicknessStacked";591 case HydrologydcMaskEplactiveEltEnum : return "HydrologydcMaskEplactiveElt";592 case HydrologydcMaskEplactiveNodeEnum : return "HydrologydcMaskEplactiveNode";593 case HydrologydcMaskThawedEltEnum : return "HydrologydcMaskThawedElt";594 case HydrologydcMaskThawedNodeEnum : return "HydrologydcMaskThawedNode";595 case HydrologydcSedimentTransmitivityEnum : return "HydrologydcSedimentTransmitivity";596 596 case IceEnum : return "Ice"; 597 597 case IceMaskNodeActivationEnum : return "IceMaskNodeActivation"; … … 666 666 case SealevelriseStericRateEnum : return "SealevelriseStericRate"; 667 667 case SedimentHeadEnum : return "SedimentHead"; 668 case SedimentHeadHydrostepEnum : return "SedimentHeadHydrostep";669 668 case SedimentHeadOldEnum : return "SedimentHeadOld"; 669 case SedimentHeadSubstepEnum : return "SedimentHeadSubstep"; 670 case SedimentHeadTransientEnum : return "SedimentHeadTransient"; 670 671 case SedimentHeadResidualEnum : return "SedimentHeadResidual"; 671 672 case SedimentHeadStackedEnum : return "SedimentHeadStacked"; … … 714 715 case SmbMassBalanceClimateEnum : return "SmbMassBalanceClimate"; 715 716 case SmbMassBalanceEnum : return "SmbMassBalance"; 717 case SmbMassBalanceSubstepEnum : return "SmbMassBalanceSubstep"; 718 case SmbMassBalanceTransientEnum : return "SmbMassBalanceTransient"; 716 719 case SmbMeanLHFEnum : return "SmbMeanLHF"; 717 720 case SmbMeanSHFEnum : return "SmbMeanSHF"; … … 734 737 case SmbReiniEnum : return "SmbReini"; 735 738 case SmbRunoffEnum : return "SmbRunoff"; 739 case SmbRunoffSubstepEnum : return "SmbRunoffSubstep"; 740 case SmbRunoffTransientEnum : return "SmbRunoffTransient"; 736 741 case SmbS0gcmEnum : return "SmbS0gcm"; 737 742 case SmbS0pEnum : return "SmbS0p"; -
issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp
r24205 r24240 193 193 else if (strcmp(name,"HydrologydcRelTol")==0) return HydrologydcRelTolEnum; 194 194 else if (strcmp(name,"HydrologydcSedimentCompressibility")==0) return HydrologydcSedimentCompressibilityEnum; 195 else if (strcmp(name,"HydrologydcSedimentlimit")==0) return HydrologydcSedimentlimitEnum; 196 else if (strcmp(name,"HydrologydcSedimentlimitFlag")==0) return HydrologydcSedimentlimitFlagEnum; 195 197 else if (strcmp(name,"HydrologydcSedimentPorosity")==0) return HydrologydcSedimentPorosityEnum; 196 198 else if (strcmp(name,"HydrologydcSedimentThickness")==0) return HydrologydcSedimentThicknessEnum; 197 else if (strcmp(name,"HydrologydcSedimentlimit")==0) return HydrologydcSedimentlimitEnum;198 else if (strcmp(name,"HydrologydcSedimentlimitFlag")==0) return HydrologydcSedimentlimitFlagEnum;199 199 else if (strcmp(name,"HydrologydcTransferFlag")==0) return HydrologydcTransferFlagEnum; 200 200 else if (strcmp(name,"HydrologydcUnconfinedFlag")==0) return HydrologydcUnconfinedFlagEnum; 201 201 else if (strcmp(name,"HydrologydcWaterCompressibility")==0) return HydrologydcWaterCompressibilityEnum; 202 else if (strcmp(name,"Hydrologydt")==0) return HydrologydtEnum;203 202 else if (strcmp(name,"HydrologyshreveStabilization")==0) return HydrologyshreveStabilizationEnum; 204 203 else if (strcmp(name,"IcecapToEarthComm")==0) return IcecapToEarthCommEnum; … … 260 259 else if (strcmp(name,"MaterialsLithosphereShearModulus")==0) return MaterialsLithosphereShearModulusEnum; 261 260 else if (strcmp(name,"MaterialsMantleDensity")==0) return MaterialsMantleDensityEnum; 261 else if (strcmp(name,"MaterialsMantleShearModulus")==0) return MaterialsMantleShearModulusEnum; 262 262 else stage=3; 263 263 } 264 264 if(stage==3){ 265 if (strcmp(name,"MaterialsMantleShearModulus")==0) return MaterialsMantleShearModulusEnum; 266 else if (strcmp(name,"MaterialsMeltingpoint")==0) return MaterialsMeltingpointEnum; 265 if (strcmp(name,"MaterialsMeltingpoint")==0) return MaterialsMeltingpointEnum; 267 266 else if (strcmp(name,"MaterialsMixedLayerCapacity")==0) return MaterialsMixedLayerCapacityEnum; 268 267 else if (strcmp(name,"MaterialsMuWater")==0) return MaterialsMuWaterEnum; … … 345 344 else if (strcmp(name,"SmbAccuref")==0) return SmbAccurefEnum; 346 345 else if (strcmp(name,"SmbAdThresh")==0) return SmbAdThreshEnum; 346 else if (strcmp(name,"SmbDesfac")==0) return SmbDesfacEnum; 347 else if (strcmp(name,"SmbDpermil")==0) return SmbDpermilEnum; 348 else if (strcmp(name,"SmbDsnowIdx")==0) return SmbDsnowIdxEnum; 347 349 else if (strcmp(name,"SmbCldFrac")==0) return SmbCldFracEnum; 348 350 else if (strcmp(name,"SmbDelta18o")==0) return SmbDelta18oEnum; 349 351 else if (strcmp(name,"SmbDelta18oSurface")==0) return SmbDelta18oSurfaceEnum; 350 352 else if (strcmp(name,"SmbDenIdx")==0) return SmbDenIdxEnum; 351 else if (strcmp(name,"SmbDesfac")==0) return SmbDesfacEnum;352 else if (strcmp(name,"SmbDpermil")==0) return SmbDpermilEnum;353 else if (strcmp(name,"SmbDsnowIdx")==0) return SmbDsnowIdxEnum;354 353 else if (strcmp(name,"SmbDt")==0) return SmbDtEnum; 355 354 else if (strcmp(name,"Smb")==0) return SmbEnum; … … 383 382 else if (strcmp(name,"SmbRunoffref")==0) return SmbRunoffrefEnum; 384 383 else if (strcmp(name,"SmbSealev")==0) return SmbSealevEnum; 384 else if (strcmp(name,"SmbStepsPerStep")==0) return SmbStepsPerStepEnum; 385 385 else stage=4; 386 386 } … … 531 531 else if (strcmp(name,"DrivingStressY")==0) return DrivingStressYEnum; 532 532 else if (strcmp(name,"EffectivePressure")==0) return EffectivePressureEnum; 533 else if (strcmp(name,"EffectivePressure Hydrostep")==0) return EffectivePressureHydrostepEnum;534 else if (strcmp(name,"EffectivePressure Stacked")==0) return EffectivePressureStackedEnum;533 else if (strcmp(name,"EffectivePressureSubstep")==0) return EffectivePressureSubstepEnum; 534 else if (strcmp(name,"EffectivePressureTransient")==0) return EffectivePressureTransientEnum; 535 535 else if (strcmp(name,"Enthalpy")==0) return EnthalpyEnum; 536 536 else if (strcmp(name,"EnthalpyPicard")==0) return EnthalpyPicardEnum; 537 537 else if (strcmp(name,"EplHead")==0) return EplHeadEnum; 538 else if (strcmp(name,"EplHeadHydrostep")==0) return EplHeadHydrostepEnum;539 538 else if (strcmp(name,"EplHeadOld")==0) return EplHeadOldEnum; 540 539 else if (strcmp(name,"EplHeadSlopeX")==0) return EplHeadSlopeXEnum; 541 540 else if (strcmp(name,"EplHeadSlopeY")==0) return EplHeadSlopeYEnum; 542 else if (strcmp(name,"EplHeadStacked")==0) return EplHeadStackedEnum; 541 else if (strcmp(name,"EplHeadSubstep")==0) return EplHeadSubstepEnum; 542 else if (strcmp(name,"EplHeadTransient")==0) return EplHeadTransientEnum; 543 543 else if (strcmp(name,"EsaDeltathickness")==0) return EsaDeltathicknessEnum; 544 544 else if (strcmp(name,"EsaEmotion")==0) return EsaEmotionEnum; … … 582 582 else if (strcmp(name,"HydrologyBumpHeight")==0) return HydrologyBumpHeightEnum; 583 583 else if (strcmp(name,"HydrologyBumpSpacing")==0) return HydrologyBumpSpacingEnum; 584 else if (strcmp(name,"HydrologydcBasalMoulinInput")==0) return HydrologydcBasalMoulinInputEnum; 585 else if (strcmp(name,"HydrologydcEplThickness")==0) return HydrologydcEplThicknessEnum; 586 else if (strcmp(name,"HydrologydcEplThicknessOld")==0) return HydrologydcEplThicknessOldEnum; 587 else if (strcmp(name,"HydrologydcEplThicknessSubstep")==0) return HydrologydcEplThicknessSubstepEnum; 588 else if (strcmp(name,"HydrologydcEplThicknessTransient")==0) return HydrologydcEplThicknessTransientEnum; 589 else if (strcmp(name,"HydrologydcMaskEplactiveElt")==0) return HydrologydcMaskEplactiveEltEnum; 590 else if (strcmp(name,"HydrologydcMaskEplactiveNode")==0) return HydrologydcMaskEplactiveNodeEnum; 591 else if (strcmp(name,"HydrologydcMaskThawedElt")==0) return HydrologydcMaskThawedEltEnum; 592 else if (strcmp(name,"HydrologydcMaskThawedNode")==0) return HydrologydcMaskThawedNodeEnum; 593 else if (strcmp(name,"HydrologydcSedimentTransmitivity")==0) return HydrologydcSedimentTransmitivityEnum; 584 594 else if (strcmp(name,"HydrologyDrainageRate")==0) return HydrologyDrainageRateEnum; 585 595 else if (strcmp(name,"HydrologyEnglacialInput")==0) return HydrologyEnglacialInputEnum; … … 593 603 else if (strcmp(name,"HydrologySheetThickness")==0) return HydrologySheetThicknessEnum; 594 604 else if (strcmp(name,"HydrologySheetThicknessOld")==0) return HydrologySheetThicknessOldEnum; 605 else if (strcmp(name,"HydrologyWatercolumnMax")==0) return HydrologyWatercolumnMaxEnum; 595 606 else if (strcmp(name,"HydrologyWaterVx")==0) return HydrologyWaterVxEnum; 596 607 else if (strcmp(name,"HydrologyWaterVy")==0) return HydrologyWaterVyEnum; 597 else if (strcmp(name,"HydrologyWatercolumnMax")==0) return HydrologyWatercolumnMaxEnum;598 else if (strcmp(name,"HydrologydcBasalMoulinInput")==0) return HydrologydcBasalMoulinInputEnum;599 else if (strcmp(name,"HydrologydcEplThickness")==0) return HydrologydcEplThicknessEnum;600 else if (strcmp(name,"HydrologydcEplThicknessHydrostep")==0) return HydrologydcEplThicknessHydrostepEnum;601 else if (strcmp(name,"HydrologydcEplThicknessOld")==0) return HydrologydcEplThicknessOldEnum;602 else if (strcmp(name,"HydrologydcEplThicknessStacked")==0) return HydrologydcEplThicknessStackedEnum;603 else if (strcmp(name,"HydrologydcMaskEplactiveElt")==0) return HydrologydcMaskEplactiveEltEnum;604 else if (strcmp(name,"HydrologydcMaskEplactiveNode")==0) return HydrologydcMaskEplactiveNodeEnum;605 else if (strcmp(name,"HydrologydcMaskThawedElt")==0) return HydrologydcMaskThawedEltEnum;606 else if (strcmp(name,"HydrologydcMaskThawedNode")==0) return HydrologydcMaskThawedNodeEnum;607 else if (strcmp(name,"HydrologydcSedimentTransmitivity")==0) return HydrologydcSedimentTransmitivityEnum;608 608 else if (strcmp(name,"Ice")==0) return IceEnum; 609 609 else if (strcmp(name,"IceMaskNodeActivation")==0) return IceMaskNodeActivationEnum; … … 681 681 else if (strcmp(name,"SealevelriseStericRate")==0) return SealevelriseStericRateEnum; 682 682 else if (strcmp(name,"SedimentHead")==0) return SedimentHeadEnum; 683 else if (strcmp(name,"SedimentHeadHydrostep")==0) return SedimentHeadHydrostepEnum;684 683 else if (strcmp(name,"SedimentHeadOld")==0) return SedimentHeadOldEnum; 684 else if (strcmp(name,"SedimentHeadSubstep")==0) return SedimentHeadSubstepEnum; 685 else if (strcmp(name,"SedimentHeadTransient")==0) return SedimentHeadTransientEnum; 685 686 else if (strcmp(name,"SedimentHeadResidual")==0) return SedimentHeadResidualEnum; 686 687 else if (strcmp(name,"SedimentHeadStacked")==0) return SedimentHeadStackedEnum; … … 729 730 else if (strcmp(name,"SmbMassBalanceClimate")==0) return SmbMassBalanceClimateEnum; 730 731 else if (strcmp(name,"SmbMassBalance")==0) return SmbMassBalanceEnum; 732 else if (strcmp(name,"SmbMassBalanceSubstep")==0) return SmbMassBalanceSubstepEnum; 733 else if (strcmp(name,"SmbMassBalanceTransient")==0) return SmbMassBalanceTransientEnum; 731 734 else if (strcmp(name,"SmbMeanLHF")==0) return SmbMeanLHFEnum; 732 735 else if (strcmp(name,"SmbMeanSHF")==0) return SmbMeanSHFEnum; … … 749 752 else if (strcmp(name,"SmbReini")==0) return SmbReiniEnum; 750 753 else if (strcmp(name,"SmbRunoff")==0) return SmbRunoffEnum; 754 else stage=7; 755 } 756 if(stage==7){ 757 if (strcmp(name,"SmbRunoffSubstep")==0) return SmbRunoffSubstepEnum; 758 else if (strcmp(name,"SmbRunoffTransient")==0) return SmbRunoffTransientEnum; 751 759 else if (strcmp(name,"SmbS0gcm")==0) return SmbS0gcmEnum; 752 760 else if (strcmp(name,"SmbS0p")==0) return SmbS0pEnum; 753 761 else if (strcmp(name,"SmbS0t")==0) return SmbS0tEnum; 754 else stage=7; 755 } 756 if(stage==7){ 757 if (strcmp(name,"SmbSizeini")==0) return SmbSizeiniEnum; 762 else if (strcmp(name,"SmbSizeini")==0) return SmbSizeiniEnum; 758 763 else if (strcmp(name,"SmbSmbCorr")==0) return SmbSmbCorrEnum; 759 764 else if (strcmp(name,"SmbSmbref")==0) return SmbSmbrefEnum; … … 870 875 else if (strcmp(name,"Outputdefinition37")==0) return Outputdefinition37Enum; 871 876 else if (strcmp(name,"Outputdefinition38")==0) return Outputdefinition38Enum; 872 else if (strcmp(name,"Outputdefinition39")==0) return Outputdefinition39Enum; 877 else stage=8; 878 } 879 if(stage==8){ 880 if (strcmp(name,"Outputdefinition39")==0) return Outputdefinition39Enum; 873 881 else if (strcmp(name,"Outputdefinition3")==0) return Outputdefinition3Enum; 874 882 else if (strcmp(name,"Outputdefinition40")==0) return Outputdefinition40Enum; 875 883 else if (strcmp(name,"Outputdefinition41")==0) return Outputdefinition41Enum; 876 884 else if (strcmp(name,"Outputdefinition42")==0) return Outputdefinition42Enum; 877 else stage=8; 878 } 879 if(stage==8){ 880 if (strcmp(name,"Outputdefinition43")==0) return Outputdefinition43Enum; 885 else if (strcmp(name,"Outputdefinition43")==0) return Outputdefinition43Enum; 881 886 else if (strcmp(name,"Outputdefinition44")==0) return Outputdefinition44Enum; 882 887 else if (strcmp(name,"Outputdefinition45")==0) return Outputdefinition45Enum; … … 993 998 else if (strcmp(name,"ControlInputMaxs")==0) return ControlInputMaxsEnum; 994 999 else if (strcmp(name,"ControlInputMins")==0) return ControlInputMinsEnum; 995 else if (strcmp(name,"ControlInputValues")==0) return ControlInputValuesEnum; 1000 else stage=9; 1001 } 1002 if(stage==9){ 1003 if (strcmp(name,"ControlInputValues")==0) return ControlInputValuesEnum; 996 1004 else if (strcmp(name,"CrouzeixRaviart")==0) return CrouzeixRaviartEnum; 997 1005 else if (strcmp(name,"Cuffey")==0) return CuffeyEnum; 998 1006 else if (strcmp(name,"CuffeyTemperate")==0) return CuffeyTemperateEnum; 999 1007 else if (strcmp(name,"DamageEvolutionAnalysis")==0) return DamageEvolutionAnalysisEnum; 1000 else stage=9; 1001 } 1002 if(stage==9){ 1003 if (strcmp(name,"DamageEvolutionSolution")==0) return DamageEvolutionSolutionEnum; 1008 else if (strcmp(name,"DamageEvolutionSolution")==0) return DamageEvolutionSolutionEnum; 1004 1009 else if (strcmp(name,"DataSet")==0) return DataSetEnum; 1005 1010 else if (strcmp(name,"DataSetParam")==0) return DataSetParamEnum; … … 1116 1121 else if (strcmp(name,"LoveHi")==0) return LoveHiEnum; 1117 1122 else if (strcmp(name,"LoveHr")==0) return LoveHrEnum; 1118 else if (strcmp(name,"LoveKernelsImag")==0) return LoveKernelsImagEnum; 1123 else stage=10; 1124 } 1125 if(stage==10){ 1126 if (strcmp(name,"LoveKernelsImag")==0) return LoveKernelsImagEnum; 1119 1127 else if (strcmp(name,"LoveKernelsReal")==0) return LoveKernelsRealEnum; 1120 1128 else if (strcmp(name,"LoveKi")==0) return LoveKiEnum; 1121 1129 else if (strcmp(name,"LoveKr")==0) return LoveKrEnum; 1122 1130 else if (strcmp(name,"LoveLi")==0) return LoveLiEnum; 1123 else stage=10; 1124 } 1125 if(stage==10){ 1126 if (strcmp(name,"LoveLr")==0) return LoveLrEnum; 1131 else if (strcmp(name,"LoveLr")==0) return LoveLrEnum; 1127 1132 else if (strcmp(name,"LoveSolution")==0) return LoveSolutionEnum; 1128 1133 else if (strcmp(name,"MINI")==0) return MINIEnum; … … 1239 1244 else if (strcmp(name,"Segment")==0) return SegmentEnum; 1240 1245 else if (strcmp(name,"SegmentRiftfront")==0) return SegmentRiftfrontEnum; 1241 else if (strcmp(name,"Separate")==0) return SeparateEnum; 1246 else stage=11; 1247 } 1248 if(stage==11){ 1249 if (strcmp(name,"Separate")==0) return SeparateEnum; 1242 1250 else if (strcmp(name,"Seq")==0) return SeqEnum; 1243 1251 else if (strcmp(name,"SmbAnalysis")==0) return SmbAnalysisEnum; 1244 1252 else if (strcmp(name,"SmbSolution")==0) return SmbSolutionEnum; 1245 1253 else if (strcmp(name,"SmoothAnalysis")==0) return SmoothAnalysisEnum; 1246 else stage=11; 1247 } 1248 if(stage==11){ 1249 if (strcmp(name,"SoftMigration")==0) return SoftMigrationEnum; 1254 else if (strcmp(name,"SoftMigration")==0) return SoftMigrationEnum; 1250 1255 else if (strcmp(name,"SpatialLinearFloatingMeltRate")==0) return SpatialLinearFloatingMeltRateEnum; 1251 1256 else if (strcmp(name,"SpcDynamic")==0) return SpcDynamicEnum; -
issm/trunk-jpl/src/c/shared/Enum/Synchronize.sh
r24017 r24240 6 6 7 7 #Removed existing files 8 rm $ISSM_D IR/src/c/shared/Enum/EnumToStringx.cpp9 rm $ISSM_D IR/src/c/shared/Enum/StringToEnumx.cpp8 rm $ISSM_DEV_DIR/src/c/shared/Enum/EnumToStringx.cpp 9 rm $ISSM_DEV_DIR/src/c/shared/Enum/StringToEnumx.cpp 10 10 11 11 #Get number of enums … … 16 16 #Build EnumToAnalysis.cpp {{{ 17 17 #Header 18 cat <<END > $ISSM_D IR/src/c/analyses/EnumToAnalysis.cpp18 cat <<END > $ISSM_DEV_DIR/src/c/analyses/EnumToAnalysis.cpp 19 19 /* 20 20 * \file EnumToAnalysis.cpp … … 37 37 grep -v DefaultAnalysis | grep -v FlaimAnalysis | grep -v SurfaceSlopeAnalysis | grep -v BedSlopeAnalysis | \ 38 38 awk '{print "\t\t#ifdef _HAVE_"toupper(substr($1,1,length($1)-12))"_\n\t\t" "case " $1" : return new " substr($1,1,length($1)-4) "();\n\t\t#endif"}' \ 39 >> $ISSM_D IR/src/c/analyses/EnumToAnalysis.cpp39 >> $ISSM_DEV_DIR/src/c/analyses/EnumToAnalysis.cpp 40 40 41 41 #Footer 42 cat <<END >> $ISSM_D IR/src/c/analyses/EnumToAnalysis.cpp42 cat <<END >> $ISSM_DEV_DIR/src/c/analyses/EnumToAnalysis.cpp 43 43 default : _error_("enum provided not supported ("<<EnumToStringx(analysis_enum)<<")"); 44 44 } … … 48 48 #Build analyses.m4{{{ 49 49 #Header 50 cat <<END > $ISSM_D IR/m4/analyses.m450 cat <<END > $ISSM_DEV_DIR/m4/analyses.m4 51 51 52 52 dnl WARNING: DO NOT MODIFY THIS FILE … … 78 78 AC_MSG_RESULT($HAVE_" toupper($1)")\n\ 79 79 dnl }}}"}' \ 80 >> $ISSM_D IR/m4/analyses.m480 >> $ISSM_DEV_DIR/m4/analyses.m4 81 81 82 82 #Footer 83 cat <<END >> $ISSM_D IR/m4/analyses.m483 cat <<END >> $ISSM_DEV_DIR/m4/analyses.m4 84 84 85 85 ]) … … 91 91 #Build EnumToStringx.cpp {{{ 92 92 #Header 93 cat <<END > $ISSM_D IR/src/c/shared/Enum/EnumToStringx.cpp93 cat <<END > $ISSM_DEV_DIR/src/c/shared/Enum/EnumToStringx.cpp 94 94 /* 95 95 * \file EnumToStringx.cpp: … … 112 112 END 113 113 #core 114 cat temp | awk '{print "\t\t" "case " $1" : return \"" substr($1,1,length($1)-4) "\";"}' >> $ISSM_D IR/src/c/shared/Enum/EnumToStringx.cpp114 cat temp | awk '{print "\t\t" "case " $1" : return \"" substr($1,1,length($1)-4) "\";"}' >> $ISSM_DEV_DIR/src/c/shared/Enum/EnumToStringx.cpp 115 115 #Footer 116 cat <<END >> $ISSM_D IR/src/c/shared/Enum/EnumToStringx.cpp116 cat <<END >> $ISSM_DEV_DIR/src/c/shared/Enum/EnumToStringx.cpp 117 117 default : return "unknown"; 118 118 … … 144 144 #Build StringToEnumx.cpp {{{ 145 145 #Header 146 cat <<END > $ISSM_D IR/src/c/shared/Enum/StringToEnumx.cpp146 cat <<END > $ISSM_DEV_DIR/src/c/shared/Enum/StringToEnumx.cpp 147 147 /* 148 148 * \file StringToEnumx.cpp: … … 168 168 i2=120; 169 169 for (( i=1 ; i<=100 ; i++ )); do 170 echo " if(stage==$i){" >> $ISSM_D IR//src/c/shared/Enum/StringToEnumx.cpp170 echo " if(stage==$i){" >> $ISSM_DEV_DIR//src/c/shared/Enum/StringToEnumx.cpp 171 171 awk -v i1=$i1 -v i2=$i2 '{if(NR>=i1 && NR<=i2) print $0 }' temp | 172 awk '{print "\t" ((NR==1)?" if":" else if") " (strcmp(name,\"" substr($1,1,length($1)-4) "\")==0) return " $1 ";"}' >> $ISSM_D IR//src/c/shared/Enum/StringToEnumx.cpp173 echo " else stage=$(($i+1));" >> $ISSM_D IR//src/c/shared/Enum/StringToEnumx.cpp174 echo " }" >> $ISSM_D IR//src/c/shared/Enum/StringToEnumx.cpp175 172 awk '{print "\t" ((NR==1)?" if":" else if") " (strcmp(name,\"" substr($1,1,length($1)-4) "\")==0) return " $1 ";"}' >> $ISSM_DEV_DIR//src/c/shared/Enum/StringToEnumx.cpp 173 echo " else stage=$(($i+1));" >> $ISSM_DEV_DIR//src/c/shared/Enum/StringToEnumx.cpp 174 echo " }" >> $ISSM_DEV_DIR//src/c/shared/Enum/StringToEnumx.cpp 175 176 176 if [ $i2 -ge $NUMENUMS ]; then break; fi 177 177 let i1=$i1+120 … … 180 180 181 181 #footer 182 cat <<END >> $ISSM_D IR/src/c/shared/Enum/StringToEnumx.cpp182 cat <<END >> $ISSM_DEV_DIR/src/c/shared/Enum/StringToEnumx.cpp 183 183 /*If we reach this point, the string provided has not been found*/ 184 184 if(notfounderror) -
issm/trunk-jpl/src/c/toolkits/petsc/objects/PetscVec.cpp
r23643 r24240 83 83 84 84 _assert_(this->vector); 85 VecAssemblyBegin(this->vector); 85 VecAssemblyBegin(this->vector); 86 86 VecAssemblyEnd(this->vector); 87 87 … … 135 135 136 136 /*Get Ownership range*/ 137 PetscInt lower_row,upper_row; 137 PetscInt lower_row,upper_row; 138 138 VecGetOwnershipRange(this->vector,&lower_row,&upper_row); 139 int range=upper_row-lower_row; 139 int range=upper_row-lower_row; 140 140 141 141 /*return NULL if no range*/ … … 147 147 148 148 /*Build indices*/ 149 int* indices=xNew<int>(range); 149 int* indices=xNew<int>(range); 150 150 for(int i=0;i<range;i++) indices[i]=lower_row+i; 151 151 /*Get vector*/ 152 152 IssmDouble* values =xNew<IssmDouble>(range); 153 VecGetValues(this->vector,range,indices,values); 153 VecGetValues(this->vector,range,indices,values); 154 154 155 155 *pvector = values; … … 238 238 239 239 _assert_(this->vector); 240 VecScale(this->vector,scale_factor); 240 VecScale(this->vector,scale_factor); 241 242 } 243 /*}}}*/ 244 void PetscVec::Pow(IssmDouble scale_factor){/*{{{*/ 245 246 _assert_(this->vector); 247 VecPow(this->vector,scale_factor); 241 248 242 249 } … … 258 265 } 259 266 /*}}}*/ 267 void PetscVec::PointwiseMult(PetscVec* x,PetscVec* y){/*{{{*/ 268 269 _assert_(this->vector); 270 VecPointwiseMult(this->vector,x->vector,y->vector); 271 272 } 273 /*}}}*/ -
issm/trunk-jpl/src/c/toolkits/petsc/objects/PetscVec.h
r23643 r24240 1 1 /*!\file: PetscVec.h 2 * \brief wrapper to our own PetscVec object, which is needed to add AD capabilities (using ADOLC) 3 * to a C-coded Petsc API. We are just wrapping the Petsc objects into C++ equivalent, so that 2 * \brief wrapper to our own PetscVec object, which is needed to add AD capabilities (using ADOLC) 3 * to a C-coded Petsc API. We are just wrapping the Petsc objects into C++ equivalent, so that 4 4 * later, we can map all of the Petsc routines into Adolc equivalents. 5 */ 5 */ 6 6 7 7 #ifndef _PETSCVEC_H_ … … 57 57 IssmDouble Max(void); 58 58 void Scale(IssmDouble scale_factor); 59 void Pow(IssmDouble scale_factor); 59 60 void PointwiseDivide(PetscVec* x,PetscVec* y); 61 void PointwiseMult(PetscVec* x,PetscVec* y); 60 62 IssmDouble Dot(PetscVec* vector); 61 63 }; -
issm/trunk-jpl/src/m/archive/arch.py
r24213 r24240 8 8 """ 9 9 ARCHWRITE - Write data to a field, given the file name, field name, and data. 10 11 10 Usage: 12 11 archwrite('archive101.arch', 'variable_name', data) 13 12 """ 13 14 14 nargs = len(args) 15 15 if nargs % 2 != 0: … … 23 23 except IOError as e: 24 24 raise IOError("archwrite error: could not open '{}' to write to due to:".format(filename), e) 25 26 25 nfields = len(args) / 2 27 26 # generate data to write 28 for i in range( nfields):27 for i in range(int(nfields)): 29 28 # write field name 30 29 name = args[2 * i] 31 30 write_field_name(fid, name) 32 33 31 # write data associated with field name 34 32 data = args[2 * i + 1] … … 42 40 else: 43 41 raise ValueError("archwrite : error writing data, invalid code entered '{}'".format(code)) 44 45 42 fid.close() 46 47 43 # }}} 48 44 … … 64 60 65 61 archive_results = [] 66 67 62 # read first result 68 63 result = read_field(fid) 69 70 64 while result: 71 65 if fieldname == result['field_name']: … … 73 67 archive_results = result['data'] # we only want the data 74 68 break 75 76 69 # read next result 77 70 result = read_field(fid) 78 79 71 # close file 80 72 fid.close() 81 82 73 return archive_results 83 74 # }}} … … 98 89 except IOError as e: 99 90 raise IOError("archread error : could not open file '{}' to read from due to ".format(filename), e) 100 101 91 print('Source file: ') 102 92 print(('\t{0}'.format(filename))) 103 93 print('Variables: ') 104 105 94 result = read_field(fid) 106 95 while result: … … 110 99 # go to next result 111 100 result = read_field(fid) 112 113 101 # close file 114 102 fid.close() 115 116 # }}} 117 118 # Helper functions 119 120 103 # }}} 104 105 106 # Helper functions 121 107 def write_field_name(fid, data): # {{{ 122 108 """ … … 127 113 reclen = len(data) + 4 + 4 128 114 fid.write(struct.pack('>i', reclen)) 129 130 115 # write format code 131 116 code = format_archive_code(data) … … 133 118 raise TypeError("archwrite : error writing field name, expected string, but got %s" % type(data)) 134 119 fid.write(struct.pack('>i', 1)) 135 136 120 # write string length, and then the string 137 121 fid.write(struct.pack('>i', len(data))) … … 151 135 # write the format code (2 for scalar) 152 136 fid.write(struct.pack('>i', 2)) 153 154 137 # write the double 155 138 fid.write(struct.pack('>d', data)) 156 157 139 # }}} 158 140 … … 168 150 elif isinstance(data, (list, tuple)): 169 151 data = np.array(data).reshape(- 1, ) 170 171 152 if np.ndim(data) == 1: 172 153 if np.size(data): … … 174 155 else: 175 156 data = data.reshape(0, 0) 176 177 157 # get size of data 178 158 sz = data.shape 179 180 159 # write length of record 181 160 # format code + row size + col size + (double size * row amt * col amt) … … 185 164 raise ValueError("archwrite error : can not write vector to binary file because it is too large") 186 165 fid.write(struct.pack('>i', reclen)) 187 188 166 # write format code 189 167 fid.write(struct.pack('>i', 3)) 190 191 168 # write vector 192 169 fid.write(struct.pack('>i', sz[0])) … … 195 172 for j in range(sz[1]): 196 173 fid.write(struct.pack('>d', float(data[i][j]))) 197 198 174 # }}} 199 175 -
issm/trunk-jpl/src/m/classes/SMBcomponents.m
r23814 r24240 5 5 6 6 classdef SMBcomponents 7 properties (SetAccess=public) 7 properties (SetAccess=public) 8 8 isclimatology = 0; 9 9 accumulation = NaN; 10 10 runoff = NaN; 11 11 evaporation = NaN; 12 requested_outputs = {}; 12 steps_per_step = 1; 13 requested_outputs = {}; 13 14 end 14 15 methods … … 36 37 if isnan(self.accumulation) 37 38 self.accumulation=zeros(md.mesh.numberofvertices,1); 38 disp(' 39 disp(' no smb.accumulation specified: values set as zero'); 39 40 end 40 41 if isnan(self.evaporation) 41 42 self.evaporation=zeros(md.mesh.numberofvertices,1); 42 disp(' 43 disp(' no smb.evaporation specified: values set as zero'); 43 44 end 44 45 if isnan(self.runoff) 45 46 self.runoff=zeros(md.mesh.numberofvertices,1); 46 disp(' 47 disp(' no smb.runoff specified: values set as zero'); 47 48 end 48 49 … … 52 53 if ismember('MasstransportAnalysis',analyses), 53 54 md = checkfield(md,'fieldname','smb.accumulation','timeseries',1,'NaN',1,'Inf',1); 55 md = checkfield(md,'fieldname','smb.runoff','timeseries',1,'NaN',1,'Inf',1); 56 md = checkfield(md,'fieldname','smb.evaporation','timeseries',1,'NaN',1,'Inf',1); 54 57 end 55 58 if ismember('BalancethicknessAnalysis',analyses), 56 59 md = checkfield(md,'fieldname','smb.accumulation','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 57 end58 if ismember('MasstransportAnalysis',analyses),59 md = checkfield(md,'fieldname','smb.runoff','timeseries',1,'NaN',1,'Inf',1);60 end61 if ismember('BalancethicknessAnalysis',analyses),62 60 md = checkfield(md,'fieldname','smb.runoff','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 63 end64 if ismember('MasstransportAnalysis',analyses),65 md = checkfield(md,'fieldname','smb.evaporation','timeseries',1,'NaN',1,'Inf',1);66 end67 if ismember('BalancethicknessAnalysis',analyses),68 61 md = checkfield(md,'fieldname','smb.evaporation','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 69 62 end 63 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 70 64 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1); 71 65 md = checkfield(md,'fieldname','smb.isclimatology','values',[0 1]); 72 66 if (self.isclimatology) 73 67 md = checkfield(md,'fieldname', 'smb.accumulation', 'size',[md.mesh.numberofvertices+1],... 74 'message',['accumulation must have md.mesh.numberofvertices+1 rows in order to force a climatology']);68 'message',['accumulation must have md.mesh.numberofvertices+1 rows in order to force a climatology']); 75 69 md = checkfield(md,'fieldname', 'smb.runoff', 'size',[md.mesh.numberofvertices+1],... 76 'message',['runoff must have md.mesh.numberofvertices+1 rows in order to force a climatology']);70 'message',['runoff must have md.mesh.numberofvertices+1 rows in order to force a climatology']); 77 71 md = checkfield(md,'fieldname', 'smb.evaporation', 'size',[md.mesh.numberofvertices+1],... 78 'message',['evaporation must have md.mesh.numberofvertices+1 rows in order to force a climatology']);72 'message',['evaporation must have md.mesh.numberofvertices+1 rows in order to force a climatology']); 79 73 end 80 74 end % }}} 81 75 function disp(self) % {{{ 82 disp(sprintf(' 76 disp(sprintf(' surface forcings parameters (SMB=accumulation-runoff-evaporation) :')); 83 77 fielddisplay(self,'accumulation','accumulated snow [m/yr ice eq]'); 84 78 fielddisplay(self,'runoff','amount of ice melt lost from the ice column [m/yr ice eq]'); 85 79 fielddisplay(self,'evaporation','amount of ice lost to evaporative processes [m/yr ice eq]'); 86 80 fielddisplay(self,'isclimatology','repeat all forcings when past last forcing time (default false)'); 81 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 87 82 fielddisplay(self,'requested_outputs','additional outputs requested'); 88 83 end % }}} … … 95 90 WriteData(fid,prefix,'object',self,'class','smb','fieldname','runoff','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 96 91 WriteData(fid,prefix,'object',self,'class','smb','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 97 92 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer'); 98 93 %process requested outputs 99 94 outputs = self.requested_outputs; 100 95 pos = find(ismember(outputs,'default')); 101 96 if ~isempty(pos), 102 outputs(pos) = []; 103 outputs 97 outputs(pos) = []; %remove 'default' from outputs 98 outputs = [outputs defaultoutputs(self,md)]; %add defaults 104 99 end 105 100 WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray'); -
issm/trunk-jpl/src/m/classes/SMBcomponents.py
r24213 r24240 18 18 self.evaporation = float('NaN') 19 19 self.isclimatology = 0 20 self.steps_per_step = 1 20 21 self.requested_outputs = [] 21 #}}}22 #}}} 22 23 23 24 def __repr__(self): # {{{ 24 string = " surface forcings parameters (SMB = accumulation - runoff -evaporation) :"25 string = "%s\n%s" % (string, fielddisplay(self, 'accumulation', 'accumulated snow [m /yr ice eq]'))26 string = "%s\n%s" % (string, fielddisplay(self, 'runoff', 'amount of ice melt lost from the ice column [m /yr ice eq]'))27 string = "%s\n%s" % (string, fielddisplay(self, 'evaporation', 'mount of ice lost to evaporative processes [m /yr ice eq]'))25 string = " surface forcings parameters (SMB = accumulation-runoff-evaporation) :" 26 string = "%s\n%s" % (string, fielddisplay(self, 'accumulation', 'accumulated snow [m/yr ice eq]')) 27 string = "%s\n%s" % (string, fielddisplay(self, 'runoff', 'amount of ice melt lost from the ice column [m/yr ice eq]')) 28 string = "%s\n%s" % (string, fielddisplay(self, 'evaporation', 'mount of ice lost to evaporative processes [m/yr ice eq]')) 28 29 string = "%s\n%s" % (string, fielddisplay(self, 'isclimatology', 'repeat all forcings when past last forcing time (default false)')) 30 string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 29 31 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 30 32 return string 31 #}}}33 #}}} 32 34 33 35 def extrude(self, md): # {{{ … … 61 63 if 'MasstransportAnalysis' in analyses: 62 64 md = checkfield(md, 'fieldname', 'smb.accumulation', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 63 65 md = checkfield(md, 'fieldname', 'smb.runoff', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 66 md = checkfield(md, 'fieldname', 'smb.evaporation', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 64 67 if 'BalancethicknessAnalysis' in analyses: 65 68 md = checkfield(md, 'fieldname', 'smb.accumulation', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 66 67 if 'MasstransportAnalysis' in analyses:68 md = checkfield(md, 'fieldname', 'smb.runoff', 'timeseries', 1, 'NaN', 1, 'Inf', 1)69 70 if 'BalancethicknessAnalysis' in analyses:71 69 md = checkfield(md, 'fieldname', 'smb.runoff', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 72 73 if 'MasstransportAnalysis' in analyses:74 md = checkfield(md, 'fieldname', 'smb.evaporation', 'timeseries', 1, 'NaN', 1, 'Inf', 1)75 76 if 'BalancethicknessAnalysis' in analyses:77 70 md = checkfield(md, 'fieldname', 'smb.evaporation', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 78 71 72 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 79 73 md = checkfield(md, 'fieldname', 'masstransport.requested_outputs', 'stringrow', 1) 80 74 md = checkfield(md, 'fieldname', 'smb.isclimatology', 'values', [0, 1]) … … 90 84 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'runoff', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 91 85 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'evaporation', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 92 86 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer') 93 87 #process requested outputs 94 88 outputs = self.requested_outputs -
issm/trunk-jpl/src/m/classes/SMBd18opdd.m
r22854 r24240 5 5 6 6 classdef SMBd18opdd 7 properties (SetAccess=public) 7 properties (SetAccess=public) 8 8 9 desfac = 0; 9 10 s0p = NaN; 10 11 s0t = NaN; 11 12 rlaps = 0; 12 rlapslgm = 0; 13 dpermil = 0; 13 rlapslgm = 0; 14 dpermil = 0; 14 15 f = 0; 15 16 Tdiff = NaN; … … 28 29 pddfac_snow = NaN; 29 30 pddfac_ice = NaN; 30 requested_outputs = {}; 31 steps_per_step = 1; 32 requested_outputs = {}; 31 33 end 32 34 methods … … 50 52 51 53 end % }}} 52 54 function list = defaultoutputs(self,md) % {{{ 53 55 54 56 list = {''}; … … 56 58 end % }}} 57 59 function self = initialize(self,md) % {{{ 58 60 59 61 if isnan(self.s0p), 60 61 62 self.s0p=zeros(md.mesh.numberofvertices,1); 63 disp(' no SMBd18opdd.s0p specified: values set as zero'); 62 64 end 63 65 if isnan(self.s0t), … … 69 71 function self = setdefaultparameters(self) % {{{ 70 72 71 72 73 74 75 76 77 78 79 80 81 73 self.ismungsm = 0; 74 self.isd18opd = 1; 75 self.istemperaturescaled = 1; 76 self.isprecipscaled = 1; 77 self.desfac = 0.5; 78 self.rlaps = 6.5; 79 self.rlapslgm = 6.5; 80 self.dpermil = 2.4; 81 self.f = 0.169; 82 self.issetpddfac = 0; 83 82 84 end % }}} 83 85 function md = checkconsistency(self,md,solution,analyses) % {{{ … … 89 91 md = checkfield(md,'fieldname','smb.rlaps','>=',0,'numel',1); 90 92 md = checkfield(md,'fieldname','smb.rlapslgm','>=',0,'numel',1); 91 if(self.isd18opd==1) 93 94 if(self.isd18opd==1) 92 95 md = checkfield(md,'fieldname','smb.temperatures_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1); 93 96 md = checkfield(md,'fieldname','smb.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1); … … 104 107 md = checkfield(md,'fieldname','smb.delta18o','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1); 105 108 md = checkfield(md,'fieldname','smb.dpermil','>=',0,'numel',1); 106 109 md = checkfield(md,'fieldname','smb.f','>=',0,'numel',1); 107 110 if(self.istemperaturescaled==0) 108 111 lent=size(self.temperatures_reconstructed,2); … … 121 124 end 122 125 end 126 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 123 127 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1); 124 128 end % }}} … … 133 137 fielddisplay(self,'s0t','should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]'); 134 138 fielddisplay(self,'rlaps','present day lapse rate [degree/km]'); 135 if(self.isd18opd==1) 139 if(self.isd18opd==1) 136 140 fielddisplay(self,'temperatures_presentday','monthly present day surface temperatures [K], required if delta18o/mungsm/d18opd is activated'); 137 141 fielddisplay(self,'precipitations_presentday','monthly surface precipitation [m/yr water eq], required if delta18o/mungsm/d18opd is activated'); … … 144 148 fielddisplay(self,'precipitations_reconstructed','monthly historical precipitation [m/yr water eq], required if delta18o/mungsm/d18opd is activated and isprecipscaled is not activated'); 145 149 end 146 fielddisplay(self,'delta18o','delta18o [per mil], required if pdd is activated and d18opd activated'); 147 fielddisplay(self,'dpermil','degree per mil, required if d18opd is activated'); 148 150 fielddisplay(self,'delta18o','delta18o [per mil], required if pdd is activated and d18opd activated'); 151 fielddisplay(self,'dpermil','degree per mil, required if d18opd is activated'); 152 fielddisplay(self,'f','precip/temperature scaling factor, required if d18opd is activated'); 149 153 end 150 154 if(self.issetpddfac==1) … … 152 156 fielddisplay(self,'pddfac_ice','Pdd factor for ice, at each vertex [mm ice equiv/day/degree C]'); 153 157 end 158 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 154 159 fielddisplay(self,'requested_outputs','additional outputs requested'); 155 160 % No need to display rlapslgm, Tdiff, ismungsm … … 173 178 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tdiff','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts); 174 179 WriteData(fid,prefix,'object',self,'class','smb','fieldname','sealev','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts); 180 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer'); 175 181 176 182 if self.isd18opd … … 181 187 WriteData(fid,prefix,'object',self,'class','smb','fieldname','delta18o','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts); 182 188 WriteData(fid,prefix,'object',self,'class','smb','fieldname','dpermil','format','Double'); 183 189 WriteData(fid,prefix,'object',self,'class','smb','fieldname','f','format','Double'); 184 190 if self.istemperaturescaled==0 185 191 WriteData(fid,prefix,'object',self,'class','smb','fieldname','temperatures_reconstructed','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); … … 193 199 WriteData(fid,prefix,'object',self,'class','smb','fieldname','pddfac_ice','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 194 200 end 195 201 196 202 %process requested outputs 197 203 outputs = self.requested_outputs; -
issm/trunk-jpl/src/m/classes/SMBd18opdd.py
r24213 r24240 13 13 SMBd18opdd = SMBd18opdd() 14 14 """ 15 16 15 def __init__(self): # {{{ 17 16 self.desfac = 0. … … 37 36 self.pddfac_snow = float('NaN') 38 37 self.pddfac_ice = float('NaN') 38 self.steps_per_step = 1 39 39 40 40 #set defaults … … 51 51 string = "%s\n%s" % (string, fielddisplay(self, 's0p', 'should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]')) 52 52 string = "%s\n%s" % (string, fielddisplay(self, 's0t', 'should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]')) 53 string = "%s\n%s" % (string, fielddisplay(self, 'rlaps', 'present day lapse rate [degree /km]'))54 if self.isd18opd: 55 string = "%s\n%s" % (string, fielddisplay(self, 'temperatures_presentday', 'monthly present day surface temperatures [K], required if delta18o /mungsm is activated'))56 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_presentday', 'monthly surface precipitation [m /yr water eq], required if delta18o or mungsm is activated'))53 string = "%s\n%s" % (string, fielddisplay(self, 'rlaps', 'present day lapse rate [degree/km]')) 54 if self.isd18opd: 55 string = "%s\n%s" % (string, fielddisplay(self, 'temperatures_presentday', 'monthly present day surface temperatures [K], required if delta18o/mungsm is activated')) 56 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_presentday', 'monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated')) 57 57 string = "%s\n%s" % (string, fielddisplay(self, 'istemperaturescaled', 'if delta18o parametrisation from present day temperature and precipitation is activated, is temperature scaled to delta18o value? (0 or 1, default is 1)')) 58 58 string = "%s\n%s" % (string, fielddisplay(self, 'isprecipscaled', 'if delta18o parametrisation from present day temperature and precipitation is activated, is precipitation scaled to delta18o value? (0 or 1, default is 1)')) 59 59 60 60 if self.istemperaturescaled == 0: 61 string = "%s\n%s" % (string, fielddisplay(self, 'temperatures_reconstructed', 'monthly historical surface temperatures [K], required if delta18o / mungsm /d18opd is activated and istemperaturescaled is not activated'))61 string = "%s\n%s" % (string, fielddisplay(self, 'temperatures_reconstructed', 'monthly historical surface temperatures [K], required if delta18o/mungsm/d18opd is activated and istemperaturescaled is not activated')) 62 62 63 63 if self.isprecipscaled == 0: 64 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_reconstructed', 'monthly historical precipitation [m / yr water eq], required if delta18o / mungsm /d18opd is activated and isprecipscaled is not activated'))64 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_reconstructed', 'monthly historical precipitation [m/yr water eq], required if delta18o/mungsm/d18opd is activated and isprecipscaled is not activated')) 65 65 66 66 string = "%s\n%s" % (string, fielddisplay(self, 'delta18o', 'delta18o [per mil], required if pdd is activated and delta18o activated')) … … 69 69 70 70 if self.issetpddfac == 1: 71 string = "%s\n%s" % (string, fielddisplay(self, 'pddfac_snow', 'Pdd factor for snow, at each vertex [mm ice equiv / day / degree C]')) 72 string = "%s\n%s" % (string, fielddisplay(self, 'pddfac_ice', 'Pdd factor for ice, at each vertex [mm ice equiv / day / degree C]')) 71 string = "%s\n%s" % (string, fielddisplay(self, 'pddfac_snow', 'Pdd factor for snow, at each vertex [mm ice equiv/day/degree C]')) 72 string = "%s\n%s" % (string, fielddisplay(self, 'pddfac_ice', 'Pdd factor for ice, at each vertex [mm ice equiv/day/degree C]')) 73 string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 73 74 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 74 75 … … 93 94 self.s0p = project3d(md, 'vector', self.s0p, 'type', 'node') 94 95 self.s0t = project3d(md, 'vector', self.s0t, 'type', 'node') 95 96 96 return self 97 97 #}}} … … 109 109 self.s0t = np.zeros((md.mesh.numberofvertices)) 110 110 print(" no SMBd18opdd.s0t specified: values set as zero") 111 112 111 return self 113 112 # }}} … … 135 134 md = checkfield(md, 'fieldname', 'smb.rlaps', '>=', 0, 'numel', [1]) 136 135 md = checkfield(md, 'fieldname', 'smb.rlapslgm', '>=', 0, 'numel', [1]) 136 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 137 137 138 138 if self.isd18opd: … … 163 163 164 164 md = checkfield(md, 'fieldname', 'masstransport.requested_outputs', 'stringrow', 1) 165 166 165 return md 167 166 # }}} … … 171 170 172 171 WriteData(fid, prefix, 'name', 'md.smb.model', 'data', 5, 'format', 'Integer') 173 174 172 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'ismungsm', 'format', 'Boolean') 175 173 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'isd18opd', 'format', 'Boolean') … … 182 180 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'Tdiff', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', md.constants.yts) 183 181 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'sealev', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', md.constants.yts) 182 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer') 184 183 185 184 if self.isd18opd: -
issm/trunk-jpl/src/m/classes/SMBforcing.m
r23814 r24240 5 5 6 6 classdef SMBforcing 7 properties (SetAccess=public) 8 isclimatology = 0; 9 mass_balance = NaN; 10 requested_outputs = {}; 7 properties (SetAccess=public) 8 isclimatology = 0; 9 mass_balance = NaN; 10 steps_per_step = 1; 11 requested_outputs = {}; 11 12 end 12 13 methods … … 57 58 md = checkfield(md,'fieldname','smb.mass_balance','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 58 59 end 60 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 59 61 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1); 60 62 md = checkfield(md,'fieldname','smb.isclimatology','values',[0 1]); 61 63 if (self.isclimatology) 62 64 md = checkfield(md,'fieldname', 'smb.mass_balance', 'size',[md.mesh.numberofvertices+1],... 63 'message',['mass_balance must have md.mesh.numberofvertices+1 rows in order to force a climatology']);65 'message',['mass_balance must have md.mesh.numberofvertices+1 rows in order to force a climatology']); 64 66 end 65 67 end % }}} … … 68 70 fielddisplay(self,'mass_balance','surface mass balance [m/yr ice eq]'); 69 71 fielddisplay(self,'isclimatology','repeat all forcings when past last forcing time (default false)'); 72 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 70 73 fielddisplay(self,'requested_outputs','additional outputs requested'); 71 74 end % }}} … … 77 80 WriteData(fid,prefix,'object',self,'class','smb','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 78 81 %WriteData(fid,prefix,'object',self,'class','smb','fieldname','mass_balance','format','CompressedMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 79 82 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer'); 83 80 84 %process requested outputs 81 85 outputs = self.requested_outputs; … … 90 94 end % }}} 91 95 function savemodeljs(self,fid,modelname) % {{{ 92 96 93 97 writejs1Darray(fid,[modelname '.smb.mass_balance'],self.mass_balance); 94 98 writejscellstring(fid,[modelname '.smb.requested_outputs'],self.requested_outputs); -
issm/trunk-jpl/src/m/classes/SMBforcing.py
r24213 r24240 18 18 self.requested_outputs = [] 19 19 self.isclimatology = 0 20 self.steps_per_step = 1 20 21 #}}} 21 22 22 23 def __repr__(self): # {{{ 23 24 string = " surface forcings parameters:" 24 string = "%s\n%s" % (string, fielddisplay(self, 'mass_balance', 'surface mass balance [m /yr ice eq]'))25 string = "%s\n%s" % (string, fielddisplay(self, 'mass_balance', 'surface mass balance [m/yr ice eq]')) 25 26 string = "%s\n%s" % (string, fielddisplay(self, 'isclimatology', 'repeat all forcings when past last forcing time (default false)')) 27 string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 26 28 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 27 29 return string … … 53 55 md = checkfield(md, 'fieldname', 'smb.mass_balance', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 54 56 57 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 55 58 md = checkfield(md, 'fieldname', 'masstransport.requested_outputs', 'stringrow', 1) 56 59 md = checkfield(md, 'fieldname', 'smb.isclimatology', 'values', [0, 1]) … … 61 64 # }}} 62 65 63 def marshall(self, prefix, md, fid): # {{{66 def marshall(self, prefix, md, fid): # {{{ 64 67 yts = md.constants.yts 65 66 68 WriteData(fid, prefix, 'name', 'md.smb.model', 'data', 1, 'format', 'Integer') 67 69 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'mass_balance', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 70 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer') 68 71 69 72 #process requested outputs -
issm/trunk-jpl/src/m/classes/SMBgemb.m
r24203 r24240 1 %SMBgemb Class definition. 2 % This is the class that hosts all the inputs for the Alberta Glacier Surface Mass Balance Model 1 %SMBgemb Class definition. 2 % This is the class that hosts all the inputs for the Alberta Glacier Surface Mass Balance Model 3 3 % Alex Gardner, University of Alberta. 4 % 4 % 5 5 % Usage: 6 6 % SMBgemb=SMBgemb(); 7 7 8 8 classdef SMBgemb 9 properties (SetAccess=public) 10 % {{{11 %each one of these properties is a transient forcing to the GEMB model, loaded from meteorological data derived 12 %from an automatic weather stations (AWS). Each property is therefore a matrix, of size (numberofvertices x number 9 properties (SetAccess=public) 10 % {{{ 11 %each one of these properties is a transient forcing to the GEMB model, loaded from meteorological data derived 12 %from an automatic weather stations (AWS). Each property is therefore a matrix, of size (numberofvertices x number 13 13 %of time steps. ) 14 14 … … 21 21 ismelt; 22 22 isdensification; 23 isturbulentflux; 23 isturbulentflux; 24 24 isclimatology; 25 25 26 %inputs: 26 %inputs: 27 27 Ta = NaN; %2 m air temperature, in Kelvin 28 28 V = NaN; %wind speed (m/s-1) … … 32 32 eAir = NaN; %screen level vapor pressure [Pa] 33 33 pAir = NaN; %surface pressure [Pa] 34 34 35 35 Tmean = NaN; %mean annual temperature [K] 36 36 Vmean = NaN; %mean annual wind velocity [m s-1] … … 42 42 aValue = NaN; %Albedo forcing at every element. Used only if aIdx == 0. 43 43 teValue = NaN; %Outward longwave radiation thermal emissivity forcing at every element (default in code is 1) 44 44 45 45 % Initialization of snow properties 46 46 Dzini = NaN; %cell depth (m) … … 55 55 Sizeini = NaN; %Number of layers 56 56 57 %settings: 57 %settings: 58 58 aIdx = NaN; %method for calculating albedo and subsurface absorption (default is 1) 59 60 61 62 63 59 % 0: direct input from aValue parameter 60 % 1: effective grain radius [Gardner & Sharp, 2009] 61 % 2: effective grain radius [Brun et al., 2009] 62 % 3: density and cloud amount [Greuell & Konzelmann, 1994] 63 % 4: exponential time decay & wetness [Bougamont & Bamber, 2005] 64 64 65 65 swIdx = NaN; % apply all SW to top grid cell (0) or allow SW to penetrate surface (1) (default 1) 66 66 67 67 denIdx = NaN; %densification model to use (default is 2): 68 69 70 71 72 73 74 75 76 dsnowIdx = NaN; %model for fresh snow accumulation density (default is 1): 77 78 79 80 81 82 68 % 1 = emperical model of Herron and Langway (1980) 69 % 2 = semi-emperical model of Anthern et al. (2010) 70 % 3 = DO NOT USE: physical model from Appendix B of Anthern et al. (2010) 71 % 4 = DO NOT USE: emperical model of Li and Zwally (2004) 72 % 5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008) 73 % 6 = Antarctica semi-emperical model of Ligtenberg et al. (2011) 74 % 7 = Greenland semi-emperical model of Kuipers Munneke et al. (2015) 75 76 dsnowIdx = NaN; %model for fresh snow accumulation density (default is 1): 77 % 0 = Original GEMB value, 150 kg/m^3 78 % 1 = Antarctica value of fresh snow density, 350 kg/m^3 79 % 2 = Greenland value of fresh snow density, 315 kg/m^3, Fausto et al. (2008) 80 % 3 = Antarctica model of Kaspers et al. (2004) 81 % 4 = Greenland model of Kuipers Munneke et al. (2015) 82 83 83 zTop = NaN; % depth over which grid length is constant at the top of the snopack (default 10) [m] 84 84 dzTop = NaN; % initial top vertical grid spacing (default .05) [m] 85 dzMin = NaN; % initial min vertical allowable grid spacing (default dzTop/2) [m] 85 dzMin = NaN; % initial min vertical allowable grid spacing (default dzMin/2) [m] 86 86 87 zY = NaN; % strech grid cells bellow top_z by a [top_dz * y ^ (cells bellow top_z)] 87 88 zMax = NaN; %initial max model depth (default is min(thickness,250)) [m] … … 89 90 outputFreq = NaN; %output frequency in days (default is monthly, 30) 90 91 91 %specific albedo parameters: 92 %Method 1 and 2: 92 %specific albedo parameters: 93 %Method 1 and 2: 93 94 aSnow = NaN; % new snow albedo (0.64 - 0.89) 94 95 aIce = NaN; % range 0.27-0.58 for old snow 95 %Method 3: Radiation Correction Factors -> only used for met station data and Greuell & Konzelmann, 1994 albedo96 %Method 3: Radiation Correction Factors -> only used for met station data and Greuell & Konzelmann, 1994 albedo 96 97 cldFrac = NaN; % average cloud amount 97 %Method 4: additonal tuning parameters albedo as a funtion of age and water content (Bougamont et al., 2005)98 t0wet = NaN; % time scale for wet snow (15-21.9) 99 t0dry = NaN; % warm snow timescale (30) 100 K = NaN; % time scale temperature coef. (7) 98 %Method 4: additonal tuning parameters albedo as a funtion of age and water content (Bougamont et al., 2005) 99 t0wet = NaN; % time scale for wet snow (15-21.9) 100 t0dry = NaN; % warm snow timescale (30) 101 K = NaN; % time scale temperature coef. (7) 101 102 adThresh = NaN; %Apply aIdx method to all areas with densities below this value, 102 103 %or else apply direct input value from aValue, allowing albedo to be altered. 103 104 %Default value is rho water (1023 kg m-3). 104 105 105 106 %densities: … … 108 109 %thermal: 109 110 ThermoDeltaTScaling= NaN; %scaling factor to multiply the thermal diffusion timestep (delta t) 110 111 112 steps_per_step = 1; 111 113 requested_outputs = {}; 112 114 113 %Several fields are missing from the standard GEMB model, which are capture intrinsically by ISSM. 114 %dateN: that's the last row of the above fields. 115 %dt: included in dateN. Not an input. 115 %Several fields are missing from the standard GEMB model, which are capture intrinsically by ISSM. 116 %dateN: that's the last row of the above fields. 117 %dt: included in dateN. Not an input. 116 118 %elev: this is taken from the ISSM surface itself. 117 119 … … 121 123 switch nargin 122 124 case 2 123 mesh=varargin{1}; 124 geometry=varargin{2}; 125 mesh=varargin{1}; 126 geometry=varargin{2}; 125 127 self=setdefaultparameters(self,mesh,geometry); 126 128 otherwise … … 152 154 function self = setdefaultparameters(self,mesh,geometry) % {{{ 153 155 154 self.isgraingrowth=1;155 self.isalbedo=1;156 self.isshortwave=1;157 self.isthermal=1;158 self.isaccumulation=1;159 self.ismelt=1;160 self.isdensification=1;161 self.isturbulentflux=1;162 self.isclimatology=0;163 164 self.aIdx = 1;165 self.swIdx = 1;166 self.denIdx = 2;167 self.dsnowIdx = 1;168 self.zTop=10*ones(mesh.numberofelements,1);169 self.dzTop = .05* ones (mesh.numberofelements,1);170 self.dzMin = self.dzTop/2;171 self.InitDensityScaling = 1.0;172 self.ThermoDeltaTScaling = 1/11;173 174 self.Vmean=10.0*ones(mesh.numberofelements,1);175 176 self.zMax=250*ones(mesh.numberofelements,1);177 self.zMin=130*ones(mesh.numberofelements,1);178 self.zY = 1.10*ones(mesh.numberofelements,1);179 self.outputFreq = 30;180 181 %additional albedo parameters182 self.aSnow = 0.85;183 self.aIce = 0.48;184 self.cldFrac = 0.1;185 self.t0wet = 15;186 self.t0dry = 30;187 self.K = 7;188 self.adThresh = 1023;189 190 self.teValue = ones(mesh.numberofelements,1);191 self.aValue = self.aSnow*ones(mesh.numberofelements,1);192 193 self.Dzini=0.05*ones(mesh.numberofelements,2);194 self.Dini=910.0*ones(mesh.numberofelements,2);195 self.Reini=2.5*ones(mesh.numberofelements,2);196 self.Gdnini=0.0*ones(mesh.numberofelements,2);197 self.Gspini=0.0*ones(mesh.numberofelements,2);198 self.ECini=0.0*ones(mesh.numberofelements,1);199 self.Wini=0.0*ones(mesh.numberofelements,2);200 self.Aini=self.aSnow*ones(mesh.numberofelements,2);201 self.Tini=273.15*ones(mesh.numberofelements,2);202 % /!\ Default value of Tini must be equal to Tmean but don't know Tmean yet (computed when atmospheric forcings are interpolated on mesh). 203 % If initialization without restart, this value will be overwritten when snow parameters are retrieved in Element.cpp 204 self.Sizeini=2*ones(mesh.numberofelements,1);156 self.isgraingrowth=1; 157 self.isalbedo=1; 158 self.isshortwave=1; 159 self.isthermal=1; 160 self.isaccumulation=1; 161 self.ismelt=1; 162 self.isdensification=1; 163 self.isturbulentflux=1; 164 self.isclimatology=0; 165 166 self.aIdx = 1; 167 self.swIdx = 1; 168 self.denIdx = 2; 169 self.dsnowIdx = 1; 170 self.zTop=10*ones(mesh.numberofelements,1); 171 self.dzTop = .05* ones (mesh.numberofelements,1); 172 self.dzMin = self.dzTop/2; 173 self.InitDensityScaling = 1.0; 174 self.ThermoDeltaTScaling = 1/11; 175 176 self.Vmean=10.0*ones(mesh.numberofelements,1); 177 178 self.zMax=250*ones(mesh.numberofelements,1); 179 self.zMin=130*ones(mesh.numberofelements,1); 180 self.zY = 1.10*ones(mesh.numberofelements,1); 181 self.outputFreq = 30; 182 183 %additional albedo parameters 184 self.aSnow = 0.85; 185 self.aIce = 0.48; 186 self.cldFrac = 0.1; 187 self.t0wet = 15; 188 self.t0dry = 30; 189 self.K = 7; 190 self.adThresh = 1023; 191 192 self.teValue = ones(mesh.numberofelements,1); 193 self.aValue = self.aSnow*ones(mesh.numberofelements,1); 194 195 self.Dzini=0.05*ones(mesh.numberofelements,2); 196 self.Dini=910.0*ones(mesh.numberofelements,2); 197 self.Reini=2.5*ones(mesh.numberofelements,2); 198 self.Gdnini=0.0*ones(mesh.numberofelements,2); 199 self.Gspini=0.0*ones(mesh.numberofelements,2); 200 self.ECini=0.0*ones(mesh.numberofelements,1); 201 self.Wini=0.0*ones(mesh.numberofelements,2); 202 self.Aini=self.aSnow*ones(mesh.numberofelements,2); 203 self.Tini=273.15*ones(mesh.numberofelements,2); 204 % /!\ Default value of Tini must be equal to Tmean but don't know Tmean yet (computed when atmospheric forcings are interpolated on mesh). 205 % If initialization without restart, this value will be overwritten when snow parameters are retrieved in Element.cpp 206 self.Sizeini=2*ones(mesh.numberofelements,1); 205 207 206 208 end % }}} … … 226 228 if (self.isclimatology) 227 229 md = checkfield(md,'fieldname', 'smb.Ta', 'size',[md.mesh.numberofelements+1],... 228 'message',['Ta must have md.mesh.numberofelements+1 rows in order to force a climatology']);230 'message',['Ta must have md.mesh.numberofelements+1 rows in order to force a climatology']); 229 231 md = checkfield(md,'fieldname', 'smb.V', 'size',[md.mesh.numberofelements+1],... 230 'message',['V must have md.mesh.numberofelements+1 rows in order to force a climatology']);232 'message',['V must have md.mesh.numberofelements+1 rows in order to force a climatology']); 231 233 md = checkfield(md,'fieldname', 'smb.dswrf', 'size',[md.mesh.numberofelements+1],... 232 'message',['dswrf must have md.mesh.numberofelements+1 rows in order to force a climatology']);234 'message',['dswrf must have md.mesh.numberofelements+1 rows in order to force a climatology']); 233 235 md = checkfield(md,'fieldname', 'smb.dlwrf', 'size',[md.mesh.numberofelements+1],... 234 'message',['dlwrf must have md.mesh.numberofelements+1 rows in order to force a climatology']);236 'message',['dlwrf must have md.mesh.numberofelements+1 rows in order to force a climatology']); 235 237 md = checkfield(md,'fieldname', 'smb.P', 'size',[md.mesh.numberofelements+1],... 236 'message',['P must have md.mesh.numberofelements+1 rows in order to force a climatology']);238 'message',['P must have md.mesh.numberofelements+1 rows in order to force a climatology']); 237 239 md = checkfield(md,'fieldname', 'smb.eAir', 'size',[md.mesh.numberofelements+1],... 238 'message',['eAir must have md.mesh.numberofelements+1 rows in order to force a climatology']);240 'message',['eAir must have md.mesh.numberofelements+1 rows in order to force a climatology']); 239 241 end 240 242 241 243 md = checkfield(md,'fieldname','smb.Tmean','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>',273-100,'<',273+100); %-100/100 celsius min/max value 242 md = checkfield(md,'fieldname','smb.C','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0); 244 md = checkfield(md,'fieldname','smb.C','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0); 243 245 md = checkfield(md,'fieldname','smb.Vmean','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0); 244 md = checkfield(md,'fieldname','smb.Tz','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0,'<=',5000); 245 md = checkfield(md,'fieldname','smb.Vz','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0,'<=',5000); 246 md = checkfield(md,'fieldname','smb.Tz','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0,'<=',5000); 247 md = checkfield(md,'fieldname','smb.Vz','size',[md.mesh.numberofelements 1],'NaN',1,'Inf',1,'>=',0,'<=',5000); 246 248 247 249 md = checkfield(md,'fieldname','smb.teValue','timeseries',1,'NaN',1,'Inf',1,'>=',0,'<=',1); … … 256 258 md = checkfield(md,'fieldname','smb.dzMin','NaN',1,'Inf',1,'>',0); 257 259 md = checkfield(md,'fieldname','smb.zY','NaN',1,'Inf',1,'>=',1); 258 md = checkfield(md,'fieldname','smb.outputFreq','NaN',1,'Inf',1,'>',0,'<',10*365); %10 years max 260 md = checkfield(md,'fieldname','smb.outputFreq','NaN',1,'Inf',1,'>',0,'<',10*365); %10 years max 259 261 md = checkfield(md,'fieldname','smb.InitDensityScaling','NaN',1,'Inf',1,'>=',0,'<=',1); 260 262 md = checkfield(md,'fieldname','smb.ThermoDeltaTScaling','NaN',1,'Inf',1,'>=',0,'<=',1); … … 280 282 error('SMBgemb consistency check error: zTop should be smaller than local ice thickness'); 281 283 end 284 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 282 285 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1); 283 286 284 287 end % }}} 285 288 function disp(self) % {{{ 286 289 287 290 disp(sprintf(' surface forcings for SMB GEMB model :')); 288 291 289 292 fielddisplay(self,'isgraingrowth','run grain growth module (default true)'); 290 293 fielddisplay(self,'isalbedo','run albedo module (default true)'); … … 319 322 fielddisplay(self,'adThresh',{'Apply aIdx method to all areas with densities below this value,','or else apply direct input value from aValue, allowing albedo to be altered.'}); 320 323 fielddisplay(self,'aIdx',{'method for calculating albedo and subsurface absorption (default is 1)',... 321 '0: direct input from aValue parameter',...322 '1: effective grain radius [Gardner & Sharp, 2009]',...323 '2: effective grain radius [Brun et al., 2009]',...324 '3: density and cloud amount [Greuell & Konzelmann, 1994]',...325 '4: exponential time decay & wetness [Bougamont & Bamber, 2005]'})324 '0: direct input from aValue parameter',... 325 '1: effective grain radius [Gardner & Sharp, 2009]',... 326 '2: effective grain radius [Brun et al., 2009]',... 327 '3: density and cloud amount [Greuell & Konzelmann, 1994]',... 328 '4: exponential time decay & wetness [Bougamont & Bamber, 2005]'}) 326 329 327 330 fielddisplay(self,'teValue','Outward longwave radiation thermal emissivity forcing at every element (default in code is 1)'); 328 331 329 332 %snow properties init 330 333 fielddisplay(self,'Dzini','Initial cell depth when restart [m]'); … … 338 341 fielddisplay(self,'Tini','Initial snow temperature when restart [K]'); 339 342 fielddisplay(self,'Sizeini','Initial number of layers when restart [K]'); 340 341 342 %additional albedo parameters: 343 344 345 %additional albedo parameters: 343 346 switch self.aIdx 344 case {0 5}345 fielddisplay(self,'aValue','Albedo forcing at every element. Used only if aIdx == {0,5}.');346 case {1 2}347 fielddisplay(self,'aSnow','new snow albedo (0.64 - 0.89)');348 fielddisplay(self,'aIce','albedo of ice (0.27-0.58)');349 case 3350 fielddisplay(self,'cldFrac','average cloud amount');351 case 4352 fielddisplay(self,'t0wet','time scale for wet snow (15-21.9) [d]');353 fielddisplay(self,'t0dry','warm snow timescale (30) [d]');354 fielddisplay(self,'K','time scale temperature coef. (7) [d]');347 case {0 5} 348 fielddisplay(self,'aValue','Albedo forcing at every element. Used only if aIdx == {0,5}.'); 349 case {1 2} 350 fielddisplay(self,'aSnow','new snow albedo (0.64 - 0.89)'); 351 fielddisplay(self,'aIce','albedo of ice (0.27-0.58)'); 352 case 3 353 fielddisplay(self,'cldFrac','average cloud amount'); 354 case 4 355 fielddisplay(self,'t0wet','time scale for wet snow (15-21.9) [d]'); 356 fielddisplay(self,'t0dry','warm snow timescale (30) [d]'); 357 fielddisplay(self,'K','time scale temperature coef. (7) [d]'); 355 358 end 356 359 357 360 fielddisplay(self,'swIdx','apply all SW to top grid cell (0) or allow SW to penetrate surface (1) [default 1]'); 358 361 fielddisplay(self,'denIdx',{'densification model to use (default is 2):',... 359 360 361 362 363 364 365 362 '1 = emperical model of Herron and Langway (1980)',... 363 '2 = semi-emperical model of Anthern et al. (2010)',... 364 '3 = DO NOT USE: physical model from Appendix B of Anthern et al. (2010)',... 365 '4 = DO NOT USE: emperical model of Li and Zwally (2004)',... 366 '5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)',... 367 '6 = Antarctica semi-emperical model of Ligtenberg et al. (2011)',... 368 '7 = Greenland semi-emperical model of Kuipers Munneke et al. (2015)'}); 366 369 fielddisplay(self,'dsnowIdx',{'model for fresh snow accumulation density (default is 1):',... 367 '0 = Original GEMB value, 150 kg/m^3',... 368 '1 = Antarctica value of fresh snow density, 350 kg/m^3',... 369 '2 = Greenland value of fresh snow density, 315 kg/m^3, Fausto et al. (2008)',... 370 '3 = Antarctica model of Kaspers et al. (2004), Make sure to set Vmean accurately',... 371 '4 = Greenland model of Kuipers Munneke et al. (2015)'}); 372 370 '0 = Original GEMB value, 150 kg/m^3',... 371 '1 = Antarctica value of fresh snow density, 350 kg/m^3',... 372 '2 = Greenland value of fresh snow density, 315 kg/m^3, Fausto et al. (2008)',... 373 '3 = Antarctica model of Kaspers et al. (2004), Make sure to set Vmean accurately',... 374 '4 = Greenland model of Kuipers Munneke et al. (2015)'}); 375 376 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 373 377 fielddisplay(self,'requested_outputs','additional outputs requested'); 374 375 378 379 376 380 end % }}} 377 381 function marshall(self,prefix,md,fid) % {{{ … … 380 384 381 385 WriteData(fid,prefix,'name','md.smb.model','data',8,'format','Integer'); 382 386 383 387 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isgraingrowth','format','Boolean'); 384 388 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isalbedo','format','Boolean'); … … 390 394 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isturbulentflux','format','Boolean'); 391 395 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isclimatology','format','Boolean'); 392 396 393 397 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Ta','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts); 394 398 WriteData(fid,prefix,'object',self,'class','smb','fieldname','V','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts); … … 397 401 WriteData(fid,prefix,'object',self,'class','smb','fieldname','P','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts); 398 402 WriteData(fid,prefix,'object',self,'class','smb','fieldname','eAir','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts); 399 WriteData(fid,prefix,'object',self,'class','smb','fieldname','pAir','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts); 403 WriteData(fid,prefix,'object',self,'class','smb','fieldname','pAir','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts); 400 404 401 405 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tmean','format','DoubleMat','mattype',2); … … 410 414 WriteData(fid,prefix,'object',self,'class','smb','fieldname','zMax','format','DoubleMat','mattype',2); 411 415 WriteData(fid,prefix,'object',self,'class','smb','fieldname','zMin','format','DoubleMat','mattype',2); 412 416 413 417 WriteData(fid,prefix,'object',self,'class','smb','fieldname','aIdx','format','Integer'); 414 418 WriteData(fid,prefix,'object',self,'class','smb','fieldname','swIdx','format','Integer'); … … 428 432 WriteData(fid,prefix,'object',self,'class','smb','fieldname','aValue','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts); 429 433 WriteData(fid,prefix,'object',self,'class','smb','fieldname','teValue','format','DoubleMat','mattype',2,'timeserieslength',md.mesh.numberofelements+1,'yts',md.constants.yts); 430 434 431 435 %snow properties init 432 436 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Dzini','format','DoubleMat','mattype',3); … … 440 444 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Tini','format','DoubleMat','mattype',3); 441 445 WriteData(fid,prefix,'object',self,'class','smb','fieldname','Sizeini','format','IntMat','mattype',2); 442 443 %figure out dt from forcings: 446 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer'); 447 %figure out dt from forcings: 444 448 time=self.Ta(end,:); %assume all forcings are on the same time step 445 449 dtime=diff(time,1); 446 450 dt=min(dtime); 447 451 448 452 WriteData(fid,prefix,'data',dt,'name','md.smb.dt','format','Double','scale',yts); 449 453 450 454 % Check if smb_dt goes evenly into transient core time step 451 455 if (mod(md.timestepping.time_step,dt) >= 1e-10) 452 453 end 454 456 error('smb_dt/dt = %f. The number of SMB time steps in one transient core time step has to be an an integer',md.timestepping.time_step/dt); 457 end 458 455 459 %process requested outputs 456 460 outputs = self.requested_outputs; -
issm/trunk-jpl/src/m/classes/SMBgemb.py
r24213 r24240 31 31 32 32 #inputs: 33 self.Ta = float('NaN') #2 m air temperature, in Kelvin34 self.V = float('NaN') #wind speed (m / s -1)35 self.dswrf = float('NaN') #downward shortwave radiation flux [W /m^2]36 self.dlwrf = float('NaN') #downward longwave radiation flux [W /m^2]37 self.P = float('NaN') #precipitation [mm w.e. / m^2]38 self.eAir = float('NaN') #screen level vapor pressure [Pa]39 self.pAir = float('NaN') #surface pressure [Pa]40 self.Tmean = float('NaN') #mean annual temperature [K]41 self.Vmean = float('NaN') #mean annual wind velocity [m s -1]42 self.C = float('NaN') #mean annual snow accumulation [kg m - 2 yr -1]43 self.Tz = float('NaN') #height above ground at which temperature (T) was sampled [m]44 self.Vz = float('NaN') #height above ground at which wind (V) was sampled [m]33 self.Ta = float('NaN') #2 m air temperature, in Kelvin 34 self.V = float('NaN') #wind speed (m/s-1) 35 self.dswrf = float('NaN') #downward shortwave radiation flux [W/m^2] 36 self.dlwrf = float('NaN') #downward longwave radiation flux [W/m^2] 37 self.P = float('NaN') #precipitation [mm w.e. / m^2] 38 self.eAir = float('NaN') #screen level vapor pressure [Pa] 39 self.pAir = float('NaN') #surface pressure [Pa] 40 self.Tmean = float('NaN') #mean annual temperature [K] 41 self.Vmean = float('NaN') #mean annual wind velocity [m s-1] 42 self.C = float('NaN') #mean annual snow accumulation [kg m-2 yr-1] 43 self.Tz = float('NaN') #height above ground at which temperature (T) was sampled [m] 44 self.Vz = float('NaN') #height above ground at which wind (V) eas sampled [m] 45 45 46 46 #optional inputs: … … 49 49 50 50 # Initialization of snow properties 51 self.Dzini = float('NaN') #cell depth (m)52 self.Dini = float('NaN') #snow density (kg m -3)53 self.Reini = float('NaN') #effective grain size (mm)54 self.Gdnini = float('NaN') #grain dricity (0 -1)55 self.Gspini = float('NaN') #grain sphericity (0 -1)56 self.ECini = float('NaN') #evaporation/condensation (kg m -2)57 self.Wini = float('NaN') #Water content (kg m -2)58 self.Aini = float('NaN') #albedo (0 -1)59 self.Tini = float('NaN') #snow temperature (K)51 self.Dzini = float('NaN') #cell depth (m) 52 self.Dini = float('NaN') #snow density (kg m-3) 53 self.Reini = float('NaN') #effective grain size (mm) 54 self.Gdnini = float('NaN') #grain dricity (0-1) 55 self.Gspini = float('NaN') #grain sphericity (0-1) 56 self.ECini = float('NaN') #evaporation/condensation (kg m-2) 57 self.Wini = float('NaN') #Water content (kg m-2) 58 self.Aini = float('NaN') #albedo (0-1) 59 self.Tini = float('NaN') #snow temperature (K) 60 60 self.Sizeini = float('NaN') #Number of layers 61 61 62 62 #settings: 63 self.aIdx = float('NaN') #method for calculating albedo and subsurface absorption (default is 1) 64 # 0: direct input from aValue parameter 65 # 1: effective grain radius [Gardner & Sharp, 2009] 66 # 2: effective grain radius [Brun et al., 2009] 67 # 3: density and cloud amount [Greuell & Konzelmann, 1994] 68 # 4: exponential time decay & wetness [Bougamont & Bamber, 2005] 69 # 5: ingest MODIS mode, direct input from aValue parameter applied to surface ice only 70 self.swIdx = float('NaN') # apply all SW to top grid cell (0) or allow SW to penetrate surface (1) (default 1) 71 self.denIdx = float('NaN') #densification model to use (default is 2): 72 # 1 = emperical model of Herron and Langway (1980) 73 # 2 = semi - emperical model of Anthern et al. (2010) 74 # 3 = DO NOT USE: physical model from Appix B of Anthern et al. (2010) 75 # 4 = DO NOT USE: emperical model of Li and Zwally (2004) 76 # 5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008) 77 # 6 = Antarctica semi - emperical model of Ligtenberg et al. (2011) 78 # 7 = Greenland semi - emperical model of Kuipers Munneke et al. (2015) 63 self.aIdx = float('NaN') #method for calculating albedo and subsurface absorption (default is 1) 64 self.swIdx = float('NaN') # apply all SW to top grid cell (0) or allow SW to penetrate surface (1) (default 1) 65 self.denIdx = float('NaN') #densification model to use (default is 2): 79 66 self.dsnowIdx = float('NaN') #model for fresh snow accumulation density (default is 1): 80 # 0 = Original GEMB value, 150 kg / m^3 81 # 1 = Antarctica value of fresh snow density, 350 kg / m^3 82 # 2 = Greenland value of fresh snow density, 315 kg / m^3, Fausto et al. (2008) 83 # 3 = Antarctica model of Kaspers et al. (2004) 84 # 4 = Greenland model of Kuipers Munneke et al. (2015) 85 86 self.zTop = float('NaN') # depth over which grid length is constant at the top of the snopack (default 10) [m] 87 self.dzTop = float('NaN') # initial top vertical grid spacing (default .05) [m] 88 self.dzMin = float('NaN') # initial min vertical allowable grid spacing (default dzTop / 2) [m] 89 self.zY = float('NaN') # strech grid cells bellow top_z by a [top_dz * y ^ (cells bellow top_z)] 90 self.zMax = float('NaN') #initial max model depth (default is min(thickness, 250)) [m] 91 self.zMin = float('NaN') #initial min model depth (default is min(thickness, 130)) [m] 92 self.outputFreq = float('NaN') #output frequency in days (default is monthly, 30) 67 self.zTop = float('NaN') # depth over which grid length is constant at the top of the snopack (default 10) [m] 68 self.dzTop = float('NaN') # initial top vertical grid spacing (default .05) [m] 69 self.dzMin = float('NaN') # initial min vertical allowable grid spacing (default dzMin/2) [m] 70 self.zY = float('NaN') # strech grid cells bellow top_z by a [top_dz * y ^ (cells bellow top_z)] 71 self.zMax = float('NaN') #initial max model depth (default is min(thickness, 500)) [m] 72 self.zMin = float('NaN') #initial min model depth (default is min(thickness, 30)) [m] 73 self.outputFreq = float('NaN') #output frequency in days (default is monthly, 30) 93 74 94 75 #specific albedo parameters: 95 76 #Method 1 and 2: 96 self.aSnow = float('NaN') # new snow albedo (0.64 - 0.89)97 self.aIce = float('NaN') # range 0.27 -0.58 for old snow98 #Method 3: Radiation Correction Factors - 77 self.aSnow = float('NaN') # new snow albedo (0.64 - 0.89) 78 self.aIce = float('NaN') # range 0.27-0.58 for old snow 79 #Method 3: Radiation Correction Factors -> only used for met station data and Greuell & Konzelmann, 1994 albedo 99 80 self.cldFrac = float('NaN') # average cloud amount 100 81 #Method 4: additonal tuning parameters albedo as a funtion of age and water content (Bougamont et al., 2005) 101 self.t0wet = float('NaN') # time scale for wet snow (15 -21.9)102 self.t0dry = float('NaN') # warm snow timescale (30)103 self.K = float('NaN') # time scale temperature coef. (7)82 self.t0wet = float('NaN') # time scale for wet snow (15-21.9) 83 self.t0dry = float('NaN') # warm snow timescale (30) 84 self.K = float('NaN') # time scale temperature coef. (7) 104 85 self.adThresh = float('NaN') # Apply aIdx method to all areas with densities below this value, 105 86 # or else apply direct input value from aValue, allowing albedo to be altered. 106 # Default value is rho water (1023 kg m -3).87 # Default value is rho water (1023 kg m-3). 107 88 108 89 #densities: 109 self.InitDensityScaling = float('NaN') #initial scaling factor multiplying the density of ice, which describes the density of the snowpack.90 self.InitDensityScaling = float('NaN') #initial scaling factor multiplying the density of ice, which describes the density of the snowpack. 110 91 111 92 #thermo: 112 93 self.ThermoDeltaTScaling = float('NaN') #scaling factor to multiply the thermal diffusion timestep (delta t) 113 94 95 self.steps_per_step = 1 114 96 self.requested_outputs = [] 115 97 116 #Several fields are missing from the standard GEMB model, which are capture intrinsically by ISSM. 117 #dateN: that's the last row of the above fields. 118 #dt: included in dateN. Not an input. 119 #elev: this is taken from the ISSM surface itself. 120 121 #}}} 98 #Several fields are missing from the standard GEMB model, which are capture intrinsically by ISSM. 99 #dateN: that's the last row of the above fields. 100 #dt: included in dateN. Not an input. 101 #elev: this is taken from the ISSM surface itself. 102 103 #}}} 104 122 105 123 106 def __repr__(self): # {{{ 124 107 #string = " surface forcings parameters:" 125 #string = " #s\n #s" % (string, fielddisplay(self, 'mass_balance', 'surface mass balance [m /yr ice eq]'))126 #string = " #s\n #s" %(string, fielddisplay(self, 'requested_outputs', 'additional outputs requested'))108 #string = "#s\n#s"%(string, fielddisplay(self, 'mass_balance', 'surface mass balance [m/yr ice eq]')) 109 #string = "#s\n#s"%(string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 127 110 string = ' surface forcings for SMB GEMB model :' 128 111 string = "%s\n%s" % (string, fielddisplay(self, 'issmbgradients', 'is smb gradients method activated (0 or 1, default is 0)')) … … 137 120 string = "%s\n%s" % (string, fielddisplay(self, 'isclimatology', 'repeat all forcings when past last forcing time (default false)')) 138 121 string = "%s\n%s" % (string, fielddisplay(self, 'Ta', '2 m air temperature, in Kelvin')) 139 string = "%s\n%s" % (string, fielddisplay(self, 'V', 'wind speed (m s -1)'))140 string = "%s\n%s" % (string, fielddisplay(self, 'dlwrf', 'downward shortwave radiation flux [W /m^2]'))141 string = "%s\n%s" % (string, fielddisplay(self, 'dswrf', 'downward longwave radiation flux [W /m^2]'))122 string = "%s\n%s" % (string, fielddisplay(self, 'V', 'wind speed (m s-1)')) 123 string = "%s\n%s" % (string, fielddisplay(self, 'dlwrf', 'downward shortwave radiation flux [W/m^2]')) 124 string = "%s\n%s" % (string, fielddisplay(self, 'dswrf', 'downward longwave radiation flux [W/m^2]')) 142 125 string = "%s\n%s" % (string, fielddisplay(self, 'P', 'precipitation [mm w.e. / m^2]')) 143 126 string = "%s\n%s" % (string, fielddisplay(self, 'eAir', 'screen level vapor pressure [Pa]')) 144 127 string = "%s\n%s" % (string, fielddisplay(self, 'pAir', 'surface pressure [Pa]')) 145 128 string = "%s\n%s" % (string, fielddisplay(self, 'Tmean', 'mean annual temperature [K]')) 146 string = "%s\n%s" % (string, fielddisplay(self, 'C', 'mean annual snow accumulation [kg m - 2 yr -1]'))147 string = "%s\n%s" % (string, fielddisplay(self, 'Vmean', 'mean annual wind velocity [m s - 1] (default 10 m /s)'))129 string = "%s\n%s" % (string, fielddisplay(self, 'C', 'mean annual snow accumulation [kg m-2 yr-1]')) 130 string = "%s\n%s" % (string, fielddisplay(self, 'Vmean', 'mean annual temperature [m s-1] (default 10 m/s)')) 148 131 string = "%s\n%s" % (string, fielddisplay(self, 'Tz', 'height above ground at which temperature (T) was sampled [m]')) 149 string = "%s\n%s" % (string, fielddisplay(self, 'Vz', 'height above ground at which wind (V) was sampled [m]'))132 string = "%s\n%s" % (string, fielddisplay(self, 'Vz', 'height above ground at which wind (V) eas sampled [m]')) 150 133 string = "%s\n%s" % (string, fielddisplay(self, 'zTop', 'depth over which grid length is constant at the top of the snopack (default 10) [m]')) 151 134 string = "%s\n%s" % (string, fielddisplay(self, 'dzTop', 'initial top vertical grid spacing (default .05) [m] ')) 152 string = "%s\n%s" % (string, fielddisplay(self, 'dzMin', 'initial min vertical allowable grid spacing (default dzMin /2) [m] '))135 string = "%s\n%s" % (string, fielddisplay(self, 'dzMin', 'initial min vertical allowable grid spacing (default dzMin/2) [m] ')) 153 136 string = "%s\n%s" % (string, fielddisplay(self, 'zMax', 'initial max model depth (default is min(thickness, 500)) [m]')) 154 137 string = "%s\n%s" % (string, fielddisplay(self, 'zMin', 'initial min model depth (default is min(thickness, 30)) [m]')) … … 167 150 #snow properties init 168 151 string = "%s\n%s" % (string, fielddisplay(self, 'Dzini', 'Initial cell depth when restart [m]')) 169 string = "%s\n%s" % (string, fielddisplay(self, 'Dini', 'Initial snow density when restart [kg m -3]'))152 string = "%s\n%s" % (string, fielddisplay(self, 'Dini', 'Initial snow density when restart [kg m-3]')) 170 153 string = "%s\n%s" % (string, fielddisplay(self, 'Reini', 'Initial grain size when restart [mm]')) 171 string = "%s\n%s" % (string, fielddisplay(self, 'Gdnini', 'Initial grain dricity when restart [ -]'))172 string = "%s\n%s" % (string, fielddisplay(self, 'Gspini', 'Initial grain sphericity when restart [ -]'))173 string = "%s\n%s" % (string, fielddisplay(self, 'ECini', 'Initial evaporation / condensation when restart [kg m -2]'))174 string = "%s\n%s" % (string, fielddisplay(self, 'Wini', 'Initial snow water content when restart [kg m -2]'))175 string = "%s\n%s" % (string, fielddisplay(self, 'Aini', 'Initial albedo when restart [ -]'))154 string = "%s\n%s" % (string, fielddisplay(self, 'Gdnini', 'Initial grain dricity when restart [-]')) 155 string = "%s\n%s" % (string, fielddisplay(self, 'Gspini', 'Initial grain sphericity when restart [-]')) 156 string = "%s\n%s" % (string, fielddisplay(self, 'ECini', 'Initial evaporation/condensation when restart [kg m-2]')) 157 string = "%s\n%s" % (string, fielddisplay(self, 'Wini', 'Initial snow water content when restart [kg m-2]')) 158 string = "%s\n%s" % (string, fielddisplay(self, 'Aini', 'Initial albedo when restart [-]')) 176 159 string = "%s\n%s" % (string, fielddisplay(self, 'Tini', 'Initial snow temperature when restart [K]')) 177 160 string = "%s\n%s" % (string, fielddisplay(self, 'Sizeini', 'Initial number of layers when restart [K]')) 178 161 179 162 #additional albedo parameters: 180 if isinstance(self.aIdx, list) or isinstance(self.aIdx, np.ndarray) and (self.aIdx == [1, 2] or (1 in self.aIdx and 2 in self.aIdx)):163 if isinstance(self.aIdx, (list, type(np.array([1, 2])))) and (self.aIdx == [1, 2] or (1 in self.aIdx and 2 in self.aIdx)): 181 164 string = "%s\n%s" % (string, fielddisplay(self, 'aSnow', 'new snow albedo (0.64 - 0.89)')) 182 string = "%s\n%s" % (string, fielddisplay(self, 'aIce', 'albedo of ice (0.27 -0.58)'))183 elif elf.aIdx == 0:165 string = "%s\n%s" % (string, fielddisplay(self, 'aIce', 'albedo of ice (0.27-0.58)')) 166 elif self.aIdx == 0: 184 167 string = "%s\n%s" % (string, fielddisplay(self, 'aValue', 'Albedo forcing at every element. Used only if aIdx == {0, 5}')) 185 elif elf.aIdx == 5:168 elif self.aIdx == 5: 186 169 string = "%s\n%s" % (string, fielddisplay(self, 'aValue', 'Albedo forcing at every element. Used only if aIdx == {0, 5}')) 187 170 elif self.aIdx == 3: 188 171 string = "%s\n%s" % (string, fielddisplay(self, 'cldFrac', 'average cloud amount')) 189 172 elif self.aIdx == 4: 190 string = "%s\n%s" % (string, fielddisplay(self, 't0wet', 'time scale for wet snow (15 -21.9) [d]'))173 string = "%s\n%s" % (string, fielddisplay(self, 't0wet', 'time scale for wet snow (15-21.9) [d]')) 191 174 string = "%s\n%s" % (string, fielddisplay(self, 't0dry', 'warm snow timescale (30) [d]')) 192 175 string = "%s\n%s" % (string, fielddisplay(self, 'K', 'time scale temperature coef. (7) [d]')) … … 195 178 string = "%s\n%s" % (string, fielddisplay(self, 'denIdx', ['densification model to use (default is 2):', 196 179 '1 = emperical model of Herron and Langway (1980)', 197 '2 = semi -emperical model of Anthern et al. (2010)',180 '2 = semi-emperical model of Anthern et al. (2010)', 198 181 '3 = DO NOT USE: physical model from Appix B of Anthern et al. (2010)', 199 182 '4 = DO NOT USE: emperical model of Li and Zwally (2004)', 200 183 '5 = DO NOT USE: modified emperical model (4) by Helsen et al. (2008)', 201 '6 = Antarctica semi -emperical model of Ligtenberg et al. (2011)',202 '7 = Greenland semi -emperical model of Kuipers Munneke et al. (2015)']))184 '6 = Antarctica semi-emperical model of Ligtenberg et al. (2011)', 185 '7 = Greenland semi-emperical model of Kuipers Munneke et al. (2015)'])) 203 186 string = "%s\n%s" % (string, fielddisplay(self, 'dsnowIdx', ['model for fresh snow accumulation density (default is 1):', 204 '0 = Original GEMB value, 150 kg /m^3',205 '1 = Antarctica value of fresh snow density, 350 kg /m^3',206 '2 = Greenland value of fresh snow density, 315 kg /m^3, Fausto et al. (2008)',187 '0 = Original GEMB value, 150 kg/m^3', 188 '1 = Antarctica value of fresh snow density, 350 kg/m^3', 189 '2 = Greenland value of fresh snow density, 315 kg/m^3, Fausto et al. (2008)', 207 190 '3 = Antarctica model of Kaspers et al. (2004), Make sure to set Vmean accurately', 208 191 '4 = Greenland model of Kuipers Munneke et al. (2015)'])) 192 string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 209 193 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 210 194 return string … … 247 231 self.denIdx = 2 248 232 self.dsnowIdx = 1 249 self.zTop = 10 * np.ones((mesh.numberofelements, 250 self.dzTop = .05 * np.ones((mesh.numberofelements, 233 self.zTop = 10 * np.ones((mesh.numberofelements,)) 234 self.dzTop = .05 * np.ones((mesh.numberofelements,)) 251 235 self.dzMin = self.dzTop / 2 252 236 self.InitDensityScaling = 1.0 253 237 self.ThermoDeltaTScaling = 1 / 11.0 254 238 255 self.Vmean = 10 * np.ones((mesh.numberofelements, 256 257 self.zMax = 250 * np.ones((mesh.numberofelements, 258 self.zMin = 130 * np.ones((mesh.numberofelements, 259 self.zY = 1.10 * np.ones((mesh.numberofelements, 239 self.Vmean = 10 * np.ones((mesh.numberofelements,)) 240 241 self.zMax = 250 * np.ones((mesh.numberofelements,)) 242 self.zMin = 130 * np.ones((mesh.numberofelements,)) 243 self.zY = 1.10 * np.ones((mesh.numberofelements,)) 260 244 self.outputFreq = 30 261 245 262 #additional albedo parameters246 #additional albedo parameters 263 247 self.aSnow = 0.85 264 248 self.aIce = 0.48 … … 269 253 self.adThresh = 1023 270 254 271 self.teValue = np.ones((mesh.numberofelements, 272 self.aValue = self.aSnow * np.ones(mesh.numberofelements, 255 self.teValue = np.ones((mesh.numberofelements,)) 256 self.aValue = self.aSnow * np.ones(mesh.numberofelements,) 273 257 274 258 self.Dzini = 0.05 * np.ones((mesh.numberofelements, 2)) … … 277 261 self.Gdnini = 0.0 * np.ones((mesh.numberofelements, 2)) 278 262 self.Gspini = 0.0 * np.ones((mesh.numberofelements, 2)) 279 self.ECini = 0.0 * np.ones((mesh.numberofelements, 263 self.ECini = 0.0 * np.ones((mesh.numberofelements,)) 280 264 self.Wini = 0.0 * np.ones((mesh.numberofelements, 2)) 281 265 self.Aini = self.aSnow * np.ones((mesh.numberofelements, 2)) 282 266 self.Tini = 273.15 * np.ones((mesh.numberofelements, 2)) 283 # /!\ Default value of Tini must be equal to Tmean but don't know Tmean yet (computed when atmospheric forcings are interpolated on mesh).284 #If initialization without restart, this value will be overwritten when snow parameters are retrieved in Element.cpp285 self.Sizeini = 2 * np.ones((mesh.numberofelements, 267 # /!\ Default value of Tini must be equal to Tmean but don't know Tmean yet (computed when atmospheric forcings are interpolated on mesh). 268 # If initialization without restart, this value will be overwritten when snow parameters are retrieved in Element.cpp 269 self.Sizeini = 2 * np.ones((mesh.numberofelements,)) 286 270 #}}} 287 271 288 def checkconsistency(self, md, solution, analyses): # {{{ 272 def checkconsistency(self, md, solution, analyses): # {{{ 273 289 274 md = checkfield(md, 'fieldname', 'smb.isgraingrowth', 'values', [0, 1]) 290 275 md = checkfield(md, 'fieldname', 'smb.isalbedo', 'values', [0, 1]) … … 297 282 md = checkfield(md, 'fieldname', 'smb.isclimatology', 'values', [0, 1]) 298 283 299 md = checkfield(md, 'fieldname', 'smb.Ta', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '>', 273 - 100, '<', 273 + 100) # - 100 / 100 celsius min /max value300 md = checkfield(md, 'fieldname', 'smb.V', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '> =', 0, '<', 45, 'size', np.shape(self.Ta)) #max 500 km /h301 md = checkfield(md, 'fieldname', 'smb.dswrf', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '> =', 0, '<=', 1400, 'size', np.shape(self.Ta))302 md = checkfield(md, 'fieldname', 'smb.dlwrf', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '> =', 0, 'size', np.shape(self.Ta))303 md = checkfield(md, 'fieldname', 'smb.P', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '> =', 0, '<=', 100, 'size', np.shape(self.Ta))284 md = checkfield(md, 'fieldname', 'smb.Ta', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '>', 273 - 100, '<', 273 + 100) #-100/100 celsius min/max value 285 md = checkfield(md, 'fieldname', 'smb.V', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '> = ', 0, '<', 45, 'size', np.shape(self.Ta)) #max 500 km/h 286 md = checkfield(md, 'fieldname', 'smb.dswrf', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '> = ', 0, '< = ', 1400, 'size', np.shape(self.Ta)) 287 md = checkfield(md, 'fieldname', 'smb.dlwrf', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '> = ', 0, 'size', np.shape(self.Ta)) 288 md = checkfield(md, 'fieldname', 'smb.P', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '> = ', 0, '< = ', 100, 'size', np.shape(self.Ta)) 304 289 md = checkfield(md, 'fieldname', 'smb.eAir', 'timeseries', 1, 'NaN', 1, 'Inf', 1, 'size', np.shape(self.Ta)) 305 290 306 291 if (self.isclimatology > 0): 307 md = checkfield(md, 'fieldname', 'smb.Ta', 'size', [md.mesh.numberofelements + 1], 'message', 'Ta must have md.mesh.numberofelements +1 rows in order to force a climatology')308 md = checkfield(md, 'fieldname', 'smb.V', 'size', [md.mesh.numberofelements + 1], 'message', 'V must have md.mesh.numberofelements +1 rows in order to force a climatology')309 md = checkfield(md, 'fieldname', 'smb.dswrf', 'size', [md.mesh.numberofelements + 1], 'message', 'dswrf must have md.mesh.numberofelements +1 rows in order to force a climatology')310 md = checkfield(md, 'fieldname', 'smb.dlwrf', 'size', [md.mesh.numberofelements + 1], 'message', 'dlwrf must have md.mesh.numberofelements +1 rows in order to force a climatology')311 md = checkfield(md, 'fieldname', 'smb.P', 'size', [md.mesh.numberofelements + 1], 'message', 'P must have md.mesh.numberofelements +1 rows in order to force a climatology')312 md = checkfield(md, 'fieldname', 'smb.eAir', 'size', [md.mesh.numberofelements + 1], 'message', 'eAir must have md.mesh.numberofelements +1 rows in order to force a climatology')313 314 md = checkfield(md, 'fieldname', 'smb.Tmean', 'size', [md.mesh.numberofelements], 'NaN', 1, 'Inf', 1, '>', 273 - 100, '<', 273 + 100) # - 100 / 100 celsius min /max value315 md = checkfield(md, 'fieldname', 'smb.C', 'size', [md.mesh.numberofelements], 'NaN', 1, 'Inf', 1, '> =', 0)316 md = checkfield(md, 'fieldname', 'smb.Vmean', 'size', [md.mesh.numberofelements], 'NaN', 1, 'Inf', 1, '> =', 0)317 md = checkfield(md, 'fieldname', 'smb.Tz', 'size', [md.mesh.numberofelements], 'NaN', 1, 'Inf', 1, '> =', 0, '<=', 5000)318 md = checkfield(md, 'fieldname', 'smb.Vz', 'size', [md.mesh.numberofelements], 'NaN', 1, 'Inf', 1, '> =', 0, '<=', 5000)292 md = checkfield(md, 'fieldname', 'smb.Ta', 'size', [md.mesh.numberofelements + 1], 'message', 'Ta must have md.mesh.numberofelements+1 rows in order to force a climatology') 293 md = checkfield(md, 'fieldname', 'smb.V', 'size', [md.mesh.numberofelements + 1], 'message', 'V must have md.mesh.numberofelements+1 rows in order to force a climatology') 294 md = checkfield(md, 'fieldname', 'smb.dswrf', 'size', [md.mesh.numberofelements + 1], 'message', 'dswrf must have md.mesh.numberofelements+1 rows in order to force a climatology') 295 md = checkfield(md, 'fieldname', 'smb.dlwrf', 'size', [md.mesh.numberofelements + 1], 'message', 'dlwrf must have md.mesh.numberofelements+1 rows in order to force a climatology') 296 md = checkfield(md, 'fieldname', 'smb.P', 'size', [md.mesh.numberofelements + 1], 'message', 'P must have md.mesh.numberofelements+1 rows in order to force a climatology') 297 md = checkfield(md, 'fieldname', 'smb.eAir', 'size', [md.mesh.numberofelements + 1], 'message', 'eAir must have md.mesh.numberofelements+1 rows in order to force a climatology') 298 299 md = checkfield(md, 'fieldname', 'smb.Tmean', 'size', [md.mesh.numberofelements], 'NaN', 1, 'Inf', 1, '>', 273 - 100, '<', 273 + 100) #-100/100 celsius min/max value 300 md = checkfield(md, 'fieldname', 'smb.C', 'size', [md.mesh.numberofelements], 'NaN', 1, 'Inf', 1, '> = ', 0) 301 md = checkfield(md, 'fieldname', 'smb.Vmean', 'size', [md.mesh.numberofelements], 'NaN', 1, 'Inf', 1, '> = ', 0) 302 md = checkfield(md, 'fieldname', 'smb.Tz', 'size', [md.mesh.numberofelements], 'NaN', 1, 'Inf', 1, '> = ', 0, '< = ', 5000) 303 md = checkfield(md, 'fieldname', 'smb.Vz', 'size', [md.mesh.numberofelements], 'NaN', 1, 'Inf', 1, '> = ', 0, '< = ', 5000) 319 304 320 305 md = checkfield(md, 'fieldname', 'smb.teValue', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '>=', 0, '<=', 1) … … 325 310 md = checkfield(md, 'fieldname', 'smb.dsnowIdx', 'NaN', 1, 'Inf', 1, 'values', [0, 1, 2, 3, 4]) 326 311 327 md = checkfield(md, 'fieldname', 'smb.zTop', 'NaN', 1, 'Inf', 1, '> =', 0)312 md = checkfield(md, 'fieldname', 'smb.zTop', 'NaN', 1, 'Inf', 1, '> = ', 0) 328 313 md = checkfield(md, 'fieldname', 'smb.dzTop', 'NaN', 1, 'Inf', 1, '>', 0) 329 314 md = checkfield(md, 'fieldname', 'smb.dzMin', 'NaN', 1, 'Inf', 1, '>', 0) 330 md = checkfield(md, 'fieldname', 'smb.zY', 'NaN', 1, 'Inf', 1, '> =', 1)315 md = checkfield(md, 'fieldname', 'smb.zY', 'NaN', 1, 'Inf', 1, '> = ', 1) 331 316 md = checkfield(md, 'fieldname', 'smb.outputFreq', 'NaN', 1, 'Inf', 1, '>', 0, '<', 10 * 365) #10 years max 332 md = checkfield(md, 'fieldname', 'smb.InitDensityScaling', 'NaN', 1, 'Inf', 1, '> =', 0, '<=', 1)333 md = checkfield(md, 'fieldname', 'smb.ThermoDeltaTScaling', 'NaN', 1, 'Inf', 1, '> =', 0, '<=', 1)317 md = checkfield(md, 'fieldname', 'smb.InitDensityScaling', 'NaN', 1, 'Inf', 1, '> = ', 0, '< = ', 1) 318 md = checkfield(md, 'fieldname', 'smb.ThermoDeltaTScaling', 'NaN', 1, 'Inf', 1, '> = ', 0, '< = ', 1) 334 319 md = checkfield(md, 'fieldname', 'smb.adThresh', 'NaN', 1, 'Inf', 1, '>=', 0) 335 320 336 if isinstance(self.aIdx, list) or isinstance(self.aIdx, np.ndarray) and (self.aIdx == [1, 2] or (1 in self.aIdx and 2 in self.aIdx)):337 md = checkfield(md, 'fieldname', 'smb.aSnow', 'NaN', 1, 'Inf', 1, '> =', .64, '<=', .89)338 md = checkfield(md, 'fieldname', 'smb.aIce', 'NaN', 1, 'Inf', 1, '> =', .27, '<=', .58)321 if isinstance(self.aIdx, (list, type(np.array([1, 2])))) and (self.aIdx == [1, 2] or (1 in self.aIdx and 2 in self.aIdx)): 322 md = checkfield(md, 'fieldname', 'smb.aSnow', 'NaN', 1, 'Inf', 1, '> = ', .64, '< = ', .89) 323 md = checkfield(md, 'fieldname', 'smb.aIce', 'NaN', 1, 'Inf', 1, '> = ', .27, '< = ', .58) 339 324 elif self.aIdx == 0: 340 325 md = checkfield(md, 'fieldname', 'smb.aValue', 'timeseries', 1, 'NaN', 1, 'Inf', 1, '>=', 0, '<=', 1) 341 326 elif self.aIdx == 3: 342 md = checkfield(md, 'fieldname', 'smb.cldFrac', 'NaN', 1, 'Inf', 1, '> =', 0, '<=', 1)327 md = checkfield(md, 'fieldname', 'smb.cldFrac', 'NaN', 1, 'Inf', 1, '> = ', 0, '< = ', 1) 343 328 elif self.aIdx == 4: 344 md = checkfield(md, 'fieldname', 'smb.t0wet', 'NaN', 1, 'Inf', 1, '> =', 15, '<=', 21.9)345 md = checkfield(md, 'fieldname', 'smb.t0dry', 'NaN', 1, 'Inf', 1, '> =', 30, '<=', 30)346 md = checkfield(md, 'fieldname', 'smb.K', 'NaN', 1, 'Inf', 1, '> =', 7, '<=', 7)329 md = checkfield(md, 'fieldname', 'smb.t0wet', 'NaN', 1, 'Inf', 1, '> = ', 15, '< = ', 21.9) 330 md = checkfield(md, 'fieldname', 'smb.t0dry', 'NaN', 1, 'Inf', 1, '> = ', 30, '< = ', 30) 331 md = checkfield(md, 'fieldname', 'smb.K', 'NaN', 1, 'Inf', 1, '> = ', 7, '< = ', 7) 347 332 348 333 #check zTop is < local thickness: 349 334 he = np.sum(md.geometry.thickness[md.mesh.elements - 1], axis=1) / np.size(md.mesh.elements, 1) 350 335 if np.any(he < self.zTop): 351 error('SMBgemb consistency check error: zTop should be smaller than local ice thickness')352 336 raise IOError('SMBgemb consistency check error: zTop should be smaller than local ice thickness') 337 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 353 338 md = checkfield(md, 'fieldname', 'smb.requested_outputs', 'stringrow', 1) 354 339 return md 355 340 # }}} 356 341 357 def marshall(self, prefix, md, fid): # {{{ 342 def marshall(self, prefix, md, fid): # {{{ 343 358 344 yts = md.constants.yts 359 345 … … 408 394 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'teValue', 'format', 'DoubleMat', 'mattype', 2, 'timeserieslength', md.mesh.numberofelements + 1, 'yts', yts) 409 395 410 #snow properties init396 #snow properties init 411 397 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'Dzini', 'format', 'DoubleMat', 'mattype', 3) 412 398 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'Dini', 'format', 'DoubleMat', 'mattype', 3) … … 419 405 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'Tini', 'format', 'DoubleMat', 'mattype', 3) 420 406 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'Sizeini', 'format', 'IntMat', 'mattype', 2) 421 422 #figure out dt from forcings:407 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer') 408 #figure out dt from forcings: 423 409 time = self.Ta[-1] #assume all forcings are on the same time step 424 410 dtime = np.diff(time, n=1, axis=0) … … 427 413 WriteData(fid, prefix, 'data', dt, 'name', 'md.smb.dt', 'format', 'Double', 'scale', yts) 428 414 429 # Check if smb_dt goes evenly into transient core time step415 # Check if smb_dt goes evenly into transient core time step 430 416 if (md.timestepping.time_step % dt >= 1e-10): 431 error('smb_dt/dt =#f. The number of SMB time steps in one transient core time step has to be an an integer', md.timestepping.time_step / dt)432 433 #process requested outputs417 raise IOError('smb_dt/dt = #f. The number of SMB time steps in one transient core time step has to be an an integer', md.timestepping.time_step / dt) 418 419 #process requested outputs 434 420 outputs = self.requested_outputs 435 421 indices = [i for i, x in enumerate(outputs) if x == 'default'] -
issm/trunk-jpl/src/m/classes/SMBgradients.m
r21049 r24240 5 5 6 6 classdef SMBgradients 7 properties (SetAccess=public) 8 href = NaN; 9 smbref = NaN; 10 b_pos = NaN; 11 b_neg = NaN; 12 requested_outputs = {}; 7 properties (SetAccess=public) 8 href = NaN; 9 smbref = NaN; 10 b_pos = NaN; 11 b_neg = NaN; 12 steps_per_step = 1; 13 requested_outputs = {}; 13 14 end 14 15 methods … … 47 48 md = checkfield(md,'fieldname','smb.b_neg','timeseries',1,'NaN',1,'Inf',1); 48 49 end 50 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 49 51 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1); 50 52 end % }}} … … 57 59 fielddisplay(self,'b_pos',' slope of hs - smb regression line for accumulation regime required if smb gradients is activated'); 58 60 fielddisplay(self,'b_neg',' slope of hs - smb regression line for ablation regime required if smb gradients is activated'); 61 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 59 62 fielddisplay(self,'requested_outputs','additional outputs requested'); 60 63 … … 68 71 WriteData(fid,prefix,'object',self,'class','smb','fieldname','smbref','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 69 72 WriteData(fid,prefix,'object',self,'class','smb','fieldname','b_pos','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 70 WriteData(fid,prefix,'object',self,'class','smb','fieldname','b_neg','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 71 73 WriteData(fid,prefix,'object',self,'class','smb','fieldname','b_neg','format','DoubleMat','mattype',1,'scale',1./yts, ... 74 'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 75 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer'); 76 72 77 %process requested outputs 73 78 outputs = self.requested_outputs; -
issm/trunk-jpl/src/m/classes/SMBgradients.py
r24213 r24240 9 9 10 10 Usage: 11 SMBgradients = SMBgradients() 11 SMBgradients = SMBgradients(); 12 12 """ 13 13 … … 17 17 self.b_pos = float('NaN') 18 18 self.b_neg = float('NaN') 19 self.steps_per_step = 1 19 20 self.requested_outputs = [] 20 21 #}}} … … 28 29 string = "%s\n%s" % (string, fielddisplay(self, 'b_pos', ' slope of hs - smb regression line for accumulation regime required if smb gradients is activated')) 29 30 string = "%s\n%s" % (string, fielddisplay(self, 'b_neg', ' slope of hs - smb regression line for ablation regime required if smb gradients is activated')) 31 string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 30 32 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 31 33 … … 47 49 #}}} 48 50 49 def checkconsistency(self, md, solution, analyses): # {{{51 def checkconsistency(self, md, solution, analyses): # {{{ 50 52 if 'MasstransportAnalysis' in analyses: 51 53 md = checkfield(md, 'fieldname', 'smb.href', 'timeseries', 1, 'NaN', 1, 'Inf', 1) … … 54 56 md = checkfield(md, 'fieldname', 'smb.b_neg', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 55 57 58 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 56 59 md = checkfield(md, 'fieldname', 'masstransport.requested_outputs', 'stringrow', 1) 57 60 return md 58 61 # }}} 59 62 60 def marshall(self, prefix, md, fid): # {{{63 def marshall(self, prefix, md, fid): # {{{ 61 64 yts = md.constants.yts 62 65 63 66 WriteData(fid, prefix, 'name', 'md.smb.model', 'data', 6, 'format', 'Integer') 64 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'href', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)67 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'href', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 65 68 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'smbref', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 66 69 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'b_pos', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 67 70 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'b_neg', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 71 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer') 68 72 69 #process requested outputs73 #process requested outputs 70 74 outputs = self.requested_outputs 71 75 indices = [i for i, x in enumerate(outputs) if x == 'default'] -
issm/trunk-jpl/src/m/classes/SMBgradientscomponents.m
r23365 r24240 6 6 classdef SMBgradientscomponents 7 7 properties (SetAccess=public) 8 accuref = NaN; 9 accualti = NaN; 10 accugrad = NaN; 11 runoffref = NaN; 12 runoffalti = NaN; 13 runoffgrad = NaN; 8 9 accuref = NaN; 10 accualti = NaN; 11 accugrad = NaN; 12 runoffref = NaN; 13 runoffalti = NaN; 14 runoffgrad = NaN; 15 steps_per_step = 1; 14 16 requested_outputs = {}; 15 17 end … … 51 53 md = checkfield(md,'fieldname','smb.runoffgrad','numel',1,'NaN',1,'Inf',1); 52 54 end 55 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 53 56 md = checkfield(md,'fieldname','masstransport.requested_outputs','stringrow',1); 54 57 end % }}} … … 63 66 fielddisplay(self,'runoffalti',' Altitude at which the runoff is equal to the reference value'); 64 67 fielddisplay(self,'runoffgrad',' Gradient of the variation of the runoff (0 for uniform runoff) m w.e. m-1 y-1 (lpase rate times ddf)'); 68 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 65 69 fielddisplay(self,'requested_outputs','additional outputs requested'); 66 70 … … 75 79 WriteData(fid,prefix,'object',self,'class','smb','fieldname','runoffalti','format','Double'); 76 80 WriteData(fid,prefix,'object',self,'class','smb','fieldname','runoffgrad', ... 77 'format','Double','scale',1./md.constants.yts); 81 'format','Double','scale',1./md.constants.yts); 82 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer'); 83 78 84 79 85 %process requested outputs -
issm/trunk-jpl/src/m/classes/SMBgradientscomponents.py
r24213 r24240 9 9 10 10 Usage: 11 SMBgradients = SMBgradientscomponents() 12 For now it has accumulation, runoff ans retention which could be aither refreezing and /or evaporation11 SMBgradients = SMBgradientscomponents(); 12 For now it has accumulation, runoff ans retention which could be aither refreezing and/or evaporation 13 13 """ 14 14 … … 20 20 self.runoffalti = float('NaN') 21 21 self.runoffgrad = float('NaN') 22 self.steps_per_step = 1 22 23 self.requested_outputs = ['default'] 23 24 #}}} … … 28 29 string = "%s\n%s" % (string, fielddisplay(self, 'accualti', ' Altitude at which the accumulation is equal to the reference value')) 29 30 string = "%s\n%s" % (string, fielddisplay(self, 'accugrad', ' Gradient of the variation of the accumulation (0 for uniform accumulation)')) 30 string = "%s\n%s" % (string, fielddisplay(self, 'runoffref', ' reference value of the runoff m w.e. y -1 (temperature times ddf)'))31 string = "%s\n%s" % (string, fielddisplay(self, 'runoffref', ' reference value of the runoff m w.e. y-1 (temperature times ddf)')) 31 32 string = "%s\n%s" % (string, fielddisplay(self, 'runoffalti', ' Altitude at which the runoff is equal to the reference value')) 32 string = "%s\n%s" % (string, fielddisplay(self, 'runoffgrad', ' Gradient of the variation of the runoff (0 for uniform runoff) m w.e. m - 1 y - 1 (lpase rate times ddf)')) 33 string = "%s\n%s" % (string, fielddisplay(self, 'runoffgrad', ' Gradient of the variation of the runoff (0 for uniform runoff) m w.e. m-1 y-1 (lapse rate times ddf)')) 34 string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 33 35 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 34 36 … … 42 44 43 45 def defaultoutputs(self, md): # {{{ 44 return ['SmbMassBalance', 'SmbRunoff'] 46 list = ['SmbMassBalance', 'SmbRunoff'] 47 if self.steps_per_step > 1: 48 list.extend(['SmbMassBalanceSubstep', 'SmbRunoffSubstep']) 49 return list 45 50 #}}} 46 51 … … 58 63 md = checkfield(md, 'fieldname', 'smb.runoffalti', 'numel', [1], 'NaN', 1, 'Inf', 1) 59 64 md = checkfield(md, 'fieldname', 'smb.runoffgrad', 'numel', [1], 'NaN', 1, 'Inf', 1) 65 66 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 60 67 md = checkfield(md, 'fieldname', 'masstransport.requested_outputs', 'stringrow', 1) 61 68 return md 62 69 # }}} 63 70 64 def marshall(self, prefix, md, fid): # {{{71 def marshall(self, prefix, md, fid): # {{{ 65 72 yts = md.constants.yts 66 73 WriteData(fid, prefix, 'name', 'md.smb.model', 'data', 11, 'format', 'Integer') 67 74 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'accuref', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', yts, 'scale', 1. / yts) 68 75 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'accualti', 'format', 'Double') 69 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'accugrad', 'format', 'Double', 'scale', 1. / yts)76 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'accugrad', 'format', 'Double', 'scale', 1. / md.constants.yts) 70 77 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'runoffref', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', yts, 'scale', 1. / yts) 71 78 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'runoffalti', 'format', 'Double') 72 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'runoffgrad', 'format', 'Double', 'scale', 1. / yts) 79 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'runoffgrad', 'format', 'Double', 'scale', 1. / md.constants.yts) 80 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer') 73 81 74 #process requested outputs82 #process requested outputs 75 83 outputs = self.requested_outputs 76 84 indices = [i for i, x in enumerate(outputs) if x == 'default'] -
issm/trunk-jpl/src/m/classes/SMBgradientsela.m
r21470 r24240 5 5 6 6 classdef SMBgradientsela 7 properties (SetAccess=public) 8 ela = NaN; 9 b_pos = NaN; 10 b_neg = NaN; 11 b_max = NaN; 12 b_min = NaN; 13 requested_outputs = {}; 7 properties (SetAccess=public) 8 ela = NaN; 9 b_pos = NaN; 10 b_neg = NaN; 11 b_max = NaN; 12 b_min = NaN; 13 steps_per_step = 1; 14 requested_outputs = {}; 14 15 end 15 16 methods … … 24 25 function self = extrude(self,md) % {{{ 25 26 26 27 %Nothing for now 27 28 28 29 end % }}} … … 32 33 function self = initialize(self,md) % {{{ 33 34 34 35 %Nothing done for now 35 36 36 37 end % }}} … … 50 51 md = checkfield(md,'fieldname','smb.b_min','timeseries',1,'NaN',1,'Inf',1); 51 52 end 53 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 52 54 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1); 53 55 end % }}} … … 61 63 fielddisplay(self,'b_max',' upper cap on smb rate, default: 9999 (no cap) [m ice eq./yr] '); 62 64 fielddisplay(self,'b_min',' lower cap on smb rate, default: -9999 (no cap) [m ice eq./yr]'); 65 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 63 66 fielddisplay(self,'requested_outputs','additional outputs requested'); 64 67 … … 73 76 WriteData(fid,prefix,'object',self,'class','smb','fieldname','b_neg','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 74 77 WriteData(fid,prefix,'object',self,'class','smb','fieldname','b_max','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 75 WriteData(fid,prefix,'object',self,'class','smb','fieldname','b_min','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 76 78 WriteData(fid,prefix,'object',self,'class','smb','fieldname','b_min','format','DoubleMat','mattype',1,'scale',1./yts, ... 79 'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 80 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer'); 81 77 82 %process requested outputs 78 83 outputs = self.requested_outputs; -
issm/trunk-jpl/src/m/classes/SMBgradientsela.py
r24213 r24240 18 18 self.b_max = float('NaN') 19 19 self.b_min = float('NaN') 20 self.steps_per_step = 1 20 21 self.requested_outputs = [] 21 22 self.setdefaultparameters() … … 27 28 28 29 string = "%s\n%s" % (string, fielddisplay(self, 'ela', ' equilibrium line altitude from which deviation is used to calculate smb using the smb gradients ela method [m a.s.l.]')) 29 string = "%s\n%s" % (string, fielddisplay(self, 'b_pos', ' vertical smb gradient (dB / dz) above ela')) 30 string = "%s\n%s" % (string, fielddisplay(self, 'b_neg', ' vertical smb gradient (dB / dz) below ela')) 31 string = "%s\n%s" % (string, fielddisplay(self, 'b_max', ' upper cap on smb rate, default: 9999 (no cap) [m ice eq. / yr]')) 32 string = "%s\n%s" % (string, fielddisplay(self, 'b_min', ' lower cap on smb rate, default: - 9999 (no cap) [m ice eq. / yr]')) 30 string = "%s\n%s" % (string, fielddisplay(self, 'b_pos', ' vertical smb gradient (dB/dz) above ela')) 31 string = "%s\n%s" % (string, fielddisplay(self, 'b_neg', ' vertical smb gradient (dB/dz) below ela')) 32 string = "%s\n%s" % (string, fielddisplay(self, 'b_max', ' upper cap on smb rate, default: 9999 (no cap) [m ice eq./yr]')) 33 string = "%s\n%s" % (string, fielddisplay(self, 'b_min', ' lower cap on smb rate, default: -9999 (no cap) [m ice eq./yr]')) 34 string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 33 35 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 34 35 36 return string 36 37 #}}} … … 56 57 #}}} 57 58 58 def checkconsistency(self, md, solution, analyses): # {{{59 def checkconsistency(self, md, solution, analyses): # {{{ 59 60 if 'MasstransportAnalysis' in analyses: 60 61 md = checkfield(md, 'fieldname', 'smb.ela', 'timeseries', 1, 'NaN', 1, 'Inf', 1) … … 64 65 md = checkfield(md, 'fieldname', 'smb.b_min', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 65 66 67 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 66 68 md = checkfield(md, 'fieldname', 'smb.requested_outputs', 'stringrow', 1) 67 69 return md 68 70 # }}} 71 def marshall(self, prefix, md, fid): # {{{ 69 72 70 def marshall(self, prefix, md, fid): # {{{71 73 yts = md.constants.yts 72 74 73 75 WriteData(fid, prefix, 'name', 'md.smb.model', 'data', 9, 'format', 'Integer') 74 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'ela', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)76 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'ela', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 75 77 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'b_pos', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 76 78 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'b_neg', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 77 79 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'b_max', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 78 80 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'b_min', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 81 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer') 79 82 80 #process requested outputs83 #process requested outputs 81 84 outputs = self.requested_outputs 82 85 indices = [i for i, x in enumerate(outputs) if x == 'default'] -
issm/trunk-jpl/src/m/classes/SMBhenning.m
r21148 r24240 5 5 6 6 classdef SMBhenning 7 properties (SetAccess=public) 7 properties (SetAccess=public) 8 8 smbref = NaN; 9 steps_per_step=1; 9 10 requested_outputs = {}; 10 11 end … … 16 17 inputstruct=varargin{1}; 17 18 list1 = properties('SMBhenning'); 18 list2 = fieldnames(inputstruct); 19 for i=1:length(list1) 20 fieldname = list1{i}; 21 if ismember(fieldname,list2), 22 self.(fieldname) = inputstruct.(fieldname); 19 list2 = fieldnames(inputstruct); 20 for i=1:length(list1) 21 fieldname = list1{i}; 22 if ismember(fieldname,list2), 23 self.(fieldname) = inputstruct.(fieldname); 24 end 23 25 end 24 end25 26 otherwise 26 27 error('constructor not supported'); … … 51 52 md = checkfield(md,'fieldname','smb.smbref','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 52 53 end 54 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 53 55 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1); 54 56 end % }}} … … 56 58 disp(sprintf(' surface forcings parameters:')); 57 59 fielddisplay(self,'smbref','reference smb from which deviation is calculated [m/yr ice eq]'); 60 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 58 61 fielddisplay(self,'requested_outputs','additional outputs requested'); 59 62 end % }}} … … 64 67 WriteData(fid,prefix,'name','md.smb.model','data',7,'format','Integer'); 65 68 WriteData(fid,prefix,'object',self,'class','smb','fieldname','smbref','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 66 69 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer'); 70 67 71 %process requested outputs 68 72 outputs = self.requested_outputs; -
issm/trunk-jpl/src/m/classes/SMBmeltcomponents.m
r23814 r24240 5 5 6 6 classdef SMBmeltcomponents 7 properties (SetAccess=public) 7 properties (SetAccess=public) 8 8 isclimatology = 0; 9 9 accumulation = NaN; … … 11 11 melt = NaN; 12 12 refreeze = NaN; 13 steps_per_step=1; 13 14 requested_outputs = {}; 14 15 end … … 56 57 if ismember('MasstransportAnalysis',analyses), 57 58 md = checkfield(md,'fieldname','smb.accumulation','timeseries',1,'NaN',1,'Inf',1); 59 md = checkfield(md,'fieldname','smb.evaporation','timeseries',1,'NaN',1,'Inf',1); 60 md = checkfield(md,'fieldname','smb.refreeze','timeseries',1,'NaN',1,'Inf',1); 61 md = checkfield(md,'fieldname','smb.melt','timeseries',1,'NaN',1,'Inf',1); 58 62 end 59 63 if ismember('BalancethicknessAnalysis',analyses), 60 64 md = checkfield(md,'fieldname','smb.accumulation','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 61 end62 if ismember('MasstransportAnalysis',analyses),63 md = checkfield(md,'fieldname','smb.evaporation','timeseries',1,'NaN',1,'Inf',1);64 end65 if ismember('BalancethicknessAnalysis',analyses),66 65 md = checkfield(md,'fieldname','smb.evaporation','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 67 end68 if ismember('MasstransportAnalysis',analyses),69 md = checkfield(md,'fieldname','smb.refreeze','timeseries',1,'NaN',1,'Inf',1);70 end71 if ismember('BalancethicknessAnalysis',analyses),72 66 md = checkfield(md,'fieldname','smb.refreeze','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 73 end74 if ismember('MasstransportAnalysis',analyses),75 md = checkfield(md,'fieldname','smb.melt','timeseries',1,'NaN',1,'Inf',1);76 end77 if ismember('BalancethicknessAnalysis',analyses),78 67 md = checkfield(md,'fieldname','smb.melt','size',[md.mesh.numberofvertices 1],'NaN',1,'Inf',1); 79 68 end 69 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 80 70 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1); 81 71 md = checkfield(md,'fieldname','smb.isclimatology','values',[0 1]); 82 72 if (self.isclimatology) 83 73 md = checkfield(md,'fieldname', 'smb.accumulation', 'size',[md.mesh.numberofvertices+1],... 84 'message',['accumulation must have md.mesh.numberofvertices+1 rows in order to force a climatology']);74 'message',['accumulation must have md.mesh.numberofvertices+1 rows in order to force a climatology']); 85 75 md = checkfield(md,'fieldname', 'smb.melt', 'size',[md.mesh.numberofvertices+1],... 86 'message',['melt must have md.mesh.numberofvertices+1 rows in order to force a climatology']);76 'message',['melt must have md.mesh.numberofvertices+1 rows in order to force a climatology']); 87 77 md = checkfield(md,'fieldname', 'smb.refreeze', 'size',[md.mesh.numberofvertices+1],... 88 'message',['refreeze must have md.mesh.numberofvertices+1 rows in order to force a climatology']);78 'message',['refreeze must have md.mesh.numberofvertices+1 rows in order to force a climatology']); 89 79 md = checkfield(md,'fieldname', 'smb.evaporation', 'size',[md.mesh.numberofvertices+1],... 90 'message',['evaporation must have md.mesh.numberofvertices+1 rows in order to force a climatology']);80 'message',['evaporation must have md.mesh.numberofvertices+1 rows in order to force a climatology']); 91 81 end 92 82 end % }}} … … 98 88 fielddisplay(self,'refreeze','amount of ice melt refrozen in ice column [m/yr ice eq]'); 99 89 fielddisplay(self,'isclimatology','repeat all forcings when past last forcing time (default false)'); 90 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 100 91 fielddisplay(self,'requested_outputs','additional outputs requested'); 101 92 end % }}} … … 109 100 WriteData(fid,prefix,'object',self,'class','smb','fieldname','melt','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 110 101 WriteData(fid,prefix,'object',self,'class','smb','fieldname','refreeze','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 111 102 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer'); 103 112 104 %process requested outputs 113 105 outputs = self.requested_outputs; -
issm/trunk-jpl/src/m/classes/SMBmeltcomponents.py
r24213 r24240 10 10 11 11 Usage: 12 SMBmeltcomponents = SMBmeltcomponents() 12 SMBmeltcomponents = SMBmeltcomponents(); 13 13 """ 14 14 … … 18 18 self.evaporation = float('NaN') 19 19 self.isclimatology = 0 20 self.steps_per_step = 1 20 21 self.requested_outputs = [] 21 22 #}}} 22 23 23 24 def __repr__(self): # {{{ 24 string = " surface forcings parameters with melt (SMB = accumulation - evaporation - melt +refreeze) :"25 string = "%s\n%s" % (string, fielddisplay(self, 'accumulation', 'accumulated snow [m /yr ice eq]'))26 string = "%s\n%s" % (string, fielddisplay(self, 'evaporation', 'mount of ice lost to evaporative processes [m /yr ice eq]'))27 string = "%s\n%s" % (string, fielddisplay(self, 'melt', 'amount of ice melt in the ice column [m /yr ice eq]'))28 string = "%s\n%s" % (string, fielddisplay(self, 'refreeze', 'amount of ice melt refrozen in the ice column [m /yr ice eq]'))25 string = " surface forcings parameters with melt (SMB = accumulation-evaporation-melt+refreeze) :" 26 string = "%s\n%s" % (string, fielddisplay(self, 'accumulation', 'accumulated snow [m/yr ice eq]')) 27 string = "%s\n%s" % (string, fielddisplay(self, 'evaporation', 'mount of ice lost to evaporative processes [m/yr ice eq]')) 28 string = "%s\n%s" % (string, fielddisplay(self, 'melt', 'amount of ice melt in the ice column [m/yr ice eq]')) 29 string = "%s\n%s" % (string, fielddisplay(self, 'refreeze', 'amount of ice melt refrozen in the ice column [m/yr ice eq]')) 29 30 string = "%s\n%s" % (string, fielddisplay(self, 'isclimatology', 'repeat all forcings when past last forcing time (default false)')) 31 string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 30 32 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 31 33 return string … … 64 66 #}}} 65 67 66 def checkconsistency(self, md, solution, analyses): # {{{68 def checkconsistency(self, md, solution, analyses): # {{{ 67 69 if 'MasstransportAnalysis' in analyses: 68 70 md = checkfield(md, 'fieldname', 'smb.accumulation', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 71 md = checkfield(md, 'fieldname', 'smb.melt', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 72 md = checkfield(md, 'fieldname', 'smb.refreeze', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 73 md = checkfield(md, 'fieldname', 'smb.evaporation', 'timeseries', 1, 'NaN', 1, 'Inf', 1) 69 74 70 75 if 'BalancethicknessAnalysis' in analyses: 71 76 md = checkfield(md, 'fieldname', 'smb.accumulation', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 72 73 if 'MasstransportAnalysis' in analyses:74 md = checkfield(md, 'fieldname', 'smb.melt', 'timeseries', 1, 'NaN', 1, 'Inf', 1)75 76 if 'BalancethicknessAnalysis' in analyses:77 77 md = checkfield(md, 'fieldname', 'smb.melt', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 78 79 if 'MasstransportAnalysis' in analyses:80 md = checkfield(md, 'fieldname', 'smb.refreeze', 'timeseries', 1, 'NaN', 1, 'Inf', 1)81 82 if 'BalancethicknessAnalysis' in analyses:83 78 md = checkfield(md, 'fieldname', 'smb.refreeze', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 84 85 if 'MasstransportAnalysis' in analyses:86 md = checkfield(md, 'fieldname', 'smb.evaporation', 'timeseries', 1, 'NaN', 1, 'Inf', 1)87 88 if 'BalancethicknessAnalysis' in analyses:89 79 md = checkfield(md, 'fieldname', 'smb.evaporation', 'size', [md.mesh.numberofvertices], 'NaN', 1, 'Inf', 1) 90 80 81 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 91 82 md = checkfield(md, 'fieldname', 'masstransport.requested_outputs', 'stringrow', 1) 92 83 md = checkfield(md, 'fieldname', 'smb.isclimatology', 'values', [0, 1]) 93 84 return md 94 85 # }}} 86 def marshall(self, prefix, md, fid): # {{{ 95 87 96 def marshall(self, prefix, md, fid): # {{{97 88 yts = md.constants.yts 98 89 … … 102 93 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'melt', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 103 94 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'refreeze', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 95 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer') 104 96 105 #process requested outputs97 #process requested outputs 106 98 outputs = self.requested_outputs 107 99 indices = [i for i, x in enumerate(outputs) if x == 'default'] … … 112 104 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'isclimatology', 'format', 'Boolean') 113 105 if (self.isclimatology > 0): 114 md = checkfield(md, 'fieldname', 'smb.accumulation', 'size', [md.mesh.numberofvertices + 1], 'message', 'accumulation must have md.mesh.numberofvertices +1 rows in order to force a climatology')115 md = checkfield(md, 'fieldname', 'smb.melt', 'size', [md.mesh.numberofvertices + 1], 'message', 'melt must have md.mesh.numberofvertices +1 rows in order to force a climatology')116 md = checkfield(md, 'fieldname', 'smb.refreeze', 'size', [md.mesh.numberofvertices + 1], 'message', 'refreeze must have md.mesh.numberofvertices +1 rows in order to force a climatology')117 md = checkfield(md, 'fieldname', 'smb.evaporation', 'size', [md.mesh.numberofvertices + 1], 'message', 'evaporation must have md.mesh.numberofvertices +1 rows in order to force a climatology')106 md = checkfield(md, 'fieldname', 'smb.accumulation', 'size', [md.mesh.numberofvertices + 1], 'message', 'accumulation must have md.mesh.numberofvertices+1 rows in order to force a climatology') 107 md = checkfield(md, 'fieldname', 'smb.melt', 'size', [md.mesh.numberofvertices + 1], 'message', 'melt must have md.mesh.numberofvertices+1 rows in order to force a climatology') 108 md = checkfield(md, 'fieldname', 'smb.refreeze', 'size', [md.mesh.numberofvertices + 1], 'message', 'refreeze must have md.mesh.numberofvertices+1 rows in order to force a climatology') 109 md = checkfield(md, 'fieldname', 'smb.evaporation', 'size', [md.mesh.numberofvertices + 1], 'message', 'evaporation must have md.mesh.numberofvertices+1 rows in order to force a climatology') 118 110 119 111 # }}} -
issm/trunk-jpl/src/m/classes/SMBpdd.m
r22448 r24240 5 5 6 6 classdef SMBpdd 7 properties (SetAccess=public) 7 properties (SetAccess=public) 8 8 precipitation = NaN; 9 9 monthlytemperatures = NaN; … … 12 12 s0t = NaN; 13 13 rlaps = 0; 14 rlapslgm = 0; 14 rlapslgm = 0; 15 15 Pfac = NaN; 16 16 Tdiff = NaN; … … 25 25 precipitations_presentday = NaN; 26 26 precipitations_lgm = NaN; 27 requested_outputs = {}; 27 steps_per_step = 1; 28 requested_outputs = {}; 28 29 end 29 30 methods … … 55 56 end % }}} 56 57 function self = initialize(self,md) % {{{ 57 58 58 59 if isnan(self.s0p), 59 60 self.s0p=zeros(md.mesh.numberofvertices,1); … … 73 74 self.rlaps = 6.5; 74 75 self.rlapslgm = 6.5; 75 76 76 77 end % }}} 77 78 function md = checkconsistency(self,md,solution,analyses) % {{{ … … 86 87 md = checkfield(md,'fieldname','smb.monthlytemperatures','timeseries',1,'NaN',1,'Inf',1); 87 88 md = checkfield(md,'fieldname','smb.precipitation','timeseries',1,'NaN',1,'Inf',1); 88 elseif(self.isdelta18o==1) 89 elseif(self.isdelta18o==1) 89 90 md = checkfield(md,'fieldname','smb.delta18o','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1); 90 91 md = checkfield(md,'fieldname','smb.delta18o_surface','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1); … … 92 93 md = checkfield(md,'fieldname','smb.temperatures_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1); 93 94 md = checkfield(md,'fieldname','smb.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1); 94 md = checkfield(md,'fieldname','smb.precipitations_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1); 95 md = checkfield(md,'fieldname','smb.precipitations_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1); 95 96 md = checkfield(md,'fieldname','smb.Tdiff','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1); 96 97 md = checkfield(md,'fieldname','smb.sealev','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1); 97 elseif(self.ismungsm==1) 98 elseif(self.ismungsm==1) 98 99 md = checkfield(md,'fieldname','smb.temperatures_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1); 99 100 md = checkfield(md,'fieldname','smb.temperatures_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1); 100 101 md = checkfield(md,'fieldname','smb.precipitations_presentday','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1); 101 md = checkfield(md,'fieldname','smb.precipitations_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1); 102 md = checkfield(md,'fieldname','smb.precipitations_lgm','size',[md.mesh.numberofvertices+1 12],'NaN',1,'Inf',1,'timeseries',1); 102 103 md = checkfield(md,'fieldname','smb.Pfac','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1); 103 104 md = checkfield(md,'fieldname','smb.Tdiff','NaN',1,'Inf',1,'size',[2,NaN],'singletimeseries',1); … … 105 106 end 106 107 end 108 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 107 109 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1); 108 110 109 111 end % }}} 110 112 function disp(self) % {{{ … … 140 142 fielddisplay(self,'sealev','sea level [m], 1D(year), required if mungsm is activated'); 141 143 end 144 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 142 145 fielddisplay(self,'requested_outputs','additional outputs requested'); 143 146 end % }}} … … 156 159 WriteData(fid,prefix,'object',self,'class','smb','fieldname','rlaps','format','Double'); 157 160 WriteData(fid,prefix,'object',self,'class','smb','fieldname','rlapslgm','format','Double'); 158 161 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer'); 159 162 if(self.isdelta18o==0 & self.ismungsm==0) 160 163 %WriteData(fid,prefix,'object',self,'class','smb','fieldname','monthlytemperatures','format','DoubleMat','mattype',1); … … 179 182 WriteData(fid,prefix,'object',self,'class','smb','fieldname','sealev','format','DoubleMat','mattype',1,'timeserieslength',2,'yts',md.constants.yts); 180 183 end 181 184 182 185 %process requested outputs 183 186 outputs = self.requested_outputs; -
issm/trunk-jpl/src/m/classes/SMBpdd.py
r24213 r24240 34 34 self.precipitations_presentday = float('NaN') 35 35 self.precipitations_lgm = float('NaN') 36 self.steps_per_step = 1 36 37 37 38 #set defaults … … 48 49 string = "%s\n%s" % (string, fielddisplay(self, 's0p', 'should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]')) 49 50 string = "%s\n%s" % (string, fielddisplay(self, 's0t', 'should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]')) 50 string = "%s\n%s" % (string, fielddisplay(self, 'rlaps', 'present day lapse rate [degree /km]'))51 string = "%s\n%s" % (string, fielddisplay(self, 'rlapslgm', 'LGM lapse rate [degree /km]'))51 string = "%s\n%s" % (string, fielddisplay(self, 'rlaps', 'present day lapse rate [degree/km]')) 52 string = "%s\n%s" % (string, fielddisplay(self, 'rlapslgm', 'LGM lapse rate [degree/km]')) 52 53 if not (self.isdelta18o and self.ismungsm): 53 string = "%s\n%s" % (string, fielddisplay(self, 'monthlytemperatures', ['monthly surface temperatures [K], required if pdd is activated and delta18o not activated']))54 string = "%s\n%s" % (string, fielddisplay(self, 'precipitation', ['monthly surface precipitation [m / yr water eq], required if pdd is activated and delta18o or mungsm not activated']))54 string = "%s\n%s" % (string, fielddisplay(self, 'monthlytemperatures', 'monthly surface temperatures [K], required if pdd is activated and delta18o not activated')) 55 string = "%s\n%s" % (string, fielddisplay(self, 'precipitation', 'monthly surface precipitation [m/yr water eq], required if pdd is activated and delta18o or mungsm not activated')) 55 56 if self.isdelta18o: 56 57 string = "%s\n%s" % (string, fielddisplay(self, 'delta18o', 'delta18o [per mil], required if pdd is activated and delta18o activated')) 57 58 string = "%s\n%s" % (string, fielddisplay(self, 'delta18o_surface', 'surface elevation of the delta18o site, required if pdd is activated and delta18o activated')) 58 string = "%s\n%s" % (string, fielddisplay(self, 'temperatures_presentday', 'monthly present day surface temperatures [K], required if delta18o /mungsm is activated'))59 string = "%s\n%s" % (string, fielddisplay(self, 'temperatures_presentday', 'monthly present day surface temperatures [K], required if delta18o/mungsm is activated')) 59 60 string = "%s\n%s" % (string, fielddisplay(self, 'temperatures_lgm', 'monthly LGM surface temperatures [K], required if delta18o or mungsm is activated')) 60 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_presentday', 'monthly surface precipitation [m /yr water eq], required if delta18o or mungsm is activated'))61 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_lgm', 'monthly surface precipitation [m /yr water eq], required if delta18o or mungsm is activated'))61 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_presentday', 'monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated')) 62 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_lgm', 'monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated')) 62 63 string = "%s\n%s" % (string, fielddisplay(self, 'Tdiff', 'time interpolation parameter for temperature, 1D(year), required if mungsm is activated')) 63 64 string = "%s\n%s" % (string, fielddisplay(self, 'sealev', 'sea level [m], 1D(year), required if mungsm is activated')) 65 64 66 if self.ismungsm: 65 string = "%s\n%s" % (string, fielddisplay(self, 'temperatures_presentday', 'monthly present day surface temperatures [K], required if delta18o /mungsm is activated'))67 string = "%s\n%s" % (string, fielddisplay(self, 'temperatures_presentday', 'monthly present day surface temperatures [K], required if delta18o/mungsm is activated')) 66 68 string = "%s\n%s" % (string, fielddisplay(self, 'temperatures_lgm', 'monthly LGM surface temperatures [K], required if delta18o or mungsm is activated')) 67 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_presentday', 'monthly surface precipitation [m /yr water eq], required if delta18o or mungsm is activated'))68 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_lgm', 'monthly surface precipitation [m /yr water eq], required if delta18o or mungsm is activated'))69 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_presentday', 'monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated')) 70 string = "%s\n%s" % (string, fielddisplay(self, 'precipitations_lgm', 'monthly surface precipitation [m/yr water eq], required if delta18o or mungsm is activated')) 69 71 string = "%s\n%s" % (string, fielddisplay(self, 'Pfac', 'time interpolation parameter for precipitation, 1D(year), required if mungsm is activated')) 70 72 string = "%s\n%s" % (string, fielddisplay(self, 'Tdiff', 'time interpolation parameter for temperature, 1D(year), required if mungsm is activated')) 71 73 string = "%s\n%s" % (string, fielddisplay(self, 'sealev', 'sea level [m], 1D(year), required if mungsm is activated')) 74 75 string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 72 76 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested')) 73 77 … … 79 83 self.precipitation = project3d(md, 'vector', self.precipitation, 'type', 'node') 80 84 self.monthlytemperatures = project3d(md, 'vector', self.monthlytemperatures, 'type', 'node') 85 81 86 if self.isdelta18o: 82 87 self.temperatures_lgm = project3d(md, 'vector', self.temperatures_lgm, 'type', 'node') 83 if self.isdelta18o:84 88 self.temperatures_presentday = project3d(md, 'vector', self.temperatures_presentday, 'type', 'node') 85 if self.isdelta18o:86 89 self.precipitations_presentday = project3d(md, 'vector', self.precipitations_presentday, 'type', 'node') 87 if self.isdelta18o:88 90 self.precipitations_lgm = project3d(md, 'vector', self.precipitations_lgm, 'type', 'node') 91 89 92 if self.ismungsm: 90 93 self.temperatures_lgm = project3d(md, 'vector', self.temperatures_lgm, 'type', 'node') 91 if self.ismungsm:92 94 self.temperatures_presentday = project3d(md, 'vector', self.temperatures_presentday, 'type', 'node') 93 if self.ismungsm:94 95 self.precipitations_presentday = project3d(md, 'vector', self.precipitations_presentday, 'type', 'node') 95 if self.ismungsm:96 96 self.precipitations_lgm = project3d(md, 'vector', self.precipitations_lgm, 'type', 'node') 97 97 98 self.s0p = project3d(md, 'vector', self.s0p, 'type', 'node') 98 99 self.s0t = project3d(md, 'vector', self.s0t, 'type', 'node') 99 100 100 return self 101 101 #}}} … … 128 128 #}}} 129 129 130 def checkconsistency(self, md, solution, analyses): # {{{ 130 def checkconsistency(self, md, solution, analyses): # {{{ 131 131 132 if 'MasstransportAnalysis' in analyses: 132 133 md = checkfield(md, 'fieldname', 'smb.desfac', '<=', 1, 'numel', [1]) … … 157 158 md = checkfield(md, 'fieldname', 'smb.sealev', 'NaN', 1, 'Inf', 1, 'size', [2, np.nan], 'singletimeseries', 1) 158 159 160 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 159 161 md = checkfield(md, 'fieldname', 'masstransport.requested_outputs', 'stringrow', 1) 160 162 return md 161 163 #}}} 162 164 163 def marshall(self, prefix, md, fid): # {{{165 def marshall(self, prefix, md, fid): # {{{ 164 166 yts = md.constants.yts 165 167 166 168 WriteData(fid, prefix, 'name', 'md.smb.model', 'data', 4, 'format', 'Integer') 169 167 170 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'isdelta18o', 'format', 'Boolean') 168 171 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'ismungsm', 'format', 'Boolean') … … 173 176 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'rlaps', 'format', 'Double') 174 177 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'rlapslgm', 'format', 'Double') 178 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer') 175 179 176 180 if (self.isdelta18o == 0 and self.ismungsm == 0): … … 182 186 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'precipitations_presentday', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 183 187 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'precipitations_lgm', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 184 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'delta18o_surface', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', yts)185 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'delta18o', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', yts)186 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'Tdiff', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', yts)187 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'sealev', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', yts)188 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'delta18o_surface', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', md.constants.yts) 189 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'delta18o', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', md.constants.yts) 190 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'Tdiff', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', md.constants.yts) 191 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'sealev', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', md.constants.yts) 188 192 elif self.ismungsm: 189 193 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'temperatures_presentday', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) … … 191 195 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'precipitations_presentday', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 192 196 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'precipitations_lgm', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 193 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'Pfac', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', yts)194 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'Tdiff', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', yts)195 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'sealev', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', yts)196 197 #process requested outputs197 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'Pfac', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', md.constants.yts) 198 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'Tdiff', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', md.constants.yts) 199 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'sealev', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', 2, 'yts', md.constants.yts) 200 201 #process requested outputs 198 202 outputs = self.requested_outputs 199 203 indices = [i for i, x in enumerate(outputs) if x == 'default'] -
issm/trunk-jpl/src/m/classes/SMBpddSicopolis.m
r23317 r24240 5 5 6 6 classdef SMBpddSicopolis 7 properties (SetAccess=public) 7 properties (SetAccess=public) 8 8 precipitation = NaN; 9 9 monthlytemperatures = NaN; … … 16 16 rlaps = 0; 17 17 isfirnwarming = 0; 18 steps_per_step=1 18 19 requested_outputs = {}; 19 20 end … … 41 42 end % }}} 42 43 function self = initialize(self,md) % {{{ 43 44 44 45 if isnan(self.s0p), 45 46 self.s0p=zeros(md.mesh.numberofvertices,1); … … 66 67 function self = setdefaultparameters(self) % {{{ 67 68 68 69 70 71 69 self.isfirnwarming = 1; 70 self.desfac = -log(2.0)/1000; 71 self.rlaps = 7.4; 72 72 73 end % }}} 73 74 function md = checkconsistency(self,md,solution,analyses) % {{{ … … 82 83 md = checkfield(md,'fieldname','smb.monthlytemperatures','timeseries',1,'NaN',1,'Inf',1,'size',[md.mesh.numberofvertices+1 12]); 83 84 md = checkfield(md,'fieldname','smb.precipitation','timeseries',1,'NaN',1,'Inf',1,'size',[md.mesh.numberofvertices+1 12]); 85 84 86 end 87 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 85 88 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1); 86 89 87 90 end % }}} 88 91 function disp(self) % {{{ … … 100 103 fielddisplay(self,'desfac','desertification elevation factor (default is -log(2.0)/1000)'); 101 104 fielddisplay(self,'isfirnwarming','is firnwarming (Reeh 1991) activated (0 or 1, default is 1)'); 105 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 102 106 fielddisplay(self,'requested_outputs','additional outputs requested (TemperaturePDD, SmbAccumulation, SmbMelt)'); 103 107 end % }}} … … 119 123 WriteData(fid,prefix,'object',self,'class','smb','fieldname','precipitation_anomaly','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 120 124 WriteData(fid,prefix,'object',self,'class','smb','fieldname','smb_corr','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 125 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer'); 121 126 122 127 %process requested outputs -
issm/trunk-jpl/src/m/classes/SMBpddSicopolis.py
r24213 r24240 27 27 self.rlaps = 0 28 28 self.isfirnwarming = 0 29 self.steps_per_step = 1 29 30 self.requested_outputs = [] 30 31 … … 99 100 md = checkfield(md, 'fieldname', 'smb.precipitation', 'timeseries', 1, 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices + 1, 12]) 100 101 102 md = checkfield(md, 'fieldname', 'smb.steps_per_step', '>=', 1, 'numel', [1]) 101 103 md = checkfield(md, 'fieldname', 'smb.requested_outputs', 'stringrow', 1) 102 104 … … 109 111 110 112 string = "%s\n%s" % (string, fielddisplay(self, 'monthlytemperatures', 'monthly surface temperatures [K]')) 111 string = "%s\n%s" % (string, fielddisplay(self, 'precipitation', 'monthly surface precipitation [m /yr water eq]'))113 string = "%s\n%s" % (string, fielddisplay(self, 'precipitation', 'monthly surface precipitation [m/yr water eq]')) 112 114 string = "%s\n%s" % (string, fielddisplay(self, 'temperature_anomaly', 'anomaly to monthly reference temperature (additive [K])')) 113 string = "%s\n%s" % (string, fielddisplay(self, 'precipitation_anomaly', 'anomaly to monthly precipitation (multiplicative, e.g. q = q0 * exp(0.070458 *DeltaT) after Huybrechts (2002)) [no unit])'))114 string = "%s\n%s" % (string, fielddisplay(self, 'smb_corr', 'correction of smb after PDD call [m /a]'))115 string = "%s\n%s" % (string, fielddisplay(self, 'precipitation_anomaly', 'anomaly to monthly precipitation (multiplicative, e.g. q = q0*exp(0.070458*DeltaT) after Huybrechts (2002)) [no unit])')) 116 string = "%s\n%s" % (string, fielddisplay(self, 'smb_corr', 'correction of smb after PDD call [m/a]')) 115 117 string = "%s\n%s" % (string, fielddisplay(self, 's0p', 'should be set to elevation from precip source (between 0 and a few 1000s m, default is 0) [m]')) 116 118 string = "%s\n%s" % (string, fielddisplay(self, 's0t', 'should be set to elevation from temperature source (between 0 and a few 1000s m, default is 0) [m]')) 117 string = "%s\n%s" % (string, fielddisplay(self, 'rlaps', 'present day lapse rate (default is 7.4 degree /km)'))118 string = "%s\n%s" % (string, fielddisplay(self, 'desfac', 'desertification elevation factor (default is - log(2.0) /1000)'))119 string = "%s\n%s" % (string, fielddisplay(self, 'rlaps', 'present day lapse rate (default is 7.4 degree/km)')) 120 string = "%s\n%s" % (string, fielddisplay(self, 'desfac', 'desertification elevation factor (default is -log(2.0)/1000)')) 119 121 string = "%s\n%s" % (string, fielddisplay(self, 'isfirnwarming', 'is firnwarming (Reeh 1991) activated (0 or 1, default is 1)')) 122 string = "%s\n%s" % (string, fielddisplay(self, 'steps_per_step', 'number of smb steps per time step')) 120 123 string = "%s\n%s" % (string, fielddisplay(self, 'requested_outputs', 'additional outputs requested (TemperaturePDD, SmbAccumulation, SmbMelt)')) 121 124 # }}} 122 125 123 126 def marshall(self, prefix, md, fid): # {{{ 127 124 128 yts = md.constants.yts 125 129 … … 132 136 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'rlaps', 'format', 'Double') 133 137 134 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'monthlytemperatures', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts)138 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'monthlytemperatures', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts) 135 139 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'precipitation', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 136 140 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'temperature_anomaly', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 137 141 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'precipitation_anomaly', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 138 142 WriteData(fid, prefix, 'object', self, 'class', 'smb', 'fieldname', 'smb_corr', 'format', 'DoubleMat', 'mattype', 1, 'scale', 1. / yts, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts) 143 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer') 139 144 140 #process requested outputs145 #process requested outputs 141 146 outputs = self.requested_outputs 142 147 pos = np.where('default' in outputs) -
issm/trunk-jpl/src/m/classes/SMBsemic.m
r23540 r24240 5 5 6 6 classdef SMBsemic 7 properties (SetAccess=public) 7 properties (SetAccess=public) 8 8 dailysnowfall = NaN; 9 9 dailyrainfall = NaN; … … 19 19 rdl = 0; 20 20 s0gcm = NaN; 21 steps_per_step = 1; 21 22 requested_outputs = {}; 22 23 end … … 78 79 md = checkfield(md,'fieldname','smb.dailytemperature','timeseries',1,'NaN',1,'Inf',1); 79 80 end 81 md = checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]); 80 82 md = checkfield(md,'fieldname','smb.requested_outputs','stringrow',1); 81 83 … … 83 85 function disp(self) % {{{ 84 86 disp(sprintf(' surface forcings parameters:')); 85 87 86 88 disp(sprintf(' Interface for coupling GCM data to the energy balance model SEMIC (Krapp et al (2017) https://doi.org/10.5194/tc-11-1519-2017).')); 87 disp(sprintf(' The implemented coupling uses daily mean GCM input to calculate yearly mean smb, accumulation, ablation, and surface temperature.')); 89 disp(sprintf(' The implemented coupling uses daily mean GCM input to calculate yearly mean smb, accumulation, ablation, and surface temperature.')); 88 90 disp(sprintf(' smb and temperatures are updated every year')); 89 91 disp(sprintf('\n SEMIC parameters:')); 90 fielddisplay(self,'dailysnowfall','daily surface dailysnowfall [m/s]'); 92 fielddisplay(self,'dailysnowfall','daily surface dailysnowfall [m/s]'); 91 93 fielddisplay(self,'dailyrainfall','daily surface dailyrainfall [m/s]'); 92 94 fielddisplay(self,'dailydsradiation','daily downwelling shortwave radiation [W/m2]'); 93 95 fielddisplay(self,'dailydlradiation','daily downwelling longwave radiation [W/m2]'); 94 fielddisplay(self,'dailywindspeed','daily surface wind speed [m/s]'); 96 fielddisplay(self,'dailywindspeed','daily surface wind speed [m/s]'); 95 97 fielddisplay(self,'dailypressure','daily surface pressure [Pa]'); 96 fielddisplay(self,'dailyairdensity','daily air density [kg/m3]'); 98 fielddisplay(self,'dailyairdensity','daily air density [kg/m3]'); 97 99 fielddisplay(self,'dailyairhumidity','daily air specific humidity [kg/kg]'); 98 100 fielddisplay(self,'dailytemperature','daily surface air temperature [K]'); … … 101 103 fielddisplay(self,'rdl','longwave downward radiation decrease (default is 0.29 [W/m^2/km]; Marty et al. 2002)'); 102 104 fielddisplay(self,'s0gcm','GCM reference elevation; (default is 0) [m]'); 105 fielddisplay(self, 'steps_per_step', 'number of smb steps per time step'); 103 106 fielddisplay(self,'requested_outputs','additional outputs requested'); 104 107 end % }}} 105 108 function marshall(self,prefix,md,fid) % {{{ 106 109 107 110 WriteData(fid,prefix,'name','md.smb.model','data',12,'format','Integer'); 108 111 … … 120 123 WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailyairhumidity','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 121 124 WriteData(fid,prefix,'object',self,'class','smb','fieldname','dailytemperature','format','DoubleMat','mattype',1,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts); 122 125 WriteData(fid, prefix, 'object', self, 'fieldname', 'steps_per_step', 'format', 'Integer'); 123 126 %process requested outputs 124 127 outputs = self.requested_outputs; -
issm/trunk-jpl/src/m/classes/clusters/generic.py
r24213 r24240 22 22 23 23 def __init__(self, *args): # {{{ 24 25 24 self.name = '' 26 25 self.login = '' … … 116 115 117 116 else: # Windows 118 119 117 fid = open(modelname + '.bat', 'w') 120 118 fid.write('@echo off\n') … … 156 154 157 155 else: # Windows 158 159 156 fid = open(modelname + '.bat', 'w') 160 157 fid.write('@echo off\n') -
issm/trunk-jpl/src/m/classes/clusters/stallo.py
r24216 r24240 47 47 #use provided options to change fields 48 48 options = pairoptions(*args) 49 50 49 #initialize cluster using user settings if provided 51 50 self = stallo_settings(self) … … 111 110 d, h = divmod(h, 60) 112 111 timestring = "%02d-%02d:%02d:%02d" % (d, h, m, s) 113 114 112 fid = open(modelname + '.queue', 'w') 115 113 fid.write('#!/bin/bash -l\n') -
issm/trunk-jpl/src/m/classes/debug.py
r24213 r24240 20 20 21 21 #}}} 22 22 23 def __repr__(self): # {{{ 23 24 string = " debug parameters:" -
issm/trunk-jpl/src/m/classes/hydrologydc.m
r22899 r24240 64 64 % }}} 65 65 function list = defaultoutputs(self,md) % {{{ 66 list = {'SedimentHead Hydrostep','SedimentHeadResidual','EffectivePressureHydrostep'};66 list = {'SedimentHead','SedimentHeadResidual','EffectivePressure'}; 67 67 if self.isefficientlayer, 68 list=[list,{'EplHead Hydrostep','HydrologydcMaskEplactiveNode','HydrologydcMaskEplactiveElt','EplHeadSlopeX','EplHeadSlopeY','HydrologydcEplThicknessHydrostep'}];68 list=[list,{'EplHead','HydrologydcMaskEplactiveNode','HydrologydcMaskEplactiveElt','EplHeadSlopeX','EplHeadSlopeY','HydrologydcEplThickness'}]; 69 69 end 70 70 if self.steps_per_step>1, 71 list = [list,'EffectivePressure ','SedimentHead'];71 list = [list,'EffectivePressureSubstep','SedimentHeadSubstep']; 72 72 if self.isefficientlayer, 73 list = [list,'EplHead ','HydrologydcEplThickness'];73 list = [list,'EplHeadSubstep','HydrologydcEplThicknessSubstep']; 74 74 end 75 75 end … … 98 98 self.sedimentlimit_flag = 0; 99 99 self.sedimentlimit = 0; 100 self.transfer_flag = 0;100 self.transfer_flag = 1; 101 101 self.unconfined_flag = 0; 102 self.leakage_factor = 1 0.0;102 self.leakage_factor = 1.0e-10; 103 103 self.requested_outputs = {'default'}; 104 104 -
issm/trunk-jpl/src/m/classes/hydrologydc.py
r24213 r24240 128 128 self.sedimentlimit_flag = 0 129 129 self.sedimentlimit = 0 130 self.transfer_flag = 0130 self.transfer_flag = 1 131 131 self.unconfined_flag = 0 132 self.leakage_factor = 1 0.0132 self.leakage_factor = 1.0e-10 133 133 self.requested_outputs = ['default'] 134 134 self.sediment_compressibility = 1.0e-08 … … 150 150 151 151 def defaultoutputs(self, md): # {{{ 152 list = ['SedimentHead Hydrostep', 'SedimentHeadResidual', 'EffectivePressureHydrostep']153 if self.isefficientlayer == 1: 154 list.extend(['EplHead Hydrostep', 'HydrologydcMaskEplactiveNode', 'HydrologydcMaskEplactiveElt', 'EplHeadSlopeX', 'EplHeadSlopeY', 'HydrologydcEplThicknessHydrostep'])152 list = ['SedimentHead', 'SedimentHeadResidual', 'EffectivePressure'] 153 if self.isefficientlayer == 1: 154 list.extend(['EplHead', 'HydrologydcMaskEplactiveNode', 'HydrologydcMaskEplactiveElt', 'EplHeadSlopeX', 'EplHeadSlopeY', 'HydrologydcEplThickness']) 155 155 if self.steps_per_step > 1: 156 list.extend(['EffectivePressure ', 'SedimentHead'])156 list.extend(['EffectivePressureSubstep', 'SedimentHeadSubstep']) 157 157 if self.isefficientlayer == 1: 158 list.extend(['EplHead ', 'HydrologydcEplThickness'])158 list.extend(['EplHeadSubstep', 'HydrologydcEplThicknessSubstep']) 159 159 return list 160 160 #}}} … … 180 180 md = checkfield(md, 'fieldname', 'hydrology.rel_tol', '>', 0., 'numel', [1]) 181 181 md = checkfield(md, 'fieldname', 'hydrology.max_iter', '>', 0., 'numel', [1]) 182 md = checkfield(md, 'fieldname', 'hydrology.steps_per_step', '> ', 0., 'numel', [1])182 md = checkfield(md, 'fieldname', 'hydrology.steps_per_step', '>=', 1, 'numel', [1]) 183 183 md = checkfield(md, 'fieldname', 'hydrology.sedimentlimit_flag', 'numel', [1], 'values', [0, 1, 2, 3]) 184 184 md = checkfield(md, 'fieldname', 'hydrology.transfer_flag', 'numel', [1], 'values', [0, 1]) -
issm/trunk-jpl/src/m/classes/linearbasalforcings.py
r24213 r24240 40 40 else: 41 41 raise Exception('constructor not supported') 42 #}}} 42 43 43 #}}}44 44 def __repr__(self): # {{{ 45 45 string = " linear basal forcings parameters:" 46 47 46 string = "%s\n%s" % (string, fielddisplay(self, "deepwater_melting_rate", "basal melting rate (positive if melting applied for floating ice whith base < deepwater_elevation) [m/yr]")) 48 47 string = "%s\n%s" % (string, fielddisplay(self, "deepwater_elevation", "elevation of ocean deepwater [m]")) … … 53 52 return string 54 53 #}}} 54 55 55 def initialize(self, md): # {{{ 56 57 56 if np.all(np.isnan(self.groundedice_melting_rate)): 58 57 self.groundedice_melting_rate = np.zeros((md.mesh.numberofvertices)) 59 58 print(" no basalforcings.groundedice_melting_rate specified: values set as zero") 60 61 59 return self 62 60 #}}} 61 63 62 def setdefaultparameters(self): # {{{ 64 65 63 self.deepwater_melting_rate = 50.0 66 64 self.deepwater_elevation = - 800.0 … … 70 68 return self 71 69 #}}} 70 72 71 def checkconsistency(self, md, solution, analyses): # {{{ 73 74 72 if 'MasstransportAnalysis' in analyses and not (solution == 'TransientSolution' and not md.transient.ismasstransport): 75 73 md = checkfield(md, 'fieldname', 'basalforcings.groundedice_melting_rate', 'NaN', 1, 'Inf', 1, 'timeseries', 1) … … 96 94 return md 97 95 # }}} 96 98 97 def marshall(self, prefix, md, fid): # {{{ 99 100 98 yts = md.constants.yts 101 99 -
issm/trunk-jpl/src/m/classes/verbose.py
r24213 r24240 24 24 verbose = verbose('module', True, 'solver', False) 25 25 26 WARNING: some parts of this file are Synchronized with src / c / shared / Numerics /Verbosity.h27 Do not modify these sections. See src / c / shared / Numerics /README for more info26 WARNING: some parts of this file are Synchronized with src/c/shared/Numerics/Verbosity.h 27 Do not modify these sections. See src/c/shared/Numerics/README for more info 28 28 """ 29 29 … … 88 88 s += " %15s : %s\n" % ('smb', self.smb) 89 89 #ENDDISP 90 91 90 return s 92 91 # }}} -
issm/trunk-jpl/src/m/consistency/ismodelselfconsistent.py
r24213 r24240 36 36 else: 37 37 raise TypeError("solution type: '%s' not supported yet!" % solutiontype) 38 39 38 return analyses 40 39 #}}} -
issm/trunk-jpl/src/m/contrib/defleurian/netCDF/export_netCDF.py
r24213 r24240 27 27 dimindex = 1 28 28 dimlist = [2, md.mesh.numberofelements, md.mesh.numberofvertices, np.shape(md.mesh.elements)[1]] 29 print(' == =Creating dimensions == =')29 print('===Creating dimensions ===') 30 30 for i in range(0, 4): 31 31 if dimlist[i] not in list(DimDict.keys()): … … 38 38 groups = dict.keys(md.__dict__) 39 39 # get all model classes and create respective groups 40 print(' == =Creating and populating groups == =')40 print('===Creating and populating groups===') 41 41 for group in groups: 42 42 NCgroup = NCData.createGroup(str(group)) … … 104 104 NCData.close() 105 105 106 # == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ====106 #============================================================================ 107 107 # Define the variables 108 108 … … 176 176 return DimDict 177 177 178 # == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ====178 # ============================================================================ 179 179 # retriev the dimension tuple from a dictionnary 180 180 -
issm/trunk-jpl/src/m/dev/devpath.py
r24227 r24240 5 5 6 6 #Recover ISSM_DIR and USERNAME 7 ISSM_DIR = os.getenv('ISSM_D IR')7 ISSM_DIR = os.getenv('ISSM_DEV_DIR') 8 8 USERNAME = os.getenv('USER') 9 9 JPL_SVN = os.getenv('JPL_SVN') 10 10 if ISSM_DIR is None: 11 raise NameError('"ISSM_D IR" environment variable is empty! You should define ISSM_DIR in your .cshrc or .bashrc!')11 raise NameError('"ISSM_DEV_DIR" environment variable is empty! You should define ISSM_DEV_DIR in your .cshrc or .bashrc!') 12 12 13 13 #Go through src / m and append any directory that contains a * .py file to PATH … … 37 37 warnings.warn('cluster settings should be in, {} / usr / {}'.format(JPL_SVN, USERNAME)) 38 38 39 #Manual imports for commonly used functions40 39 from runme import runme #first because plotmodel may fail 41 40 from plotmodel import plotmodel -
issm/trunk-jpl/src/m/os/issmscpin.py
r24213 r24240 9 9 """ 10 10 ISSMSCPIN get packages from host, using scp on unix, and pscp on windows 11 12 11 usage: issmscpin(host, packages, path) 13 12 """ … … 15 14 #first get hostname 16 15 hostname = gethostname() 17 18 16 #first be sure packages are not in the current directory, this could conflict with pscp on windows. 19 17 #remove warnings in case the files do not exist … … 23 21 except OSError as e: 24 22 pass 25 26 23 #if hostname and host are the same, do a simple copy 27 if m.strcmpi(hostname, host): 28 24 if hostname == host: 29 25 for package in packages: 30 26 try: … … 32 28 except OSError as e: 33 29 pass 34 35 30 else: 36 31 if m.ispc(): … … 41 36 else: 42 37 raise OSError("issmscpin error message: could not find ISSM_DIR_WIN environment variable.") 43 44 38 username = eval(input('Username: (quoted string) ')) 45 39 key = eval(input('Key: (quoted string) ')) 46 47 40 for package in packages: 48 41 try: 49 42 subprocess.check_call('%s/externalpackages/ssh/pscp.exe -l "%s" -pw "%s" %s:%s %s' % (ISSM_DIR, username, key, host, os.path.join(path, package), os.getcwd()), shell=True) 50 43 except CalledProcessError as e: 51 raise CalledProcessError("issmscpin error message: could not call putty pscp .")44 raise CalledProcessError("issmscpin error message: could not call putty pscp due to ") 52 45 53 46 else: -
issm/trunk-jpl/src/m/solve/loadresultsfromdisk.py
r24213 r24240 10 10 11 11 Usage: 12 md = loadresultsfromdisk(md = False, filename = False)12 md = loadresultsfromdisk(md=False,filename=False); 13 13 """ 14 15 #check number of inputs / outputs 14 #check number of inputs/outputs 16 15 if not md or not filename: 17 16 raise ValueError("loadresultsfromdisk: error message.") … … 27 26 md.results = results() 28 27 29 28 #load results onto model 30 29 structure = parseresultsfromdisk(md, filename, not md.settings.io_gather) 31 30 if not len(structure): … … 40 39 if os.path.exists(md.miscellaneous.name + '.errlog'): 41 40 with open(md.miscellaneous.name + '.errlog', 'r') as f: 42 setattr(getattr(md.results, structure[0].SolutionType)[0], 'errlog', [line[: - 41 setattr(getattr(md.results, structure[0].SolutionType)[0], 'errlog', [line[: -1] for line in f]) 43 42 else: 44 43 setattr(getattr(md.results, structure[0].SolutionType)[0], 'errlog', []) … … 46 45 if os.path.exists(md.miscellaneous.name + '.outlog'): 47 46 with open(md.miscellaneous.name + '.outlog', 'r') as f: 48 setattr(getattr(md.results, structure[0].SolutionType)[0], 'outlog', [line[: - 47 setattr(getattr(md.results, structure[0].SolutionType)[0], 'outlog', [line[: -1] for line in f]) 49 48 else: 50 49 setattr(getattr(md.results, structure[0].SolutionType)[0], 'outlog', []) -
issm/trunk-jpl/src/m/solve/parseresultsfromdisk.m
r23921 r24240 23 23 counter = 1; 24 24 step = result.step; 25 while ~isempty(result), 25 while ~isempty(result), 26 26 27 27 if check_nomoresteps, 28 %check that the new result does not add a step, which would be an error: 28 %check that the new result does not add a step, which would be an error: 29 29 if result.step>=1, 30 30 error('parsing results for a steady-state core, which incorporates transient results!'); … … 40 40 %Add result 41 41 if(result.step==0), 42 %if we have a step = 0, this is a steady state solutoin, don't expect more steps. 42 %if we have a step = 0, this is a steady state solutoin, don't expect more steps. 43 43 index = 1; 44 44 check_nomoresteps=1; … … 77 77 results=struct(); 78 78 79 %if we have done split I/O, ie, we have results that are fragmented across patches, 79 %if we have done split I/O, ie, we have results that are fragmented across patches, 80 80 %do a first pass, and figure out the structure of results 81 81 result=ReadDataDimensions(fid); … … 85 85 results(result.step).step=result.step; 86 86 if result.time~=-9999, 87 results(result.step).time=result.time; 87 results(result.step).time=result.time; 88 88 end 89 89 … … 111 111 results(result.step).step=result.step; 112 112 if result.time~=-9999, 113 results(result.step).time=result.time; 113 results(result.step).time=result.time; 114 114 end 115 115 … … 205 205 elseif strcmp(fieldname,'SmbRunoff'), 206 206 field = field*yts; 207 elseif strcmp(fieldname,'SmbRunoffSubstep'), 208 field = field*yts; 207 209 elseif strcmp(fieldname,'SmbEvaporation'), 208 210 field = field*yts; … … 220 222 field = field*yts; 221 223 elseif (strcmp(fieldname,'LoveKernelsReal') | strcmp(fieldname,'LoveKernelsImag')), 222 nlayer = md.materials.numlayers; 223 degmax = md.love.sh_nmax; 224 nfreq = md.love.nfreq; 225 temp_field = cell(degmax+1,nfreq,nlayer+1,6); 224 nlayer = md.materials.numlayers; 225 degmax = md.love.sh_nmax; 226 nfreq = md.love.nfreq; 227 temp_field = cell(degmax+1,nfreq,nlayer+1,6); 226 228 for ii=1:degmax+1 227 229 for jj=1:nfreq 228 230 for kk=1:nlayer+1 229 ll = (ii-1)*(nlayer+1)*6 + ((kk-1)*6+1); 231 ll = (ii-1)*(nlayer+1)*6 + ((kk-1)*6+1); 230 232 for mm=1:6 231 temp_field{ii,jj,kk,mm} = field(ll+(mm-1),jj); 233 temp_field{ii,jj,kk,mm} = field(ll+(mm-1),jj); 232 234 end 233 235 end 234 236 end 235 237 end 236 field=temp_field; 238 field=temp_field; 237 239 end 238 240 -
issm/trunk-jpl/src/m/solve/parseresultsfromdisk.py
r24213 r24240 222 222 field = field * yts 223 223 elif fieldname == 'SmbRunoff': 224 field = field * yts 225 elif fieldname == 'SmbRunoffSubstep': 224 226 field = field * yts 225 227 elif fieldname == 'SmbEvaporation': -
issm/trunk-jpl/test/NightlyRun/runme.py
r24226 r24240 195 195 print(('ERROR difference: {} > {} test id: {} test name: {} field: {}'.format(error_diff, tolerance, id, id_string, fieldname))) 196 196 errorcount += 1 197 np.append(erroredtest_list,id)197 erroredtest_list.append(id) 198 198 else: 199 199 print(('SUCCESS difference: {} < {} test id: {} test name: {} field: {}'.format(error_diff, tolerance, id, id_string, fieldname))) … … 228 228 229 229 if errorcount > 0: 230 print("{} errors were detected in test {}".format(errorcount, erroredtest_list))230 print("{} errors were detected in test {}".format(errorcount, np.unique(erroredtest_list))) 231 231 return 232 232 -
issm/trunk-jpl/test/NightlyRun/test330.py
r24214 r24240 53 53 field_names = ['SedimentWaterHead1', 'SedimentWaterHead2'] 54 54 field_tolerances = [1e-13, 1e-13] 55 field_values = [md.results.TransientSolution[10].SedimentHead Hydrostep, md.results.TransientSolution[30].SedimentHeadHydrostep]55 field_values = [md.results.TransientSolution[10].SedimentHead, md.results.TransientSolution[30].SedimentHead] -
issm/trunk-jpl/test/NightlyRun/test3300.py
r24214 r24240 66 66 # sedstore = 20.0 * store 67 67 # for i in range(0, 4000): 68 # sedvol[i] = np.mean(md.results.TransientSolution[i].SedimentHead) *sedstore69 # eplvol[i] = np.mean(md.results.TransientSolution[i].EplHead) * store * np.mean(md.results.TransientSolution[i].HydrologydcEplThicknessHydrostep)70 # totvol[i + 1] = totvol[i] + md.basalforcings.groundedice_melting_rate[0, i] *0.00268 # sedvol[i]=np.mean(md.results.TransientSolution[i].SedimentHead)*sedstore 69 # eplvol[i]=np.mean(md.results.TransientSolution[i].EplHead)*store*np.mean(md.results.TransientSolution[i].HydrologydcEplThicknessSubstep) 70 # totvol[i+1]=totvol[i]+md.basalforcings.groundedice_melting_rate[0, i]*0.002 71 71 72 72 field_names = ['SedimentWaterHead5', 'EplWaterHead5', 'SedimentWaterHead40', 'EplWaterHead40'] 73 73 field_tolerances = [1e-13, 1e-13, 1e-13, 1e-13, 1e-13] 74 field_values = [md.results.TransientSolution[5].SedimentHead Hydrostep,75 md.results.TransientSolution[5].EplHead Hydrostep,76 md.results.TransientSolution[40].SedimentHead Hydrostep,77 md.results.TransientSolution[40].EplHead Hydrostep]74 field_values = [md.results.TransientSolution[5].SedimentHeadSubstep, 75 md.results.TransientSolution[5].EplHeadSubstep, 76 md.results.TransientSolution[40].SedimentHeadSubstep, 77 md.results.TransientSolution[40].EplHeadSubstep] -
issm/trunk-jpl/test/NightlyRun/test332.py
r24214 r24240 46 46 field_names = ['SedimentWaterHead', 'SedimentHeadResidual'] 47 47 field_tolerances = [1e-13, 3e-10] 48 field_values = [md.results.HydrologySolution.SedimentHead Hydrostep, md.results.HydrologySolution.SedimentHeadResidual]48 field_values = [md.results.HydrologySolution.SedimentHead, md.results.HydrologySolution.SedimentHeadResidual] -
issm/trunk-jpl/test/NightlyRun/test333.py
r23793 r24240 10 10 from solve import * 11 11 from generic import generic 12 12 13 13 14 md = triangle(model(), '../Exp/Square.exp', 100000.) … … 26 27 md.hydrology.sedimentlimit_flag = 1 27 28 md.hydrology.sedimentlimit = 800.0 29 md.hydrology.transfer_flag = 0 28 30 md.hydrology.mask_thawed_node = np.ones((md.mesh.numberofvertices)) 29 31 md.initialization.sediment_head = np.zeros((md.mesh.numberofvertices)) … … 52 54 #re-run with no substeps 53 55 mdfine = copy.deepcopy(md) 54 mdfine.result = []56 mdfine.results = [] 55 57 mdfine.hydrology.steps_per_step = 1 56 58 mdfine.timestepping.time_step = 0.2 57 59 mdfine = solve(mdfine, 'Transient') 58 59 60 sedmean = mdfine.results.TransientSolution[0].SedimentHeadHydrostep61 eplmean = mdfine.results.TransientSolution[0].EplHeadHydrostep62 for i in range(1, 10):63 sedmean = sedmean + (mdfine.results.TransientSolution[i].SedimentHeadHydrostep)64 eplmean = eplmean + (mdfine.results.TransientSolution[i].EplHeadHydrostep)65 60 66 61 field_names = ['SedimentWaterHead1', 'EplWaterHead1', 'SedimentHeadResidual1', … … 68 63 'SedimentWaterHead5', 'EplWaterHead5', 'SedimentHeadResidual5', 69 64 'SedimentWaterHead9', 'EplWaterHead9', 'SedimentHeadResidual9', 70 'EplWaterHead10'] 65 'EplWaterHead10', 'EplWaterHeadSubstep10', 'SedimentWaterHead10', 66 'SedimentWaterHeadSubstep10'] 71 67 field_tolerances = [1e-13, 1e-13, 1e-13, 72 68 1e-13, 1e-13, 1e-13, 73 69 1e-13, 5e-12, 1e-11, 74 70 1e-13, 5e-12, 1e-11, 71 1e-13, 1e-13, 1e-13, 75 72 1e-13] 76 field_values = [mdfine.results.TransientSolution[0].SedimentHead Hydrostep,77 mdfine.results.TransientSolution[0].EplHead Hydrostep,73 field_values = [mdfine.results.TransientSolution[0].SedimentHead, 74 mdfine.results.TransientSolution[0].EplHead, 78 75 mdfine.results.TransientSolution[0].SedimentHeadResidual, 79 mdfine.results.TransientSolution[3].SedimentHead Hydrostep,80 mdfine.results.TransientSolution[3].EplHead Hydrostep,76 mdfine.results.TransientSolution[3].SedimentHead, 77 mdfine.results.TransientSolution[3].EplHead, 81 78 mdfine.results.TransientSolution[3].SedimentHeadResidual, 82 mdfine.results.TransientSolution[4].SedimentHead Hydrostep,83 mdfine.results.TransientSolution[4].EplHead Hydrostep,79 mdfine.results.TransientSolution[4].SedimentHead, 80 mdfine.results.TransientSolution[4].EplHead, 84 81 mdfine.results.TransientSolution[4].SedimentHeadResidual, 85 mdfine.results.TransientSolution[8].SedimentHead Hydrostep,86 mdfine.results.TransientSolution[8].EplHead Hydrostep,82 mdfine.results.TransientSolution[8].SedimentHead, 83 mdfine.results.TransientSolution[8].EplHead, 87 84 mdfine.results.TransientSolution[8].SedimentHeadResidual, 88 md.results.TransientSolution[-1].EplHead] 85 md.results.TransientSolution[-1].EplHead, 86 md.results.TransientSolution[-1].EplHeadSubstep, 87 md.results.TransientSolution[-1].SedimentHead, 88 md.results.TransientSolution[-1].SedimentHeadSubstep] -
issm/trunk-jpl/test/NightlyRun/test334.py
r24214 r24240 46 46 field_names = ['SedimentWaterHead', 'SedimentHeadResidual'] 47 47 field_tolerances = [1e-13, 3e-10] 48 field_values = [md.results.HydrologySolution.SedimentHead Hydrostep, md.results.HydrologySolution.SedimentHeadResidual]48 field_values = [md.results.HydrologySolution.SedimentHead, md.results.HydrologySolution.SedimentHeadResidual] -
issm/trunk-jpl/test/NightlyRun/test335.py
r23793 r24240 26 26 md.hydrology.isefficientlayer = 1 27 27 md.hydrology.sedimentlimit_flag = 1 28 md.hydrology.transfer_flag = 0 28 29 md.hydrology.sedimentlimit = 800.0 29 30 md.hydrology.mask_thawed_node = np.ones((md.mesh.numberofvertices)) … … 58 59 1e-13, 5e-12, 2e-11, 59 60 1e-13, 5e-12, 2e-11] 60 field_values = [md.results.TransientSolution[0].SedimentHead Hydrostep,61 md.results.TransientSolution[0].EplHead Hydrostep,61 field_values = [md.results.TransientSolution[0].SedimentHead, 62 md.results.TransientSolution[0].EplHead, 62 63 md.results.TransientSolution[0].SedimentHeadResidual, 63 md.results.TransientSolution[3].SedimentHead Hydrostep,64 md.results.TransientSolution[3].EplHead Hydrostep,64 md.results.TransientSolution[3].SedimentHead, 65 md.results.TransientSolution[3].EplHead, 65 66 md.results.TransientSolution[3].SedimentHeadResidual, 66 md.results.TransientSolution[4].SedimentHead Hydrostep,67 md.results.TransientSolution[4].EplHead Hydrostep,67 md.results.TransientSolution[4].SedimentHead, 68 md.results.TransientSolution[4].EplHead, 68 69 md.results.TransientSolution[4].SedimentHeadResidual, 69 md.results.TransientSolution[8].SedimentHead Hydrostep,70 md.results.TransientSolution[8].EplHead Hydrostep,70 md.results.TransientSolution[8].SedimentHead, 71 md.results.TransientSolution[8].EplHead, 71 72 md.results.TransientSolution[8].SedimentHeadResidual]
Note:
See TracChangeset
for help on using the changeset viewer.