OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
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 #include "data_type/aggregate.hpp"
14 
15 
35 template<typename T> class Point2D_test
36 {
37 public:
38 
40  typedef boost::fusion::vector<T,T,T,T,T[2],T[2][2]> type;
41 
43  typedef boost::fusion::vector<T,T,T,T,T[2],T[2][2]> type_real;
44 
46  static constexpr bool stag_mask[]={false,false,false,true,true,true};
47 
50 
52  static const unsigned int x = 0;
53 
55  static const unsigned int y = 1;
56 
58  static const unsigned int z = 2;
59 
61  static const unsigned int s = 3;
62 
64  static const unsigned int v = 4;
65 
67  static const unsigned int t = 5;
68 
70  static const unsigned int max_prop = 6;
71 
73  static const unsigned int max_prop_real = 6;
74 
80  static inline bool noPointers()
81  {
82  return true;
83  }
84 };
85 
105 template<typename T> class Point_test
106 {
107 public:
108 
109 #ifdef SE_CLASS3
110 
112  typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3],SE3_ADD_PROP(6)> type;
113 
115  typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type_real;
116 
117 #else
118 
120  typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type;
121 
123  typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type_real;
124 
125 #endif
126 
128  static constexpr bool stag_mask[]={false,false,false,true,true,true};
129 
132 
134  static const unsigned int x = 0;
135 
137  static const unsigned int y = 1;
138 
140  static const unsigned int z = 2;
141 
143  static const unsigned int s = 3;
144 
146  static const unsigned int v = 4;
147 
149  static const unsigned int t = 5;
150 
151 #ifdef SE_CLASS3
152 
154  static const unsigned int max_prop = SE3_MAX_PROP(6);
155 
157  static const unsigned int max_prop_real = 6;
158 
159 #else
160 
162  static const unsigned int max_prop = 6;
163 
165  static const unsigned int max_prop_real = 6;
166 
167 #endif
168 
169  // Setter method
170 
176  inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
177 
183  inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
184 
190  inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
191 
197  inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
198 
205  inline void setv(size_t i,T v_) {boost::fusion::at_c<4>(data)[i] = v_;}
206 
214  inline void sett(size_t i, size_t j,T t_) {boost::fusion::at_c<5>(data)[i][j] = t_;}
215 
216 
218  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);};
219 
222  {}
223 
229  bool operator==(const Point_test<float> & p) const
230  {
231  if (boost::fusion::at_c<0>(data) != boost::fusion::at_c<0>(p.data)) return false;
232  if (boost::fusion::at_c<1>(data) != boost::fusion::at_c<1>(p.data)) return false;
233  if (boost::fusion::at_c<2>(data) != boost::fusion::at_c<2>(p.data)) return false;
234  if (boost::fusion::at_c<3>(data) != boost::fusion::at_c<3>(p.data)) return false;
235 
236  for (size_t i = 0 ; i < 3 ; i++)
237  if (boost::fusion::at_c<4>(data)[i] != boost::fusion::at_c<4>(p.data)[i]) return false;
238 
239  for (size_t i = 0 ; i < 3 ; i++)
240  {
241  for (size_t j = 0 ; j < 3 ; j++)
242  {
243  if (boost::fusion::at_c<5>(data)[i][j] != boost::fusion::at_c<5>(p.data)[i][j]) return false;
244  }
245  }
246 
247  return true;
248  }
249 
258  {
259  boost::fusion::at_c<0>(data) += boost::fusion::at_c<0>(p.data);
260  boost::fusion::at_c<1>(data) += boost::fusion::at_c<1>(p.data);
261  boost::fusion::at_c<2>(data) += boost::fusion::at_c<2>(p.data);
262  boost::fusion::at_c<3>(data) += boost::fusion::at_c<3>(p.data);
263 
264  for (size_t i = 0 ; i < 3 ; i++)
265  boost::fusion::at_c<4>(data)[i] += boost::fusion::at_c<4>(p.data)[i];
266 
267  for (size_t i = 0 ; i < 3 ; i++)
268  {
269  for (size_t j = 0 ; j < 3 ; j++)
270  boost::fusion::at_c<5>(data)[i][j] += boost::fusion::at_c<5>(p.data)[i][j];
271  }
272 
273  return *this;
274  }
275 
281  template <unsigned int dim, typename Mem> inline Point_test(const encapc<dim,Point_test<T>,Mem> & p)
282  {
283  boost::fusion::at_c<0>(data) = p.template get<0>();
284  boost::fusion::at_c<1>(data) = p.template get<1>();
285  boost::fusion::at_c<2>(data) = p.template get<2>();
286  boost::fusion::at_c<3>(data) = p.template get<3>();
287 
288  for (size_t i = 0 ; i < 3 ; i++)
289  boost::fusion::at_c<4>(data)[i] = p.template get<4>()[i];
290 
291  for (size_t i = 0 ; i < 3 ; i++)
292  {
293  for (size_t j = 0 ; j < 3 ; j++)
294  {
295  boost::fusion::at_c<5>(data)[i][j] = p.template get<5>()[i][j];
296  }
297  }
298  }
299 
305  inline Point_test(const Point_test<T> & p)
306  {
307  boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
308  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
309  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
310  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
311 
312  for (size_t i = 0 ; i < 3 ; i++)
313  boost::fusion::at_c<4>(data)[i] = boost::fusion::at_c<4>(p.data)[i];
314 
315  for (size_t i = 0 ; i < 3 ; i++)
316  {
317  for (size_t j = 0 ; j < 3 ; j++)
318  {
319  boost::fusion::at_c<5>(data)[i][j] = boost::fusion::at_c<5>(p.data)[i][j];
320  }
321  }
322  }
323 
332  {
333  boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
334  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
335  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
336  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
337 
338  for (size_t i = 0 ; i < 3 ; i++)
339  boost::fusion::at_c<4>(data)[i] = boost::fusion::at_c<4>(p.data)[i];
340 
341  for (size_t i = 0 ; i < 3 ; i++)
342  {
343  for (size_t j = 0 ; j < 3 ; j++)
344  {
345  boost::fusion::at_c<5>(data)[i][j] = boost::fusion::at_c<5>(p.data)[i][j];
346  }
347  }
348 
349  return *this;
350  }
351 
359  static bool noPointers() {return true;}
360 
366  void fill()
367  {
368  boost::fusion::at_c<0>(data) = 1;
369  boost::fusion::at_c<1>(data) = 2;
370  boost::fusion::at_c<2>(data) = 3;
371  boost::fusion::at_c<3>(data) = 4;
372 
373  for (size_t i = 0 ; i < 3 ; i++)
374  boost::fusion::at_c<4>(data)[i] = 5;
375 
376  for (size_t i = 0 ; i < 3 ; i++)
377  {
378  for (size_t j = 0 ; j < 3 ; j++)
379  {
380  boost::fusion::at_c<5>(data)[i][j] = 6;
381  }
382  }
383  }
384 };
385 
386 
407 template<typename T> class Point_test_prp
408 {
409 public:
410 
412  typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type;
413 
416 
418  static const unsigned int x = 0;
419 
421  static const unsigned int y = 1;
422 
424  static const unsigned int z = 2;
425 
427  static const unsigned int s = 3;
428 
430  static const unsigned int v = 4;
431 
433  static const unsigned int t = 5;
434 
436  static const unsigned int max_prop = 6;
437 
438  // Setter method
439 
445  inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
446 
452  inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
453 
459  inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
460 
466  inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
467 
469  struct attributes
470  {
472  static const std::string name[];
473  };
474 
476  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);};
477 
480  {}
481 
483  template <typename Mem> inline Point_test_prp(const encapc<1,Point_test_prp<T>,Mem> & p)
484  {
485  boost::fusion::at_c<0>(data) = p.template get<0>();
486  boost::fusion::at_c<1>(data) = p.template get<1>();
487  boost::fusion::at_c<2>(data) = p.template get<2>();
488  boost::fusion::at_c<3>(data) = p.template get<3>();
489 
490  for (size_t i = 0 ; i < 3 ; i++)
491  boost::fusion::at_c<4>(data)[i] = p.template get<4>()[i];
492 
493  for (size_t i = 0 ; i < 3 ; i++)
494  {
495  for (size_t j = 0 ; j < 3 ; j++)
496  {
497  boost::fusion::at_c<5>(data)[i][j] = p.template get<5>()[i][j];
498  }
499  }
500  }
501 
504  {
505  boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
506  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
507  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
508  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
509 
510  for (size_t i = 0 ; i < 3 ; i++)
511  boost::fusion::at_c<4>(data)[i] = boost::fusion::at_c<4>(p.data)[i];
512 
513  for (size_t i = 0 ; i < 3 ; i++)
514  {
515  for (size_t j = 0 ; j < 3 ; j++)
516  {
517  boost::fusion::at_c<5>(data)[i][j] = boost::fusion::at_c<5>(p.data)[i][j];
518  }
519  }
520  }
521 
522 
531  {
532  boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
533  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
534  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
535  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
536 
537  for (size_t i = 0 ; i < 3 ; i++)
538  boost::fusion::at_c<4>(data)[i] = boost::fusion::at_c<4>(p.data)[i];
539 
540  for (size_t i = 0 ; i < 3 ; i++)
541  {
542  for (size_t j = 0 ; j < 3 ; j++)
543  {
544  boost::fusion::at_c<5>(data)[i][j] = boost::fusion::at_c<5>(p.data)[i][j];
545  }
546  }
547 
548  return *this;
549  }
550 
551  static inline bool noPointers()
552  {
553  return true;
554  }
555 };
556 
557 template<typename T> const std::string Point_test_prp<T>::attributes::name[] = {"x","y","z","s","v","t"};
558 
560 template<typename T> class Point_test_scal
561 {
562 public:
563 
565  typedef boost::fusion::vector<T,T,T,T> type;
566 
569 
571  static const unsigned int x = 0;
572 
574  static const unsigned int y = 1;
575 
577  static const unsigned int z = 2;
578 
580  static const unsigned int s = 3;
581 
583  static const unsigned int max_prop = 4;
584 
585  // Setter method
586 
588  inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
590  inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
592  inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
594  inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
595 
597  struct attributes
598  {
600  static const std::string name[];
601  };
602 
604  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);};
605 
608  {}
609 
611  template <typename Mem> inline Point_test_scal(const encapc<1,Point_test_scal<T>,Mem> & p)
612  {
613  boost::fusion::at_c<0>(data) = p.template get<0>();
614  boost::fusion::at_c<1>(data) = p.template get<1>();
615  boost::fusion::at_c<2>(data) = p.template get<2>();
616  boost::fusion::at_c<3>(data) = p.template get<3>();
617  }
618 
621  {
622  boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
623  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
624  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
625  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
626  }
627 
630  {
631  boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
632  boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
633  boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
634  boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
635 
636  return *this;
637  }
638 
639  static inline bool noPointers()
640  {
641  return true;
642  }
643 };
644 
645 template<typename T> const std::string Point_test_scal<T>::attributes::name[] = {"x","y","z","s"};
646 
647 #endif
Point_test_scal(const Point_test_scal< T > &p)
constructor from another point
Definition: Point_test.hpp:620
static const unsigned int max_prop
maximum number of properties
Definition: Point_test.hpp:436
void setv(size_t i, T v_)
set the v property
Definition: Point_test.hpp:205
boost::fusion::vector< T, T, T, T, T[3], T[3][3]> type
declaration of what the Point_test store
Definition: Point_test.hpp:120
Point_test(const encapc< dim, Point_test< T >, Mem > &p)
Copy constructor from encapc (encapsulated point)
Definition: Point_test.hpp:281
Test structure used for several test.
Definition: Point_test.hpp:35
static constexpr bool stag_mask[]
in case usage with a staggered grid indicate which properties are staggered in the cell ...
Definition: Point_test.hpp:128
static const unsigned int max_prop
the number of properties
Definition: Point_test.hpp:583
static const unsigned int v
v property is at position 4 in the boost::fusion::vector
Definition: Point_test.hpp:430
void setz(T z_)
set the z property
Definition: Point_test.hpp:190
static const unsigned int s
s property is at position 3 in the boost::fusion::vector
Definition: Point_test.hpp:143
Point_test_scal()
Default constructor.
Definition: Point_test.hpp:607
static const unsigned int z
z property is at position 0 in the boost::fusion::vector
Definition: Point_test.hpp:577
type data
Object itself.
Definition: Point_test.hpp:415
Point_test_prp(const Point_test_prp< T > &p)
constructor from another point
Definition: Point_test.hpp:503
point test with only scalar properties
Definition: Point_test.hpp:560
Point_test(const Point_test< T > &p)
constructor from another point
Definition: Point_test.hpp:305
static const unsigned int t
t property is at position 5 in the boost::fusion::vector
Definition: Point_test.hpp:433
type data
object itself
Definition: Point_test.hpp:49
void sets(T s_)
set the s property
Definition: Point_test.hpp:466
static const unsigned int x
x property is at position 0 in the boost::fusion::vector
Definition: Point_test.hpp:52
static const unsigned int x
x property is at position 0 in the boost::fusion::vector
Definition: Point_test.hpp:418
bool operator==(const Point_test< float > &p) const
check if two point match
Definition: Point_test.hpp:229
void fill()
fill
Definition: Point_test.hpp:366
void sety(T y_)
set the property y
Definition: Point_test.hpp:590
static const std::string name[]
array of attributes name
Definition: Point_test.hpp:472
void setz(T z_)
set the z property
Definition: Point_test.hpp:459
static const unsigned int v
v property is at position 4 in the boost::fusion::vector
Definition: Point_test.hpp:64
Point_test< T > operator=(const Point_test< T > &p)
Copy the point.
Definition: Point_test.hpp:331
type data
The data itself.
Definition: Point_test.hpp:568
static const unsigned int s
s property is at position 3 in the boost::fusion::vector
Definition: Point_test.hpp:61
void setx(T x_)
set the property x
Definition: Point_test.hpp:588
boost::fusion::vector< T, T, T, T, T[3], T[3][3]> type_real
declaration of what the Point_test store
Definition: Point_test.hpp:123
void setx(T x_)
set the x property
Definition: Point_test.hpp:176
static const unsigned int max_prop
number of properties in the boost::fusion::vector
Definition: Point_test.hpp:162
static const unsigned int y
y property is at position 1 in the boost::fusion::vector
Definition: Point_test.hpp:137
void sets(T s_)
set the property s
Definition: Point_test.hpp:594
static const unsigned int s
s property is at position 0 in the boost::fusion::vector
Definition: Point_test.hpp:580
Point_test_scal< T > operator=(const Point_test_scal< T > &p)
operator=
Definition: Point_test.hpp:629
static const unsigned int s
s property is at position 3 in the boost::fusion::vector
Definition: Point_test.hpp:427
Point_test_prp< T > operator=(const Point_test< T > &p)
Copy the point.
Definition: Point_test.hpp:530
static const unsigned int max_prop_real
number of properties in the boost::fusion::vector
Definition: Point_test.hpp:73
Point_test()
Default constructor.
Definition: Point_test.hpp:221
static const unsigned int x
x property is at position 0 in the boost::fusion::vector
Definition: Point_test.hpp:134
static constexpr bool stag_mask[]
in case of usage with staggered grid it define which properties are staggered in the cell grid ...
Definition: Point_test.hpp:46
type data
The object itself.
Definition: Point_test.hpp:131
static const unsigned int z
z property is at position 2 in the boost::fusion::vector
Definition: Point_test.hpp:424
static bool noPointers()
noPointers function
Definition: Point_test.hpp:359
static const unsigned int z
z property is at position 2 in the boost::fusion::vector
Definition: Point_test.hpp:58
void setz(T z_)
set the property z
Definition: Point_test.hpp:592
boost::fusion::vector< T, T, T, T, T[2], T[2][2]> type_real
declaration of what the Point2D_test store
Definition: Point_test.hpp:43
static const unsigned int z
z property is at position 2 in the boost::fusion::vector
Definition: Point_test.hpp:140
void setx(T x_)
set the x property
Definition: Point_test.hpp:445
boost::fusion::vector< T, T, T, T > type
declaration of what the Point_test_scal store
Definition: Point_test.hpp:565
static bool noPointers()
indicate that this structure has no pointers
Definition: Point_test.hpp:80
static const std::string name[]
array of names
Definition: Point_test.hpp:600
Test structure used for several test.
Definition: Point_test.hpp:407
void sett(size_t i, size_t j, T t_)
set the t property
Definition: Point_test.hpp:214
static const unsigned int t
t property is at position 5 in the boost::fusion::vector
Definition: Point_test.hpp:67
static const unsigned int y
y property is at position 1 in the boost::fusion::vector
Definition: Point_test.hpp:421
void sets(T s_)
set the s property
Definition: Point_test.hpp:197
static const unsigned int max_prop
number of properties in the boost::fusion::vector
Definition: Point_test.hpp:70
Point_test_prp()
Default constructor.
Definition: Point_test.hpp:479
void sety(T y_)
set the y property
Definition: Point_test.hpp:183
static const unsigned int y
y property is at position 1 in the boost::fusion::vector
Definition: Point_test.hpp:55
void sety(T y_)
set the y property
Definition: Point_test.hpp:452
Point_test_scal(const encapc< 1, Point_test_scal< T >, Mem > &p)
constructor from encapc
Definition: Point_test.hpp:611
static const unsigned int t
t property is at position 5 in the boost::fusion::vector
Definition: Point_test.hpp:149
Test structure used for several test.
Definition: Point_test.hpp:105
Point_test< float > & operator+=(const Point_test< float > &p)
Sum the point.
Definition: Point_test.hpp:257
Point_test_prp(const encapc< 1, Point_test_prp< T >, Mem > &p)
constructor from encapc
Definition: Point_test.hpp:483
boost::fusion::vector< T, T, T, T, T[2], T[2][2]> type
declaration of what the Point2D_test store
Definition: Point_test.hpp:40
static const unsigned int v
v property is at position 4 in the boost::fusion::vector
Definition: Point_test.hpp:146
boost::fusion::vector< T, T, T, T, T[3], T[3][3]> type
declaration of what the Point_test_prp store
Definition: Point_test.hpp:412
static const unsigned int max_prop_real
number of properties in the boost::fusion::vector
Definition: Point_test.hpp:165
static const unsigned int y
y property is at position 1 in the boost::fusion::vector
Definition: Point_test.hpp:574
static const unsigned int x
x property is at position 0 in the boost::fusion::vector
Definition: Point_test.hpp:571