2 #define BOOST_TEST_DYN_LINK
3 #include <boost/test/unit_test.hpp>
5 #include "Point_test.hpp"
6 #include "Grid/grid_dist_id.hpp"
7 #include "data_type/aggregate.hpp"
8 #include "grid_dist_id_unit_test_ext_dom.hpp"
9 #include "grid_dist_id_unit_test_unb_ghost.hpp"
11 extern void print_test_v(std::string test,
size_t sz);
13 BOOST_AUTO_TEST_SUITE( grid_dist_id_test )
16 BOOST_AUTO_TEST_CASE( grid_dist_id_domain_grid_unit_converter3D_test)
18 size_t bc[3] = {NON_PERIODIC, NON_PERIODIC, NON_PERIODIC};
26 if (v_cl.getProcessingUnits() >= 32)
32 long int big_step = k / 30;
34 big_step = (big_step == 0)?1:big_step;
35 long int small_step = 21;
37 print_test_v(
"Testing 3D grid converter k<=",k);
40 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
42 BOOST_TEST_CHECKPOINT(
"Testing 3D grid converter k=" << k );
57 auto & dec = g_dist.getDecomposition();
60 bool val = dec.check_consistency();
61 BOOST_REQUIRE_EQUAL(val,
true);
65 size_t n_grid = dec.getNSubDomain();
73 for (
size_t i = 0 ; i < n_grid ; i++)
79 Box<3,size_t> g_box = g_dist.getCellDecomposer().convertDomainSpaceIntoGridUnits(sub,bc);
89 vtk_box2.write(std::to_string(v_cl.getProcessUnitID()) +
"vtk_box_3D.vtk");
94 BOOST_REQUIRE_EQUAL(vol,sz[0]*sz[1]*sz[2]);
99 BOOST_AUTO_TEST_CASE( grid_dist_id_domain_grid_unit_converter_test)
101 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
106 Vcluster & v_cl = create_vcluster();
109 if (v_cl.getProcessingUnits() >= 32)
112 for (
size_t k = 1024 ; k >= 2 ; k--)
114 BOOST_TEST_CHECKPOINT(
"Testing grid converter 3D k=" << k );
128 auto & dec = g_dist.getDecomposition();
131 bool val = dec.check_consistency();
132 BOOST_REQUIRE_EQUAL(val,
true);
136 size_t n_grid = dec.getNSubDomain();
141 for (
size_t i = 0 ; i < n_grid ; i++)
146 Box<2,size_t> g_box = g_dist.getCellDecomposer().convertDomainSpaceIntoGridUnits(sub,bc);
154 BOOST_REQUIRE_EQUAL(vol,sz[0]*sz[1]);
161 long int big_step = k / 30;
162 big_step = (big_step == 0)?1:big_step;
163 long int small_step = 21;
165 print_test_v(
"Testing 2D grid k<=",k);
168 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
170 BOOST_TEST_CHECKPOINT(
"Testing 2D grid k=" << k );
179 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/2.0f);
188 bool val = g_dist.getDecomposition().check_consistency();
189 BOOST_REQUIRE_EQUAL(val,
true);
197 auto dom = g_dist.getDomainIterator();
201 auto key = dom.get();
202 auto key_g = g_dist.getGKey(
key);
204 g_dist.template get<0>(
key) = info.LinId(key_g);
222 BOOST_REQUIRE_EQUAL(count,(
size_t)k*k);
224 auto dom2 = g_dist.getDomainIterator();
229 BOOST_REQUIRE_EQUAL((
long int)stop.
get(0),(
long int)g_dist.size(0)-1);
230 BOOST_REQUIRE_EQUAL((
long int)stop.
get(1),(
long int)g_dist.size(1)-1);
232 BOOST_REQUIRE_EQUAL(start.
get(0),0);
233 BOOST_REQUIRE_EQUAL(start.
get(1),0);
238 while (dom2.isNext())
240 auto key = dom2.get();
241 auto key_g = g_dist.getGKey(
key);
243 match &= (g_dist.template get<0>(
key) == info.LinId(key_g))?
true:
false;
248 BOOST_REQUIRE_EQUAL(match,
true);
250 g_dist.template ghost_get<0>();
254 auto domg = g_dist.getDomainGhostIterator();
257 while (domg.isNext())
259 auto key = domg.get();
260 auto key_g = g_dist.getGKey(
key);
263 if (g_dist.isInside(key_g))
265 match &= (g_dist.template get<0>(
key) == info.LinId(key_g))?
true:
false;
271 BOOST_REQUIRE_EQUAL(match,
true);
278 Vcluster & v_cl = create_vcluster();
279 long int big_step = k / 30;
280 big_step = (big_step == 0)?1:big_step;
281 long int small_step = 21;
286 print_test_v(
"Testing 1D grid k<=",k);
289 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
291 BOOST_TEST_CHECKPOINT(
"Testing 1D grid k=" << k );
299 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f);
308 bool val = g_dist.getDecomposition().check_consistency();
309 BOOST_REQUIRE_EQUAL(val,
true);
317 auto dom = g_dist.getDomainIterator();
321 auto key = dom.get();
322 auto key_g = g_dist.getGKey(
key);
324 g_dist.template get<0>(
key) = info.LinId(key_g);
342 BOOST_REQUIRE_EQUAL(count,(
size_t)k);
344 auto dom2 = g_dist.getDomainIterator();
349 BOOST_REQUIRE_EQUAL((
long int)stop.
get(0),(
long int)g_dist.size(0)-1);
351 BOOST_REQUIRE_EQUAL(start.
get(0),0);
356 while (dom2.isNext())
358 auto key = dom2.get();
359 auto key_g = g_dist.getGKey(
key);
361 match &= (g_dist.template get<0>(
key) == info.LinId(key_g))?
true:
false;
366 BOOST_REQUIRE_EQUAL(match,
true);
368 g_dist.template ghost_get<0>();
372 auto domg = g_dist.getDomainGhostIterator();
375 while (domg.isNext())
377 auto key = domg.get();
378 auto key_g = g_dist.getGKey(
key);
381 if (g_dist.isInside(key_g))
383 match &= (g_dist.template get<0>(
key) == info.LinId(key_g))?
true:
false;
389 BOOST_REQUIRE_EQUAL(match,
true);
393 void Test3D_sub(
const Box<3,float> & domain,
long int k)
395 long int big_step = k / 30;
396 big_step = (big_step == 0)?1:big_step;
397 long int small_step = 21;
400 if (create_vcluster().getProcessingUnits() > 32)
403 print_test_v(
"Testing 3D grid sub k<=",k);
406 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
408 BOOST_TEST_CHECKPOINT(
"Testing 3D grid sub k=" << k );
417 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
426 bool val = g_dist.getDecomposition().check_consistency();
427 BOOST_REQUIRE_EQUAL(val,
true);
439 auto dom = g_dist.getSubDomainIterator(one,one_end);
443 auto key = dom.get();
444 auto key_g = g_dist.getGKey(
key);
446 g_dist.template get<0>(
key) = info.LinId(key_g);
462 BOOST_REQUIRE_EQUAL(count,(
size_t)(k-2)*(k-2)*(k-2));
473 auto dom = g_dist.getSubDomainIterator(one,one_end);
477 auto key = dom.get();
478 auto key_g = g_dist.getGKey(
key);
481 BOOST_REQUIRE_EQUAL(key_g.get(0),k/2);
482 BOOST_REQUIRE_EQUAL(key_g.get(1),k/2);
483 BOOST_REQUIRE_EQUAL(key_g.get(2),k/2);
485 auto key_s_it = dom.getGKey(
key);
487 BOOST_REQUIRE_EQUAL(key_g.get(0),key_s_it.get(0));
488 BOOST_REQUIRE_EQUAL(key_g.get(1),key_s_it.get(1));
489 BOOST_REQUIRE_EQUAL(key_g.get(2),key_s_it.get(2));
501 BOOST_REQUIRE_EQUAL(count,1ul);
508 long int big_step = k / 30;
509 big_step = (big_step == 0)?1:big_step;
510 long int small_step = 21;
512 print_test_v(
"Testing 3D grid k<=",k);
515 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
517 BOOST_TEST_CHECKPOINT(
"Testing 3D grid k=" << k );
526 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
535 bool val = g_dist.getDecomposition().check_consistency();
536 BOOST_REQUIRE_EQUAL(val,
true);
544 auto dom = g_dist.getDomainIterator();
548 auto key = dom.get();
549 auto key_g = g_dist.getGKey(
key);
551 g_dist.template get<0>(
key) = info.LinId(key_g);
567 BOOST_REQUIRE_EQUAL(count,(
size_t)k*k*k);
571 auto dom2 = g_dist.getDomainIterator();
574 while (dom2.isNext())
576 auto key = dom2.get();
577 auto key_g = g_dist.getGKey(
key);
579 match &= (g_dist.template get<0>(
key) == info.LinId(key_g))?
true:
false;
584 BOOST_REQUIRE_EQUAL(match,
true);
588 g_dist.template ghost_get<0>();
592 auto domg = g_dist.getDomainGhostIterator();
595 while (domg.isNext())
597 auto key = domg.get();
598 auto key_g = g_dist.getGKey(
key);
601 if (g_dist.isInside(key_g))
603 match &= (g_dist.template get<0>(
key) == info.LinId(key_g))?
true:
false;
609 BOOST_REQUIRE_EQUAL(match,
true);
616 void Test3D_gg(
const Box<3,float> & domain,
long int k,
long int gk)
618 long int big_step = k / 30;
619 big_step = (big_step == 0)?1:big_step;
622 if (create_vcluster().getProcessingUnits() > 32)
625 print_test_v(
"Testing 3D grid k<=",k);
628 for ( ; k > 64 ; k /= 2 )
630 BOOST_TEST_CHECKPOINT(
"Testing 3D grid ghost integer k=" << k );
645 bool val = g_dist.getDecomposition().check_consistency();
646 BOOST_REQUIRE_EQUAL(val,
true);
648 auto lg = g_dist.getLocalGridsInfo();
654 for (
size_t i = 0 ; i < lg.size() ; i++)
656 for (
size_t j = 0 ; j < 3 ; j++)
658 BOOST_REQUIRE(lg.get(i).Dbox.getLow(j) >= gk);
659 BOOST_REQUIRE((lg.get(i).GDbox.getHigh(j) - lg.get(i).Dbox.getHigh(j)) >= gk);
672 long int big_step = k / 30;
673 big_step = (big_step == 0)?1:big_step;
674 long int small_step = 21;
676 print_test_v(
"Testing 3D grid shift domain k<=",k);
679 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
681 BOOST_TEST_CHECKPOINT(
"Testing 3D grid shift domain k=" << k );
690 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
698 auto & v_cl = create_vcluster();
701 bool val = g_dist.getDecomposition().check_consistency();
702 BOOST_REQUIRE_EQUAL(val,
true);
710 auto dom = g_dist.getDomainIterator();
714 auto key = dom.get();
715 auto key_g = g_dist.getGKey(
key);
717 g_dist.template get<0>(
key) = count;
718 g_dist.template get<1>(
key) = info.LinId(key_g);
726 size_t count2 = count;
741 BOOST_REQUIRE_EQUAL(count2,(
size_t)k*k*k);
744 g_dist.template ghost_get<0,1>();
750 auto domg = g_dist.getDomainGhostIterator();
753 while (domg.isNext())
755 auto key = domg.get();
756 auto key_g = g_dist.getGKey(
key);
759 if (g_dist.isInside(key_g))
761 match &= (g_dist.template get<1>(
key) == info.LinId(key_g))?
true:
false;
767 BOOST_REQUIRE_EQUAL(match,
true);
773 void Test2D_complex(
const Box<2,float> & domain,
long int k)
777 long int big_step = k / 30;
778 big_step = (big_step == 0)?1:big_step;
779 long int small_step = 21;
781 print_test_v(
"Testing 2D complex grid k<=",k);
784 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
786 BOOST_TEST_CHECKPOINT(
"Testing 2D complex grid k=" << k );
795 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/2.0f);
804 bool val = g_dist.getDecomposition().check_consistency();
805 BOOST_REQUIRE_EQUAL(val,
true);
813 auto dom = g_dist.getDomainIterator();
817 auto key = dom.get();
818 auto key_g = g_dist.getGKey(
key);
820 size_t k = info.LinId(key_g);
822 g_dist.template get<p::x>(
key) = 1 + k;
823 g_dist.template get<p::y>(
key) = 567 + k;
824 g_dist.template get<p::z>(
key) = 341 + k;
825 g_dist.template get<p::s>(
key) = 5670 + k;
826 g_dist.template get<p::v>(
key)[0] = 921 + k;
827 g_dist.template get<p::v>(
key)[1] = 5675 + k;
828 g_dist.template get<p::v>(
key)[2] = 117 + k;
829 g_dist.template get<p::t>(
key)[0][0] = 1921 + k;
830 g_dist.template get<p::t>(
key)[0][1] = 25675 + k;
831 g_dist.template get<p::t>(
key)[0][2] = 3117 + k;
832 g_dist.template get<p::t>(
key)[1][0] = 4921 + k;
833 g_dist.template get<p::t>(
key)[1][1] = 55675 + k;
834 g_dist.template get<p::t>(
key)[1][2] = 6117 + k;
835 g_dist.template get<p::t>(
key)[2][0] = 7921 + k;
836 g_dist.template get<p::t>(
key)[2][1] = 85675 + k;
837 g_dist.template get<p::t>(
key)[2][2] = 9117 + k;
855 BOOST_REQUIRE_EQUAL(count,(
size_t)k*k);
857 auto dom2 = g_dist.getDomainIterator();
862 while (dom2.isNext())
864 auto key = dom2.get();
865 auto key_g = g_dist.getGKey(
key);
867 size_t k = info.LinId(key_g);
869 match &= (g_dist.template get<p::x>(
key) == 1 + k)?
true:
false;
870 match &= (g_dist.template get<p::y>(
key) == 567 + k)?
true:
false;
871 match &= (g_dist.template get<p::z>(
key) == 341 + k)?
true:
false;
872 match &= (g_dist.template get<p::s>(
key) == 5670 + k)?
true:
false;
873 match &= (g_dist.template get<p::v>(
key)[0] == 921 + k)?
true:
false;
874 match &= (g_dist.template get<p::v>(
key)[1] == 5675 + k)?
true:
false;
875 match &= (g_dist.template get<p::v>(
key)[2] == 117 + k)?
true:
false;
876 match &= (g_dist.template get<p::t>(
key)[0][0] == 1921 + k)?
true:
false;
877 match &= (g_dist.template get<p::t>(
key)[0][1] == 25675 + k)?
true:
false;
878 match &= (g_dist.template get<p::t>(
key)[0][2] == 3117 + k)?
true:
false;
879 match &= (g_dist.template get<p::t>(
key)[1][0] == 4921 + k)?
true:
false;
880 match &= (g_dist.template get<p::t>(
key)[1][1] == 55675 + k)?
true:
false;
881 match &= (g_dist.template get<p::t>(
key)[1][2] == 6117 + k)?
true:
false;
882 match &= (g_dist.template get<p::t>(
key)[2][0] == 7921 + k)?
true:
false;
883 match &= (g_dist.template get<p::t>(
key)[2][1] == 85675 + k)?
true:
false;
884 match &= (g_dist.template get<p::t>(
key)[2][2] == 9117 + k)?
true:
false;
889 BOOST_REQUIRE_EQUAL(match,
true);
893 g_dist.template ghost_get<p::x,p::y,p::z,p::s,p::v,p::t>();
897 auto domg = g_dist.getDomainGhostIterator();
900 while (domg.isNext())
902 auto key = domg.get();
903 auto key_g = g_dist.getGKey(
key);
906 if (g_dist.isInside(key_g))
908 size_t k = info.LinId(key_g);
910 match &= (g_dist.template get<p::x>(
key) == 1 + k)?
true:
false;
911 match &= (g_dist.template get<p::y>(
key) == 567 + k)?
true:
false;
912 match &= (g_dist.template get<p::z>(
key) == 341 + k)?
true:
false;
913 match &= (g_dist.template get<p::s>(
key) == 5670 + k)?
true:
false;
915 match &= (g_dist.template get<p::v>(
key)[0] == 921 + k)?
true:
false;
916 match &= (g_dist.template get<p::v>(
key)[1] == 5675 + k)?
true:
false;
917 match &= (g_dist.template get<p::v>(
key)[2] == 117 + k)?
true:
false;
919 match &= (g_dist.template get<p::t>(
key)[0][0] == 1921 + k)?
true:
false;
920 match &= (g_dist.template get<p::t>(
key)[0][1] == 25675 + k)?
true:
false;
921 match &= (g_dist.template get<p::t>(
key)[0][2] == 3117 + k)?
true:
false;
922 match &= (g_dist.template get<p::t>(
key)[1][0] == 4921 + k)?
true:
false;
923 match &= (g_dist.template get<p::t>(
key)[1][1] == 55675 + k)?
true:
false;
924 match &= (g_dist.template get<p::t>(
key)[1][2] == 6117 + k)?
true:
false;
925 match &= (g_dist.template get<p::t>(
key)[2][0] == 7921 + k)?
true:
false;
926 match &= (g_dist.template get<p::t>(
key)[2][1] == 85675 + k)?
true:
false;
927 match &= (g_dist.template get<p::t>(
key)[2][2] == 9117 + k)?
true:
false;
937 void Test3D_complex(
const Box<3,float> & domain,
long int k)
941 long int big_step = k / 30;
942 big_step = (big_step == 0)?1:big_step;
943 long int small_step = 21;
945 print_test_v(
"Testing 3D grid complex k<=",k);
948 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
950 BOOST_TEST_CHECKPOINT(
"Testing 3D complex grid k=" << k );
959 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
968 bool val = g_dist.getDecomposition().check_consistency();
969 BOOST_REQUIRE_EQUAL(val,
true);
977 auto dom = g_dist.getDomainIterator();
981 auto key = dom.get();
982 auto key_g = g_dist.getGKey(
key);
984 size_t k = info.LinId(key_g);
986 g_dist.template get<p::x>(
key) = 1 + k;
987 g_dist.template get<p::y>(
key) = 567 + k;
988 g_dist.template get<p::z>(
key) = 341 + k;
989 g_dist.template get<p::s>(
key) = 5670 + k;
990 g_dist.template get<p::v>(
key)[0] = 921 + k;
991 g_dist.template get<p::v>(
key)[1] = 5675 + k;
992 g_dist.template get<p::v>(
key)[2] = 117 + k;
993 g_dist.template get<p::t>(
key)[0][0] = 1921 + k;
994 g_dist.template get<p::t>(
key)[0][1] = 25675 + k;
995 g_dist.template get<p::t>(
key)[0][2] = 3117 + k;
996 g_dist.template get<p::t>(
key)[1][0] = 4921 + k;
997 g_dist.template get<p::t>(
key)[1][1] = 55675 + k;
998 g_dist.template get<p::t>(
key)[1][2] = 6117 + k;
999 g_dist.template get<p::t>(
key)[2][0] = 7921 + k;
1000 g_dist.template get<p::t>(
key)[2][1] = 85675 + k;
1001 g_dist.template get<p::t>(
key)[2][2] = 9117 + k;
1017 BOOST_REQUIRE_EQUAL(count,(
size_t)k*k*k);
1021 auto dom2 = g_dist.getDomainIterator();
1024 while (dom2.isNext())
1026 auto key = dom2.get();
1027 auto key_g = g_dist.getGKey(
key);
1029 size_t k = info.LinId(key_g);
1031 match &= (g_dist.template get<p::x>(
key) == 1 + k)?
true:
false;
1032 match &= (g_dist.template get<p::y>(
key) == 567 + k)?
true:
false;
1033 match &= (g_dist.template get<p::z>(
key) == 341 + k)?
true:
false;
1034 match &= (g_dist.template get<p::s>(
key) == 5670 + k)?
true:
false;
1035 match &= (g_dist.template get<p::v>(
key)[0] == 921 + k)?
true:
false;
1036 match &= (g_dist.template get<p::v>(
key)[1] == 5675 + k)?
true:
false;
1037 match &= (g_dist.template get<p::v>(
key)[2] == 117 + k)?
true:
false;
1038 match &= (g_dist.template get<p::t>(
key)[0][0] == 1921 + k)?
true:
false;
1039 match &= (g_dist.template get<p::t>(
key)[0][1] == 25675 + k)?
true:
false;
1040 match &= (g_dist.template get<p::t>(
key)[0][2] == 3117 + k)?
true:
false;
1041 match &= (g_dist.template get<p::t>(
key)[1][0] == 4921 + k)?
true:
false;
1042 match &= (g_dist.template get<p::t>(
key)[1][1] == 55675 + k)?
true:
false;
1043 match &= (g_dist.template get<p::t>(
key)[1][2] == 6117 + k)?
true:
false;
1044 match &= (g_dist.template get<p::t>(
key)[2][0] == 7921 + k)?
true:
false;
1045 match &= (g_dist.template get<p::t>(
key)[2][1] == 85675 + k)?
true:
false;
1046 match &= (g_dist.template get<p::t>(
key)[2][2] == 9117 + k)?
true:
false;
1051 BOOST_REQUIRE_EQUAL(match,
true);
1053 g_dist.template ghost_get<p::x,p::y,p::z,p::s,p::v,p::t>();
1057 auto domg = g_dist.getDomainGhostIterator();
1060 while (domg.isNext())
1062 auto key = domg.get();
1063 auto key_g = g_dist.getGKey(
key);
1065 size_t k = info.LinId(key_g);
1068 if (g_dist.isInside(key_g))
1070 match &= (g_dist.template get<p::x>(
key) == 1 + k)?
true:
false;
1071 match &= (g_dist.template get<p::y>(
key) == 567 + k)?
true:
false;
1072 match &= (g_dist.template get<p::z>(
key) == 341 + k)?
true:
false;
1073 match &= (g_dist.template get<p::s>(
key) == 5670 + k)?
true:
false;
1075 match &= (g_dist.template get<p::v>(
key)[0] == 921 + k)?
true:
false;
1076 match &= (g_dist.template get<p::v>(
key)[1] == 5675 + k)?
true:
false;
1077 match &= (g_dist.template get<p::v>(
key)[2] == 117 + k)?
true:
false;
1079 match &= (g_dist.template get<p::t>(
key)[0][0] == 1921 + k)?
true:
false;
1080 match &= (g_dist.template get<p::t>(
key)[0][1] == 25675 + k)?
true:
false;
1081 match &= (g_dist.template get<p::t>(
key)[0][2] == 3117 + k)?
true:
false;
1082 match &= (g_dist.template get<p::t>(
key)[1][0] == 4921 + k)?
true:
false;
1083 match &= (g_dist.template get<p::t>(
key)[1][1] == 55675 + k)?
true:
false;
1084 match &= (g_dist.template get<p::t>(
key)[1][2] == 6117 + k)?
true:
false;
1085 match &= (g_dist.template get<p::t>(
key)[2][0] == 7921 + k)?
true:
false;
1086 match &= (g_dist.template get<p::t>(
key)[2][1] == 85675 + k)?
true:
false;
1087 match &= (g_dist.template get<p::t>(
key)[2][2] == 9117 + k)?
true:
false;
1093 BOOST_REQUIRE_EQUAL(match,
true);
1099 void Test3D_dup(
const Box<3,float> & domain,
long int k)
1101 long int big_step = k / 30;
1102 big_step = (big_step == 0)?1:big_step;
1103 long int small_step = 21;
1106 Vcluster & v_cl = create_vcluster();
1111 print_test_v(
"Testing 3D duplicate topology complex k<=",k);
1114 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1116 BOOST_TEST_CHECKPOINT(
"Testing 3D copy decomposition grid k=" << k );
1125 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1142 BOOST_REQUIRE_EQUAL(ret,
true);
1144 BOOST_REQUIRE_EQUAL(ret,
true);
1147 auto dom_g1 = g_dist1.getDomainIterator();
1148 auto dom_g2 = g_dist2.getDomainIterator();
1152 while (dom_g1.isNext())
1154 auto key1 = dom_g1.get();
1155 auto key2 = dom_g2.get();
1157 check &= (key1 == key2)?
true:
false;
1163 BOOST_REQUIRE_EQUAL(check,
true);
1169 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1171 BOOST_TEST_CHECKPOINT(
"Testing 3D copy decomposition grid k=" << k );
1180 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1186 grid_dist_id<3, float, Point_test<float>,
CartDecomposition<3,float>> * g_dist1 =
new grid_dist_id<3, float, Point_test<float>,
CartDecomposition<3,float>>(sz,domain,g);
1189 grid_dist_id<3, float, Point_test<float>,
CartDecomposition<3,float>> * g_dist2 =
new grid_dist_id<3, float, Point_test<float>,
CartDecomposition<3,float>>(g_dist1->
getDecomposition(),sz,g);
1194 BOOST_REQUIRE_EQUAL(ret,
true);
1203 void Test3D_periodic(
const Box<3,float> & domain,
long int k)
1205 Vcluster & v_cl = create_vcluster();
1210 long int big_step = k / 30;
1211 big_step = (big_step == 0)?1:big_step;
1212 long int small_step = 21;
1214 print_test_v(
"Testing grid periodic k<=",k);
1217 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1219 BOOST_TEST_CHECKPOINT(
"Testing grid periodick<=" << k );
1228 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1240 bool val = g_dist.getDecomposition().check_consistency();
1241 BOOST_REQUIRE_EQUAL(val,
true);
1250 auto dom1 = g_dist.getDomainGhostIterator();
1252 while (dom1.isNext())
1254 auto key = dom1.get();
1256 g_dist.template get<0>(
key) = -1;
1261 auto dom = g_dist.getDomainIterator();
1263 while (dom.isNext())
1265 auto key = dom.get();
1266 auto key_g = g_dist.getGKey(
key);
1268 g_dist.template get<0>(
key) = info.LinId(key_g);
1284 BOOST_REQUIRE_EQUAL(count,(
size_t)k*k*k);
1286 size_t tot = g_dist.getLocalDomainSize();
1291 BOOST_REQUIRE_EQUAL(count,tot);
1294 g_dist.ghost_get<0>();
1299 auto dom_gi = g_dist.getDomainGhostIterator();
1303 while (dom_gi.isNext())
1307 auto key = dom_gi.get();
1308 auto key_g = g_dist.getGKey(
key);
1311 auto & gb = dom_gi.getGBoxes();
1314 for (
size_t i = 0 ; i < 3 ; i++)
1316 if (key_g.get(i) < 0)
1317 {key_g.set_d(i,key_g.get(i) + k);out_p =
true;}
1318 else if (key_g.get(i) >= k)
1319 {key_g.set_d(i,key_g.get(i) - k);out_p =
true;}
1322 if (g_dist.template get<0>(
key) != -1 && out_p ==
true)
1326 bool can_invalid =
false;
1327 if (
key.getKey().get(0) == 0 ||
key.getKey().get(1) == 0 ||
key.getKey().get(2) == 0)
1329 else if (
key.getKey().get(0) == gb.get(
key.getSub()).GDbox.getHigh(0) ||
1330 key.getKey().get(1) == gb.get(
key.getSub()).GDbox.getHigh(1) ||
1331 key.getKey().get(2) == gb.get(
key.getSub()).GDbox.getHigh(2))
1334 if (can_invalid ==
true)
1336 if ( g_dist.template get<0>(
key) != -1 && info.LinId(key_g) != g_dist.template get<0>(
key) )
1341 if (info.LinId(key_g) != g_dist.template get<0>(
key) )
1348 BOOST_REQUIRE_EQUAL(match,
true);
1353 BOOST_REQUIRE(out_cnt != 0ul);
1360 void Test3D_periodic_put(
const Box<3,float> & domain,
long int k)
1362 Vcluster & v_cl = create_vcluster();
1367 long int big_step = k / 30;
1368 big_step = (big_step == 0)?1:big_step;
1369 long int small_step = 21;
1371 print_test_v(
"Testing grid periodic put k<=",k);
1374 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1376 BOOST_TEST_CHECKPOINT(
"Testing grid periodick<=" << k );
1394 bool val = g_dist.getDecomposition().check_consistency();
1395 BOOST_REQUIRE_EQUAL(val,
true);
1403 auto dom = g_dist.getDomainIterator();
1405 while (dom.isNext())
1407 auto key = dom.get();
1409 g_dist.template get<0>(
key) = -6.0;
1421 auto dom = g_dist.getDomainIterator();
1423 while (dom.isNext())
1425 auto key = dom.get();
1427 g_dist.template get<0>(
key.move(0,1)) += 1.0;
1428 g_dist.template get<0>(
key.move(0,-1)) += 1.0;
1429 g_dist.template get<0>(
key.move(1,1)) += 1.0;
1430 g_dist.template get<0>(
key.move(1,-1)) += 1.0;
1431 g_dist.template get<0>(
key.move(2,1)) += 1.0;
1432 g_dist.template get<0>(
key.move(2,-1)) += 1.0;
1438 bool correct =
true;
1441 auto dom_gi = g_dist.getDomainIterator();
1443 while (dom_gi.isNext())
1445 auto key = dom_gi.get();
1447 correct &= (g_dist.template get<0>(
key) == 0);
1452 g_dist.ghost_put<
add_,0>();
1455 BOOST_REQUIRE_EQUAL(correct,
false);
1458 g_dist.ghost_get<0>();
1463 auto dom_gi2 = g_dist.getDomainIterator();
1465 while (dom_gi2.isNext())
1467 auto key = dom_gi2.get();
1469 correct &= (g_dist.template get<0>(
key) == 0);
1474 BOOST_REQUIRE_EQUAL(correct,
true);
1478 void Test_grid_copy(
const Box<3,float> & domain,
long int k)
1482 Vcluster & v_cl = create_vcluster();
1487 long int big_step = k / 30;
1488 big_step = (big_step == 0)?1:big_step;
1489 long int small_step = 21;
1491 print_test_v(
"Testing grid copy k<=",k);
1494 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1496 BOOST_TEST_CHECKPOINT(
"Testing grid periodick<=" << k );
1505 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1521 auto dom = g_dist.getDomainIterator();
1523 while (dom.isNext())
1525 auto key = dom.get();
1526 auto key_g = g_dist.getGKey(
key);
1528 size_t k = info.LinId(key_g);
1530 g_dist.template get<p::x>(
key) = 1 + k;
1531 g_dist.template get<p::y>(
key) = 567 + k;
1532 g_dist.template get<p::z>(
key) = 341 + k;
1533 g_dist.template get<p::s>(
key) = 5670 + k;
1534 g_dist.template get<p::v>(
key)[0] = 921 + k;
1535 g_dist.template get<p::v>(
key)[1] = 5675 + k;
1536 g_dist.template get<p::v>(
key)[2] = 117 + k;
1537 g_dist.template get<p::t>(
key)[0][0] = 1921 + k;
1538 g_dist.template get<p::t>(
key)[0][1] = 25675 + k;
1539 g_dist.template get<p::t>(
key)[0][2] = 3117 + k;
1540 g_dist.template get<p::t>(
key)[1][0] = 4921 + k;
1541 g_dist.template get<p::t>(
key)[1][1] = 55675 + k;
1542 g_dist.template get<p::t>(
key)[1][2] = 6117 + k;
1543 g_dist.template get<p::t>(
key)[2][0] = 7921 + k;
1544 g_dist.template get<p::t>(
key)[2][1] = 85675 + k;
1545 g_dist.template get<p::t>(
key)[2][2] = 9117 + k;
1550 g_dist2.
copy(g_dist);
1557 while (dom2.isNext())
1559 auto key = dom2.get();
1560 auto key_g = g_dist.getGKey(
key);
1562 size_t k = info.LinId(key_g);
1564 match &= (g_dist2.template get<p::x>(
key) == 1 + k)?
true:
false;
1565 match &= (g_dist2.template get<p::y>(
key) == 567 + k)?
true:
false;
1566 match &= (g_dist2.template get<p::z>(
key) == 341 + k)?
true:
false;
1567 match &= (g_dist2.template get<p::s>(
key) == 5670 + k)?
true:
false;
1568 match &= (g_dist2.template get<p::v>(
key)[0] == 921 + k)?
true:
false;
1569 match &= (g_dist2.template get<p::v>(
key)[1] == 5675 + k)?
true:
false;
1570 match &= (g_dist2.template get<p::v>(
key)[2] == 117 + k)?
true:
false;
1571 match &= (g_dist2.template get<p::t>(
key)[0][0] == 1921 + k)?
true:
false;
1572 match &= (g_dist2.template get<p::t>(
key)[0][1] == 25675 + k)?
true:
false;
1573 match &= (g_dist2.template get<p::t>(
key)[0][2] == 3117 + k)?
true:
false;
1574 match &= (g_dist2.template get<p::t>(
key)[1][0] == 4921 + k)?
true:
false;
1575 match &= (g_dist2.template get<p::t>(
key)[1][1] == 55675 + k)?
true:
false;
1576 match &= (g_dist2.template get<p::t>(
key)[1][2] == 6117 + k)?
true:
false;
1577 match &= (g_dist2.template get<p::t>(
key)[2][0] == 7921 + k)?
true:
false;
1578 match &= (g_dist2.template get<p::t>(
key)[2][1] == 85675 + k)?
true:
false;
1579 match &= (g_dist2.template get<p::t>(
key)[2][2] == 9117 + k)?
true:
false;
1584 BOOST_REQUIRE_EQUAL(match,
true);
1588 void Test_ghost_correction(
Box<3,double> & domain,
long int k,
long int g_)
1590 size_t sz[3] = {(size_t)k,(
size_t)k,(size_t)k};
1597 auto itg =
grid.getDomainGhostIterator();
1599 while (itg.isNext())
1601 auto key = itg.get();
1603 grid.template get<0>(
key) = 0.0;
1610 auto it =
grid.getDomainIterator();
1614 auto key = it.get();
1615 auto gkey = it.getGKey(
key);
1617 if (gkey.get(0) == -4 && gkey.get(1) == 20 && gkey.get(2) == -4)
1619 grid.template get<0>(
key) = 20.0;
1623 grid.template get<0>(
key) = 5.0;
1629 grid.ghost_get<0>();
1630 auto it2 =
grid.getDomainGhostIterator();
1632 bool is_inside =
true;
1634 while (it2.isNext())
1636 auto key = it2.get();
1637 auto gkey = it2.getGKey(
key);
1639 if (
grid.template get<0>(
key) == 5.0)
1644 bool is_inside_point =
false;
1645 for (
size_t i = 0 ; i <
grid.getN_loc_grid() ; i++)
1648 bx +=
grid.getLocalGridsInfo().get(i).origin;
1652 if (bx.
isInside(gkey.toPoint()) ==
true)
1654 is_inside_point |=
true;
1658 is_inside &= is_inside_point;
1665 grid.getDecomposition().write(
"dec_set_for_adj");
1666 grid.write(
"dec_for_adj");
1668 BOOST_REQUIRE_EQUAL(is_inside,
true);
1671 BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use)
1676 #ifdef TEST_COVERAGE_MODE
1677 long int k = 256*256*create_vcluster().getProcessingUnits();
1679 long int k = 1024*1024*create_vcluster().getProcessingUnits();
1681 k = std::pow(k, 1/2.);
1684 Test2D_complex(domain,k);
1688 k = 128*128*128*create_vcluster().getProcessingUnits();
1689 k = std::pow(k, 1/3.);
1691 Test3D_complex(domain3,k);
1694 BOOST_AUTO_TEST_CASE( grid_dist_id_dup)
1699 long int k = 128*128*128*create_vcluster().getProcessingUnits();
1700 k = std::pow(k, 1/3.);
1701 Test3D_dup(domain3,k);
1704 BOOST_AUTO_TEST_CASE( grid_dist_id_sub)
1709 long int k = 128*128*128*create_vcluster().getProcessingUnits();
1710 k = std::pow(k, 1/3.);
1711 Test3D_sub(domain3,k);
1715 BOOST_AUTO_TEST_CASE( grid_dist_id_with_grid_unit_ghost )
1720 long int k = 1024*1024*create_vcluster().getProcessingUnits();
1721 k = std::pow(k, 1/2.);
1726 k = 128*128*128*create_vcluster().getProcessingUnits();
1727 k = std::pow(k, 1/3.);
1728 Test3D_gg(domain3,k,1);
1732 BOOST_AUTO_TEST_CASE( grid_dist_id_domain_test_use)
1740 long int k = 128*128*128*create_vcluster().getProcessingUnits();
1741 k = std::pow(k, 1/3.);
1742 Test3D_domain(domain3,k,np);
1744 auto & v_cl = create_vcluster();
1750 for (
size_t i = 0 ; i < 10 ; i++)
1754 Test3D_domain(domain3,128,p);
1758 BOOST_AUTO_TEST_CASE( grid_dist_id_extended )
1763 long int k = 128*128*128*create_vcluster().getProcessingUnits();
1764 k = std::pow(k, 1/3.);
1766 Test3D_extended_grid(domain3,k);
1769 BOOST_AUTO_TEST_CASE( grid_dist_id_periodic )
1774 long int k = 128*128*128*create_vcluster().getProcessingUnits();
1775 k = std::pow(k, 1/3.);
1777 Test3D_periodic(domain3,k);
1780 BOOST_AUTO_TEST_CASE( grid_dist_id_unbound_ghost )
1785 long int k = 28*28*28*create_vcluster().getProcessingUnits();
1786 k = std::pow(k, 1/3.);
1788 Test3D_unb_ghost(domain3,k);
1791 BOOST_AUTO_TEST_CASE( grid_dist_id_unbound_ghost_periodic )
1796 long int k = 25*25*25*create_vcluster().getProcessingUnits();
1797 k = std::pow(k, 1/3.);
1799 Test3D_unb_ghost_periodic(domain3,k);
1802 BOOST_AUTO_TEST_CASE( grid_dist_id_copy )
1807 long int k = 32*32*32*create_vcluster().getProcessingUnits();
1808 k = std::pow(k, 1/3.);
1810 Test_grid_copy(domain3,k);
1813 BOOST_AUTO_TEST_CASE( grid_1d_test )
1818 long int k = 32*32*32*create_vcluster().getProcessingUnits();
1823 BOOST_AUTO_TEST_CASE( grid_dist_id_periodic_put_test )
1828 long int k = 128*128*128*create_vcluster().getProcessingUnits();
1829 k = std::pow(k, 1/3.);
1831 Test3D_periodic_put(domain3,k);
1834 BOOST_AUTO_TEST_CASE ( grid_ghost_correction )
1840 Test_ghost_correction(domain,k,1);
1841 Test_ghost_correction(domain,k,2);
1842 Test_ghost_correction(domain,k,3);
1843 Test_ghost_correction(domain,k,4);
1847 Test_ghost_correction(domain,k,1);
1848 Test_ghost_correction(domain,k,2);
1849 Test_ghost_correction(domain,k,3);
1850 Test_ghost_correction(domain,k,4);
1854 Test_ghost_correction(domain,k,1);
1855 Test_ghost_correction(domain,k,2);
1856 Test_ghost_correction(domain,k,3);
1857 Test_ghost_correction(domain,k,4);
1861 Test_ghost_correction(domain,k,1);
1862 Test_ghost_correction(domain,k,2);
1863 Test_ghost_correction(domain,k,3);
1864 Test_ghost_correction(domain,k,4);
1867 BOOST_AUTO_TEST_CASE ( grid_basic_functions )
1869 auto & v_cl = create_vcluster();
1874 size_t sz[2] = {(size_t)8,(
size_t)8};
1882 BOOST_REQUIRE_EQUAL(
grid.getOffset(0)[0],-1.25);
1883 BOOST_REQUIRE_EQUAL(
grid.getOffset(0)[1],-1.25);
1886 BOOST_AUTO_TEST_CASE ( grid_overflow_round_off_error )
1888 size_t numGridPoint = 100;
1889 const double domainSize = 20851.7;
1890 double domainLength = sqrt(domainSize);
1892 Box<2,double> domain({0.0,0.0},{domainLength,domainLength});
1894 size_t sz[2] = {numGridPoint,numGridPoint};
1902 auto & gs =
grid.getGridInfo();
1904 auto it =
grid.getDomainIterator();
1909 auto gp = it.getGKey(p);
1911 grid.get<0>(p) = gs.LinId(gp);
1916 grid.ghost_get<0>();
1920 auto it2 =
grid.getDomainIterator();
1924 while (it2.isNext())
1927 auto gp = it.getGKey(p);
1929 if (gs.LinId(gp) !=
grid.get<0>(p))
1934 auto px = p.move(0,1);
1935 auto gpx = it.getGKey(px);
1936 auto mx = p.move(0,-1);
1937 auto gmx = it.getGKey(mx);
1939 auto py = p.move(1,1);
1940 auto gpy = it.getGKey(py);
1941 auto my = p.move(1,-1);
1942 auto gmy = it.getGKey(my);
1944 gpx.set_d(0,gpx.get(0) % gs.size(0));
1945 gpx.set_d(1,gpx.get(1) % gs.size(1));
1947 if (
grid.template get<0>(px) != gs.LinId(gpx))
1950 gmx.set_d(0,(gmx.get(0) + gs.size(0)) % gs.size(0));
1951 gmx.set_d(1,(gmx.get(1) + gs.size(1)) % gs.size(1));
1953 if (
grid.template get<0>(mx) != gs.LinId(gmx))
1956 gpy.set_d(0,gpy.get(0) % gs.size(0));
1957 gpy.set_d(1,gpy.get(1) % gs.size(1));
1959 if (
grid.template get<0>(py) != gs.LinId(gpy))
1962 gmy.set_d(0,(gmy.get(0) + gs.size(0)) % gs.size(0));
1963 gmy.set_d(1,(gmy.get(1) + gs.size(1)) % gs.size(1));
1965 if (
grid.template get<0>(my) != gs.LinId(gmy))
1971 BOOST_REQUIRE_EQUAL(match,
true);
1975 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.
grid_dist_iterator< dim, device_grid, FREE > getDomainIterator() const
It return an iterator that span the full grid domain (each processor span its local domain) ...
T getLow(int i) const
get the i-coordinate of the low bound interval of the box
grid_key_dx is the key to access any element in the grid
size_t getProcessUnitID()
Get the process unit id.
void execute()
Execute all the requests.
bool isInside(const Point< dim, T > &p) const
Check if the point is inside the box.
bool check_consistency()
function to check the consistency of the information of the decomposition
T getHigh(int i) const
get the high interval of the box
This structure define the operation add to use with copy general.
mem_id get(size_t i) const
Get the i index.
Implementation of VCluster class.
This class decompose a space into sub-sub-domains and distribute them across processors.
This is a distributed grid.
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
This class is a trick to indicate the compiler a specific specialization pattern. ...
grid_dist_id< dim, St, T, Decomposition, Memory, device_grid > & copy(grid_dist_id< dim, St, T, Decomposition, Memory, device_grid > &g, bool use_memcpy=true)
Copy the give grid into this grid.
Test structure used for several test.
T getVolumeKey() const
Get the volume spanned by the Box P1 and P2 interpreted as grid key.
Implementation of 1-D std::vector like structure.
size_t getProcessingUnits()
Get the total number of processors.
Decomposition & getDecomposition()
Get the object that store the information about the decomposition.
bool allGather(T &send, openfpm::vector< T, Mem, gr > &v)
Gather the data from all processors.