Ignore:
Timestamp:
05/29/20 16:03:44 (5 years ago)
Author:
Eric.Larour
Message:

CHG: 10% increase in sea level solver speed, using a G_rigid kernel pre computed
in the SealevelriseAnalysis section, before G_elastic kernels.

File:
1 edited

Legend:

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

    r24915 r24921  
    55985598
    55995599        /*elastic green function:*/
     5600        int         index;
    56005601        IssmDouble* G_elastic_precomputed=NULL;
     5602        IssmDouble* G_rigid_precomputed=NULL;
    56015603        int         M;
    56025604
     
    56495651
    56505652        /*recover elastic green function:*/
     5653        DoubleVecParam* parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelriseGRigidEnum)); _assert_(parameter);
     5654        parameter->GetParameterValueByPointer(&G_rigid_precomputed,&M);
     5655
    56515656        if(computeelastic){
    5652                 DoubleVecParam* parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelriseGElasticEnum));
    5653                 _assert_(parameter);
     5657                parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelriseGElasticEnum)); _assert_(parameter);
    56545658                parameter->GetParameterValueByPointer(&G_elastic_precomputed,&M);
    56555659        }
     
    57485752                for(int i=0;i<gsize;i++){
    57495753
    5750                         IssmDouble G_rigid=0;  //do not remove =0!
    57515754                        IssmDouble G_elastic=0;  //do not remove =0!
    57525755
    5753                         /*Compute alpha angle between centroid and current vertex : */
     5756                        /*Compute alpha angle between centroid and current vertex and index into precomputed tables: */
    57545757                        lati=latitude[i]/180*PI; longi=longitude[i]/180*PI;
    5755 
    57565758                        delPhi=fabs(lati-late); delLambda=fabs(longi-longe);
    57575759                        alpha=2.*asin(sqrt(pow(sin(delPhi/2),2.0)+cos(lati)*cos(late)*pow(sin(delLambda/2),2)));
    5758 
    5759                         //Rigid earth gravitational perturbation:
    5760                         if(computerigid)G_rigid=1.0/2.0/sin(alpha/2.0);
     5760                        index=reCast<int,IssmDouble>(alpha/PI*reCast<IssmDouble,int>(M-1));
    57615761
    57625762                        //Elastic component  (from Eq 17 in Adhikari et al, GMD 2015)
    5763                         if(computeelastic){
    5764                                 int index=reCast<int,IssmDouble>(alpha/PI*reCast<IssmDouble,int>(M-1));
    5765                                 G_elastic += G_elastic_precomputed[index];
    5766                         }
     5763                        if(computeelastic) G_elastic += G_elastic_precomputed[index];
    57675764
    57685765                        /*Add all components to the Sgi or Sgo solution vectors:*/
    5769                         Sgi[i]+=3*rho_ice/rho_earth*area/eartharea*I*(G_rigid+G_elastic);
    5770 
     5766                        Sgi[i]+=3*rho_ice/rho_earth*area/eartharea*I*(G_rigid_precomputed[index]+G_elastic);
    57715767                }
    57725768        }
     
    59405936
    59415937        /*precomputed elastic green functions:*/
     5938        IssmDouble* G_rigid_precomputed = NULL;
    59425939        IssmDouble* G_elastic_precomputed = NULL;
    59435940        int         M;
    5944 
    5945         /*computation of Green functions:*/
    5946         IssmDouble* G_elastic= NULL;
    5947         IssmDouble* G_rigid= NULL;
     5941        int         index;
     5942        IssmDouble alpha;
     5943        IssmDouble delPhi,delLambda;
    59485944
    59495945        /*optimization:*/
     
    60206016        /*}}}*/
    60216017
     6018        /*recover rigid and elastic green functions:*/
     6019        DoubleVecParam* parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelriseGRigidEnum)); _assert_(parameter);
     6020        parameter->GetParameterValueByPointer(&G_rigid_precomputed,&M);
     6021
    60226022        if(computeelastic){
    6023 
    60246023                /*recover elastic green function:*/
    6025                 DoubleVecParam* parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelriseGElasticEnum)); _assert_(parameter);
     6024                parameter = static_cast<DoubleVecParam*>(this->parameters->FindParamObject(SealevelriseGElasticEnum)); _assert_(parameter);
    60266025                parameter->GetParameterValueByPointer(&G_elastic_precomputed,&M);
    6027 
    6028                 /*initialize G_elastic:*/
    6029                 G_elastic=xNewZeroInit<IssmDouble>(gsize);
    6030         }
    6031         if(computerigid) G_rigid=xNewZeroInit<IssmDouble>(gsize);
    6032 
    6033         IssmDouble alpha;
    6034         IssmDouble delPhi,delLambda;
    6035 
     6026        }
     6027
     6028       
    60366029        for(int i=0;i<gsize;i++){
    60376030
    60386031                /*Compute alpha angle between centroid and current vertex : */
    60396032                lati=latitude[i]/180*PI; longi=longitude[i]/180*PI;
    6040 
    60416033                delPhi=fabs(lati-late); delLambda=fabs(longi-longe);
    60426034                alpha=2.*asin(sqrt(pow(sin(delPhi/2),2.0)+cos(lati)*cos(late)*pow(sin(delLambda/2),2)));
     6035                index=reCast<int,IssmDouble>(alpha/PI*(M-1));
    60436036
    60446037                /*Rigid earth gravitational perturbation: */
    60456038                if(computerigid){
    6046                         G_rigid[i]=1.0/2.0/sin(alpha/2.0);
    6047                         //values[i]+=3*rho_water/rho_earth*area/eartharea*S*G_rigid[i];
    6048                         Sgo[i]+=3*rho_water/rho_earth*area/eartharea*S*G_rigid[i];
     6039                        Sgo[i]+=3*rho_water/rho_earth*area/eartharea*S*G_rigid_precomputed[index];
    60496040                }
    60506041
    60516042                /*Elastic component  (from Eq 17 in Adhikari et al, GMD 2015): */
    60526043                if(computeelastic){
    6053                         int index=reCast<int,IssmDouble>(alpha/PI*(M-1));
    6054                         G_elastic[i] += G_elastic_precomputed[index];
    6055                         //values[i]+=3*rho_water/rho_earth*area/eartharea*S*G_elastic[i];
    6056                         Sgo[i]+=3*rho_water/rho_earth*area/eartharea*S*G_elastic[i];
    6057                 }
    6058         }
    6059 
    6060 
    6061         /*Free ressources:*/
    6062         if(computeelastic) xDelete<IssmDouble>(G_elastic);
    6063         if(computerigid) xDelete<IssmDouble>(G_rigid);
     6044                        Sgo[i]+=3*rho_water/rho_earth*area/eartharea*S*G_elastic_precomputed[index];
     6045                }
     6046        }
     6047
    60646048
    60656049        return;
Note: See TracChangeset for help on using the changeset viewer.