8#ifndef OPENFPM_DATA_SRC_GRID_GRID_SM_UNIT_TESTS_HPP_
9#define OPENFPM_DATA_SRC_GRID_GRID_SM_UNIT_TESTS_HPP_
11#include "iterators/grid_key_dx_iterator_sub_bc.hpp"
12#include "grid_key_dx_iterator_hilbert.hpp"
14BOOST_AUTO_TEST_SUITE( grid_sm_test )
17BOOST_AUTO_TEST_CASE( grid_sm_linearization )
23 const comb<3> c({(char)1,(
char)0,(char)-1});
24 size_t sz[3] = {8,8,8};
27 size_t bc[] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
30 BOOST_REQUIRE_EQUAL(lin,146);
32 BOOST_REQUIRE_EQUAL(lin,-1);
34 BOOST_REQUIRE_EQUAL(lin,-1);
36 for (
size_t i = 0 ; i < 3 ; i++)
40 BOOST_REQUIRE_EQUAL(lin,146);
42 BOOST_REQUIRE_EQUAL(lin,71);
44 BOOST_REQUIRE_EQUAL(lin,62);
48BOOST_AUTO_TEST_CASE( grid_iterator_sub_p )
53 size_t sz[3] = {8,8,8};
65 for (
size_t i = 0 ; i < 3 ; i++)
67 BOOST_REQUIRE_EQUAL(key.get(i) >= (
long int)0,
true);
68 BOOST_REQUIRE_EQUAL(key.get(i) < (
long int)sz[i],
true);
76 BOOST_REQUIRE_EQUAL(cnt,216ul);
86 for (
size_t i = 0 ; i < 3 ; i++)
88 BOOST_REQUIRE_EQUAL(key.get(i) >= (
long int)0,
true);
89 BOOST_REQUIRE_EQUAL(key.get(i) < (
long int)sz[i],
true);
97 BOOST_REQUIRE_EQUAL(cnt,1331ul);
108 auto key = it3.
get();
110 for (
size_t i = 0 ; i < 3 ; i++)
112 BOOST_REQUIRE_EQUAL(key.get(i) >= (
long int)0,
true);
113 BOOST_REQUIRE_EQUAL(key.get(i) < (
long int)sz[i],
true);
121 BOOST_REQUIRE_EQUAL(cnt,36ul);
125 grid_key_dx_iterator_sub_bc<3,no_stencil,grid_sm<3,void>,
do_not_print_warning_on_adjustment<3,grid_sm<3,void>>> it4(gs,key4,key5,{NON_PERIODIC,NON_PERIODIC,NON_PERIODIC});
131 auto key = it4.get();
133 for (
size_t i = 0 ; i < 3 ; i++)
135 BOOST_REQUIRE_EQUAL(key.get(i) >= (
long int)0,
true);
136 BOOST_REQUIRE_EQUAL(key.get(i) < (
long int)sz[i],
true);
144 BOOST_REQUIRE_EQUAL(cnt,27ul);
151 grid_key_dx_iterator_sub_bc<3,no_stencil,grid_sm<3,void>,
do_not_print_warning_on_adjustment<3,grid_sm<3,void>>> it5(gs,key6,key7,{NON_PERIODIC,NON_PERIODIC,NON_PERIODIC});
157 auto key = it5.get();
159 for (
size_t i = 0 ; i < 3 ; i++)
161 BOOST_REQUIRE_EQUAL(key.get(i) >= 0,
true);
162 BOOST_REQUIRE_EQUAL(key.get(i) < (
long int)sz[i],
true);
170 BOOST_REQUIRE_EQUAL(cnt,0ul);
173BOOST_AUTO_TEST_CASE( grid_key_dx_iterator_hilbert_test )
187 while (h_it.isNext())
195 BOOST_REQUIRE_EQUAL(count, (
size_t)16);
199 bool val = h_it.get() == start;
201 BOOST_REQUIRE_EQUAL(val,
true);
216 while (h_it.isNext())
224 BOOST_REQUIRE_EQUAL(count, (
size_t)64);
228 bool val = h_it.get() == start;
230 BOOST_REQUIRE_EQUAL(val,
true);
235BOOST_AUTO_TEST_CASE( grid_iterator_sp_test )
237 size_t sz[3] = {16,16,16};
245 auto info = c3.getGrid();
258 BOOST_REQUIRE_EQUAL(count,2185ul);
261BOOST_AUTO_TEST_CASE( grid_iterator_test_use)
268 size_t div[3] = {16,16,16};
277 while (g_it.isNext())
289 BOOST_REQUIRE_EQUAL(count, (
size_t)16*16*16);
299 size_t div[3] = {16,16,16};
311 while (g_it.isNext())
323 BOOST_REQUIRE_EQUAL(count, (
size_t)14*14*14);
330 bool val = g_it.get() == start;
332 BOOST_REQUIRE_EQUAL(val,
true);
336BOOST_AUTO_TEST_CASE( grid_sub_iterator_test )
343 size_t div[3] = {16,16,16};
353 auto g_it = g.getIterator(start,stop);
356 while (g_it.isNext())
361 g.template get<p::x>(key) = 1.0;
368 BOOST_REQUIRE_EQUAL(count, (
size_t)14*14*14);
373BOOST_AUTO_TEST_SUITE_END()
Class to check if the edge can be created or not.
Test structure used for several test.
The same as grid_key_dx_iterator_sub_p but with periodic boundary.
const grid_key_dx< dim > get() const
Return the actual grid key iterator.
Declaration grid_key_dx_iterator_sub.
grid_key_dx is the key to access any element in the grid
void zero()
Set to zero the key.
__device__ __host__ index_type get(index_type i) const
Get the i index.
Position of the element of dimension d in the hyper-cube of dimension dim.