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"
15BOOST_AUTO_TEST_SUITE( copy_grid_test )
17template<
unsigned int dim,
typename gr
id>
18void 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);
66template<
unsigned int dim,
typename gr
id>
67void 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);
123BOOST_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);
233BOOST_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);
285BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
grid_key_dx< dim > getKP2() const
Get the point p12 as grid_key_dx.
grid_key_dx< dim > getKP1() const
Get the point p1 as grid_key_dx.
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.
This is a way to quickly copy a grid into another grid.