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 "../DataSet/DataSet.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,int in_solution_type,int* analyses, int nummodels){
|
---|
23 |
|
---|
24 | /*intermediary*/
|
---|
25 | int i;
|
---|
26 | IoModel* iomodel=NULL;
|
---|
27 | int analysis_type;
|
---|
28 |
|
---|
29 | /*Initialize internal data: */
|
---|
30 | this->nummodels=nummodels;
|
---|
31 | this->solution_type=in_solution_type;
|
---|
32 | analysis_counter=nummodels-1; //point to last analysis_type carried out.
|
---|
33 | this->results=new DataSet(); //not initialized by CreateDataSets
|
---|
34 |
|
---|
35 | /*Dynamically allocate whatever is a list of length nummodels: */
|
---|
36 | analysis_type_list=(int*)xmalloc(nummodels*sizeof(int));
|
---|
37 | m_Rmg=(Mat*)xmalloc(nummodels*sizeof(Mat));
|
---|
38 | m_Gmn=(Mat*)xmalloc(nummodels*sizeof(Mat));
|
---|
39 | m_nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSets*));
|
---|
40 | m_yg=(Vec*)xmalloc(nummodels*sizeof(Vec));
|
---|
41 | m_ys=(Vec*)xmalloc(nummodels*sizeof(Vec));
|
---|
42 |
|
---|
43 | /*Initialize: */
|
---|
44 | for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
|
---|
45 | for(i=0;i<nummodels;i++)m_Rmg[i]=NULL;
|
---|
46 | for(i=0;i<nummodels;i++)m_Gmn[i]=NULL;
|
---|
47 | for(i=0;i<nummodels;i++)m_nodesets[i]=NULL;
|
---|
48 | for(i=0;i<nummodels;i++)m_yg[i]=NULL;
|
---|
49 | for(i=0;i<nummodels;i++)m_ys[i]=NULL;
|
---|
50 |
|
---|
51 | _printf_(" fill model with matlab workspace data\n");
|
---|
52 | iomodel = new IoModel(IOMODEL);
|
---|
53 |
|
---|
54 | for(i=0;i<nummodels;i++){
|
---|
55 |
|
---|
56 | analysis_type=analysis_type_list[i];
|
---|
57 |
|
---|
58 | _printf_(" create datasets:\n");
|
---|
59 | CreateDataSets(&elements,&nodes,&vertices,&materials,&constraints,&loads,¶meters,iomodel,IOMODEL,solution_type,analysis_type,nummodels,i);
|
---|
60 |
|
---|
61 | _printf_(" create degrees of freedom: \n");
|
---|
62 | VerticesDofx( &partition,&tpartition,vertices,parameters);
|
---|
63 | NodesDofx(nodes,parameters);
|
---|
64 |
|
---|
65 | _printf_(" create single point constraints: \n");
|
---|
66 | SpcNodesx( &m_yg[i], nodes,constraints,analysis_type);
|
---|
67 |
|
---|
68 | _printf_(" create rigid body constraints:\n");
|
---|
69 | MpcNodesx( &m_Rmg[i], nodes,constraints,analysis_type);
|
---|
70 |
|
---|
71 | _printf_(" create node sets:\n");
|
---|
72 | BuildNodeSetsx(&m_nodesets[i], nodes,analysis_type);
|
---|
73 |
|
---|
74 | _printf_(" reducing single point constraints vector:\n");
|
---|
75 | Reducevectorgtosx(&m_ys[i], m_yg[i],m_nodesets[i]);
|
---|
76 |
|
---|
77 | _printf_(" normalizing rigid body constraints matrix:\n");
|
---|
78 | NormalizeConstraintsx(&m_Gmn[i], m_Rmg[i],m_nodesets[i]);
|
---|
79 |
|
---|
80 | _printf_(" configuring element and loads:\n");
|
---|
81 | ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
|
---|
82 | }
|
---|
83 |
|
---|
84 | _printf_(" free ressources:\n");
|
---|
85 | delete iomodel;
|
---|
86 | }
|
---|
87 | /*}}}1*/
|
---|
88 | /*FUNCTION FemModel::destructor {{{1*/
|
---|
89 | FemModel::~FemModel(){
|
---|
90 |
|
---|
91 | /*Intermediary*/
|
---|
92 | int i;
|
---|
93 |
|
---|
94 | /*Delete all the datasets: */
|
---|
95 | xfree((void**)&analysis_type_list);
|
---|
96 | delete elements;
|
---|
97 | delete nodes;
|
---|
98 | delete vertices;
|
---|
99 | delete constraints;
|
---|
100 | delete loads;
|
---|
101 | delete materials;
|
---|
102 | delete parameters;
|
---|
103 | delete results;
|
---|
104 | delete partition;
|
---|
105 | delete tpartition;
|
---|
106 |
|
---|
107 | for(i=0;i<nummodels;i++){
|
---|
108 | Mat temp_Rmg=m_Rmg[i];
|
---|
109 | MatFree(&temp_Rmg);
|
---|
110 | Mat temp_Gmn=m_Gmn[i];
|
---|
111 | MatFree(&temp_Gmn);
|
---|
112 | NodeSets* temp_nodesets=m_nodesets[i];
|
---|
113 | delete temp_nodesets;
|
---|
114 | Vec temp_yg=m_yg[i];
|
---|
115 | VecFree(&temp_yg);
|
---|
116 | Vec temp_ys=m_ys[i];
|
---|
117 | VecFree(&temp_ys);
|
---|
118 | }
|
---|
119 |
|
---|
120 | /*Delete dynamically allocated arrays: */
|
---|
121 | delete m_Rmg;
|
---|
122 | delete m_Gmn;
|
---|
123 | delete m_nodesets;
|
---|
124 | delete m_yg;
|
---|
125 | delete m_ys;
|
---|
126 |
|
---|
127 | }
|
---|
128 | /*}}}1*/
|
---|
129 |
|
---|
130 | /*Object management*/
|
---|
131 | /*FUNCTION FemModel::Echo {{{1*/
|
---|
132 | void FemModel::Echo(void){
|
---|
133 |
|
---|
134 | printf("FemModel echo: \n");
|
---|
135 | printf(" number of fem models: %i\n",nummodels);
|
---|
136 | printf(" analysis_type_list: \n");
|
---|
137 | for(int i=0;i<nummodels;i++)printf(" %i: %s\n",i,EnumAsString(analysis_type_list[i]));
|
---|
138 | printf(" current analysis_type: \n");
|
---|
139 | printf(" %i: %s\n",analysis_counter,EnumAsString(analysis_type_list[analysis_counter]));
|
---|
140 |
|
---|
141 |
|
---|
142 | }
|
---|
143 | /*}}}*/
|
---|
144 |
|
---|
145 | /*Numerics: */
|
---|
146 | /*FUNCTION FemModel::GetCurrentAnalysis {{{1*/
|
---|
147 | int FemModel::GetCurrentAnalysis(){
|
---|
148 | return analysis_type_list[analysis_counter];
|
---|
149 | }
|
---|
150 | /*}}}1*/
|
---|
151 | /*FUNCTION FemModel::SetCurrentAnalysis {{{1*/
|
---|
152 | void FemModel::SetCurrentAnalysis(int analysis_type){
|
---|
153 |
|
---|
154 | int found=-1;
|
---|
155 | for(int i=0;i<nummodels;i++){
|
---|
156 | if (analysis_type_list[i]==analysis_type){
|
---|
157 | found=i;
|
---|
158 | break;
|
---|
159 | }
|
---|
160 | }
|
---|
161 | if(found!=-1) analysis_counter=found;
|
---|
162 | else ISSMERROR("Could not find analysis_type %s in list of FemModel analyses",EnumAsString(analysis_type));
|
---|
163 |
|
---|
164 | /*activate matrices/vectors: */
|
---|
165 | Rmg=m_Rmg[analysis_counter];
|
---|
166 | Gmn=m_Gmn[analysis_counter];
|
---|
167 | nodesets=m_nodesets[analysis_counter];
|
---|
168 | yg=m_yg[analysis_counter];
|
---|
169 | ys=m_ys[analysis_counter];
|
---|
170 |
|
---|
171 | }
|
---|
172 | /*}}}1*/
|
---|
173 | /*FUNCTION FemModel::SetCurrentAnalysisAlias {{{1*/
|
---|
174 | void FemModel::SetCurrentAnalysisAlias(int base_analysis_type,int real_analysis_type){
|
---|
175 | int found=-1;
|
---|
176 | for(int i=0;i<nummodels;i++){
|
---|
177 | if (analysis_type_list[i]==base_analysis_type){
|
---|
178 | found=i;
|
---|
179 | break;
|
---|
180 | }
|
---|
181 | }
|
---|
182 | if(found!=-1) analysis_counter=found;
|
---|
183 | else ISSMERROR("Could not find alias for analysis_type %s in list of FemModel analyses",EnumAsString(base_analysis_type));
|
---|
184 | }
|
---|
185 | /*}}}1*/
|
---|
186 |
|
---|