Changeset 20935


Ignore:
Timestamp:
07/18/16 02:53:03 (9 years ago)
Author:
Eric.Larour
Message:

CHG (JS): bug fix for FemModel constructor.

Location:
issm/trunk-jpl/src/c/classes
Files:
2 edited

Legend:

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

    r20871 r20935  
    365365        /*Clean up*/
    366366        delete iomodel;
     367}/*}}}*/
     368void FemModel::InitFromFids(char* rootpath, FILE* IOMODEL, FILE* toolkitsoptionsfid, int in_solution_type, bool trace, IssmPDouble* X){/*{{{*/
     369       
     370        /*intermediary*/
     371        int         i;
     372        int         analysis_type;
     373       
     374
     375        /*Initialize internal data: */
     376        this->solution_type    = in_solution_type;
     377        this->analysis_counter = nummodels-1;   //point to last analysis_type carried out.
     378        this->results          = new Results(); //not initialized by CreateDataSets
     379       
     380        /*create IoModel */
     381        IoModel* iomodel = new IoModel(IOMODEL,in_solution_type,trace,X);
     382
     383        /*Figure out what analyses are activated for this solution*/
     384        SolutionAnalysesList(&this->analysis_type_list,&this->nummodels,iomodel,this->solution_type);
     385
     386        /*create datasets for all analyses*/
     387        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);
     388
     389        /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
     390        for(i=0;i<nummodels;i++){
     391
     392                if(VerboseMProcessor()) _printf0_("   Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":\n");
     393                analysis_type=analysis_type_list[i];
     394                this->SetCurrentConfiguration(analysis_type);
     395               
     396                if(i==0){
     397                        if(VerboseMProcessor()) _printf0_("      creating vertex PIDs\n");
     398                        VerticesDofx(vertices,parameters);
     399
     400                        if(VerboseMProcessor()) _printf0_("      detecting active vertices\n");
     401                        GetMaskOfIceVerticesLSMx(this);
     402                }
     403
     404                if(VerboseMProcessor()) _printf0_("      resolving node constraints\n");
     405                SpcNodesx(nodes,constraints,parameters,analysis_type);
     406
     407                if(VerboseMProcessor()) _printf0_("      creating nodal degrees of freedom\n");
     408                NodesDofx(nodes,parameters,analysis_type);
     409
     410                if(VerboseMProcessor()) _printf0_("      configuring element and loads\n");
     411                ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
     412        }
     413
     414        /*Clean up*/
     415        delete iomodel;
     416
    367417}/*}}}*/
    368418void FemModel::Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
     
    26502700
    26512701        /*intermediary*/
    2652         int         i;
    2653         int         analysis_type;
    26542702        FILE       *IOMODEL = NULL;
    26552703        FILE       *toolkitsoptionsfid = NULL;
     
    26582706        size_t      outputsize;
    26592707        char       *outputbuffer;
    2660         const char* rootpath=""; //needed for Dakota runs only, which we won't do here.
     2708        const char*       rootpath=""; //needed for Dakota runs only, which we won't do here.
    26612709
    26622710        /*recover my_rank:*/
    26632711        my_rank=IssmComm::GetRank();
    26642712
    2665         /*Initialize internal data: */
    2666         this->solution_type    = in_solution_type;
    2667         this->analysis_counter = nummodels-1;   //point to last analysis_type carried out.
    2668         this->results          = new Results(); //not initialized by CreateDataSets
    2669        
    2670         /*Open input file on cpu 0 and create IoModel */
     2713        /*Open input file descriptor on cpu 0: */
    26712714        if(my_rank==0) IOMODEL = fmemopen((void*)buffer, buffersize, "rb");
    2672         IoModel* iomodel = new IoModel(IOMODEL,in_solution_type,trace,X);
    2673 
    2674         /*Figure out what analyses are activated for this solution*/
    2675         SolutionAnalysesList(&this->analysis_type_list,&this->nummodels,iomodel,this->solution_type);
    2676 
    2677         /*Open toolkits file: */
     2715
     2716        /*Open toolkits file descriptor: */
    26782717        toolkitsoptionsfid=fmemopen((void*)toolkits, strlen(toolkits)+1, "r");
    26792718
    2680         /*create datasets for all analyses*/
    2681         ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,iomodel,toolkitsoptionsfid,(char*)rootpath,this->solution_type,this->nummodels,this->analysis_type_list);
    2682 
    2683         /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
    2684         for(i=0;i<nummodels;i++){
    2685 
    2686                 if(VerboseMProcessor()) _printf0_("   Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":\n");
    2687                 analysis_type=analysis_type_list[i];
    2688                 this->SetCurrentConfiguration(analysis_type);
    2689 
    2690                 if(i==0){
    2691                         if(VerboseMProcessor()) _printf0_("      creating vertex PIDs\n");
    2692                         VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
    2693                 }
    2694 
    2695                 if(VerboseMProcessor()) _printf0_("      resolving node constraints\n");
    2696                 SpcNodesx(nodes,constraints,parameters,analysis_type);
    2697 
    2698                 if(VerboseMProcessor()) _printf0_("      creating nodal degrees of freedom\n");
    2699                 NodesDofx(nodes,parameters,analysis_type);
    2700 
    2701                 if(VerboseMProcessor()) _printf0_("      configuring element and loads\n");
    2702                 ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
    2703         }
     2719        /*Now, go create FemModel:*/
     2720        this->InitFromFids((char*)rootpath,IOMODEL,toolkitsoptionsfid,in_solution_type,trace,X);
    27042721
    27052722        /*Close input file and toolkits file descriptors: */
     
    27142731        this->parameters->AddObject(new GenericParam<size_t*>(&outputsize,OutputBufferSizePointerEnum));
    27152732
    2716         /*Clean up*/
    2717         delete iomodel;
    27182733}/*}}}*/
    27192734#endif
  • issm/trunk-jpl/src/c/classes/FemModel.h

    r20810 r20935  
    5555                void Echo();
    5656                void InitFromFiles(char* rootpath, char* inputfilename, char* outputfilename, char* petscfilename, char* lockfilename, char* restartfilename, const int solution_type,bool trace,IssmPDouble* X=NULL);
     57                void InitFromFids(char* rootpath, FILE* IOMODEL, FILE* toolkitsoptionsfid, int in_solution_type, bool trace, IssmPDouble* X=NULL);
    5758                void Marshall(char** pmarshalled_data, int* pmarshalled_data_size, int marshall_direction);
    5859                void Restart(void);
Note: See TracChangeset for help on using the changeset viewer.