OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
vector_dist_operators_unit_tests.cpp
1/*
2 * vector_dist_operators_unit_tests.hpp
3 *
4 * Created on: Jun 11, 2016
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_UNIT_TESTS_HPP_
9#define OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_UNIT_TESTS_HPP_
10
11#define BOOST_TEST_DYN_LINK
12#include <boost/test/unit_test.hpp>
13
14#include "tests/vector_dist_operators_tests_util.hpp"
15
16
18
19BOOST_AUTO_TEST_SUITE( vector_dist_operators_test )
20
21BOOST_AUTO_TEST_CASE( vector_dist_operators_test )
22{
23 if (create_vcluster().getProcessingUnits() > 3)
24 return;
25
26 Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0});
27
28 // Boundary conditions
29 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
30
31 // ghost
32 Ghost<3,float> ghost(0.05);
33
34 // vector type
36
38
40}
41
42
44{
45 auto it = v1.getDomainIterator();
46
47 while (it.isNext())
48 {
49 auto p = it.get();
50
51 v1.template getProp<0>(p) = -1.0;
52 v1.template getProp<1>(p) = -1.0;
53 v1.template getProp<2>(p) = -1.0;
54 v1.template getProp<3>(p) = -1.0;
55 v1.template getProp<4>(p) = -1.0;
56 v1.template getProp<5>(p) = -1.0;
57 v1.template getProp<6>(p) = -1.0;
58 v1.template getProp<7>(p) = -1.0;
59
60 ++it;
61 }
62}
63
64template<unsigned int i> void loop_check(vector_dist<3,float,aggregate<float,float,float,float,float,float,float,float>> & v1, float check)
65{
66 auto it = v1.getDomainIterator();
67 bool ret = true;
68
69 while (it.isNext())
70 {
71 auto p = it.get();
72
73 ret &= v1.template getProp<i>(p) == check;
74
75 ++it;
76 }
77
78 BOOST_REQUIRE_EQUAL(ret,true);
79}
80
82{
83 float check = -1.0;
84
85 if (0 < i) check = 0.0;
86 else check = -1.0;
87 loop_check<0>(v1,check);
88
89 if (1 < i) check = 1.0;
90 else check = -1.0;
91 loop_check<1>(v1,check);
92
93 if (2 < i) check = 2.0;
94 else check = -1.0;
95 loop_check<2>(v1,check);
96
97 if (3 < i) check = 3.0;
98 else check = -1.0;
99 loop_check<3>(v1,check);
100
101 if (4 < i) check = 4.0;
102 else check = -1.0;
103 loop_check<4>(v1,check);
104
105 if (5 < i) check = 5.0;
106 else check = -1.0;
107 loop_check<5>(v1,check);
108
109 if (6 < i) check = 6.0;
110 else check = -1.0;
111 loop_check<6>(v1,check);
112
113 if (7 < i) check = 7.0;
114 else check = -1.0;
115 loop_check<7>(v1,check);
116}
117
118BOOST_AUTO_TEST_CASE( vector_dist_operators_assign_test )
119{
120 if (create_vcluster().getProcessingUnits() > 3)
121 return;
122
123 Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0});
124
125 // Boundary conditions
126 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
127
128 // ghost
129 Ghost<3,float> ghost(0.05);
130
132
133 auto v1 = getV<0>(vd);
134 auto v2 = getV<1>(vd);
135 auto v3 = getV<2>(vd);
136 auto v4 = getV<3>(vd);
137 auto v5 = getV<4>(vd);
138 auto v6 = getV<5>(vd);
139 auto v7 = getV<6>(vd);
140 auto v8 = getV<7>(vd);
141
142 auto v_pos = getV<POS_PROP>(vd);
143
144 reset(vd);
145
146 assign(v1,0.0,
147 v2,1.0);
148
149 check(vd,2);
150
151 reset(vd);
152
153 assign(v1,0.0,
154 v2,1.0,
155 v3,2.0);
156
157 check(vd,3);
158
159 reset(vd);
160
161 assign(v1,0.0,
162 v2,1.0,
163 v3,2.0,
164 v4,3.0);
165
166 check(vd,4);
167
168 reset(vd);
169
170 assign(v1,0.0,
171 v2,1.0,
172 v3,2.0,
173 v4,3.0,
174 v5,4.0);
175
176 check(vd,5);
177
178 reset(vd);
179
180 assign(v1,0.0,
181 v2,1.0,
182 v3,2.0,
183 v4,3.0,
184 v5,4.0,
185 v6,5.0);
186
187 check(vd,6);
188
189 reset(vd);
190
191 assign(v1,0.0,
192 v2,1.0,
193 v3,2.0,
194 v4,3.0,
195 v5,4.0,
196 v6,5.0,
197 v7,6.0);
198
199 check(vd,7);
200
201 reset(vd);
202
203 assign(v1,0.0,
204 v2,1.0,
205 v3,2.0,
206 v4,3.0,
207 v5,4.0,
208 v6,5.0,
209 v7,6.0,
210 v8,7.0);
211
212 check(vd,8);
213
214 // Self assign;
215 assign(v_pos,v_pos,
216 v_pos,v_pos);
217}
218
219BOOST_AUTO_TEST_SUITE_END()
220
221
222#endif /* OPENFPM_NUMERICS_SRC_OPERATORS_VECTOR_VECTOR_DIST_OPERATORS_UNIT_TESTS_HPP_ */
This class represent an N-dimensional box.
Definition Box.hpp:61
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
Distributed vector.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...