OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
grid_dist_id_util_tests.hpp
1/*
2 * grid_dist_id_util_tests.hpp
3 *
4 * Created on: Oct 15, 2017
5 * Author: i-bird
6 */
7
8#ifndef SRC_GRID_TESTS_GRID_DIST_ID_UTIL_TESTS_HPP_
9#define SRC_GRID_TESTS_GRID_DIST_ID_UTIL_TESTS_HPP_
10
11
12static void print_test(std::string test, size_t sz)
13{
14 if (create_vcluster().getProcessUnitID() == 0)
15 std::cout << test << " " << sz << "\n";
16}
17
18
19static void Test2D_core(grid_dist_id<2, float, aggregate<double>> & g_dist, const size_t (& sz)[2], size_t k)
20{
21 // check the consistency of the decomposition
22 bool val = g_dist.getDecomposition().check_consistency();
23 BOOST_REQUIRE_EQUAL(val,true);
24
25 // Grid sm
26 grid_sm<2,void> info(sz);
27
28 // get the domain iterator
29 size_t count = 0;
30
31 auto dom = g_dist.getDomainIterator();
32
33 while (dom.isNext())
34 {
35 auto key = dom.get();
36 auto key_g = g_dist.getGKey(key);
37
38 g_dist.template get<0>(key) = info.LinId(key_g);
39
40 // Count the point
41 count++;
42
43 ++dom;
44 }
45
47
48 // Get the virtual cluster machine
49 Vcluster<> & vcl = g_dist.getVC();
50
51 // reduce
52 vcl.sum(count);
53 vcl.execute();
54
55 // Check
56 BOOST_REQUIRE_EQUAL(count,(size_t)k*k);
57
58 auto dom2 = g_dist.getDomainIterator();
59
60 grid_key_dx<2> start = dom2.getStart();
61 grid_key_dx<2> stop = dom2.getStop();
62
63 BOOST_REQUIRE_EQUAL((long int)stop.get(0),(long int)g_dist.size(0)-1);
64 BOOST_REQUIRE_EQUAL((long int)stop.get(1),(long int)g_dist.size(1)-1);
65
66 BOOST_REQUIRE_EQUAL(start.get(0),0);
67 BOOST_REQUIRE_EQUAL(start.get(1),0);
68
69 bool match = true;
70
71 // check that the grid store the correct information
72 while (dom2.isNext())
73 {
74 auto key = dom2.get();
75 auto key_g = g_dist.getGKey(key);
76
77 match &= (g_dist.template get<0>(key) == info.LinId(key_g))?true:false;
78
79 ++dom2;
80 }
81
82 BOOST_REQUIRE_EQUAL(match,true);
83
84 g_dist.template ghost_get<0>();
85
86 // check that the communication is correctly completed
87
88 auto domg = g_dist.getDomainGhostIterator();
89
90 // check that the grid with the ghost part store the correct information
91 while (domg.isNext())
92 {
93 auto key = domg.get();
94 auto key_g = g_dist.getGKey(key);
95
96 // In this case the boundary condition are non periodic
97 if (g_dist.isInside(key_g))
98 {
99 match &= (g_dist.template get<0>(key) == info.LinId(key_g))?true:false;
100 }
101
102 ++domg;
103 }
104
105 BOOST_REQUIRE_EQUAL(match,true);
106}
107
108#endif /* SRC_GRID_TESTS_GRID_DIST_ID_UTIL_TESTS_HPP_ */
void execute()
Execute all the requests.
void sum(T &num)
Sum the numbers across all processors and get the result.
Implementation of VCluster class.
Definition VCluster.hpp:59
This is a distributed grid.
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
__device__ __host__ index_type get(index_type i) const
Get the i index.
Definition grid_key.hpp:503
Declaration grid_sm.
Definition grid_sm.hpp:167
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...