Changeset 15895


Ignore:
Timestamp:
08/23/13 08:36:26 (12 years ago)
Author:
jbondzio
Message:

CHG: updated thermal values now fed back into model.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Elements/Penta.cpp

    r15893 r15895  
    52455245        IssmDouble  enthalpy, enthalpyup;
    52465246        IssmDouble  pressure, pressureup;
    5247         IssmDouble  meltrate, watercolumn;
    52485247        IssmDouble  temperature, waterfraction;
    52495248        IssmDouble  latentheat;
     
    52825281        SurfaceNodeIndices(&numindicesup,&indicesup,this->element_type);
    52835282        _assert_(numindices==numindicesup);
     5283   
     5284        IssmDouble  meltrate[numindices], watercolumn[numindices];
    52845285
    52855286        /*Ok, get meltrates now from basal conditions*/
     
    52875288        GaussPenta* gaussup=new GaussPenta();
    52885289        for(ig=0;ig<numindices;ig++){
    5289                 gauss->GaussNode(this->element_type,indices[ig]);
     5290                gauss->GaussVertex(this->element_type,indices[ig]);
    52905291                gaussup->GaussNode(this->element_type,indicesup[ig]);
    52915292
    5292                 watercolumn_input->GetInputValue(&watercolumn, gauss);
     5293        // TODO: make sure that no node is computed twice (insert mask)
     5294
     5295                watercolumn_input->GetInputValue(&watercolumn[indices[ig]], gauss);
    52935296                enthalpy_input->GetInputValue(&enthalpy, gauss);
    52945297                pressure_input->GetInputValue(&pressure, gauss);
    52955298
    52965299                /*Calculate basal meltrate*/
    5297                 if((watercolumn>0.) && (enthalpy<matpar->PureIceEnthalpy(pressure))){
     5300                if((watercolumn[indices[ig]]>0.) && (enthalpy<matpar->PureIceEnthalpy(pressure))){
    52985301                        enthalpy=matpar->PureIceEnthalpy(pressure);
    52995302                }
    53005303                else if(enthalpy<matpar->PureIceEnthalpy(pressure)){
    5301                         meltrate=0.;   //TODO: set zero meltrate and watercolumn in model
    5302                         watercolumn=0.;
     5304                        meltrate[indices[ig]]=0.;   //TODO: set zero meltrate and watercolumn in model
     5305                        watercolumn[indices[ig]]=0.;
    53035306                        return;
    53045307                }
     
    53305333                vz_input->GetInputValue(&vz,gauss);
    53315334                basalfriction=alpha2*(pow(vx,2.0)+pow(vy,2.0)+pow(vz,2.0));
    5332                 meltrate=(basalfriction-(heatflux-geothermalflux_value))/(1-waterfraction)/latentheat;
     5335                meltrate[indices[ig]]=(basalfriction-(heatflux-geothermalflux_value))/(1-waterfraction)/latentheat;
    53335336
    53345337                /*Update water column*/
    53355338                this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
    53365339                if(reCast<bool,IssmDouble>(dt))
    5337                  watercolumn+=dt*meltrate;
     5340            watercolumn[indices[ig]]+=dt*meltrate[indices[ig]];
    53385341                else
    5339                  watercolumn=meltrate;
    5340                 // TODO: feed meltrate & watercolumn back to model
     5342            watercolumn[indices[ig]]=meltrate[indices[ig]];
    53415343        } 
     5344    /*update meltrate and watercolumn*/
     5345    this->inputs->AddInput(new PentaInput(WatercolumnEnum, watercolumn, P1Enum));
     5346    this->inputs->AddInput(new PentaInput(BasalMeltrateEnum, meltrate, P1Enum));
    53425347
    53435348        /*Clean up and return*/
     
    53545359
    53555360    /*Intermediaries*/
    5356     const int numdof=NDOF1*NUMVERTICES;
    53575361    int ig;
    53585362    bool isenthalpy;
    5359     IssmDouble waterfraction, temperature;
    5360     IssmDouble enthalpy, pressure;
     5363    IssmDouble waterfraction_array[NUMVERTICES], temperature[NUMVERTICES];
     5364    IssmDouble enthalpy[NUMVERTICES], pressure[NUMVERTICES];
    53615365    IssmDouble latentheat, dt;
    5362 
     5366    GaussPenta* gauss;
     5367   
    53635368    Input* watercolumn_input=inputs->GetInput(WatercolumnEnum);       _assert_(watercolumn_input);
    53645369        Input* enthalpy_input=inputs->GetInput(EnthalpyEnum);             _assert_(enthalpy_input);
     
    53685373        parameters->FindParam(&isenthalpy,ThermalIsenthalpyEnum);
    53695374        if(!isenthalpy) return;       
     5375   
    53705376    this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
    5371    
    5372     GaussPenta* gauss=new GaussPenta(2,3);
    5373     for(ig=gauss->begin();ig<gauss->end();ig++){
    5374         gauss->GaussPoint(ig);
    5375        
    5376         enthalpy_input->GetInputValue(&enthalpy, gauss);
    5377         pressure_input->GetInputValue(&pressure, gauss);
    5378         matpar->EnthalpyToThermal(&temperature, &waterfraction, enthalpy,pressure);
     5377    latentheat=matpar->GetLatentHeat();
     5378    gauss=new GaussPenta(2,3);
     5379    for(ig=0;ig<NUMVERTICES;ig++){
     5380        gauss->GaussVertex(ig);
     5381        /*TODO: Check whether Vertex has been drained already*/
     5382        enthalpy_input->GetInputValue(&enthalpy[ig], gauss);
     5383        pressure_input->GetInputValue(&pressure[ig], gauss);
     5384        matpar->EnthalpyToThermal(&temperature[ig], &waterfraction[ig], enthalpy[ig],pressure[ig]);
    53795385   
    53805386        /*drain water fraction*/
    5381         waterfraction-=dt*DrainageFunctionWaterfraction(waterfraction);
    5382         if(waterfraction<0) waterfraction=0.;
     5387        waterfraction[ig]-=dt*DrainageFunctionWaterfraction(waterfraction[ig]);
     5388        if(waterfraction[ig]<0) waterfraction[ig]=0.;
    53835389        /*update enthalpy*/
    5384         latentheat=matpar->GetLatentHeat();
    5385         matpar->ThermalToEnthalpy(&enthalpy, temperature, waterfraction, pressure);
    5386         //TODO feed result back into model
     5390        matpar->ThermalToEnthalpy(&enthalpy[ig], temperature[ig], waterfraction[ig], pressure[ig]);       
    53875391    }
     5392    /*feed updated results back into model*/
     5393    this->inputs->AddInput(new PentaInput(EnthalpyEnum,enthalpy,P1Enum));
     5394    this->inputs->AddInput(new PentaInput(WaterfractionEnum,waterfraction,P1Enum));
     5395    this->inputs->AddInput(new PentaInput(TemperatureEnum,temperature,P1Enum));   
    53885396}
    53895397/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.