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

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

Split results between element results and external results.
element results are held in the Results* dataset of each element.
external results are held in the femmodel->Results* dataset, and hold anything that cannot fit in the elements.

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