8#define BOOST_TEST_DYN_LINK
9#include <boost/test/unit_test.hpp>
11#include "Vector/vector_dist_multiphase_functions.hpp"
12#include "VCluster/VCluster.hpp"
13#include "Vector/vector_dist.hpp"
15BOOST_AUTO_TEST_SUITE( vector_dist_multiphase_test )
17BOOST_AUTO_TEST_CASE( vector_dist_multiphase_cell_list_test )
19 if (create_vcluster().getProcessingUnits() > 24)
22 size_t sz[3] = {60,60,40};
25 Box<3,float> box({-1000.0,-1000.0,-1000.0},{2000.0,2000.0,1000.0});
28 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
30 int rank_test = create_vcluster().rank();
48 auto g_it = phases.get(0).getGridIterator(sz);
52 auto key = g_it.get();
60 phases.get(0).getLastPos()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
61 phases.get(0).getLastPos()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
62 phases.get(0).getLastPos()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
64 phases.get(1).getLastPos()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
65 phases.get(1).getLastPos()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
66 phases.get(1).getLastPos()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
68 phases.get(2).getLastPos()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
69 phases.get(2).getLastPos()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
70 phases.get(2).getLastPos()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
72 phases.get(3).getLastPos()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
73 phases.get(3).getLastPos()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
74 phases.get(3).getLastPos()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
80 for (
size_t i = 0 ; i < 4 ; i++)
87 for (
size_t p = 0 ; p < phases.
size() ; p++)
91 for (
size_t j = 0 ; j < phases.get(p).size_local() ; j++)
93 vt.add(phases.get(p).getPos((j + p*133) % phases.get(p).size_local()));
95 phases.get(p).getPosVector().swap(vt);
99 for (
size_t i = 0 ; i < 4 ; i++)
101 phases.get(i).ghost_get<>();
105 auto CL_phase0 = phases.get(0).getCellList(r_cut);
106 auto CL_phase1 = phases.get(1).getCellList(r_cut);
109 auto NN_ver01 = createVerlet(phases.get(0),phases.get(1),CL_phase1,r_cut);
114 auto it = phases.get(0).getDomainIterator();
119 auto Np = NN_ver01.getNNIterator<NO_CHECK>(p.getKey());
132 ret &= nn_count == 7ul;
137 BOOST_REQUIRE_EQUAL(ret,
true);
140 for (
size_t i = 0 ; i < 4 ; i++)
143 phases.get(i).ghost_get<>();
149 auto CL_all = createCellListM<2>(phases,r_cut);
152 auto NNver0_all = createVerletM<2>(0,phases.get(0),phases,CL_all,r_cut);
154 it = phases.get(0).getDomainIterator();
159 auto Np = NNver0_all.getNNIterator<NO_CHECK>(p.getKey());
161 size_t nn_cout[4] = {0,0,0,0};
167 auto ph_q = Np.getV();
174 ret &= nn_cout[0] == 7;
175 ret &= nn_cout[1] == 7;
176 ret &= nn_cout[2] == 7;
177 ret &= nn_cout[3] == 7;
182 BOOST_REQUIRE_EQUAL(ret,
true);
186BOOST_AUTO_TEST_CASE( vector_dist_multiphase_cell_list_sym_test )
188 if (create_vcluster().getProcessingUnits() > 24)
191 size_t sz[3] = {60,60,40};
194 Box<3,float> box({-1000.0,-1000.0,-1000.0},{2000.0,2000.0,1000.0});
197 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
216 auto g_it = phases.get(0).getGridIterator(sz);
218 while (g_it.isNext())
220 auto key = g_it.get();
228 phases.get(0).getLastPosWrite()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
229 phases.get(0).getLastPosWrite()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
230 phases.get(0).getLastPosWrite()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
232 phases.get(1).getLastPosWrite()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
233 phases.get(1).getLastPosWrite()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
234 phases.get(1).getLastPosWrite()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
236 phases.get(2).getLastPosWrite()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
237 phases.get(2).getLastPosWrite()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
238 phases.get(2).getLastPosWrite()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
240 phases.get(3).getLastPosWrite()[0] = key.get(0) * g_it.getSpacing(0) + box.getLow(0);
241 phases.get(3).getLastPosWrite()[1] = key.get(1) * g_it.getSpacing(1) + box.getLow(1);
242 phases.get(3).getLastPosWrite()[2] = key.get(2) * g_it.getSpacing(2) + box.getLow(2);
248 for (
size_t i = 0 ; i < 4 ; i++)
255 for (
size_t p = 0 ; p < phases.
size() ; p++)
259 for (
size_t j = 0 ; j < phases.get(p).size_local() ; j++)
261 vt.add(phases.get(p).getPos((j + p*133) % phases.get(p).size_local()));
263 phases.get(p).getPosVector().swap(vt);
267 for (
size_t i = 0 ; i < 4 ; i++)
269 phases.get(i).ghost_get<>();
273 auto CL_phase0 = phases.get(0).getCellListSym(r_cut);
274 auto CL_phase1 = phases.get(1).getCellListSym(r_cut);
277 auto NN_ver01 = createVerletSym(phases.get(0),phases.get(1),CL_phase1,r_cut);
282 auto it = phases.get(0).getDomainIterator();
287 auto Np = NN_ver01.getNNIterator<NO_CHECK>(p.getKey());
295 phases.get(0).getPropWrite<0>(p)++;
296 phases.get(1).getPropWrite<0>(q)++;
304 phases.get(0).ghost_put<
add_,0>();
305 phases.get(1).ghost_put<
add_,0>();
309 phases.get(1).getDomainIterator();
313 it = phases.get(0).getDomainIterator();
318 ret &= phases.get(0).getPropRead<0>(p) == 7;
319 ret &= phases.get(1).getPropRead<0>(p) == 7;
324 BOOST_REQUIRE_EQUAL(ret,
true);
327 for (
size_t i = 0 ; i < 4 ; i++)
330 phases.get(i).ghost_get<>();
335 for (
size_t i = 0 ; i < phases.
size() ; i++)
337 it = phases.get(i).getDomainAndGhostIterator();
342 phases.get(i).getPropWrite<0>(p) = 0;
351 auto CL_all = createCellListSymM<2>(phases,r_cut);
353 typedef decltype(createVerletSymM<2>(0,phases.get(0),phases,CL_all,r_cut)) verlet_type;
355 verlet_type NNver_all[4];
358 NNver_all[0] = createVerletSymM<2>(0,phases.get(0),phases,CL_all,r_cut);
359 NNver_all[1] = createVerletSymM<2>(1,phases.get(1),phases,CL_all,r_cut);
360 NNver_all[2] = createVerletSymM<2>(2,phases.get(2),phases,CL_all,r_cut);
361 NNver_all[3] = createVerletSymM<2>(3,phases.get(3),phases,CL_all,r_cut);
365 for (
size_t i = 0 ; i < phases.
size() ; i++)
367 it = phases.get(i).getDomainIterator();
372 auto Np = NNver_all[i].getNNIterator<NO_CHECK>(p.getKey());
381 auto ph_q = Np.getV();
383 phases.get(i).getPropWrite<0>(p)++;
384 phases.get(ph_q).getPropWrite<0>(q)++;
393 phases.get(0).ghost_put<
add_,0>();
394 phases.get(1).ghost_put<
add_,0>();
395 phases.get(2).ghost_put<
add_,0>();
396 phases.get(3).ghost_put<
add_,0>();
400 it = phases.get(1).getDomainIterator();
401 it = phases.get(2).getDomainIterator();
402 it = phases.get(3).getDomainIterator();
406 it = phases.get(0).getDomainIterator();
411 ret &= phases.get(0).getPropRead<0>(p) == 32;
412 ret &= phases.get(1).getPropRead<0>(p) == 32;
413 ret &= phases.get(2).getPropRead<0>(p) == 32;
414 ret &= phases.get(3).getPropRead<0>(p) == 32;
418 std::cout << phases.get(0).getPropRead<0>(p) << std::endl;
419 std::cout << phases.get(1).getPropRead<0>(p) << std::endl;
420 std::cout << phases.get(2).getPropRead<0>(p) << std::endl;
421 std::cout << phases.get(3).getPropRead<0>(p) << std::endl;
427 BOOST_REQUIRE_EQUAL(ret,
true);
430BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
Implementation of 1-D std::vector like structure.
This structure define the operation add to use with copy general.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...