/*!\file FemModel.c * \brief: implementation of the FemModel object */ #ifdef HAVE_CONFIG_H #include "config.h" #else #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!" #endif #include "stdio.h" #include "../Container/Container.h" #include "../modules/ModelProcessorx/ModelProcessorx.h" #include "./objects.h" #include "../include/include.h" #include "../EnumDefinitions/EnumDefinitions.h" #include "../modules/modules.h" /*Object constructors and destructor*/ /*FUNCTION FemModel::constructor {{{1*/ FemModel::FemModel(char* inputfilename, char* outputfilename, const int in_solution_type,const int* analyses,const int nummodels){ #ifdef _PARALLEL_ /*intermediary*/ int i; int analysis_type; FILE* IOMODEL; /*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=(int*)xmalloc(nummodels*sizeof(int)); m_nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSets*)); m_ys=(Vec*)xmalloc(nummodels*sizeof(Vec)); /*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){ _printf_(VerboseMProcessor()," create vertex degrees of freedom\n"); VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices } _printf_(VerboseMProcessor()," resolve node constraints\n"); SpcNodesx(nodes,constraints,analysis_type); _printf_(VerboseMProcessor()," create nodal degrees of freedom\n"); NodesDofx(nodes,parameters,analysis_type); _printf_(VerboseMProcessor()," create nodal constraints vector\n"); CreateNodalConstraintsx(&m_ys[i],nodes,analysis_type); _printf_(VerboseMProcessor()," create node sets\n"); BuildNodeSetsx(&m_nodesets[i], nodes,analysis_type); _printf_(VerboseMProcessor()," configuring element and loads\n"); 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)); #endif } /*}}}1*/ /*FUNCTION FemModel::destructor {{{1*/ FemModel::~FemModel(){ /*Intermediary*/ int i; /*Delete all the datasets: */ xfree((void**)&analysis_type_list); delete elements; delete nodes; delete vertices; delete constraints; delete loads; delete materials; delete parameters; delete results; for(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); /*take care of petsc options, that depend on this analysis type: */ PetscOptionsFromAnalysis(this->parameters,analysis_type); _printf_(VerboseSolver()," petsc Options set for analysis type: %s\n",EnumToString(analysis_type)); } /*}}}1*/ /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{1*/ void FemModel::SetCurrentConfiguration(int configuration_type){ /*overload: analysis_type = configuration_type: */ this->SetCurrentConfiguration(configuration_type,configuration_type); } /*}}}1*/