[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] | 22 | FemModel::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_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_nodesets[i]=NULL;
|
---|
| 46 | for(i=0;i<nummodels;i++)m_yg[i]=NULL;
|
---|
| 47 | for(i=0;i<nummodels;i++)m_ys[i]=NULL;
|
---|
[3982] | 48 |
|
---|
[4063] | 49 | /*create datasets for all analyses: */
|
---|
| 50 | ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,this->solution_type,nummodels,analyses);
|
---|
[4004] | 51 |
|
---|
[4063] | 52 | /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
|
---|
[4004] | 53 | for(i=0;i<nummodels;i++){
|
---|
| 54 |
|
---|
[4122] | 55 | _printf_(" processing finite element model of analysis %s:\n",EnumAsString(analysis_type_list[i]));
|
---|
[4004] | 56 | analysis_type=analysis_type_list[i];
|
---|
[4356] | 57 | this->SetCurrentConfiguration(analysis_type);
|
---|
[4004] | 58 |
|
---|
[4117] | 59 | _printf_(" create degrees of freedom\n");
|
---|
[4168] | 60 | VerticesDofx(&partition,&tpartition,vertices,parameters);
|
---|
[4229] | 61 | NodesDofx(nodes,parameters,analysis_type);
|
---|
[4004] | 62 |
|
---|
[4117] | 63 | _printf_(" create single point constraints\n");
|
---|
[4055] | 64 | SpcNodesx( &m_yg[i], nodes,constraints,analysis_type);
|
---|
[4004] | 65 |
|
---|
[4117] | 66 | _printf_(" create node sets\n");
|
---|
[4055] | 67 | BuildNodeSetsx(&m_nodesets[i], nodes,analysis_type);
|
---|
[4004] | 68 |
|
---|
[4117] | 69 | _printf_(" reducing single point constraints vector\n");
|
---|
[4055] | 70 | Reducevectorgtosx(&m_ys[i], m_yg[i],m_nodesets[i]);
|
---|
[4004] | 71 |
|
---|
[4117] | 72 | _printf_(" configuring element and loads\n");
|
---|
[4034] | 73 | ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
|
---|
[4004] | 74 | }
|
---|
[1881] | 75 | }
|
---|
[3982] | 76 | /*}}}1*/
|
---|
| 77 | /*FUNCTION FemModel::destructor {{{1*/
|
---|
[1881] | 78 | FemModel::~FemModel(){
|
---|
| 79 |
|
---|
[4001] | 80 | /*Intermediary*/
|
---|
[3982] | 81 | int i;
|
---|
| 82 |
|
---|
| 83 | /*Delete all the datasets: */
|
---|
| 84 | xfree((void**)&analysis_type_list);
|
---|
[1881] | 85 | delete elements;
|
---|
| 86 | delete nodes;
|
---|
[3417] | 87 | delete vertices;
|
---|
[3982] | 88 | delete constraints;
|
---|
[1881] | 89 | delete loads;
|
---|
| 90 | delete materials;
|
---|
| 91 | delete parameters;
|
---|
[4050] | 92 | delete results;
|
---|
[4181] | 93 | VecFree(&partition);
|
---|
| 94 | VecFree(&tpartition);
|
---|
[3982] | 95 |
|
---|
| 96 | for(i=0;i<nummodels;i++){
|
---|
[4055] | 97 | NodeSets* temp_nodesets=m_nodesets[i];
|
---|
| 98 | delete temp_nodesets;
|
---|
| 99 | Vec temp_yg=m_yg[i];
|
---|
[3982] | 100 | VecFree(&temp_yg);
|
---|
[4055] | 101 | Vec temp_ys=m_ys[i];
|
---|
[3982] | 102 | VecFree(&temp_ys);
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | /*Delete dynamically allocated arrays: */
|
---|
[4137] | 106 | xfree((void**)&m_nodesets);
|
---|
| 107 | xfree((void**)&m_yg);
|
---|
| 108 | xfree((void**)&m_ys);
|
---|
[1881] | 109 |
|
---|
| 110 | }
|
---|
[3982] | 111 | /*}}}1*/
|
---|
| 112 |
|
---|
| 113 | /*Object management*/
|
---|
| 114 | /*FUNCTION FemModel::Echo {{{1*/
|
---|
| 115 | void FemModel::Echo(void){
|
---|
| 116 |
|
---|
| 117 | printf("FemModel echo: \n");
|
---|
| 118 | printf(" number of fem models: %i\n",nummodels);
|
---|
| 119 | printf(" analysis_type_list: \n");
|
---|
[4001] | 120 | for(int i=0;i<nummodels;i++)printf(" %i: %s\n",i,EnumAsString(analysis_type_list[i]));
|
---|
[3982] | 121 | printf(" current analysis_type: \n");
|
---|
[4001] | 122 | printf(" %i: %s\n",analysis_counter,EnumAsString(analysis_type_list[analysis_counter]));
|
---|
[3982] | 123 |
|
---|
| 124 |
|
---|
| 125 | }
|
---|
[4001] | 126 | /*}}}*/
|
---|
[3982] | 127 |
|
---|
| 128 | /*Numerics: */
|
---|
[4422] | 129 | /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){{{1*/
|
---|
[4356] | 130 | void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){
|
---|
[4055] | 131 |
|
---|
[4356] | 132 | /*Use configuration_type to setup the analysis counter, the configurations of objects etc ... but use
|
---|
| 133 | * analysis_type to drive the element numerics. This allows for use of 1 configuration_type for several
|
---|
| 134 | * analyses. For example: do a SurfaceSlopeX, SurfaceSlopeY, BedSlopeX and BedSlopeY analysis using the
|
---|
[4402] | 135 | * Slope configuration.*/
|
---|
[4356] | 136 |
|
---|
[3982] | 137 | int found=-1;
|
---|
[4001] | 138 | for(int i=0;i<nummodels;i++){
|
---|
[4356] | 139 | if (analysis_type_list[i]==configuration_type){
|
---|
[3982] | 140 | found=i;
|
---|
| 141 | break;
|
---|
| 142 | }
|
---|
| 143 | }
|
---|
[4001] | 144 | if(found!=-1) analysis_counter=found;
|
---|
[4356] | 145 | else ISSMERROR("Could not find alias for analysis_type %s in list of FemModel analyses",EnumAsString(configuration_type));
|
---|
[4055] | 146 |
|
---|
| 147 | /*activate matrices/vectors: */
|
---|
| 148 | nodesets=m_nodesets[analysis_counter];
|
---|
| 149 | yg=m_yg[analysis_counter];
|
---|
| 150 | ys=m_ys[analysis_counter];
|
---|
| 151 |
|
---|
[4059] | 152 | /*Now, plug analysis_counter and analysis_type inside the parameters: */
|
---|
| 153 | this->parameters->SetParam(analysis_counter,AnalysisCounterEnum);
|
---|
| 154 | this->parameters->SetParam(analysis_type,AnalysisTypeEnum);
|
---|
[4356] | 155 | this->parameters->SetParam(configuration_type,ConfigurationTypeEnum);
|
---|
[4573] | 156 |
|
---|
| 157 | /*configure elements, loads and nodes, for this new analysis: */
|
---|
[4575] | 158 | this->elements->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters);
|
---|
| 159 | this->nodes->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters);
|
---|
| 160 | this->loads->SetCurrentConfiguration(elements, loads, nodes,vertices, materials,parameters);
|
---|
[4573] | 161 |
|
---|
[3982] | 162 | }
|
---|
| 163 | /*}}}1*/
|
---|
[4422] | 164 | /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{1*/
|
---|
[4356] | 165 | void FemModel::SetCurrentConfiguration(int configuration_type){
|
---|
[4059] | 166 |
|
---|
[4356] | 167 | /*overload: analysis_type = configuration_type: */
|
---|
| 168 | this->SetCurrentConfiguration(configuration_type,configuration_type);
|
---|
[4055] | 169 | }
|
---|
| 170 | /*}}}1*/
|
---|