8 #ifndef OPENFPM_DATA_SRC_GRID_ITERATORS_COPY_GRID_UNIT_TEST_HPP_
9 #define OPENFPM_DATA_SRC_GRID_ITERATORS_COPY_GRID_UNIT_TEST_HPP_
11 #define BOOST_TEST_DYN_LINK
12 #include <boost/test/unit_test.hpp>
13 #include "Grid/map_grid.hpp"
14 #include "data_type/aggregate.hpp"
15 #include "Vector/map_vector.hpp"
17 BOOST_AUTO_TEST_SUITE( copy_grid_test )
19 template<
unsigned int dim, typename
grid>
20 void Test_copy_grid(
grid & g_src,
grid & g_dst,
21 Box<dim,
size_t> & bsrc_1,
Box<dim,
size_t> & bdst_1)
23 auto gs1 = g_src.getGrid();
24 auto gd1 = g_dst.getGrid();
25 auto it = g_src.getIterator();
34 g_src.template get<0>(
key) = gs1.LinId(
key);
56 auto key_s = its.
get();
57 auto key_d = itd.get();
59 match &= g_src.template get<0>(key_s) == g_dst.template get<0>(key_d);
65 BOOST_REQUIRE_EQUAL(match,
true);
68 template<
unsigned int dim,
typename gr
id>
69 void Test_copy_grid_cmp(
grid & g_src,
grid & g_dst,
72 auto gs1 = g_src.getGrid();
73 auto gd1 = g_dst.getGrid();
74 auto it = g_src.getIterator();
83 for (
size_t k = 0 ; k < (size_t)gs1.LinId(
key) % 4 ; k++)
85 g_src.template get<0>(
key).add(gs1.LinId(
key) + 1);
108 auto key_s = its.
get();
109 auto key_d = itd.get();
111 match &= g_src.template get<0>(key_s).size() == g_dst.template get<0>(key_d).size();
113 for (
size_t i = 0 ; i < g_dst.template get<0>(key_d).size() ; i++)
115 match &= g_src.template get<0>(key_s).
get(i) == g_dst.template get<0>(key_d).
get(i);
122 BOOST_REQUIRE_EQUAL(match,
true);
125 BOOST_AUTO_TEST_CASE( copy_grid_test_use)
128 size_t sz1[1] = {37};
129 size_t sz2[2] = {37,37};
130 size_t sz3[3] = {37,37,37};
131 size_t sz4[4] = {37,37,37,37};
155 Test_copy_grid(g1_src,g1_dst,bsrc_1,bdst_1);
160 Test_copy_grid(g2_src,g2_dst,bsrc_2,bdst_2);
165 Test_copy_grid(g3_src,g3_dst,bsrc_3,bdst_3);
171 Test_copy_grid(g4_src,g4_dst,bsrc_4,bdst_4);
176 Test_copy_grid(g4_src,g4_dst,bsrc_4,bdst_4);
182 size_t sz1[1] = {37};
183 size_t sz2[2] = {37,37};
184 size_t sz3[3] = {37,37,37};
185 size_t sz4[4] = {37,37,37,37};
209 Test_copy_grid_cmp(g1_src,g1_dst,bsrc_1,bdst_1);
214 Test_copy_grid_cmp(g2_src,g2_dst,bsrc_2,bdst_2);
221 Test_copy_grid_cmp(g3_src,g3_dst,bsrc_3,bdst_3);
227 Test_copy_grid_cmp(g4_src,g4_dst,bsrc_4,bdst_4);
232 Test_copy_grid_cmp(g4_src,g4_dst,bsrc_4,bdst_4);
238 BOOST_AUTO_TEST_SUITE_END()
grid_key_dx is the key to access any element in the grid
grid_key_dx< dim > getKP2() const
Get the point p12 as grid_key_dx.
This is a way to quickly copy a grid into another grid.
grid_key_dx< dim > getKP1() const
Get the point p1 as grid_key_dx.
void zero()
Set to zero the key.
This class represent an N-dimensional box.
grid_key_dx< dim > get() const
Return the actual grid key iterator.
This class is a trick to indicate the compiler a specific specialization pattern. ...
Declaration grid_key_dx_iterator_sub.