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

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

New configuration_type instead of aliases

File size: 5.7 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"
[4236]13#include "../Container/Container.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*/
[4295]22FemModel::FemModel(ConstDataHandle IOMODEL,const int in_solution_type,const int* analyses,const 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;
[4063]32 this->analysis_counter=nummodels-1; //point to last analysis_type carried out.
[4050]33 this->results=new DataSet(); //not initialized by CreateDataSets
[4137]34 this->partition=NULL;
35 this->tpartition=NULL;
[3982]36
37 /*Dynamically allocate whatever is a list of length nummodels: */
38 analysis_type_list=(int*)xmalloc(nummodels*sizeof(int));
[4055]39 m_Rmg=(Mat*)xmalloc(nummodels*sizeof(Mat));
40 m_Gmn=(Mat*)xmalloc(nummodels*sizeof(Mat));
41 m_nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSets*));
42 m_yg=(Vec*)xmalloc(nummodels*sizeof(Vec));
43 m_ys=(Vec*)xmalloc(nummodels*sizeof(Vec));
[1881]44
[4004]45 /*Initialize: */
46 for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
[4055]47 for(i=0;i<nummodels;i++)m_Rmg[i]=NULL;
48 for(i=0;i<nummodels;i++)m_Gmn[i]=NULL;
49 for(i=0;i<nummodels;i++)m_nodesets[i]=NULL;
50 for(i=0;i<nummodels;i++)m_yg[i]=NULL;
51 for(i=0;i<nummodels;i++)m_ys[i]=NULL;
[3982]52
[4063]53 /*create datasets for all analyses: */
54 ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,this->solution_type,nummodels,analyses);
[4004]55
[4063]56 /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
[4004]57 for(i=0;i<nummodels;i++){
58
[4122]59 _printf_(" processing finite element model of analysis %s:\n",EnumAsString(analysis_type_list[i]));
[4004]60 analysis_type=analysis_type_list[i];
[4356]61 this->SetCurrentConfiguration(analysis_type);
[4004]62
[4117]63 _printf_(" create degrees of freedom\n");
[4168]64 VerticesDofx(&partition,&tpartition,vertices,parameters);
[4229]65 NodesDofx(nodes,parameters,analysis_type);
[4004]66
[4117]67 _printf_(" create single point constraints\n");
[4055]68 SpcNodesx( &m_yg[i], nodes,constraints,analysis_type);
[4004]69
[4117]70 _printf_(" create rigid body constraints\n");
[4055]71 MpcNodesx( &m_Rmg[i], nodes,constraints,analysis_type);
[4004]72
[4117]73 _printf_(" create node sets\n");
[4055]74 BuildNodeSetsx(&m_nodesets[i], nodes,analysis_type);
[4004]75
[4117]76 _printf_(" reducing single point constraints vector\n");
[4055]77 Reducevectorgtosx(&m_ys[i], m_yg[i],m_nodesets[i]);
[4004]78
[4117]79 _printf_(" normalizing rigid body constraints matrix\n");
[4055]80 NormalizeConstraintsx(&m_Gmn[i], m_Rmg[i],m_nodesets[i]);
[4004]81
[4117]82 _printf_(" configuring element and loads\n");
[4034]83 ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
[4004]84 }
[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;
[4050]102 delete results;
[4181]103 VecFree(&partition);
104 VecFree(&tpartition);
[3982]105
106 for(i=0;i<nummodels;i++){
[4055]107 Mat temp_Rmg=m_Rmg[i];
[3982]108 MatFree(&temp_Rmg);
[4055]109 Mat temp_Gmn=m_Gmn[i];
[3982]110 MatFree(&temp_Gmn);
[4055]111 NodeSets* temp_nodesets=m_nodesets[i];
112 delete temp_nodesets;
113 Vec temp_yg=m_yg[i];
[3982]114 VecFree(&temp_yg);
[4055]115 Vec temp_ys=m_ys[i];
[3982]116 VecFree(&temp_ys);
117 }
118
119 /*Delete dynamically allocated arrays: */
[4137]120 xfree((void**)&m_Rmg);
121 xfree((void**)&m_Gmn);
122 xfree((void**)&m_nodesets);
123 xfree((void**)&m_yg);
124 xfree((void**)&m_ys);
[1881]125
126}
[3982]127/*}}}1*/
128
129/*Object management*/
130/*FUNCTION FemModel::Echo {{{1*/
131void FemModel::Echo(void){
132
133 printf("FemModel echo: \n");
134 printf(" number of fem models: %i\n",nummodels);
135 printf(" analysis_type_list: \n");
[4001]136 for(int i=0;i<nummodels;i++)printf(" %i: %s\n",i,EnumAsString(analysis_type_list[i]));
[3982]137 printf(" current analysis_type: \n");
[4001]138 printf(" %i: %s\n",analysis_counter,EnumAsString(analysis_type_list[analysis_counter]));
[3982]139
140
141}
[4001]142/*}}}*/
[3982]143
144/*Numerics: */
[4356]145/*FUNCTION FemModel::SetCurrentConfiguration{{{1*/
146void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){
[4055]147
[4356]148 /*Use configuration_type to setup the analysis counter, the configurations of objects etc ... but use
149 * analysis_type to drive the element numerics. This allows for use of 1 configuration_type for several
150 * analyses. For example: do a SurfaceSlopeX, SurfaceSlopeY, BedSlopeX and BedSlopeY analysis using the
151 * SlopeCompute configuration.*/
152
[3982]153 int found=-1;
[4001]154 for(int i=0;i<nummodels;i++){
[4356]155 if (analysis_type_list[i]==configuration_type){
[3982]156 found=i;
157 break;
158 }
159 }
[4001]160 if(found!=-1) analysis_counter=found;
[4356]161 else ISSMERROR("Could not find alias for analysis_type %s in list of FemModel analyses",EnumAsString(configuration_type));
[4055]162
163 /*activate matrices/vectors: */
164 Rmg=m_Rmg[analysis_counter];
165 Gmn=m_Gmn[analysis_counter];
166 nodesets=m_nodesets[analysis_counter];
167 yg=m_yg[analysis_counter];
168 ys=m_ys[analysis_counter];
169
[4059]170 /*Now, plug analysis_counter and analysis_type inside the parameters: */
171 this->parameters->SetParam(analysis_counter,AnalysisCounterEnum);
172 this->parameters->SetParam(analysis_type,AnalysisTypeEnum);
[4356]173 this->parameters->SetParam(configuration_type,ConfigurationTypeEnum);
[3982]174}
175/*}}}1*/
[4356]176/*FUNCTION FemModel::SetCurrentConfiguration{{{1*/
177void FemModel::SetCurrentConfiguration(int configuration_type){
[4059]178
[4356]179 /*overload: analysis_type = configuration_type: */
180 this->SetCurrentConfiguration(configuration_type,configuration_type);
[4055]181}
182/*}}}1*/
Note: See TracBrowser for help on using the repository browser.