source: issm/trunk/src/c/modules/ModelProcessorx/ModelProcessorx.cpp@ 23189

Last change on this file since 23189 was 23189, checked in by Mathieu Morlighem, 7 years ago

merged trunk-jpl and trunk for revision 23187

File size: 3.9 KB
Line 
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
15void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters,IoModel* 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
19 /*Initialize datasets*/
20 Elements *elements = new Elements();
21 Nodes *nodes = new Nodes();
22 Vertices *vertices = new Vertices();
23 Materials *materials = new Materials();
24 Constraints *constraints = new Constraints();
25 Loads *loads = new Loads();
26 Parameters *parameters = new Parameters();
27
28 /*Fetch parameters: */
29 iomodel->FindConstant(&verbose,"md.verbose");
30 SetVerbosityLevel(verbose);
31
32 if(VerboseMProcessor()) _printf0_(" starting model processor \n");
33
34 /*Partition Elements and Nodes*/
35 ElementsAndVerticesPartitioning(&iomodel->my_elements,&iomodel->my_vertices,iomodel);
36
37 /*Create elements, vertices and materials, independent of analysis_enum: */
38 CreateElementsVerticesAndMaterials(elements,vertices,materials,iomodel,nummodels,solution_enum);
39
40 /*Create Parameters*/
41 CreateParameters(parameters,iomodel,rootpath,toolkitfile,solution_enum);
42
43 for(i=0;i<nummodels;i++){
44
45 analysis_enum=analysis_enum_list[i];
46 parameters->AddObject(new IntParam(AnalysisCounterEnum,i));
47
48 if(VerboseMProcessor()) _printf0_(" creating datasets for analysis " << EnumToStringx(analysis_enum) << "\n");
49 Analysis* analysis = EnumToAnalysis(analysis_enum);
50 analysis->UpdateParameters(parameters,iomodel,solution_enum,analysis_enum);
51 analysis->CreateNodes(nodes,iomodel);
52 analysis->CreateConstraints(constraints,iomodel);
53 analysis->CreateLoads(loads,iomodel);
54 analysis->UpdateElements(elements,iomodel,i,analysis_enum);
55 delete analysis;
56
57 /* Update counters, because we have created more nodes, loads and
58 * constraints, and ids for objects created in next call to CreateDataSets
59 * will need to start at the end of the updated counters: */
60 if(nodes->Size()) iomodel->nodecounter = nodes->MaximumId();
61 iomodel->loadcounter = loads->NumberOfLoads();
62 iomodel->constraintcounter = constraints->NumberOfConstraints();
63
64 /*Make sure nodecounter is at least 0 (if no node exists, maxid will be -1*/
65 _assert_(iomodel->nodecounter>=0);
66 }
67
68 /*Solution specific updates*/
69 if(VerboseMProcessor()) _printf0_(" updating elements and materials for control parameters" << "\n");
70 UpdateElementsAndMaterialsControl(elements,parameters,materials,iomodel);
71 #ifdef _HAVE_DAKOTA_
72 if(VerboseMProcessor()) _printf0_(" updating elements and materials for uncertainty quantification" << "\n");
73 UpdateElementsAndMaterialsDakota(elements,materials,iomodel);
74 #endif
75 if(solution_enum==TransientSolutionEnum){
76 UpdateElementsTransient(elements,parameters,iomodel,analysis_enum);
77 }
78
79 /*Output definitions dataset: */
80 if(VerboseMProcessor()) _printf0_(" creating output definitions" << "\n");
81 CreateOutputDefinitions(elements,parameters,iomodel);
82
83 /* Sort datasets:
84 * All our datasets are already ordered by ids. Set presort flag so that
85 * later on, when sorting is requested on these datasets, it will not be
86 * redone: */
87 elements->Presort();
88 nodes->Presort();
89 vertices->Presort();
90 loads->Presort();
91 materials->Presort();
92
93 constraints->Presort();
94 if(VerboseMProcessor()) _printf0_(" done with model processor \n");
95
96 /*Assign output pointers:*/
97 *pelements = elements;
98 *pnodes = nodes;
99 *pvertices = vertices;
100 *pmaterials = materials;
101 *pconstraints = constraints;
102 *ploads = loads;
103 *pparameters = parameters;
104}
Note: See TracBrowser for help on using the repository browser.