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"
14 BOOST_AUTO_TEST_SUITE( grid_sm_test )
17 BOOST_AUTO_TEST_CASE( grid_sm_linearization )
23 size_t sz[3] = {8,8,8};
26 size_t bc[] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
29 BOOST_REQUIRE_EQUAL(lin,146);
31 BOOST_REQUIRE_EQUAL(lin,-1);
33 BOOST_REQUIRE_EQUAL(lin,-1);
35 for (
size_t i = 0 ; i < 3 ; i++)
39 BOOST_REQUIRE_EQUAL(lin,146);
41 BOOST_REQUIRE_EQUAL(lin,71);
43 BOOST_REQUIRE_EQUAL(lin,62);
47 BOOST_AUTO_TEST_CASE( grid_iterator_sub_p )
52 size_t sz[3] = {8,8,8};
64 for (
size_t i = 0 ; i < 3 ; i++)
66 BOOST_REQUIRE_EQUAL(
key.get(i) >= (
long int)0,
true);
67 BOOST_REQUIRE_EQUAL(
key.get(i) < (
long int)sz[i],
true);
75 BOOST_REQUIRE_EQUAL(cnt,216ul);
85 for (
size_t i = 0 ; i < 3 ; i++)
87 BOOST_REQUIRE_EQUAL(
key.get(i) >= (
long int)0,
true);
88 BOOST_REQUIRE_EQUAL(
key.get(i) < (
long int)sz[i],
true);
96 BOOST_REQUIRE_EQUAL(cnt,1331ul);
107 auto key = it3.get();
109 for (
size_t i = 0 ; i < 3 ; i++)
111 BOOST_REQUIRE_EQUAL(
key.get(i) >= (
long int)0,
true);
112 BOOST_REQUIRE_EQUAL(
key.get(i) < (
long int)sz[i],
true);
120 BOOST_REQUIRE_EQUAL(cnt,36ul);
130 auto key = it4.get();
132 for (
size_t i = 0 ; i < 3 ; i++)
134 BOOST_REQUIRE_EQUAL(
key.get(i) >= (
long int)0,
true);
135 BOOST_REQUIRE_EQUAL(
key.get(i) < (
long int)sz[i],
true);
143 BOOST_REQUIRE_EQUAL(cnt,27ul);
156 auto key = it5.get();
158 for (
size_t i = 0 ; i < 3 ; i++)
160 BOOST_REQUIRE_EQUAL(
key.get(i) >= 0,
true);
161 BOOST_REQUIRE_EQUAL(
key.get(i) < (
long int)sz[i],
true);
169 BOOST_REQUIRE_EQUAL(cnt,0ul);
172 BOOST_AUTO_TEST_CASE( grid_key_dx_iterator_hilbert_test )
186 while (h_it.isNext())
194 BOOST_REQUIRE_EQUAL(count, (
size_t)16);
198 bool val = h_it.get() == start;
200 BOOST_REQUIRE_EQUAL(val,
true);
215 while (h_it.isNext())
223 BOOST_REQUIRE_EQUAL(count, (
size_t)64);
227 bool val = h_it.get() == start;
229 BOOST_REQUIRE_EQUAL(val,
true);
234 BOOST_AUTO_TEST_CASE( grid_iterator_sp_test )
236 size_t sz[3] = {16,16,16};
244 auto info = c3.getGrid();
257 BOOST_REQUIRE_EQUAL(count,2185ul);
260 BOOST_AUTO_TEST_CASE( grid_iterator_test_use)
267 size_t div[3] = {16,16,16};
276 while (g_it.isNext())
288 BOOST_REQUIRE_EQUAL(count, (
size_t)16*16*16);
298 size_t div[3] = {16,16,16};
310 while (g_it.isNext())
322 BOOST_REQUIRE_EQUAL(count, (
size_t)14*14*14);
329 bool val = g_it.get() == start;
331 BOOST_REQUIRE_EQUAL(val,
true);
335 BOOST_AUTO_TEST_CASE( grid_sub_iterator_test )
342 size_t div[3] = {16,16,16};
352 auto g_it = g.getIterator(start,stop);
355 while (g_it.isNext())
360 g.template get<p::x>(key) = 1.0;
367 BOOST_REQUIRE_EQUAL(count, (
size_t)14*14*14);
372 BOOST_AUTO_TEST_SUITE_END()
grid_key_dx is the key to access any element in the grid
Position of the element of dimension d in the hyper-cube of dimension dim.
mem_id get(size_t i) const
Get the i index.
The same as grid_key_dx_iterator_sub_p but with periodic boundary.
void zero()
Set to zero the key.
This class is a trick to indicate the compiler a specific specialization pattern. ...
Declaration grid_key_dx_iterator_sub.
Test structure used for several test.
Class to check if the edge can be created or not.