Changeset 21718
- Timestamp:
- 05/16/17 16:55:45 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/c/analyses/EnthalpyAnalysis.cpp ¶
r21653 r21718 316 316 const int dim=3; 317 317 int i,is,state; 318 int vertexdown,vertexup,numvertices,numsegments;318 int nodedown,nodeup,numnodes,numsegments; 319 319 int enthalpy_enum; 320 320 IssmDouble vec_heatflux[dim],normal_base[dim],d1enthalpy[dim],d1pressure[dim]; … … 357 357 /******** MELTING RATES ************************************//*{{{*/ 358 358 element->NormalBase(&normal_base[0],xyz_list_base); 359 element->VerticalSegmentIndices (&pairindices,&numsegments);359 element->VerticalSegmentIndicesBase(&pairindices,&numsegments); 360 360 IssmDouble* meltingrate_enthalpy = xNew<IssmDouble>(numsegments); 361 361 IssmDouble* heating = xNew<IssmDouble>(numsegments); 362 362 363 num vertices=element->GetNumberOfVertices();364 IssmDouble* enthalpies = xNew<IssmDouble>(num vertices);365 IssmDouble* pressures = xNew<IssmDouble>(num vertices);366 IssmDouble* watercolumns = xNew<IssmDouble>(num vertices);367 IssmDouble* basalmeltingrates = xNew<IssmDouble>(num vertices);368 element->GetInputListOn Vertices(enthalpies,enthalpy_enum);369 element->GetInputListOn Vertices(pressures,PressureEnum);370 element->GetInputListOn Vertices(watercolumns,WatercolumnEnum);371 element->GetInputListOn Vertices(basalmeltingrates,BasalforcingsGroundediceMeltingRateEnum);363 numnodes=element->GetNumberOfNodes(); 364 IssmDouble* enthalpies = xNew<IssmDouble>(numnodes); 365 IssmDouble* pressures = xNew<IssmDouble>(numnodes); 366 IssmDouble* watercolumns = xNew<IssmDouble>(numnodes); 367 IssmDouble* basalmeltingrates = xNew<IssmDouble>(numnodes); 368 element->GetInputListOnNodes(enthalpies,enthalpy_enum); 369 element->GetInputListOnNodes(pressures,PressureEnum); 370 element->GetInputListOnNodes(watercolumns,WatercolumnEnum); 371 element->GetInputListOnNodes(basalmeltingrates,BasalforcingsGroundediceMeltingRateEnum); 372 372 373 373 Gauss* gauss=element->NewGauss(); 374 374 for(is=0;is<numsegments;is++){ 375 vertexdown = pairindices[is*2+0];376 vertexup = pairindices[is*2+1];377 gauss->Gauss Vertex(vertexdown);378 379 state=GetThermalBasalCondition(element, enthalpies[ vertexdown], enthalpies[vertexup], pressures[vertexdown], pressures[vertexup], watercolumns[vertexdown], basalmeltingrates[vertexdown]);375 nodedown = pairindices[is*2+0]; 376 nodeup = pairindices[is*2+1]; 377 gauss->GaussNode(element->GetElementType(),nodedown); 378 379 state=GetThermalBasalCondition(element, enthalpies[nodedown], enthalpies[nodeup], pressures[nodedown], pressures[nodeup], watercolumns[nodedown], basalmeltingrates[nodedown]); 380 380 switch (state) { 381 381 case 0: … … 392 392 case 4: 393 393 // temperate, thick melting base: set grad H*n=0 394 kappa_mix=GetWetIceConductivity(element, enthalpies[ vertexdown], pressures[vertexdown]);394 kappa_mix=GetWetIceConductivity(element, enthalpies[nodedown], pressures[nodedown]); 395 395 pressure_input->GetInputDerivativeValue(&d1pressure[0],xyz_list,gauss); 396 396 for(i=0;i<3;i++) vec_heatflux[i]=kappa_mix*beta*d1pressure[i]; … … 418 418 /******** UPDATE MELTINGRATES AND WATERCOLUMN **************//*{{{*/ 419 419 for(is=0;is<numsegments;is++){ 420 vertexdown = pairindices[is*2+0];421 vertexup = pairindices[is*2+1];420 nodedown = pairindices[is*2+0]; 421 nodeup = pairindices[is*2+1]; 422 422 if(dt!=0.){ 423 if(watercolumns[ vertexdown]+meltingrate_enthalpy[is]*dt<0.){ // prevent too much freeze on424 lambda = -watercolumns[ vertexdown]/(dt*meltingrate_enthalpy[is]); _assert_(lambda>=0.); _assert_(lambda<1.);425 watercolumns[ vertexdown]=0.;426 basalmeltingrates[ vertexdown]=lambda*meltingrate_enthalpy[is]; // restrict freeze on only to size of watercolumn427 enthalpies[ vertexdown]+=(1.-lambda)*dt/yts*meltingrate_enthalpy[is]*latentheat*rho_ice; // use rest of energy to cool down base: dE=L*m, m=(1-lambda)*meltingrate*rho_ice423 if(watercolumns[nodedown]+meltingrate_enthalpy[is]*dt<0.){ // prevent too much freeze on 424 lambda = -watercolumns[nodedown]/(dt*meltingrate_enthalpy[is]); _assert_(lambda>=0.); _assert_(lambda<1.); 425 watercolumns[nodedown]=0.; 426 basalmeltingrates[nodedown]=lambda*meltingrate_enthalpy[is]; // restrict freeze on only to size of watercolumn 427 enthalpies[nodedown]+=(1.-lambda)*dt/yts*meltingrate_enthalpy[is]*latentheat*rho_ice; // use rest of energy to cool down base: dE=L*m, m=(1-lambda)*meltingrate*rho_ice 428 428 } 429 429 else{ 430 basalmeltingrates[ vertexdown]=meltingrate_enthalpy[is];431 watercolumns[ vertexdown]+=dt*meltingrate_enthalpy[is];430 basalmeltingrates[nodedown]=meltingrate_enthalpy[is]; 431 watercolumns[nodedown]+=dt*meltingrate_enthalpy[is]; 432 432 } 433 433 } 434 434 else{ 435 basalmeltingrates[ vertexdown]=meltingrate_enthalpy[is];436 if(watercolumns[ vertexdown]+meltingrate_enthalpy[is]<0.)437 watercolumns[ vertexdown]=0.;435 basalmeltingrates[nodedown]=meltingrate_enthalpy[is]; 436 if(watercolumns[nodedown]+meltingrate_enthalpy[is]<0.) 437 watercolumns[nodedown]=0.; 438 438 else 439 watercolumns[ vertexdown]+=meltingrate_enthalpy[is];439 watercolumns[nodedown]+=meltingrate_enthalpy[is]; 440 440 } 441 basalmeltingrates[ vertexdown]*=rho_water/rho_ice; // convert meltingrate from water to ice equivalent442 _assert_(watercolumns[ vertexdown]>=0.);441 basalmeltingrates[nodedown]*=rho_water/rho_ice; // convert meltingrate from water to ice equivalent 442 _assert_(watercolumns[nodedown]>=0.); 443 443 }/*}}}*/ 444 444 445 445 /*feed updated variables back into model*/ 446 446 if(dt!=0.){ 447 //element->AddInput(enthalpy_enum,enthalpies,P1Enum); //TODO: distinguis for steadystate and transient run448 element->AddInput(WatercolumnEnum,watercolumns, P1Enum);449 } 450 element->AddInput(BasalforcingsGroundediceMeltingRateEnum,basalmeltingrates, P1Enum);447 element->AddInput(enthalpy_enum,enthalpies,element->GetElementType()); 448 element->AddInput(WatercolumnEnum,watercolumns,element->GetElementType()); 449 } 450 element->AddInput(BasalforcingsGroundediceMeltingRateEnum,basalmeltingrates,element->GetElementType()); 451 451 452 452 /*Clean up and return*/
Note:
See TracChangeset
for help on using the changeset viewer.