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

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

CHG: added mass flux as a possible dependent variable.
In order not to conflict with the qmu Dakota capabilities for computation
of mass fluxes, I had to generalize the treatment of mass flux segments
in the ModelProcessorx, and throughout the m/classes code.

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