8#ifndef OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTITERATOR_TEST_HPP_
9#define OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTITERATOR_TEST_HPP_
11#include "NN/CellList/CellListIterator.hpp"
12#include "NN/CellList/ParticleIt_Cells.hpp"
13#include "NN/CellList/ParticleItCRS_Cells.hpp"
16#include "VCluster/VCluster.hpp"
26template<
unsigned int dim,
typename CellList>
void FillCellList(
size_t k,
CellList & NN)
31 for (
size_t i = 0; i < k; i++)
33 for (
size_t j = 0; j < dim; j++)
35 pos[j] = rand()/double(RAND_MAX);
41#include "CellListFast_gen.hpp"
43BOOST_AUTO_TEST_SUITE( celllist_gen_and_iterator_tests )
45BOOST_AUTO_TEST_CASE( celllist_lin_and_iterator_test )
51 size_t div[dim] = {4,5,6};
60 for (
size_t i = 0; i < dim; i++)
75 for (
size_t i = 0; i < k*0.9; i++)
77 for (
size_t j = 0; j < dim; j++)
79 pos[j] = rand()/double(RAND_MAX);
89 while (it_cl.isNext())
91 auto p_key = it_cl.get();
93 BOOST_REQUIRE(p_key < NN.
get_gm());
99 BOOST_REQUIRE_EQUAL(count,NN.
get_gm());
102BOOST_AUTO_TEST_CASE( celllist_hilb_and_iterator_test )
106 auto & v_cl = create_vcluster();
108 std::string c2 = std::string(
"openfpm_data/test_data/NN_hilb_keys");
112 std::string c2 = std::string(
"test_data/NN_hilb_keys");
118 const size_t dim = 3;
120 size_t div[dim] = {4,5,6};
129 for (
size_t i = 0; i < dim; i++)
141 FillCellList<dim>((
size_t)k*0.9,NN);
149 while (it_cl.isNext())
151 auto p_key = it_cl.get();
153 BOOST_REQUIRE(p_key < NN.
get_gm());
159 BOOST_REQUIRE_EQUAL(count,NN.
get_gm());
167 for (
size_t i = 0; i < keys_old.
size(); i++)
169 size_t a1 = keys_old.get(i);
172 BOOST_REQUIRE_EQUAL(a1,a2);
175 size_t s1 = keys_old.
size();
178 BOOST_REQUIRE_EQUAL(s1,s2);
181BOOST_AUTO_TEST_CASE( ParticleItCRS_Cells_iterator )
185 const size_t dim = 3;
187 size_t div[dim] = {4,5,6};
188 size_t div_p[dim] = {6,7,8};
199 for (
size_t i = 0; i < dim; i++)
210 FillCellList<dim>(k,NN);
227 dom.add(gs.LinId(key));
235 ParticleItCRS_Cells<dim,CellList<dim,float,Mem_fast<>,
shift<dim,float>,
vector_type>,
vector_type> it_cl(NN,dom,anom,NN.
getNNc_sym());
239 while (it_cl.isNext())
245 BOOST_REQUIRE_EQUAL(count,k);
255 for (
size_t i = 0; i < k; i++)
257 pos[0] = 0.999*rand()/double(RAND_MAX) + 0.0001;
258 pos[1] = 0.999*rand()/double(RAND_MAX) + 0.0001;
259 pos[2] = 0.999*rand()/double(RAND_MAX) + 0.0001;
266 bool alternate =
false;
273 auto key = it2.get();
275 if (alternate ==
false)
277 dom.add(gs.LinId(key));
283 anom.last().subsub = gs.LinId(key);
292 ParticleItCRS_Cells<dim,CellList<dim,float,Mem_fast<>,
shift<dim,float>,
vector_type>,
vector_type> it_cl2(NN,dom,anom,NN.
getNNc_sym());
296 while (it_cl2.isNext())
302 BOOST_REQUIRE_EQUAL(count,k);
305BOOST_AUTO_TEST_CASE( ParticleIt_Cells_NN_iterator )
309 const size_t dim = 3;
311 size_t div[dim] = {4,5,6};
312 size_t div_p[dim] = {6,7,8};
321 for (
size_t i = 0; i < dim; i++)
336 for (
size_t i = 0 ; i < dim ; i++)
338 spacing[i] = box.
getHigh(i) / div[i];
339 middle[i] = spacing[i]/2;
352 p.
get(0) = key.get(0)*spacing[0] + middle[0];
353 p.
get(1) = key.get(1)*spacing[1] + middle[1];
354 p.
get(2) = key.get(2)*spacing[2] + middle[2];
373 bool alternate =
false;
376 auto key = it2.get();
378 if (alternate ==
false)
380 dom.add(gs.LinId(key));
386 anom.last().subsub = gs.LinId(key);
388 for(
size_t j = 0 ; j < openfpm::math::pow(3,dim)/2+1 ; j++)
389 {anom.last().NN_subsub.add(NN.
getNNc_sym()[j]);}
400 ParticleItCRS_Cells<dim,CellList<dim,float,Mem_fast<>,
shift<dim,float>,
vector_type>,
vector_type> it_cl(NN,dom,anom,NN.
getNNc_sym());
404 while (it_cl.isNext())
406 auto NN_it = it_cl.getNNIteratorCSR(vp);
410 while (NN_it.isNext())
417 BOOST_REQUIRE_EQUAL(size_NN,14ul);
423 BOOST_REQUIRE_EQUAL(count,(div[0]-2)*(div[1]-2)*(div[2]-2));
426BOOST_AUTO_TEST_CASE( ParticleIt_Cells_iterator )
430 const size_t dim = 3;
432 size_t div[dim] = {4,5,6};
433 size_t div_p[dim] = {6,7,8};
444 for (
size_t i = 0; i < dim; i++)
455 FillCellList<dim>(k,NN);
470 dom.add(gs.LinId(key));
480 while (it_cl.isNext())
482 auto i = it_cl.get();
488 BOOST_REQUIRE_EQUAL(count,290ul);
491BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
__device__ __host__ T getHigh(int i) const
get the high interval of the box
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
void Initialize(const Box< dim, T > &box, const size_t(&div)[dim], const size_t pad=1, size_t slot=STARTING_NSLOT)
void set_gm(size_t g_m)
Set the ghost marker.
size_t get_gm()
return the ghost marker
Prock< dim, CellList_gen< dim, T, Prock, Mem_type, transform, vector_pos_type > >::Pit getIterator()
return the celllist iterator (across cells)
const Prock< dim, CellList_gen< dim, T, Prock, Mem_type, transform, vector_pos_type > > & getCellSFC() const
Get the space filling curve object.
Class for FAST cell list implementation.
const NNc_array< dim,(unsigned int) openfpm::math::pow(3, dim)/2+1 > & getNNc_sym() const
Get the symmetric neighborhood.
void add(const T(&pos)[dim], typename Mem_type::local_index_type ele)
Add an element in the cell list.
void clear()
Clear the cell list.
size_t getPadding(size_t i) const
Return the number of padding cells of the Cell decomposer.
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 iterator iterate across the particles of a Cell-list following the Cell structure.
This iterator iterate across the particles of a Cell-list following the Cell structure.
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Declaration grid_key_dx_iterator_sub.
grid_key_dx is the key to access any element in the grid
Implementation of 1-D std::vector like structure.