/*!\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(ConstDataHandle IOMODEL,const int in_solution_type,const int* analyses,const int nummodels){ /*intermediary*/ int i; IoModel* iomodel=NULL; int analysis_type; /*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 DataSet(); //not initialized by CreateDataSets this->partition=NULL; this->tpartition=NULL; /*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); _printf_(" create vertex degrees of freedom\n"); VerticesDofx(&partition,&tpartition,vertices,parameters); _printf_(" resolve node constraints\n"); SpcNodesx(nodes,constraints,analysis_type); _printf_(" create nodal degrees of freedom\n"); NodesDofx(nodes,parameters,analysis_type); _printf_(" create nodal constraints vector\n"); CreateNodalConstraintsx(&m_ys[i],nodes,analysis_type); _printf_(" create node sets\n"); BuildNodeSetsx(&m_nodesets[i], nodes,analysis_type); _printf_(" configuring element and loads\n"); ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters); } } /*}}}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; VecFree(&partition); VecFree(&tpartition); for(i=0;iparameters->FindParam(&verbose,VerboseEnum); /*Use configuration_type to setup the analysis counter, the configurations of objects etc ... but use * analysis_type to drive the element numerics. This allows for use of 1 configuration_type for several * analyses. For example: do a SurfaceSlopeX, SurfaceSlopeY, BedSlopeX and BedSlopeY analysis using the * Slope configuration.*/ int found=-1; 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); /*take care of petsc options, that depend on this analysis type: */ PetscOptionsFromAnalysis(this->parameters,analysis_type); verbose=1; if(verbose){ _printf_("Petsc Options set for analysis type: %s\n",EnumToString(analysis_type)); PetscOptionsPrint(stdout); } } /*}}}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*/