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

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

Finished CreateFemModel with one model framework

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