/*!\file FemModel.c * \brief: implementation of the FemModel object */ #ifdef HAVE_CONFIG_H #include #else #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" #endif #include #include "../Container/Container.h" #include "../modules/ModelProcessorx/ModelProcessorx.h" #include "../io/io.h" #include "./objects.h" #include "../include/include.h" #include "../EnumDefinitions/EnumDefinitions.h" #include "../modules/modules.h" /*Object constructors and destructor*/ /*FUNCTION FemModel::constructor {{{*/ FemModel::FemModel(char* inputfilename, char* outputfilename, const int in_solution_type,const int* analyses,const int nummodels){ /*intermediary*/ int i; int analysis_type; FILE *IOMODEL = NULL; extern int my_rank; /*Open input file on cpu 0: */ if(my_rank==0) IOMODEL = pfopen(inputfilename ,"rb"); /*Initialize internal data: */ this->nummodels=nummodels; this->solution_type=in_solution_type; this->analysis_counter=nummodels-1; //point to last analysis_type carried out. this->results=new Results(); //not initialized by CreateDataSets /*Dynamically allocate whatever is a list of length nummodels: */ analysis_type_list=xNew(nummodels); /*Initialize: */ for(i=0;ielements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,this->solution_type,nummodels,analyses); /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */ for(i=0;iSetCurrentConfiguration(analysis_type); if(i==0){ if(VerboseMProcessor()) _pprintLine_(" creating vertex degrees of freedom"); VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices } if(VerboseMProcessor()) _pprintLine_(" resolving node constraints"); SpcNodesx(nodes,constraints,parameters,analysis_type); if(VerboseMProcessor()) _pprintLine_(" creating nodal degrees of freedom"); NodesDofx(nodes,parameters,analysis_type); if(VerboseMProcessor()) _pprintLine_(" configuring element and loads"); ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters); } /*Close input file descriptors: */ if(my_rank==0) pfclose(IOMODEL,inputfilename); /*Add output file name to parameters: */ this->parameters->AddObject(new StringParam(OutputfilenameEnum,outputfilename)); } /*}}}*/ /*FUNCTION FemModel::destructor {{{*/ FemModel::~FemModel(){ /*Intermediary*/ int i; /*Delete all the datasets: */ xDelete(analysis_type_list); delete elements; delete nodes; delete vertices; delete constraints; delete loads; delete materials; delete parameters; delete results; } /*}}}*/ /*Object management*/ /*FUNCTION FemModel::Echo {{{*/ void FemModel::Echo(void){ _printLine_("FemModel echo: "); _printLine_(" number of fem models: " << nummodels); _printLine_(" analysis_type_list: "); for(int i=0;iparameters->SetParam(analysis_counter,AnalysisCounterEnum); this->parameters->SetParam(analysis_type,AnalysisTypeEnum); this->parameters->SetParam(configuration_type,ConfigurationTypeEnum); /*configure elements, loads and nodes, for this new analysis: */ this->elements->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters); this->nodes->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters); this->loads->SetCurrentConfiguration(elements, loads, nodes,vertices, materials,parameters); #ifdef _HAVE_PETSC_ /*take care of petsc options, that depend on this analysis type (present only after model processor)*/ if(this->parameters->Exist(PetscOptionsStringsEnum)){ PetscOptionsFromAnalysis(this->parameters,analysis_type); if(VerboseSolver()) _pprintLine_(" petsc Options set for analysis type: " << EnumToStringx(analysis_type)); } #endif } /*}}}*/ /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{*/ void FemModel::SetCurrentConfiguration(int configuration_type){ /*overload: analysis_type = configuration_type: */ this->SetCurrentConfiguration(configuration_type,configuration_type); } /*}}}*/