8 #define BOOST_TEST_DYN_LINK 
    9 #include <boost/test/unit_test.hpp> 
   11 #include "VCluster/VCluster.hpp" 
   12 #include "Vector/vector_dist.hpp" 
   14 extern void print_test_v(std::string test, 
size_t sz);
 
   16 template<
typename VerletList>
 
   17 void test_full_nn(
long int k)
 
   27     std::default_random_engine eg;
 
   28     std::uniform_real_distribution<float> ud(0.0f, 1.0f);
 
   30     long int big_step = k / 4;
 
   31     big_step = (big_step == 0)?1:big_step;
 
   33     print_test_v(
"Testing 3D full NN search k=",k);
 
   34     BOOST_TEST_CHECKPOINT( 
"Testing 3D full NN search k=" << k );
 
   39     size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
 
   41     for (
double r_cut = 0.1 ; r_cut < 1.0; r_cut += 0.1)
 
   51         auto it = vd.getIterator();
 
   57             vd.getPos(
key)[0] = ud(eg);
 
   58             vd.getPos(
key)[1] = ud(eg);
 
   59             vd.getPos(
key)[2] = ud(eg);
 
   63             vd.getProp<0>(
key) = 0.0;
 
   76         list_idx.resize(vd.size_local());
 
   77         list_idx2.resize(vd.size_local());
 
   79         for (
size_t i = 0 ; i < vd.size_local() ; i++)
 
   83             for (
size_t j = 0 ; j < vd.size_local_with_ghost(); j++)
 
   88                     list_idx.get(i).add(j);
 
   91             list_idx.get(i).sort();
 
   94         auto NN = vd.getCellList(r_cut);
 
   96         it = vd.getDomainIterator();
 
  101             auto Np = NN.getNNIterator<NO_CHECK>(NN.getCell(xp));
 
  110                     list_idx2.get(it.get().getKey()).add(q);
 
  115             list_idx2.get(it.get().getKey()).sort();
 
  120         BOOST_REQUIRE_EQUAL(list_idx.
size(),list_idx2.
size());
 
  123         for (
size_t i = 0 ; i < list_idx.
size() ; i++)
 
  125             BOOST_REQUIRE_EQUAL(list_idx.get(i).
size(),list_idx2.get(i).
size());
 
  128             for (
size_t j = 0 ; j < list_idx.get(i).
size() ; j++)
 
  129                 ret &= list_idx.get(i).get(j) == list_idx2.get(i).get(j);
 
  131             BOOST_REQUIRE_EQUAL(ret,
true);
 
  136         auto NNv = vd.template getVerlet<VerletList>(r_cut*1.0001);
 
  138         it = vd.getDomainIterator();
 
  143             auto Np = NNv.template getNNIterator<NO_CHECK>(it.get().getKey());
 
  145             list_idx2.get(it.get().getKey()).clear();
 
  154                     list_idx2.get(it.get().getKey()).add(q);
 
  159             list_idx2.get(it.get().getKey()).sort();
 
  164         BOOST_REQUIRE_EQUAL(list_idx.
size(),list_idx2.
size());
 
  166         for (
size_t i = 0 ; i < list_idx.
size() ; i++)
 
  168             BOOST_REQUIRE_EQUAL(list_idx.get(i).
size(),list_idx2.get(i).
size());
 
  171             for (
size_t j = 0 ; j < list_idx.get(i).
size() ; j++)
 
  172                 ret &= list_idx.get(i).get(j) == list_idx2.get(i).get(j);
 
  174             BOOST_REQUIRE_EQUAL(ret,
true);
 
  180         vd.updateVerlet(NNv,r_cut*1.0001);
 
  182         it = vd.getDomainIterator();
 
  187             auto Np = NNv.template getNNIterator<NO_CHECK>(it.get().getKey());
 
  189             list_idx2.get(it.get().getKey()).clear();
 
  198                     list_idx2.get(it.get().getKey()).add(q);
 
  203             list_idx2.get(it.get().getKey()).sort();
 
  208         BOOST_REQUIRE_EQUAL(list_idx.
size(),list_idx2.
size());
 
  210         for (
size_t i = 0 ; i < list_idx.
size() ; i++)
 
  212             BOOST_REQUIRE_EQUAL(list_idx.get(i).
size(),list_idx2.get(i).
size());
 
  215             for (
size_t j = 0 ; j < list_idx.get(i).
size() ; j++)
 
  216                 ret &= list_idx.get(i).get(j) == list_idx2.get(i).get(j);
 
  218             BOOST_REQUIRE_EQUAL(ret,
true);
 
  223 BOOST_AUTO_TEST_CASE( vector_dist_full_NN )
 
  225     auto & v_cl = create_vcluster();
 
  227 #ifdef TEST_COVERAGE_MODE 
  233     test_full_nn<VERLET_MEMFAST(3,float)>(k);
 
  236     test_full_nn<VERLET_MEMBAL(3,float)>(k);
 
  238     test_full_nn<VERLET_MEMMW(3,float)>(k);
 
  241 BOOST_AUTO_TEST_CASE( vector_dist_particle_iteration )
 
  243     Vcluster & v_cl = create_vcluster();
 
  251     std::default_random_engine eg;
 
  252     std::uniform_real_distribution<float> ud(0.0f, 1.0f);
 
  256     print_test_v(
"Testing 3D particle cell iterator=",k);
 
  257     BOOST_TEST_CHECKPOINT( 
"Testing 3D full NN search k=" << k );
 
  262     size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
 
  274         auto it = vd.getIterator();
 
  280             vd.getPos(
key)[0] = ud(eg);
 
  281             vd.getPos(
key)[1] = ud(eg);
 
  282             vd.getPos(
key)[2] = ud(eg);
 
  286             vd.getProp<0>(
key) = 0.0;
 
  297     ids.resize(vd.size_local());
 
  299     auto NN = vd.getCellListSym(r_cut);
 
  301     auto it_pcell = vd.getDomainIteratorCells(NN);
 
  304     while (it_pcell.isNext())
 
  308         size_t id = it_pcell.get();
 
  311         BOOST_REQUIRE(
id < vd.size_local());
 
  319     BOOST_REQUIRE_EQUAL((
long int)count,k);
 
  322 BOOST_AUTO_TEST_CASE( vector_dist_particle_NN_update_with_limit )
 
  324     Vcluster & v_cl = create_vcluster();
 
  332     std::default_random_engine eg;
 
  333     std::uniform_real_distribution<float> ud(0.0f, 1.0f);
 
  337     print_test_v(
"Testing 3D particle cell-list with radius at limit= ",k);
 
  338     BOOST_TEST_CHECKPOINT( 
"Testing 3D particle cell-list with radius at limit= " << k );
 
  343     size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
 
  355     auto it = vd.getIterator();
 
  361         vd.getPos(
key)[0] = ud(eg);
 
  362         vd.getPos(
key)[1] = ud(eg);
 
  363         vd.getPos(
key)[2] = ud(eg);
 
  367         vd.getProp<0>(
key) = 0.0;
 
  377     auto NN = vd.getCellListSym(r_cut);
 
  379     auto cell1 = NN.getCellBox();
 
  381     vd.getDecomposition().decompose();
 
  384     vd.updateCellListSym(NN);
 
  386     auto cell2 = NN.getCellBox();
 
  388     BOOST_REQUIRE_EQUAL(cell1.getHigh(0),cell2.getHigh(0));
 
  389     BOOST_REQUIRE_EQUAL(cell1.getHigh(1),cell2.getHigh(1));
 
  390     BOOST_REQUIRE_EQUAL(cell1.getHigh(2),cell2.getHigh(2));
 
  393 BOOST_AUTO_TEST_CASE( vector_dist_particle_getCellListSym_with_div )
 
  395     Vcluster & v_cl = create_vcluster();
 
  403     std::default_random_engine eg;
 
  404     std::uniform_real_distribution<float> ud(0.0f, 1.0f);
 
  408     print_test_v(
"Testing 3D particle getCellListSym with div =",k);
 
  409     BOOST_TEST_CHECKPOINT( 
"Testing 3D particle getCellListSym with div = " << k );
 
  414     size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
 
  426     auto it = vd.getIterator();
 
  432         vd.getPos(
key)[0] = ud(eg);
 
  433         vd.getPos(
key)[1] = ud(eg);
 
  434         vd.getPos(
key)[2] = ud(eg);
 
  438         vd.getProp<0>(
key) = 0.0;
 
  448     auto NN1 = vd.getCellListSym(r_cut);
 
  450     size_t div_wp[3] = {NN1.getDivWP()[0],NN1.getDivWP()[1],NN1.getDivWP()[2]};
 
  451     size_t pad[3] = {NN1.getPadding()[0],NN1.getPadding()[1],NN1.getPadding()[2]};
 
  453     auto NN2 = vd.getCellListSym(div_wp,pad);
 
  458     size_t div[3] = {NN1.getInternalGrid().getSize()[0],
 
  459                      NN1.getInternalGrid().getSize()[1],
 
  460                      NN1.getInternalGrid().getSize()[2]};
 
  469     while (g_it.isNext())
 
  471         size_t cell = g_info.LinId(g_it.get());
 
  472         size_t n_ele1 = NN1.getNelements(cell);
 
  473         size_t n_ele2 = NN2.getNelements(cell);
 
  475         match &= n_ele1 == n_ele2;
 
  480     BOOST_REQUIRE_EQUAL(match,
true);
 
void sum(T &num)
Sum the numbers across all processors and get the result. 
 
size_t getProcessUnitID()
Get the process unit id. 
 
void execute()
Execute all the requests. 
 
This class implement the point shape in an N-dimensional space. 
 
Implementation of VCluster class. 
 
const T & get(size_t i) const 
Get coordinate. 
 
This class is a trick to indicate the compiler a specific specialization pattern. ...
 
T distance2(const Point< dim, T > &q)
It calculate the square distance between 2 points. 
 
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
 
Implementation of 1-D std::vector like structure. 
 
size_t getProcessingUnits()
Get the total number of processors.