source: issm/trunk/src/c/ProcessParamsx/ProcessParamsx.cpp@ 3673

Last change on this file since 3673 was 3673, checked in by Eric.Larour, 15 years ago

Redid Params and Inputs

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