OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
shift_vect_converter_tests.cpp
1/*
2 * shift_vect_converter_tests.cpp
3 *
4 * Created on: Feb 8, 2018
5 * Author: i-bird
6 */
7
8#define BOOST_TEST_DYN_LINK
9#include <boost/test/unit_test.hpp>
10#include "Space/Shape/Box.hpp"
11
12#include "Vector/map_vector.hpp"
13#include "Decomposition/shift_vect_converter.hpp"
14
15BOOST_AUTO_TEST_SUITE( shift_vect_converter_tests_suite )
16
17BOOST_AUTO_TEST_CASE( shift_vect_converter_tests_use )
18{
19 {
20 Box<3,double> domain({0.0,0.0,0.0},{1.0,1.0,1.0});
22 size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
23
25
26 svc.generateShiftVectors(domain,bc,sv);
27
28 BOOST_REQUIRE_EQUAL(sv.size(),27ul);
29
30 // We test that the cominations generate the correct shift vectors
31 comb<3> cmb1({(char)-1,(char)-1,(char)1});
32 comb<3> cmb2({(char)-1,(char)0,(char)1});
33 comb<3> cmb3({(char)0,(char)0,(char)1});
34
35 size_t i = svc.linId(cmb1);
36
37 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[0],-1.0);
38 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[1],1.0);
39 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[2],1.0);
40
41 i = svc.linId(cmb2);
42
43 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[0],-1.0);
44 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[1],0.0);
45 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[2],1.0);
46
47 i = svc.linId(cmb3);
48
49 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[0],-1.0);
50 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[1],0.0);
51 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[2],0.0);
52
53 }
54
55 {
57 Box<50,double> domain;
58 size_t bc[50];
59
60 for (size_t i = 0 ; i < 50 ; i++)
61 {
62 domain.setLow(i,0.0);
63 domain.setHigh(i,1.0);
64 bc[i] = NON_PERIODIC;
65 }
66
67 bc[5] = PERIODIC;
68 bc[17] = PERIODIC;
69 bc[23] = PERIODIC;
70
72
73 svc.generateShiftVectors(domain,bc,sv);
74
75 BOOST_REQUIRE_EQUAL(sv.size(),27ul);
76
77 // We test that the cominations generate the correct shift vectors
78 comb<50> cmb1;
79 comb<50> cmb2;
80 comb<50> cmb3;
81
82 cmb1.c[5] = 1;
83 cmb1.c[17] = -1;
84 cmb1.c[23] = -1;
85
86 cmb2.c[5] = 1;
87 cmb2.c[17] = 0;
88 cmb2.c[23] = -1;
89
90 cmb3.c[5] = 1;
91 cmb3.c[17] = 0;
92 cmb3.c[23] = 0;
93
94 size_t i = svc.linId(cmb1);
95
96 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[5],-1.0);
97 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[6],0.0);
98 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[17],1.0);
99 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[23],1.0);
100 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[24],0.0);
101
102 i = svc.linId(cmb2);
103
104 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[5],-1.0);
105 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[6],0.0);
106 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[17],0.0);
107 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[23],1.0);
108 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[24],0.0);
109
110 i = svc.linId(cmb3);
111
112 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[5],-1.0);
113 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[6],0.0);
114 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[17],0.0);
115 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[23],0.0);
116 BOOST_REQUIRE_EQUAL(sv.get<0>(i)[24],0.0);
117
118 }
119}
120
121
122BOOST_AUTO_TEST_SUITE_END()
123
This class represent an N-dimensional box.
Definition Box.hpp:61
Implementation of 1-D std::vector like structure.
size_t size()
Stub size.
in case of high dimensions shift vector converter
void generateShiftVectors(const Box< dim, T > &domain, size_t(&bc)[dim], openfpm::vector< Point< dim, T >, Memory, layout_base > &shifts)
Here we generare the shift vectors for the low dimension case.
size_t linId(const comb< dim > &cmb)
linearize the combination in case of high dimensions
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition comb.hpp:35
signed char c[dim]
Array that store the combination.
Definition comb.hpp:37