[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"
|
---|
| 14 | #include "../modules/FemModelProcessorx/FemModelProcessorx.h"
|
---|
| 15 | #include "./objects.h"
|
---|
[3775] | 16 | #include "../include/include.h"
|
---|
[3982] | 17 | #include "../EnumDefinitions/EnumDefinitions.h"
|
---|
| 18 | #include "../modules/modules.h"
|
---|
[1881] | 19 |
|
---|
| 20 |
|
---|
[3982] | 21 | /*Object constructors and destructor*/
|
---|
| 22 | /*FUNCTION FemModel::constructor {{{1*/
|
---|
[4004] | 23 | FemModel::FemModel(ConstDataHandle IOMODEL,int* analyses, int nummodels){
|
---|
[1881] | 24 |
|
---|
[4001] | 25 | /*intermediary*/
|
---|
| 26 | int i;
|
---|
[4004] | 27 | IoModel* iomodel=NULL;
|
---|
| 28 | int analysis_type;
|
---|
[4001] | 29 |
|
---|
[4004] | 30 | this->nummodels=nummodels;
|
---|
| 31 | analysis_counter=nummodels-1; //point to last analysis_type carried out.
|
---|
[3982] | 32 |
|
---|
| 33 | /*Dynamically allocate whatever is a list of length nummodels: */
|
---|
| 34 | analysis_type_list=(int*)xmalloc(nummodels*sizeof(int));
|
---|
[4004] | 35 | Rmg=(Mat*)xmalloc(nummodels*sizeof(Mat));
|
---|
| 36 | Gmn=(Mat*)xmalloc(nummodels*sizeof(Mat));
|
---|
| 37 | nodesets=(NodeSets**)xmalloc(nummodels*sizeof(NodeSet*));
|
---|
| 38 | yg=(Vec*)xmalloc(nummodels*sizeof(Vec));
|
---|
| 39 | ys=(Vec*)xmalloc(nummodels*sizeof(Vec));
|
---|
[1881] | 40 |
|
---|
[4004] | 41 | /*Initialize: */
|
---|
| 42 | for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
|
---|
[3982] | 43 | for(i=0;i<nummodels;i++)Rmg[i]=NULL;
|
---|
| 44 | for(i=0;i<nummodels;i++)Gmn[i]=NULL;
|
---|
| 45 | for(i=0;i<nummodels;i++)nodesets[i]=NULL;
|
---|
| 46 | for(i=0;i<nummodels;i++)yg[i]=NULL;
|
---|
| 47 | for(i=0;i<nummodels;i++)ys[i]=NULL;
|
---|
| 48 |
|
---|
[4004] | 49 | _printf_(" fill model with matlab workspace data\n");
|
---|
| 50 | iomodel = new IoModel(IOMODEL);
|
---|
| 51 |
|
---|
| 52 | for(i=0;i<nummodels;i++){
|
---|
| 53 |
|
---|
| 54 | analysis_type=analysis_type_list[i];
|
---|
| 55 |
|
---|
| 56 | _printf_(" create datasets:\n");
|
---|
| 57 | CreateDataSets(&elements,&nodes,&vertices,&materials,&constraints,&loads,¶meters,iomodel,IOMODEL,analysis_type,nummodels,i);
|
---|
| 58 |
|
---|
| 59 | _printf_(" create degrees of freedom: \n");
|
---|
| 60 | VerticesDofx( &partition,&tpartition,vertices,parameters);
|
---|
| 61 | NodesDofx( nodes,parameters);
|
---|
| 62 |
|
---|
| 63 | _printf_(" create single point constraints: \n");
|
---|
| 64 | SpcNodesx( &yg[i], nodes,constraints,analysis_type);
|
---|
| 65 |
|
---|
| 66 | _printf_(" create rigid body constraints:\n");
|
---|
| 67 | MpcNodesx( &Rmg[i], nodes,constraints,analysis_type);
|
---|
| 68 |
|
---|
| 69 | _printf_(" create node sets:\n");
|
---|
| 70 | BuildNodeSetsx(&nodesets[i], nodes,analysis_type);
|
---|
| 71 |
|
---|
| 72 | _printf_(" reducing single point constraints vector:\n");
|
---|
| 73 | Reducevectorgtosx(&ys[i], yg[i],nodesets[i]);
|
---|
| 74 |
|
---|
| 75 | _printf_(" normalizing rigid body constraints matrix:\n");
|
---|
| 76 | NormalizeConstraintsx(&Gmn[i], Rmg[i],nodesets[i]);
|
---|
| 77 |
|
---|
| 78 | _printf_(" configuring element and loads:\n");
|
---|
| 79 | ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters,i,analysis_type);
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | _printf_(" free ressources:\n");
|
---|
| 83 | delete iomodel;
|
---|
[1881] | 84 | }
|
---|
[3982] | 85 | /*}}}1*/
|
---|
| 86 | /*FUNCTION FemModel::destructor {{{1*/
|
---|
[1881] | 87 | FemModel::~FemModel(){
|
---|
| 88 |
|
---|
[4001] | 89 | /*Intermediary*/
|
---|
[3982] | 90 | int i;
|
---|
| 91 |
|
---|
| 92 | /*Delete all the datasets: */
|
---|
| 93 | xfree((void**)&analysis_type_list);
|
---|
[1881] | 94 | delete elements;
|
---|
| 95 | delete nodes;
|
---|
[3417] | 96 | delete vertices;
|
---|
[3982] | 97 | delete constraints;
|
---|
[1881] | 98 | delete loads;
|
---|
| 99 | delete materials;
|
---|
| 100 | delete parameters;
|
---|
[2316] | 101 | delete partition;
|
---|
| 102 | delete tpartition;
|
---|
[3982] | 103 |
|
---|
| 104 | for(i=0;i<nummodels;i++){
|
---|
| 105 | Mat temp_Rmg=Rmg[i];
|
---|
| 106 | MatFree(&temp_Rmg);
|
---|
| 107 | Mat temp_Gmn=Gmn[i];
|
---|
| 108 | MatFree(&temp_Gmn);
|
---|
| 109 | NodeSet* temp_nodesets=nodesets[i];
|
---|
| 110 | delete nodesets;
|
---|
| 111 | Vec temp_yg=yg[i];
|
---|
| 112 | VecFree(&temp_yg);
|
---|
| 113 | Vec temp_ys=ys[i];
|
---|
| 114 | VecFree(&temp_ys);
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | /*Delete dynamically allocated arrays: */
|
---|
| 118 | delete Rmg;
|
---|
| 119 | delete Gmn;
|
---|
| 120 | delete nodesets;
|
---|
[2316] | 121 | delete yg;
|
---|
[3982] | 122 | delete ys;
|
---|
[1881] | 123 |
|
---|
| 124 | }
|
---|
[3982] | 125 | /*}}}1*/
|
---|
| 126 |
|
---|
| 127 | /*Object management*/
|
---|
| 128 | /*FUNCTION FemModel::Echo {{{1*/
|
---|
| 129 | void FemModel::Echo(void){
|
---|
| 130 |
|
---|
| 131 | printf("FemModel echo: \n");
|
---|
| 132 | printf(" number of fem models: %i\n",nummodels);
|
---|
| 133 | printf(" analysis_type_list: \n");
|
---|
[4001] | 134 | for(int i=0;i<nummodels;i++)printf(" %i: %s\n",i,EnumAsString(analysis_type_list[i]));
|
---|
[3982] | 135 | printf(" current analysis_type: \n");
|
---|
[4001] | 136 | printf(" %i: %s\n",analysis_counter,EnumAsString(analysis_type_list[analysis_counter]));
|
---|
[3982] | 137 |
|
---|
| 138 |
|
---|
| 139 | }
|
---|
[4001] | 140 | /*}}}*/
|
---|
[3982] | 141 |
|
---|
| 142 | /*Numerics: */
|
---|
| 143 | /*FUNCTION FemModel::GetCurrentAnalysis {{{1*/
|
---|
[4001] | 144 | int FemModel::GetCurrentAnalysis(){
|
---|
[3984] | 145 | return analysis_type_list[analysis_counter];
|
---|
[3982] | 146 | }
|
---|
| 147 | /*}}}1*/
|
---|
| 148 | /*FUNCTION FemModel::SetCurrentAnalysis {{{1*/
|
---|
| 149 | void FemModel::SetCurrentAnalysis(int analysis_type){
|
---|
| 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));
|
---|
[3982] | 159 | }
|
---|
| 160 | /*}}}1*/
|
---|
| 161 |
|
---|