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
16/*! \brief Test structure used for several test
17 *
18 * It is a test structure used for several test it contain 4 scalar "x,y,z,s"
19 * one vector property v[3] and one tensor or rank 2 t[3][3]
20 *
21 * It is the OpenFPM data structure format for type parsing of see openFPM_data wiki
22 * for more information
23 *
24 * ### Declaration of a point
25 * \snippet vector_test_util.hpp Point declaration
26 *
27 * ### Create a type definition
28 *
29 * \snippet vector_test_util.hpp typedef point
30 *
31 * ### Access the members
32 * \snippet vector_test_util.hpp Point usage
33 *
34 */
35template<typename T> class Point2D_test
36{
37public:
38
39 //! declaration of what the Point2D_test store
40 typedef boost::fusion::vector<T,T,T,T,T[2],T[2][2]> type;
41
42 //! declaration of what the Point2D_test store
43 typedef boost::fusion::vector<T,T,T,T,T[2],T[2][2]> type_real;
44
45 //! in case of usage with staggered grid it define which properties are staggered in the cell grid
46 static constexpr bool stag_mask[]={false,false,false,true,true,true};
47
48 //! object itself
49 type data;
50
51 //! x property is at position 0 in the boost::fusion::vector
52 static const unsigned int x = 0;
53
54 //! y property is at position 1 in the boost::fusion::vector
55 static const unsigned int y = 1;
56
57 //! z property is at position 2 in the boost::fusion::vector
58 static const unsigned int z = 2;
59
60 //! s property is at position 3 in the boost::fusion::vector
61 static const unsigned int s = 3;
62
63 //! v property is at position 4 in the boost::fusion::vector
64 static const unsigned int v = 4;
65
66 //! t property is at position 5 in the boost::fusion::vector
67 static const unsigned int t = 5;
68
69 //! number of properties in the boost::fusion::vector
70 static const unsigned int max_prop = 6;
71
72 //! number of properties in the boost::fusion::vector
73 static const unsigned int max_prop_real = 6;
74
75 /*! \brief indicate that this structure has no pointers
76 *
77 * \return true
78 *
79 */
80 static inline bool noPointers()
81 {
82 return true;
83 }
84};
85
86/*! \brief Test structure used for several test
87 *
88 * It is a test structure used for several test it contain 4 scalar "x,y,z,s"
89 * one vector property v[3] and one tensor or rank 2 t[3][3]
90 *
91 * It is the format for type parsing of in the openfpm structures see openFPM_data wiki
92 * for more information
93 *
94 * ### Declaration of a point
95 * \snippet vector_test_util.hpp Point declaration
96 *
97 * ### Create a type definition
98 *
99 * \snippet vector_test_util.hpp typedef point
100 *
101 * ### Access the members
102 * \snippet vector_test_util.hpp Point usage
103 *
104 */
105template<typename T> class Point_test
106{
107public:
108
109#ifdef SE_CLASS3
110
111 //! declaration of what the Point_test store
112 typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3],SE3_ADD_PROP(6)> type;
113
114 //! declaration of what the Point_test store
115 typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type_real;
116
117#else
118
119 //! declaration of what the Point_test store
120 typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type;
121
122 //! declaration of what the Point_test store
123 typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type_real;
124
125#endif
126
127 //! in case usage with a staggered grid indicate which properties are staggered in the cell
128 static constexpr bool stag_mask[]={false,false,false,true,true,true};
129
130 //! The object itself
131 type data;
132
133 //! x property is at position 0 in the boost::fusion::vector
134 static const unsigned int x = 0;
135
136 //! y property is at position 1 in the boost::fusion::vector
137 static const unsigned int y = 1;
138
139 //! z property is at position 2 in the boost::fusion::vector
140 static const unsigned int z = 2;
141
142 //! s property is at position 3 in the boost::fusion::vector
143 static const unsigned int s = 3;
144
145 //! v property is at position 4 in the boost::fusion::vector
146 static const unsigned int v = 4;
147
148 //! t property is at position 5 in the boost::fusion::vector
149 static const unsigned int t = 5;
150
151#ifdef SE_CLASS3
152
153 //! number of properties in the boost::fusion::vector
154 static const unsigned int max_prop = SE3_MAX_PROP(6);
155
156 //! number of properties in the boost::fusion::vector
157 static const unsigned int max_prop_real = 6;
158
159#else
160
161 //! number of properties in the boost::fusion::vector
162 static const unsigned int max_prop = 6;
163
164 //! number of properties in the boost::fusion::vector
165 static const unsigned int max_prop_real = 6;
166
167#endif
168
169 // Setter method
170
171 /*! \brief set the x property
172 *
173 * \param x_
174 *
175 */
176 inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
177
178 /*! \brief set the y property
179 *
180 * \param y_
181 *
182 */
183 inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
184
185 /*! \brief set the z property
186 *
187 * \param z_
188 *
189 */
190 inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
191
192 /*! \brief set the s property
193 *
194 * \param s_
195 *
196 */
197 inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
198
199 /*! \brief set the v property
200 *
201 * \param i component to set
202 * \param v_ value
203 *
204 */
205 inline void setv(size_t i,T v_) {boost::fusion::at_c<4>(data)[i] = v_;}
206
207 /*! \brief set the t property
208 *
209 * \param i component to set
210 * \param j component to set
211 * \param t_ value
212 *
213 */
214 inline void sett(size_t i, size_t j,T t_) {boost::fusion::at_c<5>(data)[i][j] = t_;}
215
216
217 //! getter method for a general property i
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
222 //! getter method for a general property i
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
227 //! Default constructor
228 Point_test()
229 {}
230
231 /*! \brief check if two point match
232 *
233 * \param p point to compare
234 *
235 */
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
257 /*! \brief Sum the point
258 *
259 * \param p point to sum
260 *
261 * \return this
262 *
263 */
264 Point_test<float> & operator+=(const Point_test<float> & p)
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
283 /*! \brief Copy constructor from encapc (encapsulated point)
284 *
285 * \param p ecapsulated point
286 *
287 */
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
307 /*! \brief constructor from another point
308 *
309 * \param p point to copy
310 *
311 */
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
331 /*! \brief Copy the point
332 *
333 * \param p point
334 *
335 * \return this
336 *
337 */
338 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
359 /*! \brief noPointers function
360 *
361 * It notify that Point_test does not have any pointer and is safe to send
362 *
363 * \return true
364 *
365 */
366 static bool noPointers() {return true;}
367
368 /*! \brief fill
369 *
370 * Fill the point with data
371 *
372 */
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
394/*! \brief Test structure used for several test
395 *
396 * It is a test structure used for several test it contain 4 scalar "x,y,z,s"
397 * one vector property v[3] and one tensor or rank 2 t[3][3] + the definition
398 * of properties names
399 *
400 * It is the format for type parsing of in the openfpm structures see openFPM_data wiki
401 * for more information
402 *
403 * ### Declaration of a point
404 * \snippet vector_test_util.hpp Point prp declaration
405 *
406 * ### Create a type definition
407 *
408 * \snippet vector_test_util.hpp typedef point
409 *
410 * ### Access the members
411 * \snippet vector_test_util.hpp Point prp usage
412 *
413 */
414template<typename T> class Point_test_prp
415{
416public:
417
418 //! declaration of what the Point_test_prp store
419 typedef boost::fusion::vector<T,T,T,T,T[3],T[3][3]> type;
420
421 //! Object itself
422 type data;
423
424 //! x property is at position 0 in the boost::fusion::vector
425 static const unsigned int x = 0;
426
427 //! y property is at position 1 in the boost::fusion::vector
428 static const unsigned int y = 1;
429
430 //! z property is at position 2 in the boost::fusion::vector
431 static const unsigned int z = 2;
432
433 //! s property is at position 3 in the boost::fusion::vector
434 static const unsigned int s = 3;
435
436 //! v property is at position 4 in the boost::fusion::vector
437 static const unsigned int v = 4;
438
439 //! t property is at position 5 in the boost::fusion::vector
440 static const unsigned int t = 5;
441
442 //! maximum number of properties
443 static const unsigned int max_prop = 6;
444
445 // Setter method
446
447 /*! \brief set the x property
448 *
449 * \param x_
450 *
451 */
452 inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
453
454 /*! \brief set the y property
455 *
456 * \param y_
457 *
458 */
459 inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
460
461 /*! \brief set the z property
462 *
463 * \param z_
464 *
465 */
466 inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
467
468 /*! \brief set the s property
469 *
470 * \param s_
471 *
472 */
473 inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
474
475 //! Attributes name
476 struct attributes
477 {
478 //! array of attributes name
479 static const std::string name[];
480 };
481
482 //! getter method for a general property i
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
485 //! Default constructor
486 Point_test_prp()
487 {}
488
489 //! constructor from encapc
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
509 //! constructor from another point
510 inline Point_test_prp(const Point_test_prp<T> & p)
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
530 /*! \brief Copy the point
531 *
532 * \param p point
533 *
534 * \return this
535 *
536 */
537 inline Point_test_prp<T> operator= (const Point_test<T> & p)
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
566//! point test with only scalar properties
567template<typename T> class Point_test_scal
568{
569public:
570
571 //! declaration of what the Point_test_scal store
572 typedef boost::fusion::vector<T,T,T,T> type;
573
574 //! The data itself
575 type data;
576
577 //! x property is at position 0 in the boost::fusion::vector
578 static const unsigned int x = 0;
579
580 //! y property is at position 1 in the boost::fusion::vector
581 static const unsigned int y = 1;
582
583 //! z property is at position 0 in the boost::fusion::vector
584 static const unsigned int z = 2;
585
586 //! s property is at position 0 in the boost::fusion::vector
587 static const unsigned int s = 3;
588
589 //! the number of properties
590 static const unsigned int max_prop = 4;
591
592 // Setter method
593
594 //! set the property x
595 inline void setx(T x_) {boost::fusion::at_c<0>(data) = x_;};
596 //! set the property y
597 inline void sety(T y_) {boost::fusion::at_c<1>(data) = y_;};
598 //! set the property z
599 inline void setz(T z_) {boost::fusion::at_c<2>(data) = z_;};
600 //! set the property s
601 inline void sets(T s_) {boost::fusion::at_c<3>(data) = s_;};
602
603 //! Attributes name
604 struct attributes
605 {
606 //! array of names
607 static const std::string name[];
608 };
609
610 //! getter method for the property i
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
613 //! Default constructor
614 Point_test_scal()
615 {}
616
617 //! constructor from encapc
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
626 //! constructor from another point
627 inline Point_test_scal(const Point_test_scal<T> & p)
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
635 //! operator=
636 inline Point_test_scal<T> operator= (const Point_test_scal<T> & p)
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
655