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

Last change on this file since 9002 was 9002, checked in by Eric.Larour, 14 years ago

Implemented transient boundary conditions. Applied to thermal core only for now

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