OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
staggered_grid_dist_unit_test.cpp
1/*
2 * staggered_grid_unit_test.hpp
3 *
4 * Created on: Aug 20, 2015
5 * Author: i-bird
6 */
7
8#define BOOST_TEST_DYN_LINK
9#include <boost/test/unit_test.hpp>
10
11#include "Grid/staggered_dist_grid.hpp"
12#include "Point_test.hpp"
13
14BOOST_AUTO_TEST_SUITE( staggered_grid_dist_id_test )
15
16
17BOOST_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>({(char)0,(char)0}));
45 BOOST_REQUIRE(cmbs[1].get(0) == comb<2>({(char)0,(char)0}));
46 BOOST_REQUIRE(cmbs[2].get(0) == comb<2>({(char)0,(char)0}));
47 BOOST_REQUIRE(cmbs[3].get(0) == comb<2>({(char)0,(char)0}));
48 BOOST_REQUIRE(cmbs[4].get(0) == comb<2>({(char)0,(char)-1}));
49 BOOST_REQUIRE(cmbs[4].get(1) == comb<2>({(char)-1,(char)0}));
50 BOOST_REQUIRE(cmbs[5].get(0) == comb<2>({(char)0,(char)0}));
51 BOOST_REQUIRE(cmbs[5].get(1) == comb<2>({(char)-1,(char)-1}));
52 BOOST_REQUIRE(cmbs[5].get(2) == comb<2>({(char)-1,(char)-1}));
53 BOOST_REQUIRE(cmbs[5].get(3) == comb<2>({(char)0,(char)0}));
54}
55
56BOOST_AUTO_TEST_SUITE_END()
57
This class represent an N-dimensional box.
Definition Box.hpp:61
This class decompose a space into sub-sub-domains and distribute them across processors.
Implementation of 1-D std::vector like structure.
Implementation of the staggered grid.
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition comb.hpp:35