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