1 | /*!\file ModelProcessorx
|
---|
2 | * \brief: create datasets using input binary file and a set of requested analyses
|
---|
3 | */
|
---|
4 |
|
---|
5 | #ifdef HAVE_CONFIG_H
|
---|
6 | #include <config.h>
|
---|
7 | #else
|
---|
8 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
9 | #endif
|
---|
10 |
|
---|
11 | #include "../../classes/classes.h"
|
---|
12 | #include "../../shared/shared.h"
|
---|
13 | #include "./ModelProcessorx.h"
|
---|
14 |
|
---|
15 | void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters, FILE* IOMODEL,FILE* toolkitfile, char* rootpath,const int solution_enum,const int nummodels,const int* analysis_enum_list){
|
---|
16 |
|
---|
17 | int i,analysis_enum,verbose;
|
---|
18 | bool isthermal,ismasstransport,isstressbalance,isgroundingline,isenthalpy;
|
---|
19 |
|
---|
20 | /*Initialize datasets*/
|
---|
21 | Elements *elements = new Elements();
|
---|
22 | Nodes *nodes = new Nodes();
|
---|
23 | Vertices *vertices = new Vertices();
|
---|
24 | Materials *materials = new Materials();
|
---|
25 | Constraints *constraints = new Constraints();
|
---|
26 | Loads *loads = new Loads();
|
---|
27 | Parameters *parameters = new Parameters();
|
---|
28 |
|
---|
29 | /*Initialize IoModel from input file*/
|
---|
30 | IoModel* iomodel = new IoModel(IOMODEL);
|
---|
31 |
|
---|
32 | /*Fetch parameters: */
|
---|
33 | iomodel->Constant(&verbose,VerboseEnum);
|
---|
34 | iomodel->Constant(&isthermal,TransientIsthermalEnum);
|
---|
35 | iomodel->Constant(&isenthalpy,ThermalIsenthalpyEnum);
|
---|
36 | iomodel->Constant(&ismasstransport,TransientIsmasstransportEnum);
|
---|
37 | iomodel->Constant(&isstressbalance,TransientIsstressbalanceEnum);
|
---|
38 | iomodel->Constant(&isgroundingline,TransientIsgroundinglineEnum);
|
---|
39 |
|
---|
40 | SetVerbosityLevel(verbose);
|
---|
41 |
|
---|
42 | if(VerboseMProcessor()) _printf0_(" starting model processor \n");
|
---|
43 |
|
---|
44 | /*Partition Elements and Nodes*/
|
---|
45 | ElementsAndVerticesPartitioning(&iomodel->my_elements,&iomodel->my_vertices,iomodel);
|
---|
46 |
|
---|
47 | /*Create elements, vertices and materials, independent of analysis_enum: */
|
---|
48 | CreateElementsVerticesAndMaterials(elements,vertices,materials,iomodel,nummodels);
|
---|
49 |
|
---|
50 | /*Create Parameters*/
|
---|
51 | CreateParameters(parameters,iomodel,rootpath,toolkitfile,solution_enum);
|
---|
52 |
|
---|
53 | for(i=0;i<nummodels;i++){
|
---|
54 |
|
---|
55 | analysis_enum=analysis_enum_list[i];
|
---|
56 | parameters->AddObject(new IntParam(AnalysisCounterEnum,i));
|
---|
57 |
|
---|
58 | /*Hack for trasient runs (FIXME: to be improved)*/
|
---|
59 | if(solution_enum==TransientSolutionEnum && analysis_enum==ThermalAnalysisEnum && iomodel->meshtype==Mesh2DhorizontalEnum) continue;
|
---|
60 | if(solution_enum==TransientSolutionEnum && analysis_enum==MeltingAnalysisEnum && iomodel->meshtype==Mesh2DhorizontalEnum) continue;
|
---|
61 | if(solution_enum==TransientSolutionEnum && analysis_enum==EnthalpyAnalysisEnum && iomodel->meshtype==Mesh2DhorizontalEnum) continue;
|
---|
62 | if(solution_enum==TransientSolutionEnum && analysis_enum==ThermalAnalysisEnum && isthermal==false) continue;
|
---|
63 | if(solution_enum==TransientSolutionEnum && analysis_enum==MeltingAnalysisEnum && isthermal==false) continue;
|
---|
64 | if(solution_enum==TransientSolutionEnum && analysis_enum==EnthalpyAnalysisEnum && isthermal==false) continue;
|
---|
65 | if(solution_enum==TransientSolutionEnum && analysis_enum==ThermalAnalysisEnum && isenthalpy==true) continue;
|
---|
66 | if(solution_enum==TransientSolutionEnum && analysis_enum==MeltingAnalysisEnum && isenthalpy==true) continue;
|
---|
67 | if(solution_enum==TransientSolutionEnum && analysis_enum==EnthalpyAnalysisEnum && isenthalpy==false) continue;
|
---|
68 | if(solution_enum==TransientSolutionEnum && analysis_enum==MasstransportAnalysisEnum && ismasstransport==false && isgroundingline==false) continue;
|
---|
69 | if(solution_enum==TransientSolutionEnum && analysis_enum==StressbalanceAnalysisEnum && isstressbalance==false) continue;
|
---|
70 | if(solution_enum==TransientSolutionEnum && analysis_enum==StressbalanceVerticalAnalysisEnum && isstressbalance==false) continue;
|
---|
71 | if(solution_enum==TransientSolutionEnum && analysis_enum==StressbalanceSIAAnalysisEnum && isstressbalance==false) continue;
|
---|
72 | if(solution_enum==SteadystateSolutionEnum && analysis_enum==ThermalAnalysisEnum && isenthalpy==true) continue;
|
---|
73 | if(solution_enum==SteadystateSolutionEnum && analysis_enum==MeltingAnalysisEnum && isenthalpy==true) continue;
|
---|
74 | if(solution_enum==SteadystateSolutionEnum && analysis_enum==EnthalpyAnalysisEnum && isenthalpy==false) continue;
|
---|
75 |
|
---|
76 | if(VerboseMProcessor()) _printf0_(" creating datasets for analysis " << EnumToStringx(analysis_enum) << "\n");
|
---|
77 | Analysis* analysis = EnumToAnalysis(analysis_enum);
|
---|
78 | analysis->UpdateParameters(parameters,iomodel,solution_enum,analysis_enum);
|
---|
79 | analysis->CreateNodes(nodes,iomodel);
|
---|
80 | analysis->CreateConstraints(constraints,iomodel);
|
---|
81 | analysis->CreateLoads(loads,iomodel);
|
---|
82 | analysis->UpdateElements(elements,iomodel,i,analysis_enum);
|
---|
83 | delete analysis;
|
---|
84 |
|
---|
85 |
|
---|
86 | /* Update counters, because we have created more nodes, loads and
|
---|
87 | * constraints, and ids for objects created in next call to CreateDataSets
|
---|
88 | * will need to start at the end of the updated counters: */
|
---|
89 | iomodel->nodecounter = nodes->MaximumId();
|
---|
90 | iomodel->loadcounter = loads->NumberOfLoads();
|
---|
91 | iomodel->constraintcounter = constraints->NumberOfConstraints();
|
---|
92 | }
|
---|
93 |
|
---|
94 | /*Solution specific updates*/
|
---|
95 | #ifdef _HAVE_CONTROL_
|
---|
96 | UpdateElementsAndMaterialsControl(elements,materials,iomodel);
|
---|
97 | #endif
|
---|
98 | #ifdef _HAVE_DAKOTA_
|
---|
99 | UpdateElementsAndMaterialsDakota(elements,materials,iomodel);
|
---|
100 | #endif
|
---|
101 | #ifdef _HAVE_TRANSIENT_
|
---|
102 | if(solution_enum==TransientSolutionEnum){
|
---|
103 | UpdateElementsTransient(elements,parameters,iomodel,analysis_enum);
|
---|
104 | }
|
---|
105 | #endif
|
---|
106 |
|
---|
107 | /* Sort datasets:
|
---|
108 | * All our datasets are already ordered by ids. Set presort flag so that
|
---|
109 | * later on, when sorting is requested on these datasets, it will not be
|
---|
110 | * redone: */
|
---|
111 | elements->Presort();
|
---|
112 | nodes->Presort();
|
---|
113 | vertices->Presort();
|
---|
114 | loads->Presort();
|
---|
115 | materials->Presort();
|
---|
116 |
|
---|
117 | constraints->Presort();
|
---|
118 | parameters->Presort();
|
---|
119 | if(VerboseMProcessor()) _printf0_(" done with model processor \n");
|
---|
120 |
|
---|
121 | /*Free resources:*/
|
---|
122 | delete iomodel;
|
---|
123 |
|
---|
124 | /*Assign output pointers:*/
|
---|
125 | *pelements = elements;
|
---|
126 | *pnodes = nodes;
|
---|
127 | *pvertices = vertices;
|
---|
128 | *pmaterials = materials;
|
---|
129 | *pconstraints = constraints;
|
---|
130 | *ploads = loads;
|
---|
131 | *pparameters = parameters;
|
---|
132 | }
|
---|