8 #define BOOST_TEST_DYN_LINK 
    9 #include <boost/test/unit_test.hpp> 
   10 #include "Grid/iterators/grid_skin_iterator.hpp" 
   11 #include "Grid/map_grid.hpp" 
   12 #include "data_type/aggregate.hpp" 
   13 #include "Grid/iterators/grid_key_dx_iterator_sub_bc.hpp" 
   15 BOOST_AUTO_TEST_SUITE( grid_iterators_tests )
 
   17 template <
unsigned int dim> 
void test_skin_iterator(
Box<3,
size_t> & bx1, Box<3,
size_t> & bx2, 
grid_sm<3,
void> & g_sm,
size_t (& bc)[dim] , 
size_t vol_test)
 
   21     auto it = gtest.getSubIterator(0);
 
   27         gtest.get<0>(
key) = 0;
 
   35     while (gsi.isNext() == 
true)
 
   39         gtest.get<0>(
key) += 1;
 
   46     BOOST_REQUIRE_EQUAL(count,(
size_t)vol_test);
 
   49     auto it2 = gtest.getSubIterator(0);
 
   55         ret &= gtest.get<0>(
key) <= 1;
 
   60     BOOST_REQUIRE_EQUAL(ret,
true);
 
   63 BOOST_AUTO_TEST_CASE( grid_skin_iterator_test )
 
   67     size_t sz[] = {112,112,112};
 
   75     size_t bc[] = {PERIODIC,PERIODIC,PERIODIC};
 
   81     tot *= bx2.getHigh(0) - bx2.getLow(0) + 1;
 
   82     tot *= bx2.getHigh(1) - bx2.getLow(1) + 1;
 
   83     tot *= bx2.getHigh(2) - bx2.getLow(2) + 1;
 
   87     tot_ *= bx1.getHigh(0) - bx1.getLow(0) + 1 - 2;
 
   88     tot_ *= bx1.getHigh(1) - bx1.getLow(1) + 1 - 2;
 
   89     tot_ *= bx1.getHigh(2) - bx1.getLow(2) + 1 - 2;
 
   93     test_skin_iterator<3>(bx1,bx2,g_sm,bc,tot);
 
   94     test_skin_iterator<3>(bx2,bx1,g_sm,bc,0);
 
   95     test_skin_iterator<3>(bx3,bx3,g_sm,bc,4899);
 
  102     test_skin_iterator<3>(bx1,bx2,g_sm,bc,tot);
 
  103     test_skin_iterator<3>(bx2,bx1,g_sm,bc,0);
 
  105     test_skin_iterator<3>(bx4,bx4,g_sm,bc,15042);
 
  106     test_skin_iterator<3>(bx5,bx4,g_sm,bc,7679);
 
  113     auto it = gtest.getSubIterator(0);
 
  119         gtest.get<0>(
key) = 
key.get(0) + 
key.get(1) + 
key.get(2);
 
  125     stencil[0].
set_d(0,0);
 
  126     stencil[0].
set_d(1,0);
 
  127     stencil[0].
set_d(2,0);
 
  132     while (gsi.isNext() == 
true)
 
  134         auto key = gsi.get();
 
  135         auto lin = gsi.getStencil<0>();
 
  137         ret &= (gtest.get<0>(lin) == 
key.get(0) + 
key.get(1) + 
key.get(2));
 
  143     BOOST_REQUIRE_EQUAL(ret,
true);
 
  146 BOOST_AUTO_TEST_CASE( grid_iterator_stencil_test )
 
  148     size_t sz[] = {52,52,52};
 
  150     test_stencil_iterator(g_sm);
 
  165     auto it = gtest.getSubIterator(0);
 
  171         gtest.get<0>(
key) = 
key.get(0) + 
key.get(1) + 
key.get(2);
 
  177     grid_key_dx<3> stop({(
long int)gtest.getGrid().size(0)-2,(
long int)gtest.getGrid().size(1)-2,(
long int)gtest.getGrid().size(2)-2});
 
  182     while (gsi.isNext() == 
true)
 
  184         auto key = gsi.get();
 
  186         size_t lin1 = gsi.getStencil<0>();
 
  187         size_t lin2 = gsi.getStencil<1>();
 
  188         size_t lin3 = gsi.getStencil<2>();
 
  189         size_t lin4 = gsi.getStencil<3>();
 
  190         size_t lin5 = gsi.getStencil<4>();
 
  191         size_t lin6 = gsi.getStencil<5>();
 
  192         size_t lin7 = gsi.getStencil<6>();
 
  195         size_t sum = 6*gtest.get<0>(lin1) -
 
  205         ret &= g_sm.
LinId(
key) == (
long int)lin1;
 
  211     BOOST_REQUIRE_EQUAL(ret,
true);
 
  214 BOOST_AUTO_TEST_CASE( grid_iterator_sub_stencil_test )
 
  216     size_t sz[] = {52,52,52};
 
  218     test_stencil_sub_iterator(g_sm);
 
  223 BOOST_AUTO_TEST_CASE( grid_iterator_sub_bc )
 
  226     size_t sz[] = {52,52,52};
 
  232     size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
 
  242         if ((p.get(0) != 51 && p.get(0) != 0) ||
 
  243             (p.get(1) != 51 && p.get(1) != 0) ||
 
  244             (p.get(2) != 51 && p.get(2) != 0))
 
  254     BOOST_REQUIRE_EQUAL(is_ok,
true);
 
  255     BOOST_REQUIRE_EQUAL(cnt,8ul);
 
  259     size_t sz[] = {52,52,52};
 
  265     size_t bc[3] = {PERIODIC,PERIODIC,PERIODIC};
 
  275         if ((p.get(0) != 51 && p.get(0) != 0) ||
 
  276             (p.get(1) != 51 && p.get(1) != 0) ||
 
  277             (p.get(2) != 51 && p.get(2) != 0))
 
  287     BOOST_REQUIRE_EQUAL(is_ok,
true);
 
  288     BOOST_REQUIRE_EQUAL(cnt,8ul);
 
  292 BOOST_AUTO_TEST_CASE( grid_iterator_sub_bc_hd )
 
  298     for (
size_t i = 0 ; i < 50 ; i++)
 
  303         bc[i] = NON_PERIODIC;
 
  332         if ((p.get(0) != 51 && p.get(0) != 0) ||
 
  333             (p.get(11) != 51 && p.get(11) != 0) ||
 
  334             (p.get(23) != 51 && p.get(23) != 0))
 
  344     BOOST_REQUIRE_EQUAL(is_ok,
true);
 
  345     BOOST_REQUIRE_EQUAL(cnt,8ul);
 
  348 BOOST_AUTO_TEST_SUITE_END()
 
mem_id LinId(const grid_key_dx< N > &gk, const char sum_id[N]) const 
Linearization of the grid_key_dx with a specified shift. 
 
grid_key_dx is the key to access any element in the grid 
 
This class implement the point shape in an N-dimensional space. 
 
The same as grid_key_dx_iterator_sub_p but with periodic boundary. 
 
const size_t(& getSize() const)[N]
Return the size of the grid as an array. 
 
This class represent an N-dimensional box. 
 
This class is a trick to indicate the compiler a specific specialization pattern. ...
 
Declaration grid_key_dx_iterator_sub. 
 
It model an expression expr1 + ... exprn. 
 
void set_d(size_t i, mem_id id)
Set the i index.