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"
21 template<
unsigned int dim,
typename CellList>
void FillCellList(
size_t k,
CellList & NN)
26 for (
size_t i = 0; i < k; i++)
28 for (
size_t j = 0; j < dim; j++)
30 pos[j] = rand()/double(RAND_MAX);
36 #include "CellListFast_gen.hpp"
38 BOOST_AUTO_TEST_SUITE( celllist_gen_and_iterator_tests )
40 BOOST_AUTO_TEST_CASE( celllist_lin_and_iterator_test )
46 size_t div[dim] = {4,5,6};
55 for (
size_t i = 0; i < dim; i++)
70 for (
size_t i = 0; i < k*0.9; i++)
72 for (
size_t j = 0; j < dim; j++)
74 pos[j] = rand()/double(RAND_MAX);
84 while (it_cl.isNext())
86 auto p_key = it_cl.get();
88 BOOST_REQUIRE(p_key < NN.
get_gm());
94 BOOST_REQUIRE_EQUAL(count,NN.
get_gm());
97 BOOST_AUTO_TEST_CASE( celllist_hilb_and_iterator_test )
101 const size_t dim = 3;
103 size_t div[dim] = {4,5,6};
112 for (
size_t i = 0; i < dim; i++)
124 FillCellList<dim>((size_t)k*0.9,NN);
132 while (it_cl.isNext())
134 auto p_key = it_cl.get();
136 BOOST_REQUIRE(p_key < NN.
get_gm());
142 BOOST_REQUIRE_EQUAL(count,NN.
get_gm());
148 keys_old.load(
"NN_hilb_keys");
150 for (
size_t i = 0; i < keys_old.size(); i++)
152 size_t a1 = keys_old.get(i);
155 BOOST_REQUIRE_EQUAL(a1,a2);
158 size_t s1 = keys_old.size();
161 BOOST_REQUIRE_EQUAL(s1,s2);
164 BOOST_AUTO_TEST_CASE( ParticleItCRS_Cells_iterator )
168 const size_t dim = 3;
170 size_t div[dim] = {4,5,6};
171 size_t div_p[dim] = {6,7,8};
182 for (
size_t i = 0; i < dim; i++)
193 FillCellList<dim>(k,NN);
210 dom.add(gs.LinId(
key));
220 while (it_cl.isNext())
226 BOOST_REQUIRE_EQUAL(count,k);
236 for (
size_t i = 0; i < k; i++)
238 pos[0] = 0.999*rand()/double(RAND_MAX) + 0.0001;
239 pos[1] = 0.999*rand()/double(RAND_MAX) + 0.0001;
240 pos[2] = 0.999*rand()/double(RAND_MAX) + 0.0001;
247 bool alternate =
false;
254 auto key = it2.get();
256 if (alternate ==
false)
258 dom.add(gs.LinId(
key));
264 anom.last().subsub = gs.LinId(
key);
275 while (it_cl2.isNext())
281 BOOST_REQUIRE_EQUAL(count,k);
284 BOOST_AUTO_TEST_CASE( ParticleIt_Cells_NN_iterator )
288 const size_t dim = 3;
290 size_t div[dim] = {4,5,6};
291 size_t div_p[dim] = {6,7,8};
300 for (
size_t i = 0; i < dim; i++)
315 for (
size_t i = 0 ; i < dim ; i++)
317 spacing[i] = box.
getHigh(i) / div[i];
318 middle[i] = spacing[i]/2;
331 p.
get(0) =
key.get(0)*spacing[0] + middle[0];
332 p.
get(1) =
key.get(1)*spacing[1] + middle[1];
333 p.
get(2) =
key.get(2)*spacing[2] + middle[2];
352 bool alternate =
false;
355 auto key = it2.get();
357 if (alternate ==
false)
359 dom.add(gs.LinId(
key));
365 anom.last().subsub = gs.LinId(
key);
367 for(
size_t j = 0 ; j < openfpm::math::pow(3,dim)/2+1 ; j++)
368 {anom.last().NN_subsub.add(NN.
getNNc_sym()[j]);}
381 while (it_cl.isNext())
387 while (NN_it.isNext())
394 BOOST_REQUIRE_EQUAL(size_NN,14ul);
400 BOOST_REQUIRE_EQUAL(count,(div[0]-2)*(div[1]-2)*(div[2]-2));
403 BOOST_AUTO_TEST_CASE( ParticleIt_Cells_iterator )
407 const size_t dim = 3;
409 size_t div[dim] = {4,5,6};
410 size_t div_p[dim] = {6,7,8};
421 for (
size_t i = 0; i < dim; i++)
432 FillCellList<dim>(k,NN);
447 dom.add(gs.LinId(
key));
457 while (it_cl.isNext())
463 BOOST_REQUIRE_EQUAL(count,290ul);
466 BOOST_AUTO_TEST_SUITE_END()
void add(const T(&pos)[dim], typename base::value_type ele)
Add an element in the cell list.
grid_key_dx is the key to access any element in the grid
CellListType::SymNNIterator getNNIteratorCSR(const openfpm::vector< Point< dim, typename CellListType::stype >> &v) const
Get the neighborhood iterator according to the CRS scheme.
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.
const NNc_array< dim,(unsigned int) openfpm::math::pow(3, dim)/2+1 > & getNNc_sym() const
Get the symmetric neighborhood.
This iterator iterate across the particles of a Cell-list following the Cell structure.
void Initialize(const Box< dim, T > &box, const size_t(&div)[dim], const size_t pad=1, size_t slot=STARTING_NSLOT)
size_t getPadding(size_t i) const
Return the number of padding cells of the Cell decomposer.
const Prock< dim, CellList_gen< dim, T, Prock, Mem_type, transform, base > > & getCellSFC() const
Get the space filling curve object.
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 clear()
Clear the cell list.
Prock< dim, CellList_gen< dim, T, Prock, Mem_type, transform, base > >::Pit getIterator()
return the celllist iterator (across cells)
This iterator iterate across the particles of a Cell-list following the Cell structure.
void set_gm(size_t g_m)
Set the ghost marker.
size_t get_gm()
return the ghost marker
Class for FAST cell list implementation.