OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
Point_test.hpp
1 #ifndef POINT_TEST_HPP
2 #define POINT_TEST_HPP
3 
4 #include <boost/fusion/sequence/intrinsic/at_c.hpp>
5 #include <boost/fusion/include/at_c.hpp>
6 #include <boost/fusion/container/vector.hpp>
7 #include <boost/fusion/include/vector.hpp>
8 #include <boost/fusion/container/vector/vector_fwd.hpp>
9 #include <boost/fusion/include/vector_fwd.hpp>
10 #include "boost/multi_array.hpp"
11 #include "Point_orig.hpp"
12 #include "Grid/Encap.hpp"
13 
14 
34 template<typename T> class Point2D_test
35 {
36 public:
37 
38  typedef boost::fusion::vector<T,T,T,T,T[2],T[2][2]> type;
39 
40  static constexpr bool stag_mask[]={false,false,false,true,true,true};
41 
42  type data;
43 
44  static const unsigned int x = 0;
45  static const unsigned int y = 1;
46  static const unsigned int z = 2;
47  static const unsigned int s = 3;
48  static const unsigned int v = 4;
49  static const unsigned int t = 5;
50  static const unsigned int max_prop = 6;
51 };
52 
72 template<typename T> class Point_test
73 {
74 public:
75 
76  typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type;
77 
78  static constexpr bool stag_mask[]={false,false,false,true,true,true};
79 
80  type data;
81 
82  static const unsigned int x = 0;
83  static const unsigned int y = 1;
84  static const unsigned int z = 2;
85  static const unsigned int s = 3;
86  static const unsigned int v = 4;
87  static const unsigned int t = 5;
88  static const unsigned int max_prop = 6;
89 
90  // Setter method
91 
92  inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
93  inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
94  inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
95  inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
96 
97  inline void setv(size_t i,T v_) {boost::fusion::at_c<4>(data)[i] = v_;}
98  inline void sett(size_t i, size_t j,T t_) {boost::fusion::at_c<5>(data)[i][j] = t_;}
99 
100 
101  // getter method
102 
103  template<unsigned int i> inline typename boost::fusion::result_of::at<type, boost::mpl::int_<i> >::type get() {return boost::fusion::at_c<i>(data);};
104 
107  {}
108 
110  bool operator==(const Point_test<float> & p) const
111  {
112  if (boost::fusion::at_c<0>(data) != boost::fusion::at_c<0>(p.data)) return false;
113  if (boost::fusion::at_c<1>(data) != boost::fusion::at_c<1>(p.data)) return false;
114  if (boost::fusion::at_c<2>(data) != boost::fusion::at_c<2>(p.data)) return false;
115  if (boost::fusion::at_c<3>(data) != boost::fusion::at_c<3>(p.data)) return false;
116 
117  for (size_t i = 0 ; i < 3 ; i++)
118  if (boost::fusion::at_c<4>(data)[i] != boost::fusion::at_c<4>(p.data)[i]) return false;
119 
120  for (size_t i = 0 ; i < 3 ; i++)
121  {
122  for (size_t j = 0 ; j < 3 ; j++)
123  {
124  if (boost::fusion::at_c<5>(data)[i][j] != boost::fusion::at_c<5>(p.data)[i][j]) return false;
125  }
126  }
127 
128  return true;
129  }
130 
132  template <unsigned int dim, typename Mem> inline Point_test(const encapc<dim,Point_test<T>,Mem> & p)
133  {
134  boost::fusion::at_c<0>(data) = p.template get<0>();
135  boost::fusion::at_c<1>(data) = p.template get<1>();
136  boost::fusion::at_c<2>(data) = p.template get<2>();
137  boost::fusion::at_c<3>(data) = p.template get<3>();
138 
139  for (size_t i = 0 ; i < 3 ; i++)
140  boost::fusion::at_c<4>(data)[i] = p.template get<4>()[i];
141 
142  for (size_t i = 0 ; i < 3 ; i++)
143  {
144  for (size_t j = 0 ; j < 3 ; j++)
145  {
146  boost::fusion::at_c<5>(data)[i][j] = p.template get<5>()[i][j];
147  }
148  }
149  }
150 
152  template <unsigned int dim, typename Mem> inline Point_test(const encapg<dim,Point_test<T>,Mem> & p)
153  {
154  boost::fusion::at_c<0>(data) = p.template get<0>();
155  boost::fusion::at_c<1>(data) = p.template get<1>();
156  boost::fusion::at_c<2>(data) = p.template get<2>();
157  boost::fusion::at_c<3>(data) = p.template get<3>();
158 
159  for (size_t i = 0 ; i < 3 ; i++)
160  boost::fusion::at_c<4>(data)[i] = p.template get<4>()[i];
161 
162  for (size_t i = 0 ; i < 3 ; i++)
163  {
164  for (size_t j = 0 ; j < 3 ; j++)
165  {
166  boost::fusion::at_c<5>(data)[i][j] = p.template get<5>()[i][j];
167  }
168  }
169  }
170 
172  inline Point_test(const Point_test<T> & p)
173  {
174  boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
175  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
176  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
177  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
178 
179  for (size_t i = 0 ; i < 3 ; i++)
180  boost::fusion::at_c<4>(data)[i] = boost::fusion::at_c<4>(p.data)[i];
181 
182  for (size_t i = 0 ; i < 3 ; i++)
183  {
184  for (size_t j = 0 ; j < 3 ; j++)
185  {
186  boost::fusion::at_c<5>(data)[i][j] = boost::fusion::at_c<5>(p.data)[i][j];
187  }
188  }
189  }
190 
193  {
194  boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
195  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
196  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
197  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
198 
199  for (size_t i = 0 ; i < 3 ; i++)
200  boost::fusion::at_c<4>(data)[i] = boost::fusion::at_c<4>(p.data)[i];
201 
202  for (size_t i = 0 ; i < 3 ; i++)
203  {
204  for (size_t j = 0 ; j < 3 ; j++)
205  {
206  boost::fusion::at_c<5>(data)[i][j] = boost::fusion::at_c<5>(p.data)[i][j];
207  }
208  }
209 
210  return *this;
211  }
212 
220  static bool noPointers() {return true;}
221 
227  void fill()
228  {
229  boost::fusion::at_c<0>(data) = 1;
230  boost::fusion::at_c<1>(data) = 2;
231  boost::fusion::at_c<2>(data) = 3;
232  boost::fusion::at_c<3>(data) = 4;
233 
234  for (size_t i = 0 ; i < 3 ; i++)
235  boost::fusion::at_c<4>(data)[i] = 5;
236 
237  for (size_t i = 0 ; i < 3 ; i++)
238  {
239  for (size_t j = 0 ; j < 3 ; j++)
240  {
241  boost::fusion::at_c<5>(data)[i][j] = 6;
242  }
243  }
244  }
245 
246 };
247 
248 
269 template<typename T> class Point_test_prp
270 {
271 public:
272 
273  typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type;
274 
275  type data;
276 
277  static const unsigned int x = 0;
278  static const unsigned int y = 1;
279  static const unsigned int z = 2;
280  static const unsigned int s = 3;
281  static const unsigned int v = 4;
282  static const unsigned int t = 5;
283  static const unsigned int max_prop = 6;
284 
285  // Setter method
286 
287  inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
288  inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
289  inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
290  inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
291 
293  struct attributes
294  {
295  static const std::string name[];
296  };
297 
298  // getter method
299 
300  template<unsigned int i> inline typename boost::fusion::result_of::at<type, boost::mpl::int_<i> >::type get() {return boost::fusion::at_c<i>(data);};
301 
304  {}
305 
307  template <typename Mem> inline Point_test_prp(const encapc<1,Point_test_prp<T>,Mem> & p)
308  {
309  boost::fusion::at_c<0>(data) = p.template get<0>();
310  boost::fusion::at_c<1>(data) = p.template get<1>();
311  boost::fusion::at_c<2>(data) = p.template get<2>();
312  boost::fusion::at_c<3>(data) = p.template get<3>();
313 
314  for (size_t i = 0 ; i < 3 ; i++)
315  boost::fusion::at_c<4>(data)[i] = p.template get<4>()[i];
316 
317  for (size_t i = 0 ; i < 3 ; i++)
318  {
319  for (size_t j = 0 ; j < 3 ; j++)
320  {
321  boost::fusion::at_c<5>(data)[i][j] = p.template get<5>()[i][j];
322  }
323  }
324  }
325 
328  {
329  boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
330  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
331  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
332  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
333 
334  for (size_t i = 0 ; i < 3 ; i++)
335  boost::fusion::at_c<4>(data)[i] = boost::fusion::at_c<4>(p.data)[i];
336 
337  for (size_t i = 0 ; i < 3 ; i++)
338  {
339  for (size_t j = 0 ; j < 3 ; j++)
340  {
341  boost::fusion::at_c<5>(data)[i][j] = boost::fusion::at_c<5>(p.data)[i][j];
342  }
343  }
344  }
345 
348  {
349  boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
350  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
351  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
352  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
353 
354  for (size_t i = 0 ; i < 3 ; i++)
355  boost::fusion::at_c<4>(data)[i] = boost::fusion::at_c<4>(p.data)[i];
356 
357  for (size_t i = 0 ; i < 3 ; i++)
358  {
359  for (size_t j = 0 ; j < 3 ; j++)
360  {
361  boost::fusion::at_c<5>(data)[i][j] = boost::fusion::at_c<5>(p.data)[i][j];
362  }
363  }
364 
365  return *this;
366  }
367 };
368 
369 template<typename T> const std::string Point_test_prp<T>::attributes::name[] = {"x","y","z","s","v","t"};
370 
371 template<typename T> class Point_test_scal
372 {
373 public:
374 
375  typedef boost::fusion::vector<T,T,T,T> type;
376 
377  type data;
378 
379  static const unsigned int x = 0;
380  static const unsigned int y = 1;
381  static const unsigned int z = 2;
382  static const unsigned int s = 3;
383  static const unsigned int max_prop = 4;
384 
385  // Setter method
386 
387  inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
388  inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
389  inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
390  inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
391 
393  struct attributes
394  {
395  static const std::string name[];
396  };
397 
398  // getter method
399 
400  template<unsigned int i> inline typename boost::fusion::result_of::at<type, boost::mpl::int_<i> >::type get() {return boost::fusion::at_c<i>(data);};
401 
404  {}
405 
407  template <typename Mem> inline Point_test_scal(const encapc<1,Point_test_scal<T>,Mem> & p)
408  {
409  boost::fusion::at_c<0>(data) = p.template get<0>();
410  boost::fusion::at_c<1>(data) = p.template get<1>();
411  boost::fusion::at_c<2>(data) = p.template get<2>();
412  boost::fusion::at_c<3>(data) = p.template get<3>();
413  }
414 
417  {
418  boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
419  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
420  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
421  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
422  }
423 
426  {
427  boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
428  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
429  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
430  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
431 
432  return *this;
433  }
434 };
435 
436 template<typename T> const std::string Point_test_scal<T>::attributes::name[] = {"x","y","z","s"};
437 
438 #endif
Point_test_scal(const Point_test_scal< T > &p)
constructor from another point
Definition: Point_test.hpp:416
Point_test(const encapc< dim, Point_test< T >, Mem > &p)
constructor from encapc
Definition: Point_test.hpp:132
Test structure used for several test.
Definition: Point_test.hpp:34
Point_test_scal()
Default constructor.
Definition: Point_test.hpp:403
Point_test_prp(const Point_test_prp< T > &p)
constructor from another point
Definition: Point_test.hpp:327
Point_test(const Point_test< T > &p)
constructor from another point
Definition: Point_test.hpp:172
bool operator==(const Point_test< float > &p) const
check if two point match
Definition: Point_test.hpp:110
void fill()
fill
Definition: Point_test.hpp:227
Point_test< T > operator=(const Point_test< T > &p)
constructor from another point
Definition: Point_test.hpp:192
Point_test_scal< T > operator=(const Point_test_scal< T > &p)
constructor from another point
Definition: Point_test.hpp:425
Point_test_prp< T > operator=(const Point_test< T > &p)
constructor from another point
Definition: Point_test.hpp:347
Point_test()
Default constructor.
Definition: Point_test.hpp:106
this structure encapsulate an object of the grid
Definition: Encap.hpp:209
static bool noPointers()
noPointers function
Definition: Point_test.hpp:220
Test structure used for several test.
Definition: Point_test.hpp:269
this structure encapsulate an object of the grid
Definition: Encap.hpp:370
Point_test_prp()
Default constructor.
Definition: Point_test.hpp:303
Point_test_scal(const encapc< 1, Point_test_scal< T >, Mem > &p)
constructor from encapc
Definition: Point_test.hpp:407
Test structure used for several test.
Definition: Point_test.hpp:72
Point_test(const encapg< dim, Point_test< T >, Mem > &p)
constructor from encapg
Definition: Point_test.hpp:152
Point_test_prp(const encapc< 1, Point_test_prp< T >, Mem > &p)
constructor from encapc
Definition: Point_test.hpp:307