OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
SubdomainGraphNodes.hpp
1 #ifndef SUBDOMAIN_NODES_HPP
2 #define SUBDOMAIN_NODES_HPP
3 
4 #include <boost/fusion/container/vector.hpp>
5 #include <boost/fusion/include/at_c.hpp>
6 #include "memory_ly/Encap.hpp"
7 
8 /* In a decomposition graph each node represent a sub-domain while an edge represent
9  * an interaction between sub-domain (it mean that they have to communicate).
10  *
11  * Here we list the of property that a vertex node can carry with a brief
12  * explanation:
13  *
14  * x = position x of the sub-domain
15  * y = position y of the sub-domain
16  * z = position z of the sub-domain
17  * communication = is the estimated total communication produced by the sub-domain
18  * computation = the total computation produced by the sub-domain
19  * memory = estimated memory required by the sub-domain
20  * id = which processor own this sub-domain
21  * sub-id = sub-decomposition where each group of sub-domain is organized in an
22  * hyper-cube
23  *
24  * Here we list the properties that an edge node can carry with a brief explanation
25  *
26  * communication = is the estimated communication between sub-domains
27  *
28  */
29 
30 constexpr unsigned int nm_v_x = 0;
31 constexpr unsigned int nm_v_migration = 1;
32 constexpr unsigned int nm_v_computation = 2;
33 constexpr unsigned int nm_v_global_id = 3;
34 constexpr unsigned int nm_v_id = 4;
35 constexpr unsigned int nm_v_sub_id = 5;
36 constexpr unsigned int nm_v_proc_id = 6;
37 
38 template<unsigned int dim>
39 struct nm_v
40 {
42  typedef boost::fusion::vector<float[3], size_t, size_t, size_t, size_t, long int, size_t> type;
43 
45  typedef float s_type;
46 
48  struct attributes
49  {
50  static const std::string name[];
51  };
52 
55 
57  static const unsigned int x = 0;
59  static const unsigned int migration = 1;
61  static const unsigned int computation = 2;
63  static const unsigned int global_id = 3;
65  static const unsigned int id = 4;
67  static const unsigned int sub_id = 5;
69  static const unsigned int proc_id = 6;
70 
72  static const unsigned int max_prop = 7;
73 
75  nm_v()
76  {
77 
78  }
79 
80  inline nm_v(const nm_v & p)
81  {
82  for (size_t i = 0 ; i < dim ; i++)
83  {boost::fusion::at_c<0>(data)[i] = boost::fusion::at_c<0>(p.data)[i];}
84  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
85  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
86  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
87  boost::fusion::at_c<4>(data) = boost::fusion::at_c<4>(p.data);
88  boost::fusion::at_c<5>(data) = boost::fusion::at_c<5>(p.data);
89  boost::fusion::at_c<6>(data) = boost::fusion::at_c<6>(p.data);
90  }
91 
92  template<unsigned int dime, typename Mem> inline nm_v(const encapc<dime, nm_v, Mem> & p)
93  {
94  this->operator=(p);
95  }
96 
97  template<unsigned int dime, typename Mem> inline nm_v & operator=(const encapc<dime, nm_v, Mem> & p)
98  {
99  for (size_t i = 0 ; i < dim ; i++)
100  {boost::fusion::at_c<0>(data)[i] = boost::fusion::at_c<0>(p.data)[i];}
101  boost::fusion::at_c<1>(data) = p.template get<1>();
102  boost::fusion::at_c<2>(data) = p.template get<2>();
103  boost::fusion::at_c<3>(data) = p.template get<3>();
104  boost::fusion::at_c<4>(data) = p.template get<4>();
105  boost::fusion::at_c<5>(data) = p.template get<5>();
106  boost::fusion::at_c<6>(data) = p.template get<6>();
107 
108  return *this;
109  }
110 
111  template<unsigned int id> inline auto get() -> decltype(boost::fusion::at_c < id > (data))
112  {
113  return boost::fusion::at_c<id>(data);
114  }
115 
116  template<unsigned int id> inline auto get() const -> const decltype(boost::fusion::at_c < id > (data))
117  {
118  return boost::fusion::at_c<id>(data);
119  }
120 
121  static bool noPointers()
122  {
123  return true;
124  }
125 
126 };
127 
132 struct nm_e
133 {
135  typedef boost::fusion::vector<size_t, size_t, size_t> type;
136 
138  struct attributes
139  {
140  static const std::string name[];
141  };
142 
145 
147  static const unsigned int communication = 0;
148  static const unsigned int srcgid = 1;
149  static const unsigned int dstgid = 2;
151  static const unsigned int max_prop = 3;
152 
153  nm_e()
154  {
155 
156  }
157 
158  template<unsigned int dim, typename Mem> inline nm_e(const encapc<dim, nm_e, Mem> & p)
159  {
160  boost::fusion::at_c<0>(data) = p.template get<0>();
161  boost::fusion::at_c<1>(data) = p.template get<1>();
162  boost::fusion::at_c<2>(data) = p.template get<2>();
163 
164  }
165 
166  template<unsigned int id> inline auto get() -> decltype(boost::fusion::at_c < id > (data))
167  {
168  return boost::fusion::at_c<id>(data);
169  }
170 
171  static bool noPointers()
172  {
173  return true;
174  }
175 };
176 
183 struct nm_part_v
184 {
186  typedef boost::fusion::vector<size_t, size_t> type;
187 
188  typedef float s_type;
189 
191  struct attributes
192  {
193  static const std::string name[];
194  };
195 
197 
199 
201  static const unsigned int id = 0;
203  static const unsigned int sub_id = 1;
204 
206  static const unsigned int max_prop = 2;
207 
210  {
211 
212  }
213 
214  template<unsigned int dim, typename Mem> inline nm_part_v(const encapc<dim, nm_part_v, Mem> & p)
215  {
216  boost::fusion::at_c<0>(data) = p.template get<0>();
217  boost::fusion::at_c<1>(data) = p.template get<1>();
218  }
219 
220  static inline bool noPointers()
221  {
222  return true;
223  }
224 
225 };
226 
233 struct nm_part_e
234 {
236  typedef boost::fusion::vector<> type;
237 
239 
241 
243  static const unsigned int max_prop = 0;
244 
246  struct attributes
247  {
248  static const std::string name[];
249  };
250 
251  static inline bool noPointers()
252  {
253  return true;
254  }
255 };
256 
257 
258 
259 #endif
static const unsigned int x
pos property id in boost::fusion::vector
static const unsigned int proc_id
proc_id property id in boost::fusion::vector
Reduced sub-domain vertex graph node.
static const unsigned int communication
computation property id in boost::fusion::vector
type data
The data.
nm_v()
default constructor
boost::fusion::vector< size_t, size_t > type
The node contain 3 unsigned long integer for comunication computation and memory.
static const unsigned int global_id
global_id property id in boost::fusion::vector
float s_type
type of the positional field
static const unsigned int max_prop
total number of properties boost::fusion::vector
type data
The data.
nm_part_v()
default constructor
static const unsigned int sub_id
sub_id property id in boost::fusion::vector
static const unsigned int max_prop
total number of properties
static const unsigned int computation
computation property id in boost::fusion::vector
type data
The data.
boost::fusion::vector< float[3], size_t, size_t, size_t, size_t, long int, size_t > type
The node contain 3 unsigned long integer for communication computation memory and id.
sub-domain edge graph node
boost::fusion::vector type
The node contain 3 unsigned long integer for comunication computation and memory.
Reduced edge graph node.
static const unsigned int sub_id
partition id in the boost::fusion::vector
boost::fusion::vector< size_t, size_t, size_t > type
The node contain 3 unsigned long integer for comunication computation and memory.
static const unsigned int migration
migration property id in boost::fusion::vector
static const unsigned int max_prop
total number of properties
type data
The data.
static const unsigned int max_prop
total number of properties boost::fusion::vector
Attributes name.