OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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 "memory_ly/Encap.hpp"
13#include "data_type/aggregate.hpp"
14
15
35template<typename T> class Point2D_test
36{
37public:
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
105template<typename T> class Point_test
106{
107public:
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>
219 inline auto get() -> decltype(boost::fusion::at_c<i>(data))
220 {return boost::fusion::at_c<i>(data);}
221
223 template<unsigned int i>
224 inline auto get() const -> decltype(boost::fusion::at_c<i>(data))
225 {return boost::fusion::at_c<i>(data);}
226
229 {}
230
236 bool operator==(const Point_test<float> & p) const
237 {
238 if (boost::fusion::at_c<0>(data) != boost::fusion::at_c<0>(p.data)) return false;
239 if (boost::fusion::at_c<1>(data) != boost::fusion::at_c<1>(p.data)) return false;
240 if (boost::fusion::at_c<2>(data) != boost::fusion::at_c<2>(p.data)) return false;
241 if (boost::fusion::at_c<3>(data) != boost::fusion::at_c<3>(p.data)) return false;
242
243 for (size_t i = 0 ; i < 3 ; i++)
244 if (boost::fusion::at_c<4>(data)[i] != boost::fusion::at_c<4>(p.data)[i]) return false;
245
246 for (size_t i = 0 ; i < 3 ; i++)
247 {
248 for (size_t j = 0 ; j < 3 ; j++)
249 {
250 if (boost::fusion::at_c<5>(data)[i][j] != boost::fusion::at_c<5>(p.data)[i][j]) return false;
251 }
252 }
253
254 return true;
255 }
256
265 {
266 boost::fusion::at_c<0>(data) += boost::fusion::at_c<0>(p.data);
267 boost::fusion::at_c<1>(data) += boost::fusion::at_c<1>(p.data);
268 boost::fusion::at_c<2>(data) += boost::fusion::at_c<2>(p.data);
269 boost::fusion::at_c<3>(data) += boost::fusion::at_c<3>(p.data);
270
271 for (size_t i = 0 ; i < 3 ; i++)
272 boost::fusion::at_c<4>(data)[i] += boost::fusion::at_c<4>(p.data)[i];
273
274 for (size_t i = 0 ; i < 3 ; i++)
275 {
276 for (size_t j = 0 ; j < 3 ; j++)
277 boost::fusion::at_c<5>(data)[i][j] += boost::fusion::at_c<5>(p.data)[i][j];
278 }
279
280 return *this;
281 }
282
288 template <unsigned int dim, typename Mem> inline Point_test(const encapc<dim,Point_test<T>,Mem> & p)
289 {
290 boost::fusion::at_c<0>(data) = p.template get<0>();
291 boost::fusion::at_c<1>(data) = p.template get<1>();
292 boost::fusion::at_c<2>(data) = p.template get<2>();
293 boost::fusion::at_c<3>(data) = p.template get<3>();
294
295 for (size_t i = 0 ; i < 3 ; i++)
296 boost::fusion::at_c<4>(data)[i] = p.template get<4>()[i];
297
298 for (size_t i = 0 ; i < 3 ; i++)
299 {
300 for (size_t j = 0 ; j < 3 ; j++)
301 {
302 boost::fusion::at_c<5>(data)[i][j] = p.template get<5>()[i][j];
303 }
304 }
305 }
306
312 inline Point_test(const Point_test<T> & p)
313 {
314 boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
315 boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
316 boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
317 boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
318
319 for (size_t i = 0 ; i < 3 ; i++)
320 boost::fusion::at_c<4>(data)[i] = boost::fusion::at_c<4>(p.data)[i];
321
322 for (size_t i = 0 ; i < 3 ; i++)
323 {
324 for (size_t j = 0 ; j < 3 ; j++)
325 {
326 boost::fusion::at_c<5>(data)[i][j] = boost::fusion::at_c<5>(p.data)[i][j];
327 }
328 }
329 }
330
338 __device__ __host__ inline Point_test<T> & operator= (const Point_test<T> & p)
339 {
340 boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
341 boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
342 boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
343 boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
344
345 for (size_t i = 0 ; i < 3 ; i++)
346 boost::fusion::at_c<4>(data)[i] = boost::fusion::at_c<4>(p.data)[i];
347
348 for (size_t i = 0 ; i < 3 ; i++)
349 {
350 for (size_t j = 0 ; j < 3 ; j++)
351 {
352 boost::fusion::at_c<5>(data)[i][j] = boost::fusion::at_c<5>(p.data)[i][j];
353 }
354 }
355
356 return *this;
357 }
358
366 static bool noPointers() {return true;}
367
373 void fill()
374 {
375 boost::fusion::at_c<0>(data) = 1;
376 boost::fusion::at_c<1>(data) = 2;
377 boost::fusion::at_c<2>(data) = 3;
378 boost::fusion::at_c<3>(data) = 4;
379
380 for (size_t i = 0 ; i < 3 ; i++)
381 boost::fusion::at_c<4>(data)[i] = 5;
382
383 for (size_t i = 0 ; i < 3 ; i++)
384 {
385 for (size_t j = 0 ; j < 3 ; j++)
386 {
387 boost::fusion::at_c<5>(data)[i][j] = 6;
388 }
389 }
390 }
391};
392
393
414template<typename T> class Point_test_prp
415{
416public:
417
419 typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type;
420
423
425 static const unsigned int x = 0;
426
428 static const unsigned int y = 1;
429
431 static const unsigned int z = 2;
432
434 static const unsigned int s = 3;
435
437 static const unsigned int v = 4;
438
440 static const unsigned int t = 5;
441
443 static const unsigned int max_prop = 6;
444
445 // Setter method
446
452 inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
453
459 inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
460
466 inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
467
473 inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
474
477 {
479 static const std::string name[];
480 };
481
483 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);}
484
487 {}
488
490 template <typename Mem> inline Point_test_prp(const encapc<1,Point_test_prp<T>,Mem> & p)
491 {
492 boost::fusion::at_c<0>(data) = p.template get<0>();
493 boost::fusion::at_c<1>(data) = p.template get<1>();
494 boost::fusion::at_c<2>(data) = p.template get<2>();
495 boost::fusion::at_c<3>(data) = p.template get<3>();
496
497 for (size_t i = 0 ; i < 3 ; i++)
498 boost::fusion::at_c<4>(data)[i] = p.template get<4>()[i];
499
500 for (size_t i = 0 ; i < 3 ; i++)
501 {
502 for (size_t j = 0 ; j < 3 ; j++)
503 {
504 boost::fusion::at_c<5>(data)[i][j] = p.template get<5>()[i][j];
505 }
506 }
507 }
508
511 {
512 boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
513 boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
514 boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
515 boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
516
517 for (size_t i = 0 ; i < 3 ; i++)
518 boost::fusion::at_c<4>(data)[i] = boost::fusion::at_c<4>(p.data)[i];
519
520 for (size_t i = 0 ; i < 3 ; i++)
521 {
522 for (size_t j = 0 ; j < 3 ; j++)
523 {
524 boost::fusion::at_c<5>(data)[i][j] = boost::fusion::at_c<5>(p.data)[i][j];
525 }
526 }
527 }
528
529
538 {
539 boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
540 boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
541 boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
542 boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
543
544 for (size_t i = 0 ; i < 3 ; i++)
545 boost::fusion::at_c<4>(data)[i] = boost::fusion::at_c<4>(p.data)[i];
546
547 for (size_t i = 0 ; i < 3 ; i++)
548 {
549 for (size_t j = 0 ; j < 3 ; j++)
550 {
551 boost::fusion::at_c<5>(data)[i][j] = boost::fusion::at_c<5>(p.data)[i][j];
552 }
553 }
554
555 return *this;
556 }
557
558 static inline bool noPointers()
559 {
560 return true;
561 }
562};
563
564template<typename T> const std::string Point_test_prp<T>::attributes::name[] = {"x","y","z","s","v","t"};
565
567template<typename T> class Point_test_scal
568{
569public:
570
572 typedef boost::fusion::vector<T,T,T,T> type;
573
576
578 static const unsigned int x = 0;
579
581 static const unsigned int y = 1;
582
584 static const unsigned int z = 2;
585
587 static const unsigned int s = 3;
588
590 static const unsigned int max_prop = 4;
591
592 // Setter method
593
595 inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
597 inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
599 inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
601 inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
602
605 {
607 static const std::string name[];
608 };
609
611 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);}
612
615 {}
616
618 template <typename Mem> inline Point_test_scal(const encapc<1,Point_test_scal<T>,Mem> & p)
619 {
620 boost::fusion::at_c<0>(data) = p.template get<0>();
621 boost::fusion::at_c<1>(data) = p.template get<1>();
622 boost::fusion::at_c<2>(data) = p.template get<2>();
623 boost::fusion::at_c<3>(data) = p.template get<3>();
624 }
625
628 {
629 boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
630 boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
631 boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
632 boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
633 }
634
637 {
638 boost::fusion::at_c<0>(data) = boost::fusion::at_c<0>(p.data);
639 boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
640 boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
641 boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
642
643 return *this;
644 }
645
646 static inline bool noPointers()
647 {
648 return true;
649 }
650};
651
652template<typename T> const std::string Point_test_scal<T>::attributes::name[] = {"x","y","z","s"};
653
654#endif
Test structure used for several test.
boost::fusion::vector< T, T, T, T, T[2], T[2][2]> type_real
declaration of what the Point2D_test store
static const unsigned int max_prop
number of properties in the boost::fusion::vector
type data
object itself
static const unsigned int y
y property is at position 1 in the boost::fusion::vector
static const unsigned int t
t property is at position 5 in the boost::fusion::vector
static const unsigned int v
v property is at position 4 in the boost::fusion::vector
static const unsigned int s
s property is at position 3 in the boost::fusion::vector
static const unsigned int x
x property is at position 0 in the boost::fusion::vector
boost::fusion::vector< T, T, T, T, T[2], T[2][2]> type
declaration of what the Point2D_test store
static const unsigned int max_prop_real
number of properties in the boost::fusion::vector
static bool noPointers()
indicate that this structure has no pointers
static constexpr bool stag_mask[]
in case of usage with staggered grid it define which properties are staggered in the cell grid
static const unsigned int z
z property is at position 2 in the boost::fusion::vector
Test structure used for several test.
boost::fusion::vector< T, T, T, T, T[3], T[3][3]> type
declaration of what the Point_test_prp store
type data
Object itself.
static const unsigned int max_prop
maximum number of properties
Point_test_prp< T > operator=(const Point_test< T > &p)
Copy the point.
void sets(T s_)
set the s property
static const unsigned int y
y property is at position 1 in the boost::fusion::vector
void setx(T x_)
set the x property
void setz(T z_)
set the z property
static const unsigned int s
s property is at position 3 in the boost::fusion::vector
static const unsigned int x
x property is at position 0 in the boost::fusion::vector
static const unsigned int z
z property is at position 2 in the boost::fusion::vector
static const unsigned int v
v property is at position 4 in the boost::fusion::vector
Point_test_prp()
Default constructor.
Point_test_prp(const encapc< 1, Point_test_prp< T >, Mem > &p)
constructor from encapc
boost::fusion::result_of::at< type, boost::mpl::int_< i > >::type get()
getter method for a general property i
static const unsigned int t
t property is at position 5 in the boost::fusion::vector
Point_test_prp(const Point_test_prp< T > &p)
constructor from another point
void sety(T y_)
set the y property
point test with only scalar properties
static const unsigned int s
s property is at position 0 in the boost::fusion::vector
Point_test_scal()
Default constructor.
void sets(T s_)
set the property s
Point_test_scal(const encapc< 1, Point_test_scal< T >, Mem > &p)
constructor from encapc
type data
The data itself.
Point_test_scal(const Point_test_scal< T > &p)
constructor from another point
Point_test_scal< T > operator=(const Point_test_scal< T > &p)
operator=
static const unsigned int z
z property is at position 0 in the boost::fusion::vector
void sety(T y_)
set the property y
void setz(T z_)
set the property z
boost::fusion::vector< T, T, T, T > type
declaration of what the Point_test_scal store
void setx(T x_)
set the property x
boost::fusion::result_of::at< type, boost::mpl::int_< i > >::type get()
getter method for the property i
static const unsigned int max_prop
the number of properties
static const unsigned int x
x property is at position 0 in the boost::fusion::vector
static const unsigned int y
y property is at position 1 in the boost::fusion::vector
Test structure used for several test.
void fill()
fill
type data
The object itself.
static const unsigned int max_prop
number of properties in the boost::fusion::vector
bool operator==(const Point_test< float > &p) const
check if two point match
static const unsigned int x
x property is at position 0 in the boost::fusion::vector
boost::fusion::vector< T, T, T, T, T[3], T[3][3]> type_real
declaration of what the Point_test store
boost::fusion::vector< T, T, T, T, T[3], T[3][3]> type
declaration of what the Point_test store
void sety(T y_)
set the y property
__device__ __host__ Point_test< T > & operator=(const Point_test< T > &p)
Copy the point.
static const unsigned int s
s property is at position 3 in the boost::fusion::vector
void setv(size_t i, T v_)
set the v property
void setz(T z_)
set the z property
auto get() -> decltype(boost::fusion::at_c< i >(data))
getter method for a general property i
static const unsigned int v
v property is at position 4 in the boost::fusion::vector
void sets(T s_)
set the s property
static const unsigned int y
y property is at position 1 in the boost::fusion::vector
Point_test< float > & operator+=(const Point_test< float > &p)
Sum the point.
static const unsigned int z
z property is at position 2 in the boost::fusion::vector
void setx(T x_)
set the x property
Point_test()
Default constructor.
Point_test(const encapc< dim, Point_test< T >, Mem > &p)
Copy constructor from encapc (encapsulated point)
auto get() const -> decltype(boost::fusion::at_c< i >(data))
getter method for a general property i
static constexpr bool stag_mask[]
in case usage with a staggered grid indicate which properties are staggered in the cell
static const unsigned int max_prop_real
number of properties in the boost::fusion::vector
void sett(size_t i, size_t j, T t_)
set the t property
Point_test(const Point_test< T > &p)
constructor from another point
static const unsigned int t
t property is at position 5 in the boost::fusion::vector
static bool noPointers()
noPointers function
static const std::string name[]
array of attributes name
static const std::string name[]
array of names