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*/
|
---|
22 | FemModel::FemModel(ConstDataHandle IOMODEL,const int in_solution_type,const int* analyses,const int nummodels){
|
---|
23 |
|
---|
24 | /*intermediary*/
|
---|
25 | int i;
|
---|
26 | int analysis_type;
|
---|
27 | int verbosity_level;
|
---|
28 | bool verbose;
|
---|
29 |
|
---|
30 | /*Initialize internal data: */
|
---|
31 | this->nummodels=nummodels;
|
---|
32 | this->solution_type=in_solution_type;
|
---|
33 | this->analysis_counter=nummodels-1; //point to last analysis_type carried out.
|
---|
34 | this->results=new DataSet(); //not initialized by CreateDataSets
|
---|
35 |
|
---|
36 | /*Dynamically allocate whatever is a list of length nummodels: */
|
---|
37 | analysis_type_list=(int*)xmalloc(nummodels*sizeof(int));
|
---|
38 | m_nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSets*));
|
---|
39 | m_ys=(Vec*)xmalloc(nummodels*sizeof(Vec));
|
---|
40 |
|
---|
41 | /*Initialize: */
|
---|
42 | for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
|
---|
43 | for(i=0;i<nummodels;i++)m_nodesets[i]=NULL;
|
---|
44 | for(i=0;i<nummodels;i++)m_ys[i]=NULL;
|
---|
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 | /*Shall we verbose?*/
|
---|
50 | this->parameters->FindParam(&verbosity_level,VerboseEnum); verbose=IsModelProcessorVerbosity(verbosity_level);
|
---|
51 |
|
---|
52 | /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
|
---|
53 | for(i=0;i<nummodels;i++){
|
---|
54 |
|
---|
55 | if(verbose) _printf_(" processing finite element model of analysis %s:\n",EnumToString(analysis_type_list[i]));
|
---|
56 | analysis_type=analysis_type_list[i];
|
---|
57 | this->SetCurrentConfiguration(analysis_type);
|
---|
58 |
|
---|
59 | if(i==0){
|
---|
60 | if(verbose) _printf_(" create vertex degrees of freedom\n");
|
---|
61 | VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
|
---|
62 | }
|
---|
63 |
|
---|
64 | if(verbose) _printf_(" resolve node constraints\n");
|
---|
65 | SpcNodesx(nodes,constraints,analysis_type);
|
---|
66 |
|
---|
67 | if(verbose) _printf_(" create nodal degrees of freedom\n");
|
---|
68 | NodesDofx(nodes,parameters,analysis_type);
|
---|
69 |
|
---|
70 | if(verbose) _printf_(" create nodal constraints vector\n");
|
---|
71 | CreateNodalConstraintsx(&m_ys[i],nodes,analysis_type);
|
---|
72 |
|
---|
73 | if(verbose) _printf_(" create node sets\n");
|
---|
74 | BuildNodeSetsx(&m_nodesets[i], nodes,analysis_type);
|
---|
75 |
|
---|
76 | if(verbose) _printf_(" configuring element and loads\n");
|
---|
77 | ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
|
---|
78 | }
|
---|
79 | }
|
---|
80 | /*}}}1*/
|
---|
81 | /*FUNCTION FemModel::destructor {{{1*/
|
---|
82 | FemModel::~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 | for(i=0;i<nummodels;i++){
|
---|
99 | NodeSets* temp_nodesets=m_nodesets[i];
|
---|
100 | delete temp_nodesets;
|
---|
101 | Vec temp_ys=m_ys[i];
|
---|
102 | VecFree(&temp_ys);
|
---|
103 | }
|
---|
104 |
|
---|
105 | /*Delete dynamically allocated arrays: */
|
---|
106 | xfree((void**)&m_nodesets);
|
---|
107 | xfree((void**)&m_ys);
|
---|
108 |
|
---|
109 | }
|
---|
110 | /*}}}1*/
|
---|
111 |
|
---|
112 | /*Object management*/
|
---|
113 | /*FUNCTION FemModel::Echo {{{1*/
|
---|
114 | void FemModel::Echo(void){
|
---|
115 |
|
---|
116 | printf("FemModel echo: \n");
|
---|
117 | printf(" number of fem models: %i\n",nummodels);
|
---|
118 | printf(" analysis_type_list: \n");
|
---|
119 | for(int i=0;i<nummodels;i++)printf(" %i: %s\n",i,EnumToString(analysis_type_list[i]));
|
---|
120 | printf(" current analysis_type: \n");
|
---|
121 | printf(" %i: %s\n",analysis_counter,EnumToString(analysis_type_list[analysis_counter]));
|
---|
122 |
|
---|
123 |
|
---|
124 | }
|
---|
125 | /*}}}*/
|
---|
126 |
|
---|
127 | /*Numerics: */
|
---|
128 | /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){{{1*/
|
---|
129 | void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){
|
---|
130 |
|
---|
131 | int verbose=0;
|
---|
132 |
|
---|
133 | /*retrieve parameters: */
|
---|
134 | this->parameters->FindParam(&verbose,VerboseEnum);
|
---|
135 |
|
---|
136 | /*Use configuration_type to setup the analysis counter, the configurations of objects etc ... but use
|
---|
137 | * analysis_type to drive the element numerics. This allows for use of 1 configuration_type for several
|
---|
138 | * analyses. For example: do a SurfaceSlopeX, SurfaceSlopeY, BedSlopeX and BedSlopeY analysis using the
|
---|
139 | * Slope configuration.*/
|
---|
140 |
|
---|
141 | int found=-1;
|
---|
142 | for(int i=0;i<nummodels;i++){
|
---|
143 | if (analysis_type_list[i]==configuration_type){
|
---|
144 | found=i;
|
---|
145 | break;
|
---|
146 | }
|
---|
147 | }
|
---|
148 | if(found!=-1) analysis_counter=found;
|
---|
149 | else ISSMERROR("Could not find alias for analysis_type %s in list of FemModel analyses",EnumToString(configuration_type));
|
---|
150 |
|
---|
151 | /*activate matrices/vectors: */
|
---|
152 | nodesets=m_nodesets[analysis_counter];
|
---|
153 | ys=m_ys[analysis_counter];
|
---|
154 |
|
---|
155 | /*Now, plug analysis_counter and analysis_type inside the parameters: */
|
---|
156 | this->parameters->SetParam(analysis_counter,AnalysisCounterEnum);
|
---|
157 | this->parameters->SetParam(analysis_type,AnalysisTypeEnum);
|
---|
158 | this->parameters->SetParam(configuration_type,ConfigurationTypeEnum);
|
---|
159 |
|
---|
160 | /*configure elements, loads and nodes, for this new analysis: */
|
---|
161 | this->elements->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters);
|
---|
162 | this->nodes->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters);
|
---|
163 | this->loads->SetCurrentConfiguration(elements, loads, nodes,vertices, materials,parameters);
|
---|
164 |
|
---|
165 | /*take care of petsc options, that depend on this analysis type: */
|
---|
166 | PetscOptionsFromAnalysis(this->parameters,analysis_type);
|
---|
167 |
|
---|
168 | if(verbose){
|
---|
169 | _printf_(" petsc Options set for analysis type: %s\n",EnumToString(analysis_type));
|
---|
170 | }
|
---|
171 |
|
---|
172 |
|
---|
173 | }
|
---|
174 | /*}}}1*/
|
---|
175 | /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{1*/
|
---|
176 | void FemModel::SetCurrentConfiguration(int configuration_type){
|
---|
177 |
|
---|
178 | /*overload: analysis_type = configuration_type: */
|
---|
179 | this->SetCurrentConfiguration(configuration_type,configuration_type);
|
---|
180 | }
|
---|
181 | /*}}}1*/
|
---|