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

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

Some minor debugging

File size: 4.3 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"
[4009]14#include "../modules/ModelProcessorx/ModelProcessorx.h"
[3982]15#include "./objects.h"
[3775]16#include "../include/include.h"
[3982]17#include "../EnumDefinitions/EnumDefinitions.h"
18#include "../modules/modules.h"
[1881]19
[3982]20/*Object constructors and destructor*/
21/*FUNCTION FemModel::constructor {{{1*/
[4028]22FemModel::FemModel(ConstDataHandle IOMODEL,int in_solution_type,int* analyses, int nummodels){
[1881]23
[4001]24 /*intermediary*/
25 int i;
[4004]26 IoModel* iomodel=NULL;
27 int analysis_type;
[4001]28
[4028]29 /*Initialize internal data: */
[4004]30 this->nummodels=nummodels;
[4028]31 this->solution_type=in_solution_type;
[4004]32 analysis_counter=nummodels-1; //point to last analysis_type carried out.
[3982]33
34 /*Dynamically allocate whatever is a list of length nummodels: */
35 analysis_type_list=(int*)xmalloc(nummodels*sizeof(int));
[4004]36 Rmg=(Mat*)xmalloc(nummodels*sizeof(Mat));
37 Gmn=(Mat*)xmalloc(nummodels*sizeof(Mat));
[4009]38 nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSets*));
[4004]39 yg=(Vec*)xmalloc(nummodels*sizeof(Vec));
40 ys=(Vec*)xmalloc(nummodels*sizeof(Vec));
[1881]41
[4004]42 /*Initialize: */
43 for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
[3982]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
[4004]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");
[4028]58 CreateDataSets(&elements,&nodes,&vertices,&materials,&constraints,&loads,&parameters,iomodel,IOMODEL,solution_type,analysis_type,nummodels,i);
[4004]59
60 _printf_(" create degrees of freedom: \n");
61 VerticesDofx( &partition,&tpartition,vertices,parameters);
[4009]62 NodesDofx(nodes,parameters);
[4004]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");
[4034]80 ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
[4004]81 }
82
83 _printf_(" free ressources:\n");
84 delete iomodel;
[1881]85}
[3982]86/*}}}1*/
87/*FUNCTION FemModel::destructor {{{1*/
[1881]88FemModel::~FemModel(){
89
[4001]90 /*Intermediary*/
[3982]91 int i;
92
93 /*Delete all the datasets: */
94 xfree((void**)&analysis_type_list);
[1881]95 delete elements;
96 delete nodes;
[3417]97 delete vertices;
[3982]98 delete constraints;
[1881]99 delete loads;
100 delete materials;
101 delete parameters;
[2316]102 delete partition;
103 delete tpartition;
[3982]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);
[4009]110 NodeSets* temp_nodesets=nodesets[i];
[3982]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;
[2316]122 delete yg;
[3982]123 delete ys;
[1881]124
125}
[3982]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");
[4001]135 for(int i=0;i<nummodels;i++)printf(" %i: %s\n",i,EnumAsString(analysis_type_list[i]));
[3982]136 printf(" current analysis_type: \n");
[4001]137 printf(" %i: %s\n",analysis_counter,EnumAsString(analysis_type_list[analysis_counter]));
[3982]138
139
140}
[4001]141/*}}}*/
[3982]142
143/*Numerics: */
144/*FUNCTION FemModel::GetCurrentAnalysis {{{1*/
[4001]145int FemModel::GetCurrentAnalysis(){
[3984]146 return analysis_type_list[analysis_counter];
[3982]147}
148/*}}}1*/
149/*FUNCTION FemModel::SetCurrentAnalysis {{{1*/
150void FemModel::SetCurrentAnalysis(int analysis_type){
151 int found=-1;
[4001]152 for(int i=0;i<nummodels;i++){
[3982]153 if (analysis_type_list[i]==analysis_type){
154 found=i;
155 break;
156 }
157 }
[4001]158 if(found!=-1) analysis_counter=found;
159 else ISSMERROR("Could not find analysis_type %s in list of FemModel analyses",EnumAsString(analysis_type));
[3982]160}
161/*}}}1*/
162
Note: See TracBrowser for help on using the repository browser.