8 #ifndef VECTOR_DIST_UNIT_TEST_HPP_
9 #define VECTOR_DIST_UNIT_TEST_HPP_
14 #include "Vector/vector_dist.hpp"
15 #include "data_type/aggregate.hpp"
16 #include "Vector/performance/vector_dist_performance_common.hpp"
27 auto it2 = vd.getDomainIterator();
44 BOOST_REQUIRE_EQUAL(noOut,
true);
65 template<
unsigned int dim,
typename vector_dist>
inline void count_local_n_local(
vector_dist & vd,
vector_dist_iterator & it,
size_t (& bc)[dim] ,
Box<dim,float> & box,
Box<dim,float> & dom_ext,
size_t & l_cnt,
size_t & nl_cnt,
size_t & n_out)
96 BOOST_AUTO_TEST_SUITE( vector_dist_test )
98 void print_test(std::
string test,
size_t sz)
100 if (create_vcluster().getProcessUnitID() == 0)
101 std::cout << test <<
" " << sz <<
"\n";
107 Vcluster & v_cl = create_vcluster();
118 size_t g_div[]= {sz,sz};
141 spacing = spacing / g_div;
150 size_t bc[2]={NON_PERIODIC,NON_PERIODIC};
161 while (v_it.isNext() && it.
isNext())
164 auto key_v = v_it.get();
168 vd.
getPos(key_v)[0] =
key.get(0) * spacing[0] + m_spacing[0] + box.
getLow(0);
169 vd.
getPos(key_v)[1] =
key.get(1) * spacing[1] + m_spacing[1] + box.
getLow(1);
181 BOOST_REQUIRE_EQUAL(v_it.isNext(),
false);
182 BOOST_REQUIRE_EQUAL(it.
isNext(),
false);
183 BOOST_REQUIRE_EQUAL(cobj,p_np);
192 while (v_it2.isNext())
194 auto key = v_it2.get();
222 while (g_it.isNext())
224 auto key = g_it.get();
234 for ( ; b < dec.getNEGhostBox() ; b++)
238 if (dec.getEGhostBox(b).isInside(xp) == true )
247 BOOST_REQUIRE_EQUAL(is_in,
true);
250 BOOST_REQUIRE_EQUAL(vd.
getProp<p::v>(
key)[0],dec.getEGhostBoxProcessor(lb));
258 BOOST_REQUIRE(n_part != 0);
263 for (
size_t i = 0 ; i < vb.size() ; i++)
266 size_t n_point = cd.getGridPoints(dec.getEGhostBox(i)).getVolumeKey();
268 BOOST_REQUIRE_EQUAL(n_point,vb.get(i));
272 BOOST_AUTO_TEST_CASE( vector_dist_ghost )
281 void print_test_v(std::string test,
size_t sz)
283 if (create_vcluster().getProcessUnitID() == 0)
284 std::cout << test <<
" " << sz <<
"\n";
287 long int decrement(
long int k,
long int step)
293 else if (k - 2*step+1 <= 0)
301 BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use_2d )
303 Vcluster & v_cl = create_vcluster();
308 std::default_random_engine eg;
309 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
311 #ifdef TEST_COVERAGE_MODE
317 long int big_step = k / 4;
318 big_step = (big_step == 0)?1:big_step;
320 print_test_v(
"Testing 2D vector k<=",k);
323 for ( ; k >= 2 ; k-= decrement(k,big_step) )
325 BOOST_TEST_CHECKPOINT(
"Testing 2D vector k=" << k );
332 size_t bc[2]={NON_PERIODIC,NON_PERIODIC};
359 auto key = it2.get();
372 BOOST_REQUIRE_EQUAL((
long int)cnt,k);
376 BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use_3d )
378 Vcluster & v_cl = create_vcluster();
383 std::default_random_engine eg;
384 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
386 #ifdef TEST_COVERAGE_MODE
392 long int big_step = k / 4;
393 big_step = (big_step == 0)?1:big_step;
395 print_test_v(
"Testing 3D vector k<=",k);
398 for ( ; k >= 2 ; k-= decrement(k,big_step) )
400 BOOST_TEST_CHECKPOINT(
"Testing 3D vector k=" << k );
407 size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
435 auto key = it2.get();
448 BOOST_REQUIRE_EQUAL(cnt,(
size_t)k);
453 BOOST_AUTO_TEST_CASE( vector_dist_iterator_fixed_dec_3d )
455 Vcluster & v_cl = create_vcluster();
460 std::default_random_engine eg;
461 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
463 #ifdef TEST_COVERAGE_MODE
469 long int big_step = k / 4;
470 big_step = (big_step == 0)?1:big_step;
472 print_test_v(
"Testing 3D vector copy decomposition k<=",k);
475 for ( ; k >= 2 ; k-= decrement(k,big_step) )
477 BOOST_TEST_CHECKPOINT(
"Testing 3D vector copy decomposition k=" << k );
482 size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
511 auto NN2 = vd2.getCellList(0.05);
513 cross_calc<3,0>(NN,NN2,vd,vd2);
514 cross_calc<3,1>(NN,NN,vd,vd);
517 auto it3 = vd.getIterator();
521 auto key = it3.get();
523 BOOST_REQUIRE_EQUAL(vd.getProp<0>(
key),vd.getProp<1>(
key));
530 BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_use_2d )
532 Vcluster & v_cl = create_vcluster();
537 std::default_random_engine eg;
538 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
540 #ifdef TEST_COVERAGE_MODE
546 long int big_step = k / 4;
547 big_step = (big_step == 0)?1:big_step;
549 print_test_v(
"Testing 2D periodic vector k<=",k);
552 for ( ; k >= 2 ; k-= decrement(k,big_step) )
554 BOOST_TEST_CHECKPOINT(
"Testing 2D periodic vector k=" << k );
559 size_t bc[2]={PERIODIC,PERIODIC};
562 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
580 vd.getPos(
key)[1] = ud(eg);
600 auto it2 = vd.getIterator();
601 count_local_n_local<2,vector_dist<2,float, Point_test<float> >>(vd,it2,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
604 BOOST_REQUIRE_EQUAL(n_out,0ul);
609 BOOST_REQUIRE(nl_cnt != 0);
610 BOOST_REQUIRE(l_cnt > nl_cnt);
618 BOOST_REQUIRE_EQUAL((
long int)l_cnt,k);
624 auto itg = vd.getGhostIterator();
625 count_local_n_local<2,vector_dist<2,float, Point_test<float> > >(vd,itg,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
628 BOOST_REQUIRE_EQUAL(l_cnt,0ul);
633 BOOST_REQUIRE(nl_cnt != 0);
638 BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_use_3d )
640 Vcluster & v_cl = create_vcluster();
645 std::default_random_engine eg;
646 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
648 #ifdef TEST_COVERAGE_MODE
654 long int big_step = k / 4;
655 big_step = (big_step == 0)?1:big_step;
657 print_test_v(
"Testing 3D periodic vector k<=",k);
660 for ( ; k >= 2 ; k-= decrement(k,big_step) )
662 BOOST_TEST_CHECKPOINT(
"Testing 3D periodic vector k=" << k );
667 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
670 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
688 vd.getPos(
key)[1] = ud(eg);
689 vd.getPos(
key)[2] = ud(eg);
708 auto it2 = vd.getIterator();
709 count_local_n_local<3,vector_dist<3,float, Point_test<float> >>(vd,it2,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
712 BOOST_REQUIRE_EQUAL(n_out,0ul);
717 BOOST_REQUIRE(nl_cnt != 0);
718 BOOST_REQUIRE(l_cnt > nl_cnt);
724 BOOST_REQUIRE_EQUAL(l_cnt,(
size_t)k);
730 auto itg = vd.getGhostIterator();
731 count_local_n_local<3,vector_dist<3,float, Point_test<float> > >(vd,itg,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
734 BOOST_REQUIRE_EQUAL(l_cnt,0ul);
739 BOOST_REQUIRE(nl_cnt != 0);
744 BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_random_walk )
746 Vcluster & v_cl = create_vcluster();
751 std::default_random_engine eg;
752 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
754 size_t nsz[] = {0,32,4};
757 print_test_v(
"Testing 3D random walk vector k<=",nsz[0]);
760 for (
size_t i = 0 ; i < 3 ; i++ )
764 BOOST_TEST_CHECKPOINT(
"Testing 3D random walk vector k=" << k );
769 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
772 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
787 vd.getPos(
key)[1] = ud(eg);
788 vd.getPos(
key)[2] = ud(eg);
797 for (
size_t j = 0 ; j < 4 ; j++)
806 vd.getPos(
key)[1] += 0.02 * ud(eg);
807 vd.getPos(
key)[2] += 0.02 * ud(eg);
817 size_t cnt = total_n_part_lc(vd,bc);
819 BOOST_REQUIRE_EQUAL((
size_t)k,cnt);
824 BOOST_AUTO_TEST_CASE( vector_dist_periodic_map )
829 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
832 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
849 vd.getPos(
key)[1] = 1.0;
850 vd.getPos(
key)[2] = 1.0;
857 auto it2 = vd.getIterator();
861 auto key = it2.get();
863 float f = vd.getPos(
key)[0];
864 BOOST_REQUIRE_EQUAL(f, 0.0);
865 f = vd.getPos(
key)[1];
866 BOOST_REQUIRE_EQUAL(f, 0.0);
867 f = vd.getPos(
key)[2];
868 BOOST_REQUIRE_EQUAL(f, 0.0);
875 BOOST_AUTO_TEST_CASE( vector_dist_not_periodic_map )
880 size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
883 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
900 vd.getPos(
key)[1] = 1.0;
901 vd.getPos(
key)[2] = 1.0;
908 auto it2 = vd.getIterator();
912 auto key = it2.get();
914 float f = vd.getPos(
key)[0];
915 BOOST_REQUIRE_EQUAL(f, 1.0);
916 f = vd.getPos(
key)[1];
917 BOOST_REQUIRE_EQUAL(f, 1.0);
918 f = vd.getPos(
key)[2];
919 BOOST_REQUIRE_EQUAL(f, 1.0);
925 BOOST_AUTO_TEST_CASE( vector_dist_out_of_bound_policy )
927 Vcluster & v_cl = create_vcluster();
935 size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
938 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
959 vd.getPos(
key)[1] = -0.06;
960 vd.getPos(
key)[2] = -0.06;
964 vd.getPos(
key)[0] = 0.06;
965 vd.getPos(
key)[1] = 0.06;
966 vd.getPos(
key)[2] = 0.06;
977 size_t cnt_l = vd.size_local();
987 Vcluster & v_cl = create_vcluster();
995 std::default_random_engine eg;
996 std::uniform_real_distribution<float> ud(-0.5f, 0.5f);
998 size_t nsz[] = {0,32,4};
1000 #ifdef TEST_COVERAGE_MODE
1006 print_test_v(
"Testing 3D random walk interacting particles vector k=", nsz[0]);
1009 for (
size_t i = 0 ; i < 3 ; i++ )
1013 BOOST_TEST_CHECKPOINT(
"Testing 3D random walk interacting particles vector k=" << k );
1016 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
1019 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1022 float r_cut = 0.01 / factor;
1034 auto key = it.get();
1037 vd.getPos(
key)[1] = ud(eg);
1038 vd.getPos(
key)[2] = ud(eg);
1047 for (
size_t j = 0 ; j < 4 ; j++)
1055 auto key = it.get();
1058 vd.getPos(
key)[1] += 0.02 * ud(eg);
1059 vd.getPos(
key)[2] += 0.02 * ud(eg);
1066 vd.write(
"Without_ghost");
1070 vd.write(
"With_ghost");
1071 vd.getDecomposition().write(
"With_dec_ghost");
1077 auto NN = vd.getCellList(0.01 / factor);
1081 auto it2 = vd.getDomainIterator();
1083 while (it2.isNext())
1089 auto Np = NN.getCellIterator(NN.getCell(xp));
1100 float distance = f.
norm();
1104 if (distance > 2*r_cut*sqrt(2))
1115 BOOST_REQUIRE_EQUAL(error,
false);
1118 size_t cnt = total_n_part_lc(vd,bc);
1120 BOOST_REQUIRE_EQUAL((
size_t)k,cnt);
1125 BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_interacting_particles )
1128 Test_interacting(box);
1131 Test_interacting(box2);
1134 BOOST_AUTO_TEST_CASE( vector_dist_grid_iterator )
1136 #ifdef TEST_COVERAGE_MODE
1137 long int k = 32*32*32*create_vcluster().getProcessingUnits();
1139 long int k = 64*64*64*create_vcluster().getProcessingUnits();
1141 k = std::pow(k, 1/3.);
1143 long int big_step = k / 30;
1144 big_step = (big_step == 0)?1:big_step;
1145 long int small_step = 21;
1147 print_test(
"Testing vector grid iterator list k<=",k);
1150 for ( ; k > 8*big_step ; k-= (k > 2*big_step)?big_step:small_step )
1152 Vcluster & v_cl = create_vcluster();
1154 const size_t Ng = k;
1157 size_t sz[3] = {Ng,Ng,Ng};
1162 size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
1177 auto key = it.get();
1186 BOOST_REQUIRE_EQUAL(it.getSpacing(0),1.0f/(Ng-1));
1187 BOOST_REQUIRE_EQUAL(it.getSpacing(1),1.0f/(Ng-1));
1188 BOOST_REQUIRE_EQUAL(it.getSpacing(2),1.0f/(Ng-1));
1195 size_t total = vd.size_local();
1199 BOOST_REQUIRE_EQUAL(total,(Ng) * (Ng) * (Ng));
1203 BOOST_AUTO_TEST_CASE( vector_dist_cell_verlet_test )
1205 #ifdef TEST_COVERAGE_MODE
1206 long int k = 16*16*16*create_vcluster().getProcessingUnits();
1208 long int k = 64*64*64*create_vcluster().getProcessingUnits();
1210 k = std::pow(k, 1/3.);
1212 long int big_step = k / 30;
1213 big_step = (big_step == 0)?1:big_step;
1214 long int small_step = 21;
1216 print_test(
"Testing cell and verlet list k<=",k);
1219 for ( ; k > 8*big_step ; k-= (k > 2*big_step)?big_step:small_step )
1221 Vcluster & v_cl = create_vcluster();
1223 const size_t Ng = k;
1226 size_t sz[3] = {Ng,Ng,Ng};
1231 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
1233 float spacing = 1.0/Ng;
1234 float first_dist = spacing;
1235 float second_dist = sqrt(2.0*spacing*spacing);
1236 float third_dist = sqrt(3.0 * spacing*spacing);
1251 auto key = it.get();
1260 BOOST_REQUIRE_EQUAL(it.getSpacing(0),1.0f/Ng);
1261 BOOST_REQUIRE_EQUAL(it.getSpacing(1),1.0f/Ng);
1262 BOOST_REQUIRE_EQUAL(it.getSpacing(2),1.0f/Ng);
1268 size_t total = vd.size_local();
1272 BOOST_REQUIRE_EQUAL(total,(Ng) * (Ng) * (Ng));
1281 first_dist += first_dist * 0.05;
1282 second_dist += second_dist * 0.05;
1283 third_dist += third_dist * 0.05;
1289 bool correct =
true;
1291 BOOST_REQUIRE_EQUAL(vd.size_local(),verlet.size());
1294 for (
size_t i = 0 ; i < verlet.size() ; i++)
1297 size_t first_NN = 0;
1298 size_t second_NN = 0;
1299 size_t third_NN = 0;
1304 for (
size_t j = 0 ; j < verlet.getNNPart(i) ; j++)
1310 if (dist <= first_dist)
1312 else if (dist <= second_dist)
1318 correct &= (first_NN == 7);
1319 correct &= (second_NN == 12);
1320 correct &= (third_NN == 8);
1323 BOOST_REQUIRE_EQUAL(correct,
true);
1328 BOOST_AUTO_TEST_CASE( vector_dist_periodic_map_list )
1330 Vcluster & v_cl = create_vcluster();
1338 std::default_random_engine eg;
1339 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
1341 #ifdef TEST_COVERAGE_MODE
1347 long int big_step = k / 4;
1348 big_step = (big_step == 0)?1:big_step;
1350 print_test(
"Testing 3D periodic vector with map_list k=",k);
1351 BOOST_TEST_CHECKPOINT(
"Testing 3D periodic vector with map_list k=" << k );
1356 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
1359 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1376 auto key = it.get();
1379 vd.getPos(
key)[1] = ud(eg);
1380 vd.getPos(
key)[2] = ud(eg);
1384 vd.getProp<2>(
key).push_back(1);
1385 vd.getProp<2>(
key).push_back(2);
1386 vd.getProp<2>(
key).push_back(3);
1387 vd.getProp<2>(
key).push_back(4);
1389 vd.getProp<3>(
key).add(1);
1390 vd.getProp<3>(
key).add(2);
1391 vd.getProp<3>(
key).add(3);
1392 vd.getProp<3>(
key).add(4);
1394 vd.getProp<4>(
key).add();
1395 vd.getProp<4>(
key).add();
1396 vd.getProp<4>(
key).add();
1397 vd.getProp<4>(
key).add();
1416 auto it2 = vd.getIterator();
1417 count_local_n_local<3,vector_dist<3,float, part_prop>>(vd,it2,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
1420 BOOST_REQUIRE_EQUAL(n_out,0ul);
1425 BOOST_REQUIRE(nl_cnt != 0);
1426 BOOST_REQUIRE(l_cnt > nl_cnt);
1432 BOOST_REQUIRE_EQUAL(l_cnt,(
size_t)k);
1438 auto itg = vd.getGhostIterator();
1439 count_local_n_local<3, vector_dist<3,float,part_prop> >(vd,itg,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
1442 BOOST_REQUIRE_EQUAL(l_cnt,0ul);
1447 BOOST_REQUIRE(nl_cnt != 0);
1452 BOOST_AUTO_TEST_CASE( vector_dist_ghost_with_ghost_buffering )
1454 Vcluster & v_cl = create_vcluster();
1462 std::default_random_engine eg;
1463 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
1465 #ifdef TEST_COVERAGE_MODE
1471 long int big_step = k / 4;
1472 big_step = (big_step == 0)?1:big_step;
1474 print_test(
"Testing 3D periodic vector with ghost buffering k=",k);
1475 BOOST_TEST_CHECKPOINT(
"Testing 3D periodic with ghost buffering k=" << k );
1480 size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
1494 auto key = it.get();
1497 vd.getPos(
key)[1] = ud(eg);
1498 vd.getPos(
key)[2] = ud(eg);
1502 vd.getProp<0>(
key) = 0.0;
1503 vd.getProp<1>(
key) = vd.getPos(
key)[0];
1504 vd.getProp<2>(
key) = vd.getPos(
key)[0]*vd.getPos(
key)[0];
1512 vd.ghost_get<0,1,2>();
1515 auto it2 = vd.getGhostIterator();
1516 while (it2.isNext())
1518 auto key = it2.get();
1520 ret &= vd.getProp<1>(
key) == vd.getPos(
key)[0];
1521 ret &= vd.getProp<2>(
key) == vd.getPos(
key)[0] * vd.getPos(
key)[0];
1526 BOOST_REQUIRE_EQUAL(ret,
true);
1528 for (
size_t i = 0 ; i < 10 ; i++)
1534 auto key = it.get();
1537 vd.getPos(
key)[2] = ud(eg);
1541 vd.getProp<0>(
key) = i;
1549 vd.ghost_get<0>(SKIP_LABELLING | NO_CHANGE_ELEMENTS );
1551 auto it2 = vd.getGhostIterator();
1554 while (it2.isNext())
1556 auto key = it2.get();
1558 ret &= vd.getProp<0>(
key) == i;
1559 ret &= vd.getProp<1>(
key) == vd.getPos(
key)[0];
1560 ret &= vd.getProp<2>(
key) == vd.getPos(
key)[0] * vd.getPos(
key)[0];
1565 BOOST_REQUIRE_EQUAL(ret,
true);
1569 vd.ghost_get<0,1,2>();
1583 vd.getPos(p)[1] = 17.0;
1589 for (
size_t i = 0 ; i < 10 ; i++)
1595 auto key = it.get();
1598 vd.getPos(
key)[2] = ud(eg);
1602 vd.getProp<0>(
key) = i;
1603 vd.getProp<1>(
key) = vd.getPos(
key)[0];
1604 vd.getProp<2>(
key) = vd.getPos(
key)[0]*vd.getPos(
key)[0];
1609 vd.
ghost_get<0>(SKIP_LABELLING | NO_POSITION);
1611 auto it2 = vd.getGhostIterator();
1614 while (it2.isNext())
1619 ret &= vd.
getPos(p)[0] == 10.0;
1622 ret &= vd.getPos(p)[1] == 17.0;
1628 BOOST_REQUIRE_EQUAL(ret,
true);
1634 BOOST_AUTO_TEST_CASE( vector_dist_ghost_put )
1636 Vcluster & v_cl = create_vcluster();
1638 long int k = 25*25*25*create_vcluster().getProcessingUnits();
1639 k = std::pow(k, 1/3.);
1644 print_test(
"Testing 3D periodic ghost put k=",k);
1645 BOOST_TEST_CHECKPOINT(
"Testing 3D periodic ghost put k=" << k );
1647 long int big_step = k / 30;
1648 big_step = (big_step == 0)?1:big_step;
1649 long int small_step = 21;
1652 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1654 float r_cut = 1.3 / k;
1655 float r_g = 1.5 / k;
1660 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
1674 auto key = it.get();
1678 vd.getLastPosWrite()[0] =
key.get(0)*it.getSpacing(0);
1695 auto NN = vd.getCellList(r_cut);
1700 auto it2 = vd.getDomainIterator();
1702 while (it2.isNext())
1709 auto Np = NN.getNNIterator<NO_CHECK>(NN.getCell(xp));
1720 vd.getPropWrite<0>(q) += a*(-dist*dist+r_cut*r_cut);
1728 vd.ghost_put<
add_,0>();
1731 auto it3 = vd.getDomainIterator();
1733 float constant = vd.getProp<0>(it3.get());
1736 while (it3.isNext())
1738 float constant2 = vd.getProp<0>(it3.get());
1739 if (fabs(constant - constant2)/constant > eps)
1750 BOOST_REQUIRE_EQUAL(ret,
true);
1753 auto itp = vd.getDomainAndGhostIterator();
1754 while (itp.isNext())
1756 auto key = itp.get();
1758 vd.getPropWrite<0>(
key) = 0.0;
1764 auto NN = vd.getCellList(r_cut);
1769 auto it2 = vd.getDomainIterator();
1771 while (it2.isNext())
1778 auto Np = NN.getNNIterator<NO_CHECK>(NN.getCell(xp));
1789 vd.getPropWrite<0>(q) += a*(-dist*dist+r_cut*r_cut);
1797 vd.ghost_put<
add_,0>();
1800 auto it3 = vd.getDomainIterator();
1802 float constant = vd.getPropRead<0>(it3.get());
1805 while (it3.isNext())
1807 float constant2 = vd.getPropRead<0>(it3.get());
1808 if (fabs(constant - constant2)/constant > eps)
1819 BOOST_REQUIRE_EQUAL(ret,
true);
1824 BOOST_AUTO_TEST_CASE( vector_of_vector_dist )
1826 Vcluster & v_cl = create_vcluster();
1832 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
1850 phases.get(0).map();
1851 phases.get(0).ghost_get<>();
1852 phases.get(1).map();
1853 phases.get(1).ghost_get<>();
1854 phases.get(2).map();
1855 phases.get(2).ghost_get<>();
1856 phases.get(3).map();
1857 phases.get(3).ghost_get<>();
1861 for (
size_t i = 0 ; i < phases.
size() ; i++)
1862 cnt += phases.get(i).size_local();
1867 BOOST_REQUIRE_EQUAL(cnt,4*4096ul);
1871 #include "vector_dist_cell_list_tests.hpp"
1872 #include "vector_dist_NN_tests.hpp"
1873 #include "vector_dist_complex_prp_unit_test.hpp"
1875 BOOST_AUTO_TEST_SUITE_END()
void sum(T &num)
Sum the numbers across all processors and get the result.
This class represent an N-dimensional box.
bool isInsideNP(const Point< dim, T > &p) const
Check if the point is inside the region excluding the positive part.
T getLow(int i) const
get the i-coordinate of the low bound interval of the box
void map_list()
It move all the particles that does not belong to the local processor to the respective processor...
size_t getProcessUnitID()
Get the process unit id.
static size_t getDefaultGrid(size_t n_sub)
The default grid size.
auto getPos(vect_dist_key_dx vec_key) -> decltype(v_pos.template get< 0 >(vec_key.getKey()))
Get the position of an element.
void execute()
Execute all the requests.
bool isInside(const Point< dim, T > &p) const
Check if the point is inside the box.
std::string toString() const
Return the string with the point coordinate.
auto getLastPos() -> decltype(v_pos.template get< 0 >(0))
Get the position of the last element.
Iterator that Iterate across particle indexes.
This structure define the operation add to use with copy general.
This class implement the point shape in an N-dimensional space.
auto getLastPropWrite() -> decltype(v_prp.template get< id >(0))
Get the property of the last element.
vector_dist_iterator getIterator()
Get an iterator that traverse domain and ghost particles.
bool isLocalBC(const encapc< 1, Point< dim, T >, Mem > p, const size_t(&bc)[dim]) const
Check if the particle is local considering boundary conditions.
Point< dim, T > getP1() const
Get the point p1.
CellL getCellList(St r_cut, bool no_se3=false)
Construct a cell list starting from the stored particles.
bool isLocal(const encapc< 1, Point< dim, T >, Mem > p) const
Check if the particle is local.
Implementation of VCluster class.
vector_dist_iterator getDomainIterator() const
Get an iterator that traverse the particles in the domain.
bool isNext()
Check if there is the next element.
auto getProp(vect_dist_key_dx vec_key) -> decltype(v_prp.template get< id >(vec_key.getKey()))
Get the property of an element.
This class decompose a space into sub-sub-domains and distribute them across processors.
vector_dist_iterator getGhostIterator() const
Get the iterator across the position of the ghost particles.
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
const T & get(int i) const
Get coordinate.
void add()
Add local particle.
void map()
It move all the particles that does not belong to the local processor to the respective processor...
This class represent an N-dimensional box.
T norm()
norm of the vector
This class is a trick to indicate the compiler a specific specialization pattern. ...
auto getLastPosWrite() -> decltype(v_pos.template get< 0 >(0))
Get the position of the last element.
vect_dist_key_dx get()
Get the actual key.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
T distance(const Point< dim, T > &q)
It calculate the distance between 2 points.
Test structure used for several test.
size_t getProcessingUnits()
Get the total number of processors.
Point< dim, T > getP2() const
Get the point p2.
Decomposition & getDecomposition()
Get the decomposition.
void ghost_get(size_t opt=WITH_POSITION)
It synchronize the properties and position of the ghost particles.
grid_dist_id_iterator_dec< Decomposition > getGridIterator(const size_t(&sz)[dim])