[1881] | 1 | /*!\file FemModel.c
|
---|
| 2 | * \brief: implementation of the FemModel object
|
---|
| 3 | */
|
---|
| 4 |
|
---|
[3982] | 5 |
|
---|
[1881] | 6 | #ifdef HAVE_CONFIG_H
|
---|
[9320] | 7 | #include <config.h>
|
---|
[1881] | 8 | #else
|
---|
| 9 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 10 | #endif
|
---|
| 11 |
|
---|
[9320] | 12 | #include <stdio.h>
|
---|
[4236] | 13 | #include "../Container/Container.h"
|
---|
[4009] | 14 | #include "../modules/ModelProcessorx/ModelProcessorx.h"
|
---|
[9761] | 15 | #include "../io/io.h"
|
---|
[3982] | 16 | #include "./objects.h"
|
---|
[3775] | 17 | #include "../include/include.h"
|
---|
[3982] | 18 | #include "../EnumDefinitions/EnumDefinitions.h"
|
---|
| 19 | #include "../modules/modules.h"
|
---|
[1881] | 20 |
|
---|
[3982] | 21 | /*Object constructors and destructor*/
|
---|
[12706] | 22 | /*FUNCTION FemModel::constructor {{{*/
|
---|
[6372] | 23 | FemModel::FemModel(char* inputfilename, char* outputfilename, const int in_solution_type,const int* analyses,const int nummodels){
|
---|
[1881] | 24 |
|
---|
[4001] | 25 | /*intermediary*/
|
---|
[12706] | 26 | int i;
|
---|
| 27 | int analysis_type;
|
---|
| 28 | FILE *IOMODEL = NULL;
|
---|
| 29 | extern int my_rank;
|
---|
[4001] | 30 |
|
---|
[6372] | 31 | /*Open input file on cpu 0: */
|
---|
[12706] | 32 | if(my_rank==0) IOMODEL = pfopen(inputfilename ,"rb");
|
---|
[6372] | 33 |
|
---|
[4028] | 34 | /*Initialize internal data: */
|
---|
[4004] | 35 | this->nummodels=nummodels;
|
---|
[4028] | 36 | this->solution_type=in_solution_type;
|
---|
[4063] | 37 | this->analysis_counter=nummodels-1; //point to last analysis_type carried out.
|
---|
[6372] | 38 | this->results=new Results(); //not initialized by CreateDataSets
|
---|
[3982] | 39 |
|
---|
| 40 | /*Dynamically allocate whatever is a list of length nummodels: */
|
---|
[12706] | 41 | analysis_type_list=xNew<int>(nummodels);
|
---|
[1881] | 42 |
|
---|
[4004] | 43 | /*Initialize: */
|
---|
| 44 | for(i=0;i<nummodels;i++)analysis_type_list[i]=analyses[i];
|
---|
[3982] | 45 |
|
---|
[6273] | 46 | /*create datasets for all analyses*/
|
---|
[4063] | 47 | ModelProcessorx(&this->elements,&this->nodes,&this->vertices,&this->materials,&this->constraints,&this->loads,&this->parameters,IOMODEL,this->solution_type,nummodels,analyses);
|
---|
[4004] | 48 |
|
---|
[4063] | 49 | /*do the post-processing of the datasets to get an FemModel that can actually run analyses: */
|
---|
[4004] | 50 | for(i=0;i<nummodels;i++){
|
---|
| 51 |
|
---|
[12706] | 52 | if(VerboseMProcessor()) _pprintLine_(" Processing finite element model of analysis " << EnumToStringx(analysis_type_list[i]) << ":");
|
---|
[4004] | 53 | analysis_type=analysis_type_list[i];
|
---|
[4356] | 54 | this->SetCurrentConfiguration(analysis_type);
|
---|
[4004] | 55 |
|
---|
[6231] | 56 | if(i==0){
|
---|
[12706] | 57 | if(VerboseMProcessor()) _pprintLine_(" creating vertex degrees of freedom");
|
---|
[6231] | 58 | VerticesDofx(vertices,parameters); //only call once, we only have one set of vertices
|
---|
| 59 | }
|
---|
[5772] | 60 |
|
---|
[12706] | 61 | if(VerboseMProcessor()) _pprintLine_(" resolving node constraints");
|
---|
[9002] | 62 | SpcNodesx(nodes,constraints,parameters,analysis_type);
|
---|
| 63 |
|
---|
[12706] | 64 | if(VerboseMProcessor()) _pprintLine_(" creating nodal degrees of freedom");
|
---|
[4229] | 65 | NodesDofx(nodes,parameters,analysis_type);
|
---|
[5772] | 66 |
|
---|
[12706] | 67 | if(VerboseMProcessor()) _pprintLine_(" configuring element and loads");
|
---|
[4034] | 68 | ConfigureObjectsx(elements, loads, nodes, vertices, materials,parameters);
|
---|
[4004] | 69 | }
|
---|
[6372] | 70 |
|
---|
| 71 | /*Close input file descriptors: */
|
---|
| 72 | if(my_rank==0) pfclose(IOMODEL,inputfilename);
|
---|
| 73 |
|
---|
| 74 | /*Add output file name to parameters: */
|
---|
[8926] | 75 | this->parameters->AddObject(new StringParam(OutputfilenameEnum,outputfilename));
|
---|
[6372] | 76 |
|
---|
[1881] | 77 | }
|
---|
[6372] | 78 |
|
---|
[12706] | 79 | /*}}}*/
|
---|
| 80 | /*FUNCTION FemModel::destructor {{{*/
|
---|
[1881] | 81 | FemModel::~FemModel(){
|
---|
| 82 |
|
---|
[4001] | 83 | /*Intermediary*/
|
---|
[3982] | 84 | int i;
|
---|
| 85 |
|
---|
| 86 | /*Delete all the datasets: */
|
---|
[12706] | 87 | xDelete<int>(analysis_type_list);
|
---|
[1881] | 88 | delete elements;
|
---|
| 89 | delete nodes;
|
---|
[3417] | 90 | delete vertices;
|
---|
[3982] | 91 | delete constraints;
|
---|
[1881] | 92 | delete loads;
|
---|
| 93 | delete materials;
|
---|
| 94 | delete parameters;
|
---|
[4050] | 95 | delete results;
|
---|
[3982] | 96 |
|
---|
[1881] | 97 | }
|
---|
[12706] | 98 | /*}}}*/
|
---|
[3982] | 99 |
|
---|
| 100 | /*Object management*/
|
---|
[12706] | 101 | /*FUNCTION FemModel::Echo {{{*/
|
---|
[3982] | 102 | void FemModel::Echo(void){
|
---|
| 103 |
|
---|
[12706] | 104 | _printLine_("FemModel echo: ");
|
---|
| 105 | _printLine_(" number of fem models: " << nummodels);
|
---|
| 106 | _printLine_(" analysis_type_list: ");
|
---|
| 107 | for(int i=0;i<nummodels;i++)_printLine_(" " << i << ": " << EnumToStringx(analysis_type_list[i]));
|
---|
| 108 | _printLine_(" current analysis_type: ");
|
---|
| 109 | _printLine_(" " << analysis_counter << ": " << EnumToStringx(analysis_type_list[analysis_counter]));
|
---|
[3982] | 110 |
|
---|
| 111 | }
|
---|
[4001] | 112 | /*}}}*/
|
---|
[3982] | 113 |
|
---|
| 114 | /*Numerics: */
|
---|
[12706] | 115 | /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){{{*/
|
---|
[4356] | 116 | void FemModel::SetCurrentConfiguration(int configuration_type,int analysis_type){
|
---|
[4055] | 117 |
|
---|
[4356] | 118 | /*Use configuration_type to setup the analysis counter, the configurations of objects etc ... but use
|
---|
| 119 | * analysis_type to drive the element numerics. This allows for use of 1 configuration_type for several
|
---|
| 120 | * analyses. For example: do a SurfaceSlopeX, SurfaceSlopeY, BedSlopeX and BedSlopeY analysis using the
|
---|
[4402] | 121 | * Slope configuration.*/
|
---|
[4356] | 122 |
|
---|
[3982] | 123 | int found=-1;
|
---|
[4001] | 124 | for(int i=0;i<nummodels;i++){
|
---|
[4356] | 125 | if (analysis_type_list[i]==configuration_type){
|
---|
[3982] | 126 | found=i;
|
---|
| 127 | break;
|
---|
| 128 | }
|
---|
| 129 | }
|
---|
[4001] | 130 | if(found!=-1) analysis_counter=found;
|
---|
[12706] | 131 | else _error2_("Could not find alias for analysis_type " << EnumToStringx(configuration_type) << " in list of FemModel analyses");
|
---|
[4055] | 132 |
|
---|
[4059] | 133 | /*Now, plug analysis_counter and analysis_type inside the parameters: */
|
---|
| 134 | this->parameters->SetParam(analysis_counter,AnalysisCounterEnum);
|
---|
| 135 | this->parameters->SetParam(analysis_type,AnalysisTypeEnum);
|
---|
[4356] | 136 | this->parameters->SetParam(configuration_type,ConfigurationTypeEnum);
|
---|
[4573] | 137 |
|
---|
| 138 | /*configure elements, loads and nodes, for this new analysis: */
|
---|
[4575] | 139 | this->elements->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters);
|
---|
| 140 | this->nodes->SetCurrentConfiguration(elements,loads, nodes,vertices, materials,parameters);
|
---|
| 141 | this->loads->SetCurrentConfiguration(elements, loads, nodes,vertices, materials,parameters);
|
---|
[4573] | 142 |
|
---|
[11995] | 143 | #ifdef _HAVE_PETSC_
|
---|
[8263] | 144 | /*take care of petsc options, that depend on this analysis type (present only after model processor)*/
|
---|
| 145 | if(this->parameters->Exist(PetscOptionsStringsEnum)){
|
---|
| 146 | PetscOptionsFromAnalysis(this->parameters,analysis_type);
|
---|
[12706] | 147 | if(VerboseSolver()) _pprintLine_(" petsc Options set for analysis type: " << EnumToStringx(analysis_type));
|
---|
[8263] | 148 | }
|
---|
[11995] | 149 | #endif
|
---|
[6014] | 150 |
|
---|
[3982] | 151 | }
|
---|
[12706] | 152 | /*}}}*/
|
---|
| 153 | /*FUNCTION FemModel::SetCurrentConfiguration(int configuration_type){{{*/
|
---|
[4356] | 154 | void FemModel::SetCurrentConfiguration(int configuration_type){
|
---|
[4059] | 155 |
|
---|
[4356] | 156 | /*overload: analysis_type = configuration_type: */
|
---|
| 157 | this->SetCurrentConfiguration(configuration_type,configuration_type);
|
---|
[4055] | 158 | }
|
---|
[12706] | 159 | /*}}}*/
|
---|