8 #ifndef OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETLIST_TEST_HPP_
9 #define OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETLIST_TEST_HPP_
11 #include "NN/VerletList/VerletList.hpp"
12 #include "NN/VerletList/VerletListM.hpp"
31 for (
size_t i = 0 ; i < dim ; i++)
33 middle.
get(i) = end.
get(i) / g_info.
size(i) / 2.0;
42 key = pmul(key,spacing) + box.
getP1() + middle;
56 template<
unsigned int dim,
typename T>
void create_particles_on_gridM(
grid_sm<dim,void> & g_info, T r_cut,
SpaceBox<dim,T> & box,
openfpm::vector<
pos_v<dim,T>> & v,
CellListM<dim,T,2> & cl)
70 for (
size_t i = 0 ; i < dim ; i++)
76 for (
size_t i = 0 ; i < dim ; i++)
77 offset[i].
get(i) += (1.0 / g_info.
size(i)) / 32.0;
79 for (
size_t i = 0 ; i < dim ; i++)
81 middle.
get(i) = end.
get(i) / g_info.
size(i) / 2.0;
85 cl.Initialize(box,div);
92 key = pmul(key,spacing) + box.
getP1() + middle;
111 template<
unsigned int dim,
typename T,
typename VerS>
void Verlet_list_s(
SpaceBox<dim,T> & box)
115 for (
size_t k = 0 ; k < 5; k++)
120 for (
size_t i = 0 ; i < dim ; i++)
126 create_particles_on_grid(ginfo,box,pos);
131 for (
size_t i = 0 ; i < dim ; i++)
137 vl1.Initialize(box,box,r_cut,pos,pos.
size());
140 for (
size_t i = 0 ; i < pos.
size() ; i++)
142 if (innerBox.
isInside(pos.get(i)) ==
false)
148 {BOOST_REQUIRE_EQUAL(vl1.getNNPart(i),19ul);}
150 auto NN = vl1.getNNIterator(i);
160 ret &= (dist < r_cut);
165 BOOST_REQUIRE_EQUAL(ret,
true);
174 for (
size_t i = 0 ; i < dim ; i++)
180 create_particles_on_grid(ginfo,box,pos);
194 for (
size_t i = 0; i < pos.
size() ; i++)
195 cli.
add(pos.get(i), i);
201 for (
size_t k = 0 ; k < 4; k++)
206 vl1.Initialize(cli,r_cut,pos,pos,pos.
size());
213 vl2.Initialize(box,box,r_cut,pos,pos.
size());
218 for (
size_t i = 0 ; i < dim ; i++)
225 for (
size_t i = 0 ; i < pos.
size() ; i++)
227 if (innerBox.
isInside(pos.get(i)) ==
false)
233 {BOOST_REQUIRE_EQUAL(vl1.getNNPart(i),19ul);}
234 BOOST_REQUIRE_EQUAL(vl1.getNNPart(i),vl2.getNNPart(i));
242 auto NN = vl1.getNNIterator(i);
249 ret &= (dist < r_cut);
258 auto NN2 = vl2.getNNIterator(i);
271 for (
size_t i = 0 ; i < v1.size(); i++)
273 ret &= v1.get(i) == v2.get(i);
276 BOOST_REQUIRE_EQUAL(ret,
true);
289 template<
unsigned int dim,
typename T,
typename VerS>
void Verlet_list_sM(
SpaceBox<dim,T> & box)
293 for (
size_t k = 0 ; k <= 0 ; k++)
298 for (
size_t i = 0 ; i < dim ; i++)
313 create_particles_on_gridM(ginfo,r_cut,box,pos2,cl);
318 for (
size_t i = 0 ; i < dim ; i++)
324 vl1.Initialize(cl,0,r_cut,pos2.get(0).pos,pos2,pos2.get(0).pos.
size());
327 for (
size_t i = 0 ; i < pos2.get(0).pos.
size() ; i++)
329 if (innerBox.
isInside(pos2.get(0).pos.get(i)) ==
false)
335 {BOOST_REQUIRE_EQUAL(vl1.getNNPart(i),57ul);}
337 auto NN = vl1.getNNIterator(i);
348 ret &= (dist < r_cut);
353 BOOST_REQUIRE_EQUAL(ret,
true);
362 for (
size_t i = 0 ; i < dim ; i++)
380 create_particles_on_gridM(ginfo,r_cut,box,pos2,cli);
388 for (
size_t k = 0 ; k <= 0 ; k++)
393 vl1.Initialize(cli,0,r_cut,pos2.get(0).pos,pos2,pos2.get(0).pos.
size());
400 vl2.Initialize(cli,0,r_cut,pos2.get(0).pos,pos2,pos2.get(0).pos.
size());
405 for (
size_t i = 0 ; i < dim ; i++)
412 for (
size_t i = 0 ; i < pos2.get(0).pos.
size() ; i++)
414 if (innerBox.
isInside(pos2.get(0).pos.get(i)) ==
false)
420 {BOOST_REQUIRE_EQUAL(vl1.getNNPart(i),57ul);}
421 BOOST_REQUIRE_EQUAL(vl1.getNNPart(i),vl2.getNNPart(i));
429 auto NN = vl1.getNNIterator(i);
437 ret &= (dist < r_cut);
446 auto NN2 = vl2.getNNIterator(i);
459 for (
size_t i = 0 ; i < v1.size(); i++)
461 ret &= v1.get(i) == v2.get(i);
464 BOOST_REQUIRE_EQUAL(ret,
true);
472 BOOST_AUTO_TEST_SUITE( VerletList_test )
474 BOOST_AUTO_TEST_CASE( VerletList_use)
476 std::cout <<
"Test verlet list" <<
"\n";
482 Verlet_list_sM<3,double,VerletListM<3,double,2>>(box);
485 std::cout <<
"End verlet list" <<
"\n";
490 BOOST_AUTO_TEST_SUITE_END()
void add(const T(&pos)[dim], typename base::value_type ele)
Add an element in the cell list.
This class represent an N-dimensional box.
T getLow(int i) const
get the i-coordinate of the low bound interval of the box
bool isInside(const Point< dim, T > &p) const
Check if the point is inside the box.
size_t size() const
Return the size of the grid.
void Initialize(CellDecomposer_sm< dim, T, transform > &cd_sm, const Box< dim, T > &dom_box, const size_t pad=1, size_t slot=STARTING_NSLOT)
T getHigh(int i) const
get the high interval of the box
void setHigh(int i, T val)
set the high interval of the box
This class implement the point shape in an N-dimensional space.
Structure that contain a reference to a vector of particles.
Point< dim, T > getP1() const
Get the point p1.
Class for Multi-Phase cell-list.
const T & get(size_t i) const
Get coordinate.
void setLow(int i, T val)
set the low interval of the box
This class represent an N-dimensional box.
This class is a trick to indicate the compiler a specific specialization pattern. ...
void add(const T(&pos)[dim], size_t ele, size_t v_id)
Add an element in the cell list.
T distance(const Point< dim, T > &q)
It calculate the distance between 2 points.
Implementation of 1-D std::vector like structure.
Class for FAST cell list implementation.
Point< dim, T > getP2() const
Get the point p2.