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