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

Last change on this file since 12706 was 12706, checked in by Mathieu Morlighem, 13 years ago

merged trunk-jpl and trunk for revision 12703

File size: 5.5 KB
Line 
1/*!\file FemModel.c
2 * \brief: implementation of the FemModel object
3 */
4
5
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>
13#include "../Container/Container.h"
14#include "../modules/ModelProcessorx/ModelProcessorx.h"
15#include "../io/io.h"
16#include "./objects.h"
17#include "../include/include.h"
18#include "../EnumDefinitions/EnumDefinitions.h"
19#include "../modules/modules.h"
20
21/*Object constructors and destructor*/
22/*FUNCTION FemModel::constructor {{{*/
23FemModel::FemModel(char* inputfilename, char* outputfilename, const int in_solution_type,const int* analyses,const int nummodels){
24
25 /*intermediary*/
26 int i;
27 int analysis_type;
28 FILE *IOMODEL = NULL;
29 extern int my_rank;
30
31 /*Open input file on cpu 0: */
32 if(my_rank==0) IOMODEL = pfopen(inputfilename ,"rb");
33
34 /*Initialize internal data: */
35 this->nummodels=nummodels;
36 this->solution_type=in_solution_type;
37 this->analysis_counter=nummodels-1; //point to last analysis_type carried out.
38 this->results=new Results(); //not initialized by CreateDataSets
39
40 /*Dynamically allocate whatever is a list of length nummodels: */
41 analysis_type_list=xNew<int>(nummodels);
42
43 /*Initialize: */
44 for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
45
46 /*create datasets for all analyses*/
47 ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,this->solution_type,nummodels,analyses);
48
49 /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
50 for(i=0;i<nummodels;i++){
51
52 if(VerboseMProcessor()) _pprintLine_(" Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":");
53 analysis_type=analysis_type_list[i];
54 this->SetCurrentConfiguration(analysis_type);
55
56 if(i==0){
57 if(VerboseMProcessor()) _pprintLine_(" creating vertex degrees of freedom");
58 VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
59 }
60
61 if(VerboseMProcessor()) _pprintLine_(" resolving node constraints");
62 SpcNodesx(nodes,constraints,parameters,analysis_type);
63
64 if(VerboseMProcessor()) _pprintLine_(" creating nodal degrees of freedom");
65 NodesDofx(nodes,parameters,analysis_type);
66
67 if(VerboseMProcessor()) _pprintLine_(" configuring element and loads");
68 ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
69 }
70
71 /*Close input file descriptors: */
72 if(my_rank==0) pfclose(IOMODEL,inputfilename);
73
74 /*Add output file name to parameters: */
75 this->parameters->AddObject(new StringParam(OutputfilenameEnum,outputfilename));
76
77}
78
79/*}}}*/
80/*FUNCTION FemModel::destructor {{{*/
81FemModel::~FemModel(){
82
83 /*Intermediary*/
84 int i;
85
86 /*Delete all the datasets: */
87 xDelete<int>(analysis_type_list);
88 delete elements;
89 delete nodes;
90 delete vertices;
91 delete constraints;
92 delete loads;
93 delete materials;
94 delete parameters;
95 delete results;
96
97}
98/*}}}*/
99
100/*Object management*/
101/*FUNCTION FemModel::Echo {{{*/
102void FemModel::Echo(void){
103
104 _printLine_("FemModel echo: ");
105 _printLine_(" number of fem models: " << nummodels);
106 _printLine_(" analysis_type_list: ");
107 for(int i=0;i<nummodels;i++)_printLine_(" " << i << ": " << EnumToStringx(analysis_type_list[i]));
108 _printLine_(" current analysis_type: ");
109 _printLine_(" " << analysis_counter << ": " << EnumToStringx(analysis_type_list[analysis_counter]));
110
111}
112/*}}}*/
113
114/*Numerics: */
115/*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){{{*/
116void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){
117
118 /*Use configuration_type to setup the analysis counter, the configurations of objects etc ... but use
119 * analysis_type to drive the element numerics. This allows for use of 1 configuration_type for several
120 * analyses. For example: do a SurfaceSlopeX, SurfaceSlopeY, BedSlopeX and BedSlopeY analysis using the
121 * Slope configuration.*/
122
123 int found=-1;
124 for(int i=0;i<nummodels;i++){
125 if (analysis_type_list[i]==configuration_type){
126 found=i;
127 break;
128 }
129 }
130 if(found!=-1) analysis_counter=found;
131 else _error2_("Could not find alias for analysis_type " << EnumToStringx(configuration_type) << " in list of FemModel analyses");
132
133 /*Now, plug analysis_counter and analysis_type inside the parameters: */
134 this->parameters->SetParam(analysis_counter,AnalysisCounterEnum);
135 this->parameters->SetParam(analysis_type,AnalysisTypeEnum);
136 this->parameters->SetParam(configuration_type,ConfigurationTypeEnum);
137
138 /*configure elements, loads and nodes, for this new analysis: */
139 this->elements->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters);
140 this->nodes->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters);
141 this->loads->SetCurrentConfiguration(elements, loads, nodes,vertices, materials,parameters);
142
143 #ifdef _HAVE_PETSC_
144 /*take care of petsc options, that depend on this analysis type (present only after model processor)*/
145 if(this->parameters->Exist(PetscOptionsStringsEnum)){
146 PetscOptionsFromAnalysis(this->parameters,analysis_type);
147 if(VerboseSolver()) _pprintLine_(" petsc Options set for analysis type: " << EnumToStringx(analysis_type));
148 }
149 #endif
150
151}
152/*}}}*/
153/*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{*/
154void FemModel::SetCurrentConfiguration(int configuration_type){
155
156 /*overload: analysis_type = configuration_type: */
157 this->SetCurrentConfiguration(configuration_type,configuration_type);
158}
159/*}}}*/
Note: See TracBrowser for help on using the repository browser.