[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] | 22 | FemModel::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;
|
---|
[4063] | 32 | this->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));
|
---|
[4055] | 37 | m_Rmg=(Mat*)xmalloc(nummodels*sizeof(Mat));
|
---|
| 38 | m_Gmn=(Mat*)xmalloc(nummodels*sizeof(Mat));
|
---|
| 39 | m_nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSets*));
|
---|
| 40 | m_yg=(Vec*)xmalloc(nummodels*sizeof(Vec));
|
---|
| 41 | m_ys=(Vec*)xmalloc(nummodels*sizeof(Vec));
|
---|
[1881] | 42 |
|
---|
[4004] | 43 | /*Initialize: */
|
---|
| 44 | for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
|
---|
[4055] | 45 | for(i=0;i<nummodels;i++)m_Rmg[i]=NULL;
|
---|
| 46 | for(i=0;i<nummodels;i++)m_Gmn[i]=NULL;
|
---|
| 47 | for(i=0;i<nummodels;i++)m_nodesets[i]=NULL;
|
---|
| 48 | for(i=0;i<nummodels;i++)m_yg[i]=NULL;
|
---|
| 49 | for(i=0;i<nummodels;i++)m_ys[i]=NULL;
|
---|
[3982] | 50 |
|
---|
[4063] | 51 | /*create datasets for all analyses: */
|
---|
| 52 | ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,this->solution_type,nummodels,analyses);
|
---|
[4004] | 53 |
|
---|
[4063] | 54 | /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
|
---|
[4004] | 55 | for(i=0;i<nummodels;i++){
|
---|
| 56 |
|
---|
| 57 | analysis_type=analysis_type_list[i];
|
---|
[4117] | 58 | _printf_(" processing finite element model of analysis %s:\n",EnumAsString(analysis_type));
|
---|
[4004] | 59 |
|
---|
[4117] | 60 | _printf_(" create degrees of freedom\n");
|
---|
[4004] | 61 | VerticesDofx( &partition,&tpartition,vertices,parameters);
|
---|
[4009] | 62 | NodesDofx(nodes,parameters);
|
---|
[4004] | 63 |
|
---|
[4117] | 64 | _printf_(" create single point constraints\n");
|
---|
[4055] | 65 | SpcNodesx( &m_yg[i], nodes,constraints,analysis_type);
|
---|
[4004] | 66 |
|
---|
[4117] | 67 | _printf_(" create rigid body constraints\n");
|
---|
[4055] | 68 | MpcNodesx( &m_Rmg[i], nodes,constraints,analysis_type);
|
---|
[4004] | 69 |
|
---|
[4117] | 70 | _printf_(" create node sets\n");
|
---|
[4055] | 71 | BuildNodeSetsx(&m_nodesets[i], nodes,analysis_type);
|
---|
[4004] | 72 |
|
---|
[4117] | 73 | _printf_(" reducing single point constraints vector\n");
|
---|
[4055] | 74 | Reducevectorgtosx(&m_ys[i], m_yg[i],m_nodesets[i]);
|
---|
[4004] | 75 |
|
---|
[4117] | 76 | _printf_(" normalizing rigid body constraints matrix\n");
|
---|
[4055] | 77 | NormalizeConstraintsx(&m_Gmn[i], m_Rmg[i],m_nodesets[i]);
|
---|
[4004] | 78 |
|
---|
[4117] | 79 | _printf_(" configuring element and loads\n");
|
---|
[4034] | 80 | ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
|
---|
[4004] | 81 | }
|
---|
[1881] | 82 | }
|
---|
[3982] | 83 | /*}}}1*/
|
---|
| 84 | /*FUNCTION FemModel::destructor {{{1*/
|
---|
[1881] | 85 | FemModel::~FemModel(){
|
---|
| 86 |
|
---|
[4001] | 87 | /*Intermediary*/
|
---|
[3982] | 88 | int i;
|
---|
| 89 |
|
---|
| 90 | /*Delete all the datasets: */
|
---|
| 91 | xfree((void**)&analysis_type_list);
|
---|
[1881] | 92 | delete elements;
|
---|
| 93 | delete nodes;
|
---|
[3417] | 94 | delete vertices;
|
---|
[3982] | 95 | delete constraints;
|
---|
[1881] | 96 | delete loads;
|
---|
| 97 | delete materials;
|
---|
| 98 | delete parameters;
|
---|
[4050] | 99 | delete results;
|
---|
[2316] | 100 | delete partition;
|
---|
| 101 | delete tpartition;
|
---|
[3982] | 102 |
|
---|
| 103 | for(i=0;i<nummodels;i++){
|
---|
[4055] | 104 | Mat temp_Rmg=m_Rmg[i];
|
---|
[3982] | 105 | MatFree(&temp_Rmg);
|
---|
[4055] | 106 | Mat temp_Gmn=m_Gmn[i];
|
---|
[3982] | 107 | MatFree(&temp_Gmn);
|
---|
[4055] | 108 | NodeSets* temp_nodesets=m_nodesets[i];
|
---|
| 109 | delete temp_nodesets;
|
---|
| 110 | Vec temp_yg=m_yg[i];
|
---|
[3982] | 111 | VecFree(&temp_yg);
|
---|
[4055] | 112 | Vec temp_ys=m_ys[i];
|
---|
[3982] | 113 | VecFree(&temp_ys);
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | /*Delete dynamically allocated arrays: */
|
---|
[4055] | 117 | delete m_Rmg;
|
---|
| 118 | delete m_Gmn;
|
---|
| 119 | delete m_nodesets;
|
---|
| 120 | delete m_yg;
|
---|
| 121 | delete m_ys;
|
---|
[1881] | 122 |
|
---|
| 123 | }
|
---|
[3982] | 124 | /*}}}1*/
|
---|
| 125 |
|
---|
| 126 | /*Object management*/
|
---|
| 127 | /*FUNCTION FemModel::Echo {{{1*/
|
---|
| 128 | void FemModel::Echo(void){
|
---|
| 129 |
|
---|
| 130 | printf("FemModel echo: \n");
|
---|
| 131 | printf(" number of fem models: %i\n",nummodels);
|
---|
| 132 | printf(" analysis_type_list: \n");
|
---|
[4001] | 133 | for(int i=0;i<nummodels;i++)printf(" %i: %s\n",i,EnumAsString(analysis_type_list[i]));
|
---|
[3982] | 134 | printf(" current analysis_type: \n");
|
---|
[4001] | 135 | printf(" %i: %s\n",analysis_counter,EnumAsString(analysis_type_list[analysis_counter]));
|
---|
[3982] | 136 |
|
---|
| 137 |
|
---|
| 138 | }
|
---|
[4001] | 139 | /*}}}*/
|
---|
[3982] | 140 |
|
---|
| 141 | /*Numerics: */
|
---|
| 142 | /*FUNCTION FemModel::GetCurrentAnalysis {{{1*/
|
---|
[4001] | 143 | int FemModel::GetCurrentAnalysis(){
|
---|
[3984] | 144 | return analysis_type_list[analysis_counter];
|
---|
[3982] | 145 | }
|
---|
| 146 | /*}}}1*/
|
---|
| 147 | /*FUNCTION FemModel::SetCurrentAnalysis {{{1*/
|
---|
| 148 | void FemModel::SetCurrentAnalysis(int analysis_type){
|
---|
[4055] | 149 |
|
---|
[3982] | 150 | int found=-1;
|
---|
[4001] | 151 | for(int i=0;i<nummodels;i++){
|
---|
[3982] | 152 | if (analysis_type_list[i]==analysis_type){
|
---|
| 153 | found=i;
|
---|
| 154 | break;
|
---|
| 155 | }
|
---|
| 156 | }
|
---|
[4001] | 157 | if(found!=-1) analysis_counter=found;
|
---|
| 158 | else ISSMERROR("Could not find analysis_type %s in list of FemModel analyses",EnumAsString(analysis_type));
|
---|
[4055] | 159 |
|
---|
| 160 | /*activate matrices/vectors: */
|
---|
| 161 | Rmg=m_Rmg[analysis_counter];
|
---|
| 162 | Gmn=m_Gmn[analysis_counter];
|
---|
| 163 | nodesets=m_nodesets[analysis_counter];
|
---|
| 164 | yg=m_yg[analysis_counter];
|
---|
| 165 | ys=m_ys[analysis_counter];
|
---|
| 166 |
|
---|
[4059] | 167 | /*Now, plug analysis_counter and analysis_type inside the parameters: */
|
---|
| 168 | this->parameters->SetParam(analysis_counter,AnalysisCounterEnum);
|
---|
| 169 | this->parameters->SetParam(analysis_type,AnalysisTypeEnum);
|
---|
[3982] | 170 | }
|
---|
| 171 | /*}}}1*/
|
---|
[4055] | 172 | /*FUNCTION FemModel::SetCurrentAnalysisAlias {{{1*/
|
---|
| 173 | void FemModel::SetCurrentAnalysisAlias(int base_analysis_type,int real_analysis_type){
|
---|
[4059] | 174 |
|
---|
| 175 | /*Use base_analysis_type to setup the analysis counter, but the analysis type of the FemModel will remain
|
---|
| 176 | * real_analysis_type. This means we are using the base_analysis_type settings to run a similar, compatible
|
---|
| 177 | * analysis called real_analysis_type: */
|
---|
| 178 |
|
---|
[4055] | 179 | int found=-1;
|
---|
| 180 | for(int i=0;i<nummodels;i++){
|
---|
| 181 | if (analysis_type_list[i]==base_analysis_type){
|
---|
| 182 | found=i;
|
---|
| 183 | break;
|
---|
| 184 | }
|
---|
| 185 | }
|
---|
| 186 | if(found!=-1) analysis_counter=found;
|
---|
| 187 | else ISSMERROR("Could not find alias for analysis_type %s in list of FemModel analyses",EnumAsString(base_analysis_type));
|
---|
[4059] | 188 |
|
---|
| 189 | /*activate matrices/vectors: */
|
---|
| 190 | Rmg=m_Rmg[analysis_counter];
|
---|
| 191 | Gmn=m_Gmn[analysis_counter];
|
---|
| 192 | nodesets=m_nodesets[analysis_counter];
|
---|
| 193 | yg=m_yg[analysis_counter];
|
---|
| 194 | ys=m_ys[analysis_counter];
|
---|
| 195 |
|
---|
| 196 | /*Now, plug analysis_counter and real_analysis_type inside the parameters: */
|
---|
| 197 | this->parameters->SetParam(analysis_counter,AnalysisCounterEnum);
|
---|
| 198 | this->parameters->SetParam(real_analysis_type,AnalysisTypeEnum);
|
---|
[4055] | 199 | }
|
---|
| 200 | /*}}}1*/
|
---|