source: issm/trunk/src/c/objects/FemModel.cpp@ 6305

Last change on this file since 6305 was 6305, checked in by Mathieu Morlighem, 14 years ago

Added verbose class

File size: 5.7 KB
RevLine 
[1881]1/*!\file FemModel.c
2 * \brief: implementation of the FemModel object
3 */
4
[3982]5
[1881]6#ifdef HAVE_CONFIG_H
7 #include "config.h"
8#else
9#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
10#endif
11
12#include "stdio.h"
[4236]13#include "../Container/Container.h"
[4009]14#include "../modules/ModelProcessorx/ModelProcessorx.h"
[3982]15#include "./objects.h"
[3775]16#include "../include/include.h"
[3982]17#include "../EnumDefinitions/EnumDefinitions.h"
18#include "../modules/modules.h"
[1881]19
[3982]20/*Object constructors and destructor*/
21/*FUNCTION FemModel::constructor {{{1*/
[4295]22FemModel::FemModel(ConstDataHandle IOMODEL,const int in_solution_type,const int* analyses,const int nummodels){
[1881]23
[4001]24 /*intermediary*/
25 int i;
[4004]26 int analysis_type;
[4001]27
[4028]28 /*Initialize internal data: */
[4004]29 this->nummodels=nummodels;
[4028]30 this->solution_type=in_solution_type;
[4063]31 this->analysis_counter=nummodels-1; //point to last analysis_type carried out.
[4050]32 this->results=new DataSet(); //not initialized by CreateDataSets
[3982]33
34 /*Dynamically allocate whatever is a list of length nummodels: */
35 analysis_type_list=(int*)xmalloc(nummodels*sizeof(int));
[4055]36 m_nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSets*));
37 m_ys=(Vec*)xmalloc(nummodels*sizeof(Vec));
[1881]38
[4004]39 /*Initialize: */
40 for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
[4055]41 for(i=0;i<nummodels;i++)m_nodesets[i]=NULL;
42 for(i=0;i<nummodels;i++)m_ys[i]=NULL;
[3982]43
[6273]44 /*create datasets for all analyses*/
[4063]45 ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,this->solution_type,nummodels,analyses);
[4004]46
[4063]47 /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
[4004]48 for(i=0;i<nummodels;i++){
49
[6305]50 if(VerbModProc()) _printf_(" Processing finite element model of analysis %s:\n",EnumToString(analysis_type_list[i]));
[4004]51 analysis_type=analysis_type_list[i];
[4356]52 this->SetCurrentConfiguration(analysis_type);
[4004]53
[6231]54 if(i==0){
[6305]55 if(VerbModProc()) _printf_(" create vertex degrees of freedom\n");
[6231]56 VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
57 }
[5772]58
[6305]59 if(VerbModProc()) _printf_(" resolve node constraints\n");
[5772]60 SpcNodesx(nodes,constraints,analysis_type);
61
[6305]62 if(VerbModProc()) _printf_(" create nodal degrees of freedom\n");
[4229]63 NodesDofx(nodes,parameters,analysis_type);
[5772]64
[6305]65 if(VerbModProc()) _printf_(" create nodal constraints vector\n");
[5772]66 CreateNodalConstraintsx(&m_ys[i],nodes,analysis_type);
[4004]67
[6305]68 if(VerbModProc()) _printf_(" create node sets\n");
[4055]69 BuildNodeSetsx(&m_nodesets[i], nodes,analysis_type);
[4004]70
[6305]71 if(VerbModProc()) _printf_(" configuring element and loads\n");
[4034]72 ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
[4004]73 }
[1881]74}
[3982]75/*}}}1*/
76/*FUNCTION FemModel::destructor {{{1*/
[1881]77FemModel::~FemModel(){
78
[4001]79 /*Intermediary*/
[3982]80 int i;
81
82 /*Delete all the datasets: */
83 xfree((void**)&analysis_type_list);
[1881]84 delete elements;
85 delete nodes;
[3417]86 delete vertices;
[3982]87 delete constraints;
[1881]88 delete loads;
89 delete materials;
90 delete parameters;
[4050]91 delete results;
[3982]92
93 for(i=0;i<nummodels;i++){
[4055]94 NodeSets* temp_nodesets=m_nodesets[i];
95 delete temp_nodesets;
96 Vec temp_ys=m_ys[i];
[3982]97 VecFree(&temp_ys);
98 }
99
100 /*Delete dynamically allocated arrays: */
[4137]101 xfree((void**)&m_nodesets);
102 xfree((void**)&m_ys);
[1881]103
104}
[3982]105/*}}}1*/
106
107/*Object management*/
108/*FUNCTION FemModel::Echo {{{1*/
109void FemModel::Echo(void){
110
111 printf("FemModel echo: \n");
112 printf(" number of fem models: %i\n",nummodels);
113 printf(" analysis_type_list: \n");
[5103]114 for(int i=0;i<nummodels;i++)printf(" %i: %s\n",i,EnumToString(analysis_type_list[i]));
[3982]115 printf(" current analysis_type: \n");
[5103]116 printf(" %i: %s\n",analysis_counter,EnumToString(analysis_type_list[analysis_counter]));
[3982]117
118
119}
[4001]120/*}}}*/
[3982]121
122/*Numerics: */
[4422]123/*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){{{1*/
[4356]124void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){
[4055]125
[6014]126 int verbose=0;
127
128 /*retrieve parameters: */
129 this->parameters->FindParam(&verbose,VerboseEnum);
130
[4356]131 /*Use configuration_type to setup the analysis counter, the configurations of objects etc ... but use
132 * analysis_type to drive the element numerics. This allows for use of 1 configuration_type for several
133 * analyses. For example: do a SurfaceSlopeX, SurfaceSlopeY, BedSlopeX and BedSlopeY analysis using the
[4402]134 * Slope configuration.*/
[4356]135
[3982]136 int found=-1;
[4001]137 for(int i=0;i<nummodels;i++){
[4356]138 if (analysis_type_list[i]==configuration_type){
[3982]139 found=i;
140 break;
141 }
142 }
[4001]143 if(found!=-1) analysis_counter=found;
[5103]144 else ISSMERROR("Could not find alias for analysis_type %s in list of FemModel analyses",EnumToString(configuration_type));
[4055]145
146 /*activate matrices/vectors: */
147 nodesets=m_nodesets[analysis_counter];
148 ys=m_ys[analysis_counter];
149
[4059]150 /*Now, plug analysis_counter and analysis_type inside the parameters: */
151 this->parameters->SetParam(analysis_counter,AnalysisCounterEnum);
152 this->parameters->SetParam(analysis_type,AnalysisTypeEnum);
[4356]153 this->parameters->SetParam(configuration_type,ConfigurationTypeEnum);
[4573]154
155 /*configure elements, loads and nodes, for this new analysis: */
[4575]156 this->elements->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters);
157 this->nodes->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters);
158 this->loads->SetCurrentConfiguration(elements, loads, nodes,vertices, materials,parameters);
[4573]159
[6014]160 /*take care of petsc options, that depend on this analysis type: */
161 PetscOptionsFromAnalysis(this->parameters,analysis_type);
162
163 if(verbose){
[6273]164 _printf_(" petsc Options set for analysis type: %s\n",EnumToString(analysis_type));
[6014]165 }
166
167
[3982]168}
169/*}}}1*/
[4422]170/*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{1*/
[4356]171void FemModel::SetCurrentConfiguration(int configuration_type){
[4059]172
[4356]173 /*overload: analysis_type = configuration_type: */
174 this->SetCurrentConfiguration(configuration_type,configuration_type);
[4055]175}
176/*}}}1*/
Note: See TracBrowser for help on using the repository browser.