source: issm/trunk/src/c/objects/FemModel.cpp@ 4028

Last change on this file since 4028 was 4028, checked in by Eric.Larour, 15 years ago

Thinking about shuffling analysis_type, sub_analysis_type and solution_type

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