Changeset 26296


Ignore:
Timestamp:
06/04/21 16:35:40 (4 years ago)
Author:
caronlam
Message:

BUG: BarystaticLoad was considering coastline elements that were fully covered by ice as also fully grounded; CHG: lots of renaming in sealevelchange_core & analysis; CHG: it is now possible to compute GRD with Barystatic contributions & ocean mass but without sea-level loading

Location:
issm/trunk-jpl
Files:
24 edited

Legend:

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

    r26047 r26296  
    6161        /*some constant parameters: */
    6262        parameters->AddObject(iomodel->CopyConstantObject("md.esa.hemisphere",EsaHemisphereEnum));
    63         parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.rigid",SolidearthSettingsRigidEnum));
     63        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.selfattraction",SolidearthSettingsSelfAttractionEnum));
    6464        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.horiz",SolidearthSettingsHorizEnum));
    6565        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.elastic",SolidearthSettingsElasticEnum));
  • issm/trunk-jpl/src/c/analyses/SealevelchangeAnalysis.cpp

    r26283 r26296  
    9292        int         isexternal=0;
    9393
    94         IssmDouble* G_rigid = NULL;
    95         IssmDouble* G_rigid_local = NULL;
     94        IssmDouble* G_gravi = NULL;
     95        IssmDouble* G_gravi_local = NULL;
    9696        IssmDouble* G_viscoelastic = NULL;
    9797        IssmDouble* G_viscoelastic_interpolated = NULL;
     
    108108        IssmDouble  planetradius=0;
    109109        IssmDouble  planetarea=0;
    110         bool            rigid=false;
     110        bool            selfattraction=false;
    111111        bool            elastic=false;
    112112        bool            viscous=false;
     
    145145        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.abstol",SolidearthSettingsAbstolEnum));
    146146        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.maxiter",SolidearthSettingsMaxiterEnum));
    147         parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.rigid",SolidearthSettingsRigidEnum));
     147        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.selfattraction",SolidearthSettingsSelfAttractionEnum));
    148148        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.horiz",SolidearthSettingsHorizEnum));
    149149        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.elastic",SolidearthSettingsElasticEnum));
     
    153153        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.rotational.polarmoi",RotationalPolarMoiEnum));
    154154        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.rotational.angularvelocity",RotationalAngularVelocityEnum));
     155        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.grdocean",SolidearthSettingsGrdOceanEnum));
    155156        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.ocean_area_scaling",SolidearthSettingsOceanAreaScalingEnum));
    156         parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.computesealevelchange",SolidearthSettingsComputesealevelchangeEnum));
     157        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.sealevelloading",SolidearthSettingsSealevelLoadingEnum));
    157158        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.isgrd",SolidearthSettingsGRDEnum));
    158159        parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.settings.compute_bp_grd",SolidearthSettingsComputeBpGrdEnum));
     
    228229
    229230        parameters->FindParam(&grdmodel,GrdModelEnum);
    230         if(grdmodel!=IvinsEnum){
     231        if(grdmodel==ElasticEnum){
    231232                /*Deal with elasticity {{{*/
    232                 iomodel->FetchData(&rigid,"md.solidearth.settings.rigid");
     233                iomodel->FetchData(&selfattraction,"md.solidearth.settings.selfattraction");
    233234                iomodel->FetchData(&elastic,"md.solidearth.settings.elastic");
    234235                iomodel->FetchData(&viscous,"md.solidearth.settings.viscous");
     
    236237                iomodel->FetchData(&horiz,"md.solidearth.settings.horiz");
    237238
    238                 if(rigid){
     239                if(selfattraction){
    239240                        /*compute green functions for a range of angles*/
    240241                        iomodel->FetchData(&degacc,"md.solidearth.settings.degacc");
     
    271272                        // // Providing "t" will cause ensurecontiguous to be called.
    272273                        if(viscous){
    273                                 IssmDouble* stacktimes=NULL;
     274                                IssmDouble* viscoustimes=NULL;
    274275                                ntimesteps=precomputednt;
    275276                                nt=reCast<int,IssmDouble>((final_time-start_time)/timeacc)+1;
    276277
    277                                 parameters->AddObject(new IntParam(StackNumStepsEnum,nt));
    278                                 /*Initialize stack times:*/
    279                                 stacktimes=xNew<IssmDouble>(nt);
     278                                parameters->AddObject(new IntParam(SealevelchangeViscousNumStepsEnum,nt));
     279                                /*Initialize viscous stack times:*/
     280                                viscoustimes=xNew<IssmDouble>(nt);
    280281                                for(int t=0;t<nt;t++){
    281                                         stacktimes[t]=start_time+timeacc*t;
     282                                        viscoustimes[t]=start_time+timeacc*t;
    282283                                }
    283                                 parameters->AddObject(new DoubleVecParam(StackTimesEnum,stacktimes,nt));
    284                                 parameters->AddObject(new IntParam(StackIndexEnum,0));
    285                                 xDelete<IssmDouble>(stacktimes);
     284                                parameters->AddObject(new DoubleVecParam(SealevelchangeViscousTimesEnum,viscoustimes,nt));
     285                                parameters->AddObject(new IntParam(SealevelchangeViscousIndexEnum,0));
     286                                xDelete<IssmDouble>(viscoustimes);
    286287                        }
    287288                        else {
     
    300301#endif
    301302                }
    302                 if(rigid){
     303                if(selfattraction){
    303304#ifdef _HAVE_AD_
    304                         G_rigid=xNew<IssmDouble>(M,"t");
     305                        G_gravi=xNew<IssmDouble>(M,"t");
    305306#else
    306                         G_rigid=xNew<IssmDouble>(M);
     307                        G_gravi=xNew<IssmDouble>(M);
    307308#endif
    308309                }
     
    310311                if(rotation)parameters->AddObject(iomodel->CopyConstantObject("md.solidearth.lovenumbers.tk2secular",TidalLoveK2SecularEnum));
    311312
    312                 if(rigid){
     313                if(selfattraction){
    313314
    314315                        /*compute combined legendre + love number (elastic green function:*/
     
    327328#endif
    328329                }
    329                 if(rigid){
     330                if(selfattraction){
    330331#ifdef _HAVE_AD_
    331                         G_rigid_local=xNew<IssmDouble>(m,"t");
     332                        G_gravi_local=xNew<IssmDouble>(m,"t");
    332333#else
    333                         G_rigid_local=xNew<IssmDouble>(m);
     334                        G_gravi_local=xNew<IssmDouble>(m);
    334335#endif
    335336                }
    336337
    337                 if(rigid){
     338                if(selfattraction){
    338339                        for(int i=lower_row;i<upper_row;i++){
    339340                                IssmDouble alpha,x;
    340341                                alpha= reCast<IssmDouble>(i)*degacc * M_PI / 180.0;
    341                                 G_rigid_local[i-lower_row]= .5/sin(alpha/2.0);
     342                                G_gravi_local[i-lower_row]= .5/sin(alpha/2.0);
    342343                        }
    343344                }
     
    348349
    349350                                for(int t=0;t<ntimesteps;t++){
    350                                         G_viscoelastic_local[(i-lower_row)*ntimesteps+t]= (love_k[(ndeg-1)*precomputednt+t]-love_h[(ndeg-1)*precomputednt+t])*G_rigid_local[i-lower_row];
    351                                         U_viscoelastic_local[(i-lower_row)*ntimesteps+t]= (love_h[(ndeg-1)*precomputednt+t])*G_rigid_local[i-lower_row];
     351                                        G_viscoelastic_local[(i-lower_row)*ntimesteps+t]= (love_k[(ndeg-1)*precomputednt+t]-love_h[(ndeg-1)*precomputednt+t])*G_gravi_local[i-lower_row];
     352                                        U_viscoelastic_local[(i-lower_row)*ntimesteps+t]= (love_h[(ndeg-1)*precomputednt+t])*G_gravi_local[i-lower_row];
    352353                                        if(horiz)H_viscoelastic_local[(i-lower_row)*ntimesteps+t]= 0;
    353354                                }
     
    392393                        }
    393394                }
    394                 if(rigid){
     395                if(selfattraction){
    395396
    396397                        /*merge G_viscoelastic_local into G_viscoelastic; U_viscoelastic_local into U_viscoelastic; H_viscoelastic_local to H_viscoelastic:{{{*/
     
    400401                        int  offset;
    401402
    402                         //deal with rigid first:
     403                        //deal with selfattraction first:
    403404                        ISSM_MPI_Allgather(&m,1,ISSM_MPI_INT,recvcounts,1,ISSM_MPI_INT,IssmComm::GetComm());
    404405
     
    407408
    408409                        /*All gather:*/
    409                         ISSM_MPI_Allgatherv(G_rigid_local, m, ISSM_MPI_DOUBLE, G_rigid, recvcounts, displs, ISSM_MPI_DOUBLE,IssmComm::GetComm());
     410                        ISSM_MPI_Allgatherv(G_gravi_local, m, ISSM_MPI_DOUBLE, G_gravi, recvcounts, displs, ISSM_MPI_DOUBLE,IssmComm::GetComm());
    410411
    411412                        if(elastic){
     
    427428
    428429                        /*Avoid singularity at 0: */
    429                         G_rigid[0]=G_rigid[1];
     430                        G_gravi[0]=G_gravi[1];
    430431                        if(elastic){
    431432                                for(int t=0;t<ntimesteps;t++){
     
    486487                        }
    487488                        else if(elastic){
    488                                 nt=1; //in elastic, or if we run only rigid, we need only one step
     489                                nt=1; //in elastic, or if we run only selfattraction, we need only one step
    489490#ifdef _HAVE_AD_
    490491                                G_viscoelastic_interpolated=G_viscoelastic;
     
    499500
    500501                        /*Save our precomputed tables into parameters*/
    501                         parameters->AddObject(new DoubleVecParam(SealevelchangeGRigidEnum,G_rigid,M));
     502                        parameters->AddObject(new DoubleVecParam(SealevelchangeGSelfAttractionEnum,G_gravi,M));
    502503                        if(viscous || elastic){
    503504                                parameters->AddObject(new DoubleVecParam(SealevelchangeGViscoElasticEnum,G_viscoelastic_interpolated,M*nt));
     
    507508
    508509                        /*free resources: */
    509                         xDelete<IssmDouble>(G_rigid);
    510                         xDelete<IssmDouble>(G_rigid_local);
     510                        xDelete<IssmDouble>(G_gravi);
     511                        xDelete<IssmDouble>(G_gravi_local);
    511512                        if(elastic){
    512513                                xDelete<IssmDouble>(love_h);
  • issm/trunk-jpl/src/c/classes/Elements/Element.h

    r26294 r26296  
    391391                virtual void          GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,Matlitho* litho, IssmDouble* x,IssmDouble* y)=0;
    392392
    393                 virtual void       SealevelchangeGeometryFractionKernel(SealevelGeometry* slgeom)=0;
     393                virtual void       SealevelchangeGeometrySubElementKernel(SealevelGeometry* slgeom)=0;
    394394                virtual void       SealevelchangeMomentOfInertiaCentroid(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom)=0;
    395395                virtual void       SealevelchangeShift(GrdLoads* loads, IssmDouble offset, SealevelGeometry* slgeom)=0;
     
    400400                virtual void       SealevelchangeConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom)=0;
    401401                virtual void       SealevelchangeOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble* sealevelpercpu, SealevelGeometry* slgeom)=0;
    402                 virtual void       SealevelchangeDeformationConvolution(GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom)=0;
     402                virtual void       SealevelchangeDeformationConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom)=0;
    403403                virtual void       SealevelchangeMomentOfInertiaSubElement(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom)=0;
    404404                virtual void       SealevelchangeUpdateViscousFields()=0;
  • issm/trunk-jpl/src/c/classes/Elements/Penta.h

    r26272 r26296  
    223223                #ifdef _HAVE_SEALEVELCHANGE_
    224224                void       GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,Matlitho* litho, IssmDouble* x,IssmDouble* y){_error_("not implemented yet");};
    225                 void       SealevelchangeGeometryFractionKernel(SealevelGeometry* slgeom){_error_("not implemented yet");};
     225                void       SealevelchangeGeometrySubElementKernel(SealevelGeometry* slgeom){_error_("not implemented yet");};
    226226                void       SealevelchangeMomentOfInertiaCentroid(IssmDouble* dI_list, GrdLoads* loads,  SealevelGeometry* slgeom){_error_("not implemented yet");};
    227227                void       SealevelchangeShift(GrdLoads* loads,  IssmDouble offset, SealevelGeometry* slgeom){_error_("not implemented yet");};
     
    232232                void       SealevelchangeConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom){_error_("not implemented yet");};
    233233                void       SealevelchangeOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble* sealevelpercpu, SealevelGeometry* slgeom){_error_("not implemented yet");};
    234                 void       SealevelchangeDeformationConvolution(GrdLoads* loads,  IssmDouble* rotationvector,SealevelGeometry* slgeom){_error_("not implemented yet");};
     234                void       SealevelchangeDeformationConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads,  IssmDouble* rotationvector,SealevelGeometry* slgeom){_error_("not implemented yet");};
    235235                void       SealevelchangeMomentOfInertiaSubElement(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom){_error_("not implemented yet");};
    236236                void       SealevelchangeUpdateViscousFields(){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Elements/Seg.h

    r26272 r26296  
    178178#ifdef _HAVE_SEALEVELCHANGE_
    179179                void       GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,Matlitho* litho, IssmDouble* x,IssmDouble* y){_error_("not implemented yet");};
    180                 void       SealevelchangeGeometryFractionKernel(SealevelGeometry* slgeom){_error_("not implemented yet");};
     180                void       SealevelchangeGeometrySubElementKernel(SealevelGeometry* slgeom){_error_("not implemented yet");};
    181181                void       SealevelchangeMomentOfInertiaCentroid(IssmDouble* dI_list, GrdLoads* loads,  SealevelGeometry* slgeom){_error_("not implemented yet");};
    182182                void       SealevelchangeShift(GrdLoads* loads, IssmDouble offset, SealevelGeometry* slgeom){_error_("not implemented yet");};
     
    187187                void       SealevelchangeConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom){_error_("not implemented yet");};
    188188                void       SealevelchangeOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble* sealevelpercpu, SealevelGeometry* slgeom){_error_("not implemented yet");};
    189                 void       SealevelchangeDeformationConvolution(GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom){_error_("not implemented yet");};
     189                void       SealevelchangeDeformationConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom){_error_("not implemented yet");};
    190190                void       SealevelchangeMomentOfInertiaSubElement(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom){_error_("not implemented yet");};
    191191                void       SealevelchangeUpdateViscousFields(){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Elements/Tetra.h

    r26272 r26296  
    185185#ifdef _HAVE_SEALEVELCHANGE_
    186186                void       GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt, Matlitho* litho, IssmDouble* x,IssmDouble* y){_error_("not implemented yet");};
    187                 void       SealevelchangeGeometryFractionKernel(SealevelGeometry* slgeom){_error_("not implemented yet");};
     187                void       SealevelchangeGeometrySubElementKernel(SealevelGeometry* slgeom){_error_("not implemented yet");};
    188188                void       SealevelchangeMomentOfInertiaCentroid(IssmDouble* dI_list, GrdLoads* loads,  SealevelGeometry* slgeom){_error_("not implemented yet");};
    189189                void       SealevelchangeShift(GrdLoads* loads,  IssmDouble offset, SealevelGeometry* slgeom){_error_("not implemented yet");};
     
    194194                void       SealevelchangeConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom){_error_("not implemented yet");};
    195195                void       SealevelchangeOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble* sealevelpercpu, SealevelGeometry* slgeom){_error_("not implemented yet");};
    196                 void       SealevelchangeDeformationConvolution(GrdLoads* loads,  IssmDouble* rotationvector,SealevelGeometry* slgeom){_error_("not implemented yet");};
     196                void       SealevelchangeDeformationConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads,  IssmDouble* rotationvector,SealevelGeometry* slgeom){_error_("not implemented yet");};
    197197                void       SealevelchangeMomentOfInertiaSubElement(IssmDouble* dI_list, GrdLoads* loads, SealevelGeometry* slgeom){_error_("not implemented yet");};
    198198                void       SealevelchangeUpdateViscousFields(){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Elements/Tria.cpp

    r26283 r26296  
    19371937
    19381938        bool istrapeze1, istrapeze2;
    1939         IssmDouble phi1,phi2, f11,f12,f21,f22;
     1939        IssmDouble phi1,phi2, d,e,f,g,h1,h2;
    19401940        int point1, point2,  i0,i1,i2,j0,j1,j2;
    19411941        IssmDouble weights1[3],weights2[3];
     
    19511951        IssmDouble xyz3[3][3]={0};
    19521952        IssmDouble xyz[8][3]={0};
    1953         IssmDouble f1o;
    19541953        IssmDouble w[8][NUMVERTICES]={0};
    19551954        IssmDouble areasub=0;
     
    20192018        //If just one levelset is all negative, just take the partitioning of the other, no interaction between them
    20202019        if (levelset1[0]<=0 && levelset1[1]<=0 && levelset1[2]<=0) {
    2021                 this->GetFractionGeometry(loadweights,&phi2,&point2,&f21,&f22,&istrapeze2,levelset2);
    2022                 this->GetBarycenterFromLevelset(platbar,plongbar, phi2, f21, f22, late, longe, point2,istrapeze2,planetradius);
     2020                this->GetFractionGeometry(loadweights,&phi2,&point2,&f,&g,&istrapeze2,levelset2);
     2021                this->GetBarycenterFromLevelset(platbar,plongbar, phi2, f, g, late, longe, point2,istrapeze2,planetradius);
    20232022                *ploadarea=area*phi2;
    20242023                return;
    20252024        }
    20262025        if (levelset2[0]<=0 && levelset2[1]<=0 && levelset2[2]<=0) {
    2027                 this->GetFractionGeometry(loadweights,&phi1,&point1,&f11,&f12,&istrapeze1,levelset1);
    2028                 this->GetBarycenterFromLevelset(platbar,plongbar, phi1, f11, f12, late, longe, point1,istrapeze1,planetradius);
     2026                this->GetFractionGeometry(loadweights,&phi1,&point1,&d,&e,&istrapeze1,levelset1);
     2027                this->GetBarycenterFromLevelset(platbar,plongbar, phi1, d, e, late, longe, point1,istrapeze1,planetradius);
    20292028                *ploadarea=area*phi1;
    20302029                return;
     
    20322031
    20332032
    2034         this->GetFractionGeometry(&weights1[0],&phi1,&point1,&f11,&f12,&istrapeze1,levelset1);
    2035         this->GetFractionGeometry(&weights2[0],&phi2,&point2,&f21,&f22,&istrapeze2,levelset2);
     2033        this->GetFractionGeometry(&weights1[0],&phi1,&point1,&d,&e,&istrapeze1,levelset1);
     2034        this->GetFractionGeometry(&weights2[0],&phi2,&point2,&f,&g,&istrapeze2,levelset2);
    20362035
    20372036
     
    20392038        if (istrapeze1==istrapeze2 && point1==point2 && phi1==phi2){
    20402039                //the two levelsets are redundant: levelset1 = positivescalar * levelset2
    2041                 this->GetBarycenterFromLevelset(platbar,plongbar, phi1, f11, f12, late, longe, point1,istrapeze1,planetradius);
     2040                this->GetBarycenterFromLevelset(platbar,plongbar, phi1, d, e, late, longe, point1,istrapeze1,planetradius);
    20422041                *ploadarea=area*phi1;
    20432042                for (int i=0;i<NUMVERTICES;i++) loadweights[i]=weights1[i];
     
    20562055        ::GetVerticesCoordinates(&xyz0[0][0],vertices,NUMVERTICES); // initial triangle
    20572056
    2058         i0=point1;
    2059         i1=(point1+1)%3;
    2060         i2=(point1+2)%3;
    2061 
    2062         j0=point2;
    2063         j1=(point2+1)%3;
    2064         j2=(point2+2)%3;
    2065 
    2066         //f1o: fraction of segment {point_f11 -> point_f12} where the levelsets intersect (only used when f1o>=0 and f1o<=1)
    2067         if(point2==i0) f1o= f22*(f11-f21)/(f11*f22-f12*f21);
    2068         else if(point2==i1) f1o=f21*(1.0-f22-f11)/(f21*(f12-f11)-f12*f22);
    2069         else f1o= (f22*(1.0-f21-f11)+f21*f11)/(f22*(f12-f11) +f21*f11);
     2057        //Let our element be triangle ABC with:
     2058        i0=point1; //A
     2059        i1=(point1+1)%3; //B
     2060        i2=(point1+2)%3; //C
     2061
     2062        j0=point2; //Can be A, B or C
     2063        j1=(point2+1)%3; //anticlockwise point from j0
     2064        j2=(point2+2)%3; //clockwise point from j0
     2065
     2066        /* Below we define the relative fractional lengths of ABC where the zero-level contours of the two level sets intersect with ABC and each other. For example D is the intersection of level set 1 with side AB with fractional length d=[AD]/[AB].
     2067
     2068           levelset1 intersects ABC on D and E:
     2069           A------D---B
     2070           <--d--->             
     2071
     2072           A-----E----C
     2073           <--e-->
     2074
     2075           levelset2 intersects ABC on F and G:
     2076           j0---F------j1
     2077           <--f->
     2078
     2079           j0-------G--j2
     2080           <---g---->
     2081
     2082           levelset1 and 2 intersect on H (when that intersection exists inside the element)
     2083           D----H------E
     2084           <-h1->
     2085
     2086           F-----H----G
     2087           <--h2->
     2088        */
     2089
     2090        if (point2==i0){
     2091                h1= g*(d-f)/(d*g-e*f);
     2092                h2= e/g * h1;
     2093        }
     2094        else if (point2==i1){
     2095                h1=f*(1.0-g-d)/(f*(e-d)-e*g);
     2096                h2= 1.0-e/f * h1;
     2097        }
     2098        else if (point2==i2){
     2099                h1= (g*(1.0-f-d)+f*d)/(g*(e-d) +f*d);
     2100                h2= (d*(f+e-1))/(g*(e-d) +f*d);
     2101        }
    20702102
    20712103
    20722104        //interpolant weights of each point. Any field F[0,1,2] provided at the original vertices [0,1,2] will be equal on point k to sum_i (F[i] * w[k][i])
    2073         w[0][0]=1;
    2074         w[1][1]=1;
    2075         w[2][2]=1;
    2076         w[3][i0]=1.0-f11; w[3][i1]=f11;
    2077         w[4][i0]=1.0-f12; w[4][i2]=f12;
    2078         w[5][j0]=1.0-f21; w[5][j1]=f21;
    2079         w[6][j0]=1.0-f22; w[6][j2]=f22;
    2080         for (int j=0;j<3;j++) w[7][j]=w[3][j]*(1.0-f1o) + w[4][j]*f1o; //we interpolate the intersection point between point_f11 and point_f12 at fraction f1o
     2105        w[0][0]=1; //A
     2106        w[1][1]=1; //B
     2107        w[2][2]=1; //C
     2108        w[3][i0]=1.0-d; w[3][i1]=d; //D
     2109        w[4][i0]=1.0-e; w[4][i2]=e; //E
     2110        w[5][j0]=1.0-f; w[5][j1]=f; //F
     2111        w[6][j0]=1.0-g; w[6][j2]=g; //G
     2112        for (int j=0;j<3;j++) w[7][j]=w[3][j]*(1.0-h1) + w[4][j]*h1; //H: we interpolate the intersection point H between D and E at fraction h1
    20812113
    20822114        for (int k=0;k<8;k++){
     
    20882120                //point2 can be either i0,i1 or i2. We start the search with i1 and i2 as they have less computational cost in ifs
    20892121                if(point2==i2){ /*{{{*/
    2090                         if (f12>1.0-f21){ /*{{{*/
     2122                        if (e>1.0-f){ /*{{{*/
    20912123                                if (!istrapeze1 && !istrapeze2){
    2092                                         tria1[0]=5; tria1[1]= 7; tria1[2]= 4;
     2124                                        tria1[0]=5; tria1[1]= 7; tria1[2]= 4; // FHE
     2125                                        area1=h2*(e+f-1.0)*g;
    20932126                                }
    20942127                                else if (!istrapeze1 && istrapeze2){
    2095                                         tria1[0]=i0; tria1[1]= 3; tria1[2]= 7;
    2096                                         tria2[0]=i0; tria2[1]= 7; tria2[2]= 5;
     2128                                        tria1[0]=i0; tria1[1]= 3; tria1[2]= 5; //ADF
     2129                                        area1=d*(1.0-f);
     2130                                        tria2[0]=3; tria2[1]= 7; tria2[2]= 5; //DHF
     2131                                        area2=d*h1*(e+f-1.0);
    20972132                                }
    20982133                                else if (istrapeze1 && !istrapeze2){
    2099                                         tria1[0]=7; tria1[1]= 6; tria1[2]= 4;
    2100                                         tria2[0]=4; tria2[1]= 6; tria2[2]= i2;
     2134                                        tria1[0]=7; tria1[1]= 6; tria1[2]= 4; //HGE
     2135                                        area1=g*(1.0-h2)*(e+f-1.0);
     2136                                        tria2[0]=4; tria2[1]= 6; tria2[2]= i2; //EGC
     2137                                        area2=g*(1.0-e);
    21012138                                }
    21022139                                else { //istrapeze1 && istrapeze2
    2103                                         tria1[0]=3; tria1[1]= i1; tria1[2]= 7;
    2104                                         tria2[0]=7; tria2[1]= i1; tria2[2]= 6;
     2140                                        tria1[0]=3; tria1[1]= i1; tria1[2]= 6; //DBG
     2141                                        area1=(1.0-d)*(1.0-g);
     2142                                        tria2[0]=3; tria2[1]= 6; tria2[2]= 7; //DGH
     2143                                        area2=g*((1.0-f)*(1.0-h2)+h2*e)+d*(1.0-e-g);
    21052144                                }  /*}}}*/
    21062145                        }
    2107                         else if (f12<=1.0-f21){ /*{{{*/
     2146                        else if (e<=1.0-f){ /*{{{*/
    21082147                                if (!istrapeze1 && !istrapeze2){
    21092148                                }
    21102149                                else if (!istrapeze1 && istrapeze2){
    2111                                         tria1[0]=i0; tria1[1]= 3; tria1[2]= 4;
     2150                                        tria1[0]=i0; tria1[1]= 3; tria1[2]= 4; //ADE
     2151                                        area1=d*e;
    21122152                                }
    21132153                                else if (istrapeze1 && !istrapeze2){
    2114                                         tria1[0]=5; tria1[1]= 6; tria1[2]= i2;
     2154                                        tria1[0]=5; tria1[1]= 6; tria1[2]= i2; //FGC
     2155                                        area1=f*g;
    21152156                                }
    21162157                                else { //istrapeze1 && istrapeze2
    2117                                         tria1[0]=3; tria1[1]= i1; tria1[2]= 4;
    2118                                         tria2[0]=4; tria2[1]= i1; tria2[2]= 5;
    2119                                         tria3[0]=5; tria3[1]= i1; tria3[2]= 6;
     2158                                        tria1[0]=3; tria1[1]= i1; tria1[2]= 5; //DBF
     2159                                        area1=(1.0-d)*(1.0-f);
     2160                                        tria2[0]=4; tria2[1]= 3; tria2[2]= 5;  //EDF
     2161                                        area2=d*(1.0-e-f);
     2162                                        tria3[0]=5; tria3[1]= i1; tria3[2]= 6; //FBG
     2163                                        area3=f*(1.0-g);
    21202164                                } /*}}}*/
    21212165                        }
    21222166                }/*}}}*/   
    21232167                else if(point2==i1){ /*{{{*/
    2124                         if (f11>1.0-f22){ /*{{{*/
     2168                        if (d>1.0-g){ /*{{{*/
    21252169                                if (!istrapeze1 && !istrapeze2){
    2126                                         tria1[0]=6; tria1[1]= 3; tria1[2]= 7;
     2170                                        tria1[0]=6; tria1[1]= 3; tria1[2]= 7; //GDH
     2171                                        area1=(1.0-h2)*(d+g-1.0)*f;
    21272172                                }
    21282173                                else if (!istrapeze1 && istrapeze2){
    2129                                         tria1[0]=i0; tria1[1]= 6; tria1[2]= 7;
    2130                                         tria2[0]=i0; tria2[1]= 7; tria2[2]= 4;
     2174                                        tria1[0]=i0; tria1[1]= 6; tria1[2]= 4; //AGE
     2175                                        area1=(1.0-g)*e;
     2176                                        tria2[0]=6; tria2[1]= 7; tria2[2]= 4; //GHE
     2177                                        area2=e*(1.0-h1)*(g+d-1.0);
    21312178                                }
    21322179                                else if (istrapeze1 && !istrapeze2){
    2133                                         tria1[0]=3; tria1[1]= i1; tria1[2]= 7;
    2134                                         tria2[0]=7; tria2[1]= i1; tria2[2]= 5;
     2180                                        tria1[0]=i1; tria1[1]= 5; tria1[2]= 3; //BFD
     2181                                        area1=(1.0-d)*f;
     2182                                        tria2[0]=3; tria2[1]= 5; tria2[2]= 7; //DFH
     2183                                        area2=f*h2*(d+g-1.0);
    21352184                                }
    21362185                                else { //istrapeze1 && istrapeze2
    2137                                         tria1[0]=7; tria1[1]= 5; tria1[2]= 4;
    2138                                         tria2[0]=4; tria2[1]= 5; tria2[2]= i2;
     2186                                        tria1[0]=7; tria1[1]= 5; tria1[2]= 4; //HFE
     2187                                        area1=e*((1.0-d)*(1.0-h1)+h1*g)+f*(1.0-g-e);
     2188                                        tria2[0]=4; tria2[1]= 5; tria2[2]= i2;//EFC
     2189                                        area2=(1.0-e)*(1.0-f);
    21392190                                }  /*}}}*/
    21402191                        }
    2141                         else if (f11<=1.0-f22){ /*{{{*/
     2192                        else if (d<=1.0-g){ /*{{{*/
    21422193                                if (!istrapeze1 && !istrapeze2){
    21432194                                }
    21442195                                else if (!istrapeze1 && istrapeze2){
    2145                                         tria1[0]=i0; tria1[1]= 3; tria1[2]= 4;
     2196                                        tria1[0]=i0; tria1[1]= 3; tria1[2]= 4; //ADE
     2197                                        area1=d*e;
    21462198                                }
    21472199                                else if (istrapeze1 && !istrapeze2){
    2148                                         tria1[0]=6; tria1[1]= i1; tria1[2]= 5;
     2200                                        tria1[0]=6; tria1[1]= i1; tria1[2]= 5; //GBF
     2201                                        area1=f*g;
    21492202                                }
    21502203                                else { //istrapeze1 && istrapeze2
    2151                                         tria1[0]=3; tria1[1]= 6; tria1[2]= 4;
    2152                                         tria2[0]=4; tria2[1]= 6; tria2[2]= 5;
    2153                                         tria3[0]=4; tria3[1]= 5; tria3[2]= i2;
     2204                                        tria1[0]=3; tria1[1]= 6; tria1[2]= 4; //DGE
     2205                                        area1=e*(1.0-d-g);
     2206                                        tria2[0]=6; tria2[1]= i2; tria2[2]= 4; //GCE
     2207                                        area2=(1.0-g)*(1.0-e);
     2208                                        tria3[0]=6; tria3[1]= 5; tria3[2]= i2; //GFC
     2209                                        area3=g*(1.0-f);
    21542210                                } /*}}}*/
    21552211                        }
     
    21572213                }/*}}}*/
    21582214                else{ /*{{{*/
    2159                         if (f11<=f21 && f12>=f22){  /*{{{*/
     2215                        if (d<=f && e>=g){  /*{{{*/
    21602216                                if (!istrapeze1 && !istrapeze2){
    2161                                         tria1[0]=i0; tria1[1]= 3; tria1[2]= 7;
    2162                                         tria2[0]=i0; tria2[1]= 7; tria2[2]= 6;
     2217                                        tria1[0]=i0; tria1[1]= 3; tria1[2]= 7; //ADH
     2218                                        area1=h1*d*e;
     2219                                        tria2[0]=i0; tria2[1]= 7; tria2[2]= 6; //AHG
     2220                                        area2=(1.0-h2)*f*g;
    21632221                                }
    21642222                                else if (!istrapeze1 && istrapeze2){
    2165                                         tria1[0]=6; tria1[1]= 7; tria1[2]= 4;
     2223                                        tria1[0]=6; tria1[1]= 7; tria1[2]= 4; //GHE
     2224                                        area1=(e-g)*d*(1.0-h1);
    21662225                                }
    21672226                                else if (istrapeze1 && !istrapeze2){
    2168                                         tria1[0]=3; tria1[1]= 5; tria1[2]= 7;
     2227                                        tria1[0]=3; tria1[1]= 5; tria1[2]= 7; //DFH
     2228                                        area1=(f-d)*g*h2;
    21692229                                }
    21702230                                else { //istrapeze1 && istrapeze2
    2171                                         tria1[0]=7; tria1[1]= 5; tria1[2]= i1;
    2172                                         tria2[0]=7; tria2[1]= i1; tria2[2]= 4;
    2173                                         tria3[0]=4; tria3[1]= i1; tria3[2]= i2;
     2231                                        tria1[0]=5; tria1[1]= i1; tria1[2]= 7; //FBH
     2232                                        area1=g*h2*(1.0-f);
     2233                                        tria2[0]=7; tria2[1]= i1; tria2[2]= i2;//HBC
     2234                                        area2=1.0+d*(h1-e*h1-1.0)+g*h2*(d-1.0);
     2235                                        tria3[0]=7; tria3[1]= i2; tria3[2]= 4; //HCE
     2236                                        area3=d*(1.0-h1)*(1.0-e);
    21742237                                } /*}}}*/
    21752238                        }
    2176                         else if (f11>=f21 && f12<=f22){ /*{{{*/
     2239                        else if (d>=f && e<=g){ /*{{{*/
    21772240                                if (!istrapeze1 && !istrapeze2){
    2178                                         tria1[0]=i0; tria1[1]= 5; tria1[2]= 7;
    2179                                         tria2[0]=i0; tria2[1]= 4; tria2[2]= 7;
     2241                                        tria1[0]=i0; tria1[1]= 5; tria1[2]= 7; //AFH
     2242                                        area1=h2*f*g;
     2243                                        tria2[0]=i0; tria2[1]= 7; tria2[2]= 4; //AHE
     2244                                        area2=(1.0-h1)*d*e;
    21802245                                }else if (!istrapeze1 && istrapeze2){
    2181                                         tria1[0]=5; tria1[1]= 3; tria1[2]= 7;
     2246                                        tria1[0]=5; tria1[1]= 3; tria1[2]= 7; //FDH
     2247                                        area1=(d-f)*e*h1;
    21822248                                }else if (istrapeze1 && !istrapeze2){
    2183                                         tria1[0]=4; tria1[1]= 7; tria1[2]= 6;
     2249                                        tria1[0]=4; tria1[1]= 7; tria1[2]= 6; //EHG
     2250                                        area1=(g-e)*f*(1.0-h2);
    21842251                                }else { //istrapeze1 && istrapeze2
    2185                                         tria1[0]=3; tria1[1]= i1; tria1[2]= 7;
    2186                                         tria2[0]=7; tria2[1]= i1; tria2[2]= 6;
    2187                                         tria3[0]=6; tria3[1]= i1; tria3[2]= i2;
     2252                                        tria1[0]=3; tria1[1]= i1; tria1[2]= 7; //DBH
     2253                                        area1=e*h1*(1.0-d);
     2254                                        tria2[0]=7; tria2[1]= i1; tria2[2]= 6; //HCG
     2255                                        area2=f*(1.0-h2)*(1.0-g);
     2256                                        tria3[0]=6; tria3[1]= i1; tria3[2]= i2; //HBC
     2257                                        area3=1.0+f*(h2-g*h2-1.0)+e*h1*(f-1.0);
    21882258                                }  /*}}}*/
    21892259                        }
    2190                         else if (f11<=f21 && f12<=f22){ /*{{{*/
     2260                        else if (d<=f && e<=g){ /*{{{*/
    21912261                                if (!istrapeze1 && !istrapeze2){
    2192                                         tria1[0]=i0; tria1[1]= 3; tria1[2]= 4;
     2262                                        tria1[0]=i0; tria1[1]= 3; tria1[2]= 4;//ADE
     2263                                        area1=d*e;
    21932264                                }else if (!istrapeze1 && istrapeze2){
    21942265                                }else if (istrapeze1 && !istrapeze2){
    2195                                         tria1[0]=3; tria1[1]= 5; tria1[2]= 4;
    2196                                         tria2[0]=4; tria2[1]= 5; tria2[2]= 6;
     2266                                        tria1[0]=3; tria1[1]= 5; tria1[2]= 6; //DFG
     2267                                        area1=g*(f-d);
     2268                                        tria2[0]=3; tria2[1]= 6; tria2[2]= 4; //DGE
     2269                                        area2=d*(g-e);
    21972270                                }else { //istrapeze1 && istrapeze2
    2198                                         tria1[0]=6; tria1[1]= 5; tria1[2]= i1;
    2199                                         tria2[0]=6; tria2[1]= i1; tria2[2]= i2;
     2271                                        tria1[0]=5; tria1[1]= i2; tria1[2]= 6; //FCG
     2272                                        area1=f*(1.0-g);
     2273                                        tria2[0]=5; tria2[1]= i1; tria2[2]= i2;//FBC
     2274                                        area2=1.0-f;
    22002275                                }  /*}}}*/
    22012276                        }
    2202                         else if (f11>=f21 && f12>=f22){ /*{{{*/
     2277                        else if (d>=f && e>=g){ /*{{{*/
    22032278                                if (!istrapeze1 && !istrapeze2){
    2204                                         tria1[0]=i0; tria1[1]= 5; tria1[2]= 6;
     2279                                        tria1[0]=i0; tria1[1]= 5; tria1[2]= 6; //AFG
     2280                                        area1=f*g;
    22052281                                }else if (!istrapeze1 && istrapeze2){
    2206                                         tria1[0]=5; tria1[1]= 3; tria1[2]= 6;
    2207                                         tria2[0]=6; tria2[1]= 3; tria2[2]= 4;
     2282                                        tria1[0]=5; tria1[1]= 4; tria1[2]= 6; //FEG
     2283                                        area1=f*(e-g);
     2284                                        tria2[0]=5; tria2[1]= 3; tria2[2]= 4; //FDE
     2285                                        area2=e*(d-f);
    22082286                                }else if (istrapeze1 && !istrapeze2){
    22092287                                }else { //istrapeze1 && istrapeze2
    2210                                         tria1[0]=4; tria1[1]= 3; tria1[2]= i1;
    2211                                         tria2[0]=i1; tria2[1]= i2; tria2[2]= 4;
     2288                                        tria1[0]=3; tria1[1]= i1; tria1[2]= i2; //DBC
     2289                                        area1=1.0-d;
     2290                                        tria2[0]=3; tria2[1]= i2; tria2[2]= 4;//DCE
     2291                                        area2=d*(1.0-e);
    22122292                                }  /*}}}*/
    22132293                        }
     
    22212301                        }
    22222302                }
    2223                 area1= GetTriangleAreaSpherical(xyz1);
     2303                area1*=area; //dimensionalize the fractional area from [0:1] to [0:area]
    22242304        }
    22252305        if(tria2[0]>-1){
     
    22302310                        }
    22312311                }
    2232                 area2= GetTriangleAreaSpherical(xyz2);
     2312                area2*=area;
    22332313        }
    22342314        if(tria3[0]>-1){
     
    22392319                        }
    22402320                }
    2241                 area3= GetTriangleAreaSpherical(xyz3);
     2321                area3*=area;
    22422322        }
    22432323
     
    61006180        IssmDouble xyz_list[NUMVERTICES][3];
    61016181
    6102         /*stacks:*/
    6103         IssmDouble* stackRSL = NULL;
    6104         IssmDouble* stackU = NULL;
    6105         IssmDouble* stackN = NULL;
    6106         IssmDouble* stackE = NULL;
     6182        /*viscous stacks:*/
     6183        IssmDouble* viscousRSL = NULL;
     6184        IssmDouble* viscousU = NULL;
     6185        IssmDouble* viscousN = NULL;
     6186        IssmDouble* viscousE = NULL;
    61076187
    61086188        #ifdef _HAVE_RESTRICT_
     
    61126192        IssmDouble* __restrict__ GE=NULL;
    61136193        IssmDouble* __restrict__ G_viscoelastic_precomputed=NULL;
    6114         IssmDouble* __restrict__ G_rigid_precomputed=NULL;
     6194        IssmDouble* __restrict__ G_gravi_precomputed=NULL;
    61156195        IssmDouble* __restrict__ U_viscoelastic_precomputed=NULL;
    61166196        IssmDouble* __restrict__ H_viscoelastic_precomputed=NULL;
     
    61216201        IssmDouble* GE=NULL;
    61226202        IssmDouble* G_viscoelastic_precomputed=NULL;
    6123         IssmDouble* G_rigid_precomputed=NULL;
     6203        IssmDouble* G_gravi_precomputed=NULL;
    61246204        IssmDouble* U_viscoelastic_precomputed=NULL;
    61256205        IssmDouble* H_viscoelastic_precomputed=NULL;
     
    61286208        /*viscoelastic green function:*/
    61296209        int index;
    6130         int         M;
     6210        int M;
     6211        IssmDouble doubleindex,lincoef;
    61316212
    61326213        /*Computational flags:*/
    6133         bool computerigid = false;
     6214        bool computeselfattraction = false;
    61346215        bool computeelastic = false;
    61356216        bool computerotation = false;
     
    61406221        IssmDouble start_time,final_time;
    61416222        int  nt,precomputednt;
     6223        int grd, grdmodel;
    61426224
    61436225        /*Rotational:*/
     
    61556237        IssmDouble polenudge;
    61566238        /*}}}*/
     6239
    61576240        /*Recover parameters:{{{ */
    61586241        rho_earth=FindParam(MaterialsEarthDensityEnum);
    6159         this->parameters->FindParam(&computerigid,SolidearthSettingsRigidEnum);
     6242        this->parameters->FindParam(&computeselfattraction,SolidearthSettingsSelfAttractionEnum);
    61606243        this->parameters->FindParam(&computeelastic,SolidearthSettingsElasticEnum);
    61616244        this->parameters->FindParam(&computerotation,SolidearthSettingsRotationEnum);
     
    61666249        this->parameters->FindParam(&NewtonG,ConstantsNewtonGravityEnum);
    61676250        this->parameters->FindParam(&horiz,SolidearthSettingsHorizEnum);
     6251        this->parameters->FindParam(&grd,SolidearthSettingsGRDEnum);
     6252        this->parameters->FindParam(&grdmodel,GrdModelEnum);
     6253
     6254        /*early return:*/
     6255        if (!grd || grdmodel!=ElasticEnum) return; //Love numbers won't be found in this case, return before loading them
     6256        if(!computeselfattraction)return;
    61686257
    61696258        if(computerotation){
     
    61776266        /*}}}*/
    61786267
    6179         /*early return:*/
    6180         if(!computerigid)return;
    6181 
    61826268        /*Recover precomputed green function kernels:{{{*/
    6183         DoubleVecParam* parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelchangeGRigidEnum)); _assert_(parameter);
    6184         parameter->GetParameterValueByPointer((IssmDouble**)&G_rigid_precomputed,&M);
     6269        DoubleVecParam* parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelchangeGSelfAttractionEnum)); _assert_(parameter);
     6270        parameter->GetParameterValueByPointer((IssmDouble**)&G_gravi_precomputed,&M);
    61856271
    61866272        if(computeelastic){
     
    62156301        }
    62166302        else{
    6217                 nt=1; //in elastic, or if we run only rigid, we need only one step
     6303                nt=1; //in elastic, or if we run only selfattraction, we need only one step
    62186304        }
    62196305
     
    62456331                        delPhi=fabs(lati-late); delLambda=fabs(longi-longe); if (delLambda>M_PI)delLambda=2*M_PI-delLambda;
    62466332                        alpha=2.*asin(sqrt(pow(sin(delPhi/2),2)+cos(lati)*cos(late)*pow(sin(delLambda/2),2)));
    6247                         index=reCast<int,IssmDouble>( alpha/M_PI*reCast<IssmDouble,int>(M-1) );
     6333                        doubleindex=alpha/M_PI*reCast<IssmDouble,int>(M-1); //maps 0<alpha<PI on [0:M-1]
     6334                        index=reCast<int,IssmDouble>(doubleindex); //truncates doubleindex to integer part
    62486335                        _assert_(index>=0 && index<M);
     6336
     6337
     6338                        lincoef=doubleindex-index; //where between index and index+1 is alpha
     6339                        if (index==M-1){ //avoids out of bound case
     6340                                index-=1;
     6341                                lincoef=1;
     6342                        }
     6343                       
    62496344
    62506345                        if(horiz){
     
    62666361
    62676362                                /*Rigid earth gravitational perturbation: */
    6268                                 G[timeindex]+=G_rigid_precomputed[index];
     6363                                G[timeindex]+=G_gravi_precomputed[index+0]*(1.-lincoef)
     6364                                             +G_gravi_precomputed[index+1]*lincoef; //linear interpolation
    62696365
    62706366                                /*Find a way to interpolate precomputed Gkernels to our solution time stepping:*/
    62716367                                if(computeelastic){
    6272                                         G[timeindex]+=G_viscoelastic_precomputed[index*nt+t];
     6368                                        G[timeindex]+=G_viscoelastic_precomputed[(index+0)*nt+t]*(1.-lincoef)
     6369                                                     +G_viscoelastic_precomputed[(index+1)*nt+t]*lincoef; //linear interpolation
    62736370                                }
    62746371                                G[timeindex]=G[timeindex]*ratioe;
     
    62766373                                /*Elastic components:*/
    62776374                                if(computeelastic){
    6278                                         GU[timeindex] =  ratioe * U_viscoelastic_precomputed[index*nt+t];
     6375                                        GU[timeindex] =  ratioe *(U_viscoelastic_precomputed[(index+0)*nt+t]*(1.-lincoef)
     6376                                                                 +U_viscoelastic_precomputed[(index+1)*nt+t]*lincoef);
    62796377                                        if(horiz){
    6280                                                 GN[timeindex] = ratioe*H_viscoelastic_precomputed[index*nt+t]*N_azim;
    6281                                                 GE[timeindex] = ratioe*H_viscoelastic_precomputed[index*nt+t]*E_azim;
     6378                                                GN[timeindex] = N_azim*ratioe *(H_viscoelastic_precomputed[(index+0)*nt+t]*(1.-lincoef)
     6379                                                                               +H_viscoelastic_precomputed[(index+1)*nt+t]*lincoef);
     6380                                                GE[timeindex] = E_azim*ratioe *(H_viscoelastic_precomputed[(index+0)*nt+t]*(1.-lincoef)
     6381                                                                               +H_viscoelastic_precomputed[(index+1)*nt+t]*lincoef);
    62826382                                        }
    62836383                                }
     
    63766476        }
    63776477        /*}}}*/
    6378         /*Initialize stacks: {{{*/
     6478        /*Initialize viscous stacks: {{{*/
    63796479        if(computeviscous){
    6380                 stackRSL=xNewZeroInit<IssmDouble>(3*nt);
    6381                 stackU=xNewZeroInit<IssmDouble>(3*nt);
    6382 
    6383                 this->inputs->SetArrayInput(StackRSLEnum,this->lid,stackRSL,3*nt);
    6384                 this->inputs->SetArrayInput(StackUEnum,this->lid,stackU,3*nt);
    6385                 this->parameters->SetParam(0,StackIndexEnum);
     6480                viscousRSL=xNewZeroInit<IssmDouble>(3*nt);
     6481                viscousU=xNewZeroInit<IssmDouble>(3*nt);
     6482
     6483                this->inputs->SetArrayInput(SealevelchangeViscousRSLEnum,this->lid,viscousRSL,3*nt);
     6484                this->inputs->SetArrayInput(SealevelchangeViscousUEnum,this->lid,viscousU,3*nt);
     6485                this->parameters->SetParam(0,SealevelchangeViscousIndexEnum);
    63866486                if(horiz){
    6387                         stackN=xNewZeroInit<IssmDouble>(3*nt);
    6388                         stackE=xNewZeroInit<IssmDouble>(3*nt);
    6389                         this->inputs->SetArrayInput(StackNEnum,this->lid,stackRSL,3*nt);
    6390                         this->inputs->SetArrayInput(StackEEnum,this->lid,stackU,3*nt);
     6487                        viscousN=xNewZeroInit<IssmDouble>(3*nt);
     6488                        viscousE=xNewZeroInit<IssmDouble>(3*nt);
     6489                        this->inputs->SetArrayInput(SealevelchangeViscousNEnum,this->lid,viscousRSL,3*nt);
     6490                        this->inputs->SetArrayInput(SealevelchangeViscousEEnum,this->lid,viscousU,3*nt);
    63916491                }
    63926492        }
     
    64726572        slgeom->late[this->lid]=late;
    64736573
    6474         /*compute fractional areas and load weights for ocean:*/
     6574        /*compute areas and load weights for ocean and flag elements only partially in the ocean:*/
    64756575        if(isoceanonly){
    64766576                slgeom->LoadArea[SLGEOM_OCEAN][this->lid]=area;
     
    65826682        /*Deal with ice loads if we are on grounded ice:*/
    65836683        if(isice && !isoceanonly && computeice){
    6584                 if(isiceonly){
     6684                if(isiceonly && !isocean){
    65856685                        slgeom->LoadArea[SLGEOM_ICE][this->lid]=area;
    65866686                        for(int i=0;i<NUMVERTICES;i++) slgeom->LoadWeigths[SLGEOM_ICE][i][this->lid]=1.0/3.0;
     
    66356735        IssmDouble loadweightsocean[3]; //to keep memory of these loads, no need to recompute for bottom pressure.
    66366736        IssmDouble xyz_list[NUMVERTICES][3];
    6637         IssmDouble latbar=0;
    6638         IssmDouble longbar=0;
     6737        IssmDouble latbar=slgeom->late[this->lid];
     6738        IssmDouble longbar=slgeom->longe[this->lid];
    66396739        IssmDouble constant;
    66406740        IssmDouble nanconstant=NAN;
     
    66456745
    66466746        #ifdef _ISSM_DEBUG_
    6647         this->AddInput(SealevelBarystaticIceLatbarEnum,&nanconstant,P0Enum);
    6648         this->AddInput(SealevelBarystaticIceLongbarEnum,&nanconstant,P0Enum);
    6649         this->AddInput(SealevelBarystaticHydroLatbarEnum,&nanconstant,P0Enum);
    6650         this->AddInput(SealevelBarystaticHydroLongbarEnum,&nanconstant,P0Enum);
    6651         this->AddInput(SealevelBarystaticOceanLatbarEnum,&nanconstant,P0Enum);
    6652         this->AddInput(SealevelBarystaticOceanLongbarEnum,&nanconstant,P0Enum);
     6747        this->AddInput(SealevelBarystaticIceLatbarEnum,&latbar,P0Enum);
     6748        this->AddInput(SealevelBarystaticIceLongbarEnum,&longbar,P0Enum);
     6749        this->AddInput(SealevelBarystaticHydroLatbarEnum,&latbar,P0Enum);
     6750        this->AddInput(SealevelBarystaticHydroLongbarEnum,&longbar,P0Enum);
     6751        this->AddInput(SealevelBarystaticOceanLatbarEnum,&latbar,P0Enum);
     6752        this->AddInput(SealevelBarystaticOceanLongbarEnum,&longbar,P0Enum);
    66536753        #endif
    66546754       
     
    67256825}
    67266826/*}}}*/
    6727 void       Tria::SealevelchangeGeometryFractionKernel(SealevelGeometry* slgeom){ /*{{{*/
     6827void       Tria::SealevelchangeGeometrySubElementKernel(SealevelGeometry* slgeom){ /*{{{*/
    67286828
    67296829        /*Declarations:{{{*/
     
    67406840        #ifdef _HAVE_RESTRICT_
    67416841        IssmDouble* __restrict__ G_viscoelastic_precomputed=NULL;
    6742         IssmDouble* __restrict__ G_rigid_precomputed=NULL;
     6842        IssmDouble* __restrict__ G_gravi_precomputed=NULL;
    67436843        IssmDouble* __restrict__ U_viscoelastic_precomputed=NULL;
    67446844        IssmDouble* __restrict__ H_viscoelastic_precomputed=NULL;
     
    67506850        #else
    67516851        IssmDouble* G_viscoelastic_precomputed=NULL;
    6752         IssmDouble* G_rigid_precomputed=NULL;
     6852        IssmDouble* G_gravi_precomputed=NULL;
    67536853        IssmDouble* U_viscoelastic_precomputed=NULL;
    67546854        IssmDouble* H_viscoelastic_precomputed=NULL;
     
    67596859        #endif
    67606860       
    6761         /*elastic green function:*/
     6861        /*viscoelastic green function:*/
    67626862        int index;
    6763         int         M;
     6863        int M;
     6864        IssmDouble doubleindex,lincoef;
    67646865
    67656866        /*Computational flags:*/
    6766         bool computerigid = false;
     6867        bool computeselfattraction = false;
    67676868        bool computeelastic = false;
    67686869        bool computeviscous = false;
    67696870        int  horiz;
     6871        int grd, grdmodel;
    67706872
    67716873        bool istime=true;
     
    67776879        /*Recover parameters:{{{ */
    67786880        rho_earth=FindParam(MaterialsEarthDensityEnum);
    6779         this->parameters->FindParam(&computerigid,SolidearthSettingsRigidEnum);
     6881        this->parameters->FindParam(&computeselfattraction,SolidearthSettingsSelfAttractionEnum);
    67806882        this->parameters->FindParam(&computeelastic,SolidearthSettingsElasticEnum);
    67816883        this->parameters->FindParam(&computeviscous,SolidearthSettingsViscousEnum);
     
    67846886        this->parameters->FindParam(&planetradius,SolidearthPlanetRadiusEnum);
    67856887        this->parameters->FindParam(&horiz,SolidearthSettingsHorizEnum);
     6888        this->parameters->FindParam(&grd,SolidearthSettingsGRDEnum);
     6889        this->parameters->FindParam(&grdmodel,GrdModelEnum);
    67866890        /*}}}*/
    67876891
    67886892        /*early return:*/
    6789         if(!computerigid)return;
     6893        if (!grd || grdmodel!=ElasticEnum) return; //Love numbers won't be found in this case, return before loading them
     6894        if(!computeselfattraction)return;
    67906895
    67916896        /*Recover precomputed green function kernels:{{{*/
    6792         DoubleVecParam* parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelchangeGRigidEnum)); _assert_(parameter);
    6793         parameter->GetParameterValueByPointer((IssmDouble**)&G_rigid_precomputed,&M);
     6897        DoubleVecParam* parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelchangeGSelfAttractionEnum)); _assert_(parameter);
     6898        parameter->GetParameterValueByPointer((IssmDouble**)&G_gravi_precomputed,&M);
    67946899
    67956900        if(computeelastic){
     
    68266931        }
    68276932        else{
    6828                 nt=1; //in elastic, or if we run only rigid, we need only one step
     6933                nt=1; //in elastic, or if we run only selfattraction, we need only one step
    68296934        }
    68306935        Gsubel=xNew<IssmDouble*>(SLGEOM_NUMLOADS);
     
    68846989                                delPhi=fabs(lati-late); delLambda=fabs(longi-longe); if (delLambda>M_PI)delLambda=2*M_PI-delLambda;
    68856990                                alpha=2.*asin(sqrt(pow(sin(delPhi/2.0),2.0)+cos(lati)*cos(late)*pow(sin(delLambda/2.0),2.0)));
    6886                                 index=reCast<int,IssmDouble>( alpha/M_PI*reCast<IssmDouble,int>(M-1) );
    6887 
     6991                                doubleindex=alpha/M_PI*reCast<IssmDouble,int>(M-1); //maps 0<alpha<PI on [0:M-1]
     6992                                index=reCast<int,IssmDouble>(doubleindex); //truncates doubleindex to integer part
     6993
     6994                                lincoef=doubleindex-index; //where between index and index+1 is alpha
     6995                                if (index==M-1){ //avoids out of bound case
     6996                                        index-=1;
     6997                                        lincoef=1;
     6998                                }
    68886999
    68897000                                for(int t=0;t<nt;t++){
     
    68917002
    68927003                                        /*Rigid earth gravitational perturbation: */
    6893                                         Gsubel[l][timeindex]+=G_rigid_precomputed[index];
     7004                                        Gsubel[l][timeindex]+=G_gravi_precomputed[index+0]*(1.-lincoef)
     7005                                                             +G_gravi_precomputed[index+1]*lincoef; //linear interpolation
    68947006
    68957007                                        if(computeelastic){
    6896                                                 Gsubel[l][timeindex]+=G_viscoelastic_precomputed[index*nt+t];
     7008                                                Gsubel[l][timeindex]+=G_viscoelastic_precomputed[(index+0)*nt+t]*(1.-lincoef)
     7009                                                                     +G_viscoelastic_precomputed[(index+1)*nt+t]*lincoef; //linear interpolation
    68977010                                        }
    68987011                                        Gsubel[l][timeindex]*=ratioe;
     
    69007013                                        /*Elastic components:*/
    69017014                                        if(computeelastic){
    6902                                                 GUsubel[l][timeindex] =  ratioe * U_viscoelastic_precomputed[index*nt+t];
    6903 
     7015                                                GUsubel[l][timeindex] =  ratioe *(U_viscoelastic_precomputed[(index+0)*nt+t]*(1.-lincoef)
     7016                                                                                 +U_viscoelastic_precomputed[(index+1)*nt+t]*lincoef);
    69047017                                                if(horiz){
    6905                                                         GNsubel[l][timeindex] = ratioe*H_viscoelastic_precomputed[index*nt+t]*N_azim;
    6906                                                         GEsubel[l][timeindex] = ratioe*H_viscoelastic_precomputed[index*nt+t]*E_azim;
     7018                                                        GNsubel[l][timeindex] = N_azim*ratioe *(H_viscoelastic_precomputed[(index+0)*nt+t]*(1.-lincoef)
     7019                                                                                              +H_viscoelastic_precomputed[(index+1)*nt+t]*lincoef);
     7020                                                        GEsubel[l][timeindex] = E_azim*ratioe *(H_viscoelastic_precomputed[(index+0)*nt+t]*(1.-lincoef)
     7021                                                                                              +H_viscoelastic_precomputed[(index+1)*nt+t]*lincoef);
    69077022                                                }
    69087023                                        }
     
    69517066       
    69527067        /*Inputs:*/
    6953         IssmDouble* stackRSL=NULL;
    6954         IssmDouble* stackU=NULL;
    6955         IssmDouble* stackN=NULL;
    6956         IssmDouble* stackE=NULL;
    6957         IssmDouble* stacktimes=NULL;
    6958         int         stacknumsteps;
    6959         int         stackindex=0;
     7068        IssmDouble* viscousRSL=NULL;
     7069        IssmDouble* viscousU=NULL;
     7070        IssmDouble* viscousN=NULL;
     7071        IssmDouble* viscousE=NULL;
     7072        IssmDouble* viscoustimes=NULL;
     7073        int         viscousnumsteps;
     7074        int         viscousindex=0;
    69607075        int         newindex=0;
    69617076        int         dummy;
     
    69707085                this->parameters->FindParam(&horiz,SolidearthSettingsHorizEnum);
    69717086               
    6972                 this->parameters->FindParam(&stacknumsteps,StackNumStepsEnum);
    6973                 this->parameters->FindParam(&stacktimes,NULL,StackTimesEnum);
    6974                 this->parameters->FindParam(&stackindex,StackIndexEnum);
     7087                this->parameters->FindParam(&viscousnumsteps,SealevelchangeViscousNumStepsEnum);
     7088                this->parameters->FindParam(&viscoustimes,NULL,SealevelchangeViscousTimesEnum);
     7089                this->parameters->FindParam(&viscousindex,SealevelchangeViscousIndexEnum);
    69757090                this->parameters->FindParam(&currenttime,TimeEnum);
    69767091
    6977                 this->inputs->GetArrayPtr(StackRSLEnum,this->lid,&stackRSL,&dummy);
    6978                 this->inputs->GetArrayPtr(StackUEnum,this->lid,&stackU,&dummy);
     7092                this->inputs->GetArrayPtr(SealevelchangeViscousRSLEnum,this->lid,&viscousRSL,&dummy);
     7093                this->inputs->GetArrayPtr(SealevelchangeViscousUEnum,this->lid,&viscousU,&dummy);
    69797094                if(horiz){
    6980                         this->inputs->GetArrayPtr(StackNEnum,this->lid,&stackN,&dummy);
    6981                         this->inputs->GetArrayPtr(StackEEnum,this->lid,&stackE,&dummy);
     7095                        this->inputs->GetArrayPtr(SealevelchangeViscousNEnum,this->lid,&viscousN,&dummy);
     7096                        this->inputs->GetArrayPtr(SealevelchangeViscousEEnum,this->lid,&viscousE,&dummy);
    69827097                }
    69837098
     
    69867101                int offset=1;
    69877102                lincoeff=0;
    6988                 newindex=stacknumsteps-2;
    6989 
    6990                 for(int t=stackindex;t<stacknumsteps;t++){
    6991                         if (stacktimes[t]>currenttime){
     7103                newindex=viscousnumsteps-2;
     7104
     7105                for(int t=viscousindex;t<viscousnumsteps;t++){
     7106                        if (viscoustimes[t]>currenttime){
    69927107                                newindex=t-1;
    6993                                 lincoeff=(currenttime-stacktimes[newindex])/(stacktimes[t]-stacktimes[newindex]);
     7108                                lincoeff=(currenttime-viscoustimes[newindex])/(viscoustimes[t]-viscoustimes[newindex]);
    69947109                                foundtime=true;
    69957110                                offset=0;
     
    69997114
    70007115                if(!foundtime) lincoeff=1;
    7001                 stacktimes[newindex]=currenttime;
     7116                viscoustimes[newindex]=currenttime;
    70027117                for(int i=0;i<NUMVERTICES;i++){
    7003                         stackRSL[i*stacknumsteps+newindex+offset]=(1-lincoeff)*stackRSL[i*stacknumsteps+newindex]+lincoeff*stackRSL[i*stacknumsteps+newindex+1];
    7004                         stackU[i*stacknumsteps+newindex+offset]=(1-lincoeff)*stackU[i*stacknumsteps+newindex]+lincoeff*stackU[i*stacknumsteps+newindex+1];
     7118                        viscousRSL[i*viscousnumsteps+newindex+offset]=(1-lincoeff)*viscousRSL[i*viscousnumsteps+newindex]+lincoeff*viscousRSL[i*viscousnumsteps+newindex+1];
     7119                        viscousU[i*viscousnumsteps+newindex+offset]=(1-lincoeff)*viscousU[i*viscousnumsteps+newindex]+lincoeff*viscousU[i*viscousnumsteps+newindex+1];
    70057120                        if(horiz){
    7006                                 stackN[i*stacknumsteps+newindex+offset]=(1-lincoeff)*stackN[i*stacknumsteps+newindex]+lincoeff*stackN[i*stacknumsteps+newindex+1];
    7007                                 stackE[i*stacknumsteps+newindex+offset]=(1-lincoeff)*stackE[i*stacknumsteps+newindex]+lincoeff*stackE[i*stacknumsteps+newindex+1];
    7008                         }
    7009                 }
    7010                 stackindex=newindex+offset;
     7121                                viscousN[i*viscousnumsteps+newindex+offset]=(1-lincoeff)*viscousN[i*viscousnumsteps+newindex]+lincoeff*viscousN[i*viscousnumsteps+newindex+1];
     7122                                viscousE[i*viscousnumsteps+newindex+offset]=(1-lincoeff)*viscousE[i*viscousnumsteps+newindex]+lincoeff*viscousE[i*viscousnumsteps+newindex+1];
     7123                        }
     7124                }
     7125                viscousindex=newindex+offset;
    70117126
    70127127               
    7013                 this->parameters->SetParam(stackindex,StackIndexEnum);
    7014                 this->parameters->SetParam(stacktimes,stacknumsteps,StackTimesEnum);
     7128                this->parameters->SetParam(viscousindex,SealevelchangeViscousIndexEnum);
     7129                this->parameters->SetParam(viscoustimes,viscousnumsteps,SealevelchangeViscousTimesEnum);
    70157130
    70167131                /*free allocations:*/
    7017                 xDelete<IssmDouble>(stacktimes);
     7132                xDelete<IssmDouble>(viscoustimes);
    70187133        }
    70197134
     
    70997214}
    71007215/*}}}*/
    7101 void       Tria::SealevelchangeConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom){ /*{{{*/
     7216void       Tria::SealevelchangeConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* polarmotionvector,SealevelGeometry* slgeom){ /*{{{*/
    71027217
    71037218        /*sal green function:*/
    71047219        IssmDouble* G=NULL;
    71057220        IssmDouble* Gsub[SLGEOM_NUMLOADS];
    7106         IssmDouble SealevelGRD[NUMVERTICES]={0};
    7107         IssmDouble oceanaverage=0;
    7108         IssmDouble oceanarea=0;
    7109         IssmDouble rho_water;
    71107221        bool computefuture=false;
    71117222       
     
    71207231        IssmDouble Grotm3[3];
    71217232               
    7122         this->parameters->FindParam(&sal,SolidearthSettingsRigidEnum);
     7233        this->parameters->FindParam(&sal,SolidearthSettingsSelfAttractionEnum);
    71237234        this->parameters->FindParam(&viscous,SolidearthSettingsViscousEnum);
    71247235        this->parameters->FindParam(&rotation,SolidearthSettingsRotationEnum);
    71257236        this->parameters->FindParam(&nel,MeshNumberofelementsEnum);
    7126         this->parameters->FindParam(&rho_water,MaterialsRhoSeawaterEnum);
    71277237
    71287238        if(sal){
     
    71327242                this->inputs->GetArrayPtr(SealevelchangeGsubelOceanEnum,this->lid,&Gsub[SLGEOM_OCEAN],&size);
    71337243
    7134                 this->SealevelchangeGxL(sealevelpercpu, G, Gsub, loads, slgeom, nel,percpu=true,StackRSLEnum,computefuture=false);
     7244                this->SealevelchangeGxL(sealevelpercpu, G, Gsub, loads, slgeom, nel,percpu=true,SealevelchangeViscousRSLEnum,computefuture=false);
    71357245        }
    71367246
     
    71427252                for(int i=0;i<NUMVERTICES;i++){
    71437253                        if(slgeom->lids[this->vertices[i]->lid]==this->lid){
    7144                                 sealevelpercpu[this->vertices[i]->lid]+=Grotm1[i]*rotationvector[0]+Grotm2[i]*rotationvector[1]+Grotm3[i]*rotationvector[2];
     7254                                sealevelpercpu[this->vertices[i]->lid]+=Grotm1[i]*polarmotionvector[0]+Grotm2[i]*polarmotionvector[1]+Grotm3[i]*polarmotionvector[2];
    71457255                        }
    71467256                }
     
    71517261
    71527262        /*sal green function:*/
    7153         IssmDouble* G=NULL;
    7154         IssmDouble* Gsub[SLGEOM_NUMLOADS];
    71557263        IssmDouble oceanaverage=0;
    71567264        IssmDouble oceanarea=0;
     
    71887296        return;
    71897297} /*}}}*/
    7190 void       Tria::SealevelchangeDeformationConvolution(GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom){ /*{{{*/
    7191 
    7192         IssmDouble Sealevel[3]={0,0,0};
    7193         IssmDouble SealevelRSL[3]={0,0,0};
    7194         IssmDouble SealevelU[3]={0,0,0};
    7195         IssmDouble SealevelN[3]={0,0,0};
    7196         IssmDouble SealevelE[3]={0,0,0};
     7298void       Tria::SealevelchangeDeformationConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* polarmotionvector,SealevelGeometry* slgeom){ /*{{{*/
     7299
     7300        IssmDouble SealevelGrd[3]={0,0,0};
     7301        IssmDouble RSLGrd[3]={0,0,0};
     7302        IssmDouble UGrd[3]={0,0,0};
     7303        IssmDouble NGrd[3]={0,0,0};
     7304        IssmDouble EGrd[3]={0,0,0};
    71977305        int nel,nbar;
    71987306        bool sal = false;
     
    72247332        bool elastic=false;
    72257333        bool percpu=false;
     7334        bool planethasocean=false;
    72267335
    72277336        this->parameters->FindParam(&nel,MeshNumberofelementsEnum);
    7228         this->parameters->FindParam(&sal,SolidearthSettingsRigidEnum);
     7337        this->parameters->FindParam(&sal,SolidearthSettingsSelfAttractionEnum);
    72297338        this->parameters->FindParam(&rotation,SolidearthSettingsRotationEnum);
    72307339        this->parameters->FindParam(&elastic,SolidearthSettingsElasticEnum);
    72317340        this->parameters->FindParam(&horiz,SolidearthSettingsHorizEnum);
    7232 
     7341        this->parameters->FindParam(&planethasocean,SolidearthSettingsGrdOceanEnum);
    72337342       
    72347343               
     
    72577366                        }
    72587367                }
    7259                 this->SealevelchangeGxL(&SealevelRSL[0],G, Gsub, loads, slgeom, nel,percpu=false,StackRSLEnum,computefuture=true);
     7368                this->SealevelchangeGxL(&RSLGrd[0],G, Gsub, loads, slgeom, nel,percpu=false,SealevelchangeViscousRSLEnum,computefuture=true);
    72607369
    72617370                if(elastic){
    7262                         this->SealevelchangeGxL(&SealevelU[0],GU, GUsub, loads, slgeom, nel,percpu=false,StackUEnum,computefuture=true);
     7371                        this->SealevelchangeGxL(&UGrd[0],GU, GUsub, loads, slgeom, nel,percpu=false,SealevelchangeViscousUEnum,computefuture=true);
    72637372                        if(horiz ){
    7264                                 this->SealevelchangeGxL(&SealevelN[0],GN, GNsub, loads, slgeom, nel,percpu=false,StackNEnum,computefuture=true);
    7265                                 this->SealevelchangeGxL(&SealevelE[0],GE, GEsub, loads, slgeom, nel,percpu=false,StackEEnum,computefuture=true);
     7373                                this->SealevelchangeGxL(&NGrd[0],GN, GNsub, loads, slgeom, nel,percpu=false,SealevelchangeViscousNEnum,computefuture=true);
     7374                                this->SealevelchangeGxL(&EGrd[0],GE, GEsub, loads, slgeom, nel,percpu=false,SealevelchangeViscousEEnum,computefuture=true);
    72667375                        }
    72677376                }
     
    72757384                for(int i=0;i<NUMVERTICES;i++){
    72767385                        if(slgeom->lids[this->vertices[i]->lid]==this->lid){
    7277                                 SealevelRSL[i]+=Grotm1[i]*rotationvector[0]+Grotm2[i]*rotationvector[1]+Grotm3[i]*rotationvector[2];
     7386                                RSLGrd[i]+=Grotm1[i]*polarmotionvector[0]+Grotm2[i]*polarmotionvector[1]+Grotm3[i]*polarmotionvector[2];
    72787387                        }
    72797388                }
     
    72867395                        for(int i=0;i<NUMVERTICES;i++){
    72877396                                if(slgeom->lids[this->vertices[i]->lid]==this->lid){
    7288                                         SealevelU[i]+=GUrotm1[i]*rotationvector[0]+GUrotm2[i]*rotationvector[1]+GUrotm3[i]*rotationvector[2];
     7397                                        UGrd[i]+=GUrotm1[i]*polarmotionvector[0]+GUrotm2[i]*polarmotionvector[1]+GUrotm3[i]*polarmotionvector[2];
    72897398                                }
    72907399                        }
     
    72997408                                for(int i=0;i<NUMVERTICES;i++){
    73007409                                        if(slgeom->lids[this->vertices[i]->lid]==this->lid){
    7301                                                 SealevelN[i]+=GNrotm1[i]*rotationvector[0]+GNrotm2[i]*rotationvector[1]+GNrotm3[i]*rotationvector[2];
    7302                                                 SealevelE[i]+=GErotm1[i]*rotationvector[0]+GErotm2[i]*rotationvector[1]+GErotm3[i]*rotationvector[2];
     7410                                                NGrd[i]+=GNrotm1[i]*polarmotionvector[0]+GNrotm2[i]*polarmotionvector[1]+GNrotm3[i]*polarmotionvector[2];
     7411                                                EGrd[i]+=GErotm1[i]*polarmotionvector[0]+GErotm2[i]*polarmotionvector[1]+GErotm3[i]*polarmotionvector[2];
    73037412                                        }
    73047413                                }
     
    73077416        }
    73087417
     7418        if (planethasocean){ //We must also output the RSL on vertices to compute the ocean mass conservation
     7419                for(int i=0;i<NUMVERTICES;i++){
     7420                        if(slgeom->lids[this->vertices[i]->lid]==this->lid){
     7421                                sealevelpercpu[this->vertices[i]->lid]=RSLGrd[i];
     7422                        }
     7423                }
     7424        }
     7425
    73097426        /*Create geoid: */
    7310         for(int i=0;i<NUMVERTICES;i++)Sealevel[i]=SealevelU[i]+SealevelRSL[i];
     7427        for(int i=0;i<NUMVERTICES;i++)SealevelGrd[i]=UGrd[i]+RSLGrd[i];
    73117428       
    73127429        /*Create inputs*/
    7313         this->AddInput(SealevelGRDEnum,Sealevel,P1Enum);
    7314         this->AddInput(BedGRDEnum,SealevelU,P1Enum);
     7430        this->AddInput(SealevelGRDEnum,SealevelGrd,P1Enum);
     7431        this->AddInput(BedGRDEnum,UGrd,P1Enum);
    73157432        if(horiz){
    7316                 this->AddInput(BedNorthGRDEnum,SealevelN,P1Enum);
    7317                 this->AddInput(BedEastGRDEnum,SealevelE,P1Enum);
     7433                this->AddInput(BedNorthGRDEnum,NGrd,P1Enum);
     7434                this->AddInput(BedEastGRDEnum,EGrd,P1Enum);
    73187435        }
    73197436
    73207437
    73217438} /*}}}*/
    7322 void       Tria::SealevelchangeGxL(IssmDouble* sealevelout, IssmDouble* G, IssmDouble** Gsub, GrdLoads* loads, SealevelGeometry* slgeom, int nel, bool percpu, int stackenum, bool computefuture) { /*{{{*/
    7323 
    7324         IssmDouble* sealevel=NULL;
     7439void       Tria::SealevelchangeGxL(IssmDouble* grdfieldout, IssmDouble* G, IssmDouble** Gsub, GrdLoads* loads, SealevelGeometry* slgeom, int nel, bool percpu, int viscousenum, bool computefuture) { /*{{{*/
     7440
     7441        IssmDouble* grdfield=NULL;
    73257442        int i,e,l,t,nbar;
    7326         bool viscous=false;
    7327         IssmDouble* stack=NULL;
     7443        bool computeviscous=false;
     7444        IssmDouble* viscousfield=NULL;
    73287445        int nt=1; //important
    7329         int stackindex=0; //important
    7330         int stacknumsteps=1; //important
    7331 
    7332         this->parameters->FindParam(&viscous,SolidearthSettingsViscousEnum);
    7333         if(viscous){
    7334                 this->parameters->FindParam(&stacknumsteps,StackNumStepsEnum);
    7335                 if(computefuture) nt=stacknumsteps;
     7446        int viscousindex=0; //important
     7447        int viscousnumsteps=1; //important
     7448
     7449        this->parameters->FindParam(&computeviscous,SolidearthSettingsViscousEnum);
     7450        if(computeviscous){
     7451                this->parameters->FindParam(&viscousnumsteps,SealevelchangeViscousNumStepsEnum);
     7452                if(computefuture) nt=viscousnumsteps;
    73367453                else nt=1;
    73377454
    73387455                //allocate
    7339                 sealevel=xNewZeroInit<IssmDouble>(3*nt);
    7340         }
    7341         else sealevel=xNewZeroInit<IssmDouble>(3*nt);
     7456                grdfield=xNewZeroInit<IssmDouble>(3*nt);
     7457        }
     7458        else grdfield=xNewZeroInit<IssmDouble>(3*nt);
    73427459
    73437460        if(loads->sealevelloads){
     
    73477464                        for (e=0;e<nel;e++){
    73487465                                for(t=0;t<nt;t++){
    7349                                         int index=i*nel*stacknumsteps+e*stacknumsteps+t;
    7350                                         sealevel[i*nt+t]+=G[index]*(loads->sealevelloads[e]+loads->loads[e]);
     7466                                        int index=i*nel*viscousnumsteps+e*viscousnumsteps+t;
     7467                                        grdfield[i*nt+t]+=G[index]*(loads->sealevelloads[e]+loads->loads[e]);
    73517468                                }
    73527469                        }
     
    73557472                                for (e=0;e<nbar;e++){
    73567473                                        for(t=0;t<nt;t++){
    7357                                                 int index=i*nbar*stacknumsteps+e*stacknumsteps+t;
    7358                                                 sealevel[i*nt+t]+=Gsub[l][index]*(loads->subloads[l][e]);
     7474                                                int index=i*nbar*viscousnumsteps+e*viscousnumsteps+t;
     7475                                                grdfield[i*nt+t]+=Gsub[l][index]*(loads->subloads[l][e]);
    73597476                                        }
    73607477                                }
     
    73627479                                        for (e=0;e<nbar;e++){
    73637480                                                for(t=0;t<nt;t++){
    7364                                                         int index=i*nbar*stacknumsteps+e*stacknumsteps+t;
    7365                                                         sealevel[i*nt+t]+=Gsub[l][index]*(loads->subsealevelloads[e]);
     7481                                                        int index=i*nbar*viscousnumsteps+e*viscousnumsteps+t;
     7482                                                        grdfield[i*nt+t]+=Gsub[l][index]*(loads->subsealevelloads[e]);
    73667483                                                }
    73677484                                        }
     
    73767493                        for (e=0;e<nel;e++){
    73777494                                for(t=0;t<nt;t++){
    7378                                         int index=i*nel*stacknumsteps+e*stacknumsteps+t;
    7379                                         sealevel[i*nt+t]+=G[index]*(loads->loads[e]);
     7495                                        int index=i*nel*viscousnumsteps+e*viscousnumsteps+t;
     7496                                        grdfield[i*nt+t]+=G[index]*(loads->loads[e]);
    73807497                                }
    73817498                        }
     
    73847501                                for (e=0;e<nbar;e++){
    73857502                                        for(t=0;t<nt;t++){
    7386                                                 int index=i*nbar*stacknumsteps+e*stacknumsteps+t;
    7387                                                 sealevel[i*nt+t]+=Gsub[l][index]*(loads->subloads[l][e]);
     7503                                                int index=i*nbar*viscousnumsteps+e*viscousnumsteps+t;
     7504                                                grdfield[i*nt+t]+=Gsub[l][index]*(loads->subloads[l][e]);
    73887505                                        }
    73897506                                }
     
    73927509        }
    73937510       
    7394         if(viscous){
    7395                 IssmDouble* sealevelinterp=NULL;
    7396                 IssmDouble* stacktimes=NULL;
     7511        if(computeviscous){
     7512                IssmDouble* grdfieldinterp=NULL;
     7513                IssmDouble* viscoustimes=NULL;
    73977514                IssmDouble  final_time;
    73987515                IssmDouble  lincoeff;
    73997516                IssmDouble  timeacc;
    74007517
    7401                 this->parameters->FindParam(&stackindex,StackIndexEnum);
    7402                 this->parameters->FindParam(&stacktimes,NULL,StackTimesEnum);
     7518                this->parameters->FindParam(&viscousindex,SealevelchangeViscousIndexEnum);
     7519                this->parameters->FindParam(&viscoustimes,NULL,SealevelchangeViscousTimesEnum);
    74037520                this->parameters->FindParam(&final_time,TimesteppingFinalTimeEnum);
    74047521                this->parameters->FindParam(&timeacc,SolidearthSettingsTimeAccEnum);
    7405                 this->inputs->GetArrayPtr(stackenum,this->lid,&stack,NULL);
     7522                this->inputs->GetArrayPtr(viscousenum,this->lid,&viscousfield,NULL);
    74067523                if(computefuture){
    7407                         sealevelinterp=xNew<IssmDouble>(3*nt);
    7408                         if(stacktimes[stackindex]<final_time){
    7409                                 lincoeff=(stacktimes[stackindex+1]-stacktimes[stackindex])/timeacc;
    7410                                 for(int t=stackindex;t<nt;t++){
    7411                                         if(t==stackindex){
     7524                        grdfieldinterp=xNew<IssmDouble>(3*nt);
     7525                        if(viscoustimes[viscousindex]<final_time){
     7526                                lincoeff=(viscoustimes[viscousindex+1]-viscoustimes[viscousindex])/timeacc;
     7527                                for(int t=viscousindex;t<nt;t++){
     7528                                        if(t==viscousindex){
    74127529                                                for(int i=0;i<NUMVERTICES;i++){
    74137530                                                        if(slgeom->lids[this->vertices[i]->lid]!=this->lid)continue;
    7414                                                         sealevelinterp[i*nt+t]=  sealevel[i*nt+0];
     7531                                                        grdfieldinterp[i*nt+t]=  grdfield[i*nt+0];
    74157532                                                }
    74167533                                        }
     
    74187535                                                for(int i=0;i<NUMVERTICES;i++){
    74197536                                                        if(slgeom->lids[this->vertices[i]->lid]!=this->lid)continue;
    7420                                                         sealevelinterp[i*nt+t]=  (1-lincoeff)*sealevel[i*nt+(t-stackindex-1)]+lincoeff*sealevel[i*nt+(t-stackindex)];
     7537                                                        grdfieldinterp[i*nt+t]=  (1-lincoeff)*grdfield[i*nt+(t-viscousindex-1)]+lincoeff*grdfield[i*nt+(t-viscousindex)];
    74217538                                                }
    74227539                                        }
     
    74257542                }
    74267543
    7427                 /*update sealevel at present time using stack at present time: */
     7544                /*update grdfield at present time using viscous stack at present time: */
    74287545                for(int i=0;i<NUMVERTICES;i++){
    74297546                        if(slgeom->lids[this->vertices[i]->lid]!=this->lid)continue;
    7430                         sealevel[i*nt+0]+=stack[i*stacknumsteps+stackindex];
    7431                 }
    7432 
    7433                 if(computefuture){ /*update stack with future deformation from present load: */
    7434 
    7435                         for(int t=nt-1;t>=stackindex;t--){
     7547                        grdfield[i*nt+0]+=viscousfield[i*viscousnumsteps+viscousindex];
     7548                }
     7549
     7550                if(computefuture){ /*update viscous stack with future deformation from present load: */
     7551
     7552                        for(int t=nt-1;t>=viscousindex;t--){
    74367553                                for(int i=0;i<NUMVERTICES;i++){
    74377554                                        if(slgeom->lids[this->vertices[i]->lid]!=this->lid)continue;
    7438                                         stack[i*stacknumsteps+t]+=sealevelinterp[i*nt+t]-sealevelinterp[i*nt+stackindex]-stack[i*stacknumsteps+stackindex];
     7555                                        //offset viscousfield to remove all deformation that has already been added
     7556                                        viscousfield[i*viscousnumsteps+t]+=grdfieldinterp[i*nt+t]-grdfieldinterp[i*nt+viscousindex]-viscousfield[i*viscousnumsteps+viscousindex];
    74397557                                }
    74407558                        }
    7441                         /*Re-add stack now that we updated:*/
    7442                         this->inputs->SetArrayInput(stackenum,this->lid,stack,3*stacknumsteps);
     7559                        /*Re-add viscous stack now that we updated:*/
     7560                        this->inputs->SetArrayInput(viscousenum,this->lid,viscousfield,3*viscousnumsteps);
    74437561                }
    74447562
    74457563                /*Free allocatoins:*/
    7446                 xDelete<IssmDouble>(stacktimes);
     7564                xDelete<IssmDouble>(viscoustimes);
    74477565        }
    74487566
     
    74517569                for(i=0;i<NUMVERTICES;i++){
    74527570                        if(slgeom->lids[this->vertices[i]->lid]==this->lid){
    7453                                 sealevelout[this->vertices[i]->lid]=sealevel[i*nt+0];
     7571                                grdfieldout[this->vertices[i]->lid]=grdfield[i*nt+0];
    74547572                        }
    74557573                }
    74567574        }
    74577575        else{
    7458                 for(i=0;i<NUMVERTICES;i++) sealevelout[i]=sealevel[i*nt+0];
     7576                for(i=0;i<NUMVERTICES;i++) grdfieldout[i]=grdfield[i*nt+0];
    74597577        }
    74607578
  • issm/trunk-jpl/src/c/classes/Elements/Tria.h

    r26272 r26296  
    170170                void       GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,Matlitho* litho, IssmDouble* x,IssmDouble* y);
    171171                void       SealevelchangeGeometryInitial(IssmDouble* xxe, IssmDouble* yye, IssmDouble* zze, IssmDouble* areae);
    172                 void       SealevelchangeGeometryFractionKernel(SealevelGeometry* slgeom);
     172                void       SealevelchangeGeometrySubElementKernel(SealevelGeometry* slgeom);
    173173                void       SealevelchangeGeometrySubElementLoads(SealevelGeometry* slgeom, IssmDouble* areae);
    174174                void       SealevelchangeGeometryCentroidLoads(SealevelGeometry* slgeom, IssmDouble* xxe, IssmDouble* yye, IssmDouble* zze, IssmDouble* areae);
     
    176176                void       SealevelchangeConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom);
    177177                void       SealevelchangeOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble* sealevelpercpu, SealevelGeometry* slgeom);
    178                 void       SealevelchangeDeformationConvolution(GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom);
     178                void       SealevelchangeDeformationConvolution(IssmDouble* sealevelpercpu, GrdLoads* loads, IssmDouble* rotationvector,SealevelGeometry* slgeom);
    179179                void       SealevelchangeShift(GrdLoads* loads,  IssmDouble offset, SealevelGeometry* slgeom);
    180180                void       SealevelchangeMomentOfInertiaCentroid(IssmDouble* dI_list, GrdLoads* loads,  SealevelGeometry* slgeom);
  • issm/trunk-jpl/src/c/cores/sealevelchange_core.cpp

    r26285 r26296  
    2424void TransferSealevel(FemModel* femmodel,int forcingenum);
    2525bool slcconvergence(Vector<IssmDouble>* RSLg,Vector<IssmDouble>* RSLg_old,IssmDouble eps_rel,IssmDouble eps_abs);
    26 IssmDouble  SealevelloadsOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble oceanarea);
    27 void RotationAxisMotion(IssmDouble* m, FemModel* femmodel,GrdLoads* loads, SealevelGeometry* slgeom);
     26IssmDouble  SealevelloadsOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* subelementoceanareas, IssmDouble totaloceanarea);
     27void PolarMotion(IssmDouble* m, FemModel* femmodel,GrdLoads* loads, SealevelGeometry* slgeom);
    2828void ConserveOceanMass(FemModel* femmodel,GrdLoads* loads, IssmDouble offset, SealevelGeometry* slgeom);
    2929void ivins_deformation_core(FemModel* femmodel);
     
    221221        BarystaticContributions* barycontrib=NULL;
    222222        GenericParam<BarystaticContributions*>* barycontribparam=NULL;
    223         IssmDouble rotationaxismotionvector[3]={0};
     223        IssmDouble polarmotionvector[3]={0};
    224224       
    225225        GrdLoads*              loads=NULL;
    226226        Vector<IssmDouble>*    oldsealevelloads=NULL;
    227227        Vector<IssmDouble>*    oceanareas=NULL;
    228         IssmDouble             oceanarea;
     228        IssmDouble             totaloceanarea;
    229229        Vector<IssmDouble>*    subelementoceanareas=NULL;
    230230        IssmDouble             oceanaverage;
     
    244244        int  grd=0;
    245245        int  grdmodel;
    246         int  computesealevel=0;
     246        int  sealevelloading=0;
    247247        bool viscous=false;
     248        bool rotation=false;
     249        bool planethasocean=false;
    248250        IssmDouble*           sealevelpercpu=NULL;
    249251
     
    255257        /*retrieve parameters:{{{*/
    256258        femmodel->parameters->FindParam(&grd,SolidearthSettingsGRDEnum);
     259        femmodel->parameters->FindParam(&grdmodel,GrdModelEnum);
    257260        femmodel->parameters->FindParam(&frequency,SolidearthSettingsRunFrequencyEnum);
    258261        femmodel->parameters->FindParam(&count,SealevelchangeRunCountEnum);
    259         femmodel->parameters->FindParam(&computesealevel,SolidearthSettingsComputesealevelchangeEnum);
     262        femmodel->parameters->FindParam(&step,StepEnum);
     263        femmodel->parameters->FindParam(&time,TimeEnum);
     264        femmodel->parameters->FindParam(&sealevelloading,SolidearthSettingsSealevelLoadingEnum);
    260265        femmodel->parameters->FindParam(&max_nonlinear_iterations,SolidearthSettingsMaxiterEnum);
    261         femmodel->parameters->FindParam(&grdmodel,GrdModelEnum);
    262266        femmodel->parameters->FindParam(&viscous,SolidearthSettingsViscousEnum);
     267        femmodel->parameters->FindParam(&rotation,SolidearthSettingsRotationEnum);
     268        femmodel->parameters->FindParam(&planethasocean,SolidearthSettingsGrdOceanEnum);
    263269        /*}}}*/
    264270
     
    314320        loads->BroadcastLoads();
    315321
    316         //compute rotation axis motion:
    317         RotationAxisMotion(&rotationaxismotionvector[0],femmodel,loads,slgeom);
    318 
    319         /*skip computation of sea level if requested, which means sea level loads should be zeroed */
    320         if(!computesealevel){
     322        //compute polar motion:
     323        PolarMotion(&polarmotionvector[0],femmodel,loads,slgeom);
     324
     325        /*skip computation of sea level equation if requested, which means sea level loads should be zeroed */
     326        if(!sealevelloading){
    321327                loads->sealevelloads=xNewZeroInit<IssmDouble>(nel);
    322328                loads->subsealevelloads=xNewZeroInit<IssmDouble>(slgeom->nbar[SLGEOM_OCEAN]);
     329
    323330                goto deformation;
    324331        }
     
    332339                for(Object* & object : femmodel->elements->objects){
    333340                        Element* element = xDynamicCast<Element*>(object);
    334                         element->SealevelchangeConvolution(sealevelpercpu, loads , rotationaxismotionvector,slgeom);
     341                        element->SealevelchangeConvolution(sealevelpercpu, loads , polarmotionvector,slgeom);
    335342                }
    336343               
     
    347354                        oceanareas->Assemble();
    348355                        subelementoceanareas->Assemble();
    349                         oceanareas->Sum(&oceanarea); _assert_(oceanarea>0.);
    350                         if(scaleoceanarea) oceanarea=3.619e+14; // use true ocean area, m^2
     356                        oceanareas->Sum(&totaloceanarea); _assert_(totaloceanarea>0.);
     357                        if(scaleoceanarea) totaloceanarea=3.619e+14; // use true ocean area, m^2
    351358                }
    352359       
    353360                //Conserve ocean mass:
    354                 oceanaverage=SealevelloadsOceanAverage(loads, oceanareas,subelementoceanareas, oceanarea);
    355                 ConserveOceanMass(femmodel,loads,barycontrib->Total()/oceanarea - oceanaverage,slgeom);
     361                oceanaverage=SealevelloadsOceanAverage(loads, oceanareas,subelementoceanareas, totaloceanarea);
     362                ConserveOceanMass(femmodel,loads,barycontrib->Total()/totaloceanarea - oceanaverage,slgeom);
    356363
    357364                //broadcast sea level loads
    358365                loads->BroadcastSealevelLoads();
    359366
    360                 //compute rotation axis motion:
    361                 RotationAxisMotion(&rotationaxismotionvector[0],femmodel,loads, slgeom);
     367                //compute polar motion:
     368                PolarMotion(&polarmotionvector[0],femmodel,loads, slgeom);
    362369
    363370                //convergence?
     
    376383        for(Object* & object : femmodel->elements->objects){
    377384                Element* element = xDynamicCast<Element*>(object);
    378                 element->SealevelchangeDeformationConvolution(loads, rotationaxismotionvector,slgeom);
     385                element->SealevelchangeDeformationConvolution(sealevelpercpu, loads, polarmotionvector,slgeom);
    379386        }
    380387
    381388        if(VerboseSolution()) _printf0_("         updating GRD fields\n");
    382389
    383         /*Update bedrock motion and geoid:*/
    384         if(computesealevel){
    385                 femmodel->inputs->Shift(SealevelGRDEnum,barycontrib->Total()/rho_water/oceanarea- oceanaverage/rho_water); //given that we converged, no need to recompute ocean average
     390        if(planethasocean){
     391                if (!sealevelloading){ //we haven't done so before, so we need to compute the ocean average and area
     392                        loads->sealevelloads=NULL; //needed to trigger the calculation of areas
     393                        /*retrieve sea level average  and ocean area:*/
     394                        for(Object* & object : femmodel->elements->objects){
     395                                Element* element = xDynamicCast<Element*>(object);
     396                                element->SealevelchangeOceanAverage(loads, oceanareas, subelementoceanareas, sealevelpercpu, slgeom);
     397                        }
     398                        loads->sealevelloads=xNewZeroInit<IssmDouble>(nel);
     399                        loads->AssembleSealevelLoads();
     400                        /*compute ocean areas:*/
     401                        oceanareas->Assemble();
     402                        subelementoceanareas->Assemble();
     403                        oceanareas->Sum(&totaloceanarea); _assert_(totaloceanarea>0.);
     404                        if(scaleoceanarea) totaloceanarea=3.619e+14; // use true ocean area, m^2
     405                               
     406                        //Conserve ocean mass
     407                        //Note that here we create sea-level loads but they will not generate GRD as we have already run all the convolutions
     408                        oceanaverage=SealevelloadsOceanAverage(loads, oceanareas,subelementoceanareas, totaloceanarea);
     409                        ConserveOceanMass(femmodel,loads,barycontrib->Total()/totaloceanarea - oceanaverage,slgeom);
     410                }
     411
     412                femmodel->inputs->Shift(SealevelGRDEnum,barycontrib->Total()/rho_water/totaloceanarea- oceanaverage/rho_water);
    386413
    387414                //cumulate barystatic contributions and save to results:
    388415                barycontrib->Cumulate(femmodel->parameters);
    389                 barycontrib->Save(femmodel->results,femmodel->parameters,oceanarea);
     416                barycontrib->Save(femmodel->results,femmodel->parameters,totaloceanarea);
    390417                barycontrib->Reset();
    391418        }
    392419
     420        if (rotation) {
     421                femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,SealevelInertiaTensorXZEnum,polarmotionvector[0],step,time));
     422                femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,SealevelInertiaTensorYZEnum,polarmotionvector[1],step,time));
     423                femmodel->results->AddResult(new GenericExternalResult<IssmDouble>(femmodel->results->Size()+1,SealevelInertiaTensorZZEnum,polarmotionvector[2],step,time));
     424        }
     425
     426        /*Update bedrock motion and geoid:*/
    393427        femmodel->inputs->AXPY(1,SealevelGRDEnum,SealevelEnum);
    394428        femmodel->inputs->AXPY(1,BedGRDEnum,BedEnum);
     
    409443        /*parameters: */
    410444        int  step;
    411         int computesealevel=0;
    412445        bool isocean=false;
    413446        IssmDouble time;
     
    417450        IssmDouble cumgmslc=0;
    418451        IssmDouble gmtslc=0;
    419 
    420         /*early return if we are not computing sea level, but rather deformation: */
    421         femmodel->parameters->FindParam(&computesealevel,SolidearthSettingsComputesealevelchangeEnum);
    422         if (!computesealevel)return;
    423452
    424453        /*early return if we have no ocean transport:*/
     
    610639        femmodel->parameters->FindParam(&areae,&nel,AreaeEnum);
    611640       
    612         /*initialize SealevelMasks structure: */
     641        /*initialize SealevelloadMasks structure: */
    613642        slgeom=new SealevelGeometry(femmodel->elements->Size(),femmodel->vertices->Size());
    614643       
     
    639668        for(Object* & object : femmodel->elements->objects){
    640669                Element*   element=xDynamicCast<Element*>(object);
    641                 element->SealevelchangeGeometryFractionKernel(slgeom);
     670                element->SealevelchangeGeometrySubElementKernel(slgeom);
    642671        }
    643672
     
    699728
    700729} /*}}}*/
    701 IssmDouble  SealevelloadsOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* suboceanareas, IssmDouble oceanarea){ /*{{{*/
     730IssmDouble  SealevelloadsOceanAverage(GrdLoads* loads, Vector<IssmDouble>* oceanareas, Vector<IssmDouble>* suboceanareas, IssmDouble totaloceanarea){ /*{{{*/
    702731
    703732        IssmDouble sealevelloadsaverage;       
     
    715744        delete vsubsealevelloadsvolume;
    716745       
    717         return (sealevelloadsaverage+subsealevelloadsaverage)/oceanarea;
     746        return (sealevelloadsaverage+subsealevelloadsaverage)/totaloceanarea;
    718747} /*}}}*/
    719 void RotationAxisMotion(IssmDouble* m, FemModel* femmodel,GrdLoads* loads, SealevelGeometry* slgeom){ /*{{{*/
     748void PolarMotion(IssmDouble* polarmotionvector, FemModel* femmodel,GrdLoads* loads, SealevelGeometry* slgeom){ /*{{{*/
    720749
    721750        IssmDouble  moi_list[3]={0,0,0};
     
    746775
    747776                element->SealevelchangeMomentOfInertiaCentroid(&moi_list[0],loads,slgeom);
    748 
    749777                element->SealevelchangeMomentOfInertiaSubElement(&moi_list_sub[0],loads, slgeom);
    750778
     
    754782        }
    755783
     784        for (int i=0;i<3;i++) moi_list[i]=0;
    756785
    757786        ISSM_MPI_Reduce (&moi_list_cpu[0],&moi_list[0],1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
     
    770799
    771800        /*Assign output pointers:*/
    772         m[0]=m1;
    773         m[1]=m2;
    774         m[2]=m3;
     801        polarmotionvector[0]=m1;
     802        polarmotionvector[1]=m2;
     803        polarmotionvector[2]=m3;
    775804} /*}}}*/
    776805void        ConserveOceanMass(FemModel* femmodel,GrdLoads* loads, IssmDouble offset, SealevelGeometry* slgeom){ /*{{{*/
  • issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h

    r26274 r26296  
    360360        SolidearthSettingsViscousEnum,
    361361        SealevelchangeGeometryDoneEnum,
     362        SealevelchangeViscousNumStepsEnum,
     363        SealevelchangeViscousTimesEnum,
     364        SealevelchangeViscousIndexEnum,
    362365        RotationalEquatorialMoiEnum,
    363366        TidalLoveHEnum,
     
    370373        LoveTimeFreqEnum,
    371374        LoveIsTimeEnum,
    372         SealevelchangeGRigidEnum,
     375        SealevelchangeGSelfAttractionEnum,
    373376        SealevelchangeGViscoElasticEnum,
    374         SolidearthSettingsComputesealevelchangeEnum,
     377        SolidearthSettingsSealevelLoadingEnum,
    375378        SolidearthSettingsGRDEnum,
    376379        SolidearthSettingsRunFrequencyEnum,
     
    379382        SolidearthSettingsHorizEnum,
    380383        SolidearthSettingsMaxiterEnum,
     384        SolidearthSettingsGrdOceanEnum,
    381385        SolidearthSettingsOceanAreaScalingEnum,
    382386        RotationalPolarMoiEnum,
    383387        SolidearthSettingsReltolEnum,
    384388        SealevelchangeRequestedOutputsEnum,
    385         SolidearthSettingsRigidEnum,
     389        SolidearthSettingsSelfAttractionEnum,
    386390        SolidearthSettingsRotationEnum,
    387391        SolidearthSettingsMaxSHCoeffEnum,
     
    397401        SettingsSolverResidueThresholdEnum,
    398402        SettingsWaitonlockEnum,
    399         StackNumStepsEnum,
    400         StackTimesEnum,
    401         StackIndexEnum,
    402403        SmbAIceEnum,
    403404        SmbAIdxEnum,
     
    832833        SealevelchangeGEsubelHydroEnum,
    833834        SealevelchangeGNsubelHydroEnum,
     835        SealevelchangeViscousRSLEnum,
     836        SealevelchangeViscousUEnum,
     837        SealevelchangeViscousNEnum,
     838        SealevelchangeViscousEEnum,
    834839        SedimentHeadEnum,
    835840        SedimentHeadOldEnum,
     
    953958        SolidearthExternalDisplacementUpRateEnum,
    954959        SolidearthExternalGeoidRateEnum,
    955         StackRSLEnum,
    956         StackUEnum,
    957         StackNEnum,
    958         StackEEnum,
    959960        StrainRateeffectiveEnum,
    960961        StrainRateparallelEnum,
     
    14301431        SealevelInertiaTensorYZEnum,
    14311432        SealevelInertiaTensorZZEnum,
     1433        SealevelchangePolarMotionEnum,
    14321434        SealevelNmotionEnum,
    14331435        SealevelUmotionEnum,
  • issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp

    r26274 r26296  
    378378                case LoveTimeFreqEnum : return "LoveTimeFreq";
    379379                case LoveIsTimeEnum : return "LoveIsTime";
    380                 case SealevelchangeGRigidEnum : return "SealevelchangeGRigid";
     380                case SealevelchangeGSelfAttractionEnum : return "SealevelchangeGSelfAttraction";
    381381                case SealevelchangeGViscoElasticEnum : return "SealevelchangeGViscoElastic";
    382                 case SolidearthSettingsComputesealevelchangeEnum : return "SolidearthSettingsComputesealevelchange";
     382                case SolidearthSettingsSealevelLoadingEnum : return "SolidearthSettingsSealevelLoading";
    383383                case SolidearthSettingsGRDEnum : return "SolidearthSettingsGRD";
    384384                case SolidearthSettingsRunFrequencyEnum : return "SolidearthSettingsRunFrequency";
     
    391391                case SolidearthSettingsReltolEnum : return "SolidearthSettingsReltol";
    392392                case SealevelchangeRequestedOutputsEnum : return "SealevelchangeRequestedOutputs";
    393                 case SolidearthSettingsRigidEnum : return "SolidearthSettingsRigid";
     393                case SolidearthSettingsSelfAttractionEnum : return "SolidearthSettingsSelfAttraction";
    394394                case SolidearthSettingsRotationEnum : return "SolidearthSettingsRotation";
    395395                case SealevelchangeRunCountEnum : return "SealevelchangeRunCount";
     
    404404                case SettingsSolverResidueThresholdEnum : return "SettingsSolverResidueThreshold";
    405405                case SettingsWaitonlockEnum : return "SettingsWaitonlock";
    406                 case StackNumStepsEnum : return "StackNumSteps";
    407                 case StackTimesEnum : return "StackTimes";
    408                 case StackIndexEnum : return "StackIndex";
     406                case SealevelchangeViscousNumStepsEnum : return "SealevelchangeViscousNumSteps";
     407                case SealevelchangeViscousTimesEnum : return "SealevelchangeViscousTimes";
     408                case SealevelchangeViscousIndexEnum : return "SealevelchangeViscousIndex";
    409409                case SmbAIceEnum : return "SmbAIce";
    410410                case SmbAIdxEnum : return "SmbAIdx";
     
    957957                case SolidearthExternalDisplacementUpRateEnum : return "SolidearthExternalDisplacementUpRate";
    958958                case SolidearthExternalGeoidRateEnum : return "SolidearthExternalGeoidRate";
    959                 case StackRSLEnum : return "StackRSL";
    960                 case StackUEnum : return "StackU";
    961                 case StackNEnum : return "StackN";
    962                 case StackEEnum : return "StackE";
     959                case SealevelchangeViscousRSLEnum : return "SealevelchangeViscousRSL";
     960                case SealevelchangeViscousUEnum : return "SealevelchangeViscousU";
     961                case SealevelchangeViscousNEnum : return "SealevelchangeViscousN";
     962                case SealevelchangeViscousEEnum : return "SealevelchangeViscousE";
    963963                case StrainRateeffectiveEnum : return "StrainRateeffective";
    964964                case StrainRateparallelEnum : return "StrainRateparallel";
  • issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp

    r26274 r26296  
    387387   if(stage==4){
    388388              if (strcmp(name,"LoveIsTime")==0) return LoveIsTimeEnum;
    389               else if (strcmp(name,"SealevelchangeGRigid")==0) return SealevelchangeGRigidEnum;
     389              else if (strcmp(name,"SealevelchangeGSelfAttraction")==0) return SealevelchangeGSelfAttractionEnum;
    390390              else if (strcmp(name,"SealevelchangeGViscoElastic")==0) return SealevelchangeGViscoElasticEnum;
    391               else if (strcmp(name,"SolidearthSettingsComputesealevelchange")==0) return SolidearthSettingsComputesealevelchangeEnum;
     391              else if (strcmp(name,"SolidearthSettingsSealevelLoading")==0) return SolidearthSettingsSealevelLoadingEnum;
    392392              else if (strcmp(name,"SolidearthSettingsGRD")==0) return SolidearthSettingsGRDEnum;
    393393              else if (strcmp(name,"SolidearthSettingsRunFrequency")==0) return SolidearthSettingsRunFrequencyEnum;
     
    400400              else if (strcmp(name,"SolidearthSettingsReltol")==0) return SolidearthSettingsReltolEnum;
    401401              else if (strcmp(name,"SealevelchangeRequestedOutputs")==0) return SealevelchangeRequestedOutputsEnum;
    402               else if (strcmp(name,"SolidearthSettingsRigid")==0) return SolidearthSettingsRigidEnum;
     402              else if (strcmp(name,"SolidearthSettingsSelfAttraction")==0) return SolidearthSettingsSelfAttractionEnum;
    403403              else if (strcmp(name,"SolidearthSettingsRotation")==0) return SolidearthSettingsRotationEnum;
    404404              else if (strcmp(name,"SealevelchangeRunCount")==0) return SealevelchangeRunCountEnum;
     
    413413              else if (strcmp(name,"SettingsSolverResidueThreshold")==0) return SettingsSolverResidueThresholdEnum;
    414414              else if (strcmp(name,"SettingsWaitonlock")==0) return SettingsWaitonlockEnum;
    415               else if (strcmp(name,"StackNumSteps")==0) return StackNumStepsEnum;
    416               else if (strcmp(name,"StackTimes")==0) return StackTimesEnum;
    417               else if (strcmp(name,"StackIndex")==0) return StackIndexEnum;
     415              else if (strcmp(name,"SealevelchangeViscousNumSteps")==0) return SealevelchangeViscousNumStepsEnum;
     416              else if (strcmp(name,"SealevelchangeViscousTimes")==0) return SealevelchangeViscousTimesEnum;
     417              else if (strcmp(name,"SealevelchangeViscousIndex")==0) return SealevelchangeViscousIndexEnum;
    418418              else if (strcmp(name,"SmbAIce")==0) return SmbAIceEnum;
    419419              else if (strcmp(name,"SmbAIdx")==0) return SmbAIdxEnum;
     
    978978              else if (strcmp(name,"SolidearthExternalDisplacementUpRate")==0) return SolidearthExternalDisplacementUpRateEnum;
    979979              else if (strcmp(name,"SolidearthExternalGeoidRate")==0) return SolidearthExternalGeoidRateEnum;
    980               else if (strcmp(name,"StackRSL")==0) return StackRSLEnum;
    981               else if (strcmp(name,"StackU")==0) return StackUEnum;
    982               else if (strcmp(name,"StackN")==0) return StackNEnum;
    983               else if (strcmp(name,"StackE")==0) return StackEEnum;
     980              else if (strcmp(name,"SealevelchangeViscousRSL")==0) return SealevelchangeViscousRSLEnum;
     981              else if (strcmp(name,"SealevelchangeViscousU")==0) return SealevelchangeViscousUEnum;
     982              else if (strcmp(name,"SealevelchangeViscousN")==0) return SealevelchangeViscousNEnum;
     983              else if (strcmp(name,"SealevelchangeViscousE")==0) return SealevelchangeViscousEEnum;
    984984              else if (strcmp(name,"StrainRateeffective")==0) return StrainRateeffectiveEnum;
    985985              else if (strcmp(name,"StrainRateparallel")==0) return StrainRateparallelEnum;
  • issm/trunk-jpl/src/m/classes/solidearthsettings.m

    r26272 r26296  
    99                abstol                 = 0;
    1010                maxiter                = 0;
    11                 rigid                  = 0;
    12                 elastic                = 0;
    13                 viscous                = 0;
    14                 rotation               = 0;
     11                selfattraction         = 1;
     12                elastic                = 1;
     13                viscous                = 1;
     14                rotation               = 1;
     15                grdocean               = 1;
    1516                ocean_area_scaling     = 0;
    1617                runfrequency           = 1; %how many time steps we skip before we run grd_core
    17                 computesealevelchange  = 1; %will sea-level be coputed?
     18                sealevelloading        = 1; %will sea-level loads be computed?
    1819                isgrd                  = 0; %will GRD patterns be computed?
    1920                compute_bp_grd         = 0; %will GRD patterns for bottom pressures be computed?
     
    2122                timeacc                = 0; %time step accurary required to compute Green tables
    2223                horiz                  = 0; %compute horizontal deformation
    23                 grdmodel               = 0; %grd model (0 by default, 1 for elastic, 2 for Ivins)
     24                grdmodel               = 0; %grd model (0 by default, 1 for (visco)-elastic, 2 for Ivins)
    2425                cross_section_shape    = 0; %cross section only used when grd model is Ivins
    2526        end
     27        methods (Static)
     28                function self = loadobj(self) % {{{
     29                        % This function is directly called by matlab when a model object is
     30                        % loaded. If the input is a struct it is an old version of this class and
     31                        % old fields must be recovered (make sure they are in the deprecated
     32                        % model properties)
     33
     34                        if isstruct(self)
     35                                % 2021, Jun 4
     36                                if isfield(self,'rigid')
     37                                        self.selfattraction = self.rigid;
     38                                end
     39                                if isfield(self,'computesealevelchange')
     40                                        self.sealevelloading = self.computesealevelchange;
     41                                end
     42                                self = structtoobj(solidearthsettings(),self);
     43
     44                        end
     45                end% }}}
     46        end
    2647        methods
     48
    2749                function self = solidearthsettings(varargin) % {{{
    2850                        switch nargin
     
    4365
    4466                %computational flags:
    45                 self.rigid=1;
     67                self.selfattraction=1;
    4668                self.elastic=1;
    4769                self.viscous=1;
    4870                self.rotation=1;
     71                self.grdocean=1;
    4972                self.ocean_area_scaling=0;
    5073                self.compute_bp_grd=0;
    5174                self.isgrd=0;
    52                 self.computesealevelchange=1;
     75                self.sealevelloading=1;
    5376
    5477                %numerical discretization accuracy
     
    83106                        md = checkfield(md,'fieldname','solidearth.settings.grdmodel','>=',0,'<=',2);
    84107                        md = checkfield(md,'fieldname','solidearth.settings.cross_section_shape','numel',[1],'values',[1,2]);
    85 
    86                         %checks on computational flags
    87                         if self.elastic==1 & self.rigid==0,
    88                                 error('solidearthsettings checkconsistency error message: need rigid on if elastic flag is set');
     108                        if self.elastic==1 & self.selfattraction==0,
     109                                error('solidearthsettings checkconsistency error message: need selfattraction on if elastic flag is set');
    89110                        end
    90111                        if self.viscous==1 & self.elastic==0,
     
    103124                                        end
    104125                                end
     126                                if self.sealevelloading==1 & self.grdocean==0
     127                                        error('solidearthsettings checkconsistency error message: need grdocean on if sealevelloading flag is set');
     128                                end
    105129                        end
    106130
     
    116140                        fielddisplay(self,'abstol','sea level change absolute convergence criterion, NaN: not applied');
    117141                        fielddisplay(self,'maxiter','maximum number of nonlinear iterations');
     142                        fielddisplay(self,'grdocean','does this planet have an ocean, if set to 1: global water mass is conserved in GRD module [default: 1]');
    118143                        fielddisplay(self,'ocean_area_scaling','correction for model representation of ocean area [default: No correction]');
    119                         fielddisplay(self,'computesealevelchange','compute sealevel change (default 1)');
     144                        fielddisplay(self,'sealevelloading','enables surface loading from sea-level change (default 1)');
    120145                        fielddisplay(self,'isgrd','compute GRD patterns (default 1)');
    121146                        fielddisplay(self,'compute_bp_grd','compute GRD patterns for bottom pressure loads (default 1)');
    122147                        fielddisplay(self,'runfrequency','how many time steps we skip before we run solidearthsettings solver during transient (default: 1)');
    123                         fielddisplay(self,'rigid','rigid earth graviational potential perturbation');
    124                         fielddisplay(self,'elastic','elastic earth graviational potential perturbation');
    125                         fielddisplay(self,'viscous','viscous earth graviational potential perturbation');
    126                         fielddisplay(self,'rotation','earth rotational potential perturbation');
     148                        fielddisplay(self,'selfattraction','enables surface mass load to perturb the gravity field');
     149                        fielddisplay(self,'elastic','enables elastic deformation from surface loading');
     150                        fielddisplay(self,'viscous','enables viscous deformation from surface loading');
     151                        fielddisplay(self,'rotation','enables polar motion to feedback on the GRD fields');
    127152                        fielddisplay(self,'degacc','accuracy (default .01 deg) for numerical discretization of the Green''s functions');
    128153                        fielddisplay(self,'timeacc','time accuracy (default 1 yr) for numerical discretization of the Green''s functions');
    129                         fielddisplay(self,'grdmodel','type of deformation model, 1 for elastic, 2 for visco-elastic from Ivins');
     154                        fielddisplay(self,'grdmodel','type of deformation model, 0 for no GRD, 1 for spherical GRD model (SESAW model), 2 for half-space planar GRD (visco-elastic model from Ivins)');
    130155                        fielddisplay(self,'cross_section_shape','1: square-edged (default). 2: elliptical. See iedge in GiaDeflectionCore');
    131156                end % }}}
     
    134159                        WriteData(fid,prefix,'object',self,'fieldname','abstol','name','md.solidearth.settings.abstol','format','Double');
    135160                        WriteData(fid,prefix,'object',self,'fieldname','maxiter','name','md.solidearth.settings.maxiter','format','Integer');
    136                         WriteData(fid,prefix,'object',self,'fieldname','rigid','name','md.solidearth.settings.rigid','format','Boolean');
     161                        WriteData(fid,prefix,'object',self,'fieldname','selfattraction','name','md.solidearth.settings.selfattraction','format','Boolean');
    137162                        WriteData(fid,prefix,'object',self,'fieldname','elastic','name','md.solidearth.settings.elastic','format','Boolean');
    138163                        WriteData(fid,prefix,'object',self,'fieldname','viscous','name','md.solidearth.settings.viscous','format','Boolean');
    139164                        WriteData(fid,prefix,'object',self,'fieldname','rotation','name','md.solidearth.settings.rotation','format','Boolean');
     165                        WriteData(fid,prefix,'object',self,'fieldname','grdocean','name','md.solidearth.settings.grdocean','format','Boolean');
    140166                        WriteData(fid,prefix,'object',self,'fieldname','ocean_area_scaling','name','md.solidearth.settings.ocean_area_scaling','format','Boolean');
    141167                        WriteData(fid,prefix,'object',self,'fieldname','runfrequency','name','md.solidearth.settings.runfrequency','format','Integer');
     
    143169                        WriteData(fid,prefix,'object',self,'fieldname','timeacc','name','md.solidearth.settings.timeacc','format','Double','scale',md.constants.yts);
    144170                        WriteData(fid,prefix,'object',self,'fieldname','horiz','name','md.solidearth.settings.horiz','format','Integer');
    145                         WriteData(fid,prefix,'object',self,'fieldname','computesealevelchange','name','md.solidearth.settings.computesealevelchange','format','Integer');
     171                        WriteData(fid,prefix,'object',self,'fieldname','sealevelloading','name','md.solidearth.settings.sealevelloading','format','Integer');
    146172                        WriteData(fid,prefix,'object',self,'fieldname','isgrd','name','md.solidearth.settings.isgrd','format','Integer');
    147173                        WriteData(fid,prefix,'object',self,'fieldname','compute_bp_grd','name','md.solidearth.settings.compute_bp_grd','format','Integer');
     
    154180                        writejsdouble(fid,[modelname '.solidearth.settings.reltol'],self.reltol);
    155181                        writejsdouble(fid,[modelname '.solidearth.settings.abstol'],self.abstol);
    156                         writejsdouble(fid,[modelname '.solidearth.settings.rigid'],self.rigid);
     182                        writejsdouble(fid,[modelname '.solidearth.settings.selfattraction'],self.selfattraction);
    157183                        writejsdouble(fid,[modelname '.solidearth.settings.elastic'],self.elastic);
    158184                        writejsdouble(fid,[modelname '.solidearth.settings.viscous'],self.viscous);
    159185                        writejsdouble(fid,[modelname '.solidearth.settings.rotation'],self.rotation);
     186                        writejsdouble(fid,[modelname '.solidearth.settings.grdocean'],self.rotation);
    160187                        writejsdouble(fid,[modelname '.solidearth.settings.ocean_area_scaling'],self.ocean_area_scaling);
    161188                        writejsdouble(fid,[modelname '.solidearth.settings.run_frequency'],self.run_frequency);
  • issm/trunk-jpl/test/NightlyRun/test2001.m

    r26165 r26296  
    1717md.initialization.sealevel=zeros(md.mesh.numberofvertices,1);
    1818md.solidearth.settings.cross_section_shape=1;    % for square-edged x-section
    19 md.solidearth.settings.computesealevelchange=0;  %do not compute sea level, only deformation
     19md.solidearth.settings.grdocean=0;  %do not compute sea level, only deformation
     20md.solidearth.settings.sealevelloading=0;  %do not compute sea level, only deformation
    2021md.solidearth.requested_outputs={'Sealevel','BedGRD'};
    2122
  • issm/trunk-jpl/test/NightlyRun/test2002.m

    r26268 r26296  
    33%mesh earth:
    44md=model;
    5 md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',500.); %700 km resolution mesh
     5load ../Data/SlcTestMesh.mat;
     6md.mesh=SlcMesh; %700 km resolution mesh
    67
    7 %Geometry for the bed, arbitrary thickness of 1000:
     8%Geometry for the bed, arbitrary thickness of 100:
    89md.geometry.bed=zeros(md.mesh.numberofvertices,1);
    910md.geometry.base=md.geometry.bed;
     
    7071md.solidearth.settings.reltol=NaN;
    7172md.solidearth.settings.abstol=1e-3;
    72 md.solidearth.settings.computesealevelchange=1;
     73md.solidearth.settings.sealevelloading=1;
    7374md.solidearth.settings.isgrd=1;
    7475md.solidearth.settings.ocean_area_scaling=0;
     
    8788
    8889%eustatic run:
    89 md.solidearth.settings.rigid=0;
     90md.solidearth.settings.selfattraction=0;
    9091md.solidearth.settings.elastic=0;
    9192md.solidearth.settings.rotation=0;
     
    9697Beustatic=md.results.TransientSolution.Bed;
    9798
    98 %eustatic + rigid run:
    99 md.solidearth.settings.rigid=1;
     99%eustatic + selfattraction run:
     100md.solidearth.settings.selfattraction=1;
    100101md.solidearth.settings.elastic=0;
    101102md.solidearth.settings.rotation=0;
    102103md.solidearth.settings.viscous=0;
    103104md=solve(md,'tr');
    104 Srigid=md.results.TransientSolution.Sealevel;
    105 Brigid=md.results.TransientSolution.Bed;
     105Sselfattraction=md.results.TransientSolution.Sealevel;
     106Bselfattraction=md.results.TransientSolution.Bed;
    106107
    107 %eustatic + rigid + elastic run:
    108 md.solidearth.settings.rigid=1;
     108%eustatic + selfattraction + elastic run:
     109md.solidearth.settings.selfattraction=1;
    109110md.solidearth.settings.elastic=1;
    110111md.solidearth.settings.rotation=0;
     
    114115Belastic=md.results.TransientSolution.Bed;
    115116
    116 %eustatic + rigid + elastic + rotation run:
    117 md.solidearth.settings.rigid=1;
     117%eustatic + selfattraction + elastic + rotation run:
     118md.solidearth.settings.selfattraction=1;
    118119md.solidearth.settings.elastic=1;
    119120md.solidearth.settings.rotation=1;
     
    124125
    125126%Fields and tolerances to track changes
    126 field_names={'Seustatic','Srigid','Selastic','Srotation','Beustatic','Brigid','Belastic','Brotation'};
     127field_names={'Seustatic','Sselfattraction','Selastic','Srotation','Beustatic','Bselfattraction','Belastic','Brotation'};
    127128field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,1e-13};
    128 field_values={Seustatic,Srigid,Selastic,Srotation,Beustatic,Brigid,Belastic,Brotation};
     129field_values={Seustatic,Sselfattraction,Selastic,Srotation,Beustatic,Bselfattraction,Belastic,Brotation};
  • issm/trunk-jpl/test/NightlyRun/test2003.m

    r26269 r26296  
    33%mesh earth:
    44md=model;
    5 md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',1000.); %1000 km resolution mesh
     5load ../Data/SlcTestMesh.mat;
     6md.mesh=SlcMesh; %700 km resolution mesh
    67
    78%Geometry for the bed, arbitrary thickness of 1000:
     
    6263md.solidearth.settings.reltol=NaN;
    6364md.solidearth.settings.abstol=1e-3;
    64 md.solidearth.settings.computesealevelchange=0;
     65md.solidearth.settings.sealevelloading=0;
     66md.solidearth.settings.grdocean=0;
    6567md.solidearth.settings.isgrd=1;
    6668md.solidearth.settings.ocean_area_scaling=0;
     
    6870md.solidearth.settings.horiz=1;
    6971md.solidearth.requested_outputs={'Sealevel','Bed', 'BedEast', 'BedNorth'};
    70 
    7172
    7273%Physics:
     
    8182md.timestepping.final_time=1;
    8283
    83 %eustatic + rigid + elastic run:
    84 md.solidearth.settings.rigid=1;
     84%eustatic + selfattraction + elastic run:
     85md.solidearth.settings.selfattraction=1;
    8586md.solidearth.settings.elastic=1;
    8687md.solidearth.settings.rotation=0;
     
    9495BNnoRotation=md.results.TransientSolution.BedNorth;
    9596
    96 %eustatic + rigid + elastic + rotation run:
    97 md.solidearth.settings.rigid=1;
     97%eustatic + selfattraction + elastic + rotation run:
     98md.solidearth.settings.selfattraction=1;
    9899md.solidearth.settings.elastic=1;
    99100md.solidearth.settings.rotation=1;
     
    108109
    109110%Fields and tolerances to track changes
    110 field_names     ={'noRotation','Rotation'};
     111field_names     ={'Sealevel', 'Uplift', 'NorthDisplacement', 'EastDisplacement'};
    111112field_tolerances={1e-13,1e-13,1e-13,1e-13};
    112113field_values={SRotation-SnoRotation,BURotation-BUnoRotation,BNRotation-BNnoRotation,BERotation-BEnoRotation};
  • issm/trunk-jpl/test/NightlyRun/test2004.m

    r26121 r26296  
    395395md.solidearth.settings.reltol=NaN;
    396396md.solidearth.settings.abstol=1e-3;
    397 md.solidearth.settings.computesealevelchange=1;
     397md.solidearth.settings.sealevelloading=1;
    398398md.solidearth.settings.isgrd=1;
    399399md.solidearth.settings.ocean_area_scaling=0;
     
    423423
    424424%eustatic run:
    425 md.solidearth.settings.rigid=0;
     425md.solidearth.settings.selfattraction=0;
    426426md.solidearth.settings.elastic=0;
    427427md.solidearth.settings.rotation=0;
     
    432432Seustatic=md.results.TransientSolution.Sealevel;
    433433
    434 %eustatic + rigid run:
    435 md.solidearth.settings.rigid=1;
     434%eustatic + selfattraction run:
     435md.solidearth.settings.selfattraction=1;
    436436md.solidearth.settings.elastic=0;
    437437md.solidearth.settings.rotation=0;
    438438md=solve(md,'Transient');
    439 Srigid=md.results.TransientSolution.Sealevel;
    440 
    441 %eustatic + rigid + elastic run:
    442 md.solidearth.settings.rigid=1;
     439Sselfattraction=md.results.TransientSolution.Sealevel;
     440
     441%eustatic + selfattraction + elastic run:
     442md.solidearth.settings.selfattraction=1;
    443443md.solidearth.settings.elastic=1;
    444444md.solidearth.settings.rotation=0;
     
    446446Selastic=md.results.TransientSolution.Sealevel;
    447447
    448 %eustatic + rigid + elastic + rotation run:
    449 md.solidearth.settings.rigid=1;
     448%eustatic + selfattraction + elastic + rotation run:
     449md.solidearth.settings.selfattraction=1;
    450450md.solidearth.settings.elastic=1;
    451451md.solidearth.settings.rotation=1;
     
    457457field_names     ={'Eustatic','Rigid','Elastic','Rotation'};
    458458field_tolerances={1e-13,1e-13,1e-13,1e-13};
    459 field_values={Seustatic,Srigid,Selastic,Srotation};
     459field_values={Seustatic,Sselfattraction,Selastic,Srotation};
  • issm/trunk-jpl/test/NightlyRun/test2005.m

    r26054 r26296  
    1 %Test Name: EarthSlc
     1%Test Name: Earthslc_time
    22
    33%mesh earth:
    44md=model;
    5 md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.); %700 km resolution mesh
     5load ../Data/SlcTestMesh.mat;
     6md.mesh=SlcMesh; %700 km resolution mesh
    67
    7 %parameterize solidearth solution:
     8%Geometry for the bed, arbitrary thickness of 100:
     9md.geometry.bed=zeros(md.mesh.numberofvertices,1);
     10md.geometry.base=md.geometry.bed;
     11md.geometry.thickness=100*ones(md.mesh.numberofvertices,1);
     12md.geometry.surface=md.geometry.bed+md.geometry.thickness;
     13
    814%solidearth loading:  {{{
    9 md.solidearth.surfaceload.icethicknesschange=zeros(md.mesh.numberofelements,1);
    10 md.solidearth.initialsealevel=zeros(md.mesh.numberofvertices,1);
    11 md.dsl.global_average_thermosteric_sea_level_change=[1;0];
    12 md.dsl.sea_surface_height_change_above_geoid=zeros(md.mesh.numberofvertices+1,1);
    13 md.dsl.sea_water_pressure_change_at_sea_floor=zeros(md.mesh.numberofvertices+1,1);
     15md.masstransport.spcthickness=[md.geometry.thickness;0];
     16md.smb.mass_balance=zeros(md.mesh.numberofvertices,1);
    1417%antarctica
    15 late=sum(md.mesh.lat(md.mesh.elements),2)/3;
    16 longe=sum(md.mesh.long(md.mesh.elements),2)/3;
     18xe=md.mesh.x(md.mesh.elements)*[1;1;1]/3;
     19ye=md.mesh.y(md.mesh.elements)*[1;1;1]/3;
     20ze=md.mesh.z(md.mesh.elements)*[1;1;1]/3;
     21re=sqrt(xe.^2+ye.^2+ze.^2);
     22
     23late=asind(ze./re);
     24longe=atan2d(ye,xe);
    1725pos=find(late < -80);
    18 md.solidearth.surfaceload.icethicknesschange(pos)=-100;
     26md.masstransport.spcthickness(md.mesh.elements(pos,:))= md.masstransport.spcthickness(md.mesh.elements(pos,:))-100;
     27posant=pos;
    1928%greenland
    20 pos=find(late>70 & late<80 & longe>-60 & longe<-30);
    21 md.solidearth.surfaceload.icethicknesschange(pos)=-100;
     29pos=find(late>60 & late<90 & longe>-75 & longe<-15);
     30md.masstransport.spcthickness(md.mesh.elements(pos,:))= md.masstransport.spcthickness(md.mesh.elements(pos,:))-100;
     31posgre=pos;
    2232
    2333%elastic loading from love numbers:
    24 md.solidearth.lovenumbers=lovenumbers('maxdeg',100);
     34md.solidearth.lovenumbers=lovenumbers('maxdeg',1000);
    2535
    2636%}}}
    2737%mask:  {{{
    2838mask=gmtmask(md.mesh.lat,md.mesh.long);
     39oceanmask=-ones(md.mesh.numberofvertices,1);
     40pos=find(mask==0); oceanmask(pos)=1;
     41
    2942icemask=ones(md.mesh.numberofvertices,1);
    30 pos=find(mask==0);
    31 icemask(pos)=-1;
    32 pos=find(sum(mask(md.mesh.elements),2)<3);
    33 icemask(md.mesh.elements(pos,:))=-1;
     43icemask(md.mesh.elements(posant))=-1;
     44icemask(md.mesh.elements(posgre))=-1;
     45
    3446md.mask.ice_levelset=icemask;
    35 md.mask.ocean_levelset=-icemask;
    36 
    37 %make sure that the elements that have loads are fully grounded:
    38 pos=find(md.solidearth.surfaceload.icethicknesschange);
    39 md.mask.ocean_levelset(md.mesh.elements(pos,:))=1;
    40 
    41 %make sure wherever there is an ice load, that the mask is set to ice:
    42 %pos=find(md.solidearth.surfaceload.icethicknesschange); % TODO: Do we need to do this twice?
    43 md.mask.ice_levelset(md.mesh.elements(pos,:))=-1;
     47md.mask.ocean_levelset=oceanmask;
    4448% }}}
    4549
    46 md.solidearth.settings.ocean_area_scaling=0;
     50%time stepping:
     51md.timestepping.start_time=0;
     52md.timestepping.time_step=1;
     53md.timestepping.final_time=10;
    4754
    48 %Geometry for the bed, arbitrary:
    49 md.geometry.bed=-ones(md.mesh.numberofvertices,1);
     55%masstransport:
     56md.basalforcings.groundedice_melting_rate=zeros(md.mesh.numberofvertices,1);
     57md.basalforcings.floatingice_melting_rate=zeros(md.mesh.numberofvertices,1);
     58md.initialization.vx=zeros(md.mesh.numberofvertices,1);
     59md.initialization.vy=zeros(md.mesh.numberofvertices,1);
     60md.initialization.sealevel=zeros(md.mesh.numberofvertices,1);
     61md.initialization.str=0;
    5062
    5163%Materials:
     
    5668
    5769%Solution parameters
     70md.cluster.np=3;
    5871md.solidearth.settings.reltol=NaN;
    5972md.solidearth.settings.abstol=1e-3;
    60 md.solidearth.settings.computesealevelchange=1;
     73md.solidearth.settings.sealevelloading=1;
     74md.solidearth.settings.isgrd=1;
     75md.solidearth.settings.ocean_area_scaling=0;
     76md.solidearth.settings.grdmodel=1;
    6177
    62 % max number of iteration reverted back to 10 (i.e., the original default value)
    63 md.solidearth.settings.maxiter=10;
    64 
    65 %eustatic + rigid + elastic + rotation run:
    66 md.solidearth.settings.rigid=1;
     78md.solidearth.settings.selfattraction=1;
    6779md.solidearth.settings.elastic=1;
    6880md.solidearth.settings.rotation=1;
     81md.solidearth.settings.viscous=0;
    6982
    70 %transient settings:
    71 md.timestepping.start_time=0;
    72 md.timestepping.final_time=10;
    73 md.timestepping.time_step=1;
    74 md.transient.isslc=1;
    75 md.transient.issmb=0;
    76 md.transient.ismasstransport=0;
     83%Physics:
     84md.transient.issmb=0;
    7785md.transient.isstressbalance=0;
    7886md.transient.isthermal=0;
    79 dh=md.solidearth.surfaceload.icethicknesschange;
    80 deltathickness=zeros(md.mesh.numberofelements+1,10);
    81 for i=1:10,
    82         deltathickness(1:end-1,i)=dh*i;
     87md.transient.ismasstransport=1;
     88md.transient.isslc=1;
     89md.solidearth.requested_outputs={'Sealevel'};
     90
     91dh=md.masstransport.spcthickness;
     92deltathickness=zeros(md.mesh.numberofvertices+1,10);
     93for i=0:10,
     94        deltathickness(1:end-1,i+1)=md.geometry.thickness+dh(1:end-1)*i;
    8395end
    84 deltathickness(end,:)=0:1:9;
    85 md.solidearth.surfaceload.icethicknesschange=deltathickness;
     96deltathickness(end,:)=0:1:10;
     97md.masstransport.spcthickness=deltathickness;
    8698%hack:
    8799md.geometry.surface=zeros(md.mesh.numberofvertices,1);
     
    89101md.geometry.base=-ones(md.mesh.numberofvertices,1);
    90102md.geometry.bed=md.geometry.base;
     103
    91104
    92105%run transient solution:
  • issm/trunk-jpl/test/NightlyRun/test2006.m

    r26054 r26296  
    33%mesh earth:
    44md=model;
    5 md.cluster=generic('name',oshostname(),'np',5);
    6 md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.); %700 km resolution mesh
    7 
    8 %parameterize solidearth solution:
     5load ../Data/SlcTestMesh.mat;
     6md.mesh=SlcMesh; %700 km resolution mesh
     7
     8%Geometry for the bed, arbitrary thickness of 100:
     9md.geometry.bed=zeros(md.mesh.numberofvertices,1);
     10md.geometry.base=md.geometry.bed;
     11md.geometry.thickness=100*ones(md.mesh.numberofvertices,1);
     12md.geometry.surface=md.geometry.bed+md.geometry.thickness;
     13
    914%solidearth loading:  {{{
    10 md.solidearth.surfaceload.icethicknesschange=zeros(md.mesh.numberofelements,1);
    11 md.solidearth.initialsealevel=zeros(md.mesh.numberofvertices,1);
    12 md.dsl.global_average_thermosteric_sea_level_change=[1;0];
    13 md.dsl.sea_surface_height_change_above_geoid=zeros(md.mesh.numberofvertices+1,1);
    14 md.dsl.sea_water_pressure_change_at_sea_floor=zeros(md.mesh.numberofvertices+1,1);
     15md.masstransport.spcthickness=[md.geometry.thickness;0];
     16md.smb.mass_balance=zeros(md.mesh.numberofvertices,1);
    1517%antarctica
    16 late=sum(md.mesh.lat(md.mesh.elements),2)/3;
    17 longe=sum(md.mesh.long(md.mesh.elements),2)/3;
     18xe=md.mesh.x(md.mesh.elements)*[1;1;1]/3;
     19ye=md.mesh.y(md.mesh.elements)*[1;1;1]/3;
     20ze=md.mesh.z(md.mesh.elements)*[1;1;1]/3;
     21re=sqrt(xe.^2+ye.^2+ze.^2);
     22
     23late=asind(ze./re);
     24longe=atan2d(ye,xe);
    1825pos=find(late < -80);
    19 md.solidearth.surfaceload.icethicknesschange(pos)=-100;
     26md.masstransport.spcthickness(md.mesh.elements(pos,:))= md.masstransport.spcthickness(md.mesh.elements(pos,:))-100;
     27posant=pos;
    2028%greenland
    21 pos=find(late>70 & late<80 & longe>-60 & longe<-30);
    22 md.solidearth.surfaceload.icethicknesschange(pos)=-100;
     29pos=find(late>60 & late<90 & longe>-75 & longe<-15);
     30md.masstransport.spcthickness(md.mesh.elements(pos,:))= md.masstransport.spcthickness(md.mesh.elements(pos,:))-100;
     31posgre=pos;
    2332
    2433%elastic loading from love numbers:
     
    2837%mask:  {{{
    2938mask=gmtmask(md.mesh.lat,md.mesh.long);
     39oceanmask=-ones(md.mesh.numberofvertices,1);
     40pos=find(mask==0); oceanmask(pos)=1;
     41
    3042icemask=ones(md.mesh.numberofvertices,1);
    31 pos=find(mask==0);
    32 icemask(pos)=-1;
    33 pos=find(sum(mask(md.mesh.elements),2)<3);
    34 icemask(md.mesh.elements(pos,:))=-1;
     43icemask(md.mesh.elements(posant))=-1;
     44icemask(md.mesh.elements(posgre))=-1;
     45
    3546md.mask.ice_levelset=icemask;
    36 md.mask.ocean_levelset=-icemask;
    37 
    38 %make sure that the elements that have loads are fully grounded:
    39 pos=find(md.solidearth.surfaceload.icethicknesschange);
    40 md.mask.ocean_levelset(md.mesh.elements(pos,:))=1;
    41 
    42 %make sure wherever there is an ice load, that the mask is set to ice:
    43 pos=find(md.solidearth.surfaceload.icethicknesschange);
    44 md.mask.ice_levelset(md.mesh.elements(pos,:))=-1;
     47md.mask.ocean_levelset=oceanmask;
    4548% }}}
    4649
    47 md.solidearth.settings.ocean_area_scaling=0;
    48 
    49 %Geometry for the bed, arbitrary:
    50 md.geometry.bed=-ones(md.mesh.numberofvertices,1);
     50%time stepping:
     51md.timestepping.start_time=0;
     52md.timestepping.time_step=1;
     53md.timestepping.final_time=10;
     54
     55%masstransport:
     56md.basalforcings.groundedice_melting_rate=zeros(md.mesh.numberofvertices,1);
     57md.basalforcings.floatingice_melting_rate=zeros(md.mesh.numberofvertices,1);
     58md.initialization.vx=zeros(md.mesh.numberofvertices,1);
     59md.initialization.vy=zeros(md.mesh.numberofvertices,1);
     60md.initialization.sealevel=zeros(md.mesh.numberofvertices,1);
     61md.initialization.str=0;
    5162
    5263%Materials:
     
    5768
    5869%Solution parameters
     70md.cluster.np=3;
    5971md.solidearth.settings.reltol=NaN;
    6072md.solidearth.settings.abstol=1e-3;
    61 md.solidearth.settings.computesealevelchange=1;
    62 
    63 % max number of iteration reverted back to 10 (i.e., the original default value)
    64 md.solidearth.settings.maxiter=10;
    65 
    66 %eustatic + rigid + elastic + rotation run:
    67 md.solidearth.settings.rigid=1;
     73md.solidearth.settings.sealevelloading=1;
     74md.solidearth.settings.isgrd=1;
     75md.solidearth.settings.ocean_area_scaling=0;
     76md.solidearth.settings.grdmodel=1;
     77
     78md.solidearth.settings.selfattraction=1;
    6879md.solidearth.settings.elastic=1;
    6980md.solidearth.settings.rotation=1;
    70 
    71 %transient settings:
    72 md.timestepping.start_time=0;
    73 md.timestepping.final_time=10;
    74 md.timestepping.time_step=1;
    75 md.transient.isslc=1;
    76 md.transient.issmb=0;
    77 md.transient.ismasstransport=0;
     81md.solidearth.settings.viscous=0;
     82
     83%Physics:
     84md.transient.issmb=0;
    7885md.transient.isstressbalance=0;
    7986md.transient.isthermal=0;
    80 dh=md.solidearth.surfaceload.icethicknesschange;
    81 deltathickness=zeros(md.mesh.numberofelements+1,10);
    82 for i=1:10,
    83         deltathickness(1:end-1,i)=dh*i;
     87md.transient.ismasstransport=1;
     88md.transient.isslc=1;
     89md.solidearth.requested_outputs={'Sealevel'};
     90
     91dh=md.masstransport.spcthickness;
     92deltathickness=zeros(md.mesh.numberofvertices+1,10);
     93for i=0:10,
     94        deltathickness(1:end-1,i+1)=md.geometry.thickness+dh(1:end-1)*i;
    8495end
    85 deltathickness(end,:)=0:1:9;
    86 md.solidearth.surfaceload.icethicknesschange=deltathickness;
     96deltathickness(end,:)=0:1:10;
     97md.masstransport.spcthickness=deltathickness;
    8798
    8899%hack:
  • issm/trunk-jpl/test/NightlyRun/test2007.m

    r26274 r26296  
    1 %Test Name: offline solid earth solution
     1%Test Name: External_OfflineSolidearthSolution
    22
    33%mesh earth:
    44md=model;
    5 md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.); %700 km resolution mesh
     5load ../Data/SlcTestMesh.mat;
     6md.mesh=SlcMesh; %700 km resolution mesh
    67
    7 %Geometry for the bed, arbitrary thickness of 1000:
     8%Geometry for the bed, arbitrary
    89md.geometry.bed=-ones(md.mesh.numberofvertices,1);
    910md.geometry.base=md.geometry.bed;
     
    4647%Solution parameters
    4748md.cluster.np=3;
     49md.solidearth.settings.isgrd=0;
    4850md.solidearth.settings.horiz=1;
    4951
  • issm/trunk-jpl/test/NightlyRun/test2008.m

    r26274 r26296  
    1 %Test Name: External:AdditionalSolidearthSolution
     1%Test Name: External_AdditionalSolidearthSolution
    22
    33%mesh earth:
    44md=model;
    5 md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.); %700 km resolution mesh
     5load ../Data/SlcTestMesh.mat;
     6md.mesh=SlcMesh; %700 km resolution mesh
    67
    78%Geometry for the bed, arbitrary thickness of 100:
     
    7071md.solidearth.settings.reltol=NaN;
    7172md.solidearth.settings.abstol=1e-3;
    72 md.solidearth.settings.computesealevelchange=1;
     73md.solidearth.settings.sealevelloading=1;
    7374md.solidearth.settings.isgrd=1;
    7475md.solidearth.settings.ocean_area_scaling=0;
     
    8687md.solidearth.settings.maxiter=10;
    8788
    88 %eustatic + rigid + elastic:
    89 md.solidearth.settings.rigid=1;
     89%eustatic + selfattraction + elastic:
     90md.solidearth.settings.selfattraction=1;
    9091md.solidearth.settings.elastic=1;
    9192md.solidearth.settings.rotation=0;
  • issm/trunk-jpl/test/NightlyRun/test2010.m

    r25956 r26296  
    33%mesh earth:
    44md=model;
    5 rad_e = 6.371012*10^3; % mean radius of Earth, km
    6 md.mesh=gmshplanet('radius',rad_e,'resolution',1000.0);  % km resolution
     5load ../Data/SlcTestMesh.mat;
     6md.mesh=SlcMesh; %700 km resolution mesh
     7
     8%Geometry for the bed, arbitrary thickness of 1000:
     9md.geometry.bed=-ones(md.mesh.numberofvertices,1);
     10md.geometry.base=md.geometry.bed;
     11md.geometry.thickness=100*ones(md.mesh.numberofvertices,1);
     12md.geometry.surface=md.geometry.bed+md.geometry.thickness;
     13
    714
    815%parameterize slc solution:
    9 %slc loading:  {{{
    10 late=sum(md.mesh.lat(md.mesh.elements),2)/3;
    11 longe=sum(md.mesh.long(md.mesh.elements),2)/3;
     16%solidearth loading:  {{{
     17md.masstransport.spcthickness=[md.geometry.thickness;0];
     18md.smb.mass_balance=zeros(md.mesh.numberofvertices,1);
    1219
    13 md.solidearth.surfaceload.icethicknesschange=zeros(md.mesh.numberofelements,1);
    14 pos=find(late <-75 & longe >0);
    15 md.solidearth.surfaceload.icethicknesschange(pos(6:7))=-1;
    1620
    17 md.solidearth.initialsealevel=zeros(md.mesh.numberofvertices,1);
    18 md.dsl.global_average_thermosteric_sea_level_change=[0;0];
    19 md.dsl.sea_surface_height_change_above_geoid=zeros(md.mesh.numberofvertices+1,1);
    20 md.dsl.sea_water_pressure_change_at_sea_floor=zeros(md.mesh.numberofvertices+1,1);
     21xe=md.mesh.x(md.mesh.elements)*[1;1;1]/3;
     22ye=md.mesh.y(md.mesh.elements)*[1;1;1]/3;
     23ze=md.mesh.z(md.mesh.elements)*[1;1;1]/3;
     24re=sqrt(xe.^2+ye.^2+ze.^2);
    2125
    22 md.solidearth.settings.ocean_area_scaling = 1;
     26late=asind(ze./re);
     27longe=atan2d(ye,xe);
     28%greenland
     29pos=find(late>60 & late<90 & longe>-75 & longe<-15);
     30md.masstransport.spcthickness(md.mesh.elements(pos,:))= md.masstransport.spcthickness(md.mesh.elements(pos,:))-100;
     31posice=pos;
    2332
    2433%elastic loading from love numbers:
    25 md.solidearth.lovenumbers=lovenumbers('maxdeg',1000);
     34md.solidearth.lovenumbers=lovenumbers('maxdeg',100);
    2635
    2736%}}}
     
    2938mask=gmtmask(md.mesh.lat,md.mesh.long);
    3039icemask=ones(md.mesh.numberofvertices,1);
    31 pos=find(mask==0);
    32 icemask(pos)=-1;
    33 pos=find(sum(mask(md.mesh.elements),2)<3);
    34 icemask(md.mesh.elements(pos,:))=-1;
     40icemask(md.mesh.elements(posice,:))=-0.5;
     41
     42oceanmask=-ones(md.mesh.numberofvertices,1);
     43pos=find(mask==0); oceanmask(pos)=1; icemask(~pos)=1;
     44
    3545md.mask.ice_levelset=icemask;
    36 md.mask.ocean_levelset=-icemask;
     46md.mask.ocean_levelset=oceanmask;
    3747
    38 %make sure that the elements that have loads are fully grounded:
    39 pos=find(md.solidearth.surfaceload.icethicknesschange);
    40 md.mask.ocean_levelset(md.mesh.elements(pos,:))=1;
     48% use model representation of ocen area (not the true area)
     49md.solidearth.settings.ocean_area_scaling = 0;
    4150
    42 %make sure wherever there is an ice load, that the mask is set to ice:
    43 md.mask.ice_levelset=ones(md.mesh.numberofvertices,1);
    44 pos=find(md.solidearth.surfaceload.icethicknesschange);
    45 md.mask.ice_levelset(md.mesh.elements(pos,:))=-1;
    46 % }}}
     51%materials
     52md.initialization.temperature=273.25*ones(md.mesh.numberofvertices,1);
     53md.initialization.sealevel=zeros(md.mesh.numberofvertices,1);
     54md.initialization.str=0;
    4755
    48 %geometry {{{
    49 di=md.materials.rho_ice/md.materials.rho_water;
    50 md.geometry.thickness=ones(md.mesh.numberofvertices,1);
    51 md.geometry.surface=(1-di)*zeros(md.mesh.numberofvertices,1);
    52 md.geometry.base=md.geometry.surface-md.geometry.thickness;
    53 md.geometry.bed=md.geometry.base;
    54 % }}}
    55 %materials {{{
    56 md.initialization.temperature=273.25*ones(md.mesh.numberofvertices,1);
    57 md.materials.rheology_B=paterson(md.initialization.temperature);
    58 md.materials.rheology_n=3*ones(md.mesh.numberofelements,1);
    59 % }}}
    60 %Miscellaneous {{{
     56md.basalforcings.groundedice_melting_rate=zeros(md.mesh.numberofvertices,1);
     57md.basalforcings.floatingice_melting_rate=zeros(md.mesh.numberofvertices,1);
     58md.initialization.vx=zeros(md.mesh.numberofvertices,1);
     59md.initialization.vy=zeros(md.mesh.numberofvertices,1);
     60
     61%Miscellaneous
    6162md.miscellaneous.name='test2010';
    62 % }}}
    63 %Solution parameters {{{
     63
     64%Solution parameters
    6465md.solidearth.settings.reltol=NaN;
    6566md.solidearth.settings.abstol=1e-3;
    66 md.solidearth.settings.computesealevelchange=1;
    67 % }}}
     67md.solidearth.settings.sealevelloading=0;
     68md.solidearth.settings.grdocean=1;
     69md.solidearth.settings.isgrd=1;
     70md.solidearth.settings.ocean_area_scaling=0;
     71md.solidearth.settings.grdmodel=1;
     72md.solidearth.settings.horiz=1;
     73md.solidearth.requested_outputs={'Sealevel','SealevelBarystaticIceArea','SealevelBarystaticIceLoad','SealevelBarystaticIceMask','SealevelBarystaticIceLatbar' 'SealevelBarystaticIceLongbar'};
    6874
    69 %eustatic + rigid + elastic run:
    70 md.solidearth.settings.rigid=1;
     75%Physics:
     76md.transient.issmb=0;
     77md.transient.isstressbalance=0;
     78md.transient.isthermal=0;
     79md.transient.ismasstransport=1;
     80md.transient.isslc=1;
     81 
     82md.timestepping.start_time=0;
     83md.timestepping.time_step=1;
     84md.timestepping.final_time=1;
     85
     86%eustatic + selfattraction + elastic + rotation run:
     87md.solidearth.settings.selfattraction=1;
    7188md.solidearth.settings.elastic=1;
    7289md.solidearth.settings.rotation=1;
     90md.solidearth.settings.viscous=0;
    7391md.cluster=generic('name',oshostname(),'np',3);
     92%md.verbose=verbose('111111111');
     93md=solve(md,'Transient');
    7494
     95moi_p=md.solidearth.rotational.polarmoi;
     96moi_e=md.solidearth.rotational.equatorialmoi;
     97tide_love_k2=md.solidearth.lovenumbers.tk(3);
     98load_love_k2=md.solidearth.lovenumbers.k(3);
     99tide_love_k2secular=md.solidearth.lovenumbers.tk2secular;
    75100% uncomment following 2 lines for
    76 md=solve(md,'Sealevelchange');
    77 eus=md.results.SealevelchangeSolution.Bslc;
    78 slc=md.results.SealevelchangeSolution.Sealevel;
    79 moixz=md.results.SealevelchangeSolution.SealevelInertiaTensorXZ;
    80 moiyz=md.results.SealevelchangeSolution.SealevelInertiaTensorYZ;
    81 moizz=md.results.SealevelchangeSolution.SealevelInertiaTensorZZ;
     101eus=md.results.TransientSolution.Bslc;
     102slc=md.results.TransientSolution.Sealevel;
     103moixz=md.results.TransientSolution.SealevelInertiaTensorXZ / (1/(1-tide_love_k2/tide_love_k2secular) * (1+load_love_k2)/(moi_p-moi_e) );
     104moiyz=md.results.TransientSolution.SealevelInertiaTensorYZ / (1/(1-tide_love_k2/tide_love_k2secular) * (1+load_love_k2)/(moi_p-moi_e) );
     105moizz=md.results.TransientSolution.SealevelInertiaTensorZZ / ( -(1+load_love_k2)/moi_p);
     106
     107areaice=md.results.TransientSolution.SealevelBarystaticIceArea;
     108loadice=md.results.TransientSolution.SealevelBarystaticIceLoad;
    82109
    83110% analytical moi => just checking FOR ICE only!!! {{{
    84111% ...have to mute ** slc induced MOI in Tria.cpp ** prior to the comparison
    85 %rad_e = rad_e*1e3; % now in meters
    86 %areas=GetAreasSphericalTria(md.mesh.elements,md.mesh.lat,md.mesh.long,rad_e);
    87 %lat=late*pi/180; lon=longe*pi/180;
    88 %moi_xz = sum(-md.materials.rho_freshwater.*md.solidearth.surfaceload.icethicknesschange.*areas.*rad_e^2.*sin(lat).*cos(lat).*cos(lon));
    89 %moi_yz = sum(-md.materials.rho_freshwater.*md.solidearth.surfaceload.icethicknesschange.*areas.*rad_e^2.*sin(lat).*cos(lat).*sin(lon));
     112rad_e = md.solidearth.planetradius;
     113
     114lat=md.results.TransientSolution.SealevelBarystaticIceLatbar*pi/180;
     115lon=md.results.TransientSolution.SealevelBarystaticIceLongbar*pi/180;
     116moi_xz = sum(-loadice.*areaice.*rad_e^2.*sin(lat).*cos(lat).*cos(lon));
     117moi_yz = sum(-loadice.*areaice.*rad_e^2.*sin(lat).*cos(lat).*sin(lon));
     118moi_zz = sum(-loadice.*areaice.*rad_e^2.*(1.0-sin(lat).^2));
     119theoretical_value_check=[moixz/moi_xz moiyz/moi_yz moizz/moizz]
    90120% }}}
    91121
    92122%Fields and tolerances to track changes
    93123field_names     ={'eus','slc','moixz','moiyz','moizz'};
    94 field_tolerances={1e-13,1e-13,1e-13,1e-13,1e-13};
     124field_tolerances={1e-13,1e-13,1e-13,1e-13};
    95125field_values={eus,slc,moixz,moiyz,moizz};
    96126
  • issm/trunk-jpl/test/NightlyRun/test2011.m

    r26222 r26296  
    1 %Test Name: EarthSlc
     1%Test Name: SlcBarystatic
    22
    33%mesh earth:
    44md=model;
    5 md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',500.); %700 km resolution mesh
     5load ../Data/SlcTestMesh.mat;
     6md.mesh=SlcMesh; %700 km resolution mesh
    67
    78%Geometry for the bed, arbitrary thickness of 1000:
     
    7071
    7172%Miscellaneous
    72 md.miscellaneous.name='test2002';
     73md.miscellaneous.name='test2011';
    7374
    7475%Solution parameters
     
    7677md.solidearth.settings.reltol=NaN;
    7778md.solidearth.settings.abstol=1e-3;
    78 md.solidearth.settings.computesealevelchange=1;
     79md.solidearth.settings.sealevelloading=1;
    7980md.solidearth.settings.isgrd=1;
    8081md.solidearth.settings.ocean_area_scaling=0;
     
    9495
    9596%eustatic + rigid + elastic + rotation run:
    96 md.solidearth.settings.rigid=1;
     97md.solidearth.settings.selfattraction=1;
    9798md.solidearth.settings.elastic=1;
    98 md.solidearth.settings.rotation=1;
     99md.solidearth.settings.rotation=0;
     100md.solidearth.settings.viscous=0;
    99101md=solve(md,'tr');
    100102
     
    106108weights=md.results.TransientSolution(1).SealevelBarystaticIceWeights;
    107109dH=md.results.TransientSolution(1).DeltaIceThickness(md.mesh.elements);
    108 dHavg=sum(dH.*weights);
     110dHavg=sum(dH.*weights,2);
    109111oceanarea=sum(md.results.TransientSolution(1).SealevelBarystaticOceanArea);
    110112bslc2=-sum(dHavg.*area)*md.materials.rho_ice/md.materials.rho_water/oceanarea;
     
    113115field_names={'BarystaticIce','BarystaticIce2','BarystaticIceDiff'};
    114116field_tolerances={1e-13,1e-13,1e-13};
    115 field_values={bslc,bslc2,bslc2-bslc2};
     117field_values={bslc,bslc2,bslc2-bslc};
  • issm/trunk-jpl/test/NightlyRun/test2090.m

    r26284 r26296  
    33%mesh earth:
    44md=model;
    5 md.mesh=gmshplanet('radius',6.371012*10^3,'resolution',700.); %700 km resolution mesh
     5load ../Data/SlcTestMesh.mat;
     6md.mesh=SlcMesh; %700 km resolution mesh
    67
    78%Geometry for the bed, arbitrary thickness of 1000:
     
    7374time1=md.timestepping.start_time:md.timestepping.time_step:md.timestepping.final_time;
    7475md.masstransport.spcthickness=repmat(md.masstransport.spcthickness, [1 length(time1)]);
    75 md.masstransport.spcthickness(1:end-1,2:end)=0;
     76md.masstransport.spcthickness(1:end-1,3:end)=0;
    7677md.masstransport.spcthickness(end,:)=time1;
    7778
     
    9293
    9394%Solution parameters
    94 md.cluster.np=1;
     95md.cluster.np=3;
    9596md.solidearth.settings.reltol=NaN;
    9697md.solidearth.settings.abstol=1e-3;
    97 md.solidearth.settings.computesealevelchange=1;
     98md.solidearth.settings.sealevelloading=1;
    9899md.solidearth.settings.isgrd=1;
    99100md.solidearth.settings.ocean_area_scaling=0;
    100101md.solidearth.settings.grdmodel=1;
    101102md.solidearth.settings.timeacc=md.timestepping.time_step;
    102 md.solidearth.settings.degacc=.01;
     103md.solidearth.settings.degacc=.1;
    103104
    104105%Physics:
     
    113114md.solidearth.settings.maxiter=10;
    114115
    115 %eustatic + rigid + elastic + rotation run:
    116 md.solidearth.settings.rigid=1;
     116%eustatic + selfattraction + elastic + rotation run:
     117md.solidearth.settings.selfattraction=1;
    117118md.solidearth.settings.elastic=1;
    118119md.solidearth.settings.viscous=1;
     
    127128end
    128129
     130hold on
     131plot(md.timestepping.start_time:md.timestepping.time_step:(md.timestepping.final_time-md.timestepping.time_step), [B(916,:)]);
     132
    129133%Fields and tolerances to track changes
    130134field_names={'Sealevel','Bed'};
Note: See TracChangeset for help on using the changeset viewer.