Changeset 21311


Ignore:
Timestamp:
10/25/16 11:44:04 (8 years ago)
Author:
Eric.Larour
Message:

CHG: new time dependent GetVectorFromInputsx routine. New EarthMassBalance module in sealevelrise_core
that relies on this routine.

Location:
issm/branches/trunk-larour-NatGeoScience2016/src/c
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • issm/branches/trunk-larour-NatGeoScience2016/src/c/classes/Elements/Element.cpp

    r21232 r21311  
    963963}
    964964/*}}}*/
     965void       Element::GetInputListOnVerticesAtTime(IssmDouble* pvalue, int enumtype, IssmDouble time){/*{{{*/
     966
     967        /*Recover input*/
     968        Input* input=this->GetInput(enumtype);
     969        if (!input) _error_("Input " << EnumToStringx(enumtype) << " not found in element");
     970
     971        /*Fetch number vertices for this element*/
     972        int numvertices = this->GetNumberOfVertices();
     973
     974        /*Checks in debugging mode*/
     975        _assert_(pvalue);
     976
     977        /* Start looping on the number of vertices: */
     978        Gauss*gauss=this->NewGauss();
     979        for(int iv=0;iv<numvertices;iv++){
     980                gauss->GaussVertex(iv);
     981                input->GetInputValue(&pvalue[iv],gauss,time);
     982        }
     983
     984        /*clean-up*/
     985        delete gauss;
     986}
     987/*}}}*/
    965988void       Element::GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue){/*{{{*/
    966989
     
    11721195                this->GetInputListOnNodes(values,input_enum);
    11731196                vector->SetValues(numnodes,doflist,values,INS_VAL);
     1197                break;
     1198        default:
     1199                _error_("type " << type << " (" << EnumToStringx(type) << ") not implemented yet");
     1200        }
     1201       
     1202        /*Clean up*/
     1203        xDelete<int>(doflist);
     1204        xDelete<IssmDouble>(values);
     1205
     1206}
     1207/*}}}*/
     1208void       Element::GetVectorFromInputs(Vector<IssmDouble>* vector,int input_enum,int type, IssmDouble time){/*{{{*/
     1209
     1210        /*Fetch number vertices for this element and allocate arrays*/
     1211        int         numvertices = this->GetNumberOfVertices();
     1212        int         numnodes    = this->GetNumberOfNodes();
     1213        int*        doflist     = NULL;
     1214        IssmDouble* values      = NULL;
     1215
     1216        switch(type){
     1217        case VertexPIdEnum:
     1218                doflist = xNew<int>(numvertices);
     1219                values = xNew<IssmDouble>(numvertices);
     1220                /*Fill in values*/
     1221                this->GetVertexPidList(doflist);
     1222                this->GetInputListOnVerticesAtTime(values,input_enum,time);
     1223                vector->SetValues(numvertices,doflist,values,INS_VAL);
    11741224                break;
    11751225        default:
  • issm/branches/trunk-larour-NatGeoScience2016/src/c/classes/Elements/Element.h

    r20999 r21311  
    8989                void               GetInputListOnNodesVelocity(IssmDouble* pvalue,int enumtype);
    9090                void               GetInputListOnVertices(IssmDouble* pvalue,int enumtype);
     91                void               GetInputListOnVerticesAtTime(IssmDouble* pvalue,int enumtype,IssmDouble time);
    9192                void               GetInputListOnVertices(IssmDouble* pvalue,int enumtype,IssmDouble defaultvalue);
    9293                void               GetInputLocalMinMaxOnNodes(IssmDouble* min,IssmDouble* max,IssmDouble* ug);
     
    100101                void               GetPhi(IssmDouble* phi, IssmDouble*  epsilon, IssmDouble viscosity);
    101102                void               GetVectorFromInputs(Vector<IssmDouble>* vector, int name_enum, int type);
     103                void               GetVectorFromInputs(Vector<IssmDouble>* vector, int name_enum, int type,IssmDouble time);
    102104                void                 GetVertexPidList(int* pidlist);
    103105                void               GetVerticesConnectivityList(int* connectivitylist);
  • issm/branches/trunk-larour-NatGeoScience2016/src/c/cores/cores.h

    r20454 r21311  
    6464void TransferForcing(FemModel* femmodel,int forcingenum);
    6565void TransferSealevel(FemModel* femmodel,int forcingenum);
     66void EarthMassTransport(FemModel* femmodel);
    6667
    6768//solution configuration
  • issm/branches/trunk-larour-NatGeoScience2016/src/c/cores/sealevelrise_core.cpp

    r21226 r21311  
    4040        femmodel->parameters->FindParam(&isslr,TransientIsslrEnum);
    4141        femmodel->parameters->FindParam(&iscoupler,TransientIscouplerEnum);
    42 
     42       
    4343        /*first, recover lat,long and radius vectors from vertices: */
    4444        VertexCoordinatesx(&latitude,&longitude,&radius,femmodel->vertices,spherical);
     
    7171        /*set configuration: */
    7272        if(isslr)femmodel->SetCurrentConfiguration(SealevelriseAnalysisEnum);
     73
     74        /*figure out whether deltathickness was computed on the earth (mass trasnport module should
     75         * have taken care of it for ice caps:  */
     76        if(iscoupler){
     77                int ismasstransport,modelid,earthid;
     78                femmodel->parameters->FindParam(&modelid,ModelIdEnum);
     79                femmodel->parameters->FindParam(&earthid,EarthIdEnum);
     80                femmodel->parameters->FindParam(&ismasstransport,TransientIsmasstransportEnum);
     81                if((modelid==EarthIdEnum) & !ismasstransport) EarthMassTransport(femmodel);
     82        }
    7383
    7484        /*transfer deltathickness forcing from ice caps to earth model: */
     
    359369
    360370} /*}}}*/
     371void EarthMassTransport(FemModel* femmodel){ /*{{{*/
     372
     373        IssmDouble time,dt;
     374        Vector<IssmDouble> *oldthickness    = NULL;
     375        Vector<IssmDouble> *newthickness    = NULL;
     376        Vector<IssmDouble> *deltathickness    = NULL;
     377        int nv;
     378
     379        /*No mass transport module was called, so we are just going to retrieve the geometry thickness
     380         * at this time step, at prior time step, and plug the difference as deltathickness: */
     381        femmodel->parameters->FindParam(&time,TimeEnum);
     382        femmodel->parameters->FindParam(&dt,TimesteppingTimeStepEnum);
     383        nv=femmodel->vertices->NumberOfVertices();
     384
     385        GetVectorFromInputsx(&newthickness,femmodel,ThicknessEnum,VertexSIdEnum);
     386        GetVectorFromInputsx(&oldthickness,femmodel,ThicknessEnum,VertexSIdEnum,time-dt);
     387
     388        /*compute deltathickness: */
     389        deltathickness = new Vector<IssmDouble>(nv);
     390        newthickness->Copy(deltathickness); deltathickness->AXPY(oldthickness,-1);
     391               
     392        /*plug into elements:*/
     393        InputUpdateFromVectorx(femmodel,deltathickness,SealevelriseDeltathicknessEnum,VertexSIdEnum);
     394
     395        /*free ressources:*/
     396        delete oldthickness;
     397        delete newthickness;
     398        delete deltathickness;
     399
     400} /*}}}*/
  • issm/branches/trunk-larour-NatGeoScience2016/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp

    r19094 r21311  
    3333        *pvector=vector;
    3434}
     35void GetVectorFromInputsx(Vector<IssmDouble>** pvector,FemModel* femmodel,int name,int type,IssmDouble time){
     36
     37        int i;
     38        Vector<IssmDouble>* vector=NULL;
     39
     40        switch(type){
     41        case VertexPIdEnum: case VertexSIdEnum:
     42                vector=new Vector<IssmDouble>(femmodel->vertices->NumberOfVertices());
     43                break;
     44        case NodesEnum:case NodeSIdEnum:
     45                vector=new Vector<IssmDouble>(femmodel->nodes->NumberOfNodes());
     46                break;
     47        default:
     48                        _error_("vector type: " << EnumToStringx(type) << " not supported yet!");
     49        }
     50        /*Look up in elements*/
     51        for(i=0;i<femmodel->elements->Size();i++){
     52                Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
     53                element->GetVectorFromInputs(vector,name,type,time);
     54        }
     55
     56        vector->Assemble();
     57
     58        /*Assign output pointers:*/
     59        *pvector=vector;
     60}
    3561
    3662void GetVectorFromInputsx(IssmDouble** pvector,FemModel* femmodel,int name, int type){
  • issm/branches/trunk-larour-NatGeoScience2016/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.h

    r15849 r21311  
    99/* local prototypes: */
    1010void    GetVectorFromInputsx( Vector<IssmDouble>** pvector,FemModel* femmodel,int name,int type);
     11void    GetVectorFromInputsx( Vector<IssmDouble>** pvector,FemModel* femmodel,int name,int type,IssmDouble time);
    1112void    GetVectorFromInputsx( IssmDouble** pvector,FemModel* femmodel,int name,int type);
    1213
Note: See TracChangeset for help on using the changeset viewer.