Changeset 20012


Ignore:
Timestamp:
01/29/16 12:03:48 (9 years ago)
Author:
Eric.Larour
Message:

CHG: 20% improvement in the SLR core speed from switching to SetValues instead of SetValue one at a time.

File:
1 edited

Legend:

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

    r20007 r20012  
    36183618
    36193619        if(computeelastic | computerigid){
     3620                int* indices=xNew<int>(gsize);
     3621                IssmDouble* values=xNew<IssmDouble>(gsize);
    36203622                for(int i=0;i<gsize;i++){
     3623                        indices[i]=i;
    36213624
    36223625                        IssmDouble alpha;
     
    36523655
    36533656                        /*Add all components to the pSgi or pSgo solution vectors:*/
    3654                         pSgi->SetValue(i,3*rho_ice/rho_earth*area/eartharea*I*(G_rigid+G_elastic),ADD_VAL);
    3655                        
    3656                 }
     3657                        values[i]=3*rho_ice/rho_earth*area/eartharea*I*(G_rigid+G_elastic);
     3658                }
     3659                pSgi->SetValues(gsize,indices,values,ADD_VAL);
     3660               
     3661                /*free ressources:*/
     3662                xDelete<IssmDouble>(values);
     3663                xDelete<int>(indices);
    36573664        }
    36583665       
     
    36933700        int         M;
    36943701
     3702        /*optimization:*/
     3703        bool store_green_functions=false;
     3704
    36953705        /*ice properties: */
    36963706        IssmDouble rho_ice,rho_water,rho_earth;
     
    37163726        this->parameters->FindParam(&computeelastic,SealevelriseElasticEnum);
    37173727        this->parameters->FindParam(&computeeustatic,SealevelriseEustaticEnum);
     3728        this->parameters->FindParam(&store_green_functions,SealevelriseStoreGreenFunctionsEnum);
    37183729       
    37193730        /*early return if rigid or elastic not requested:*/
     
    38053816        }
    38063817
     3818        int* indices=xNew<int>(gsize);
     3819        IssmDouble* values=xNewZeroInit<IssmDouble>(gsize);
     3820
    38073821        for(int i=0;i<gsize;i++){
    38083822
     3823                indices[i]=i;
    38093824                if(compute_G_elastic | compute_G_rigid){
    38103825                        IssmDouble alpha;
     
    38393854
    38403855                /*Add all components to the pSgi or pSgo solution vectors:*/
    3841                 if(computerigid)pSgo->SetValue(i,3*rho_water/rho_earth*area/eartharea*I*G_rigid[i],ADD_VAL);
    3842                 if(computeelastic)pSgo->SetValue(i,3*rho_water/rho_earth*area/eartharea*I*G_elastic[i],ADD_VAL);
    3843         }
     3856                if(computerigid)values[i]+=3*rho_water/rho_earth*area/eartharea*I*G_rigid[i];
     3857                if(computeelastic)values[i]+=3*rho_water/rho_earth*area/eartharea*I*G_elastic[i];
     3858        }
     3859       
     3860        pSgo->SetValues(gsize,indices,values,ADD_VAL);
     3861
     3862        /*free ressources:*/
     3863        xDelete<IssmDouble>(values);
     3864        xDelete<int>(indices);
    38443865
    38453866        /*Save G_rigid and G_elastic if computed:*/
    3846         if(G_rigid)this->inputs->AddInput(new DoubleArrayInput(SealevelriseGRigidEnum,G_rigid,gsize));
    3847         if(G_elastic)this->inputs->AddInput(new DoubleArrayInput(SealevelriseGElasticEnum,G_elastic,gsize));
     3867        if(store_green_functions){
     3868                if(G_rigid)this->inputs->AddInput(new DoubleArrayInput(SealevelriseGRigidEnum,G_rigid,gsize));
     3869                if(G_elastic)this->inputs->AddInput(new DoubleArrayInput(SealevelriseGElasticEnum,G_elastic,gsize));
     3870        }
    38483871
    38493872        /*Free ressources:*/
Note: See TracChangeset for help on using the changeset viewer.