[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;
|
---|
[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));
|
---|
[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 |
|
---|
[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,¶meters,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");
|
---|
[4055] | 66 | SpcNodesx( &m_yg[i], nodes,constraints,analysis_type);
|
---|
[4004] | 67 |
|
---|
| 68 | _printf_(" create rigid body constraints:\n");
|
---|
[4055] | 69 | MpcNodesx( &m_Rmg[i], nodes,constraints,analysis_type);
|
---|
[4004] | 70 |
|
---|
| 71 | _printf_(" create node sets:\n");
|
---|
[4055] | 72 | BuildNodeSetsx(&m_nodesets[i], nodes,analysis_type);
|
---|
[4004] | 73 |
|
---|
| 74 | _printf_(" reducing single point constraints vector:\n");
|
---|
[4055] | 75 | Reducevectorgtosx(&m_ys[i], m_yg[i],m_nodesets[i]);
|
---|
[4004] | 76 |
|
---|
| 77 | _printf_(" normalizing rigid body constraints matrix:\n");
|
---|
[4055] | 78 | NormalizeConstraintsx(&m_Gmn[i], m_Rmg[i],m_nodesets[i]);
|
---|
[4004] | 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] | 89 | FemModel::~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++){
|
---|
[4055] | 108 | Mat temp_Rmg=m_Rmg[i];
|
---|
[3982] | 109 | MatFree(&temp_Rmg);
|
---|
[4055] | 110 | Mat temp_Gmn=m_Gmn[i];
|
---|
[3982] | 111 | MatFree(&temp_Gmn);
|
---|
[4055] | 112 | NodeSets* temp_nodesets=m_nodesets[i];
|
---|
| 113 | delete temp_nodesets;
|
---|
| 114 | Vec temp_yg=m_yg[i];
|
---|
[3982] | 115 | VecFree(&temp_yg);
|
---|
[4055] | 116 | Vec temp_ys=m_ys[i];
|
---|
[3982] | 117 | VecFree(&temp_ys);
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | /*Delete dynamically allocated arrays: */
|
---|
[4055] | 121 | delete m_Rmg;
|
---|
| 122 | delete m_Gmn;
|
---|
| 123 | delete m_nodesets;
|
---|
| 124 | delete m_yg;
|
---|
| 125 | delete m_ys;
|
---|
[1881] | 126 |
|
---|
| 127 | }
|
---|
[3982] | 128 | /*}}}1*/
|
---|
| 129 |
|
---|
| 130 | /*Object management*/
|
---|
| 131 | /*FUNCTION FemModel::Echo {{{1*/
|
---|
| 132 | void 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] | 147 | int FemModel::GetCurrentAnalysis(){
|
---|
[3984] | 148 | return analysis_type_list[analysis_counter];
|
---|
[3982] | 149 | }
|
---|
| 150 | /*}}}1*/
|
---|
| 151 | /*FUNCTION FemModel::SetCurrentAnalysis {{{1*/
|
---|
| 152 | void FemModel::SetCurrentAnalysis(int analysis_type){
|
---|
[4055] | 153 |
|
---|
[3982] | 154 | int found=-1;
|
---|
[4001] | 155 | for(int i=0;i<nummodels;i++){
|
---|
[3982] | 156 | if (analysis_type_list[i]==analysis_type){
|
---|
| 157 | found=i;
|
---|
| 158 | break;
|
---|
| 159 | }
|
---|
| 160 | }
|
---|
[4001] | 161 | if(found!=-1) analysis_counter=found;
|
---|
| 162 | else ISSMERROR("Could not find analysis_type %s in list of FemModel analyses",EnumAsString(analysis_type));
|
---|
[4055] | 163 |
|
---|
| 164 | /*activate matrices/vectors: */
|
---|
| 165 | Rmg=m_Rmg[analysis_counter];
|
---|
| 166 | Gmn=m_Gmn[analysis_counter];
|
---|
| 167 | nodesets=m_nodesets[analysis_counter];
|
---|
| 168 | yg=m_yg[analysis_counter];
|
---|
| 169 | ys=m_ys[analysis_counter];
|
---|
| 170 |
|
---|
[3982] | 171 | }
|
---|
| 172 | /*}}}1*/
|
---|
[4055] | 173 | /*FUNCTION FemModel::SetCurrentAnalysisAlias {{{1*/
|
---|
| 174 | void FemModel::SetCurrentAnalysisAlias(int base_analysis_type,int real_analysis_type){
|
---|
| 175 | int found=-1;
|
---|
| 176 | for(int i=0;i<nummodels;i++){
|
---|
| 177 | if (analysis_type_list[i]==base_analysis_type){
|
---|
| 178 | found=i;
|
---|
| 179 | break;
|
---|
| 180 | }
|
---|
| 181 | }
|
---|
| 182 | if(found!=-1) analysis_counter=found;
|
---|
| 183 | else ISSMERROR("Could not find alias for analysis_type %s in list of FemModel analyses",EnumAsString(base_analysis_type));
|
---|
| 184 | }
|
---|
| 185 | /*}}}1*/
|
---|
[3982] | 186 |
|
---|