rebl-AMR
partition.h
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include "typedefs.h"
3 #include "tree.h"
4 #include "zoltan.h"
5 #include "communicate.h"
6 #include "params.h"
7 #define TOL "1.1"
8 
9 /*
10 
11  Two Different Data Structures are Used for Graph and Mesh Data
12  Only hypergraph can handle nonsymmetric graphs
13 
14  ----------------------------------------------------------------------
15  GEOMETRIC (Coordinate-Based) of Zoltan
16  ----------------------------------------------------------------------
17 
18  set method=1 for HSFC: Hilbert Space Filling Curve
19  set method=2 for RCB: Recursive Coordinate Bisection
20  set method=3 for RIB: Recursive Inertial Bisection
21 
22  need to use coordinate transformation to impose the principal peorcessor topology
23  direction, otherwise it this routine starts from z=0 plane, this
24  might not necessarily be the best option as it might require too many
25  elements to be moved unnecessarily, just rotate the xyz directions if you
26  have more processor in x and y directions. e.g. 3 1 1 is needs transformation
27  but 1 1 3 is ok, default is that nz>=ny and nz >=nx
28  -----------------------------------------------------------------------
29  HyperGraph of Zoltan
30  -----------------------------------------------------------------------
31 
32  For HyperGraph in Zoltan
33  set method=0
34  -----------------------------------------------------------------------
35  ParMETIS
36  -----------------------------------------------------------------------
37 
38  set method=1 for PARTKWAY
39  set method=2 for PARTGEOMKWAY (Hybrid Method uses geom+graph)
40  set method=3 for ADEAPTIVEREPART
41  set method=4 for PARTGEOM
42  the *c in GraphData is only assigned when needed
43  Default method is ADAPTIVEREPART as set per Zoltan
44 
45  #define TOL "1.1" defines the imbalance tolerance for
46  Graph and Hypergraph methods
47 
48  -----------------------------------------------------------------------
49 */
56 typedef struct
57 {
58  ZOLTAN_ID_TYPE numGlobalPoints;
59  ZOLTAN_ID_TYPE numMyPoints;
60  ZOLTAN_ID_PTR myGlobalIDs;
61  real *c;
62  real *w;
63 } MeshData;
64 
71 typedef struct
72 {
73  ZOLTAN_ID_TYPE numMyVertices; /* total vertices in in my partition */
74  // ZOLTAN_ID_TYPE numAllNbors; /* total number of neighbors of my vertices */
75  ZOLTAN_ID_PTR vertexGID; /* global ID of each of my vertices */
76  ZOLTAN_ID_PTR nbrIndex; /* nborIndex[i] is location of start of neighbors for vertex i */
77  ZOLTAN_ID_PTR nbrGID; /* nborGIDs[nborIndex[i]] is first neighbor of vertex i */
78  int *nbrProc; /* process owning each nbor in nborGID */
79  float *c; /* this one is for the center of the elements*/
80 } GraphData;
81 
82 
83 
84 
85 class Partition{
86 
87 private:
88 int size;
89 struct Zoltan_Struct *zz=NULL;
90 //Zoltan_Out *zoltan_out=NULL;
93 int method;
95 real *weight=nullptr;
96 
97 public:
98 Partition(int argcs,char *pArgs[],int meth,int sze);
100 void construct(int argcs,char *pArgs[],int meth,int sze );
101 void MPIStartUp();
102 void partition(double *ID, int totalvalue);
103 
104 bool zoltanGeometricPartitioner( const uint size, const uint ncube_total, const uint offset);
105 
106 void zoltanSetParams();
107 
108 //bool zoltanGeometricPartitionerSerial( const uint size, const uint ncube_total, const uint offset, int comsizei, struct Zoltan_Struct *zz, Zoltan_Out *zoltan_out );
109 bool zoltanGeometricPartitionerSerial( const uint size, const uint ncube_total, const uint offset, int comsize, Zoltan_Out *zoltan_out );
110 
111 /*
112 friend int get_number_of_objects( void *data, int *ierr );
113 
114 friend void get_object_list( void *data, int sizeGID, int sizeLID, ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID, int wgt_dim,
115  float *obj_wgts, int *ierr );
116 friend int get_num_geometry( void *data, int *ierr );
117 
118 friend void get_geometry_list( void *data, int sizeGID, int sizeLID, int num_obj, ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID,
119  int num_dim, double *geom_vec, int *ierr );
120 */
121 template <size_t N, typename Nvalue, size_t M, typename Mvalue >
122  friend class ReblAmr;
123 
124 ~Partition();
125 
126 };
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
void MPIStartUp()
Definition: partition.cpp:573
ZOLTAN_ID_TYPE numMyPoints
Definition: partition.h:59
ZOLTAN_ID_PTR nbrIndex
Definition: partition.h:76
Definition: partition.h:85
ZOLTAN_ID_PTR vertexGID
Definition: partition.h:75
ZOLTAN_ID_TYPE numGlobalPoints
Definition: partition.h:58
real * c
Definition: partition.h:61
real * w
Definition: partition.h:62
bool zoltanGeometricPartitionerSerial(const uint size, const uint ncube_total, const uint offset, int comsize, Zoltan_Out *zoltan_out)
Definition: partition.cpp:306
ZOLTAN_ID_PTR nbrGID
Definition: partition.h:77
bool zoltanGeometricPartitioner(const uint size, const uint ncube_total, const uint offset)
ZOLTAN_ID_TYPE numMyVertices
Definition: partition.h:73
MpiCom Com
Definition: partition.h:91
Definition: ReblAmr.h:19
struct Zoltan_Struct * zz
Definition: partition.h:89
MeshData myMesh
Definition: partition.h:92
real * weight
Definition: partition.h:95
~Partition()
Definition: partition.cpp:121
void partition(double *ID, int totalvalue)
struct to supply information required by zoltan for geometric partitioners
Definition: partition.h:56
int method
Definition: partition.h:93
Partition()
Definition: partition.h:99
int size
Definition: partition.h:88
double real
Definition: definitions.h:37
unsigned int uint
Definition: definitions.h:38
struct to supply information required by zoltan for geometric partitioners
Definition: partition.h:71
ZOLTAN_ID_PTR myGlobalIDs
Definition: partition.h:60
std::vector< CenterCoords > Center_coords
Definition: typedefs.h:20
int * nbrProc
Definition: partition.h:78
This structure is an interface to store the output from Zoltan.
Definition: typedefs.h:29
class for embedding data related to the communicator
Definition: communicate.h:10
void construct(int argcs, char *pArgs[], int meth, int sze)
Definition: partition.cpp:69
void zoltanSetParams()
Definition: partition.cpp:528
Center_coords XYZ
Definition: partition.h:94
float * c
Definition: partition.h:79