1 | /*!\file FemModel.c
|
---|
2 | * \brief: implementation of the FemModel object
|
---|
3 | */
|
---|
4 |
|
---|
5 | #ifdef HAVE_CONFIG_H
|
---|
6 | #include "config.h"
|
---|
7 | #else
|
---|
8 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
9 | #endif
|
---|
10 |
|
---|
11 | #include "stdio.h"
|
---|
12 | #include "../shared/shared.h"
|
---|
13 | #include "../include/include.h"
|
---|
14 | #include "./objects.h"
|
---|
15 |
|
---|
16 | /*constructors/destructors*/
|
---|
17 | /*FUNCTION FemModel::FemModel {{{1*/
|
---|
18 | FemModel::FemModel(){
|
---|
19 |
|
---|
20 | elements=NULL;
|
---|
21 | nodes=NULL;
|
---|
22 | vertices=NULL;
|
---|
23 | constraints=NULL;
|
---|
24 | loads=NULL;
|
---|
25 | materials=NULL;
|
---|
26 | parameters=NULL;
|
---|
27 |
|
---|
28 | partition=NULL;
|
---|
29 | tpartition=NULL;
|
---|
30 | yg=NULL;
|
---|
31 | Rmg=NULL;
|
---|
32 | nodesets=NULL;
|
---|
33 | ys=NULL;
|
---|
34 | ys0=NULL;
|
---|
35 | Gmn=NULL;
|
---|
36 |
|
---|
37 | }
|
---|
38 | /*}}}*/
|
---|
39 | /*FUNCTION FemModel::FemModel {{{1*/
|
---|
40 | FemModel::FemModel(DataSet* femmodel_elements,DataSet* femmodel_nodes,DataSet* femmodel_vertices, DataSet* femmodel_constraints,DataSet* femmodel_loads,
|
---|
41 | DataSet* femmodel_materials,Parameters* femmodel_parameters, DofVec* femmodel_partition,DofVec* femmodel_tpartition,DofVec* femmodel_yg,
|
---|
42 | Mat femmodel_Rmg,Mat femmodel_Gmn,NodeSets* femmodel_nodesets,Vec femmodel_ys,Vec femmodel_ys0){
|
---|
43 |
|
---|
44 |
|
---|
45 | elements=femmodel_elements;
|
---|
46 | nodes=femmodel_nodes;
|
---|
47 | vertices=femmodel_vertices;
|
---|
48 | constraints=femmodel_constraints;
|
---|
49 | loads=femmodel_loads;
|
---|
50 | materials=femmodel_materials;
|
---|
51 | parameters=femmodel_parameters;
|
---|
52 |
|
---|
53 | partition=femmodel_partition;
|
---|
54 | tpartition=femmodel_tpartition;
|
---|
55 | yg=femmodel_yg;
|
---|
56 | Rmg=femmodel_Rmg;
|
---|
57 | nodesets=femmodel_nodesets;
|
---|
58 | ys=femmodel_ys;
|
---|
59 | ys0=femmodel_ys0;
|
---|
60 | Gmn=femmodel_Gmn;
|
---|
61 |
|
---|
62 | }
|
---|
63 | /*}}}*/
|
---|
64 | /*FUNCTION FemModel::~FemModel {{{1*/
|
---|
65 | FemModel::~FemModel(){
|
---|
66 |
|
---|
67 | delete elements;
|
---|
68 | delete nodes;
|
---|
69 | delete vertices;
|
---|
70 | delete loads;
|
---|
71 | delete constraints;
|
---|
72 | delete materials;
|
---|
73 | delete parameters;
|
---|
74 |
|
---|
75 | delete partition;
|
---|
76 | delete tpartition;
|
---|
77 | delete yg;
|
---|
78 | MatFree(&Rmg);
|
---|
79 | delete nodesets;
|
---|
80 | VecFree(&ys);
|
---|
81 | VecFree(&ys0);
|
---|
82 | MatFree(&Gmn);
|
---|
83 |
|
---|
84 | }
|
---|
85 | /*}}}*/
|
---|
86 |
|
---|
87 | /*object functions*/
|
---|
88 | /*FUNCTION FemModel::Echo {{{1*/
|
---|
89 | void FemModel::Echo(void){
|
---|
90 |
|
---|
91 | printf("FemModels echo: \n");
|
---|
92 | printf(" elements: %p\n",elements);
|
---|
93 | printf(" nodes: %p\n",nodes);
|
---|
94 | printf(" vertices: %p\n",vertices);
|
---|
95 | printf(" loads: %p\n",loads);
|
---|
96 | printf(" materials: %p\n",materials);
|
---|
97 | printf(" parameters: %p\n",parameters);
|
---|
98 |
|
---|
99 | printf(" partition: %p\n",partition);
|
---|
100 | printf(" tpartition: %p\n",tpartition);
|
---|
101 | printf(" yg: %p\n",yg);
|
---|
102 | printf(" Rmg: %p\n",Rmg);
|
---|
103 | printf(" nodesets: %p\n",nodesets);
|
---|
104 | printf(" ys: %p\n",ys);
|
---|
105 | printf(" ys0: %p\n",ys0);
|
---|
106 | printf(" Gmn: %p\n",Gmn);
|
---|
107 |
|
---|
108 | }
|
---|
109 | /*}}}*/
|
---|
110 | /*FUNCTION FemModel::DeepEcho {{{1*/
|
---|
111 | void FemModel::DeepEcho(void){
|
---|
112 |
|
---|
113 | printf("FemModels echo: \n");
|
---|
114 | printf(" elements: \n");
|
---|
115 | elements->Echo();
|
---|
116 | printf(" nodes: \n");
|
---|
117 | nodes->Echo();
|
---|
118 | printf(" vertices: \n");
|
---|
119 | vertices->Echo();
|
---|
120 | printf(" loads: \n");
|
---|
121 | nodes->Echo();
|
---|
122 | printf(" materials: \n");
|
---|
123 | nodes->Echo();
|
---|
124 | printf(" parameters: \n");
|
---|
125 | nodes->Echo();
|
---|
126 |
|
---|
127 | printf(" partition: \n");
|
---|
128 | partition->Echo();
|
---|
129 | printf(" tpartition: \n");
|
---|
130 | tpartition->Echo();
|
---|
131 | printf(" yg: \n");
|
---|
132 | yg->Echo();
|
---|
133 | printf(" Rmg: \n");
|
---|
134 | MatView(Rmg,PETSC_VIEWER_STDOUT_WORLD);
|
---|
135 | printf(" nodesets: \n");
|
---|
136 | nodesets->Echo();
|
---|
137 | printf(" ys: \n");
|
---|
138 | VecView(ys,PETSC_VIEWER_STDOUT_WORLD);
|
---|
139 | printf(" ys0: \n");
|
---|
140 | VecView(ys0,PETSC_VIEWER_STDOUT_WORLD);
|
---|
141 | printf(" Gmn: \n");
|
---|
142 | MatView(Gmn,PETSC_VIEWER_STDOUT_WORLD);
|
---|
143 |
|
---|
144 | }
|
---|
145 | /*}}}*/
|
---|
146 | /*FUNCTION FemModel::Id {{{1*/
|
---|
147 | int FemModel::Id(void){
|
---|
148 | ISSMERROR("not implemented yet!");
|
---|
149 | }
|
---|
150 | /*}}}*/
|
---|
151 | /*FUNCTION FemModel::MyRank {{{1*/
|
---|
152 | int FemModel::MyRank(void){
|
---|
153 | ISSMERROR("not implemented yet!");
|
---|
154 | }
|
---|
155 | /*}}}*/
|
---|
156 | /*FUNCTION FemModel::Marshall {{{1*/
|
---|
157 | void FemModel::Marshall(char** pmarshalled_dataset){
|
---|
158 | ISSMERROR("not implemented yet!");
|
---|
159 | }
|
---|
160 | /*}}}*/
|
---|
161 | /*FUNCTION FemModel::MarshallSize {{{1*/
|
---|
162 | int FemModel::MarshallSize(void){
|
---|
163 | ISSMERROR("not implemented yet!");
|
---|
164 | }
|
---|
165 | /*}}}*/
|
---|
166 | /*FUNCTION FemModel::Demarshall {{{1*/
|
---|
167 | void FemModel::Demarshall(char** pmarshalled_dataset){
|
---|
168 | ISSMERROR("not implemented yet!");
|
---|
169 | }
|
---|
170 | /*}}}*/
|
---|
171 | /*FUNCTION FemModel::Enum {{{1*/
|
---|
172 | int FemModel::Enum(void){
|
---|
173 | ISSMERROR("not implemented yet!");
|
---|
174 | }
|
---|
175 | /*}}}*/
|
---|
176 | /*FUNCTION FemModel::copy {{{1*/
|
---|
177 | Object* FemModel::copy(void){
|
---|
178 | ISSMERROR("not implemented yet!");
|
---|
179 | }
|
---|
180 | /*}}}*/
|
---|
181 | /*FUNCTION FemModel::FindParam(bool* pinteger,int enum_type) {{{1*/
|
---|
182 | int FemModel::FindParam(bool* pinteger,int enum_type){
|
---|
183 |
|
---|
184 | return parameters->FindParam(pinteger,enum_type);
|
---|
185 |
|
---|
186 | }
|
---|
187 | /*}}}*/
|
---|
188 | /*FUNCTION FemModel::FindParam(int* pinteger,int enum_type) {{{1*/
|
---|
189 | int FemModel::FindParam(int* pinteger,int enum_type){
|
---|
190 |
|
---|
191 | return parameters->FindParam(pinteger,enum_type);
|
---|
192 |
|
---|
193 | }
|
---|
194 | /*}}}*/
|
---|
195 | /*FUNCTION FemModel::FindParam(double* pscalar,int enum_type) {{{1*/
|
---|
196 | int FemModel::FindParam(double* pscalar,int enum_type){
|
---|
197 |
|
---|
198 | return parameters->FindParam(pscalar,enum_type);
|
---|
199 |
|
---|
200 | }
|
---|
201 | /*}}}*/
|
---|
202 | /*FUNCTION FemModel::FindParam(char** pstring,int enum_type) {{{1*/
|
---|
203 | int FemModel::FindParam(char** pstring,int enum_type){
|
---|
204 |
|
---|
205 | return parameters->FindParam(pstring,enum_type);
|
---|
206 |
|
---|
207 | }
|
---|
208 | /*}}}*/
|
---|
209 | /*FUNCTION FemModel::FindParam(char*** pstringarray,int* pM,int enum_type) {{{1*/
|
---|
210 | int FemModel::FindParam(char*** pstringarray,int* pM,int enum_type){
|
---|
211 |
|
---|
212 | return parameters->FindParam(pstringarray,pM,enum_type);
|
---|
213 |
|
---|
214 | }
|
---|
215 | /*}}}*/
|
---|
216 | /*FUNCTION FemModel::FindParam(double** pdoublearray,int* pM,int* pN,int enum_type) {{{1*/
|
---|
217 | int FemModel::FindParam(double** pdoublearray,int* pM,int* pN,int enum_type){
|
---|
218 |
|
---|
219 | return parameters->FindParam(pdoublearray,pM,pN,enum_type);
|
---|
220 |
|
---|
221 | }
|
---|
222 | /*}}}*/
|
---|
223 | /*FUNCTION FemModel::FindParam(double** pdoublearray,int* pM,int enum_type) {{{1*/
|
---|
224 | int FemModel::FindParam(double** pdoublearray,int* pM,int enum_type){
|
---|
225 |
|
---|
226 | return parameters->FindParam(pdoublearray,pM,enum_type);
|
---|
227 |
|
---|
228 | }
|
---|
229 | /*}}}*/
|
---|
230 | /*FUNCTION FemModel::FindParam(Vec* pvec,int enum_type) {{{1*/
|
---|
231 | int FemModel::FindParam(Vec* pvec,int enum_type){
|
---|
232 |
|
---|
233 | return parameters->FindParam(pvec,enum_type);
|
---|
234 |
|
---|
235 | }
|
---|
236 | /*}}}*/
|
---|
237 | /*FUNCTION FemModel::FindParam(Mat* pmat,int enum_type) {{{1*/
|
---|
238 | int FemModel::FindParam(Mat* pmat,int enum_type){
|
---|
239 |
|
---|
240 | return parameters->FindParam(pmat,enum_type);
|
---|
241 |
|
---|
242 | }
|
---|
243 | /*}}}*/
|
---|
244 |
|
---|
245 | /*access to internal data: */
|
---|
246 | /*FUNCTION FemModel::get_elements {{{1*/
|
---|
247 | DataSet* FemModel::get_elements(void){
|
---|
248 | return elements;
|
---|
249 | }
|
---|
250 | /*}}}*/
|
---|
251 | /*FUNCTION FemModel::get_nodes {{{1*/
|
---|
252 | DataSet* FemModel::get_nodes(void){
|
---|
253 | return nodes;
|
---|
254 | }
|
---|
255 | /*}}}*/
|
---|
256 | /*FUNCTION FemModel::get_vertices {{{1*/
|
---|
257 | DataSet* FemModel::get_vertices(void){
|
---|
258 | return vertices;
|
---|
259 | }
|
---|
260 | /*}}}*/
|
---|
261 | /*FUNCTION FemModel::get_constraints {{{1*/
|
---|
262 | DataSet* FemModel::get_constraints(void){
|
---|
263 | return constraints;
|
---|
264 | }
|
---|
265 | /*}}}*/
|
---|
266 | /*FUNCTION FemModel::get_loads {{{1*/
|
---|
267 | DataSet* FemModel::get_loads(void){
|
---|
268 | return loads;
|
---|
269 | }
|
---|
270 | /*}}}*/
|
---|
271 | /*FUNCTION FemModel::get_materials {{{1*/
|
---|
272 | DataSet* FemModel::get_materials(void){
|
---|
273 | return materials;
|
---|
274 | }
|
---|
275 | /*}}}*/
|
---|
276 | /*FUNCTION FemModel::get_parameters {{{1*/
|
---|
277 | Parameters* FemModel::get_parameters(void){
|
---|
278 | return parameters;
|
---|
279 | }
|
---|
280 | /*}}}*/
|
---|
281 | /*FUNCTION FemModel::get_partition {{{1*/
|
---|
282 | DofVec* FemModel::get_partition(void){
|
---|
283 | return partition;
|
---|
284 | }
|
---|
285 | /*}}}*/
|
---|
286 | /*FUNCTION FemModel::get_tpartition {{{1*/
|
---|
287 | DofVec* FemModel::get_tpartition(void){
|
---|
288 | return tpartition;
|
---|
289 | }
|
---|
290 | /*}}}*/
|
---|
291 | /*FUNCTION FemModel::get_yg {{{1*/
|
---|
292 | DofVec* FemModel::get_yg(void){
|
---|
293 | return yg;
|
---|
294 | }
|
---|
295 | /*}}}*/
|
---|
296 | /*FUNCTION FemModel::get_Rmg {{{1*/
|
---|
297 | Mat FemModel::get_Rmg(void){
|
---|
298 | return Rmg;
|
---|
299 | }
|
---|
300 | /*}}}*/
|
---|
301 | /*FUNCTION FemModel::get_nodesets {{{1*/
|
---|
302 | NodeSets* FemModel::get_nodesets(void){
|
---|
303 | return nodesets;
|
---|
304 | }
|
---|
305 | /*}}}*/
|
---|
306 | /*FUNCTION FemModel::get_ys {{{1*/
|
---|
307 | Vec FemModel::get_ys(void){
|
---|
308 | return ys;
|
---|
309 | }
|
---|
310 | /*}}}*/
|
---|
311 | /*FUNCTION FemModel::get_ys0 {{{1*/
|
---|
312 | Vec FemModel::get_ys0(void){
|
---|
313 | return ys0;
|
---|
314 | }
|
---|
315 | /*}}}*/
|
---|
316 | /*FUNCTION FemModel::get_Gmn {{{1*/
|
---|
317 | Mat FemModel::get_Gmn(void){
|
---|
318 | return Gmn;
|
---|
319 | }
|
---|
320 | /*}}}*/
|
---|
321 | /*FUNCTION FemModel::UpdateInputsFromVector(Vec vector, int name, int type){{{1*/
|
---|
322 | void FemModel::UpdateInputsFromVector(Vec vector, int name, int type){
|
---|
323 |
|
---|
324 | double* serial_vector=NULL;
|
---|
325 |
|
---|
326 | if(vector==NULL)return; //don't bother
|
---|
327 |
|
---|
328 | VecToMPISerial(&serial_vector,vector);
|
---|
329 |
|
---|
330 | this->UpdateInputsFromVector(serial_vector,name,type);
|
---|
331 |
|
---|
332 | /*Free ressources:*/
|
---|
333 | xfree((void**)&serial_vector);
|
---|
334 | }
|
---|
335 | /*}}}*/
|
---|
336 | /*FUNCTION FemModel::UpdateInputsFromVector(double* vector, int name, int type){{{1*/
|
---|
337 | void FemModel::UpdateInputsFromVector(double* vector, int name, int type){
|
---|
338 |
|
---|
339 | if(vector==NULL)return; //don't bother
|
---|
340 |
|
---|
341 | elements->UpdateInputsFromVector(vector,name,type);
|
---|
342 | nodes->UpdateInputsFromVector(vector,name,type);
|
---|
343 | vertices->UpdateInputsFromVector(vector,name,type);
|
---|
344 | loads->UpdateInputsFromVector(vector,name,type);
|
---|
345 | materials->UpdateInputsFromVector(vector,name,type);
|
---|
346 | parameters->UpdateInputsFromVector(vector,name,type);
|
---|
347 |
|
---|
348 | }
|
---|
349 | /*}}}*/
|
---|
350 | /*FUNCTION FemModel::UpdateInputsFromVector(int* vector, int name, int type){{{1*/
|
---|
351 | void FemModel::UpdateInputsFromVector(int* vector, int name, int type){
|
---|
352 |
|
---|
353 | if(vector==NULL)return; //don't bother
|
---|
354 |
|
---|
355 | elements->UpdateInputsFromVector(vector,name,type);
|
---|
356 | nodes->UpdateInputsFromVector(vector,name,type);
|
---|
357 | vertices->UpdateInputsFromVector(vector,name,type);
|
---|
358 | loads->UpdateInputsFromVector(vector,name,type);
|
---|
359 | materials->UpdateInputsFromVector(vector,name,type);
|
---|
360 | parameters->UpdateInputsFromVector(vector,name,type);
|
---|
361 |
|
---|
362 | }
|
---|
363 | /*}}}*/
|
---|
364 | /*FUNCTION FemModel::UpdateInputsFromVector(bool* vector, int name, int type){{{1*/
|
---|
365 | void FemModel::UpdateInputsFromVector(bool* vector, int name, int type){
|
---|
366 |
|
---|
367 | if(vector==NULL)return; //don't bother
|
---|
368 |
|
---|
369 | elements->UpdateInputsFromVector(vector,name,type);
|
---|
370 | nodes->UpdateInputsFromVector(vector,name,type);
|
---|
371 | vertices->UpdateInputsFromVector(vector,name,type);
|
---|
372 | loads->UpdateInputsFromVector(vector,name,type);
|
---|
373 | materials->UpdateInputsFromVector(vector,name,type);
|
---|
374 | parameters->UpdateInputsFromVector(vector,name,type);
|
---|
375 |
|
---|
376 | }
|
---|
377 | /*}}}*/
|
---|
378 | /*FUNCTION FemModel::UpdateInputsFromConstant(double constant, int name){{{1*/
|
---|
379 | void FemModel::UpdateInputsFromConstant(double constant, int name){
|
---|
380 |
|
---|
381 | elements->UpdateInputsFromConstant(constant,name);
|
---|
382 | nodes->UpdateInputsFromConstant(constant,name);
|
---|
383 | vertices->UpdateInputsFromConstant(constant,name);
|
---|
384 | loads->UpdateInputsFromConstant(constant,name);
|
---|
385 | materials->UpdateInputsFromConstant(constant,name);
|
---|
386 | parameters->UpdateInputsFromConstant(constant,name);
|
---|
387 |
|
---|
388 | }
|
---|
389 | /*}}}*/
|
---|
390 | /*FUNCTION FemModel::UpdateInputsFromConstant(int constant, int name){{{1*/
|
---|
391 | void FemModel::UpdateInputsFromConstant(int constant, int name){
|
---|
392 |
|
---|
393 | elements->UpdateInputsFromConstant(constant,name);
|
---|
394 | nodes->UpdateInputsFromConstant(constant,name);
|
---|
395 | vertices->UpdateInputsFromConstant(constant,name);
|
---|
396 | loads->UpdateInputsFromConstant(constant,name);
|
---|
397 | materials->UpdateInputsFromConstant(constant,name);
|
---|
398 | parameters->UpdateInputsFromConstant(constant,name);
|
---|
399 |
|
---|
400 | }
|
---|
401 | /*}}}*/
|
---|
402 | /*FUNCTION FemModel::UpdateInputsFromConstant(bool constant, int name){{{1*/
|
---|
403 | void FemModel::UpdateInputsFromConstant(bool constant, int name){
|
---|
404 |
|
---|
405 | elements->UpdateInputsFromConstant(constant,name);
|
---|
406 | nodes->UpdateInputsFromConstant(constant,name);
|
---|
407 | vertices->UpdateInputsFromConstant(constant,name);
|
---|
408 | loads->UpdateInputsFromConstant(constant,name);
|
---|
409 | materials->UpdateInputsFromConstant(constant,name);
|
---|
410 | parameters->UpdateInputsFromConstant(constant,name);
|
---|
411 |
|
---|
412 | }
|
---|
413 | /*}}}*/
|
---|
414 | /*FUNCTION FemModel::UpdateInputsFromSolution(Vec vector, int name, int type){{{1*/
|
---|
415 | void FemModel::UpdateInputsFromSolution(Vec vector,int name, int type){
|
---|
416 |
|
---|
417 | double* serial_vector=NULL;
|
---|
418 |
|
---|
419 | VecToMPISerial(&serial_vector,vector);
|
---|
420 | elements->UpdateInputsFromSolution(serial_vector,name,type);
|
---|
421 |
|
---|
422 | /*Free ressources:*/
|
---|
423 | xfree((void**)&serial_vector);
|
---|
424 |
|
---|
425 | }
|
---|
426 | /*}}}*/
|
---|
427 | /*FUNCTION FemModel::UpdateInputsFromSolution(double* vector, int name, int type){{{1*/
|
---|
428 | void FemModel::UpdateInputsFromSolution(double* vector,int name, int type){
|
---|
429 | ISSMERROR(" not supported yet!");
|
---|
430 | }
|
---|
431 | /*}}}*/
|
---|