source: issm/trunk-jpl/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp@ 14917

Last change on this file since 14917 was 14917, checked in by Eric.Larour, 12 years ago

CHG: got rid of the include/include.h headere file, finally :)

File size: 4.8 KB
Line 
1/*!\file: CreateParametersDakota.cpp
2 * \brief general driver for creating parameters dataset
3 */
4
5#include "../../../Container/Container.h"
6#include "../../../toolkits/toolkits.h"
7#include "../../../EnumDefinitions/EnumDefinitions.h"
8#include "../../../classes/objects/objects.h"
9#include "../../../shared/shared.h"
10#include "../../../io/io.h"
11#include "../../MeshPartitionx/MeshPartitionx.h"
12#include "../ModelProcessorx.h"
13
14void CreateParametersDakota(Parameters** pparameters,IoModel* iomodel,char* rootpath,int solution_type,int analysis_type){
15
16 /*variable declarations: {{{*/
17 int i;
18 Parameters* parameters = NULL;
19
20 int* part=NULL;
21 double* dpart=NULL;
22
23 char** responsedescriptors=NULL;
24 int numresponsedescriptors;
25 char** variabledescriptors=NULL;
26 int numvariabledescriptors;
27 char* descriptor=NULL;
28 double* dakota_parameter=NULL;
29
30 //qmu files
31 char* qmuinname=NULL;
32 char* qmuerrname=NULL;
33 char* qmuoutname=NULL;
34
35 //descriptors:
36 char tag[50];
37
38 bool dakota_analysis=false;
39 char* name=NULL;
40 int numberofresponses;
41 int numberofvertices;
42 int nrows;
43 int ncols;
44
45 /*}}}*/
46
47 /*recover parameters : */
48 parameters=*pparameters;
49
50 /*recover parameters: */
51 iomodel->Constant(&dakota_analysis,QmuIsdakotaEnum);
52
53 if(dakota_analysis){
54
55 iomodel->Constant(&name,MiscellaneousNameEnum);
56 iomodel->Constant(&numberofresponses,QmuNumberofresponsesEnum);
57 iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
58
59 /*name of qmu input, error and output files:{{{*/
60 qmuinname=xNew<char>((strlen(rootpath)+strlen(name)+strlen(".qmu.in")+1));
61 sprintf(qmuinname,"%s%s%s",rootpath,name,".qmu.in");
62 parameters->AddObject(new StringParam(QmuInNameEnum,qmuinname));
63
64 qmuoutname=xNew<char>((strlen(rootpath)+strlen(name)+strlen(".qmu.out")+1));
65 sprintf(qmuoutname,"%s%s%s",rootpath,name,".qmu.out");
66 parameters->AddObject(new StringParam(QmuOutNameEnum,qmuoutname));
67
68 qmuerrname=xNew<char>((strlen(rootpath)+strlen(name)+strlen(".qmu.err")+1));
69 sprintf(qmuerrname,"%s%s%s",rootpath,name,".qmu.err");
70 parameters->AddObject(new StringParam(QmuErrNameEnum,qmuerrname));
71 /*}}}*/
72 /*Fetch variable descriptors: {{{*/
73 iomodel->FetchData(&variabledescriptors,&numvariabledescriptors,QmuVariabledescriptorsEnum);
74
75 /*Ok, we have all the variable descriptors. Build a parameter with it: */
76 parameters->AddObject(new StringArrayParam(QmuVariabledescriptorsEnum,variabledescriptors,numvariabledescriptors));
77
78 /*}}}*/
79 /*Fetch response descriptors: {{{*/
80 iomodel->FetchData(&responsedescriptors,&numresponsedescriptors,QmuResponsedescriptorsEnum);
81
82 /*Ok, we have all the response descriptors. Build a parameter with it: */
83 parameters->AddObject(new StringArrayParam(QmuResponsedescriptorsEnum,responsedescriptors,numresponsedescriptors));
84 parameters->AddObject(new IntParam(QmuNumberofresponsesEnum,numberofresponses));
85 /*}}}*/
86 /*Deal with partitioning: {{{*/
87 /*partition vertices in iomodel->qmu_npart parts, unless a partition is already present: */
88
89 parameters->AddObject(iomodel->CopyConstantObject(QmuNumberofpartitionsEnum));
90 iomodel->FetchData(&dpart,NULL,NULL,QmuPartitionEnum);
91
92 if(!dpart){
93
94 /*Partition elements and vertices and nodes: */
95 ElementsAndVerticesPartitioning(&iomodel->my_elements,&iomodel->my_vertices,iomodel);
96
97 dpart=xNew<double>(numberofvertices);
98 for(i=0;i<numberofvertices;i++)dpart[i]=iomodel->my_vertices[i];
99 }
100 parameters->AddObject(new DoubleVecParam(QmuPartitionEnum,dpart,numberofvertices));
101 /*}}}*/
102 /*Deal with data needed because of qmu variables: {{{*/
103
104 for(i=0;i<numvariabledescriptors;i++){
105
106 if (strncmp(variabledescriptors[i],"scaled_",7)==0){
107 /*Ok, we are dealing with a variable that is distributed over nodes. Recover the name of the variable (ex: scaled_Thickness): */
108 sscanf(variabledescriptors[i],"scaled_%s",tag);
109
110 /*Recover data: */
111 iomodel->FetchData(&dakota_parameter,&nrows,&ncols,StringToEnumx(tag));
112
113 /*Add to parameters: */
114 if(nrows==numberofvertices){
115 parameters->AddObject(new DoubleMatParam(StringToEnumx(tag),dakota_parameter,nrows,ncols));
116 }
117 else{
118 parameters->AddObject(new DoubleTransientMatParam(StringToEnumx(tag),dakota_parameter,nrows,ncols));
119 }
120
121 /*Free ressources:*/
122 xDelete<double>(dakota_parameter);
123 }
124 }
125 /*}}}*/
126 /*Free data: {{{*/
127 for(i=0;i<numresponsedescriptors;i++){
128 descriptor=responsedescriptors[i];
129 xDelete<char>(descriptor);
130 }
131 xDelete<char*>(responsedescriptors);
132
133 for(i=0;i<numvariabledescriptors;i++){
134 descriptor=variabledescriptors[i];
135 xDelete<char>(descriptor);
136 }
137 xDelete<char*>(variabledescriptors);
138 xDelete<int>(part);
139 xDelete<double>(dpart);
140 xDelete<char>(qmuinname);
141 xDelete<char>(qmuerrname);
142 xDelete<char>(qmuoutname);
143 /*}}}*/
144 } //if(dakota_analysis)
145
146 /*Free data*/
147 xDelete<char>(name);
148
149 /*Assign output pointer: */
150 *pparameters=parameters;
151}
Note: See TracBrowser for help on using the repository browser.