1#define BOOST_TEST_DYN_LINK
2#include <boost/test/unit_test.hpp>
4#include "Point_test.hpp"
5#include "Grid/grid_dist_id.hpp"
6#include "data_type/aggregate.hpp"
7#include "grid_dist_id_unit_test_ext_dom.hpp"
8#include "grid_dist_id_unit_test_unb_ghost.hpp"
9#include "grid_dist_id_util_tests.hpp"
11extern void print_test_v(std::string test,
size_t sz);
13BOOST_AUTO_TEST_SUITE( grid_dist_id_test )
16BOOST_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 );
56 auto ghost_start = g_dist.getLocalGridsInfo().get(0).Dbox.getKP1();
59 auto & dec = g_dist.getDecomposition();
62 bool val = dec.check_consistency();
63 BOOST_REQUIRE_EQUAL(val,
true);
67 size_t n_grid = dec.getNSubDomain();
75 for (
size_t i = 0 ; i < n_grid ; i++)
81 Box<3,size_t> g_box = g_dist.getCellDecomposer().convertDomainSpaceIntoGridUnits(sub,bc);
91 vtk_box2.write(std::to_string(v_cl.getProcessUnitID()) +
"vtk_box_3D.vtk");
96 BOOST_REQUIRE_EQUAL(vol,sz[0]*sz[1]*sz[2]);
100 auto it = g_dist.getDomainIterator();
105 auto gkey = it.getGKey(key);
107 auto pos = g_dist.getPos(key);
109 if (gkey.get(0) == 0 && gkey.get(1) == 0 && gkey.get(2) == 0)
111 BOOST_REQUIRE_CLOSE(pos.get(0),-0.3f,0.0001);
112 BOOST_REQUIRE_CLOSE(pos.get(1),-0.3f,0.0001);
113 BOOST_REQUIRE_CLOSE(pos.get(2),-0.3f,0.0001);
121 auto key2 = it.get();
123 auto pos = g_dist.getPos(key2);
125 if (pos[0] >= 0.99999 && pos[0] <= 1.00001 &&
126 pos[1] >= 0.99999 && pos[1] <= 1.00001 &&
127 pos[2] >= 0.99999 && pos[2] <= 1.00001)
138 BOOST_REQUIRE_EQUAL(check,1);
143BOOST_AUTO_TEST_CASE( grid_dist_id_domain_grid_unit_converter_test)
145 size_t bc[2] = {NON_PERIODIC, NON_PERIODIC};
153 if (v_cl.getProcessingUnits() >= 32)
156 for (
size_t k = 1024 ; k >= 2 ; k--)
158 BOOST_TEST_CHECKPOINT(
"Testing grid converter 3D k=" << k );
172 auto & dec = g_dist.getDecomposition();
175 bool val = dec.check_consistency();
176 BOOST_REQUIRE_EQUAL(val,
true);
180 size_t n_grid = dec.getNSubDomain();
185 for (
size_t i = 0 ; i < n_grid ; i++)
190 Box<2,size_t> g_box = g_dist.getCellDecomposer().convertDomainSpaceIntoGridUnits(sub,bc);
199 BOOST_REQUIRE_EQUAL(vol,sz[0]*sz[1]);
206 long int big_step = k / 30;
207 big_step = (big_step == 0)?1:big_step;
208 long int small_step = 21;
210 print_test_v(
"Testing 2D grid k<=",k);
213 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
215 BOOST_TEST_CHECKPOINT(
"Testing 2D grid k=" << k );
224 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/2.0f);
232 Test2D_core(g_dist,sz,k);
240 long int big_step = k / 30;
241 big_step = (big_step == 0)?1:big_step;
242 long int small_step = 21;
247 print_test_v(
"Testing 1D grid k<=",k);
250 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
252 BOOST_TEST_CHECKPOINT(
"Testing 1D grid k=" << k );
258 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f);
267 bool val = g_dist.getDecomposition().check_consistency();
268 BOOST_REQUIRE_EQUAL(val,
true);
276 auto dom = g_dist.getDomainIterator();
280 auto key = dom.get();
281 auto key_g = g_dist.getGKey(key);
283 g_dist.template get<0>(key) = info.LinId(key_g);
299 BOOST_REQUIRE_EQUAL(count,(
size_t)k);
301 auto dom2 = g_dist.getDomainIterator();
306 BOOST_REQUIRE_EQUAL((
long int)stop.
get(0),(
long int)g_dist.size(0)-1);
308 BOOST_REQUIRE_EQUAL(start.
get(0),0);
313 while (dom2.isNext())
315 auto key = dom2.get();
316 auto key_g = g_dist.getGKey(key);
318 match &= (g_dist.template get<0>(key) == info.LinId(key_g))?
true:false;
323 BOOST_REQUIRE_EQUAL(match,
true);
325 g_dist.template ghost_get<0>();
329 auto domg = g_dist.getDomainGhostIterator();
332 while (domg.isNext())
334 auto key = domg.get();
335 auto key_g = g_dist.getGKey(key);
338 if (g_dist.isInside(key_g))
340 match &= (g_dist.template get<0>(key) == info.LinId(key_g))?
true:false;
346 BOOST_REQUIRE_EQUAL(match,
true);
352 long int big_step = k / 30;
353 big_step = (big_step == 0)?1:big_step;
354 long int small_step = 21;
357 if (create_vcluster().getProcessingUnits() > 32)
360 print_test_v(
"Testing 3D grid sub k<=",k);
363 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
365 BOOST_TEST_CHECKPOINT(
"Testing 3D grid sub k=" << k );
374 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
383 bool val = g_dist.getDecomposition().check_consistency();
384 BOOST_REQUIRE_EQUAL(val,
true);
396 auto dom = g_dist.getSubDomainIterator(one,one_end);
400 auto key = dom.get();
401 auto key_g = g_dist.getGKey(key);
403 g_dist.template get<0>(key) = info.LinId(key_g);
419 BOOST_REQUIRE_EQUAL(count,(
size_t)(k-2)*(k-2)*(k-2));
430 auto dom = g_dist.getSubDomainIterator(one,one_end);
434 auto key = dom.get();
435 auto key_g = g_dist.getGKey(key);
438 BOOST_REQUIRE_EQUAL(key_g.get(0),k/2);
439 BOOST_REQUIRE_EQUAL(key_g.get(1),k/2);
440 BOOST_REQUIRE_EQUAL(key_g.get(2),k/2);
442 auto key_s_it = dom.getGKey(key);
444 BOOST_REQUIRE_EQUAL(key_g.get(0),key_s_it.get(0));
445 BOOST_REQUIRE_EQUAL(key_g.get(1),key_s_it.get(1));
446 BOOST_REQUIRE_EQUAL(key_g.get(2),key_s_it.get(2));
458 BOOST_REQUIRE_EQUAL(count,1ul);
465 long int big_step = k / 30;
466 big_step = (big_step == 0)?1:big_step;
467 long int small_step = 21;
469 print_test_v(
"Testing 3D grid k<=",k);
472 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
474 BOOST_TEST_CHECKPOINT(
"Testing 3D grid k=" << k );
483 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
492 bool val = g_dist.getDecomposition().check_consistency();
493 BOOST_REQUIRE_EQUAL(val,
true);
501 auto dom = g_dist.getDomainIterator();
505 auto key = dom.get();
506 auto key_g = g_dist.getGKey(key);
508 g_dist.template get<0>(key) = info.LinId(key_g);
524 BOOST_REQUIRE_EQUAL(count,(
size_t)k*k*k);
528 auto dom2 = g_dist.getDomainIterator();
531 while (dom2.isNext())
533 auto key = dom2.get();
534 auto key_g = g_dist.getGKey(key);
536 match &= (g_dist.template get<0>(key) == info.LinId(key_g))?
true:false;
541 BOOST_REQUIRE_EQUAL(match,
true);
545 g_dist.template ghost_get<0>();
549 auto domg = g_dist.getDomainGhostIterator();
552 while (domg.isNext())
554 auto key = domg.get();
555 auto key_g = g_dist.getGKey(key);
558 if (g_dist.isInside(key_g))
560 match &= (g_dist.template get<0>(key) == info.LinId(key_g))?
true:false;
562 {std::cout <<
"ERROR IN: " << key_g.to_string() <<
" " << info.LinId(key_g) <<
" != " << g_dist.template get<0>(key) << std::endl;
break;}
570 g_dist.write(
"Error_grid");
572 g_dist.getDecomposition().write(
"Error_dec");
575 BOOST_REQUIRE_EQUAL(match,
true);
582void Test3D_gg(
const Box<3,float> & domain,
long int k,
long int gk)
584 long int big_step = k / 30;
585 big_step = (big_step == 0)?1:big_step;
588 if (create_vcluster().getProcessingUnits() > 32)
591 print_test_v(
"Testing 3D grid k<=",k);
594 for ( ; k > 64 ; k /= 2 )
596 BOOST_TEST_CHECKPOINT(
"Testing 3D grid ghost integer k=" << k );
611 bool val = g_dist.getDecomposition().check_consistency();
612 BOOST_REQUIRE_EQUAL(val,
true);
614 auto lg = g_dist.getLocalGridsInfo();
620 for (
size_t i = 0 ; i < lg.size() ; i++)
622 for (
size_t j = 0 ; j < 3 ; j++)
624 BOOST_REQUIRE(lg.get(i).Dbox.getLow(j) >= gk);
625 BOOST_REQUIRE((lg.get(i).GDbox.getHigh(j) - lg.get(i).Dbox.getHigh(j)) >= gk);
638 long int big_step = k / 30;
639 big_step = (big_step == 0)?1:big_step;
640 long int small_step = 21;
642 print_test_v(
"Testing 3D grid shift domain k<=",k);
645 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
647 BOOST_TEST_CHECKPOINT(
"Testing 3D grid shift domain k=" << k );
656 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
664 auto & v_cl = create_vcluster();
667 bool val = g_dist.getDecomposition().check_consistency();
668 BOOST_REQUIRE_EQUAL(val,
true);
676 auto dom = g_dist.getDomainIterator();
680 auto key = dom.get();
681 auto key_g = g_dist.getGKey(key);
683 g_dist.template get<0>(key) = count;
684 g_dist.template get<1>(key) = info.LinId(key_g);
692 size_t count2 = count;
707 BOOST_REQUIRE_EQUAL(count2,(
size_t)k*k*k);
710 g_dist.template ghost_get<0,1>();
716 auto domg = g_dist.getDomainGhostIterator();
719 while (domg.isNext())
721 auto key = domg.get();
722 auto key_g = g_dist.getGKey(key);
725 if (g_dist.isInside(key_g))
727 match &= (g_dist.template get<1>(key) == info.LinId(key_g))?
true:false;
733 BOOST_REQUIRE_EQUAL(match,
true);
739void Test2D_complex(
const Box<2,float> & domain,
long int k)
743 long int big_step = k / 30;
744 big_step = (big_step == 0)?1:big_step;
745 long int small_step = 21;
747 print_test_v(
"Testing 2D complex grid k<=",k);
750 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
752 BOOST_TEST_CHECKPOINT(
"Testing 2D complex grid k=" << k );
761 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/2.0f);
770 bool val = g_dist.getDecomposition().check_consistency();
771 BOOST_REQUIRE_EQUAL(val,
true);
779 auto dom = g_dist.getDomainIterator();
783 auto key = dom.get();
784 auto key_g = g_dist.getGKey(key);
786 size_t k = info.LinId(key_g);
788 g_dist.template get<p::x>(key) = 1 + k;
789 g_dist.template get<p::y>(key) = 567 + k;
790 g_dist.template get<p::z>(key) = 341 + k;
791 g_dist.template get<p::s>(key) = 5670 + k;
792 g_dist.template get<p::v>(key)[0] = 921 + k;
793 g_dist.template get<p::v>(key)[1] = 5675 + k;
794 g_dist.template get<p::v>(key)[2] = 117 + k;
795 g_dist.template get<p::t>(key)[0][0] = 1921 + k;
796 g_dist.template get<p::t>(key)[0][1] = 25675 + k;
797 g_dist.template get<p::t>(key)[0][2] = 3117 + k;
798 g_dist.template get<p::t>(key)[1][0] = 4921 + k;
799 g_dist.template get<p::t>(key)[1][1] = 55675 + k;
800 g_dist.template get<p::t>(key)[1][2] = 6117 + k;
801 g_dist.template get<p::t>(key)[2][0] = 7921 + k;
802 g_dist.template get<p::t>(key)[2][1] = 85675 + k;
803 g_dist.template get<p::t>(key)[2][2] = 9117 + k;
821 BOOST_REQUIRE_EQUAL(count,(
size_t)k*k);
823 auto dom2 = g_dist.getDomainIterator();
828 while (dom2.isNext())
830 auto key = dom2.get();
831 auto key_g = g_dist.getGKey(key);
833 size_t k = info.LinId(key_g);
835 match &= (g_dist.template get<p::x>(key) == 1 + k)?
true:false;
836 match &= (g_dist.template get<p::y>(key) == 567 + k)?
true:false;
837 match &= (g_dist.template get<p::z>(key) == 341 + k)?
true:false;
838 match &= (g_dist.template get<p::s>(key) == 5670 + k)?
true:false;
839 match &= (g_dist.template get<p::v>(key)[0] == 921 + k)?
true:false;
840 match &= (g_dist.template get<p::v>(key)[1] == 5675 + k)?
true:false;
841 match &= (g_dist.template get<p::v>(key)[2] == 117 + k)?
true:false;
842 match &= (g_dist.template get<p::t>(key)[0][0] == 1921 + k)?
true:false;
843 match &= (g_dist.template get<p::t>(key)[0][1] == 25675 + k)?
true:false;
844 match &= (g_dist.template get<p::t>(key)[0][2] == 3117 + k)?
true:false;
845 match &= (g_dist.template get<p::t>(key)[1][0] == 4921 + k)?
true:false;
846 match &= (g_dist.template get<p::t>(key)[1][1] == 55675 + k)?
true:false;
847 match &= (g_dist.template get<p::t>(key)[1][2] == 6117 + k)?
true:false;
848 match &= (g_dist.template get<p::t>(key)[2][0] == 7921 + k)?
true:false;
849 match &= (g_dist.template get<p::t>(key)[2][1] == 85675 + k)?
true:false;
850 match &= (g_dist.template get<p::t>(key)[2][2] == 9117 + k)?
true:false;
855 BOOST_REQUIRE_EQUAL(match,
true);
859 g_dist.template ghost_get<p::x,p::y,p::z,p::s,p::v,p::t>();
863 auto domg = g_dist.getDomainGhostIterator();
866 while (domg.isNext())
868 auto key = domg.get();
869 auto key_g = g_dist.getGKey(key);
872 if (g_dist.isInside(key_g))
874 size_t k = info.LinId(key_g);
876 match &= (g_dist.template get<p::x>(key) == 1 + k)?
true:false;
877 match &= (g_dist.template get<p::y>(key) == 567 + k)?
true:false;
878 match &= (g_dist.template get<p::z>(key) == 341 + k)?
true:false;
879 match &= (g_dist.template get<p::s>(key) == 5670 + k)?
true:false;
881 match &= (g_dist.template get<p::v>(key)[0] == 921 + k)?
true:false;
882 match &= (g_dist.template get<p::v>(key)[1] == 5675 + k)?
true:false;
883 match &= (g_dist.template get<p::v>(key)[2] == 117 + k)?
true:false;
885 match &= (g_dist.template get<p::t>(key)[0][0] == 1921 + k)?
true:false;
886 match &= (g_dist.template get<p::t>(key)[0][1] == 25675 + k)?
true:false;
887 match &= (g_dist.template get<p::t>(key)[0][2] == 3117 + k)?
true:false;
888 match &= (g_dist.template get<p::t>(key)[1][0] == 4921 + k)?
true:false;
889 match &= (g_dist.template get<p::t>(key)[1][1] == 55675 + k)?
true:false;
890 match &= (g_dist.template get<p::t>(key)[1][2] == 6117 + k)?
true:false;
891 match &= (g_dist.template get<p::t>(key)[2][0] == 7921 + k)?
true:false;
892 match &= (g_dist.template get<p::t>(key)[2][1] == 85675 + k)?
true:false;
893 match &= (g_dist.template get<p::t>(key)[2][2] == 9117 + k)?
true:false;
903void Test3D_complex(
const Box<3,float> & domain,
long int k)
907 long int big_step = k / 30;
908 big_step = (big_step == 0)?1:big_step;
909 long int small_step = 21;
911 print_test_v(
"Testing 3D grid complex k<=",k);
914 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
916 BOOST_TEST_CHECKPOINT(
"Testing 3D complex grid k=" << k );
925 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
934 bool val = g_dist.getDecomposition().check_consistency();
935 BOOST_REQUIRE_EQUAL(val,
true);
943 auto dom = g_dist.getDomainIterator();
947 auto key = dom.get();
948 auto key_g = g_dist.getGKey(key);
950 size_t k = info.LinId(key_g);
952 g_dist.template get<p::x>(key) = 1 + k;
953 g_dist.template get<p::y>(key) = 567 + k;
954 g_dist.template get<p::z>(key) = 341 + k;
955 g_dist.template get<p::s>(key) = 5670 + k;
956 g_dist.template get<p::v>(key)[0] = 921 + k;
957 g_dist.template get<p::v>(key)[1] = 5675 + k;
958 g_dist.template get<p::v>(key)[2] = 117 + k;
959 g_dist.template get<p::t>(key)[0][0] = 1921 + k;
960 g_dist.template get<p::t>(key)[0][1] = 25675 + k;
961 g_dist.template get<p::t>(key)[0][2] = 3117 + k;
962 g_dist.template get<p::t>(key)[1][0] = 4921 + k;
963 g_dist.template get<p::t>(key)[1][1] = 55675 + k;
964 g_dist.template get<p::t>(key)[1][2] = 6117 + k;
965 g_dist.template get<p::t>(key)[2][0] = 7921 + k;
966 g_dist.template get<p::t>(key)[2][1] = 85675 + k;
967 g_dist.template get<p::t>(key)[2][2] = 9117 + k;
983 BOOST_REQUIRE_EQUAL(count,(
size_t)k*k*k);
987 auto dom2 = g_dist.getDomainIterator();
990 while (dom2.isNext())
992 auto key = dom2.get();
993 auto key_g = g_dist.getGKey(key);
995 size_t k = info.LinId(key_g);
997 match &= (g_dist.template get<p::x>(key) == 1 + k)?
true:false;
998 match &= (g_dist.template get<p::y>(key) == 567 + k)?
true:false;
999 match &= (g_dist.template get<p::z>(key) == 341 + k)?
true:false;
1000 match &= (g_dist.template get<p::s>(key) == 5670 + k)?
true:false;
1001 match &= (g_dist.template get<p::v>(key)[0] == 921 + k)?
true:false;
1002 match &= (g_dist.template get<p::v>(key)[1] == 5675 + k)?
true:false;
1003 match &= (g_dist.template get<p::v>(key)[2] == 117 + k)?
true:false;
1004 match &= (g_dist.template get<p::t>(key)[0][0] == 1921 + k)?
true:false;
1005 match &= (g_dist.template get<p::t>(key)[0][1] == 25675 + k)?
true:false;
1006 match &= (g_dist.template get<p::t>(key)[0][2] == 3117 + k)?
true:false;
1007 match &= (g_dist.template get<p::t>(key)[1][0] == 4921 + k)?
true:false;
1008 match &= (g_dist.template get<p::t>(key)[1][1] == 55675 + k)?
true:false;
1009 match &= (g_dist.template get<p::t>(key)[1][2] == 6117 + k)?
true:false;
1010 match &= (g_dist.template get<p::t>(key)[2][0] == 7921 + k)?
true:false;
1011 match &= (g_dist.template get<p::t>(key)[2][1] == 85675 + k)?
true:false;
1012 match &= (g_dist.template get<p::t>(key)[2][2] == 9117 + k)?
true:false;
1017 BOOST_REQUIRE_EQUAL(match,
true);
1019 g_dist.template ghost_get<p::x,p::y,p::z,p::s,p::v,p::t>();
1023 auto domg = g_dist.getDomainGhostIterator();
1026 while (domg.isNext())
1028 auto key = domg.get();
1029 auto key_g = g_dist.getGKey(key);
1031 size_t k = info.LinId(key_g);
1034 if (g_dist.isInside(key_g))
1036 match &= (g_dist.template get<p::x>(key) == 1 + k)?
true:false;
1037 match &= (g_dist.template get<p::y>(key) == 567 + k)?
true:false;
1038 match &= (g_dist.template get<p::z>(key) == 341 + k)?
true:false;
1039 match &= (g_dist.template get<p::s>(key) == 5670 + k)?
true:false;
1041 match &= (g_dist.template get<p::v>(key)[0] == 921 + k)?
true:false;
1042 match &= (g_dist.template get<p::v>(key)[1] == 5675 + k)?
true:false;
1043 match &= (g_dist.template get<p::v>(key)[2] == 117 + k)?
true:false;
1045 match &= (g_dist.template get<p::t>(key)[0][0] == 1921 + k)?
true:false;
1046 match &= (g_dist.template get<p::t>(key)[0][1] == 25675 + k)?
true:false;
1047 match &= (g_dist.template get<p::t>(key)[0][2] == 3117 + k)?
true:false;
1048 match &= (g_dist.template get<p::t>(key)[1][0] == 4921 + k)?
true:false;
1049 match &= (g_dist.template get<p::t>(key)[1][1] == 55675 + k)?
true:false;
1050 match &= (g_dist.template get<p::t>(key)[1][2] == 6117 + k)?
true:false;
1051 match &= (g_dist.template get<p::t>(key)[2][0] == 7921 + k)?
true:false;
1052 match &= (g_dist.template get<p::t>(key)[2][1] == 85675 + k)?
true:false;
1053 match &= (g_dist.template get<p::t>(key)[2][2] == 9117 + k)?
true:false;
1059 BOOST_REQUIRE_EQUAL(match,
true);
1065void Test3D_dup(
const Box<3,float> & domain,
long int k)
1067 long int big_step = k / 30;
1068 big_step = (big_step == 0)?1:big_step;
1069 long int small_step = 21;
1077 print_test_v(
"Testing 3D duplicate topology complex k<=",k);
1080 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1082 BOOST_TEST_CHECKPOINT(
"Testing 3D copy decomposition grid k=" << k );
1091 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1107 bool ret = g_dist2.getDecomposition().check_consistency();
1108 BOOST_REQUIRE_EQUAL(ret,
true);
1109 ret = g_dist2.getDecomposition().is_equal(g_dist2.getDecomposition());
1110 BOOST_REQUIRE_EQUAL(ret,
true);
1113 auto dom_g1 = g_dist1.getDomainIterator();
1114 auto dom_g2 = g_dist2.getDomainIterator();
1118 while (dom_g1.isNext())
1120 auto key1 = dom_g1.get();
1121 auto key2 = dom_g2.get();
1123 check &= (key1 == key2)?
true:false;
1129 BOOST_REQUIRE_EQUAL(check,
true);
1135 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1137 BOOST_TEST_CHECKPOINT(
"Testing 3D copy decomposition grid k=" << k );
1146 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1152 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);
1155 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);
1160 BOOST_REQUIRE_EQUAL(ret,
true);
1169void Test3D_periodic(
const Box<3,float> & domain,
long int k)
1176 long int big_step = k / 30;
1177 big_step = (big_step == 0)?1:big_step;
1178 long int small_step = 21;
1180 print_test_v(
"Testing grid periodic k<=",k);
1183 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1185 BOOST_TEST_CHECKPOINT(
"Testing grid periodic k<=" << k );
1194 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1206 bool val = g_dist.getDecomposition().check_consistency();
1207 BOOST_REQUIRE_EQUAL(val,
true);
1216 auto dom1 = g_dist.getDomainGhostIterator();
1218 while (dom1.isNext())
1220 auto key = dom1.get();
1222 g_dist.template get<0>(key) = -1;
1227 auto dom = g_dist.getDomainIterator();
1229 while (dom.isNext())
1231 auto key = dom.get();
1232 auto key_g = g_dist.getGKey(key);
1234 g_dist.template get<0>(key) = info.LinId(key_g);
1250 BOOST_REQUIRE_EQUAL(count,(
size_t)k*k*k);
1252 size_t tot = g_dist.getLocalDomainSize();
1257 BOOST_REQUIRE_EQUAL(count,tot);
1260 g_dist.ghost_get<0>();
1265 auto dom_gi = g_dist.getDomainGhostIterator();
1269 while (dom_gi.isNext())
1273 auto key = dom_gi.get();
1274 auto key_g = g_dist.getGKey(key);
1277 auto & gb = dom_gi.getGBoxes();
1280 for (
size_t i = 0 ; i < 3 ; i++)
1282 if (key_g.get(i) < 0)
1283 {key_g.set_d(i,key_g.get(i) + k);out_p =
true;}
1284 else if (key_g.get(i) >= k)
1285 {key_g.set_d(i,key_g.get(i) - k);out_p =
true;}
1288 if (g_dist.template get<0>(key) != -1 && out_p ==
true)
1292 bool can_invalid =
false;
1293 if (key.getKey().get(0) == 0 || key.getKey().get(1) == 0 || key.getKey().get(2) == 0)
1295 else if (key.getKey().get(0) == gb.get(key.getSub()).GDbox.getHigh(0) ||
1296 key.getKey().get(1) == gb.get(key.getSub()).GDbox.getHigh(1) ||
1297 key.getKey().get(2) == gb.get(key.getSub()).GDbox.getHigh(2))
1300 if (can_invalid ==
true)
1302 if ( g_dist.template get<0>(key) != -1 && info.LinId(key_g) != g_dist.template get<0>(key) )
1307 if (info.LinId(key_g) != g_dist.template get<0>(key) )
1314 BOOST_REQUIRE_EQUAL(match,
true);
1319 BOOST_REQUIRE(out_cnt != 0ul);
1328void Test3D_periodic_put(
const Box<3,float> & domain,
long int k)
1335 long int big_step = k / 30;
1336 big_step = (big_step == 0)?1:big_step;
1337 long int small_step = 21;
1339 print_test_v(
"Testing grid periodic put k<=",k);
1342 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1344 BOOST_TEST_CHECKPOINT(
"Testing grid periodick<=" << k );
1362 bool val = g_dist.getDecomposition().check_consistency();
1363 BOOST_REQUIRE_EQUAL(val,
true);
1371 auto dom = g_dist.getDomainIterator();
1373 while (dom.isNext())
1375 auto key = dom.get();
1377 g_dist.template get<0>(key) = -6.0;
1378 g_dist.template get<1>(key) = -6.0;
1390 auto dom = g_dist.getDomainIterator();
1392 while (dom.isNext())
1394 auto key = dom.get();
1396 g_dist.template get<0>(key.move(0,1)) += 1.0;
1397 g_dist.template get<0>(key.move(0,-1)) += 1.0;
1398 g_dist.template get<0>(key.move(1,1)) += 1.0;
1399 g_dist.template get<0>(key.move(1,-1)) += 1.0;
1400 g_dist.template get<0>(key.move(2,1)) += 1.0;
1401 g_dist.template get<0>(key.move(2,-1)) += 1.0;
1404 g_dist.template get<1>(key.move(0,1)) += 1.0;
1405 g_dist.template get<1>(key.move(0,-1)) += 1.0;
1406 g_dist.template get<1>(key.move(1,1)) += 1.0;
1407 g_dist.template get<1>(key.move(1,-1)) += 1.0;
1408 g_dist.template get<1>(key.move(2,1)) += 1.0;
1409 g_dist.template get<1>(key.move(2,-1)) += 1.0;
1415 bool correct =
true;
1418 auto dom_gi = g_dist.getDomainIterator();
1420 while (dom_gi.isNext())
1422 auto key = dom_gi.get();
1424 correct &= (g_dist.template get<0>(key) == 0);
1429 g_dist.ghost_put<
add_,0>();
1430 g_dist.ghost_put<
add_,1>();
1434 BOOST_REQUIRE_EQUAL(correct,
false);
1437 g_dist.ghost_get<0,1>();
1442 auto dom_gi2 = g_dist.getDomainIterator();
1444 while (dom_gi2.isNext())
1446 auto key = dom_gi2.get();
1448 correct &= (g_dist.template get<0>(key) == 0);
1449 correct &= (g_dist.template get<1>(key) == 0);
1454 BOOST_REQUIRE_EQUAL(correct,
true);
1458void Test_grid_copy(
const Box<3,float> & domain,
long int k)
1467 long int big_step = k / 30;
1468 big_step = (big_step == 0)?1:big_step;
1469 long int small_step = 21;
1471 print_test_v(
"Testing grid copy k<=",k);
1474 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1476 BOOST_TEST_CHECKPOINT(
"Testing grid periodick<=" << k );
1485 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1501 auto dom = g_dist.getDomainIterator();
1503 while (dom.isNext())
1505 auto key = dom.get();
1506 auto key_g = g_dist.getGKey(key);
1508 size_t k = info.LinId(key_g);
1510 g_dist.template get<p::x>(key) = 1 + k;
1511 g_dist.template get<p::y>(key) = 567 + k;
1512 g_dist.template get<p::z>(key) = 341 + k;
1513 g_dist.template get<p::s>(key) = 5670 + k;
1514 g_dist.template get<p::v>(key)[0] = 921 + k;
1515 g_dist.template get<p::v>(key)[1] = 5675 + k;
1516 g_dist.template get<p::v>(key)[2] = 117 + k;
1517 g_dist.template get<p::t>(key)[0][0] = 1921 + k;
1518 g_dist.template get<p::t>(key)[0][1] = 25675 + k;
1519 g_dist.template get<p::t>(key)[0][2] = 3117 + k;
1520 g_dist.template get<p::t>(key)[1][0] = 4921 + k;
1521 g_dist.template get<p::t>(key)[1][1] = 55675 + k;
1522 g_dist.template get<p::t>(key)[1][2] = 6117 + k;
1523 g_dist.template get<p::t>(key)[2][0] = 7921 + k;
1524 g_dist.template get<p::t>(key)[2][1] = 85675 + k;
1525 g_dist.template get<p::t>(key)[2][2] = 9117 + k;
1530 g_dist2.
copy(g_dist);
1537 while (dom2.isNext())
1539 auto key = dom2.get();
1540 auto key_g = g_dist.getGKey(key);
1542 size_t k = info.LinId(key_g);
1544 match &= (g_dist2.template get<p::x>(key) == 1 + k)?
true:false;
1545 match &= (g_dist2.template get<p::y>(key) == 567 + k)?
true:false;
1546 match &= (g_dist2.template get<p::z>(key) == 341 + k)?
true:false;
1547 match &= (g_dist2.template get<p::s>(key) == 5670 + k)?
true:false;
1548 match &= (g_dist2.template get<p::v>(key)[0] == 921 + k)?
true:false;
1549 match &= (g_dist2.template get<p::v>(key)[1] == 5675 + k)?
true:false;
1550 match &= (g_dist2.template get<p::v>(key)[2] == 117 + k)?
true:false;
1551 match &= (g_dist2.template get<p::t>(key)[0][0] == 1921 + k)?
true:false;
1552 match &= (g_dist2.template get<p::t>(key)[0][1] == 25675 + k)?
true:false;
1553 match &= (g_dist2.template get<p::t>(key)[0][2] == 3117 + k)?
true:false;
1554 match &= (g_dist2.template get<p::t>(key)[1][0] == 4921 + k)?
true:false;
1555 match &= (g_dist2.template get<p::t>(key)[1][1] == 55675 + k)?
true:false;
1556 match &= (g_dist2.template get<p::t>(key)[1][2] == 6117 + k)?
true:false;
1557 match &= (g_dist2.template get<p::t>(key)[2][0] == 7921 + k)?
true:false;
1558 match &= (g_dist2.template get<p::t>(key)[2][1] == 85675 + k)?
true:false;
1559 match &= (g_dist2.template get<p::t>(key)[2][2] == 9117 + k)?
true:false;
1564 BOOST_REQUIRE_EQUAL(match,
true);
1568void Test_ghost_correction(
Box<3,double> & domain,
long int k,
long int g_)
1570 size_t sz[3] = {(size_t)k,(
size_t)k,(size_t)k};
1577 auto itg =
grid.getDomainGhostIterator();
1579 while (itg.isNext())
1581 auto key = itg.get();
1583 grid.template get<0>(key) = 0.0;
1590 auto it =
grid.getDomainIterator();
1594 auto key = it.get();
1595 auto gkey = it.getGKey(key);
1597 if (gkey.get(0) == -4 && gkey.get(1) == 20 && gkey.get(2) == -4)
1599 grid.template get<0>(key) = 20.0;
1603 grid.template get<0>(key) = 5.0;
1609 grid.ghost_get<0>();
1610 auto it2 =
grid.getDomainGhostIterator();
1612 bool is_inside =
true;
1614 while (it2.isNext())
1616 auto key = it2.get();
1617 auto gkey = it2.getGKey(key);
1619 if (
grid.template get<0>(key) == 5.0)
1624 bool is_inside_point =
false;
1625 for (
size_t i = 0 ; i <
grid.getN_loc_grid() ; i++)
1628 bx +=
grid.getLocalGridsInfo().get(i).origin;
1632 if (bx.
isInside(gkey.toPoint()) ==
true)
1634 is_inside_point |=
true;
1638 is_inside &= is_inside_point;
1644 BOOST_REQUIRE_EQUAL(is_inside,
true);
1647void Test3D_copy(
const Box<3,float> & domain,
long int k)
1656 long int big_step = k / 30;
1657 big_step = (big_step == 0)?1:big_step;
1658 long int small_step = 21;
1660 print_test(
"Testing grid copy k<=",k);
1663 for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
1665 BOOST_TEST_CHECKPOINT(
"Testing grid periodick<=" << k );
1674 float factor = pow(create_vcluster().getProcessingUnits()/2.0f,1.0f/3.0f);
1689 auto dom = g_dist.getDomainIterator();
1691 while (dom.isNext())
1693 auto key = dom.get();
1694 auto key_g = g_dist.getGKey(key);
1696 size_t k = info.LinId(key_g);
1698 g_dist.template get<p::x>(key) = 1 + k;
1699 g_dist.template get<p::y>(key) = 567 + k;
1700 g_dist.template get<p::z>(key) = 341 + k;
1701 g_dist.template get<p::s>(key) = 5670 + k;
1702 g_dist.template get<p::v>(key)[0] = 921 + k;
1703 g_dist.template get<p::v>(key)[1] = 5675 + k;
1704 g_dist.template get<p::v>(key)[2] = 117 + k;
1705 g_dist.template get<p::t>(key)[0][0] = 1921 + k;
1706 g_dist.template get<p::t>(key)[0][1] = 25675 + k;
1707 g_dist.template get<p::t>(key)[0][2] = 3117 + k;
1708 g_dist.template get<p::t>(key)[1][0] = 4921 + k;
1709 g_dist.template get<p::t>(key)[1][1] = 55675 + k;
1710 g_dist.template get<p::t>(key)[1][2] = 6117 + k;
1711 g_dist.template get<p::t>(key)[2][0] = 7921 + k;
1712 g_dist.template get<p::t>(key)[2][1] = 85675 + k;
1713 g_dist.template get<p::t>(key)[2][2] = 9117 + k;
1719 g_dist2.template ghost_get<0>();
1726 while (dom2.isNext())
1728 auto key = dom2.get();
1729 auto key_g = g_dist.getGKey(key);
1731 size_t k = info.LinId(key_g);
1733 match &= (g_dist2.template get<p::x>(key) == 1 + k)?
true:false;
1734 match &= (g_dist2.template get<p::y>(key) == 567 + k)?
true:false;
1735 match &= (g_dist2.template get<p::z>(key) == 341 + k)?
true:false;
1736 match &= (g_dist2.template get<p::s>(key) == 5670 + k)?
true:false;
1737 match &= (g_dist2.template get<p::v>(key)[0] == 921 + k)?
true:false;
1738 match &= (g_dist2.template get<p::v>(key)[1] == 5675 + k)?
true:false;
1739 match &= (g_dist2.template get<p::v>(key)[2] == 117 + k)?
true:false;
1740 match &= (g_dist2.template get<p::t>(key)[0][0] == 1921 + k)?
true:false;
1741 match &= (g_dist2.template get<p::t>(key)[0][1] == 25675 + k)?
true:false;
1742 match &= (g_dist2.template get<p::t>(key)[0][2] == 3117 + k)?
true:false;
1743 match &= (g_dist2.template get<p::t>(key)[1][0] == 4921 + k)?
true:false;
1744 match &= (g_dist2.template get<p::t>(key)[1][1] == 55675 + k)?
true:false;
1745 match &= (g_dist2.template get<p::t>(key)[1][2] == 6117 + k)?
true:false;
1746 match &= (g_dist2.template get<p::t>(key)[2][0] == 7921 + k)?
true:false;
1747 match &= (g_dist2.template get<p::t>(key)[2][1] == 85675 + k)?
true:false;
1748 match &= (g_dist2.template get<p::t>(key)[2][2] == 9117 + k)?
true:false;
1753 BOOST_REQUIRE_EQUAL(match,
true);
1758BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use_2D)
1763#ifdef TEST_COVERAGE_MODE
1764 long int k = 256*256*create_vcluster().getProcessingUnits();
1766 long int k = 1024*1024*create_vcluster().getProcessingUnits();
1768 k = std::pow(k, 1/2.);
1771 Test2D_complex(domain,k);
1774BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use_3D)
1779 size_t k = 128*128*128*create_vcluster().getProcessingUnits();
1780 k = std::pow(k, 1/3.);
1782 Test3D_complex(domain3,k);
1785BOOST_AUTO_TEST_CASE( grid_dist_id_dup)
1790 long int k = 128*128*128*create_vcluster().getProcessingUnits();
1791 k = std::pow(k, 1/3.);
1792 Test3D_dup(domain3,k);
1795BOOST_AUTO_TEST_CASE( grid_dist_id_sub)
1800 long int k = 128*128*128*create_vcluster().getProcessingUnits();
1801 k = std::pow(k, 1/3.);
1802 Test3D_sub(domain3,k);
1806BOOST_AUTO_TEST_CASE( grid_dist_id_with_grid_unit_ghost )
1811 long int k = 1024*1024*create_vcluster().getProcessingUnits();
1812 k = std::pow(k, 1/2.);
1817 k = 128*128*128*create_vcluster().getProcessingUnits();
1818 k = std::pow(k, 1/3.);
1819 Test3D_gg(domain3,k,1);
1823BOOST_AUTO_TEST_CASE( grid_dist_id_domain_test_use)
1831 long int k = 128*128*128*create_vcluster().getProcessingUnits();
1832 k = std::pow(k, 1/3.);
1833 Test3D_domain(domain3,k,np);
1835 auto & v_cl = create_vcluster();
1841 for (
size_t i = 0 ; i < 10 ; i++)
1845 Test3D_domain(domain3,128,p);
1849BOOST_AUTO_TEST_CASE( grid_dist_id_extended )
1854 long int k = 128*128*128*create_vcluster().getProcessingUnits();
1855 k = std::pow(k, 1/3.);
1857 Test3D_extended_grid(domain3,k);
1860BOOST_AUTO_TEST_CASE( grid_dist_id_periodic )
1865 long int k = 128*128*128*create_vcluster().getProcessingUnits();
1866 k = std::pow(k, 1/3.);
1868 Test3D_periodic(domain3,k);
1871BOOST_AUTO_TEST_CASE( grid_dist_id_unbound_ghost )
1876 long int k = 28*28*28*create_vcluster().getProcessingUnits();
1877 k = std::pow(k, 1/3.);
1879 Test3D_unb_ghost(domain3,k);
1882BOOST_AUTO_TEST_CASE( grid_dist_id_unbound_ghost_periodic )
1887 long int k = 25*25*25*create_vcluster().getProcessingUnits();
1888 k = std::pow(k, 1/3.);
1890 Test3D_unb_ghost_periodic(domain3,k);
1893BOOST_AUTO_TEST_CASE( grid_dist_id_copy )
1898 long int k = 32*32*32*create_vcluster().getProcessingUnits();
1899 k = std::pow(k, 1/3.);
1901 Test_grid_copy(domain3,k);
1904BOOST_AUTO_TEST_CASE( grid_1d_test )
1909 long int k = 32*32*32*create_vcluster().getProcessingUnits();
1914BOOST_AUTO_TEST_CASE( grid_dist_id_periodic_put_test )
1919 long int k = 128*128*128*create_vcluster().getProcessingUnits();
1920 k = std::pow(k, 1/3.);
1922 Test3D_periodic_put(domain3,k);
1925BOOST_AUTO_TEST_CASE ( grid_ghost_correction )
1931 Test_ghost_correction(domain,k,1);
1932 Test_ghost_correction(domain,k,2);
1933 Test_ghost_correction(domain,k,3);
1934 Test_ghost_correction(domain,k,4);
1938 Test_ghost_correction(domain,k,1);
1939 Test_ghost_correction(domain,k,2);
1940 Test_ghost_correction(domain,k,3);
1941 Test_ghost_correction(domain,k,4);
1945 Test_ghost_correction(domain,k,1);
1946 Test_ghost_correction(domain,k,2);
1947 Test_ghost_correction(domain,k,3);
1948 Test_ghost_correction(domain,k,4);
1952 Test_ghost_correction(domain,k,1);
1953 Test_ghost_correction(domain,k,2);
1954 Test_ghost_correction(domain,k,3);
1955 Test_ghost_correction(domain,k,4);
1958BOOST_AUTO_TEST_CASE ( grid_basic_functions )
1960 auto & v_cl = create_vcluster();
1965 size_t sz[2] = {(size_t)8,(
size_t)8};
1973 BOOST_REQUIRE_EQUAL(
grid.getOffset(0)[0],-1.25);
1974 BOOST_REQUIRE_EQUAL(
grid.getOffset(0)[1],-1.25);
1977BOOST_AUTO_TEST_CASE ( grid_overflow_round_off_error )
1979 size_t numGridPoint = 100;
1980 const double domainSize = 20851.7;
1981 double domainLength = sqrt(domainSize);
1983 Box<2,double> domain({0.0,0.0},{domainLength,domainLength});
1985 size_t sz[2] = {numGridPoint,numGridPoint};
1989 Ghost<2,double> g(3.0*(domain.getHigh(0) - domain.getLow(0))/numGridPoint + 0.001);
1993 auto & gs =
grid.getGridInfo();
1995 auto it =
grid.getDomainIterator();
2000 auto gp = it.getGKey(p);
2002 grid.get<0>(p) = gs.LinId(gp);
2007 grid.ghost_get<0>();
2011 auto it2 =
grid.getDomainIterator();
2015 while (it2.isNext())
2018 auto gp = it.getGKey(p);
2020 if (gs.LinId(gp) !=
grid.get<0>(p))
2025 auto px = p.move(0,1);
2026 auto gpx = it.getGKey(px);
2027 auto mx = p.move(0,-1);
2028 auto gmx = it.getGKey(mx);
2030 auto py = p.move(1,1);
2031 auto gpy = it.getGKey(py);
2032 auto my = p.move(1,-1);
2033 auto gmy = it.getGKey(my);
2035 gpx.set_d(0,gpx.get(0) % gs.size(0));
2036 gpx.set_d(1,gpx.get(1) % gs.size(1));
2038 if (
grid.template get<0>(px) != gs.LinId(gpx))
2041 gmx.set_d(0,(gmx.get(0) + gs.size(0)) % gs.size(0));
2042 gmx.set_d(1,(gmx.get(1) + gs.size(1)) % gs.size(1));
2044 if (
grid.template get<0>(mx) != gs.LinId(gmx))
2047 gpy.set_d(0,gpy.get(0) % gs.size(0));
2048 gpy.set_d(1,gpy.get(1) % gs.size(1));
2050 if (
grid.template get<0>(py) != gs.LinId(gpy))
2053 gmy.set_d(0,(gmy.get(0) + gs.size(0)) % gs.size(0));
2054 gmy.set_d(1,(gmy.get(1) + gs.size(1)) % gs.size(1));
2056 if (
grid.template get<0>(my) != gs.LinId(gmy))
2062 BOOST_REQUIRE_EQUAL(match,
true);
2065BOOST_AUTO_TEST_CASE( grid_dist_id_copy_test )
2070 long int k = 128*128*128*create_vcluster().getProcessingUnits();
2071 k = std::pow(k, 1/3.);
2073 Test3D_copy(domain3,k);
2077template<
typename gr
id_amr>
2078void Test3D_ghost_put(grid_amr & g_dist_amr,
long int k)
2081 bool val = g_dist_amr.getDecomposition().check_consistency();
2082 BOOST_REQUIRE_EQUAL(val,
true);
2084 size_t sz[3] = {(size_t)k,(
size_t)k,(size_t)k};
2091 auto dom = g_dist_amr.getGridIterator();
2093 while (dom.isNext())
2095 auto key = dom.get_dist();
2097 g_dist_amr.template insert<0>(key) = -6.0;
2108 auto dom = g_dist_amr.getDomainIterator();
2110 while (dom.isNext())
2112 auto key = dom.get();
2114 g_dist_amr.template insert<0>(key.move(0,1)) += 1.0;
2115 g_dist_amr.template insert<0>(key.move(0,-1)) += 1.0;
2116 g_dist_amr.template insert<0>(key.move(1,1)) += 1.0;
2117 g_dist_amr.template insert<0>(key.move(1,-1)) += 1.0;
2118 g_dist_amr.template insert<0>(key.move(2,1)) += 1.0;
2119 g_dist_amr.template insert<0>(key.move(2,-1)) += 1.0;
2125 bool correct =
true;
2128 auto dom_gi = g_dist_amr.getDomainIterator();
2130 while (dom_gi.isNext())
2132 auto key = dom_gi.get();
2134 correct &= (g_dist_amr.template get<0>(key) == 0);
2139 g_dist_amr.template ghost_put<add_,0>();
2142 {BOOST_REQUIRE_EQUAL(correct,
false);}
2145 g_dist_amr.template ghost_get<0>();
2150 auto dom_gi2 = g_dist_amr.getDomainIterator();
2152 while (dom_gi2.isNext())
2154 auto key = dom_gi2.get();
2156 correct &= (g_dist_amr.template get<0>(key) == 0);
2161 BOOST_REQUIRE_EQUAL(correct,
true);
2164BOOST_AUTO_TEST_CASE( grid_dist_domain_ghost_put_check )
2172 if ( v_cl.getProcessingUnits() > 32 )
2177 BOOST_TEST_CHECKPOINT(
"Testing grid periodic k<=" << k );
2194 Test3D_ghost_put(g_dist,k);
2199 Test3D_ghost_put(sg_dist,k);
2203template<
typename gr
id_amr>
2204void TestXD_ghost_put_create(grid_amr & g_dist_amr,
long int k)
2207 bool val = g_dist_amr.getDecomposition().check_consistency();
2208 BOOST_REQUIRE_EQUAL(val,
true);
2212 auto dom = g_dist_amr.getGridIterator();
2214 while (dom.isNext())
2216 auto key = dom.get_dist();
2218 g_dist_amr.template insert<1>(key) = 1;
2227 g_dist_amr.template ghost_get<1>();
2233 auto itg = g_dist_amr.getDomainGhostIterator();
2235 while (itg.isNext())
2243 auto it = g_dist_amr.getDomainIterator();
2249 g_dist_amr.remove_no_flush(p);
2255 g_dist_amr.flush_remove();
2262 auto it = g_dist_amr.getDomainIterator();
2272 BOOST_REQUIRE_EQUAL(cnt,0ul);
2275 g_dist_amr.template ghost_put<add_,1>();
2278 auto it = g_dist_amr.getDomainIterator();
2287 cnt += g_dist_amr.template get<1>(p);
2289 check &= (g_dist_amr.template get<1>(p) >= 1);
2295 auto & v_cl = create_vcluster();
2302 BOOST_REQUIRE_EQUAL(g_point,cnt);
2303 BOOST_REQUIRE_EQUAL(check,
true);
2309 auto it = g_dist_amr.getDomainIterator();
2315 g_dist_amr.remove_no_flush(p);
2320 g_dist_amr.flush_remove();
2323 auto it2 = g_dist_amr.getDomainGhostIterator();
2325 while (it2.isNext())
2333 BOOST_REQUIRE(cnt != 0);
2335 g_dist_amr.template ghost_get<1>();
2338 auto it3 = g_dist_amr.getDomainGhostIterator();
2340 while (it3.isNext())
2347 BOOST_REQUIRE_EQUAL(cnt,0ul);
2352BOOST_AUTO_TEST_CASE( grid_dist_domain_ghost_2D_put_create_check )
2360 if ( v_cl.getProcessingUnits() > 32 )
2365 BOOST_TEST_CHECKPOINT(
"Testing grid periodic k<=" << k );
2381 TestXD_ghost_put_create(sg_dist,k);
2390 TestXD_ghost_put_create(sg_dist2,k);
2399 TestXD_ghost_put_create(sg_dist3,k);
2402BOOST_AUTO_TEST_CASE( grid_dist_domain_ghost_3D_put_create_check )
2410 if ( v_cl.getProcessingUnits() > 32 )
2415 BOOST_TEST_CHECKPOINT(
"Testing grid periodic k<=" << k );
2432 TestXD_ghost_put_create(sg_dist,k);
2442 TestXD_ghost_put_create(sg_dist2,k);
2452 TestXD_ghost_put_create(sg_dist3,k);
2456BOOST_AUTO_TEST_CASE( grid_dist_ghost_zero_size )
2464 if ( v_cl.getProcessingUnits() > 32 )
2467 BOOST_TEST_CHECKPOINT(
"Testing grid zero ghost");
2484 auto it = g_dist.getDomainIterator();
2500 BOOST_REQUIRE_EQUAL(count,53*53*10);
2504BOOST_AUTO_TEST_CASE(grid_dist_id_smb_write_out_1_proc)
2512 if ( v_cl.getProcessingUnits() > 1 )
2531 auto it = g_smb.getDomainIterator();
2535 unsigned char * base = (
unsigned char *)g_smb.get_loc_grid(0).getPointer<0>();
2541 g_smb.template getProp<0>(k) = (
unsigned char *)&g_smb.template getProp<0>(k) - base;
2551 BOOST_REQUIRE_EQUAL(count,16*16);
2553 g_smb.write(
"g_smb_out");
2557BOOST_AUTO_TEST_CASE(grid_dist_id_zmb_write_out_1_proc)
2566 if ( v_cl.getProcessingUnits() > 1 )
2585 auto it = g_smb.getDomainIterator();
2589 unsigned char * base = (
unsigned char *)g_smb.get_loc_grid(0).getPointer<0>();
2595 g_smb.template getProp<0>(k) = (
unsigned char *)&g_smb.template getProp<0>(k) - base;
2605 BOOST_REQUIRE_EQUAL(count,16*16);
2607 g_smb.write(
"g_zmb_out");
2615 if ( v_cl.getProcessingUnits() > 1 )
2634 auto it = g_smb.getDomainIterator();
2638 unsigned char * base = (
unsigned char *)g_smb.get_loc_grid(0).getPointer<0>();
2644 g_smb.template getProp<0>(k) = (
unsigned char *)&g_smb.template getProp<0>(k) - base;
2654 BOOST_REQUIRE_EQUAL(count,16*16);
2656 g_smb.write(
"g_zm_out");
2664 if ( v_cl.getProcessingUnits() > 1 )
2683 auto it = g_smb.getDomainIterator();
2687 unsigned char * base = (
unsigned char *)g_smb.get_loc_grid(0).getPointer<0>();
2693 g_smb.template getProp<0>(k) = (
unsigned char *)&g_smb.template getProp<0>(k) - base;
2703 BOOST_REQUIRE_EQUAL(count,16*16);
2705 g_smb.write(
"g_sm_out");
2709BOOST_AUTO_TEST_CASE( grid_dist_copy_construct )
2717 if ( v_cl.getProcessingUnits() > 32 )
2720 BOOST_TEST_CHECKPOINT(
"Testing grid zero ghost");
2738 auto & gs = g_dist.getGridInfoVoid();
2739 auto it = g_dist.getDomainIterator();
2746 auto gkey = it.getGKey(k);
2748 g_dist.get<0>(k) = gs.LinId(gkey);
2753 g_dist.template ghost_get<0>();
2760 while (it2.isNext())
2765 g_dist2.template get<0>(k) = g_dist.template get<0>(k) + 1;
2766 g_dist3.template get<0>(k) = g_dist.template get<0>(k) + 2;
2771 g_dist2.template ghost_get<0>();
2772 g_dist3.template ghost_get<0>();
2776 auto it3 = g_dist.getDomainIterator();
2778 while (it3.isNext())
2781 auto gkey = it3.getGKey(k);
2783 match &= g_dist2.template get<0>(k) == g_dist.template get<0>(k) + 1;
2784 match &= g_dist3.template get<0>(k) == g_dist.template get<0>(k) + 2;
2789 BOOST_REQUIRE_EQUAL(match,
true);
2792BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
__host__ __device__ bool isInside(const Point< dim, T > &p) const
Check if the point is inside the box.
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
bool isValid() const
Check if the Box is a valid box P2 >= P1.
T getVolumeKey() const
Get the volume spanned by the Box P1 and P2 interpreted as grid key.
This class decompose a space into sub-sub-domains and distribute them across processors.
Test structure used for several test.
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.
bool allGather(T &send, openfpm::vector< T, Mem, gr > &v)
Gather the data from all processors.
Implementation of VCluster class.
This is a distributed grid.
Decomposition & getDecomposition()
Get the object that store the information about the decomposition.
grid_key_dx< dim > getGKey(const grid_dist_key_dx< dim > &k) const
Convert a g_dist_key_dx into a global key.
grid_dist_iterator< dim, device_grid, decltype(device_grid::type_of_subiterator()), FREE > getDomainIterator() const
It return an iterator that span the full grid domain (each processor span its local domain)
auto get(const grid_dist_key_dx< dim, bg_key > &v1) const -> typename std::add_lvalue_reference< decltype(loc_grid.get(v1.getSub()).template get< p >(v1.getKey()))>::type
Get the reference of the selected element.
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.
grid_key_dx is the key to access any element in the grid
__device__ __host__ index_type get(index_type i) const
Get the i index.
class that store the information of the grid like number of point on each direction and define the in...
Implementation of 1-D std::vector like structure.
This structure define the operation add to use with copy general.