1 #include <libgeodecomp/config.h>
2 #include <libgeodecomp/communication/mpilayer.h>
3 #include <libgeodecomp/geometry/partitions/ptscotchpartition.h>
4 
5 #include <iostream>
6 
7 using namespace LibGeoDecomp;
8 
9 namespace LibGeoDecomp {
10 
11 class PTScotchPartitionTest : public CxxTest::TestSuite
12 {
13 public:
testComplete3D()14     void testComplete3D()
15     {
16 #ifdef LIBGEODECOMP_WITH_SCOTCH
17         Coord<3> origin(10, 10, 10);
18         Coord<3> dimensions(123,26,27);
19         std::vector<std::size_t> weights;
20         weights << 100 << 100 << 100 << 100;
21         PTScotchPartition<3> p(origin, dimensions, 0, weights);
22         Region<3> expected0;
23 
24         expected0 << CoordBox<3>(Coord<3>(10,10,10), Coord<3>(123,26,27));
25 
26         Region<3> complete = p.getRegion(0)
27             + p.getRegion(1)
28             + p.getRegion(2)
29             + p.getRegion(3);
30 
31         TS_ASSERT_EQUALS(expected0, complete);
32 #endif
33      }
34 
testOverlapse3D()35      void testOverlapse3D()
36      {
37 #ifdef LIBGEODECOMP_WITH_SCOTCH
38         Coord<3> origin(0, 0);
39         Coord<3> dimensions(28,231,52);
40         std::vector<std::size_t> weights;
41         weights << 100 << 100 << 100 << 100;
42         PTScotchPartition<3> p(origin, dimensions, 0, weights);
43 
44         Region<3> expected0;
45 
46         expected0 << CoordBox<3>(Coord<3>(0,0), Coord<3>(0,0));
47 
48         Region<3> cut = p.getRegion(0)
49             & p.getRegion(1)
50             & p.getRegion(2)
51             & p.getRegion(3);
52 
53         TS_ASSERT_EQUALS(expected0, cut);
54 #endif
55      }
56 
57 
testEqual2D()58     void testEqual2D()
59     {
60 #ifdef LIBGEODECOMP_WITH_SCOTCH
61         Coord<2> origin(0, 0);
62         Coord<2> dimensions(1023,511);
63         std::vector<std::size_t> weights;
64         weights << 100 << 100 << 100 << 100;
65         PTScotchPartition<2> p(origin, dimensions, 0, weights);
66         std::size_t sizeRegion0 = p.getRegion(0).size();
67         std::size_t compSize;
68 
69         for(unsigned int i = 1 ; i < weights.size() ; ++i){
70             compSize = p.getRegion(i).size();
71             TS_ASSERT(sizeRegion0 == compSize ||
72                       sizeRegion0 == compSize - 1 ||
73                       sizeRegion0 == compSize + 1);
74         }
75 #endif
76     }
77 
testComplete2D()78     void testComplete2D()
79     {
80 #ifdef LIBGEODECOMP_WITH_SCOTCH
81         Coord<2> origin(10, 10);
82         Coord<2> dimensions(543,234);
83         std::vector<std::size_t> weights;
84         weights << 100 << 100 << 100 << 100;
85         PTScotchPartition<2> p(origin, dimensions, 0, weights);
86         Region<2> expected0;
87 
88         expected0 << CoordBox<2>(Coord<2>(10,10), Coord<2>(543,234));
89 
90         Region<2> complete = p.getRegion(0)
91             + p.getRegion(1)
92             + p.getRegion(2)
93             + p.getRegion(3);
94 
95         TS_ASSERT_EQUALS(expected0, complete);
96 #endif
97      }
98 
testOverlapse2D()99      void testOverlapse2D()
100      {
101 #ifdef LIBGEODECOMP_WITH_SCOTCH
102         Coord<2> origin(0, 0);
103         Coord<2> dimensions(128, 231);
104         std::vector<std::size_t> weights;
105         weights << 100 << 100 << 100 << 100;
106         PTScotchPartition<2> p(origin, dimensions, 0, weights);
107 
108         Region<2> expected0;
109 
110         expected0 << CoordBox<2>(Coord<2>(0,0), Coord<2>(0,0));
111 
112         Region<2> cut = p.getRegion(0)
113             & p.getRegion(1)
114             & p.getRegion(2)
115             & p.getRegion(3);
116 
117         TS_ASSERT_EQUALS(expected0, cut);
118 #endif
119      }
120 };
121 
122 }
123