OpenFPM_pdata  1.0.0
Project that contain the implementation of distributed structures
 All Data Structures Functions Variables Typedefs Enumerations Friends Pages
staggered_grid_dist_unit_test.hpp
1 /*
2  * staggered_grid_unit_test.hpp
3  *
4  * Created on: Aug 20, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef SRC_GRID_STAGGERED_GRID_DIST_UNIT_TEST_HPP_
9 #define SRC_GRID_STAGGERED_GRID_DIST_UNIT_TEST_HPP_
10 
11 #include "staggered_dist_grid.hpp"
12 #include "Point_test.hpp"
13 
14 BOOST_AUTO_TEST_SUITE( staggered_grid_dist_id_test )
15 
16 
17 BOOST_AUTO_TEST_CASE( staggered_grid_dist_unit_test)
18 {
19  // Domain
20  Box<2,float> domain({0.0,0.0},{1.0,1.0});
21 
22  size_t k = 1024;
23 
24  // grid size
25  size_t sz[2] = {k,k};
26 
27  // Ghost
28  Ghost<2,float> g(0.0);
29 
31  sg.setDefaultStagPosition();
32 
33  // We check that the staggered position is correct
34  const openfpm::vector<comb<2>> (& cmbs)[6] = sg.getStagPositions();
35 
36 
37  BOOST_REQUIRE_EQUAL(cmbs[0].size(),1ul);
38  BOOST_REQUIRE_EQUAL(cmbs[1].size(),1ul);
39  BOOST_REQUIRE_EQUAL(cmbs[2].size(),1ul);
40  BOOST_REQUIRE_EQUAL(cmbs[3].size(),1ul);
41  BOOST_REQUIRE_EQUAL(cmbs[4].size(),2ul);
42  BOOST_REQUIRE_EQUAL(cmbs[5].size(),4ul);
43 
44  BOOST_REQUIRE(cmbs[0].get(0) == comb<2>({0,0}));
45  BOOST_REQUIRE(cmbs[1].get(0) == comb<2>({0,0}));
46  BOOST_REQUIRE(cmbs[2].get(0) == comb<2>({0,0}));
47  BOOST_REQUIRE(cmbs[3].get(0) == comb<2>({0,0}));
48  BOOST_REQUIRE(cmbs[4].get(0) == comb<2>({0,-1}));
49  BOOST_REQUIRE(cmbs[4].get(1) == comb<2>({-1,0}));
50  BOOST_REQUIRE(cmbs[5].get(0) == comb<2>({0,0}));
51  BOOST_REQUIRE(cmbs[5].get(1) == comb<2>({-1,-1}));
52  BOOST_REQUIRE(cmbs[5].get(2) == comb<2>({-1,-1}));
53  BOOST_REQUIRE(cmbs[5].get(3) == comb<2>({0,0}));
54 }
55 
56 BOOST_AUTO_TEST_SUITE_END()
57 
58 #endif /* SRC_GRID_STAGGERED_GRID_DIST_UNIT_TEST_HPP_ */
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition: comb.hpp:34
Definition: Ghost.hpp:37
This class decompose a space into sub-sub-domains and distribute them across processors.
Implementation of the staggered grid.
This class represent an N-dimensional box.
Definition: Box.hpp:56
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61