Changeset 13553


Ignore:
Timestamp:
10/05/12 10:24:48 (12 years ago)
Author:
Eric.Larour
Message:

CHG: issm.cpp now runs the following methods: Constructor, Solve, and delete.
Everything such as solution cores, configuration, etc ... has been folded in these methods.

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

Legend:

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

    r13549 r13553  
    1212#include "../Container/Container.h"
    1313#include "../modules/ModelProcessorx/ModelProcessorx.h"
     14#include "../solutions/solutions.h"
    1415#include "../io/io.h"
    1516#include "./classes.h"
     
    1920
    2021/*Object constructors and destructor*/
    21 /*FUNCTION FemModel::constructor {{{*/
     22/*FUNCTION FemModel::FemModel(int argc,char** argv){{{*/
     23FemModel::FemModel(int argc,char** argv){
     24
     25        /*configuration: */
     26        int* analyses=NULL;
     27        int  numanalyses;
     28        int  solution_type;
     29
     30        /*File names*/
     31        char *lockfilename   = NULL;
     32        char *binfilename    = NULL;
     33        char *outbinfilename = NULL;
     34        char *petscfilename  = NULL;
     35        char *rootpath       = NULL;
     36
     37        /*Start profiler: */
     38        this->profiler=new Profiler();
     39        profiler->Tag(Start);
     40
     41        /*From command line arguments, retrieve different filenames needed to create the FemModel: */
     42        ProcessArguments(&solution_type,&binfilename,&outbinfilename,&petscfilename,&lockfilename,&rootpath,argc,argv);
     43
     44        /*out of solution_type, figure out types of analyses needed in the femmodel: */
     45        AnalysisConfiguration(&analyses,&numanalyses,solution_type);
     46
     47        /*Create femmodel from input files: */
     48        profiler->Tag(StartInit);
     49        this->InitFromFiles(rootpath,binfilename,outbinfilename,petscfilename,lockfilename,solution_type,analyses,numanalyses);
     50        profiler->Tag(FinishInit);
     51
     52        /*Free resources */
     53        xDelete<int>(analyses);
     54        xDelete<char>(lockfilename);
     55        xDelete<char>(binfilename);
     56        xDelete<char>(outbinfilename);
     57        xDelete<char>(petscfilename);
     58        xDelete<char>(rootpath);
     59
     60}
     61/*}}}*/
     62/*FUNCTION FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){{{*/
    2263FemModel::FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){
    2364
     65        /*Call InitFromFiles. This constructor is just a wrapper: */
     66        this->InitFromFiles(rootpath, inputfilename, outputfilename, petscfilename, lockfilename, in_solution_type,analyses,nummodels);
     67
     68}
     69/*}}}*/
     70/*FUNCTION FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){{{*/
     71void FemModel::InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int in_solution_type,const int* analyses,const int nummodels){
     72       
    2473        /*intermediary*/
    2574        int         i;
     
    122171        delete parameters;
    123172        delete results;
     173        delete profiler;
    124174
    125175}
     
    127177
    128178/*Object management*/
     179/*FUNCTION FemModel::Solve {{{*/
     180void FemModel::Solve(void){
     181
     182        int solution_type;
     183        void (*solutioncore)(FemModel*)=NULL; //core solution function pointer
     184       
     185        _pprintLine_("call computational core:");
     186
     187        /*Retrieve solution_type from parameters: */
     188        this->parameters->FindParam(&solution_type,SolutionTypeEnum);
     189
     190        /*Figure out which solution core we are going to run with the current solution type: */
     191        CorePointerFromSolutionEnum(&solutioncore,this->parameters,solution_type);
     192
     193        /*run solutoin core: */
     194        profiler->Tag(StartCore);   
     195        solutioncore(this);
     196        profiler->Tag(FinishCore);
     197
     198        /*run AD core if needed: */
     199        profiler->Tag(StartAdCore);
     200        ad_core(this);     
     201        profiler->Tag(FinishAdCore);
     202
     203
     204}
     205/*}}}*/
    129206/*FUNCTION FemModel::Echo {{{*/
    130207void FemModel::Echo(void){
  • TabularUnified issm/trunk-jpl/src/c/classes/FemModel.h

    r13549 r13553  
    1919class Loads;
    2020class Materials;
     21class Profiler;
    2122/*}}}*/
    2223
     
    3334                int          analysis_counter;     //counter into analysis_type_list
    3435
     36                Profiler*    profiler;             //keep time, cpu and mem statistics while we are running.
     37
    3538                Elements    *elements;             //elements (one set for all analyses)
    3639                Nodes       *nodes;                //one set of nodes
     
    4346
    4447                /*constructors, destructors: */
     48                FemModel(int argc,char** argv);
    4549                FemModel(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
    4650                ~FemModel();
     51                void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, const int solution_type,const int* analyses,const int nummodels);
    4752
    4853                /*Methods: */
    4954                void Echo();
     55                void Solve(void);
    5056
    5157                /*Fem: */
  • TabularUnified issm/trunk-jpl/src/c/solutions/issm.cpp

    r13549 r13553  
    1414        FemModel *femmodel = NULL;
    1515
    16         /*configuration: */
    17         void (*solutioncore)(FemModel*)=NULL; //core solution function pointer
    18         int* analyses=NULL;
    19         int  numanalyses;
    20         int  solution_type;
    21 
    22         /*File names*/
    23         char *lockfilename   = NULL;
    24         char *binfilename    = NULL;
    25         char *outbinfilename = NULL;
    26         char *petscfilename  = NULL;
    27         char *rootpath       = NULL;
    28 
    29         /*profiling*/   
    30         Profiler* profiler=NULL;
     16        /*Print starting banner: {{{*/
     17        _pprintLine_("");
     18        _pprintLine_("Ice Sheet System Model (" << PACKAGE_NAME << ") version " << PACKAGE_VERSION);
     19        _pprintLine_("(website: " << PACKAGE_URL << " contact: " << PACKAGE_BUGREPORT << ")");
     20        _pprintLine_("");
     21        /*}}}*/
    3122
    3223        /*Initialize exception trapping: */
     
    3526        /*Initialize environment (MPI, PETSC, MUMPS, etc ...)*/
    3627        EnvironmentInit(argc,argv);
    37        
    38         /*Start profiler: */
    39         profiler=new Profiler();
    40         profiler->Tag(Start);
    41        
    42         /*First process inputs*/
    43         _pprintLine_("");
    44         _pprintLine_("Ice Sheet System Model (" << PACKAGE_NAME << ") version " << PACKAGE_VERSION);
    45         _pprintLine_("(website: " << PACKAGE_URL << " contact: " << PACKAGE_BUGREPORT << ")");
    46         _pprintLine_("");
     28               
     29        /*Initialize femmodel from arguments provided command line: */
     30        femmodel=new FemModel(argc,argv);
    4731
    48         ProcessArguments(&solution_type,&binfilename,&outbinfilename,&petscfilename,&lockfilename,&rootpath,argc,argv);
     32        /*Solve: */
     33        femmodel->Solve();
    4934
    50         /*out of solution_type, figure out types of analyses needed in the femmodel: */
    51         AnalysisConfiguration(&analyses,&numanalyses,solution_type);
    52 
    53         /*Create femmodel from input files: */
    54         profiler->Tag(StartInit);
    55         femmodel=new FemModel(rootpath,binfilename,outbinfilename,petscfilename,lockfilename,solution_type,analyses,numanalyses);
    56         profiler->Tag(FinishInit);
    57        
    58         /*call cores: */
    59         _pprintLine_("call computational core:");
    60         CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);
    61         profiler->Tag(StartCore);   solutioncore(femmodel); profiler->Tag(FinishCore);
    62         profiler->Tag(StartAdCore); ad_core(femmodel);      profiler->Tag(FinishAdCore);
    63         ProfilerEnd(profiler,femmodel->results,femmodel->parameters);
     35        /*Some profiling: */
     36        ProfilerEnd(femmodel->profiler,femmodel->results,femmodel->parameters);
    6437
    6538        _pprintLine_("write results to disk:");
     
    6740       
    6841        /*Profiling at the end: */
    69         profiler->Tag(Finish);
    70         ProfilerEcho(profiler);
     42        femmodel->profiler->Tag(Finish);
     43        ProfilerEcho(femmodel->profiler);
    7144       
    72         /*Free resources */
    73         xDelete<int>(analyses);
    74         xDelete<char>(lockfilename);
    75         xDelete<char>(binfilename);
    76         xDelete<char>(outbinfilename);
    77         xDelete<char>(petscfilename);
    78         xDelete<char>(rootpath);
     45        /*Wrap up: */
    7946        delete femmodel;
    8047
Note: See TracChangeset for help on using the changeset viewer.