8 #ifndef SRC_VECTOR_VECTOR_DIST_NN_TESTS_HPP_
9 #define SRC_VECTOR_VECTOR_DIST_NN_TESTS_HPP_
12 BOOST_AUTO_TEST_CASE( vector_dist_full_NN )
22 std::default_random_engine eg;
23 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
25 #ifdef TEST_COVERAGE_MODE
31 long int big_step = k / 4;
32 big_step = (big_step == 0)?1:big_step;
34 print_test(
"Testing 3D full NN search k=",k);
35 BOOST_TEST_CHECKPOINT(
"Testing 3D full NN search k=" << k );
40 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
42 for (
double r_cut = 0.1 ; r_cut < 1.0; r_cut += 0.1)
52 auto it = vd.getIterator();
58 vd.getPos(
key)[0] = ud(eg);
59 vd.getPos(
key)[1] = ud(eg);
60 vd.getPos(
key)[2] = ud(eg);
64 vd.getProp<0>(
key) = 0.0;
77 list_idx.resize(vd.size_local());
78 list_idx2.resize(vd.size_local());
80 for (
size_t i = 0 ; i < vd.size_local() ; i++)
84 for (
size_t j = 0 ; j < vd.size_local_with_ghost(); j++)
89 list_idx.get(i).add(j);
92 list_idx.get(i).sort();
95 auto NN = vd.getCellList(r_cut);
97 it = vd.getDomainIterator();
102 auto Np = NN.getNNIterator<NO_CHECK>(NN.getCell(xp));
111 list_idx2.get(it.get().getKey()).add(q);
116 list_idx2.get(it.get().getKey()).sort();
121 BOOST_REQUIRE_EQUAL(list_idx.
size(),list_idx2.
size());
124 for (
size_t i = 0 ; i < list_idx.
size() ; i++)
126 BOOST_REQUIRE_EQUAL(list_idx.get(i).
size(),list_idx2.get(i).
size());
129 for (
size_t j = 0 ; j < list_idx.get(i).
size() ; j++)
130 ret &= list_idx.get(i).get(j) == list_idx2.get(i).get(j);
132 BOOST_REQUIRE_EQUAL(ret,
true);
137 auto NNv = vd.getVerlet(r_cut*1.0001);
139 it = vd.getDomainIterator();
144 auto Np = NNv.getNNIterator<NO_CHECK>(it.get().getKey());
146 list_idx2.get(it.get().getKey()).clear();
155 list_idx2.get(it.get().getKey()).add(q);
160 list_idx2.get(it.get().getKey()).sort();
165 BOOST_REQUIRE_EQUAL(list_idx.
size(),list_idx2.
size());
167 for (
size_t i = 0 ; i < list_idx.
size() ; i++)
169 BOOST_REQUIRE_EQUAL(list_idx.get(i).
size(),list_idx2.get(i).
size());
172 for (
size_t j = 0 ; j < list_idx.get(i).
size() ; j++)
173 ret &= list_idx.get(i).get(j) == list_idx2.get(i).get(j);
175 BOOST_REQUIRE_EQUAL(ret,
true);
181 vd.updateVerlet(NNv,r_cut*1.0001);
183 it = vd.getDomainIterator();
188 auto Np = NNv.getNNIterator<NO_CHECK>(it.get().getKey());
190 list_idx2.get(it.get().getKey()).clear();
199 list_idx2.get(it.get().getKey()).add(q);
204 list_idx2.get(it.get().getKey()).sort();
209 BOOST_REQUIRE_EQUAL(list_idx.
size(),list_idx2.
size());
211 for (
size_t i = 0 ; i < list_idx.
size() ; i++)
213 BOOST_REQUIRE_EQUAL(list_idx.get(i).
size(),list_idx2.get(i).
size());
216 for (
size_t j = 0 ; j < list_idx.get(i).
size() ; j++)
217 ret &= list_idx.get(i).get(j) == list_idx2.get(i).get(j);
219 BOOST_REQUIRE_EQUAL(ret,
true);
224 BOOST_AUTO_TEST_CASE( vector_dist_particle_iteration )
226 Vcluster & v_cl = create_vcluster();
234 std::default_random_engine eg;
235 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
239 print_test(
"Testing 3D particle cell iterator=",k);
240 BOOST_TEST_CHECKPOINT(
"Testing 3D full NN search k=" << k );
245 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
257 auto it = vd.getIterator();
263 vd.getPos(
key)[0] = ud(eg);
264 vd.getPos(
key)[1] = ud(eg);
265 vd.getPos(
key)[2] = ud(eg);
269 vd.getProp<0>(
key) = 0.0;
280 ids.resize(vd.size_local());
282 auto NN = vd.getCellListSym(r_cut);
284 auto it_pcell = vd.getDomainIteratorCells(NN);
287 while (it_pcell.isNext())
291 size_t id = it_pcell.get();
294 BOOST_REQUIRE(
id < vd.size_local());
302 BOOST_REQUIRE_EQUAL((
long int)count,k);
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(int 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.