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