8#define BOOST_TEST_DYN_LINK
9#include <boost/test/unit_test.hpp>
14#include "Vector/vector_dist.hpp"
15#include "data_type/aggregate.hpp"
16#include "vector_dist_util_unit_tests.hpp"
17#include "Point_test.hpp"
18#include "Vector/performance/vector_dist_performance_common.hpp"
26void print_test_v(std::string test,
size_t sz)
28 if (create_vcluster().getProcessUnitID() == 0)
29 std::cout << test <<
" " << sz <<
"\n";
40long int decrement(
long int k,
long int step)
46 else if (k - 2*step+1 <= 0)
60template<
unsigned int dim,
template <
typename>
class layout>
64 auto it2 = vd.getDomainIterator();
74 noOut &= ct.
isLocal(vd.getPos(key));
81 BOOST_REQUIRE_EQUAL(noOut,
true);
91BOOST_AUTO_TEST_SUITE( vector_dist_test )
93void print_test(std::string test,
size_t sz)
95 if (create_vcluster().getProcessUnitID() == 0)
96 std::cout << test <<
" " << sz <<
"\n";
99template<
typename vector>
114 size_t g_div[]= {sz,sz};
137 spacing = spacing / g_div;
146 size_t bc[2]={NON_PERIODIC,NON_PERIODIC};
149 vector vd(g_info.size(),box,bc,g);
155 auto v_it = vd.getIterator();
157 while (v_it.isNext() && it.isNext())
160 auto key_v = v_it.get();
164 vd.getPos(key_v)[0] = key.get(0) * spacing[0] + m_spacing[0] + box.
getLow(0);
165 vd.getPos(key_v)[1] = key.get(1) * spacing[1] + m_spacing[1] + box.
getLow(1);
177 BOOST_REQUIRE_EQUAL(v_it.isNext(),
false);
178 BOOST_REQUIRE_EQUAL(it.isNext(),
false);
179 BOOST_REQUIRE_EQUAL(cobj,p_np);
186 auto v_it2 = vd.getIterator();
188 while (v_it2.isNext())
190 auto key = v_it2.get();
193 vd.template getProp<p::s>(key) = vd.getPos(key)[0] + vd.getPos(key)[1] * 16.0f;
202 vd.template ghost_get<p::s,p::v>();
207 const auto & dec = vd.getDecomposition();
213 auto g_it = vd.getGhostIterator();
218 while (g_it.isNext())
220 auto key = g_it.get();
223 float prp = vd.template getProp<p::s>(key);
224 float prp2 = vd.getPos(key)[0] + vd.getPos(key)[1] * 16.0f;
225 BOOST_REQUIRE_EQUAL(prp2,prp);
232 for ( ; b < dec.getNEGhostBox() ; b++)
236 if (dec.getEGhostBox(b).isInside(xp) ==
true )
245 BOOST_REQUIRE_EQUAL(is_in,
true);
248 BOOST_REQUIRE_EQUAL(vd.template getProp<p::v>(key)[0],dec.getEGhostBoxProcessor(lb));
256 BOOST_REQUIRE(n_part != 0);
261 for (
size_t i = 0 ; i < vb.size() ; i++)
264 size_t n_point = cd.getGridPoints(dec.getEGhostBox(i)).getVolumeKey();
266 BOOST_REQUIRE_EQUAL(n_point,vb.get(i));
270BOOST_AUTO_TEST_CASE( vector_dist_ghost )
275 Test2D_ghost<vector>(box);
278 Test2D_ghost<vector>(box2);
281BOOST_AUTO_TEST_CASE( vector_dist_ghost_inte )
286 Test2D_ghost<vector>(box);
289 Test2D_ghost<vector>(box2);
294BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use_2d )
301 std::default_random_engine eg;
302 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
304#ifdef TEST_COVERAGE_MODE
310 long int big_step = k / 4;
311 big_step = (big_step == 0)?1:big_step;
313 print_test_v(
"Testing 2D vector k<=",k);
316 for ( ; k >= 2 ; k-= decrement(k,big_step) )
318 BOOST_TEST_CHECKPOINT(
"Testing 2D vector k=" << k );
325 size_t bc[2]={NON_PERIODIC,NON_PERIODIC};
329 auto it = vd.getIterator();
335 vd.getPos(key)[0] = ud(eg);
336 vd.getPos(key)[1] = ud(eg);
348 auto it2 = vd.getIterator();
352 auto key = it2.get();
355 BOOST_REQUIRE_EQUAL(ct.
isLocal(vd.getPos(key)),
true);
365 BOOST_REQUIRE_EQUAL((
long int)cnt,k);
369BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use_3d )
376 std::default_random_engine eg;
377 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
379#ifdef TEST_COVERAGE_MODE
385 long int big_step = k / 4;
386 big_step = (big_step == 0)?1:big_step;
388 print_test_v(
"Testing 3D vector k<=",k);
391 for ( ; k >= 2 ; k-= decrement(k,big_step) )
393 BOOST_TEST_CHECKPOINT(
"Testing 3D vector k=" << k );
400 size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
404 auto it = vd.getIterator();
410 vd.getPos(key)[0] = ud(eg);
411 vd.getPos(key)[1] = ud(eg);
412 vd.getPos(key)[2] = ud(eg);
424 auto it2 = vd.getIterator();
428 auto key = it2.get();
431 BOOST_REQUIRE_EQUAL(ct.
isLocal(vd.getPos(key)),
true);
441 BOOST_REQUIRE_EQUAL(cnt,(
size_t)k);
446BOOST_AUTO_TEST_CASE( vector_dist_iterator_fixed_dec_3d )
453 std::default_random_engine eg;
454 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
456#ifdef TEST_COVERAGE_MODE
462 long int big_step = k / 4;
463 big_step = (big_step == 0)?1:big_step;
465 print_test_v(
"Testing 3D vector copy decomposition k<=",k);
468 for ( ; k >= 2 ; k-= decrement(k,big_step) )
470 BOOST_TEST_CHECKPOINT(
"Testing 3D vector copy decomposition k=" << k );
475 size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
480 auto it = vd.getIterator();
486 vd.getPos(key)[0] = ud(eg);
487 vd.getPos(key)[1] = ud(eg);
488 vd.getPos(key)[2] = ud(eg);
490 vd2.getPos(key)[0] = vd.getPos(key)[0];
491 vd2.getPos(key)[1] = vd.getPos(key)[1];
492 vd2.getPos(key)[2] = vd.getPos(key)[2];
503 auto NN = vd.getCellList(0.05);
504 auto NN2 = vd2.getCellList(0.05);
506 cross_calc<3,0>(NN,NN2,vd,vd2);
507 cross_calc<3,1>(NN,NN,vd,vd);
510 auto it3 = vd.getIterator();
514 auto key = it3.get();
516 BOOST_REQUIRE_EQUAL(vd.getProp<0>(key),vd.getProp<1>(key));
523BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_use_2d )
530 std::default_random_engine eg;
531 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
533#ifdef TEST_COVERAGE_MODE
539 long int big_step = k / 4;
540 big_step = (big_step == 0)?1:big_step;
542 print_test_v(
"Testing 2D periodic vector k<=",k);
545 for ( ; k >= 2 ; k-= decrement(k,big_step) )
547 BOOST_TEST_CHECKPOINT(
"Testing 2D periodic vector k=" << k );
552 size_t bc[2]={PERIODIC,PERIODIC};
555 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
566 auto it = vd.getIterator();
572 vd.getPos(key)[0] = ud(eg);
573 vd.getPos(key)[1] = ud(eg);
593 auto it2 = vd.getIterator();
594 count_local_n_local<2,vector_dist<2,float, Point_test<float> >>(vd,it2,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
597 BOOST_REQUIRE_EQUAL(n_out,0ul);
602 BOOST_REQUIRE(nl_cnt != 0);
603 BOOST_REQUIRE(l_cnt > nl_cnt);
611 BOOST_REQUIRE_EQUAL((
long int)l_cnt,k);
617 auto itg = vd.getGhostIterator();
618 count_local_n_local<2,vector_dist<2,float, Point_test<float> > >(vd,itg,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
621 BOOST_REQUIRE_EQUAL(l_cnt,0ul);
626 BOOST_REQUIRE(nl_cnt != 0);
631BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_use_3d )
638 std::default_random_engine eg;
639 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
641#ifdef TEST_COVERAGE_MODE
647 long int big_step = k / 4;
648 big_step = (big_step == 0)?1:big_step;
650 print_test_v(
"Testing 3D periodic vector k<=",k);
653 for ( ; k >= 2 ; k-= decrement(k,big_step) )
655 BOOST_TEST_CHECKPOINT(
"Testing 3D periodic vector k=" << k );
660 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
663 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
674 auto it = vd.getIterator();
680 vd.getPos(key)[0] = ud(eg);
681 vd.getPos(key)[1] = ud(eg);
682 vd.getPos(key)[2] = ud(eg);
701 auto it2 = vd.getIterator();
702 count_local_n_local<3,vector_dist<3,float, Point_test<float> >>(vd,it2,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
705 BOOST_REQUIRE_EQUAL(n_out,0ul);
710 BOOST_REQUIRE(nl_cnt != 0);
711 BOOST_REQUIRE(l_cnt > nl_cnt);
717 BOOST_REQUIRE_EQUAL(l_cnt,(
size_t)k);
723 auto itg = vd.getGhostIterator();
724 count_local_n_local<3,vector_dist<3,float, Point_test<float> > >(vd,itg,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
727 BOOST_REQUIRE_EQUAL(l_cnt,0ul);
732 BOOST_REQUIRE(nl_cnt != 0);
737void test_random_walk(
size_t opt)
744 std::default_random_engine eg;
745 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
747 size_t nsz[] = {0,32,4};
750 print_test_v(
"Testing 3D random walk vector k<=",nsz[0]);
753 for (
size_t i = 0 ; i < 3 ; i++ )
757 BOOST_TEST_CHECKPOINT(
"Testing 3D random walk vector k=" << k );
762 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
765 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
773 auto it = vd.getIterator();
779 vd.getPos(key)[0] = ud(eg);
780 vd.getPos(key)[1] = ud(eg);
781 vd.getPos(key)[2] = ud(eg);
790 for (
size_t j = 0 ; j < 4 ; j++)
792 auto it = vd.getDomainIterator();
798 vd.getPos(key)[0] += 0.02 * ud(eg);
799 vd.getPos(key)[1] += 0.02 * ud(eg);
800 vd.getPos(key)[2] += 0.02 * ud(eg);
810 size_t cnt = total_n_part_lc(vd,bc);
812 BOOST_REQUIRE_EQUAL((
size_t)k,cnt);
817BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_random_walk )
819 test_random_walk(NONE);
822BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_random_walk_local_map )
824 test_random_walk(MAP_LOCAL);
827BOOST_AUTO_TEST_CASE( vector_dist_periodic_map )
832 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
835 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
845 auto it = vd.getIterator();
851 vd.getPos(key)[0] = 1.0;
852 vd.getPos(key)[1] = 1.0;
853 vd.getPos(key)[2] = 1.0;
860 auto it2 = vd.getIterator();
864 auto key = it2.get();
866 float f = vd.getPos(key)[0];
867 BOOST_REQUIRE_EQUAL(f, 0.0);
868 f = vd.getPos(key)[1];
869 BOOST_REQUIRE_EQUAL(f, 0.0);
870 f = vd.getPos(key)[2];
871 BOOST_REQUIRE_EQUAL(f, 0.0);
878BOOST_AUTO_TEST_CASE( vector_dist_not_periodic_map )
883 size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
886 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
896 auto it = vd.getIterator();
902 vd.getPos(key)[0] = 1.0;
903 vd.getPos(key)[1] = 1.0;
904 vd.getPos(key)[2] = 1.0;
911 auto it2 = vd.getIterator();
915 auto key = it2.get();
917 float f = vd.getPos(key)[0];
918 BOOST_REQUIRE_EQUAL(f, 1.0);
919 f = vd.getPos(key)[1];
920 BOOST_REQUIRE_EQUAL(f, 1.0);
921 f = vd.getPos(key)[2];
922 BOOST_REQUIRE_EQUAL(f, 1.0);
928BOOST_AUTO_TEST_CASE( vector_dist_out_of_bound_policy )
938 size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
941 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
951 auto it = vd.getIterator();
961 vd.getPos(key)[0] = -0.06;
962 vd.getPos(key)[1] = -0.06;
963 vd.getPos(key)[2] = -0.06;
967 vd.getPos(key)[0] = 0.06;
968 vd.getPos(key)[1] = 0.06;
969 vd.getPos(key)[2] = 0.06;
980 size_t cnt_l = vd.size_local();
998 std::default_random_engine eg;
999 std::uniform_real_distribution<float> ud(-0.5f, 0.5f);
1001 size_t nsz[] = {0,32,4};
1003#ifdef TEST_COVERAGE_MODE
1009 print_test_v(
"Testing 3D random walk interacting particles vector k=", nsz[0]);
1012 for (
size_t i = 0 ; i < 3 ; i++ )
1016 BOOST_TEST_CHECKPOINT(
"Testing 3D random walk interacting particles vector k=" << k );
1019 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
1022 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1025 float r_cut = 0.01 / factor;
1033 auto it = vd.getIterator();
1037 auto key = it.get();
1039 vd.getPos(key)[0] = ud(eg);
1040 vd.getPos(key)[1] = ud(eg);
1041 vd.getPos(key)[2] = ud(eg);
1050 for (
size_t j = 0 ; j < 4 ; j++)
1052 auto it = vd.getDomainIterator();
1058 auto key = it.get();
1060 vd.getPos(key)[0] += 0.02 * ud(eg);
1061 vd.getPos(key)[1] += 0.02 * ud(eg);
1062 vd.getPos(key)[2] += 0.02 * ud(eg);
1074 auto NN = vd.getCellList(0.01 / factor);
1078 auto it2 = vd.getDomainIterator();
1080 while (it2.isNext())
1086 auto Np = NN.getCellIterator(NN.getCell(xp));
1097 float distance = f.norm();
1101 if (distance > 2*r_cut*sqrt(2))
1112 BOOST_REQUIRE_EQUAL(error,
false);
1115 size_t cnt = total_n_part_lc(vd,bc);
1117 BOOST_REQUIRE_EQUAL((
size_t)k,cnt);
1122BOOST_AUTO_TEST_CASE( vector_dist_periodic_test_interacting_particles )
1125 Test_interacting(box);
1128 Test_interacting(box2);
1131BOOST_AUTO_TEST_CASE( vector_dist_grid_iterator )
1133#ifdef TEST_COVERAGE_MODE
1134 long int k = 32*32*32*create_vcluster().getProcessingUnits();
1136 long int k = 64*64*64*create_vcluster().getProcessingUnits();
1138 k = std::pow(k, 1/3.);
1140 long int big_step = k / 30;
1141 big_step = (big_step == 0)?1:big_step;
1142 long int small_step = 21;
1144 print_test(
"Testing vector grid iterator list k<=",k);
1147 for ( ; k > 8*big_step ; k-= (k > 2*big_step)?big_step:small_step )
1151 const size_t Ng = k;
1154 size_t sz[3] = {Ng,Ng,Ng};
1159 size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
1168 auto it = vd.getGridIterator(sz);
1174 auto key = it.get();
1176 vd.getLastPos()[0] = key.get(0) * it.getSpacing(0);
1177 vd.getLastPos()[1] = key.get(1) * it.getSpacing(1);
1178 vd.getLastPos()[2] = key.get(2) * it.getSpacing(2);
1183 BOOST_REQUIRE_EQUAL(it.getSpacing(0),1.0f/(Ng-1));
1184 BOOST_REQUIRE_EQUAL(it.getSpacing(1),1.0f/(Ng-1));
1185 BOOST_REQUIRE_EQUAL(it.getSpacing(2),1.0f/(Ng-1));
1192 size_t total = vd.size_local();
1196 BOOST_REQUIRE_EQUAL(total,(Ng) * (Ng) * (Ng));
1200BOOST_AUTO_TEST_CASE( vector_dist_cell_verlet_test )
1202#ifdef TEST_COVERAGE_MODE
1203 long int k = 16*16*16*create_vcluster().getProcessingUnits();
1205 long int k = 64*64*64*create_vcluster().getProcessingUnits();
1207 k = std::pow(k, 1/3.);
1209 long int big_step = k / 30;
1210 big_step = (big_step == 0)?1:big_step;
1211 long int small_step = 21;
1213 print_test(
"Testing cell and verlet list k<=",k);
1216 for ( ; k > 8*big_step ; k-= (k > 2*big_step)?big_step:small_step )
1220 const size_t Ng = k;
1223 size_t sz[3] = {Ng,Ng,Ng};
1228 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
1230 float spacing = 1.0/Ng;
1231 float first_dist = spacing;
1232 float second_dist = sqrt(2.0*spacing*spacing);
1233 float third_dist = sqrt(3.0 * spacing*spacing);
1242 auto it = vd.getGridIterator(sz);
1248 auto key = it.get();
1250 vd.getLastPos()[0] = key.get(0) * it.getSpacing(0);
1251 vd.getLastPos()[1] = key.get(1) * it.getSpacing(1);
1252 vd.getLastPos()[2] = key.get(2) * it.getSpacing(2);
1257 BOOST_REQUIRE_EQUAL(it.getSpacing(0),1.0f/Ng);
1258 BOOST_REQUIRE_EQUAL(it.getSpacing(1),1.0f/Ng);
1259 BOOST_REQUIRE_EQUAL(it.getSpacing(2),1.0f/Ng);
1265 size_t total = vd.size_local();
1269 BOOST_REQUIRE_EQUAL(total,(Ng) * (Ng) * (Ng));
1278 first_dist += first_dist * 0.05;
1279 second_dist += second_dist * 0.05;
1280 third_dist += third_dist * 0.05;
1286 bool correct =
true;
1288 BOOST_REQUIRE_EQUAL(vd.size_local(),verlet.
size());
1291 for (
size_t i = 0 ; i < verlet.
size() ; i++)
1294 size_t first_NN = 0;
1295 size_t second_NN = 0;
1296 size_t third_NN = 0;
1301 for (
size_t j = 0 ; j < verlet.
getNNPart(i) ; j++)
1307 if (dist <= first_dist)
1309 else if (dist <= second_dist)
1315 correct &= (first_NN == 7);
1316 correct &= (second_NN == 12);
1317 correct &= (third_NN == 8);
1320 BOOST_REQUIRE_EQUAL(correct,
true);
1325BOOST_AUTO_TEST_CASE( vector_dist_periodic_map_list )
1335 std::default_random_engine eg;
1336 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
1338#ifdef TEST_COVERAGE_MODE
1344 long int big_step = k / 4;
1345 big_step = (big_step == 0)?1:big_step;
1347 print_test(
"Testing 3D periodic vector with map_list k=",k);
1348 BOOST_TEST_CHECKPOINT(
"Testing 3D periodic vector with map_list k=" << k );
1353 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
1356 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1369 auto it = vd.getIterator();
1373 auto key = it.get();
1375 vd.getPos(key)[0] = ud(eg);
1376 vd.getPos(key)[1] = ud(eg);
1377 vd.getPos(key)[2] = ud(eg);
1381 vd.getProp<2>(key).push_back(1);
1382 vd.getProp<2>(key).push_back(2);
1383 vd.getProp<2>(key).push_back(3);
1384 vd.getProp<2>(key).push_back(4);
1386 vd.getProp<3>(key).add(1);
1387 vd.getProp<3>(key).add(2);
1388 vd.getProp<3>(key).add(3);
1389 vd.getProp<3>(key).add(4);
1391 vd.getProp<4>(key).add();
1392 vd.getProp<4>(key).add();
1393 vd.getProp<4>(key).add();
1394 vd.getProp<4>(key).add();
1413 auto it2 = vd.getIterator();
1414 count_local_n_local<3,vector_dist<3,float, part_prop>>(vd,it2,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
1417 BOOST_REQUIRE_EQUAL(n_out,0ul);
1422 BOOST_REQUIRE(nl_cnt != 0);
1423 BOOST_REQUIRE(l_cnt > nl_cnt);
1429 BOOST_REQUIRE_EQUAL(l_cnt,(
size_t)k);
1435 auto itg = vd.getGhostIterator();
1436 count_local_n_local<3, vector_dist<3,float,part_prop> >(vd,itg,bc,box,dom_ext,l_cnt,nl_cnt,n_out);
1439 BOOST_REQUIRE_EQUAL(l_cnt,0ul);
1444 BOOST_REQUIRE(nl_cnt != 0);
1449BOOST_AUTO_TEST_CASE( vector_dist_ghost_with_ghost_buffering )
1459 std::default_random_engine eg;
1460 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
1462#ifdef TEST_COVERAGE_MODE
1468 long int big_step = k / 4;
1469 big_step = (big_step == 0)?1:big_step;
1471 print_test(
"Testing 3D periodic vector with ghost buffering k=",k);
1472 BOOST_TEST_CHECKPOINT(
"Testing 3D periodic with ghost buffering k=" << k );
1477 size_t bc[3]={NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
1487 auto it = vd.getIterator();
1491 auto key = it.get();
1493 vd.getPos(key)[0] = ud(eg);
1494 vd.getPos(key)[1] = ud(eg);
1495 vd.getPos(key)[2] = ud(eg);
1499 vd.getProp<0>(key) = 0.0;
1500 vd.getProp<1>(key) = vd.getPos(key)[0];
1501 vd.getProp<2>(key) = vd.getPos(key)[0]*vd.getPos(key)[0];
1509 vd.ghost_get<0,1,2>();
1512 auto it2 = vd.getGhostIterator();
1513 while (it2.isNext())
1515 auto key = it2.get();
1517 ret &= vd.getProp<1>(key) == vd.getPos(key)[0];
1518 ret &= vd.getProp<2>(key) == vd.getPos(key)[0] * vd.getPos(key)[0];
1523 BOOST_REQUIRE_EQUAL(ret,
true);
1525 for (
size_t i = 0 ; i < 10 ; i++)
1527 auto it = vd.getDomainIterator();
1531 auto key = it.get();
1533 vd.getPos(key)[1] = ud(eg);
1534 vd.getPos(key)[2] = ud(eg);
1538 vd.getProp<0>(key) = i;
1544 vd.ghost_get<0>(SKIP_LABELLING);
1546 vd.ghost_get<0>(SKIP_LABELLING | NO_CHANGE_ELEMENTS );
1548 auto it2 = vd.getGhostIterator();
1551 while (it2.isNext())
1553 auto key = it2.get();
1555 ret &= vd.getProp<0>(key) == i;
1556 ret &= vd.getProp<1>(key) == vd.getPos(key)[0];
1557 ret &= vd.getProp<2>(key) == vd.getPos(key)[0] * vd.getPos(key)[0];
1562 BOOST_REQUIRE_EQUAL(ret,
true);
1566 vd.ghost_get<0,1,2>();
1570 it = vd.getGhostIterator();
1577 vd.getPos(p)[0] = 10.0;
1580 vd.getPos(p)[1] = 17.0;
1586 for (
size_t i = 0 ; i < 10 ; i++)
1588 auto it = vd.getDomainIterator();
1592 auto key = it.get();
1594 vd.getPos(key)[1] = ud(eg);
1595 vd.getPos(key)[2] = ud(eg);
1599 vd.getProp<0>(key) = i;
1600 vd.getProp<1>(key) = vd.getPos(key)[0];
1601 vd.getProp<2>(key) = vd.getPos(key)[0]*vd.getPos(key)[0];
1606 vd.ghost_get<0>(SKIP_LABELLING | NO_POSITION);
1608 auto it2 = vd.getGhostIterator();
1611 while (it2.isNext())
1616 ret &= vd.getPos(p)[0] == 10.0;
1619 ret &= vd.getPos(p)[1] == 17.0;
1625 BOOST_REQUIRE_EQUAL(ret,
true);
1631BOOST_AUTO_TEST_CASE( vector_dist_ghost_put )
1635 long int k = 25*25*25*create_vcluster().getProcessingUnits();
1636 k = std::pow(k, 1/3.);
1641 print_test(
"Testing 3D periodic ghost put k=",k);
1642 BOOST_TEST_CHECKPOINT(
"Testing 3D periodic ghost put k=" << k );
1644 long int big_step = k / 30;
1645 big_step = (big_step == 0)?1:big_step;
1646 long int small_step = 21;
1649 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1651 float r_cut = 1.3 / k;
1652 float r_g = 1.5 / k;
1657 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
1667 auto it = vd.getGridIterator({(size_t)k,(
size_t)k,(size_t)k});
1671 auto key = it.get();
1675 vd.getLastPosWrite()[0] = key.get(0)*it.getSpacing(0);
1676 vd.getLastPosWrite()[1] = key.get(1)*it.getSpacing(1);
1677 vd.getLastPosWrite()[2] = key.get(2)*it.getSpacing(2);
1681 vd.getLastPropWrite<0>() = 0.0;
1692 auto NN = vd.getCellList(r_cut);
1697 auto it2 = vd.getDomainIterator();
1699 while (it2.isNext())
1706 auto Np = NN.getNNIterator<NO_CHECK>(NN.getCell(xp));
1717 vd.getPropWrite<0>(q) += a*(-dist*dist+r_cut*r_cut);
1725 vd.ghost_put<
add_,0>();
1728 auto it3 = vd.getDomainIterator();
1730 float constant = vd.getProp<0>(it3.get());
1733 while (it3.isNext())
1735 float constant2 = vd.getProp<0>(it3.get());
1736 if (fabs(constant - constant2)/constant > eps)
1747 BOOST_REQUIRE_EQUAL(ret,
true);
1750 auto itp = vd.getDomainAndGhostIterator();
1751 while (itp.isNext())
1753 auto key = itp.get();
1755 vd.getPropWrite<0>(key) = 0.0;
1761 auto NN = vd.getCellList(r_cut);
1766 auto it2 = vd.getDomainIterator();
1768 while (it2.isNext())
1775 auto Np = NN.getNNIterator<NO_CHECK>(NN.getCell(xp));
1786 vd.getPropWrite<0>(q) += a*(-dist*dist+r_cut*r_cut);
1794 vd.ghost_put<
add_,0>();
1797 auto it3 = vd.getDomainIterator();
1799 float constant = vd.getPropRead<0>(it3.get());
1802 while (it3.isNext())
1804 float constant2 = vd.getPropRead<0>(it3.get());
1805 if (fabs(constant - constant2)/constant > eps)
1816 BOOST_REQUIRE_EQUAL(ret,
true);
1821BOOST_AUTO_TEST_CASE( vector_fixing_noposition_and_keep_prop )
1829 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
1839 auto it = vd.getDomainIterator();
1843 auto key = it.get();
1845 vd.getPos(key)[0] = ((double)rand())/RAND_MAX;
1846 vd.getPos(key)[1] = ((double)rand())/RAND_MAX;
1847 vd.getPos(key)[2] = ((double)rand())/RAND_MAX;
1855 size_t local = vd.getPosVector().size();
1857 vd.ghost_get<>(KEEP_PROPERTIES | NO_POSITION);
1859 size_t local2 = vd.getPosVector().size();
1861 BOOST_REQUIRE_EQUAL(local,local2);
1867 local = vd.getPosVector().size();
1868 BOOST_REQUIRE_EQUAL(local,vd.size_local());
1869 vd.ghost_get<>(KEEP_PROPERTIES | NO_POSITION);
1871 local2 = vd.getPosVector().size();
1873 BOOST_REQUIRE_EQUAL(local,local2);
1875 vd.ghost_get<>(KEEP_PROPERTIES);
1876 BOOST_REQUIRE_EQUAL(local,vd.getPosVector().size());
1877 BOOST_REQUIRE_EQUAL(vd.getPropVector().size(),local);
1879 vd.ghost_get<0>(KEEP_PROPERTIES);
1880 BOOST_REQUIRE_EQUAL(local,vd.getPosVector().size());
1881 BOOST_REQUIRE_EQUAL(vd.getPropVector().size(),local);
1885BOOST_AUTO_TEST_CASE( vector_of_vector_dist )
1893 size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
1911 phases.get(0).map();
1912 phases.get(0).ghost_get<>();
1913 phases.get(1).map();
1914 phases.get(1).ghost_get<>();
1915 phases.get(2).map();
1916 phases.get(2).ghost_get<>();
1917 phases.get(3).map();
1918 phases.get(3).ghost_get<>();
1922 for (
size_t i = 0 ; i < phases.
size() ; i++)
1923 cnt += phases.get(i).size_local();
1928 BOOST_REQUIRE_EQUAL(cnt,4*4096ul);
1931BOOST_AUTO_TEST_CASE( vector_high_dimension )
1936 for (
size_t i = 0 ; i < 10 ; i++)
1938 domain.setLow(i,0.0);
1939 domain.setHigh(i,1.0);
1944 for (
size_t i = 0 ; i < 10 ; i++)
1945 {bc[i] = NON_PERIODIC;};
1954BOOST_AUTO_TEST_CASE ( vector_of_cell_list_compile_test )
1956 auto & v_cl = create_vcluster();
1961 std::default_random_engine eg;
1962 std::uniform_real_distribution<float> ud(0.0f, 1.0f);
1966 size_t bc[3] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
1970 auto it = vd.getIterator();
1974 auto key = it.get();
1976 vd.getPos(key)[0] = ud(eg);
1977 vd.getPos(key)[1] = ud(eg);
1978 vd.getPos(key)[2] = ud(eg);
1985 std::vector<
decltype(vd.getCellList(0.1))> vector_of_celllist;
1988 std::vector<decltype(std::declval<my_particles>().
getCellList(0.0))> vector_of_celllist2;
1990 vector_of_celllist.push_back(vd.getCellList(0.1));
1992 vector_of_celllist2.push_back(vd.getCellList(0.1));
1996BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
Point< dim, T > getP2() const
Get the point p2.
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
Point< dim, T > getP1() const
Get the point p1.
This class decompose a space into sub-sub-domains and distribute them across processors.
static size_t getDefaultGrid(size_t n_sub)
The default grid size.
bool isLocal(const encapc< 1, Point< dim, T >, Mem > p) const
Check if the particle is local.
This class allocate, and destroy CPU memory.
Test structure used for several test.
This class implement the point shape in an N-dimensional space.
__device__ __host__ T distance(const Point< dim, T > &q) const
It calculate the distance between 2 points.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
std::string toString() const
Return the string with the point coordinate.
This class represent an N-dimensional box.
void execute()
Execute all the requests.
void sum(T &num)
Sum the numbers across all processors and get the result.
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
Implementation of VCluster class.
Class for Verlet list implementation.
size_t get(size_t i, size_t j) const
Get the neighborhood element j for the particle i.
size_t size()
Return for how many particles has been constructed this verlet list.
size_t getNNPart(size_t part_id) const
Return the number of neighborhood particles for the particle id.
Implementation of 1-D std::vector like structure.
CellL getCellList(St r_cut, bool no_se3=false)
Construct a cell list starting from the stored particles.
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...