1 | /*!\file DakotaResponsesx
|
---|
2 | * \brief: update datasets using parameter inputs
|
---|
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 "./DakotaResponsesx.h"
|
---|
12 | #include "../../Container/Container.h"
|
---|
13 | #include "../../shared/shared.h"
|
---|
14 | #include "../../include/include.h"
|
---|
15 | #include "../../EnumDefinitions/EnumDefinitions.h"
|
---|
16 | #include "../../toolkits/toolkits.h"
|
---|
17 | #include "../modules.h"
|
---|
18 |
|
---|
19 |
|
---|
20 | void DakotaResponsesx(double* d_responses,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,char** responses_descriptors,int numresponsedescriptors,int d_numresponses){
|
---|
21 |
|
---|
22 | int i,j,k;
|
---|
23 | extern int my_rank;
|
---|
24 | bool process_units = true;
|
---|
25 |
|
---|
26 | /*intermediary: */
|
---|
27 | char root[50];
|
---|
28 | int index;
|
---|
29 | int npart;
|
---|
30 | double femmodel_response;
|
---|
31 | int flag;
|
---|
32 | double *vertex_response = NULL;
|
---|
33 | double *qmu_response = NULL;
|
---|
34 | double *responses_pointer = NULL;
|
---|
35 |
|
---|
36 | /*retrieve npart: */
|
---|
37 | parameters->FindParam(&npart,QmuNumberofpartitionsEnum);
|
---|
38 |
|
---|
39 | /*save the d_responses pointer: */
|
---|
40 | responses_pointer=d_responses;
|
---|
41 |
|
---|
42 | //watch out, we have more d_numresponses than numresponsedescriptors, because the responses have been expanded if they were scaled.
|
---|
43 | //because we don't know the d_responses descriptors (the scaled ones) we can't key off them, so we will key off the responses_descriptors: */
|
---|
44 |
|
---|
45 | for(i=0;i<numresponsedescriptors;i++){
|
---|
46 |
|
---|
47 | flag=DescriptorIndex(root,&index,responses_descriptors[i]);
|
---|
48 |
|
---|
49 | if(flag==ScaledEnum){
|
---|
50 |
|
---|
51 | /*this response was scaled. pick up the response from the inputs: */
|
---|
52 | GetVectorFromInputsx(&vertex_response,elements,nodes, vertices, loads, materials, parameters, StringToEnumx(root),VertexEnum);
|
---|
53 |
|
---|
54 | /*Now, average it onto the partition nodes: */
|
---|
55 | AverageOntoPartitionx(&qmu_response,elements,nodes,vertices,loads,materials,parameters,vertex_response);
|
---|
56 |
|
---|
57 | /*Copy onto our dakota responses: */
|
---|
58 | if(my_rank==0){
|
---|
59 | /*plug response: */
|
---|
60 | for(i=0;i<npart;i++)responses_pointer[i]=qmu_response[i];
|
---|
61 |
|
---|
62 | /*increment response_pointer :*/
|
---|
63 | responses_pointer+=npart;
|
---|
64 | }
|
---|
65 |
|
---|
66 | /*Free ressources:*/
|
---|
67 | xDelete<double>(vertex_response);
|
---|
68 | xDelete<double>(qmu_response);
|
---|
69 |
|
---|
70 | }
|
---|
71 | else if (flag==IndexedEnum){
|
---|
72 |
|
---|
73 | /*indexed response: plug index into parameters and call response module: */
|
---|
74 | parameters->SetParam(index,IndexEnum);
|
---|
75 |
|
---|
76 | //Responsex(responses_pointer,elements,nodes, vertices,loads,materials, parameters,root,process_units);
|
---|
77 | Responsex(&femmodel_response,elements,nodes, vertices,loads,materials, parameters,root,process_units,0);//0 is the index for weights
|
---|
78 |
|
---|
79 | if(my_rank==0){
|
---|
80 | /*plug response: */
|
---|
81 | responses_pointer[0]=femmodel_response;
|
---|
82 |
|
---|
83 | /*increment response_pointer :*/
|
---|
84 | responses_pointer++;
|
---|
85 | }
|
---|
86 | }
|
---|
87 | else if (flag==NodalEnum){
|
---|
88 | _error_("nodal response functions not supported yet!");
|
---|
89 |
|
---|
90 | /*increment response_pointer :*/
|
---|
91 | responses_pointer++;
|
---|
92 | }
|
---|
93 | else if (flag==RegularEnum){
|
---|
94 |
|
---|
95 | /*perfectly normal response function: */
|
---|
96 | Responsex(&femmodel_response,elements,nodes, vertices,loads,materials, parameters,root,process_units,0);//0 is the weight index
|
---|
97 |
|
---|
98 | if(my_rank==0){
|
---|
99 | /*plug response: */
|
---|
100 | responses_pointer[0]=femmodel_response;
|
---|
101 |
|
---|
102 | /*increment response_pointer :*/
|
---|
103 | responses_pointer++;
|
---|
104 | }
|
---|
105 | }
|
---|
106 | else _error_("flag type " << flag << " not supported yet for response analysis");
|
---|
107 | }
|
---|
108 |
|
---|
109 |
|
---|
110 | /*Synthesize echo: {{{*/
|
---|
111 | if(my_rank==0){
|
---|
112 | _printString_(" responses: " << d_numresponses << ": ");
|
---|
113 | for(i=0;i<d_numresponses-1;i++)_printString_(d_responses[i] << "|");
|
---|
114 | _printString_(d_responses[d_numresponses-1]);
|
---|
115 | _printLine_("");
|
---|
116 | }
|
---|
117 | /*}}}*/
|
---|
118 |
|
---|
119 | }
|
---|