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

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

Spcs and Mpcs now handled on a per analysis basis... getting there

File size: 4.5 KB
RevLine 
[1881]1/*!\file FemModel.c
2 * \brief: implementation of the FemModel object
3 */
4
[3982]5
[1881]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"
[3982]13#include "../DataSet/DataSet.h"
14#include "../modules/FemModelProcessorx/FemModelProcessorx.h"
15#include "./objects.h"
[3775]16#include "../include/include.h"
[3982]17#include "../EnumDefinitions/EnumDefinitions.h"
18#include "../modules/modules.h"
[1881]19
20
[3982]21/*Object constructors and destructor*/
22/*FUNCTION FemModel::constructor {{{1*/
23FemModel::FemModel(int in_nummodels){
[1881]24
[4001]25 /*intermediary*/
26 int i;
27
[3982]28 nummodels=in_nummodels;
[3984]29 analysis_counter=-1;
[3982]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;
[1881]34
[3982]35 Rmg=(Mat*)xmalloc(nummodels*sizeof(Mat));
36 for(i=0;i<nummodels;i++)Rmg[i]=NULL;
[1881]37
[3982]38 Gmn=(Mat*)xmalloc(nummodels*sizeof(Mat));
39 for(i=0;i<nummodels;i++)Gmn[i]=NULL;
[1881]40
[3982]41 nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSet*));
42 for(i=0;i<nummodels;i++)nodesets[i]=NULL;
[1881]43
[3982]44 yg=(Vec*)xmalloc(nummodels*sizeof(Vec));
45 for(i=0;i<nummodels;i++)yg[i]=NULL;
[1881]46
[3982]47 ys=(Vec*)xmalloc(nummodels*sizeof(Vec));
48 for(i=0;i<nummodels;i++)ys[i]=NULL;
49
[1881]50}
[3982]51/*}}}1*/
52/*FUNCTION FemModel::destructor {{{1*/
[1881]53FemModel::~FemModel(){
54
[4001]55 /*Intermediary*/
[3982]56 int i;
57
58 /*Delete all the datasets: */
59 xfree((void**)&analysis_type_list);
[1881]60 delete elements;
61 delete nodes;
[3417]62 delete vertices;
[3982]63 delete constraints;
[1881]64 delete loads;
65 delete materials;
66 delete parameters;
[2316]67 delete partition;
68 delete tpartition;
[3982]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;
[2316]87 delete yg;
[3982]88 delete ys;
[1881]89
90}
[3982]91/*}}}1*/
92
93/*Object management*/
94/*FUNCTION FemModel::Echo {{{1*/
95void FemModel::Echo(void){
96
97 printf("FemModel echo: \n");
98 printf(" number of fem models: %i\n",nummodels);
99 printf(" analysis_type_list: \n");
[4001]100 for(int i=0;i<nummodels;i++)printf(" %i: %s\n",i,EnumAsString(analysis_type_list[i]));
[3982]101 printf(" current analysis_type: \n");
[4001]102 printf(" %i: %s\n",analysis_counter,EnumAsString(analysis_type_list[analysis_counter]));
[3982]103
104
105}
[4001]106/*}}}*/
[3982]107
108/*Numerics: */
109/*FUNCTION FemModel::AddAnalysis(ConstDataHandle FEMMODEL, int analysis_type) {{{1*/
110void FemModel::AddAnalysis(ConstDataHandle IOMODEL, int analysis_type){
111
112 /*Set counter: */
[3984]113 if (analysis_counter==-1)analysis_counter=0;
114 else analysis_counter++;
[3982]115
116 /*intermediary: */
[4001]117 IoModel* iomodel=NULL;
[3982]118
119 _printf_(" fill model with matlab workspace data\n");
[4001]120 iomodel = new IoModel(IOMODEL);
[3982]121
122 _printf_(" create datasets:\n");
[3984]123 CreateDataSets(&elements,&nodes,&vertices,&materials,&constraints,&loads,&parameters,iomodel,IOMODEL,analysis_type,nummodels,analysis_counter);
[3982]124
125 _printf_(" create degrees of freedom: \n");
[4002]126 VerticesDofx( &partition,&tpartition,vertices,parameters);
127 NodesDofx( nodes,parameters);
[3982]128
129 _printf_(" create single point constraints: \n");
[4002]130 SpcNodesx( &yg[analysis_counter], nodes,constraints,analysis_type);
[3982]131
132 _printf_(" create rigid body constraints:\n");
[4003]133 MpcNodesx( &Rmg[analysis_counter], nodes,constraints,analysis_counter);
[3982]134
135 _printf_(" create node sets:\n");
[3984]136 BuildNodeSetsx(&nodesets[analysis_counter], nodes);
[3982]137
138 _printf_(" reducing single point constraints vector:\n");
[4001]139 Reducevectorgtosx(&ys[analysis_counter], yg[analysis_counter],nodesets[analysis_counter]);
[3982]140
141 _printf_(" normalizing rigid body constraints matrix:\n");
[3984]142 NormalizeConstraintsx(&Gmn[analysis_counter], Rmg[analysis_counter],nodesets[analysis_counter]);
[3982]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*/
[4001]155int FemModel::GetCurrentAnalysis(){
[3984]156 return analysis_type_list[analysis_counter];
[3982]157}
158/*}}}1*/
159/*FUNCTION FemModel::SetCurrentAnalysis {{{1*/
160void FemModel::SetCurrentAnalysis(int analysis_type){
161 int found=-1;
[4001]162 for(int i=0;i<nummodels;i++){
[3982]163 if (analysis_type_list[i]==analysis_type){
164 found=i;
165 break;
166 }
167 }
[4001]168 if(found!=-1) analysis_counter=found;
169 else ISSMERROR("Could not find analysis_type %s in list of FemModel analyses",EnumAsString(analysis_type));
[3982]170}
171/*}}}1*/
172
Note: See TracBrowser for help on using the repository browser.