8#define BOOST_TEST_DYN_LINK
9#include <boost/test/unit_test.hpp>
10#include "Grid/iterators/grid_skin_iterator.hpp"
11#include "Grid/map_grid.hpp"
12#include "data_type/aggregate.hpp"
13#include "Grid/iterators/grid_key_dx_iterator_sub_bc.hpp"
15BOOST_AUTO_TEST_SUITE( grid_iterators_tests )
21 auto it = gtest.getSubIterator(0);
27 gtest.get<0>(key) = 0;
35 while (gsi.isNext() ==
true)
39 gtest.get<0>(key) += 1;
46 BOOST_REQUIRE_EQUAL(count,(
size_t)vol_test);
49 auto it2 = gtest.getSubIterator(0);
55 ret &= gtest.get<0>(key) <= 1;
60 BOOST_REQUIRE_EQUAL(ret,
true);
63BOOST_AUTO_TEST_CASE( grid_skin_iterator_test )
67 size_t sz[] = {112,112,112};
75 size_t bc[] = {PERIODIC,PERIODIC,PERIODIC};
93 test_skin_iterator<3>(bx1,bx2,g_sm,bc,tot);
94 test_skin_iterator<3>(bx2,bx1,g_sm,bc,0);
95 test_skin_iterator<3>(bx3,bx3,g_sm,bc,4899);
102 test_skin_iterator<3>(bx1,bx2,g_sm,bc,tot);
103 test_skin_iterator<3>(bx2,bx1,g_sm,bc,0);
105 test_skin_iterator<3>(bx4,bx4,g_sm,bc,15042);
106 test_skin_iterator<3>(bx5,bx4,g_sm,bc,7679);
113 auto it = gtest.getSubIterator(0);
119 gtest.get<0>(key) = key.get(0) + key.get(1) + key.get(2);
125 stencil[0].
set_d(0,0);
126 stencil[0].
set_d(1,0);
127 stencil[0].
set_d(2,0);
132 while (gsi.isNext() ==
true)
134 auto key = gsi.get();
135 auto lin = gsi.getStencil<0>();
137 ret &= (gtest.get<0>(lin) == key.get(0) + key.get(1) + key.get(2));
143 BOOST_REQUIRE_EQUAL(ret,
true);
146BOOST_AUTO_TEST_CASE( grid_iterator_stencil_test )
148 size_t sz[] = {52,52,52};
150 test_stencil_iterator(g_sm);
165 auto it = gtest.getSubIterator(0);
171 gtest.get<0>(key) = key.get(0) + key.get(1) + key.get(2);
177 grid_key_dx<3> stop({(
long int)gtest.getGrid().size(0)-2,(
long int)gtest.getGrid().size(1)-2,(
long int)gtest.getGrid().size(2)-2});
182 while (gsi.isNext() ==
true)
184 auto key = gsi.get();
186 size_t lin1 = gsi.getStencil<0>();
187 size_t lin2 = gsi.getStencil<1>();
188 size_t lin3 = gsi.getStencil<2>();
189 size_t lin4 = gsi.getStencil<3>();
190 size_t lin5 = gsi.getStencil<4>();
191 size_t lin6 = gsi.getStencil<5>();
192 size_t lin7 = gsi.getStencil<6>();
195 size_t sum = 6*gtest.get<0>(lin1) -
205 ret &= g_sm.
LinId(key) == (
long int)lin1;
211 BOOST_REQUIRE_EQUAL(ret,
true);
214BOOST_AUTO_TEST_CASE( grid_iterator_sub_stencil_test )
216 size_t sz[] = {52,52,52};
218 test_stencil_sub_iterator(g_sm);
223BOOST_AUTO_TEST_CASE( grid_iterator_sub_bc )
226 size_t sz[] = {52,52,52};
232 size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
242 if ((p.get(0) != 51 && p.get(0) != 0) ||
243 (p.get(1) != 51 && p.get(1) != 0) ||
244 (p.get(2) != 51 && p.get(2) != 0))
254 BOOST_REQUIRE_EQUAL(is_ok,
true);
255 BOOST_REQUIRE_EQUAL(cnt,8ul);
259 size_t sz[] = {52,52,52};
265 size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
275 if ((p.get(0) != 51 && p.get(0) != 0) ||
276 (p.get(1) != 51 && p.get(1) != 0) ||
277 (p.get(2) != 51 && p.get(2) != 0))
287 BOOST_REQUIRE_EQUAL(is_ok,
true);
288 BOOST_REQUIRE_EQUAL(cnt,8ul);
292BOOST_AUTO_TEST_CASE( grid_iterator_sub_bc_hd )
298 for (
size_t i = 0 ; i < 50 ; i++)
303 bc[i] = NON_PERIODIC;
332 if ((p.get(0) != 51 && p.get(0) != 0) ||
333 (p.get(11) != 51 && p.get(11) != 0) ||
334 (p.get(23) != 51 && p.get(23) != 0))
344 BOOST_REQUIRE_EQUAL(is_ok,
true);
345 BOOST_REQUIRE_EQUAL(cnt,8ul);
348BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
__device__ __host__ T getHigh(int i) const
get the high interval of the box
This class implement the point shape in an N-dimensional space.
The same as grid_key_dx_iterator_sub_p but with periodic boundary.
Declaration grid_key_dx_iterator_sub.
grid_key_dx is the key to access any element in the grid
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
mem_id LinId(const grid_key_dx< N, ids_type > &gk, const signed char sum_id[N]) const
Linearization of the grid_key_dx with a specified shift.
__device__ __host__ const size_t(& getSize() const)[N]
Return the size of the grid as an array.
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data
It model an expression expr1 + ... exprn.