Changeset 15896


Ignore:
Timestamp:
08/23/13 08:57:45 (12 years ago)
Author:
jbondzio
Message:

BUG: edited bugs in Penta::ComputeBasalMeltrate and Penta::DrainWaterfraction

File:
1 edited

Legend:

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

    r15895 r15896  
    52365236        /* Intermediaries */
    52375237        bool        isenthalpy;
    5238         int         i,j,ig,analysis_type,numindices,numindicesup;
     5238        int         i,j,analysis_type;
    52395239        IssmDouble  xyz_list[NUMVERTICES][3];
    52405240        IssmDouble  xyz_list_tria[NUMVERTICES2D][3];
     
    52435243        IssmDouble  normal_base[3], d1enthalpy[3];
    52445244        IssmDouble  kappa;
     5245    IssmDouble  meltrate[3], watercolumn[3];
    52455246        IssmDouble  enthalpy, enthalpyup;
    52465247        IssmDouble  pressure, pressureup;
     
    52505251        IssmDouble  vx,vy,vz;
    52515252        IssmDouble  dt;
    5252         int        *indices   = NULL;
    5253         int        *indicesup = NULL;
    52545253        Friction   *friction  = NULL;
    52555254
     
    52775276        friction=new Friction("3d",inputs,matpar,analysis_type);
    52785277
    5279         /*Fetch indices of basal and surface nodes for this finite element*/
    5280         BasalNodeIndices(&numindices,&indices,this->element_type);
    5281         SurfaceNodeIndices(&numindicesup,&indicesup,this->element_type);
    5282         _assert_(numindices==numindicesup);
    5283    
    5284         IssmDouble  meltrate[numindices], watercolumn[numindices];
    5285 
    52865278        /*Ok, get meltrates now from basal conditions*/
    52875279        GaussPenta* gauss=new GaussPenta();
    52885280        GaussPenta* gaussup=new GaussPenta();
    5289         for(ig=0;ig<numindices;ig++){
    5290                 gauss->GaussVertex(this->element_type,indices[ig]);
    5291                 gaussup->GaussNode(this->element_type,indicesup[ig]);
     5281        for(int iv=0;iv<3;iv++){
     5282                gauss->GaussVertex(iv);
     5283                gaussup->GaussNode(iv+3);
    52925284
    52935285        // TODO: make sure that no node is computed twice (insert mask)
    52945286
    5295                 watercolumn_input->GetInputValue(&watercolumn[indices[ig]], gauss);
     5287                watercolumn_input->GetInputValue(&watercolumn[iv], gauss);
    52965288                enthalpy_input->GetInputValue(&enthalpy, gauss);
    52975289                pressure_input->GetInputValue(&pressure, gauss);
    52985290
    52995291                /*Calculate basal meltrate*/
    5300                 if((watercolumn[indices[ig]]>0.) && (enthalpy<matpar->PureIceEnthalpy(pressure))){
     5292                if((watercolumn[iv]>0.) && (enthalpy<matpar->PureIceEnthalpy(pressure))){
    53015293                        enthalpy=matpar->PureIceEnthalpy(pressure);
    53025294                }
    53035295                else if(enthalpy<matpar->PureIceEnthalpy(pressure)){
    5304                         meltrate[indices[ig]]=0.;   //TODO: set zero meltrate and watercolumn in model
    5305                         watercolumn[indices[ig]]=0.;
    5306                         return;
     5296                        meltrate[iv]=0.;   
     5297                        watercolumn[iv]=0.;
     5298                        continue;
    53075299                }
    53085300
     
    53335325                vz_input->GetInputValue(&vz,gauss);
    53345326                basalfriction=alpha2*(pow(vx,2.0)+pow(vy,2.0)+pow(vz,2.0));
    5335                 meltrate[indices[ig]]=(basalfriction-(heatflux-geothermalflux_value))/(1-waterfraction)/latentheat;
     5327                meltrate[iv]=(basalfriction-(heatflux-geothermalflux_value))/(1-waterfraction)/latentheat;
    53365328
    53375329                /*Update water column*/
    53385330                this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
    53395331                if(reCast<bool,IssmDouble>(dt))
    5340             watercolumn[indices[ig]]+=dt*meltrate[indices[ig]];
     5332            watercolumn[iv]+=dt*meltrate[iv];
    53415333                else
    5342             watercolumn[indices[ig]]=meltrate[indices[ig]];
     5334            watercolumn[iv]=meltrate[iv];
    53435335        } 
    53445336    /*update meltrate and watercolumn*/
     
    53475339
    53485340        /*Clean up and return*/
    5349         xDelete<int>(indices);
    5350         xDelete<int>(indicesup);
    53515341        delete gauss;
    53525342        delete gaussup;
     
    53595349
    53605350    /*Intermediaries*/
    5361     int ig;
    53625351    bool isenthalpy;
    53635352    IssmDouble waterfraction_array[NUMVERTICES], temperature[NUMVERTICES];
     
    53765365    this->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
    53775366    latentheat=matpar->GetLatentHeat();
    5378     gauss=new GaussPenta(2,3);
    5379     for(ig=0;ig<NUMVERTICES;ig++){
    5380         gauss->GaussVertex(ig);
     5367    gauss=new GaussPenta();
     5368    for(int iv=0;iv<NUMVERTICES;iv++){
     5369        gauss->GaussVertex(iv);
    53815370        /*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]);
     5371        enthalpy_input->GetInputValue(&enthalpy[iv], gauss);
     5372        pressure_input->GetInputValue(&pressure[iv], gauss);
     5373        matpar->EnthalpyToThermal(&temperature[iv], &waterfraction[iv], enthalpy[iv],pressure[iv]);
    53855374   
    53865375        /*drain water fraction*/
    5387         waterfraction[ig]-=dt*DrainageFunctionWaterfraction(waterfraction[ig]);
    5388         if(waterfraction[ig]<0) waterfraction[ig]=0.;
     5376        waterfraction[iv]-=dt*DrainageFunctionWaterfraction(waterfraction[iv]);
     5377        if(waterfraction[iv]<0.) waterfraction[iv]=0.;
    53895378        /*update enthalpy*/
    5390         matpar->ThermalToEnthalpy(&enthalpy[ig], temperature[ig], waterfraction[ig], pressure[ig]);       
     5379        matpar->ThermalToEnthalpy(&enthalpy[iv], temperature[iv], waterfraction[iv], pressure[iv]);       
    53915380    }
    53925381    /*feed updated results back into model*/
Note: See TracChangeset for help on using the changeset viewer.