8 #ifndef OPENFPM_DATA_SRC_NN_CELLLIST_CELLDECOMPOSER_UNIT_TESTS_HPP_ 
    9 #define OPENFPM_DATA_SRC_NN_CELLLIST_CELLDECOMPOSER_UNIT_TESTS_HPP_ 
   11 BOOST_AUTO_TEST_SUITE( CellDecomposer_test )
 
   13 BOOST_AUTO_TEST_CASE( CellDecomposer_get_grid_points )
 
   17     CellDecomposer_sm<3,float> cd;
 
   23     size_t div[] = {10,10,10};
 
   29     cd.setDimensions(box,div,padding);
 
   36     BOOST_REQUIRE_EQUAL(gp.
getLow(0),2+padding);
 
   37     BOOST_REQUIRE_EQUAL(gp.
getLow(1),3+padding);
 
   38     BOOST_REQUIRE_EQUAL(gp.
getLow(2),4+padding);
 
   40     BOOST_REQUIRE_EQUAL(gp.
getHigh(0),5+padding-1);
 
   41     BOOST_REQUIRE_EQUAL(gp.
getHigh(1),5+padding-1);
 
   42     BOOST_REQUIRE_EQUAL(gp.
getHigh(2),6+padding-1);
 
   47     BOOST_REQUIRE_EQUAL(vol,12ul);
 
   56     CellDecomposer_sm<2,float> cd;
 
   68     cd.setDimensions(box,div,padding);
 
   75     BOOST_REQUIRE_EQUAL(gp.
getLow(0),2+padding);
 
   76     BOOST_REQUIRE_EQUAL(gp.
getLow(1),2+padding);
 
   78     BOOST_REQUIRE_EQUAL(gp.
getHigh(0),3+padding);
 
   79     BOOST_REQUIRE_EQUAL(gp.
getHigh(1),3+padding);
 
   84     BOOST_REQUIRE_EQUAL(vol,4ul);
 
   89 BOOST_AUTO_TEST_CASE( CellDecomposer_use )
 
   95     double pp[3] = {0.5,0.5,0.5};
 
   98     size_t div[3] = {16,16,16};
 
  108     CellDecomposer_sm<3,double> cd(box,div,0);
 
  109     size_t cell = cd.getCell(p);
 
  110     BOOST_REQUIRE_EQUAL(cell,(
size_t)(8*16*16 + 8*16 + 8));
 
  111     auto key = cd.getCellGrid(p);
 
  112     BOOST_REQUIRE_EQUAL(
key.get(0),8);
 
  113     BOOST_REQUIRE_EQUAL(
key.get(1),8);
 
  114     BOOST_REQUIRE_EQUAL(
key.get(2),8);
 
  116     cell = cd.getCell(pp);
 
  117     BOOST_REQUIRE_EQUAL(cell,(
size_t)(8*16*16 + 8*16 + 8));
 
  118     key = cd.getCellGrid(pp);
 
  119     BOOST_REQUIRE_EQUAL(
key.get(0),8);
 
  120     BOOST_REQUIRE_EQUAL(
key.get(1),8);
 
  121     BOOST_REQUIRE_EQUAL(
key.get(2),8);
 
  128     CellDecomposer_sm<3,double> cd(box,div,1);
 
  129     size_t cell = cd.getCell(p);
 
  130     BOOST_REQUIRE_EQUAL(cell,(
size_t)(9*18*18 + 9*18 + 9));
 
  131     auto key = cd.getCellGrid(p);
 
  132     BOOST_REQUIRE_EQUAL(
key.get(0),9);
 
  133     BOOST_REQUIRE_EQUAL(
key.get(1),9);
 
  134     BOOST_REQUIRE_EQUAL(
key.get(2),9);
 
  136     cell = cd.getCell(pp);
 
  137     BOOST_REQUIRE_EQUAL(cell,(
size_t)(9*18*18 + 9*18 + 9));
 
  138     key = cd.getCellGrid(pp);
 
  139     BOOST_REQUIRE_EQUAL(
key.get(0),9);
 
  140     BOOST_REQUIRE_EQUAL(
key.get(1),9);
 
  141     BOOST_REQUIRE_EQUAL(
key.get(2),9);
 
  151     double psht[3] = {1.5,2.5,3.5};
 
  153     CellDecomposer_sm< 3,double,shift<3,double> > cd(box2,div,1);
 
  154     size_t cell = cd.getCell(p + sht);
 
  155     BOOST_REQUIRE_EQUAL(cell,(
size_t)(9*18*18 + 9*18 + 9));
 
  156     auto key = cd.getCellGrid(p + sht);
 
  157     BOOST_REQUIRE_EQUAL(
key.get(0),9);
 
  158     BOOST_REQUIRE_EQUAL(
key.get(1),9);
 
  159     BOOST_REQUIRE_EQUAL(
key.get(2),9);
 
  161     cell = cd.getCell(psht);
 
  162     BOOST_REQUIRE_EQUAL(cell,(
size_t)(9*18*18 + 9*18 + 9));
 
  163     key = cd.getCellGrid(psht);
 
  164     BOOST_REQUIRE_EQUAL(
key.get(0),9);
 
  165     BOOST_REQUIRE_EQUAL(
key.get(1),9);
 
  166     BOOST_REQUIRE_EQUAL(
key.get(2),9);
 
  173     CellDecomposer_sm<3,double> cd(box,div,1);
 
  174     size_t cell_cor_dom = cd.getCellDom(
Point<3,double>({-0.000001,-0.000001,-0.000001}));
 
  175     size_t cell_cor_pad = cd.getCellPad(
Point<3,double>({0.000001,0.000001,0.000001}));
 
  176     size_t cell_not_cor_pad1 = cd.getCell(
Point<3,double>({-0.000001,-0.000001,-0.000001}));
 
  177     size_t cell_not_cor_pad2 = cd.getCell(
Point<3,double>({0.000001,0.000001,0.000001}));
 
  178     BOOST_REQUIRE_EQUAL(cell_cor_pad,0ul);
 
  179     BOOST_REQUIRE_EQUAL(cell_cor_dom,(
size_t)(1*18*18 + 1*18 + 1));
 
  180     BOOST_REQUIRE_EQUAL(cell_not_cor_pad1,0ul);
 
  181     BOOST_REQUIRE_EQUAL(cell_not_cor_pad2,(
size_t)(1*18*18 + 1*18 + 1));
 
  185 #define N_POINTS 1000 
  187 BOOST_AUTO_TEST_CASE( CellDecomposer_consistent_use )
 
  195     size_t div[3] = {16,16,16};
 
  196     std::default_random_engine g;
 
  197     std::uniform_real_distribution<double> d(0.0,1.0);
 
  204     CellDecomposer_sm< 3,double,shift<3,double> > cd(box2,div,1);
 
  210     CellDecomposer_sm< 3,double,shift<3,double> > cd2(cd,ext);
 
  215     size_t div_ext[3] = {6+16,6+16,6+16};
 
  224     for (
size_t i = 0 ; i < N_POINTS ; i++)
 
  238         BOOST_REQUIRE(key == key_res);
 
  246     BOOST_REQUIRE(key == key_res);
 
  250     key = cd.getCellGrid(p);
 
  251     key2 = cd2.getCellGrid(p);
 
  253     key_res = key2 - key_base;
 
  255     BOOST_REQUIRE(key == key_res);
 
  262 BOOST_AUTO_TEST_CASE( CellDecomposer_swap_use )
 
  266     size_t div[3] = {16,16,16};
 
  270     CellDecomposer_sm< 3,double,shift<3,double> > cd1(box,div,1);
 
  276     size_t div2[3] = {15,15,15};
 
  280     CellDecomposer_sm< 3,double,shift<3,double> > cd2(box2,div2,2);
 
  287     BOOST_REQUIRE(cd2 == cd1_old);
 
  288     BOOST_REQUIRE(cd1 == cd2_old);
 
  291 BOOST_AUTO_TEST_SUITE_END()
 
This class represent an N-dimensional box. 
 
T getLow(int i) const 
get the i-coordinate of the low bound interval of the box 
 
grid_key_dx is the key to access any element in the grid 
 
T getHigh(int i) const 
get the high interval of the box 
 
This class implement the point shape in an N-dimensional space. 
 
const T & get(size_t i) const 
Get coordinate. 
 
This class is a trick to indicate the compiler a specific specialization pattern. ...
 
T getVolumeKey() const 
Get the volume spanned by the Box P1 and P2 interpreted as grid key.