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 |
|
---|
35 | double* responses_pointer=NULL;
|
---|
36 |
|
---|
37 | /*retrieve npart: */
|
---|
38 | parameters->FindParam(&npart,QmuNumberofpartitionsEnum);
|
---|
39 |
|
---|
40 | /*save the d_responses pointer: */
|
---|
41 | responses_pointer=d_responses;
|
---|
42 |
|
---|
43 | //watch out, we have more d_numresponses than numresponsedescriptors, because the responses have been expanded if they were scaled.
|
---|
44 | //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: */
|
---|
45 |
|
---|
46 | for(i=0;i<numresponsedescriptors;i++){
|
---|
47 |
|
---|
48 | flag=DescriptorIndex(root,&index,responses_descriptors[i]);
|
---|
49 |
|
---|
50 | if(flag==ScaledEnum){
|
---|
51 |
|
---|
52 | /*this response was scaled. pick up the response from the inputs: */
|
---|
53 | GetVectorFromInputsx(&vertex_response,elements,nodes, vertices, loads, materials, parameters, StringToEnumx(root),VertexEnum);
|
---|
54 |
|
---|
55 | /*Now, average it onto the partition nodes: */
|
---|
56 | AverageOntoPartitionx(&qmu_response,elements,nodes,vertices,loads,materials,parameters,vertex_response);
|
---|
57 |
|
---|
58 | /*Copy onto our dakota responses: */
|
---|
59 | if(my_rank==0){
|
---|
60 | /*plug response: */
|
---|
61 | for(i=0;i<npart;i++)responses_pointer[i]=qmu_response[i];
|
---|
62 |
|
---|
63 | /*increment response_pointer :*/
|
---|
64 | responses_pointer+=npart;
|
---|
65 | }
|
---|
66 |
|
---|
67 | /*Free ressources:*/
|
---|
68 | xfree((void**)&vertex_response);
|
---|
69 | xfree((void**)&qmu_response);
|
---|
70 |
|
---|
71 | }
|
---|
72 | else if (flag==IndexedEnum){
|
---|
73 |
|
---|
74 | /*indexed response: plug index into parameters and call response module: */
|
---|
75 | parameters->SetParam(index,IndexEnum);
|
---|
76 |
|
---|
77 | //Responsex(responses_pointer,elements,nodes, vertices,loads,materials, parameters,root,process_units);
|
---|
78 | Responsex(&femmodel_response,elements,nodes, vertices,loads,materials, parameters,root,process_units,0);//0 is the index for weights
|
---|
79 |
|
---|
80 | if(my_rank==0){
|
---|
81 | /*plug response: */
|
---|
82 | responses_pointer[0]=femmodel_response;
|
---|
83 |
|
---|
84 | /*increment response_pointer :*/
|
---|
85 | responses_pointer++;
|
---|
86 | }
|
---|
87 | }
|
---|
88 | else if (flag==NodalEnum){
|
---|
89 | _error_(" nodal response functions not supported yet!");
|
---|
90 |
|
---|
91 | /*increment response_pointer :*/
|
---|
92 | responses_pointer++;
|
---|
93 | }
|
---|
94 | else if (flag==RegularEnum){
|
---|
95 |
|
---|
96 | /*perfectly normal response function: */
|
---|
97 | Responsex(&femmodel_response,elements,nodes, vertices,loads,materials, parameters,root,process_units,0);//0 is the weight index
|
---|
98 |
|
---|
99 | if(my_rank==0){
|
---|
100 | /*plug response: */
|
---|
101 | responses_pointer[0]=femmodel_response;
|
---|
102 |
|
---|
103 | /*increment response_pointer :*/
|
---|
104 | responses_pointer++;
|
---|
105 | }
|
---|
106 | }
|
---|
107 | else _error_("%s%i%s"," flag type ",flag," not supported yet for response analysis");
|
---|
108 | }
|
---|
109 |
|
---|
110 |
|
---|
111 | /*Synthesize echo: {{{*/
|
---|
112 | if(my_rank==0){
|
---|
113 | printf(" responses: %i: ",d_numresponses);
|
---|
114 | for(i=0;i<d_numresponses-1;i++)printf("%g|",d_responses[i]);
|
---|
115 | printf("%g",d_responses[d_numresponses-1]);
|
---|
116 | printf("\n");
|
---|
117 | }
|
---|
118 | /*}}}*/
|
---|
119 |
|
---|
120 | }
|
---|