Changeset 17014


Ignore:
Timestamp:
12/09/13 07:48:15 (11 years ago)
Author:
jbondzio
Message:

CHG: filled EnthalpyAnalysis::ComputeBasalMeltingrate with content. ADD: GetUpperElement, ThermalToEnthalpy for parent class Element*.

Location:
issm/trunk-jpl/src/c
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/analyses/EnthalpyAnalysis.cpp

    r17005 r17014  
    403403
    404404        /*Intermediaries*/
    405         int         stabilization;
     405        int         i, stabilization;
    406406        IssmDouble  Jdet,phi,dt;
    407         IssmDouble  enthalpy;
    408         IssmDouble  kappa,tau_parameter,diameter;
     407        IssmDouble  enthalpy, Hpmp;
     408        IssmDouble  enthalpypicard, d1enthalpypicard[3];
     409        IssmDouble  pressure, d1pressure[3], d2pressure;
     410        IssmDouble  waterfractionpicard;
     411        IssmDouble  kappa,tau_parameter,diameter,kappa_w;
    409412        IssmDouble  u,v,w;
    410         IssmDouble  scalar_def,scalar_transient;
     413        IssmDouble  scalar_def, scalar_sens ,scalar_transient;
    411414        IssmDouble* xyz_list = NULL;
     415        IssmDouble  d1H_d1P, d1P2;
    412416
    413417        /*Fetch number of nodes and dof for this finite element*/
     
    423427        element->GetVerticesCoordinates(&xyz_list);
    424428        IssmDouble  rho_ice             = element->GetMaterialParameter(MaterialsRhoIceEnum);
     429        IssmDouble  heatcapacity        = element->GetMaterialParameter(MaterialsHeatcapacityEnum);
    425430        IssmDouble  thermalconductivity = element->GetMaterialParameter(MaterialsThermalconductivityEnum);
     431        IssmDouble  temperateiceconductivity = element->GetMaterialParameter(MaterialsTemperateiceconductivityEnum);
     432        IssmDouble  beta                = element->GetMaterialParameter(MaterialsBetaEnum);
     433        IssmDouble  latentheat          = element->GetMaterialParameter(MaterialsLatentheatEnum);
    426434        element->FindParam(&dt,TimesteppingTimeStepEnum);
    427435        element->FindParam(&stabilization,ThermalStabilizationEnum);
     
    429437        Input* vy_input=element->GetInput(VyEnum); _assert_(vy_input);
    430438        Input* vz_input=element->GetInput(VzEnum); _assert_(vz_input);
    431         Input* enthalpy_input = NULL;
     439        Input* enthalpypicard_input=element->GetInput(EnthalpyPicardEnum); _assert_(enthalpypicard_input);
     440        Input* pressure_input=element->GetInput(PressureEnum); _assert_(pressure_input);
     441        Input* enthalpy_input=NULL;
    432442        if(reCast<bool,IssmDouble>(dt)){enthalpy_input = element->GetInput(EnthalpyEnum); _assert_(enthalpy_input);}
    433443        if(stabilization==2){
     
    443453                element->JacobianDeterminant(&Jdet,xyz_list,gauss);
    444454                element->NodalFunctions(basis,gauss);
     455               
     456                /*viscous dissipation*/
    445457                element->ViscousHeating(&phi,xyz_list,gauss,vx_input,vy_input,vz_input);
    446458
     
    448460                if(dt!=0.) scalar_def=scalar_def*dt;
    449461
    450                 /*TODO: add -beta*laplace T_m(p)*/
    451                 for(int i=0;i<numnodes;i++) pe->values[i]+=scalar_def*basis[i];
     462                for(i=0;i<numnodes;i++) pe->values[i]+=scalar_def*basis[i];
     463
     464                /*sensible heat flux in temperate ice*/
     465                enthalpypicard_input->GetInputValue(&enthalpypicard,gauss);
     466                pressure_input->GetInputValue(&pressure,gauss);
     467                Hpmp=this->PureIceEnthalpy(element, pressure);
     468
     469                if(enthalpypicard>=Hpmp){
     470                        enthalpypicard_input->GetInputDerivativeValue(&d1enthalpypicard[0],xyz_list,gauss);
     471                        pressure_input->GetInputDerivativeValue(&d1pressure[0],xyz_list,gauss);
     472                        d2pressure=0.; // for linear elements, 2nd derivative is zero
     473                       
     474                        d1H_d1P=0.;
     475                        for(i=0;i<3;i++) d1H_d1P+=d1enthalpypicard[i]*d1pressure[i];
     476                        d1P2=0.;
     477                        for(i=0;i<3;i++) d1P2+=pow(d1pressure[i],2.);
     478
     479                        scalar_sens=-beta*((temperateiceconductivity - thermalconductivity)/latentheat*(d1H_d1P + beta*heatcapacity*d1P2))/rho_ice;
     480                        if(dt!=0.) scalar_sens=scalar_sens*dt;
     481                        for(i=0;i<numnodes;i++) pe->values[i]+=scalar_sens*basis[i];
     482                }               
    452483
    453484                /* Build transient now */
     
    455486                        enthalpy_input->GetInputValue(&enthalpy, gauss);
    456487                        scalar_transient=enthalpy*Jdet*gauss->weight;
    457                         for(int i=0;i<numnodes;i++) pe->values[i]+=scalar_transient*basis[i];
     488                        for(i=0;i<numnodes;i++) pe->values[i]+=scalar_transient*basis[i];
    458489                }
    459490
     
    466497                        tau_parameter=element->StabilizationParameter(u,v,w,diameter,kappa/rho_ice);
    467498
    468                         for(int i=0;i<numnodes;i++) pe->values[i]+=tau_parameter*scalar_def*(u*dbasis[0*numnodes+i]+v*dbasis[1*numnodes+i]+w*dbasis[2*numnodes+i]);
     499                        for(i=0;i<numnodes;i++) pe->values[i]+=tau_parameter*scalar_def*(u*dbasis[0*numnodes+i]+v*dbasis[1*numnodes+i]+w*dbasis[2*numnodes+i]);
    469500
    470501                        if(dt!=0.){
    471                                 for(int i=0;i<numnodes;i++) pe->values[i]+=tau_parameter*scalar_transient*(u*dbasis[0*numnodes+i]+v*dbasis[1*numnodes+i]+w*dbasis[2*numnodes+i]);
     502                                for(i=0;i<numnodes;i++) pe->values[i]+=tau_parameter*scalar_transient*(u*dbasis[0*numnodes+i]+v*dbasis[1*numnodes+i]+w*dbasis[2*numnodes+i]);
    472503                        }
    473504                }
     
    484515ElementVector* EnthalpyAnalysis::CreatePVectorSheet(Element* element){/*{{{*/
    485516
    486         /* Geothermal flux on ice sheet base and basal friction */
     517        /* implementation of the basal condition decision chart of Aschwanden 2012, Fig.5 */
    487518        if(!element->IsOnBed() || element->IsFloating()) return NULL;
    488519
     
    527558                watercolumn_input->GetInputValue(&watercolumn,gauss);
    528559
    529                 if((watercolumn<=0.) && (enthalpy < PureIceEnthalpy(element,pressure))){
     560                if((watercolumn<=0.) && (enthalpy<PureIceEnthalpy(element,pressure))){
    530561                        /* the above check is equivalent to
    531                          NOT ((watercolumn>0.) AND (enthalpy<PIE)) AND (enthalpy<PIE)*/
     562                         NOT [(watercolumn>0.) AND (enthalpy<PIE)] AND (enthalpy<PIE)*/
    532563                        geothermalflux_input->GetInputValue(&geothermalflux,gauss);
    533564
     
    549580                        pressure_input->GetInputValue(&pressureup,gaussup);
    550581                        if(enthalpyup >= PureIceEnthalpy(element,pressureup)){
    551                                 // TODO: temperate ice has positive thickness: grad enthalpy*n=0.
     582                                // do nothing, set grad enthalpy*n=0.
    552583                        }
    553584                        else{
     
    556587                }
    557588                else{
    558                         // base cold, but watercolumn positive. Set base to h_pmp.
     589                        // base cold, but watercolumn positive. Set base to pressure melting point enthalpy
    559590                }
    560591        }
     
    810841        }
    811842}/*}}}*/
     843
     844
     845
     846
     847
     848
    812849void EnthalpyAnalysis::ComputeBasalMeltingrate(Element* element){/*{{{*/
    813 
    814 }/*}}}*/
    815 void EnthalpyAnalysis::DrainWaterfraction(Element* element){/*{{{*/
    816 
    817 }/*}}}*/
     850        /*Calculate the basal melt rates of the enthalpy model after Aschwanden 2012*/
     851        /* melting rate is positive when melting, negative when refreezing*/
     852
     853        /* Intermediaries */
     854        int         i,is,vertexdown,vertexup,dim=3,numvertices,numsegments;
     855        IssmDouble  heatflux;
     856        IssmDouble  vec_heatflux[dim],normal_base[dim],d1enthalpy[dim];
     857        IssmDouble  temperature, waterfraction;
     858        IssmDouble  basalfriction,alpha2;
     859        IssmDouble  dt,yts;
     860        IssmDouble  melting_overshoot,lambda;
     861        IssmDouble  geothermalflux;
     862        IssmDouble  vx,vy,vz;
     863        IssmDouble *xyz_list      = NULL;
     864        IssmDouble *xyz_list_base = NULL;
     865        int        *pairindices   = NULL;
     866
     867        /* Only compute melt rates at the base of grounded ice*/
     868        if(!element->IsOnBed() || element->IsFloating()) return;
     869
     870        /*Fetch parameters and inputs */
     871        element->GetVerticesCoordinates(&xyz_list);
     872        element->GetVerticesCoordinatesBase(&xyz_list_base);
     873        IssmDouble latentheat = element->GetMaterialParameter(MaterialsLatentheatEnum);
     874        IssmDouble rho_ice    = element->GetMaterialParameter(MaterialsRhoIceEnum);
     875        //Input* watercolumn_input      = inputs->GetInput(WatercolumnEnum);                 _assert_(watercolumn_input);
     876        Input* enthalpy_input         = element->GetInput(EnthalpyEnum);                    _assert_(enthalpy_input);
     877        //  Input* pressure_input         = inputs->GetInput(PressureEnum);                    _assert_(pressure_input);
     878        //      Input* basalmeltingrate_input = inputs->GetInput(BasalforcingsMeltingRateEnum);    _assert_(basalmeltingrate_input);
     879        Input* geothermalflux_input   = element->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input);
     880        Input* vx_input               = element->GetInput(VxEnum);                          _assert_(vx_input);
     881        Input* vy_input               = element->GetInput(VyEnum);                          _assert_(vy_input);
     882        Input* vz_input               = element->GetInput(VzEnum);                          _assert_(vz_input);
     883        IssmDouble kappa=EnthalpyDiffusionParameterVolume(element,EnthalpyEnum);     _assert_(kappa>0.);
     884        element->NormalBase(&normal_base[0],xyz_list_base);
     885        element->VerticalSegmentIndices(&pairindices,&numsegments);
     886        IssmDouble* meltingrate_enthalpy = xNew<IssmDouble>(numsegments);
     887        IssmDouble* heating = xNew<IssmDouble>(numsegments);   
     888
     889        /*Build friction element, needed later: */
     890        Friction* friction=new Friction(element,dim);
     891
     892        /******** MELTING RATES  ************************************/
     893        numvertices=element->GetNumberOfVertices();
     894        IssmDouble* enthalpy = xNew<IssmDouble>(numvertices);
     895        IssmDouble* pressure = xNew<IssmDouble>(numvertices);
     896        IssmDouble* watercolumn = xNew<IssmDouble>(numvertices);
     897        IssmDouble* basalmeltingrate = xNew<IssmDouble>(numvertices);
     898        element->GetInputListOnVertices(enthalpy,EnthalpyEnum);
     899        element->GetInputListOnVertices(pressure,PressureEnum);
     900        element->GetInputListOnVertices(watercolumn,WatercolumnEnum);
     901        element->GetInputListOnVertices(basalmeltingrate,BasalforcingsMeltingRateEnum);
     902
     903        Gauss* gauss=element->NewGauss();
     904       
     905        for(int is=0;is<numsegments;is++){
     906                vertexdown = pairindices[is*2+0];
     907                vertexup   = pairindices[is*2+1];
     908                gauss->GaussVertex(vertexdown);
     909               
     910                bool checkpositivethickness=true;
     911                _assert_(watercolumn>=0.);
     912
     913                /*Calculate basal meltingrate after Fig.5 of A.Aschwanden 2012*/
     914                meltingrate_enthalpy[is]=0.;
     915                heating[is]=0.;
     916                if((watercolumn[vertexdown]>0.) && (enthalpy[vertexdown]<PureIceEnthalpy(element,pressure[vertexdown]))){
     917                        /*ensure that no ice is at T<Tm(p), if water layer present*/
     918                        enthalpy[vertexdown]=element->PureIceEnthalpy(pressure[vertexdown]);
     919                }
     920                else if(enthalpy[vertexdown]<element->PureIceEnthalpy(pressure[vertexdown])){
     921                        /*cold base: set q*n=q_geo*n+frictionheating as Neumann BC in Penta::CreatePVectorEnthalpySheet*/
     922                        checkpositivethickness=false; // cold base, skip next test
     923                }
     924                else{/*we have a temperate base, go to next test*/}
     925
     926                if(checkpositivethickness){
     927                        /*From here on all basal ice is temperate. Check for positive thickness of layer of temperate ice. */
     928                        bool istemperatelayer=false;
     929                        if(enthalpy[vertexup]>=element->PureIceEnthalpy(pressure[vertexup])) istemperatelayer=true;
     930                        if(istemperatelayer) for(i=0;i<dim;i++) vec_heatflux[i]=0.; // TODO: add -k*nabla T_pmp
     931                        else{
     932                                enthalpy_input->GetInputDerivativeValue(&d1enthalpy[0],xyz_list,gauss);
     933                                for(i=0;i<3;i++) vec_heatflux[i]=-kappa*d1enthalpy[i];
     934                        }
     935
     936                        /*heat flux along normal*/
     937                        heatflux=0.;
     938                        for(i=0;i<3;i++) heatflux+=(vec_heatflux[i])*normal_base[i];
     939
     940                        /*basal friction*/
     941                        friction->GetAlpha2(&alpha2,gauss,vx_input,vy_input,vz_input);
     942                        vx_input->GetInputValue(&vx,gauss);
     943                        vy_input->GetInputValue(&vy,gauss);
     944                        vz_input->GetInputValue(&vz,gauss);
     945                        basalfriction=alpha2*(vx*vx + vy*vy + vz*vz);
     946
     947                        element->EnthalpyToThermal(&temperature,&waterfraction,enthalpy[vertexdown],pressure[vertexdown]);
     948                        geothermalflux_input->GetInputValue(&geothermalflux,gauss);
     949                        // -Mb= Fb-(q-q_geo)/((1-w)*L), cf Aschwanden 2012, eq.66
     950                        heating[is]=(heatflux+basalfriction+geothermalflux);
     951                        meltingrate_enthalpy[is]=heating[is]/((1-waterfraction)*latentheat*rho_ice); // m/s water equivalent //????
     952                }
     953        }
     954        // enthalpy might have been changed, update
     955        //element->AddInput(EnthalpyEnum,enthalpy,P1Enum);
     956
     957        /******** DRAINAGE *****************************************/
     958        IssmDouble* drainrate_column = xNew<IssmDouble>(numsegments); //TODO: xDelete?
     959        IssmDouble* drainrate_element = xNew<IssmDouble>(numsegments);
     960        for(is=0;is<numsegments;is++)   drainrate_column[is]=0.;
     961        Element* elementi = element;
     962        for(;;){
     963                for(is=0;is<numsegments;is++)   drainrate_element[is]=0.;
     964                DrainWaterfraction(elementi,drainrate_element); // TODO: make sure every vertex is only drained once
     965                for(is=0;is<numsegments;is++)   drainrate_column[is]+=drainrate_element[is];
     966
     967                if(elementi->IsOnSurface()) break;
     968                elementi=elementi->GetUpperElement();                   
     969        }
     970        // add drained water to melting rate
     971        for(is=0;is<numsegments;is++) meltingrate_enthalpy[is]+=drainrate_column[is];
     972
     973        /******** UPDATE MELTINGRATES AND WATERCOLUMN **************/
     974        element->FindParam(&dt,TimesteppingTimeStepEnum);
     975        for(is=0;is<numsegments;is++){
     976                vertexdown = pairindices[is*2+0];
     977                vertexup   = pairindices[is*2+1];
     978                if(reCast<bool,IssmDouble>(dt)){
     979                        if(watercolumn[vertexdown]+meltingrate_enthalpy[is]*dt<0.){     // prevent too much freeze on                   
     980                                melting_overshoot=watercolumn[vertexdown]+meltingrate_enthalpy[is]*dt;
     981                                lambda=melting_overshoot/(meltingrate_enthalpy[is]*dt); _assert_(lambda>0); _assert_(lambda<1);
     982                                basalmeltingrate[vertexdown]=(1.-lambda)*meltingrate_enthalpy[is];
     983                                watercolumn[vertexdown]=0.;
     984                                yts=365*24*60*60;
     985                                enthalpy[vertexdown]+=dt/yts*lambda*heating[is];
     986                        }
     987                        else{
     988                                basalmeltingrate[vertexdown]=meltingrate_enthalpy[is];
     989                                watercolumn[vertexdown]+=dt*meltingrate_enthalpy[is];
     990                        }
     991                }
     992                else{
     993                        basalmeltingrate[vertexdown]=meltingrate_enthalpy[is];
     994                        watercolumn[vertexdown]+=meltingrate_enthalpy[is];
     995                }               
     996                _assert_(watercolumn[vertexdown]>=0.);
     997        }
     998
     999        /*feed updated variables back into model*/
     1000        element->AddInput(EnthalpyEnum,enthalpy,P1Enum);
     1001        element->AddInput(WatercolumnEnum,watercolumn,P1Enum);
     1002        element->AddInput(BasalforcingsMeltingRateEnum,basalmeltingrate,P1Enum);
     1003
     1004        /*Clean up and return*/
     1005        delete gauss;
     1006        delete friction;
     1007        xDelete<IssmDouble>(enthalpy);
     1008        xDelete<IssmDouble>(pressure);
     1009        xDelete<IssmDouble>(watercolumn);
     1010        xDelete<IssmDouble>(basalmeltingrate);
     1011        xDelete<IssmDouble>(meltingrate_enthalpy);
     1012        xDelete<IssmDouble>(heating);
     1013        xDelete<IssmDouble>(drainrate_column);
     1014        xDelete<IssmDouble>(drainrate_element);
     1015}/*}}}*/
     1016
     1017void EnthalpyAnalysis::DrainWaterfraction(Element* element, IssmDouble* pdrainrate_element){/*{{{*/
     1018
     1019        /*Intermediaries*/
     1020        int iv,is,vertexdown,vertexup,numsegments;     
     1021        IssmDouble dt, height_element;
     1022        IssmDouble rho_water, rho_ice;
     1023        int numvertices = element->GetNumberOfVertices();
     1024
     1025        IssmDouble* xyz_list = NULL;
     1026        IssmDouble* enthalpies = xNew<IssmDouble>(numvertices);
     1027        IssmDouble* pressures = xNew<IssmDouble>(numvertices);
     1028        IssmDouble* temperatures = xNew<IssmDouble>(numvertices);
     1029        IssmDouble* waterfractions = xNew<IssmDouble>(numvertices);
     1030        IssmDouble* deltawaterfractions = xNew<IssmDouble>(numvertices);
     1031        int        *pairindices   = NULL;
     1032       
     1033        rho_ice=element->GetMaterialParameter(MaterialsRhoIceEnum);
     1034        rho_water=element->GetMaterialParameter(MaterialsRhoWaterEnum);
     1035
     1036        element->GetVerticesCoordinates(&xyz_list);
     1037        element->GetInputListOnVertices(enthalpies,EnthalpyEnum);
     1038        element->GetInputListOnVertices(pressures,PressureEnum);
     1039
     1040        element->FindParam(&dt,TimesteppingTimeStepEnum);
     1041        for(iv=0;iv<numvertices;iv++){
     1042                element->EnthalpyToThermal(&temperatures[iv],&waterfractions[iv], enthalpies[iv],pressures[iv]);
     1043                deltawaterfractions[iv]=DrainageFunctionWaterfraction(waterfractions[iv], dt);
     1044        }
     1045       
     1046        /*drain waterfraction, feed updated variables back into model*/
     1047        for(iv=0;iv<numvertices;iv++){
     1048                if(reCast<bool,IssmDouble>(dt))
     1049                        waterfractions[iv]-=deltawaterfractions[iv]*dt;
     1050                else
     1051                        waterfractions[iv]-=deltawaterfractions[iv];
     1052                element->ThermalToEnthalpy(&enthalpies[iv], temperatures[iv], waterfractions[iv], pressures[iv]);
     1053        }
     1054        element->AddInput(EnthalpyEnum,enthalpies,P1Enum);
     1055        element->AddInput(WaterfractionEnum,waterfractions,P1Enum);
     1056
     1057        /*return meltwater column equivalent to drained water*/
     1058        element->VerticalSegmentIndices(&pairindices,&numsegments);
     1059        for(is=0;is<numsegments;is++){
     1060                vertexdown = pairindices[is*2+0];
     1061                vertexup   = pairindices[is*2+1];
     1062                height_element=fabs(xyz_list[vertexup*3+2]-xyz_list[vertexdown*3+2]);
     1063                pdrainrate_element[is]=(deltawaterfractions[vertexdown]+deltawaterfractions[vertexup])/2.*rho_water/rho_ice*height_element;
     1064        }
     1065
     1066        /*Clean up and return*/
     1067        xDelete<IssmDouble>(xyz_list);
     1068        xDelete<IssmDouble>(enthalpies);
     1069        xDelete<IssmDouble>(pressures);
     1070        xDelete<IssmDouble>(temperatures);
     1071        xDelete<IssmDouble>(waterfractions);
     1072        xDelete<IssmDouble>(deltawaterfractions);
     1073}/*}}}*/
     1074
     1075
     1076
     1077
     1078
    8181079void EnthalpyAnalysis::UpdateBasalConstraints(Element* element){/*{{{*/
    8191080
    820 }/*}}}*/
     1081        /* /\*Intermediary*\/ */
     1082        /* bool        isdynamicbasalspc,setspc; */
     1083        /* int         numindices, numindicesup; */
     1084        /* IssmDouble  pressure, pressureup; */
     1085        /* IssmDouble  h_pmp, enthalpy, enthalpyup; */
     1086        /* IssmDouble  watercolumn; */
     1087        /* int        *indices = NULL, *indicesup = NULL; */
     1088       
     1089        /* /\* Only update Constraints at the base of grounded ice*\/ */
     1090        /* if(!IsOnBed() || IsFloating()) return; */
     1091
     1092        /* /\*Check wether dynamic basal boundary conditions are activated *\/ */
     1093        /* element->FindParam(&isdynamicbasalspc,ThermalIsdynamicbasalspcEnum); */
     1094        /* if(!isdynamicbasalspc) return; */
     1095
     1096        /* /\*Fetch indices of basal & surface nodes for this finite element*\/ */
     1097        /* // BasalNodeIndices(&numindices,&indices,this->element_type); */
     1098        /* // SurfaceNodeIndices(&numindicesup,&indicesup,this->element_type); */
     1099        /* //   _assert_(numindices==numindicesup); */
     1100
     1101        /* /\*Get parameters and inputs: *\/ */
     1102        /* Input* pressure_input=inputs->GetInput(PressureEnum); _assert_(pressure_input); */
     1103        /* Input* enthalpy_input=inputs->GetInput(EnthalpyEnum); _assert_(enthalpy_input); */
     1104        /* Input* watercolumn_input=inputs->GetInput(WatercolumnEnum); _assert_(watercolumn_input); */
     1105
     1106        /* /\*if there is a temperate layer of zero thickness, set spc enthalpy=h_pmp at that node*\/ */
     1107        /* GaussPenta* gauss=new GaussPenta(); */
     1108        /* GaussPenta* gaussup=new GaussPenta(); */
     1109        /* for(int i=0;i<numindices;i++){ */
     1110        /*      gauss->GaussNode(this->element_type,indices[i]); */
     1111        /*      gaussup->GaussNode(this->element_type,indicesup[i]); */
     1112
     1113        /*      /\*Check wether there is a temperate layer at the base or not *\/ */
     1114        /*      /\*check if node is temperate, if not, continue*\/ */
     1115        /*      enthalpy_input->GetInputValue(&enthalpy, gauss); */
     1116        /*      pressure_input->GetInputValue(&pressure, gauss); */
     1117        /*      watercolumn_input->GetInputValue(&watercolumn,gauss); */
     1118        /*      setspc = false; */
     1119        /*      // TODO: add case H<Hpmp && watercolumn>0.; */
     1120        /*      if (enthalpy>=element->PureIceEnthalpy(pressure)){ */
     1121        /*              /\*check if upper node is temperate, too. */
     1122        /*                      if yes, then we have a temperate layer of positive thickness and reset the spc. */
     1123        /*                      if not, apply dirichlet BC.*\/ */
     1124        /*              enthalpy_input->GetInputValue(&enthalpyup, gaussup); */
     1125        /*              pressure_input->GetInputValue(&pressureup, gaussup); */
     1126        /*              setspc=((enthalpyup<element->PureIceEnthalpy(pressureup)) && (watercolumn>=0.))?true:false; */
     1127        /*      } */
     1128
     1129        /*      if (setspc) { */
     1130        /*              /\*Calculate enthalpy at pressure melting point *\/ */
     1131        /*              h_pmp=matpar->PureIceEnthalpy(pressure); */
     1132        /*              /\*Apply Dirichlet condition (dof = 0 here, since there is only one degree of freedom per node)*\/ */
     1133        /*              //element->ApplyConstraint(indices[i],1,h_pmp); */
     1134        /*              //nodes[indices[i]]->ApplyConstraint(1,h_pmp); */
     1135        /*      } */
     1136        /*      else { */
     1137        /*              /\*remove spc*\/ */
     1138        /*              //element->RemoveConstraint(indices[i],0); */
     1139        /*              //nodes[indices[i]]->DofInFSet(0); */
     1140        /*      } */
     1141        /* } */
     1142
     1143        /* /\*Free ressources:*\/ */
     1144        /* xDelete<int>(indices); */
     1145        /* xDelete<int>(indicesup); */
     1146        /* delete gauss; */
     1147        /* delete gaussup; */
     1148}/*}}}*/
     1149
     1150
     1151
     1152
    8211153
    8221154/*Intermediaries*/
  • issm/trunk-jpl/src/c/analyses/EnthalpyAnalysis.h

    r17005 r17014  
    4040                static void PostProcessing(FemModel* femmodel);
    4141                static void ComputeBasalMeltingrate(Element* element);
    42                 static void DrainWaterfraction(Element* element);
     42                static void DrainWaterfraction(Element* element, IssmDouble* pdrainrate_element);
    4343                static void UpdateBasalConstraints(Element* element);
    4444
    4545                /*Intermediaries*/
    46                 IssmDouble EnthalpyDiffusionParameter(Element* element,IssmDouble enthalpy,IssmDouble pressure);
    47                 IssmDouble EnthalpyDiffusionParameterVolume(Element* element,int enthalpy_enum);
    48                 IssmDouble PureIceEnthalpy(Element* element,IssmDouble pressure);
    49                 IssmDouble TMeltingPoint(Element* element,IssmDouble pressure);
     46                static IssmDouble EnthalpyDiffusionParameter(Element* element,IssmDouble enthalpy,IssmDouble pressure);
     47                static IssmDouble EnthalpyDiffusionParameterVolume(Element* element,int enthalpy_enum);
     48                static IssmDouble PureIceEnthalpy(Element* element,IssmDouble pressure);
     49                static IssmDouble TMeltingPoint(Element* element,IssmDouble pressure);
    5050};
    5151#endif
  • issm/trunk-jpl/src/c/classes/Elements/Element.h

    r17001 r17014  
    105105                virtual void       SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum)=0;
    106106                virtual void   ElementSizes(IssmDouble* phx,IssmDouble* phy,IssmDouble* phz)=0;
     107                virtual void   ThermalToEnthalpy(IssmDouble* penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure)=0;
    107108                virtual void   EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure)=0;
    108109                virtual IssmDouble EnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure)=0;
     
    123124                virtual IssmDouble PureIceEnthalpy(IssmDouble pressure)=0;
    124125
     126                virtual Element* GetUpperElement(void)=0;
     127                virtual Element* GetLowerElement(void)=0;
     128                virtual Element* GetSurfaceElement(void)=0;
    125129                virtual Element* GetBasalElement(void)=0;
    126130                virtual void    GetDofList(int** pdoflist,int approximation_enum,int setenum)=0;
  • issm/trunk-jpl/src/c/classes/Elements/Penta.cpp

    r17001 r17014  
    134134                                penta->inputs->AddInput(new PentaInput(input_enum,&extrudedvalues[0],P1Enum));
    135135                                if (penta->IsOnSurface()) break;
    136                                 penta=penta->GetUpperElement(); _assert_(penta->Id()!=this->id);
     136                                penta=penta->GetUpperPenta(); _assert_(penta->Id()!=this->id);
    137137                        }
    138138                }
     
    148148}
    149149/*}}}*/
    150 
    151150/*FUNCTION Penta::BasalFrictionCreateInput {{{*/
    152151void Penta::BasalFrictionCreateInput(void){
     
    479478}
    480479/*}}}*/
     480/*FUNCTION Penta::ThermalToEnthalpy{{{*/
     481void Penta::ThermalToEnthalpy(IssmDouble* penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure){
     482        matpar->ThermalToEnthalpy(penthalpy,temperature,waterfraction,pressure);
     483}
     484/*}}}*/
    481485/*FUNCTION Penta::EnthalpyToThermal{{{*/
    482486void Penta::EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure){
     
    542546}
    543547/*}}}*/
    544 /*FUNCTION Penta::GetBasalElement{{{*/
    545 Element* Penta::GetBasalElement(void){
     548/*FUNCTION Penta::GetUpperPenta{{{*/
     549Penta* Penta::GetUpperPenta(void){
     550
     551        Penta* upper_penta=NULL;
     552
     553        upper_penta=(Penta*)verticalneighbors[1]; //first one (0) under, second one (1) above
     554
     555        return upper_penta;
     556}
     557/*}}}*/
     558/*FUNCTION Penta::GetLowerPenta{{{*/
     559Penta* Penta::GetLowerPenta(void){
     560
     561        Penta* lower_penta=NULL;
     562
     563        lower_penta=(Penta*)verticalneighbors[0]; //first one (0) under, second one (1) above
     564
     565        return lower_penta;
     566}
     567/*}}}*/
     568/*FUNCTION Penta::GetSurfacePenta{{{*/
     569Penta* Penta::GetSurfacePenta(void){
    546570
    547571        /*Output*/
    548572        Penta* penta=NULL;
    549573
    550         /*Go through all elements till the bed is reached*/
     574        /*Go through all pentas till the surface is reached*/
     575        penta=this;
     576        for(;;){
     577                /*Stop if we have reached the surface, else, take upper penta*/
     578                if (penta->IsOnSurface()) break;
     579
     580                /* get upper Penta*/
     581                penta=penta->GetUpperPenta();
     582                _assert_(penta->Id()!=this->id);
     583        }
     584
     585        /*return output*/
     586        return penta;
     587}
     588/*}}}*/
     589/*FUNCTION Penta::GetBasalPenta{{{*/
     590Penta* Penta::GetBasalPenta(void){
     591
     592        /*Output*/
     593        Penta* penta=NULL;
     594
     595        /*Go through all pentas till the bed is reached*/
    551596        penta=this;
    552597        for(;;){
     
    555600
    556601                /* get lower Penta*/
    557                 penta=penta->GetLowerElement();
     602                penta=penta->GetLowerPenta();
    558603                _assert_(penta->Id()!=this->id);
    559604        }
     
    561606        /*return output*/
    562607        return penta;
     608}
     609/*}}}*/
     610/*FUNCTION Penta::GetUpperElement{{{*/
     611Element* Penta::GetUpperElement(void){
     612
     613        /*Output*/
     614        Element* upper_element=this->GetUpperPenta();
     615        return upper_element;
     616}
     617/*}}}*/
     618/*FUNCTION Penta::GetLowerElement{{{*/
     619Element* Penta::GetLowerElement(void){
     620
     621        /*Output*/
     622        Element* lower_element=this->GetLowerPenta();
     623        return lower_element;
     624}
     625/*}}}*/
     626/*FUNCTION Penta::GetSurfaceElement{{{*/
     627Element* Penta::GetSurfaceElement(void){
     628
     629        /*Output*/
     630        Element* element=this->GetSurfacePenta();
     631        return element;
     632}
     633/*}}}*/
     634/*FUNCTION Penta::GetBasalElement{{{*/
     635Element* Penta::GetBasalElement(void){
     636
     637        /*Output*/
     638        Element* element=this->GetBasalPenta();
     639        return element;
    563640}
    564641/*}}}*/
     
    833910}
    834911/*}}}*/
    835 /*FUNCTION Penta::GetLowerElement{{{*/
    836 Penta* Penta::GetLowerElement(void){
    837 
    838         Penta* upper_penta=NULL;
    839 
    840         upper_penta=(Penta*)verticalneighbors[0]; //first one (0) under, second one (1) above
    841 
    842         return upper_penta;
    843 }
    844 /*}}}*/
    845912/*FUNCTION Penta::GetNodeIndex {{{*/
    846913int Penta::GetNodeIndex(Node* node){
     
    11211188
    11221189        return tau_parameter;
    1123 }
    1124 /*}}}*/
    1125 /*FUNCTION Penta::GetUpperElement{{{*/
    1126 Penta* Penta::GetUpperElement(void){
    1127 
    1128         Penta* upper_penta=NULL;
    1129 
    1130         upper_penta=(Penta*)verticalneighbors[1]; //first one under, second one above
    1131 
    1132         return upper_penta;
    11331190}
    11341191/*}}}*/
     
    14861543
    14871544                /* get upper Penta*/
    1488                 penta=penta->GetUpperElement();
     1545                penta=penta->GetUpperPenta();
    14891546                _assert_(penta->Id()!=this->id);
    14901547
     
    15551612        for(;;){
    15561613                /* get upper Penta*/
    1557                 penta=penta->GetUpperElement();
     1614                penta=penta->GetUpperPenta();
    15581615                _assert_(penta->Id()!=this->id);
    15591616
     
    17781835
    17791836                /* get upper Penta*/
    1780                 penta=penta->GetUpperElement(); _assert_(penta->Id()!=this->id);
     1837                penta=penta->GetUpperPenta(); _assert_(penta->Id()!=this->id);
    17811838        }
    17821839
     
    34163473
    34173474                if(penta->IsOnSurface()) break;
    3418                 penta=penta->GetUpperElement();                 
     3475                penta=penta->GetUpperPenta();                   
    34193476        }
    34203477        // add drained water to melting rate
     
    34603517void Penta::DrainWaterfraction(IssmDouble* drainrate_element){
    34613518
    3462     /*Intermediaries*/
     3519  /*Intermediaries*/
    34633520        bool isenthalpy;
    34643521        int iv, index0;
     
    46094666                       
    46104667                        /* get upper Penta*/
    4611                         penta=penta->GetUpperElement(); _assert_(penta->Id()!=this->id);
     4668                        penta=penta->GetUpperPenta(); _assert_(penta->Id()!=this->id);
    46124669                }
    46134670        }
  • issm/trunk-jpl/src/c/classes/Elements/Penta.h

    r17001 r17014  
    7272                void   SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum);
    7373                void   Delta18oParameterization(void);
     74                void   ThermalToEnthalpy(IssmDouble* penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure);
    7475                void   EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure);
     76                Penta* GetUpperPenta(void);
     77                Penta* GetLowerPenta(void);
     78                Penta* GetSurfacePenta(void);
     79                Penta* GetBasalPenta(void);
     80                Element* GetUpperElement(void);
     81                Element* GetLowerElement(void);
     82                Element* GetSurfaceElement(void);
    7583                Element* GetBasalElement(void);
    7684                void     GetDofList(int** pdoflist,int approximation_enum,int setenum);
     
    211219                void           GetMaterialInputValue(IssmDouble* pvalue,Node* node,int enumtype);
    212220                Node*          GetNode(int node_number);
    213                 Penta*         GetUpperElement(void);
    214                 Penta*         GetLowerElement(void);
    215221                void           InputChangeName(int input_enum, int enum_type_old);
    216222                void             InputExtrude(int enum_type,int object_type);
  • issm/trunk-jpl/src/c/classes/Elements/Seg.h

    r17001 r17014  
    7171                void        Delta18oParameterization(void){_error_("not implemented yet");};
    7272                void        ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz){_error_("not implemented yet");};
     73                void        ThermalToEnthalpy(IssmDouble* penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure){_error_("not implemented yet");};
    7374                void        EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure){_error_("not implemented yet");};
    7475                IssmDouble  EnthalpyDiffusionParameter(IssmDouble enthalpy,IssmDouble pressure){_error_("not implemented");};
    7576                IssmDouble  EnthalpyDiffusionParameterVolume(int numvertices,IssmDouble* enthalpy,IssmDouble* pressure){_error_("not implemented");};
    7677                int         FiniteElement(void);
     78                Element*    GetUpperElement(void){_error_("not implemented yet");};
     79                Element*    GetLowerElement(void){_error_("not implemented yet");};
     80                Element*    GetSurfaceElement(void){_error_("not implemented yet");};
    7781                Element*    GetBasalElement(void){_error_("not implemented yet");};
    7882                void        GetDofList(int** pdoflist,int approximation_enum,int setenum){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Elements/Tria.h

    r17001 r17014  
    6969                void        Delta18oParameterization(void);
    7070                void        ElementSizes(IssmDouble* hx,IssmDouble* hy,IssmDouble* hz){_error_("not implemented yet");};
     71                void        ThermalToEnthalpy(IssmDouble* penthalpy,IssmDouble temperature,IssmDouble waterfraction,IssmDouble pressure){_error_("not implemented yet");};
    7172                void        EnthalpyToThermal(IssmDouble* ptemperature,IssmDouble* pwaterfraction,IssmDouble enthalpy,IssmDouble pressure){_error_("not implemented yet");};
    7273                int         FiniteElement(void);
     74                Element*    GetUpperElement(void){_error_("not implemented yet");};
     75                Element*    GetLowerElement(void){_error_("not implemented yet");};
     76                Element*    GetSurfaceElement(void){_error_("not implemented yet");};
    7377                Element*    GetBasalElement(void){_error_("not implemented yet");};
    7478                void          GetDofList(int** pdoflist,int approximation_enum,int setenum);
Note: See TracChangeset for help on using the changeset viewer.