8 #define BOOST_TEST_DYN_LINK 9 #include <boost/test/unit_test.hpp> 10 #include "Grid/map_grid.hpp" 11 #include "data_type/aggregate.hpp" 12 #include "Vector/map_vector.hpp" 13 #include "Point_test.hpp" 15 BOOST_AUTO_TEST_SUITE( copy_grid_test )
17 template<
unsigned int dim,
typename gr
id>
18 void Test_copy_grid(
grid & g_src,
grid & g_dst,
21 auto gs1 = g_src.getGrid();
22 auto gd1 = g_dst.getGrid();
23 auto it = g_src.getIterator();
32 g_src.template get<0>(key) = gs1.LinId(key);
54 auto key_s = its.
get();
55 auto key_d = itd.
get();
57 match &= g_src.template get<0>(key_s) == g_dst.template get<0>(key_d);
63 BOOST_REQUIRE_EQUAL(match,
true);
66 template<
unsigned int dim,
typename gr
id>
67 void Test_copy_grid_cmp(
grid & g_src,
grid & g_dst,
70 auto gs1 = g_src.getGrid();
71 auto gd1 = g_dst.getGrid();
72 auto it = g_src.getIterator();
81 for (
size_t k = 0 ; k < (size_t)gs1.LinId(key) % 4 ; k++)
83 g_src.template get<0>(key).add(gs1.LinId(key) + 1);
106 auto key_s = its.
get();
107 auto key_d = itd.
get();
109 match &= g_src.template get<0>(key_s).size() == g_dst.template get<0>(key_d).size();
111 for (
size_t i = 0 ; i < g_dst.template get<0>(key_d).size() ; i++)
113 match &= g_src.template get<0>(key_s).get(i) == g_dst.template get<0>(key_d).get(i);
120 BOOST_REQUIRE_EQUAL(match,
true);
123 BOOST_AUTO_TEST_CASE( copy_grid_test_use)
126 size_t sz1[1] = {37};
127 size_t sz2[2] = {37,37};
128 size_t sz3[3] = {37,37,37};
129 size_t sz4[4] = {37,37,37,37};
153 Test_copy_grid(g1_src,g1_dst,bsrc_1,bdst_1);
158 Test_copy_grid(g2_src,g2_dst,bsrc_2,bdst_2);
163 Test_copy_grid(g3_src,g3_dst,bsrc_3,bdst_3);
169 Test_copy_grid(g4_src,g4_dst,bsrc_4,bdst_4);
174 Test_copy_grid(g4_src,g4_dst,bsrc_4,bdst_4);
180 size_t sz1[1] = {37};
181 size_t sz2[2] = {37,37};
182 size_t sz3[3] = {37,37,37};
183 size_t sz4[4] = {37,37,37,37};
207 Test_copy_grid_cmp(g1_src,g1_dst,bsrc_1,bdst_1);
212 Test_copy_grid_cmp(g2_src,g2_dst,bsrc_2,bdst_2);
217 Test_copy_grid_cmp(g3_src,g3_dst,bsrc_3,bdst_3);
223 Test_copy_grid_cmp(g4_src,g4_dst,bsrc_4,bdst_4);
228 Test_copy_grid_cmp(g4_src,g4_dst,bsrc_4,bdst_4);
233 BOOST_AUTO_TEST_CASE( copy_grid_test_invalid)
236 size_t sz2_dst[2] = {3,7};
237 size_t sz2_src[2] = {3,4};
247 auto it = g2_src.getIterator();
253 g2_src.template get<0>(key) = 0.0;
258 auto it3 = g2_dst.getIterator();
262 auto key = it3.get();
264 g2_dst.template get<0>(key) = 1.0;
269 g2_dst.copy_to(g2_src,bsrc_2,bdst_2);
271 auto it2 = g2_dst.getIterator();
275 auto key = it2.get();
277 BOOST_REQUIRE_EQUAL(g2_dst.template get<0>(key),1.0);
285 BOOST_AUTO_TEST_SUITE_END()
__device__ __host__ index_type get(index_type i) const
Get the i index.
This is a way to quickly copy a grid into another grid.
grid_key_dx< dim > getKP2() const
Get the point p12 as grid_key_dx.
grid_key_dx< dim > get() const
Return the actual grid key iterator.
Declaration grid_key_dx_iterator_sub.
void zero()
Set to zero the key.
grid_key_dx< dim > getKP1() const
Get the point p1 as grid_key_dx.