Changeset 16809


Ignore:
Timestamp:
11/16/13 20:32:45 (11 years ago)
Author:
Mathieu Morlighem
Message:

NEW: done with Mass conservation CG and DG

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

Legend:

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

    r16782 r16809  
    216216}/*}}}*/
    217217ElementVector* MasstransportAnalysis::CreatePVector(Element* element){/*{{{*/
    218 _error_("not implemented yet");
     218
     219        if(!element->IsOnBed()) return NULL;
     220        Element* basalelement = element->SpawnBasalElement();
     221
     222        switch(element->FiniteElement()){
     223                case P1Enum: case P2Enum:
     224                        return CreatePVectorCG(basalelement);
     225                case P1DGEnum:
     226                        return CreatePVectorDG(basalelement);
     227                default:
     228                        _error_("Element type " << EnumToStringx(element->FiniteElement()) << " not supported yet");
     229        }
     230
     231}/*}}}*/
     232ElementVector* MasstransportAnalysis::CreatePVectorCG(Element* element){/*{{{*/
     233
     234        /*Intermediaries */
     235        IssmDouble  Jdet,dt;
     236        IssmDouble  ms,mb,mb_correction=0.,thickness;
     237        IssmDouble* xyz_list;
     238
     239        /*Fetch number of nodes and dof for this finite element*/
     240        int numnodes = element->GetNumberOfNodes();
     241
     242        /*Initialize Element vector and other vectors*/
     243        ElementVector* pe    = element->NewElementVector();
     244        IssmDouble*    basis = xNew<IssmDouble>(numnodes);
     245
     246        /*Retrieve all inputs and parameters*/
     247        element->GetVerticesCoordinates(&xyz_list);
     248        element->FindParam(&dt,TimesteppingTimeStepEnum);
     249        Input* mb_correction_input = element->GetInput(BasalforcingsMeltingRateCorrectionEnum);
     250        Input* mb_input            = element->GetInput(BasalforcingsMeltingRateEnum);     _assert_(mb_input);
     251        Input* ms_input            = element->GetInput(SurfaceforcingsMassBalanceEnum);   _assert_(ms_input);
     252        Input* thickness_input     = element->GetInput(ThicknessEnum);                    _assert_(thickness_input);
     253
     254        /*Initialize mb_correction to 0, do not forget!:*/
     255        /* Start  looping on the number of gaussian points: */
     256        Gauss* gauss=element->NewGauss(2);
     257        for(int ig=gauss->begin();ig<gauss->end();ig++){
     258                gauss->GaussPoint(ig);
     259
     260                element->JacobianDeterminant(&Jdet,xyz_list,gauss);
     261                element->NodalFunctions(basis,gauss);
     262
     263                ms_input->GetInputValue(&ms,gauss);
     264                mb_input->GetInputValue(&mb,gauss);
     265                thickness_input->GetInputValue(&thickness,gauss);
     266                if(mb_correction_input)
     267                 mb_correction_input->GetInputValue(&mb_correction,gauss);
     268
     269                for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight*(thickness+dt*(ms-mb-mb_correction))*basis[i];
     270        }
     271
     272        /*Clean up and return*/
     273        xDelete<IssmDouble>(xyz_list);
     274        xDelete<IssmDouble>(basis);
     275        delete gauss;
     276        return pe;
     277}/*}}}*/
     278ElementVector* MasstransportAnalysis::CreatePVectorDG(Element* element){/*{{{*/
     279
     280        /*Intermediaries */
     281        IssmDouble  Jdet,dt;
     282        IssmDouble  ms,mb,mb_correction=0.,thickness;
     283        IssmDouble* xyz_list;
     284
     285        /*Fetch number of nodes and dof for this finite element*/
     286        int numnodes = element->GetNumberOfNodes();
     287
     288        /*Initialize Element vector and other vectors*/
     289        ElementVector* pe    = element->NewElementVector();
     290        IssmDouble*    basis = xNew<IssmDouble>(numnodes);
     291
     292        /*Retrieve all inputs and parameters*/
     293        element->GetVerticesCoordinates(&xyz_list);
     294        element->FindParam(&dt,TimesteppingTimeStepEnum);
     295        Input* mb_correction_input = element->GetInput(BasalforcingsMeltingRateCorrectionEnum);
     296        Input* mb_input            = element->GetInput(BasalforcingsMeltingRateEnum);     _assert_(mb_input);
     297        Input* ms_input            = element->GetInput(SurfaceforcingsMassBalanceEnum);   _assert_(ms_input);
     298        Input* thickness_input     = element->GetInput(ThicknessEnum);                    _assert_(thickness_input);
     299
     300        /*Initialize mb_correction to 0, do not forget!:*/
     301        /* Start  looping on the number of gaussian points: */
     302        Gauss* gauss=element->NewGauss(2);
     303        for(int ig=gauss->begin();ig<gauss->end();ig++){
     304                gauss->GaussPoint(ig);
     305
     306                element->JacobianDeterminant(&Jdet,xyz_list,gauss);
     307                element->NodalFunctions(basis,gauss);
     308
     309                ms_input->GetInputValue(&ms,gauss);
     310                mb_input->GetInputValue(&mb,gauss);
     311                thickness_input->GetInputValue(&thickness,gauss);
     312                if(mb_correction_input)
     313                 mb_correction_input->GetInputValue(&mb_correction,gauss);
     314
     315                for(int i=0;i<numnodes;i++) pe->values[i]+=Jdet*gauss->weight*(thickness+dt*(ms-mb-mb_correction))*basis[i];
     316        }
     317
     318        /*Clean up and return*/
     319        xDelete<IssmDouble>(xyz_list);
     320        xDelete<IssmDouble>(basis);
     321        delete gauss;
     322        return pe;
    219323}/*}}}*/
    220324void MasstransportAnalysis::GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element){/*{{{*/
  • issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.h

    r16782 r16809  
    2323                ElementMatrix* CreateKMatrix(Element* element);
    2424                ElementVector* CreatePVector(Element* element);
     25                ElementVector* CreatePVectorCG(Element* element);
     26                ElementVector* CreatePVectorDG(Element* element);
    2527                void GetSolutionFromInputs(Vector<IssmDouble>* solution,Element* element);
    2628                void InputUpdateFromSolution(IssmDouble* solution,Element* element);
  • issm/trunk-jpl/src/c/classes/Elements/Tria.cpp

    r16807 r16809  
    19751975bool Tria::IsOnBed(){
    19761976
    1977         bool onbed;
    19781977        int meshtype;
    19791978        this->parameters->FindParam(&meshtype,MeshTypeEnum);
     
    19811980                case Mesh2DverticalEnum:
    19821981                        return HasEdgeOnBed();
    1983                         break;
    19841982                case Mesh2DhorizontalEnum:
    1985                         inputs->GetInputValue(&onbed,MeshElementonbedEnum);
    1986                         break;
     1983                        return true;
    19871984                default: _error_("mesh "<<EnumToStringx(meshtype)<<" not supported yet");
    19881985        }
    1989         return onbed;
    19901986}
    19911987/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.