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/FemModelProcessorx/FemModelProcessorx.h"
|
---|
15 | #include "./objects.h"
|
---|
16 | #include "../include/include.h"
|
---|
17 | #include "../EnumDefinitions/EnumDefinitions.h"
|
---|
18 | #include "../modules/modules.h"
|
---|
19 |
|
---|
20 |
|
---|
21 | /*Object constructors and destructor*/
|
---|
22 | /*FUNCTION FemModel::constructor {{{1*/
|
---|
23 | FemModel::FemModel(int in_nummodels){
|
---|
24 |
|
---|
25 | nummodels=in_nummodels;
|
---|
26 | current_analysis_type=-1;
|
---|
27 |
|
---|
28 | /*Dynamically allocate whatever is a list of length nummodels: */
|
---|
29 | analysis_type_list=(int*)xmalloc(nummodels*sizeof(int));
|
---|
30 | for(i=0;i<nummodels;i++)analysis_type_list[i]=NoneAnalysisEnum;
|
---|
31 |
|
---|
32 | Rmg=(Mat*)xmalloc(nummodels*sizeof(Mat));
|
---|
33 | for(i=0;i<nummodels;i++)Rmg[i]=NULL;
|
---|
34 |
|
---|
35 | Gmn=(Mat*)xmalloc(nummodels*sizeof(Mat));
|
---|
36 | for(i=0;i<nummodels;i++)Gmn[i]=NULL;
|
---|
37 |
|
---|
38 | nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSet*));
|
---|
39 | for(i=0;i<nummodels;i++)nodesets[i]=NULL;
|
---|
40 |
|
---|
41 | yg=(Vec*)xmalloc(nummodels*sizeof(Vec));
|
---|
42 | for(i=0;i<nummodels;i++)yg[i]=NULL;
|
---|
43 |
|
---|
44 | ys=(Vec*)xmalloc(nummodels*sizeof(Vec));
|
---|
45 | for(i=0;i<nummodels;i++)ys[i]=NULL;
|
---|
46 |
|
---|
47 | }
|
---|
48 | /*}}}1*/
|
---|
49 | /*FUNCTION FemModel::destructor {{{1*/
|
---|
50 | FemModel::~FemModel(){
|
---|
51 |
|
---|
52 | int i;
|
---|
53 |
|
---|
54 | /*Delete all the datasets: */
|
---|
55 | xfree((void**)&analysis_type_list);
|
---|
56 | delete elements;
|
---|
57 | delete nodes;
|
---|
58 | delete vertices;
|
---|
59 | delete constraints;
|
---|
60 | delete loads;
|
---|
61 | delete materials;
|
---|
62 | delete parameters;
|
---|
63 | delete partition;
|
---|
64 | delete tpartition;
|
---|
65 |
|
---|
66 | for(i=0;i<nummodels;i++){
|
---|
67 | Mat temp_Rmg=Rmg[i];
|
---|
68 | MatFree(&temp_Rmg);
|
---|
69 | Mat temp_Gmn=Gmn[i];
|
---|
70 | MatFree(&temp_Gmn);
|
---|
71 | NodeSet* temp_nodesets=nodesets[i];
|
---|
72 | delete nodesets;
|
---|
73 | Vec temp_yg=yg[i];
|
---|
74 | VecFree(&temp_yg);
|
---|
75 | Vec temp_ys=ys[i];
|
---|
76 | VecFree(&temp_ys);
|
---|
77 | }
|
---|
78 |
|
---|
79 | /*Delete dynamically allocated arrays: */
|
---|
80 | delete Rmg;
|
---|
81 | delete Gmn;
|
---|
82 | delete nodesets;
|
---|
83 | delete yg;
|
---|
84 | delete ys;
|
---|
85 |
|
---|
86 | }
|
---|
87 | /*}}}1*/
|
---|
88 |
|
---|
89 | /*Object management*/
|
---|
90 | /*FUNCTION FemModel::Echo {{{1*/
|
---|
91 |
|
---|
92 | void FemModel::Echo(void){
|
---|
93 |
|
---|
94 | printf("FemModel echo: \n");
|
---|
95 | printf(" number of fem models: %i\n",nummodels);
|
---|
96 | printf(" analysis_type_list: \n");
|
---|
97 | for(i=0;i<nummodels;i++)printf(" %i: %s\n",i,EnumAsString(analysis_type_list[i]));
|
---|
98 | printf(" current analysis_type: \n");
|
---|
99 | printf(" %i: %s\n",i,EnumAsString(analysis_type_list[current_analysis_type]));
|
---|
100 |
|
---|
101 |
|
---|
102 | }
|
---|
103 | /*}}}1*/
|
---|
104 |
|
---|
105 | /*Numerics: */
|
---|
106 | /*FUNCTION FemModel::AddAnalysis(ConstDataHandle FEMMODEL, int analysis_type) {{{1*/
|
---|
107 | void FemModel::AddAnalysis(ConstDataHandle IOMODEL, int analysis_type){
|
---|
108 |
|
---|
109 |
|
---|
110 | int i; //practical counter
|
---|
111 |
|
---|
112 | /*Set counter: */
|
---|
113 | if (current_analysis_type==-1)current_analysis_type=0;
|
---|
114 | else current_analysis_type++;
|
---|
115 |
|
---|
116 | i=current_analysis_type;
|
---|
117 |
|
---|
118 | /*intermediary: */
|
---|
119 | IoFemModel* iomodel=NULL;
|
---|
120 |
|
---|
121 | _printf_(" fill model with matlab workspace data\n");
|
---|
122 | iomodel=new IoFemModel(IOMODEL);
|
---|
123 |
|
---|
124 | _printf_(" create datasets:\n");
|
---|
125 | CreateDataSets(&elements,&nodes,&vertices,&materials,&constraints,&loads,¶meters,iomodel,IOMODEL,analysis_type);
|
---|
126 |
|
---|
127 | _printf_(" create degrees of freedom: \n");
|
---|
128 | Dofx( &partition,&tpartition,elements,nodes, vertices,parameters);
|
---|
129 |
|
---|
130 | _printf_(" create single point constraints: \n");
|
---|
131 | SpcNodesx( &yg[i], nodes,constraints);
|
---|
132 |
|
---|
133 | _printf_(" create rigid body constraints:\n");
|
---|
134 | MpcNodesx( &Rmg[i], nodes,constraints);
|
---|
135 |
|
---|
136 | _printf_(" create node sets:\n");
|
---|
137 | BuildNodeSetsx(&nodesets[i], nodes);
|
---|
138 |
|
---|
139 | _printf_(" reducing single point constraints vector:\n");
|
---|
140 | Reducevectorgtosx(&ys[i], yg[i]->vector,nodesets[i]);
|
---|
141 |
|
---|
142 | _printf_(" normalizing rigid body constraints matrix:\n");
|
---|
143 | NormalizeConstraintsx(&Gmn[i], Rmg[i],nodesets[i]);
|
---|
144 |
|
---|
145 | _printf_(" configuring element and loads:\n");
|
---|
146 | ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
|
---|
147 |
|
---|
148 | _printf_(" process parameters:\n");
|
---|
149 | ProcessParamsx( parameters, partition->vector);
|
---|
150 |
|
---|
151 | _printf_(" free ressources:\n");
|
---|
152 | delete iomodel;
|
---|
153 | }
|
---|
154 | /*}}}1*/
|
---|
155 | /*FUNCTION FemModel::GetCurrentAnalysis {{{1*/
|
---|
156 | FemFemModel* FemModel::GetCurrentAnalysis(){
|
---|
157 | return analysis_type_list[current_analysis_type];
|
---|
158 | }
|
---|
159 | /*}}}1*/
|
---|
160 | /*FUNCTION FemModel::SetCurrentAnalysis {{{1*/
|
---|
161 | void FemModel::SetCurrentAnalysis(int analysis_type){
|
---|
162 | int found=-1;
|
---|
163 | for(i=0;i<nummodels;i++){
|
---|
164 | if (analysis_type_list[i]==analysis_type){
|
---|
165 | found=i;
|
---|
166 | break;
|
---|
167 | }
|
---|
168 | }
|
---|
169 | if(found)current_analysis_type=i;
|
---|
170 | else ISSMERRR("%s%s%s"," could not find analysis_type ",EnumAsString(analysis_type) " in list of FemModel analyses");
|
---|
171 | }
|
---|
172 | /*}}}1*/
|
---|
173 |
|
---|