Changeset 4454
- Timestamp:
- 07/07/10 18:33:24 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp
r4453 r4454 8 8 #include "../../toolkits/toolkits.h" 9 9 #include "../../EnumDefinitions/EnumDefinitions.h" 10 #include "../modules.h" 10 11 11 void InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters, double* variables,char* *variables_descriptors,int numvariables){12 void InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,Vec vec_partition,double* variables,char* *variables_descriptors,int numvariables){ 12 13 14 int i,j,k; 15 int dummy; 16 13 17 int verbose; 18 int numberofvertices; 14 19 int qmu_npart; 15 double* qmu_part=NULL; 16 int dummy; 20 double *qmu_part_serial = NULL; 21 double *qmu_part = NULL; 22 23 double* distributed_values=NULL; 24 double* parameter=NULL; 25 double* parameter_serial=NULL; 26 char* descriptor=NULL; 27 char* root=NULL; //root name of distributed variable, ex: thickness, drag, etc ... 28 double* partition=NULL; //serial version of vec_partition 17 29 18 30 /*retrieve parameters: */ 19 31 parameters->FindParam(&verbose,VerboseEnum); 20 32 parameters->FindParam(&qmu_npart,QmuNPartEnum); 21 parameters->FindParam(&qmu_part,&dummy,QmuPartEnum); 33 parameters->FindParam(&qmu_part_serial,&dummy,QmuPartEnum); 34 numberofvertices=vertices->NumberOfVertices(); 22 35 23 ISSMERROR(" not supported yet!"); 36 /*serialize partition vector: */ 37 VecToMPISerial(&partition,vec_partition); 38 39 /*Use partition vector to repartition qmu_part, which is ordered in a serial way: */ 40 qmu_part=(double*)xmalloc(numberofvertices*sizeof(double)); 41 for(k=0;k<numberofvertices;k++) qmu_part[(int)(partition[k])]=qmu_part_serial[k]; 42 43 /*Go through all dakota descriptors, ex: "rho_ice","thermal_conductivity","thickness1","thickness2", etc ..., and 44 * for each descriptor, take the variable value and plug it into the inputs: */ 45 46 for(i=0;i<numvariables;i++){ 47 48 descriptor=variables_descriptors[i]; 49 50 /*From descriptor, figure out if the variable is distributed (distributed implies there is a numeric value at the 51 * end of the descriptor, for ex: thickness1, thickness10, etc .... If it is distributed, the next qmu_npart (number 52 * of partitions in the distributed variable) variable are the values for each partition of the distributed variable: */ 53 if (!isdistributed(&root,descriptor)){ 54 55 /*Ok, variable is not distributed, just update inputs using the variable: */ 56 InputUpdateFromConstantx( elements,nodes, vertices,loads, materials, parameters, variables[i],StringAsEnum(descriptor)); 57 58 } 59 else{ 60 61 /*Ok, variable is distributed. Root name of variable is also known. Now, allocate distributed_values and fill the 62 * distributed_values with the next qmu_npart variables: */ 63 64 distributed_values=(double*)xmalloc(qmu_npart*sizeof(double)); 65 for(j=0;j<qmu_npart;j++){ 66 distributed_values[j]=variables[i+j]; 67 } 68 69 /*Now, pick up the parameter corresponding to root: */ 70 parameters->FindParam(¶meter_serial,NULL,NULL,StringAsEnum(root)); 71 72 /*repartition parameter: */ 73 parameter=(double*)xmalloc(numberofvertices*sizeof(double)); 74 for(k=0;k<numberofvertices;k++) parameter[(int)(partition[k])]=parameter_serial[k]; 75 76 /*We've got the parameter, we need to update it using qmu_part (a partitioning vector), and the distributed_values: */ 77 for(k=0;k<numberofvertices;k++){ 78 parameter[k]=parameter[k]*distributed_values[(int)qmu_part[k]]; 79 } 80 81 #ifdef _ISSM_DEBUG_ 82 PetscSynchronizedPrintf(MPI_COMM_WORLD,"Parameter vetor:"); 83 PetscSynchronizedFlush(MPI_COMM_WORLD); 84 for(k=0;k<numberofvertices;k++){ 85 PetscSynchronizedPrintf(MPI_COMM_WORLD," node %i value %g\n",k+1,parameter[k]); 86 PetscSynchronizedFlush(MPI_COMM_WORLD); 87 } 88 #endif 89 90 91 /*Update inputs using the parameter vector: */ 92 InputUpdateFromVectorx( elements,nodes, vertices,loads, materials, parameters, parameter, StringAsEnum(root), VertexEnum); 93 94 /*increment i to skip the distributed values just collected: */ 95 i+=qmu_npart-1; //careful, the for loop will add 1. 96 97 /*Free allocations: */ 98 xfree((void**)¶meter); 99 xfree((void**)¶meter_serial); 100 xfree((void**)&distributed_values); 101 102 } 103 xfree((void**)&root); 104 } 105 106 /*Free ressources:*/ 107 xfree((void**)&partition); 108 xfree((void**)&qmu_part); 109 xfree((void**)&qmu_part_serial); 110 24 111 } -
issm/trunk/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.h
r4453 r4454 9 9 #include "../../Container/Container.h" 10 10 11 void InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters, double* variables,char* *variables_descriptors,int numvariables);11 void InputUpdateFromDakotax(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,Vec partition,double* variables,char* *variables_descriptors,int numvariables); 12 12 13 13 #endif /* _INPUTUPDATEFROMDAKOTAXX_H */ -
issm/trunk/src/c/modules/Qmux/SpawnCoreParallel.cpp
r4453 r4454 61 61 62 62 /*Modify core inputs in objects contained in femmodel, to reflect the dakota variables inputs: */ 63 InputUpdateFromDakotax(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters, variables,variables_descriptors,numvariables);63 InputUpdateFromDakotax(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,femmodel->partition,variables,variables_descriptors,numvariables); 64 64 65 65 /*Run the core solution sequence: */ -
issm/trunk/src/m/solutions/SpawnCore.m
r4439 r4454 14 14 15 15 %first update the inputs to the femmodel using the variables provided to us by dakota. 16 [femmodel.elements femmodel.loads]=InputUpdateFromDakota(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters, variables,variabledescriptors);16 [femmodel.elements femmodel.loads]=InputUpdateFromDakota(femmodel.elements,femmodel.nodes,femmodel.vertices,femmodel.loads,femmodel.materials,femmodel.parameters,femmodel.partition,variables,variabledescriptors); 17 17 18 18 %now run the core solution -
issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.cpp
r4453 r4454 22 22 int numvariables; 23 23 mxArray* pfield=NULL; 24 Vec partition=NULL; 24 25 25 26 /*Boot module: */ … … 36 37 FetchData((DataSet**)&materials,MATERIALSIN); 37 38 FetchParams(¶meters,PARAMETERSIN); 39 FetchData(&partition,PARTITION); 38 40 39 41 /*dakota input: */ … … 51 53 52 54 /*!Generate internal degree of freedom numbers: */ 53 InputUpdateFromDakotax(elements,nodes,vertices,loads, materials,parameters, variables,variables_descriptors,numvariables);55 InputUpdateFromDakotax(elements,nodes,vertices,loads, materials,parameters,partition,variables,variables_descriptors,numvariables); 54 56 55 57 /*write output datasets: */ … … 64 66 delete materials; 65 67 delete parameters; 68 VecFree(&partition); 66 69 67 70 xfree((void**)&variables); -
issm/trunk/src/mex/InputUpdateFromDakota/InputUpdateFromDakota.h
r4439 r4454 24 24 #define MATERIALSIN (mxArray*)prhs[4] 25 25 #define PARAMETERSIN (mxArray*)prhs[5] 26 #define VARIABLES (mxArray*)prhs[6] 27 #define VARIABLESDESCRIPTORS (mxArray*)prhs[7] 26 #define PARTITION (mxArray*)prhs[6] 27 #define VARIABLES (mxArray*)prhs[7] 28 #define VARIABLESDESCRIPTORS (mxArray*)prhs[8] 28 29 29 30 /* serial output macros: */ … … 35 36 #define NLHS 2 36 37 #undef NRHS 37 #define NRHS 838 #define NRHS 9 38 39 39 40 #endif /* _UPDATEINPUTSFROMDAKOTA_H */
Note:
See TracChangeset
for help on using the changeset viewer.