Changeset 23486


Ignore:
Timestamp:
11/29/18 14:53:35 (6 years ago)
Author:
Mathieu Morlighem
Message:

CHG: speedup SetCurrentConfiguration by not doing anything if the model is already the rigt one

File:
1 edited

Legend:

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

    r23483 r23486  
    9999                /*Verifications. AMR supports SSA, P1 and horizontal 2D domain*/
    100100                bool isSSA;
    101                 int domaintype,element_type,analysis_counter=-1;
     101                int domaintype,element_type;
     102                this->analysis_counter=-1;
    102103                this->parameters->FindParam(&isSSA,FlowequationIsSSAEnum);
    103104                this->parameters->FindParam(&domaintype,DomainTypeEnum);
     
    207208int FemModel::AnalysisIndex(int analysis_enum){/*{{{*/
    208209
    209         int found=-1;
     210        /*Checks in debugging mode*/
    210211        _assert_(this->analysis_type_list);
     212
     213        /*Find analysis in list*/
    211214        for(int i=0;i<this->nummodels;i++){
    212215                if(this->analysis_type_list[i]==analysis_enum){
    213                         found=i;
     216                        return i;
    214217                        break;
    215218                }
    216219        }
    217         if(found!=-1) return found;
    218         else _error_("Could not find index of analysis " << EnumToStringx(analysis_enum) << " in list of FemModel analyses");
     220
     221        /*If you reach this point, analysis has not been found*/
     222        _error_("Could not find index of analysis " << EnumToStringx(analysis_enum) << " in list of FemModel analyses");
    219223
    220224
     
    409413        /*Initialize internal data: */
    410414        this->solution_type    = in_solution_type;
    411         this->analysis_counter = nummodels-1;   //point to last analysis_type carried out.
     415        this->analysis_counter = -1;
    412416        this->results          = new Results(); //not initialized by CreateDataSets
    413417
     
    582586         * analyses. For example: do a SurfaceSlopeX, SurfaceSlopeY, BedSlopeX and BedSlopeY analysis using the
    583587         * Slope configuration.*/
    584         int found=-1;
    585         for(int i=0;i<nummodels;i++){
    586                 if (analysis_type_list[i]==configuration_type){
    587                         found=i;
    588                         break;
    589                 }
    590         }
    591         if(found!=-1) this->analysis_counter=found;
    592         else _error_("Could not find alias for analysis_type " << EnumToStringx(configuration_type) << " in list of FemModel analyses");
     588        int index = AnalysisIndex(configuration_type);
     589
     590        /*If we already have the right analysis, return*/
     591        if(this->analysis_counter==index) return;
     592        this->analysis_counter=index;
    593593
    594594        /*Now, plug analysis_counter and analysis_type inside the parameters: */
Note: See TracChangeset for help on using the changeset viewer.