[1] | 1 | /*!\file ProcessParamsx
|
---|
[765] | 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.
|
---|
[1] | 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"
|
---|
[765] | 17 | #include "../DataSet/DataSet.h"
|
---|
[1] | 18 | #include "../EnumDefinitions/EnumDefinitions.h"
|
---|
| 19 |
|
---|
| 20 | void ProcessParamsx( DataSet* parameters, Vec part){
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | double* partition=NULL;
|
---|
| 24 | Param* param=NULL;
|
---|
[202] | 25 |
|
---|
| 26 | /*diverse: */
|
---|
[1] | 27 | int numberofnodes;
|
---|
[765] | 28 | int i,j,k;
|
---|
| 29 | int ndof;
|
---|
[1] | 30 |
|
---|
[765] | 31 | /*processing of parameters: */
|
---|
| 32 | double* parameter=NULL;
|
---|
| 33 | double* new_parameter=NULL;
|
---|
| 34 |
|
---|
| 35 | /*Some parameters needed: */
|
---|
[2333] | 36 | parameters->FindParam(&numberofnodes,"numberofnodes");
|
---|
[1] | 37 |
|
---|
[765] | 38 | /*serialize partition vector: */
|
---|
[304] | 39 | if(part)VecToMPISerial(&partition,part);
|
---|
[202] | 40 |
|
---|
[765] | 41 | for(i=0;i<parameters->Size();i++){
|
---|
[202] | 42 |
|
---|
[765] | 43 | Param* param=(Param*)parameters->GetObjectByOffset(i);
|
---|
[202] | 44 |
|
---|
[765] | 45 | if (param->GetType()==DOUBLEVEC){
|
---|
[202] | 46 |
|
---|
[765] | 47 | ndof=param->GetNdof();
|
---|
[202] | 48 |
|
---|
[765] | 49 | if (ndof!=0){ /*ok, we are dealing with a parameter that needs to be repartitioned, for ndof degrees of freedom: */
|
---|
[202] | 50 |
|
---|
[765] | 51 | new_parameter=(double*)xcalloc(numberofnodes*ndof,sizeof(double));
|
---|
| 52 | param->GetParameterValue(¶meter);
|
---|
[202] | 53 |
|
---|
[765] | 54 | for(j=0;j<ndof;j++){
|
---|
[202] | 55 |
|
---|
[765] | 56 | for(k=0;k<numberofnodes;k++){
|
---|
| 57 |
|
---|
| 58 | new_parameter[(int)(ndof*partition[k]+j)]=parameter[ndof*k+j];
|
---|
[1] | 59 |
|
---|
[765] | 60 | }
|
---|
[1] | 61 |
|
---|
[765] | 62 | }
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | /*Now, replace old parameter with new parameter: */
|
---|
| 66 | param->SetDoubleVec(new_parameter,ndof*numberofnodes,ndof);
|
---|
[202] | 67 |
|
---|
[765] | 68 | /*Free ressources: */
|
---|
| 69 | xfree((void**)&new_parameter);
|
---|
[1937] | 70 | xfree((void**)¶meter);
|
---|
[1] | 71 |
|
---|
[765] | 72 | }
|
---|
[1] | 73 | }
|
---|
| 74 | }
|
---|
[1937] | 75 | xfree((void**)&partition);
|
---|
[1] | 76 |
|
---|
| 77 | }
|
---|