Changeset 18529


Ignore:
Timestamp:
09/18/14 08:41:51 (11 years ago)
Author:
Mathieu Morlighem
Message:

NEW: do not create all the analyses for a given solution, use iomodel to know whether some analyses can be skipped

Location:
issm/trunk-jpl/src/c
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Makefile.am

    r18492 r18529  
    342342                                        ./cores/ProcessArguments.cpp\
    343343                                        ./cores/ResetBoundaryConditions.cpp\
    344                                         ./cores/AnalysisConfiguration.cpp\
    345344                                        ./cores/WrapperCorePointerFromSolutionEnum.cpp\
    346345                                        ./cores/CorePointerFromSolutionEnum.cpp\
  • issm/trunk-jpl/src/c/classes/FemModel.cpp

    r18528 r18529  
    7575        ProcessArguments(&solution_type,&binfilename,&outbinfilename,&petscfilename,&lockfilename,&rootpath,argc,argv);
    7676
    77         /*out of solution_type, figure out types of analyses needed in the femmodel: */
    78         AnalysisConfiguration(&analyses,&numanalyses,solution_type);
    79 
    8077        /*Create femmodel from input files: */
    8178        profiler->Tag(StartInit);
    82         this->InitFromFiles(rootpath,binfilename,outbinfilename,petscfilename,lockfilename,solution_type,analyses,numanalyses);
     79        this->InitFromFiles(rootpath,binfilename,outbinfilename,petscfilename,lockfilename,solution_type);
    8380        profiler->Tag(FinishInit);
    8481
     
    9087        xDelete<char>(petscfilename);
    9188        xDelete<char>(rootpath);
    92 
    93 }
    94 /*}}}*/
    95 FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){/*{{{*/
    96 
    97         /*Call InitFromFiles. This constructor is just a wrapper: */
    98         this->InitFromFiles(rootpath, inputfilename, outputfilename, toolkitsfilename, lockfilename, in_solution_type,analyses,nummodels);
    9989
    10090}
     
    141131}
    142132/*}}}*/
    143 void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){/*{{{*/
     133void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* toolkitsfilename, char* lockfilename, const int in_solution_type){/*{{{*/
    144134
    145135        /*intermediary*/
     
    154144        my_rank=IssmComm::GetRank();
    155145
    156         /*Open input file on cpu 0: */
    157         if(my_rank==0) IOMODEL = pfopen0(inputfilename ,"rb");
    158 
    159         /*Open toolkits file: */
    160         toolkitsoptionsfid=pfopen(toolkitsfilename,"r");
    161 
    162146        /*Initialize internal data: */
    163         this->nummodels        = nummodels;
    164147        this->solution_type    = in_solution_type;
    165148        this->analysis_counter = nummodels-1;   //point to last analysis_type carried out.
    166149        this->results          = new Results(); //not initialized by CreateDataSets
    167150
    168         /*Dynamically allocate whatever is a list of length nummodels: */
    169         analysis_type_list=xNew<int>(nummodels);
    170 
    171         /*Initialize: */
    172         for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
     151        /*Open input file on cpu 0 and create IoModel */
     152        if(my_rank==0) IOMODEL = pfopen0(inputfilename ,"rb");
     153        IoModel* iomodel = new IoModel(IOMODEL);
     154
     155        /*Figure out what analyses are activated for this solution*/
     156        SolutionAnalysesList(&this->analysis_type_list,&this->nummodels,iomodel,this->solution_type);
     157
     158        /*Open toolkits file: */
     159        toolkitsoptionsfid=pfopen(toolkitsfilename,"r");
    173160
    174161        /*create datasets for all analyses*/
    175         ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,toolkitsoptionsfid,rootpath,this->solution_type,nummodels,analyses);
     162        ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,iomodel,toolkitsoptionsfid,rootpath,this->solution_type,this->nummodels,this->analysis_type_list);
    176163
    177164        /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
     
    209196        this->parameters->AddObject(new StringParam(LockFileNameEnum,lockfilename));
    210197
    211         }
    212 /*}}}*/
     198        /*Clean up*/
     199        delete iomodel;
     200}/*}}}*/
    213201void FemModel::CleanUp(void){/*{{{*/
    214202
     
    412400}
    413401/*}}}*/
     402void  FemModel::SolutionAnalysesList(int** panalyses,int* pnumanalyses,IoModel* iomodel,int solutiontype){/*{{{*/
     403
     404        /*output: */
     405        int  numanalyses = 0;
     406        int* analyses=NULL;
     407
     408        /*Intermediaries*/
     409        const int MAXANALYSES = 30;
     410        int   analyses_temp[MAXANALYSES];
     411
     412        /*Analyses lists*/
     413        switch(solutiontype){
     414
     415                case StressbalanceSolutionEnum:{
     416                        bool isSIA,isFS;
     417                        int  fe_FS;
     418                        iomodel->Constant(&fe_FS,FlowequationFeFSEnum);
     419                        iomodel->Constant(&isSIA,FlowequationIsSIAEnum);
     420                        iomodel->Constant(&isFS,FlowequationIsFSEnum);
     421                        analyses_temp[numanalyses++]=StressbalanceAnalysisEnum;
     422                        analyses_temp[numanalyses++]=StressbalanceVerticalAnalysisEnum;
     423                        if(isSIA){
     424                                analyses_temp[numanalyses++]=StressbalanceSIAAnalysisEnum;
     425                        }
     426                        analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum;
     427                        analyses_temp[numanalyses++]=ExtrudeFromBaseAnalysisEnum;
     428                        analyses_temp[numanalyses++]=DepthAverageAnalysisEnum;
     429                        if(fe_FS==LATaylorHoodEnum || fe_FS==LACrouzeixRaviartEnum){
     430                                analyses_temp[numanalyses++]=UzawaPressureAnalysisEnum;
     431                        }
     432                        }
     433                        break;
     434
     435                case SteadystateSolutionEnum:
     436                        analyses_temp[numanalyses++]=StressbalanceAnalysisEnum;
     437                        analyses_temp[numanalyses++]=StressbalanceVerticalAnalysisEnum;
     438                        analyses_temp[numanalyses++]=StressbalanceSIAAnalysisEnum;
     439                        analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum;
     440                        analyses_temp[numanalyses++]=EnthalpyAnalysisEnum;
     441                        analyses_temp[numanalyses++]=ThermalAnalysisEnum;
     442                        analyses_temp[numanalyses++]=MeltingAnalysisEnum;
     443                        break;
     444
     445                case ThermalSolutionEnum:
     446                        analyses[numanalyses++]=ThermalAnalysisEnum;
     447                        analyses[numanalyses++]=MeltingAnalysisEnum;
     448                        analyses[numanalyses++]=EnthalpyAnalysisEnum;
     449                        break;
     450
     451                case HydrologySolutionEnum:
     452                        analyses[numanalyses++]=HydrologyShreveAnalysisEnum;
     453                        analyses[numanalyses++]=HydrologyDCInefficientAnalysisEnum;
     454                        analyses[numanalyses++]=HydrologyDCEfficientAnalysisEnum;
     455                        analyses[numanalyses++]=L2ProjectionBaseAnalysisEnum;
     456                        analyses[numanalyses++]=L2ProjectionEPLAnalysisEnum;
     457                        break;
     458
     459                case MasstransportSolutionEnum:
     460                        analyses[numanalyses++]=MasstransportAnalysisEnum;
     461                        break;
     462
     463                case BalancethicknessSolutionEnum:
     464                        analyses[numanalyses++]=BalancethicknessAnalysisEnum;
     465                        break;
     466
     467                case Balancethickness2SolutionEnum:
     468                        analyses[numanalyses++]=Balancethickness2AnalysisEnum;
     469                        break;
     470
     471                case BalancethicknessSoftSolutionEnum:
     472                        analyses[numanalyses++]=BalancethicknessAnalysisEnum;
     473                        break;
     474
     475                case BalancevelocitySolutionEnum:
     476                        analyses[numanalyses++]=BalancevelocityAnalysisEnum;
     477                        analyses[numanalyses++]=SmoothedSurfaceSlopeXAnalysisEnum;
     478                        analyses[numanalyses++]=SmoothedSurfaceSlopeYAnalysisEnum;
     479                        break;
     480
     481                case SurfaceSlopeSolutionEnum:
     482                        analyses[numanalyses++]=L2ProjectionBaseAnalysisEnum;
     483                        break;
     484
     485                case BedSlopeSolutionEnum:
     486                        analyses[numanalyses++]=L2ProjectionBaseAnalysisEnum;
     487                        break;
     488
     489                case GiaSolutionEnum:
     490                        analyses[numanalyses++]=GiaAnalysisEnum;
     491                        break;
     492               
     493                case DamageEvolutionSolutionEnum:
     494                        analyses[numanalyses++]=DamageEvolutionAnalysisEnum;
     495                        break;
     496
     497                case TransientSolutionEnum:
     498                        analyses_temp[numanalyses++]=StressbalanceAnalysisEnum;
     499                        analyses_temp[numanalyses++]=StressbalanceVerticalAnalysisEnum;
     500                        analyses_temp[numanalyses++]=StressbalanceSIAAnalysisEnum;
     501                        analyses_temp[numanalyses++]=L2ProjectionBaseAnalysisEnum;
     502                        analyses_temp[numanalyses++]=ThermalAnalysisEnum;
     503                        analyses_temp[numanalyses++]=MeltingAnalysisEnum;
     504                        analyses_temp[numanalyses++]=EnthalpyAnalysisEnum;
     505                        analyses_temp[numanalyses++]=MasstransportAnalysisEnum;
     506                        analyses_temp[numanalyses++]=FreeSurfaceBaseAnalysisEnum;
     507                        analyses_temp[numanalyses++]=FreeSurfaceTopAnalysisEnum;
     508                        analyses_temp[numanalyses++]=ExtrudeFromBaseAnalysisEnum;
     509                        analyses_temp[numanalyses++]=ExtrudeFromTopAnalysisEnum;
     510                        analyses_temp[numanalyses++]=LevelsetAnalysisEnum;
     511                        analyses_temp[numanalyses++]=ExtrapolationAnalysisEnum;
     512                        analyses_temp[numanalyses++]=LsfReinitializationAnalysisEnum;
     513                        analyses_temp[numanalyses++]=DamageEvolutionAnalysisEnum;
     514                        analyses_temp[numanalyses++]=HydrologyShreveAnalysisEnum;
     515                        analyses_temp[numanalyses++]=HydrologyDCInefficientAnalysisEnum;
     516                        analyses_temp[numanalyses++]=HydrologyDCEfficientAnalysisEnum;
     517                        analyses_temp[numanalyses++]=L2ProjectionEPLAnalysisEnum;
     518                        break;
     519
     520                case SeaiceSolutionEnum:
     521                        analyses_temp[numanalyses++]=SeaiceAnalysisEnum;
     522                        break;
     523
     524                default:
     525                        _error_("solution type: " << EnumToStringx(solutiontype) << " not supported yet!");
     526                        break;
     527        }
     528
     529        /*Copy analyses from temp to output*/
     530        _assert_(numanalyses<MAXANALYSES);
     531        analyses=xNew<int>(numanalyses);
     532        for(int i=0;i<numanalyses;i++) analyses[i]=analyses_temp[i];
     533
     534        /*Assign output pointers:*/
     535        if(pnumanalyses) *pnumanalyses=numanalyses;
     536        if(panalyses)    *panalyses=analyses;
     537        else              xDelete<int>(analyses);
     538}/*}}}*/
    414539
    415540/*Modules:*/
  • issm/trunk-jpl/src/c/classes/FemModel.h

    r18528 r18529  
    4747                /*constructors, destructors: */
    4848                FemModel(int argc,char** argv,ISSM_MPI_Comm comm_init);
    49                 FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
    5049                ~FemModel();
    5150
     
    5352                void Echo();
    5453                FemModel* copy();
    55                 void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
     54                void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type);
     55                void SolutionAnalysesList(int** panalyses,int* pnumanalyses,IoModel* iomodel,int solutiontype);
    5656                void CleanUp(void);
    5757                void Solve(void);
  • issm/trunk-jpl/src/c/cores/cores.h

    r18492 r18529  
    5858
    5959//solution configuration
    60 void AnalysisConfiguration(int** pcores,int* pnumcores, int solutiontype);
    6160void CorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype);
    6261void WrapperCorePointerFromSolutionEnum(void (**psolutioncore)(FemModel*),Parameters* parameters,int solutiontype,bool nodakotacore=false);
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.cpp

    r17757 r18529  
    1313#include "./ModelProcessorx.h"
    1414
    15 void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters, FILE* IOMODEL,FILE* toolkitfile, char* rootpath,const int solution_enum,const int nummodels,const int* analysis_enum_list){
     15void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters,IoModel* iomodel,FILE* toolkitfile, char* rootpath,const int solution_enum,const int nummodels,const int* analysis_enum_list){
    1616
    1717        int   i,analysis_enum,verbose;
     
    2626        Loads       *loads       = new Loads();
    2727        Parameters  *parameters  = new Parameters();
    28 
    29         /*Initialize IoModel from input file*/
    30         IoModel* iomodel = new IoModel(IOMODEL);
    3128
    3229        /*Fetch parameters: */
     
    128125        if(VerboseMProcessor()) _printf0_("   done with model processor \n");
    129126
    130         /*Free resources:*/
    131         delete iomodel;
    132 
    133127        /*Assign output pointers:*/
    134128        *pelements    = elements;
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h

    r17844 r18529  
    99#include "../../analyses/analyses.h"
    1010
    11 void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters, FILE* iomodel_handle,FILE* toolkitfile, char* rootpath,const int solution_type,const int nummodels,const int* analysis_type_listh);
     11void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters,IoModel* iomodel,FILE* toolkitfile, char* rootpath,const int solution_type,const int nummodels,const int* analysis_type_listh);
    1212
    1313/*Creation of fem datasets: general drivers*/
Note: See TracChangeset for help on using the changeset viewer.