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,Inputs2** pinputs2,IoModel* iomodel,FILE* toolkitfile, char* rootpath,const int solution_enum,const int nummodels,const int* analysis_enum_list){
|
---|
16 | _assert_(nummodels>0);
|
---|
17 |
|
---|
18 | /*Set Verbosity once for all*/
|
---|
19 | int verbose;
|
---|
20 | iomodel->FindConstant(&verbose,"md.verbose");
|
---|
21 | SetVerbosityLevel(verbose);
|
---|
22 |
|
---|
23 | if(VerboseMProcessor()) _printf0_(" starting model processor \n");
|
---|
24 |
|
---|
25 | /*Initialize datasets*/
|
---|
26 | Elements *elements = new Elements();
|
---|
27 | Vertices *vertices = new Vertices();
|
---|
28 | Materials *materials = new Materials();
|
---|
29 | Parameters *parameters = new Parameters();
|
---|
30 | Constraints **constraints = xNew<Constraints*>(nummodels);
|
---|
31 | Loads **loads = xNew<Loads*>(nummodels);
|
---|
32 | Nodes **nodes = xNew<Nodes*>(nummodels);
|
---|
33 | for(int i = 0;i<nummodels;i++) constraints[i] = new Constraints();
|
---|
34 | for(int i = 0;i<nummodels;i++) loads[i] = new Loads();
|
---|
35 | for(int i = 0;i<nummodels;i++) nodes[i] = new Nodes();
|
---|
36 |
|
---|
37 | /*Partition Elements and Nodes*/
|
---|
38 | ElementsAndVerticesPartitioning(iomodel);
|
---|
39 |
|
---|
40 | /*Create elements, vertices and materials, independent of analysis_enum: */
|
---|
41 | CreateElements(elements,iomodel,nummodels);
|
---|
42 | CreateVertices(elements,vertices,iomodel,solution_enum);
|
---|
43 | CreateParameters(parameters,iomodel,rootpath,toolkitfile,solution_enum);
|
---|
44 |
|
---|
45 | /*Should move to CreateInputs2*/
|
---|
46 | Inputs2 *inputs2 = new Inputs2(elements->Size(),vertices->Size());
|
---|
47 | if (iomodel->domaintype != Domain3DsurfaceEnum) iomodel->FetchDataToInput(inputs2,elements,"md.mesh.scale_factor",MeshScaleFactorEnum,1.);
|
---|
48 |
|
---|
49 | /*Can now do Materials since we have created Inputs*/
|
---|
50 | CreateMaterials(elements,inputs2,materials,iomodel,nummodels);
|
---|
51 |
|
---|
52 | /*Update datasets based on each analysis (and add nodes, constrains and loads)*/
|
---|
53 | for(int i=0;i<nummodels;i++){
|
---|
54 |
|
---|
55 | int analysis_enum=analysis_enum_list[i];
|
---|
56 | parameters->AddObject(new IntParam(AnalysisCounterEnum,i));
|
---|
57 |
|
---|
58 | if(VerboseMProcessor()) _printf0_(" creating datasets for analysis " << EnumToStringx(analysis_enum) << "\n");
|
---|
59 | Analysis* analysis = EnumToAnalysis(analysis_enum);
|
---|
60 | analysis->UpdateParameters(parameters,iomodel,solution_enum,analysis_enum);
|
---|
61 | analysis->CreateNodes(nodes[i],iomodel);
|
---|
62 | analysis->UpdateElements(elements,inputs2,iomodel,i,analysis_enum);
|
---|
63 | analysis->CreateConstraints(constraints[i],iomodel);
|
---|
64 | analysis->CreateLoads(loads[i],iomodel);
|
---|
65 | delete analysis;
|
---|
66 |
|
---|
67 | /*Tell datasets that Ids are already sorted*/
|
---|
68 | constraints[i]->Presort();
|
---|
69 | loads[i]->Presort();
|
---|
70 | nodes[i]->Presort();
|
---|
71 |
|
---|
72 | /*Finalize loads (count pengrids,penpairs,rifts,etc)*/
|
---|
73 | loads[i]->Finalize();
|
---|
74 | }
|
---|
75 |
|
---|
76 | /*Solution specific updates*/
|
---|
77 | if(VerboseMProcessor()) _printf0_(" updating elements and materials for control parameters" << "\n");
|
---|
78 | UpdateElementsAndMaterialsControl(elements,parameters,inputs2,materials,iomodel);
|
---|
79 | #ifdef _HAVE_DAKOTA_
|
---|
80 | if(VerboseMProcessor()) _printf0_(" updating elements and materials for uncertainty quantification" << "\n");
|
---|
81 | UpdateElementsAndMaterialsDakota(elements,inputs2,materials,iomodel);
|
---|
82 | #endif
|
---|
83 | if(solution_enum==TransientSolutionEnum) UpdateElementsTransient(elements,parameters,inputs2,iomodel);
|
---|
84 |
|
---|
85 | /*Output definitions dataset: */
|
---|
86 | if(VerboseMProcessor()) _printf0_(" creating output definitions" << "\n");
|
---|
87 | CreateOutputDefinitions(elements,parameters,inputs2,iomodel);
|
---|
88 |
|
---|
89 | /* Sort datasets:
|
---|
90 | * All our datasets are already ordered by ids. Set presort flag so that
|
---|
91 | * later on, when sorting is requested on these datasets, it will not be
|
---|
92 | * redone: */
|
---|
93 | elements->Presort();
|
---|
94 | vertices->Presort();
|
---|
95 | materials->Presort();
|
---|
96 |
|
---|
97 | /*Assign output pointers:*/
|
---|
98 | *pelements = elements;
|
---|
99 | *pnodes = nodes;
|
---|
100 | *pvertices = vertices;
|
---|
101 | *pmaterials = materials;
|
---|
102 | *pconstraints = constraints;
|
---|
103 | *ploads = loads;
|
---|
104 | *pparameters = parameters;
|
---|
105 | *pinputs2 = inputs2;
|
---|
106 |
|
---|
107 | if(VerboseMProcessor()) _printf0_(" done with model processor \n");
|
---|
108 | }
|
---|