1 | /*!\file ProcessParamsx
|
---|
2 | * \brief: process parameters using partitioning vector.
|
---|
3 | * Go through all parameters in the 'parameters' dataset. For each parameter that holds a doublevec (ie, a double* vector synchronized across
|
---|
4 | * the MPI ring of a cluster), partition the vector so that the new node partitioning decided in ModelProcessor is applied. Otherwise,
|
---|
5 | * parameters coming directly from Matlab would be serially partitioned, which means could not be recognized by each individual node or element.
|
---|
6 | * The partition needs to be the parallel partitionting.
|
---|
7 | */
|
---|
8 |
|
---|
9 | #include "./ProcessParamsx.h"
|
---|
10 |
|
---|
11 | #undef __FUNCT__
|
---|
12 | #define __FUNCT__ "ProcessParamsx"
|
---|
13 |
|
---|
14 | #include "../shared/shared.h"
|
---|
15 | #include "../include/macros.h"
|
---|
16 | #include "../toolkits/toolkits.h"
|
---|
17 | #include "../DataSet/DataSet.h"
|
---|
18 | #include "../EnumDefinitions/EnumDefinitions.h"
|
---|
19 |
|
---|
20 | void ProcessParamsx( DataSet* parameters, Vec part){
|
---|
21 |
|
---|
22 |
|
---|
23 | double* partition=NULL;
|
---|
24 | Param* param=NULL;
|
---|
25 |
|
---|
26 | /*diverse: */
|
---|
27 | int numberofnodes;
|
---|
28 | int i,j,k;
|
---|
29 | int ndof;
|
---|
30 |
|
---|
31 | /*processing of parameters: */
|
---|
32 | double* parameter=NULL;
|
---|
33 | double* new_parameter=NULL;
|
---|
34 |
|
---|
35 | /*Some parameters needed: */
|
---|
36 | parameters->FindParam((void*)&numberofnodes,"numberofnodes");
|
---|
37 |
|
---|
38 | /*serialize partition vector: */
|
---|
39 | if(part)VecToMPISerial(&partition,part);
|
---|
40 |
|
---|
41 | for(i=0;i<parameters->Size();i++){
|
---|
42 |
|
---|
43 | Param* param=(Param*)parameters->GetObjectByOffset(i);
|
---|
44 |
|
---|
45 | if (param->GetType()==DOUBLEVEC){
|
---|
46 |
|
---|
47 | ndof=param->GetNdof();
|
---|
48 |
|
---|
49 | if (ndof!=0){ /*ok, we are dealing with a parameter that needs to be repartitioned, for ndof degrees of freedom: */
|
---|
50 |
|
---|
51 | new_parameter=(double*)xcalloc(numberofnodes*ndof,sizeof(double));
|
---|
52 | param->GetParameterValue(¶meter);
|
---|
53 |
|
---|
54 | for(j=0;j<ndof;j++){
|
---|
55 |
|
---|
56 | for(k=0;k<numberofnodes;k++){
|
---|
57 |
|
---|
58 | new_parameter[(int)(ndof*partition[k]+j)]=parameter[ndof*k+j];
|
---|
59 |
|
---|
60 | }
|
---|
61 |
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | /*Now, replace old parameter with new parameter: */
|
---|
66 | param->SetDoubleVec(new_parameter,ndof*numberofnodes,ndof);
|
---|
67 |
|
---|
68 | /*Free ressources: */
|
---|
69 | xfree((void**)&new_parameter);
|
---|
70 |
|
---|
71 | }
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | }
|
---|