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;
56template<
unsigned int dim,
typename T>
void create_particles_on_gridM(
grid_sm<dim,void> & g_info,
74 for (
size_t i = 0 ; i < dim ; i++)
80 for (
size_t i = 0 ; i < dim ; i++)
81 offset[i].get(i) += (1.0 / g_info.
size(i)) / 32.0;
83 for (
size_t i = 0 ; i < dim ; i++)
85 middle.
get(i) = end.
get(i) / g_info.
size(i) / 2.0;
89 cl.Initialize(box,div);
96 key = pmul(key,spacing) + box.
getP1() + middle;
115template<
unsigned int dim,
typename T,
typename VerS>
void Verlet_list_s(
SpaceBox<dim,T> & box)
119 for (
size_t k = 0 ; k < 5; k++)
124 for (
size_t i = 0 ; i < dim ; i++)
130 create_particles_on_grid(ginfo,box,pos);
135 for (
size_t i = 0 ; i < dim ; i++)
141 vl1.Initialize(box,box,r_cut,pos,pos.
size());
144 for (
size_t i = 0 ; i < pos.
size() ; i++)
146 if (innerBox.
isInside(pos.get(i)) ==
false)
152 {BOOST_REQUIRE_EQUAL(vl1.getNNPart(i),19ul);}
154 auto NN = vl1.getNNIterator(i);
164 ret &= (dist < r_cut);
169 BOOST_REQUIRE_EQUAL(ret,
true);
178 for (
size_t i = 0 ; i < dim ; i++)
184 create_particles_on_grid(ginfo,box,pos);
198 for (
size_t i = 0; i < pos.
size() ; i++)
199 cli.
add(pos.get(i), i);
205 for (
size_t k = 0 ; k < 4; k++)
210 vl1.Initialize(cli,r_cut,pos,pos,pos.
size());
217 vl2.Initialize(box,box,r_cut,pos,pos.
size());
222 for (
size_t i = 0 ; i < dim ; i++)
229 for (
size_t i = 0 ; i < pos.
size() ; i++)
231 if (innerBox.
isInside(pos.get(i)) ==
false)
237 {BOOST_REQUIRE_EQUAL(vl1.getNNPart(i),19ul);}
238 BOOST_REQUIRE_EQUAL(vl1.getNNPart(i),vl2.getNNPart(i));
246 auto NN = vl1.getNNIterator(i);
253 ret &= (dist < r_cut);
262 auto NN2 = vl2.getNNIterator(i);
275 for (
size_t i = 0 ; i < v1.
size(); i++)
277 ret &= v1.get(i) == v2.get(i);
280 BOOST_REQUIRE_EQUAL(ret,
true);
293template<
unsigned int dim,
typename T,
typename VerS>
void Verlet_list_sM(
SpaceBox<dim,T> & box)
297 for (
size_t k = 0 ; k <= 0 ; k++)
302 for (
size_t i = 0 ; i < dim ; i++)
317 create_particles_on_gridM(ginfo,r_cut,box,pos2,cl);
322 for (
size_t i = 0 ; i < dim ; i++)
328 vl1.Initialize(cl,0,r_cut,pos2.get(0).pos,pos2,pos2.get(0).pos.
size());
331 for (
size_t i = 0 ; i < pos2.get(0).pos.
size() ; i++)
333 if (innerBox.
isInside(pos2.get(0).pos.get(i)) ==
false)
339 {BOOST_REQUIRE_EQUAL(vl1.getNNPart(i),57ul);}
341 auto NN = vl1.getNNIterator(i);
352 ret &= (dist < r_cut);
357 BOOST_REQUIRE_EQUAL(ret,
true);
366 for (
size_t i = 0 ; i < dim ; i++)
384 create_particles_on_gridM(ginfo,r_cut,box,pos2,cli);
392 for (
size_t k = 0 ; k <= 0 ; k++)
397 vl1.Initialize(cli,0,r_cut,pos2.get(0).pos,pos2,pos2.get(0).pos.
size());
404 vl2.Initialize(cli,0,r_cut,pos2.get(0).pos,pos2,pos2.get(0).pos.
size());
409 for (
size_t i = 0 ; i < dim ; i++)
416 for (
size_t i = 0 ; i < pos2.get(0).pos.
size() ; i++)
418 if (innerBox.
isInside(pos2.get(0).pos.get(i)) ==
false)
424 {BOOST_REQUIRE_EQUAL(vl1.getNNPart(i),57ul);}
425 BOOST_REQUIRE_EQUAL(vl1.getNNPart(i),vl2.getNNPart(i));
433 auto NN = vl1.getNNIterator(i);
441 ret &= (dist < r_cut);
450 auto NN2 = vl2.getNNIterator(i);
463 for (
size_t i = 0 ; i < v1.
size(); i++)
465 ret &= v1.get(i) == v2.get(i);
468 BOOST_REQUIRE_EQUAL(ret,
true);
476BOOST_AUTO_TEST_SUITE( VerletList_test )
478BOOST_AUTO_TEST_CASE( VerletList_use)
480 std::cout <<
"Test verlet list" <<
"\n";
486 Verlet_list_sM<3,double,VerletListM<3,double,2>>(box);
489 std::cout <<
"End verlet list" <<
"\n";
494BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
Point< dim, T > getP2() const
Get the point p2.
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
__device__ __host__ T getHigh(int i) const
get the high interval of the box
__host__ __device__ bool isInside(const Point< dim, T > &p) const
Check if the point is inside the box.
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
Point< dim, T > getP1() const
Get the point p1.
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
Class for Multi-Phase cell-list.
void add(const T(&pos)[dim], size_t ele, size_t v_id)
Add an element in the cell list.
Class for FAST cell list implementation.
void add(const T(&pos)[dim], typename Mem_type::local_index_type ele)
Add an element in the cell list.
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)
This class implement the point shape in an N-dimensional space.
__device__ __host__ T distance(const Point< dim, T > &q) const
It calculate the distance between 2 points.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
This class represent an N-dimensional box.
__device__ __host__ size_t size() const
Return the size of the grid.
Implementation of 1-D std::vector like structure.
Structure that contain a reference to a vector of particles.