Changeset 24916


Ignore:
Timestamp:
05/28/20 23:43:54 (5 years ago)
Author:
Eric.Larour
Message:

CHG: speeding up by not recomputing areas all the time.

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

Legend:

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

    r24915 r24916  
    46844684#endif
    46854685#ifdef _HAVE_SEALEVELRISE_
    4686 void FemModel::SealevelriseEustatic(Vector<IssmDouble>* pRSLgi, IssmDouble* peustatic, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius,int loop) { /*{{{*/
     4686void FemModel::SealevelriseEustatic(Vector<IssmDouble>* pRSLgi, IssmDouble* peartharea, IssmDouble* poceanarea, IssmDouble* peustatic, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius,int loop) { /*{{{*/
    46874687
    46884688        /*serialized vectors:*/
     
    47064706        /*First, figure out the area of the ocean, which is needed to compute the eustatic component: */
    47074707        for(int i=0;i<elements->Size();i++){
     4708                IssmDouble area;
    47084709                Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
    4709                 oceanarea_cpu += element->OceanArea();
    4710                 eartharea_cpu += element->GetAreaSpherical();
     4710                area=element->GetAreaSpherical();
     4711                eartharea_cpu += area;
     4712                if (element->IsOceanInElement()) oceanarea_cpu += area;
    47114713        }
    47124714        ISSM_MPI_Reduce (&oceanarea_cpu,&oceanarea,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
     
    47374739
    47384740        /*Assign output pointers:*/
     4741        *peartharea=eartharea;
     4742        *poceanarea=oceanarea;
    47394743        *peustatic=eustatic;
    47404744
    47414745}
    47424746/*}}}*/
    4743 void FemModel::SealevelriseNonEustatic(Vector<IssmDouble>* pRSLgo, Vector<IssmDouble>* pRSLg_old, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius, bool verboseconvolution,int loop){/*{{{*/
     4747void FemModel::SealevelriseNonEustatic(Vector<IssmDouble>* pRSLgo, Vector<IssmDouble>* pRSLg_old, IssmDouble eartharea,IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius, bool verboseconvolution,int loop){/*{{{*/
    47444748
    47454749        /*serialized vectors:*/
    47464750        IssmDouble* RSLg_old=NULL;
    4747 
    4748         IssmDouble  eartharea=0;
    4749         IssmDouble  eartharea_cpu=0;
    47504751
    47514752        IssmDouble* RSLgo  = NULL;
     
    47624763        RSLg_old=pRSLg_old->ToMPISerial();
    47634764
    4764         /*First, figure out the area of the ocean, which is needed to compute the eustatic component: */
    4765         for(int i=0;i<elements->Size();i++){
    4766                 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
    4767                 eartharea_cpu += element->GetAreaSpherical();
    4768         }
    4769 
    4770         ISSM_MPI_Reduce (&eartharea_cpu,&eartharea,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
    4771         ISSM_MPI_Bcast(&eartharea,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
    4772 
    47734765        /*Call the sea level rise core: */
    47744766        for(int i=0;i<elements->Size();i++){
     
    47864778}
    47874779/*}}}*/
    4788 void FemModel::SealevelriseRotationalFeedback(Vector<IssmDouble>* pRSLgo_rot, Vector<IssmDouble>* pRSLg_old, IssmDouble* pIxz, IssmDouble* pIyz, IssmDouble* pIzz, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius){/*{{{*/
     4780void FemModel::SealevelriseRotationalFeedback(Vector<IssmDouble>* pRSLgo_rot, Vector<IssmDouble>* pRSLg_old, IssmDouble* pIxz, IssmDouble* pIyz, IssmDouble* pIzz, IssmDouble eartharea, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius){/*{{{*/
    47894781
    47904782        /*serialized vectors:*/
    47914783        IssmDouble* RSLg_old=NULL;
    4792         IssmDouble  eartharea=0;
    4793         IssmDouble  eartharea_cpu=0;
    47944784        IssmDouble      tide_love_h, tide_love_k, fluid_love, moi_e, moi_p, omega, g;
    47954785        IssmDouble      load_love_k2 = -0.30922675; //degree 2 load Love number
     
    47994789        /*Serialize vectors from previous iteration:*/
    48004790        RSLg_old=pRSLg_old->ToMPISerial();
    4801 
    4802         /*First, figure out the area of the ocean, which is needed to compute the eustatic component: */
    4803         for(int i=0;i<elements->Size();i++){
    4804                 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
    4805                 eartharea_cpu += element->GetAreaSpherical();
    4806         }
    4807         ISSM_MPI_Reduce (&eartharea_cpu,&eartharea,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
    4808         ISSM_MPI_Bcast(&eartharea,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
    48094791
    48104792        IssmDouble moi_list[3]={0,0,0};
     
    48724854}
    48734855/*}}}*/
    4874 void FemModel::SealevelriseElastic(Vector<IssmDouble>* pUp, Vector<IssmDouble>* pNorth, Vector<IssmDouble>* pEast, Vector<IssmDouble>* pRSLg, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius, IssmDouble* xx, IssmDouble* yy, IssmDouble* zz,int loop,int horiz){/*{{{*/
     4856void FemModel::SealevelriseElastic(Vector<IssmDouble>* pUp, Vector<IssmDouble>* pNorth, Vector<IssmDouble>* pEast, Vector<IssmDouble>* pRSLg, IssmDouble eartharea, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius, IssmDouble* xx, IssmDouble* yy, IssmDouble* zz,int loop,int horiz){/*{{{*/
    48754857
    48764858        /*serialized vectors:*/
    48774859        IssmDouble* RSLg=NULL;
    4878 
    4879         IssmDouble  eartharea=0;
    4880         IssmDouble  eartharea_cpu=0;
    48814860
    48824861        IssmDouble* Up  = NULL;
     
    48984877        indices=xNew<int>(gsize); for (int i=0;i<gsize;i++)indices[i]=i;
    48994878
    4900         /*First, figure out the area of the ocean, which is needed to compute the eustatic component: */
    4901         for(int i=0;i<elements->Size();i++){
    4902                 Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
    4903                 eartharea_cpu += element->GetAreaSpherical();
    4904         }
    4905         ISSM_MPI_Reduce (&eartharea_cpu,&eartharea,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
    4906         ISSM_MPI_Bcast(&eartharea,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
    4907 
    49084879        /*Call the sea level rise core: */
    49094880        for(int i=0;i<elements->Size();i++){
     
    49294900}
    49304901/*}}}*/
    4931 IssmDouble FemModel::SealevelriseOceanAverage(Vector<IssmDouble>* RSLg) { /*{{{*/
     4902IssmDouble FemModel::SealevelriseOceanAverage(Vector<IssmDouble>* RSLg,IssmDouble oceanarea) { /*{{{*/
    49324903
    49334904        IssmDouble* RSLg_serial=NULL;
    49344905        IssmDouble  oceanvalue,oceanvalue_cpu;
    4935         IssmDouble  oceanarea,oceanarea_cpu;
    49364906
    49374907        /*Serialize vectors from previous iteration:*/
     
    49404910        /*Initialize:*/
    49414911        oceanvalue_cpu=0;
    4942         oceanarea_cpu=0;
    49434912
    49444913        /*Go through elements, and add contribution from each element and divide by overall ocean area:*/
    49454914        for(int i=0;i<elements->Size();i++){
    49464915                Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
    4947                 oceanarea_cpu += element->OceanArea();
    49484916                oceanvalue_cpu += element->OceanAverage(RSLg_serial);
    49494917        }
    4950         ISSM_MPI_Reduce (&oceanarea_cpu,&oceanarea,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
    4951         ISSM_MPI_Bcast(&oceanarea,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
    4952 
    4953         //_printf0_("Ocean area: " << oceanarea << "\n");
    4954 
     4918       
    49554919        ISSM_MPI_Reduce (&oceanvalue_cpu,&oceanvalue,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
    49564920        ISSM_MPI_Bcast(&oceanvalue,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
  • issm/trunk-jpl/src/c/classes/FemModel.h

    r24861 r24916  
    162162                #endif
    163163                #ifdef _HAVE_SEALEVELRISE_
    164                 void SealevelriseEustatic(Vector<IssmDouble>* pSgi, IssmDouble* peustatic, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius,int loop);
    165                 void SealevelriseNonEustatic(Vector<IssmDouble>* pSgo, Vector<IssmDouble>* pSg_old, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius,bool verboseconvolution,int loop);
    166                 void SealevelriseRotationalFeedback(Vector<IssmDouble>* pRSLgo_rot, Vector<IssmDouble>* pRSLg_old, IssmDouble* pIxz, IssmDouble* pIyz, IssmDouble* pIzz, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius);
    167                 void SealevelriseElastic(Vector<IssmDouble>* pUp, Vector<IssmDouble>* pNorth, Vector<IssmDouble>* pEast, Vector<IssmDouble>* pSg_old, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius, IssmDouble* xx, IssmDouble* yy, IssmDouble* zz,int loop,int horiz);
    168                 IssmDouble SealevelriseOceanAverage(Vector<IssmDouble>* Sg);
     164                void SealevelriseEustatic(Vector<IssmDouble>* pSgi, IssmDouble* peartharea, IssmDouble* poceanarea, IssmDouble* peustatic, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius,int loop);
     165                void SealevelriseNonEustatic(Vector<IssmDouble>* pSgo, Vector<IssmDouble>* pSg_old, IssmDouble eartharea, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius,bool verboseconvolution,int loop);
     166                void SealevelriseRotationalFeedback(Vector<IssmDouble>* pRSLgo_rot, Vector<IssmDouble>* pRSLg_old, IssmDouble* pIxz, IssmDouble* pIyz, IssmDouble* pIzz, IssmDouble eartharea,IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius);
     167                void SealevelriseElastic(Vector<IssmDouble>* pUp, Vector<IssmDouble>* pNorth, Vector<IssmDouble>* pEast, Vector<IssmDouble>* pSg_old, IssmDouble eartharea,IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius, IssmDouble* xx, IssmDouble* yy, IssmDouble* zz,int loop,int horiz);
     168                IssmDouble SealevelriseOceanAverage(Vector<IssmDouble>* Sg,IssmDouble oceanarea);
    169169                #endif
    170170                void HydrologyEPLupdateDomainx(IssmDouble* pEplcount);
  • issm/trunk-jpl/src/c/cores/cores.h

    r24469 r24916  
    5555void geodetic_core(FemModel* femmodel);
    5656void steric_core(FemModel* femmodel);
    57 Vector<IssmDouble>* sealevelrise_core_eustatic(FemModel* femmodel);
    58 Vector<IssmDouble>* sealevelrise_core_noneustatic(FemModel* femmodel,Vector<IssmDouble>* RSLg_eustatic);
    59 void sealevelrise_core_elastic(Vector<IssmDouble>** pU_radial, Vector<IssmDouble>** pU_north,Vector<IssmDouble>** pU_east,FemModel* femmodel,Vector<IssmDouble>* RSLg);
     57Vector<IssmDouble>* sealevelrise_core_eustatic(FemModel* femmodel,IssmDouble* peartharea,IssmDouble* poceanarea);
     58Vector<IssmDouble>* sealevelrise_core_noneustatic(FemModel* femmodel,Vector<IssmDouble>* RSLg_eustatic,IssmDouble eartharea,IssmDouble oceanarea);
     59void sealevelrise_core_elastic(Vector<IssmDouble>** pU_radial, Vector<IssmDouble>** pU_north,Vector<IssmDouble>** pU_east,FemModel* femmodel,Vector<IssmDouble>* RSLg,IssmDouble eartharea);
    6060void sealevelrise_core_viscous(Vector<IssmDouble>** pU_gia,Vector<IssmDouble>** pN_gia,FemModel*  femmodel,Vector<IssmDouble>* RSLg);
    6161void sealevelrise_diagnostics(FemModel* femmodel,Vector<IssmDouble>* RSLg);
  • issm/trunk-jpl/src/c/cores/sealevelrise_core.cpp

    r24904 r24916  
    9292        int  geodetic=0;
    9393        IssmDouble          dt;
     94        IssmDouble          eartharea,oceanarea;
    9495
    9596        /*Should we even be here?:*/
     
    145146
    146147                /*call eustatic core  (generalized eustatic - Farrel and Clark, Eq 4, 1st, 3rd and 4rd terms on the RHS) */
    147                 RSLg_eustatic=sealevelrise_core_eustatic(femmodel);
     148                RSLg_eustatic=sealevelrise_core_eustatic(femmodel,&eartharea,&oceanarea);
    148149
    149150                /*call non-eustatic core (ocean loading tems  - 2nd and 5th terms on the RHS of Farrel and Clark) */
    150                 RSLg=sealevelrise_core_noneustatic(femmodel,RSLg_eustatic);
     151                RSLg=sealevelrise_core_noneustatic(femmodel,RSLg_eustatic,eartharea,oceanarea);
    151152
    152153                /*compute other elastic geodetic signatures, such as components of 3-D crustal motion: */
    153                 sealevelrise_core_elastic(&U_esa,&U_north_esa,&U_east_esa,femmodel,RSLg);
     154                sealevelrise_core_elastic(&U_esa,&U_north_esa,&U_east_esa,femmodel,RSLg,eartharea);
    154155
    155156                /*compute viscosus (GIA) geodetic signatures:*/
     
    303304}
    304305/*}}}*/
    305 Vector<IssmDouble>* sealevelrise_core_eustatic(FemModel* femmodel){ /*{{{*/
     306Vector<IssmDouble>* sealevelrise_core_eustatic(FemModel* femmodel,IssmDouble* peartharea,IssmDouble* poceanarea){ /*{{{*/
    306307
    307308        /*Eustatic core of the SLR solution (terms that are constant with respect to sea-level)*/
     
    317318        IssmDouble *radius    = NULL;
    318319        int         loop;
     320        IssmDouble eartharea,oceanarea;
    319321
    320322        /*outputs:*/
     
    334336
    335337        /*call the eustatic main module: */
    336         femmodel->SealevelriseEustatic(RSLgi,&eustatic, latitude, longitude, radius,loop); //this computes
     338        femmodel->SealevelriseEustatic(RSLgi,&eartharea, &oceanarea,&eustatic, latitude, longitude, radius,loop); //this computes
    337339
    338340        /*we need to average RSLgi over the ocean: RHS term  4 in Eq.4 of Farrel and clarke. Only the elements can do that: */
    339         RSLgi_oceanaverage=femmodel->SealevelriseOceanAverage(RSLgi);
     341        RSLgi_oceanaverage=femmodel->SealevelriseOceanAverage(RSLgi,oceanarea);
    340342
    341343        /*RSLg is the sum of the pure eustatic component (term 3) and the contribution from the perturbation to the graviation potential due to the
     
    350352        xDelete<IssmDouble>(longitude);
    351353        xDelete<IssmDouble>(radius);
     354
     355        /*Assign output pointers and return: */
     356        *peartharea=eartharea;
     357        *poceanarea=oceanarea;
    352358        return RSLgi;
    353359}/*}}}*/
    354 Vector<IssmDouble>* sealevelrise_core_noneustatic(FemModel* femmodel,Vector<IssmDouble>* RSLg_eustatic){ /*{{{*/
     360Vector<IssmDouble>* sealevelrise_core_noneustatic(FemModel* femmodel,Vector<IssmDouble>* RSLg_eustatic,IssmDouble eartharea,IssmDouble oceanarea){ /*{{{*/
    355361
    356362        /*sealevelrise_core_noneustatic.cpp //this computes the contributions from Eq.4 of Farrel and Clarke, rhs terms 2 and 5.
     
    419425
    420426                /*call the non eustatic module: */
    421                 femmodel->SealevelriseNonEustatic(RSLgo, RSLg_old, latitude, longitude, radius,verboseconvolution,loop);
     427                femmodel->SealevelriseNonEustatic(RSLgo, RSLg_old,  eartharea,latitude,longitude, radius,verboseconvolution,loop);
    422428
    423429                /*assemble solution vector: */
     
    428434                        /*call rotational feedback  module: */
    429435                        RSLgo_rot = new Vector<IssmDouble>(gsize); RSLgo_rot->Assemble();
    430                         femmodel->SealevelriseRotationalFeedback(RSLgo_rot,RSLg_old,&Ixz,&Iyz,&Izz,latitude,longitude,radius);
     436                        femmodel->SealevelriseRotationalFeedback(RSLgo_rot,RSLg_old,&Ixz,&Iyz,&Izz,eartharea,latitude,longitude,radius);
    431437                        RSLgo_rot->Assemble();
    432438
     
    440446
    441447                /*we need to average RSLgo over the ocean: RHS term  5 in Eq.4 of Farrel and clarke. Only the elements can do that: */
    442                 RSLgo_oceanaverage=femmodel->SealevelriseOceanAverage(RSLgo);
     448                RSLgo_oceanaverage=femmodel->SealevelriseOceanAverage(RSLgo,oceanarea);
    443449
    444450                /*RSLg is the sum of the eustatic term, and the ocean terms: */
     
    477483        return RSLg;
    478484} /*}}}*/
    479 void sealevelrise_core_elastic(Vector<IssmDouble>** pU_esa, Vector<IssmDouble>** pU_north_esa,Vector<IssmDouble>** pU_east_esa,FemModel* femmodel,Vector<IssmDouble>* RSLg){ /*{{{*/
     485void sealevelrise_core_elastic(Vector<IssmDouble>** pU_esa, Vector<IssmDouble>** pU_north_esa,Vector<IssmDouble>** pU_east_esa,FemModel* femmodel,Vector<IssmDouble>* RSLg,IssmDouble eartharea){ /*{{{*/
    480486
    481487        Vector<IssmDouble> *U_esa  = NULL;
     
    515521
    516522        /*call the elastic main modlule:*/
    517         femmodel->SealevelriseElastic(U_esa,U_north_esa,U_east_esa,RSLg,latitude,longitude,radius,xx,yy,zz,loop,horiz);
     523        femmodel->SealevelriseElastic(U_esa,U_north_esa,U_east_esa,RSLg,eartharea,latitude,longitude,radius,xx,yy,zz,loop,horiz);
    518524
    519525        /*Assign output pointers:*/
Note: See TracChangeset for help on using the changeset viewer.