OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
Domain_NN_calculator_cart_unit_test.hpp
1 /*
2  * Domain_NN_calculator_cart_unit_test.hpp
3  *
4  * Created on: Mar 11, 2017
5  * Author: i-bird
6  */
7 
8 #ifndef SRC_DECOMPOSITION_DOMAIN_NN_CALCULATOR_CART_UNIT_TEST_CPP_
9 #define SRC_DECOMPOSITION_DOMAIN_NN_CALCULATOR_CART_UNIT_TEST_CPP_
10 
11 #include "VCluster/VCluster.hpp"
12 #include "Domain_NN_calculator_cart.hpp"
13 #include "NN/CellList/CellList.hpp"
14 
15 BOOST_AUTO_TEST_SUITE (Domain_NN_cart_unit_test)
16 
17 BOOST_AUTO_TEST_CASE( Domain_NN_cart_unit_test_usage )
18 {
20 
21  Box<3,long int> pbox({20,30,40},{40,50,60});
22 
24  loc_box.add(Box<3,size_t>({21,31,41},{30,40,50}));
25  loc_box.add(Box<3,size_t>({31,41,51},{39,49,59}));
26 
27  size_t sz[3];
28  sz[0] = pbox.getHigh(0) - pbox.getLow(0) + 1;
29  sz[1] = pbox.getHigh(1) - pbox.getLow(1) + 1;
30  sz[2] = pbox.getHigh(2) - pbox.getLow(2) + 1;
31 
32  grid_sm<3,void> gs2(sz);
33  grid_key_dx<3> shift({5,5,5});
34 
35  dnn.setParameters(pbox);
36  dnn.setNNParameters(loc_box,shift,gs2);
37 
38  // Linearized domain cell over pbox
42 
43  grid_sm<3,void> gs(sz);
44 
45  size_t tot_cl = 0;
46  for (size_t i = 0 ; i < loc_box.size() ; i++)
47  tot_cl += Box<3,size_t>(loc_box.get(i)).getVolumeKey();
48 
49  BOOST_REQUIRE_EQUAL(cd.size(),tot_cl);
50 
51  Box<3,size_t> box0 = loc_box.get(0);
52 
53  size_t dom_cell = (box0.getHigh(0) - box0.getLow(0)) *
54  (box0.getHigh(1) - box0.getLow(1)) *
55  (box0.getHigh(2) - box0.getLow(2) + 1);
56 
57  Box<3,size_t> box1 = loc_box.get(1);
58 
59  dom_cell += (box1.getHigh(0) - box1.getLow(0)) *
60  (box1.getHigh(1) - box1.getLow(1)) *
61  (box1.getHigh(2) - box1.getLow(2) + 1);
62 
63  BOOST_REQUIRE_EQUAL(cdCSRdom.size(),dom_cell);
64 
65  size_t anom_cell = 2*(box0.getHigh(0) - box0.getLow(0) + 1) * ((box0.getHigh(2) - box0.getLow(2)) + 1);
66  anom_cell += 2*(box1.getHigh(0) - box1.getLow(0) + 1) * ((box1.getHigh(2) - box1.getLow(2)) + 1);
67 
68  anom_cell += 2*(box0.getHigh(1) - box0.getLow(1) + 1) * ((box0.getHigh(2) - box0.getLow(2)) + 1);
69  anom_cell += 2*(box1.getHigh(1) - box1.getLow(1) + 1) * ((box1.getHigh(2) - box1.getLow(2)) + 1);
70 
71  BOOST_REQUIRE_EQUAL(cdCSRanom.size(),anom_cell);
72 }
73 
74 BOOST_AUTO_TEST_SUITE_END()
75 
76 
77 #endif /* SRC_DECOMPOSITION_DOMAIN_NN_CALCULATOR_CART_UNIT_TEST_CPP_ */
openfpm::vector< subsub_lin< dim > > & getCRSAnomDomainCells()
Get the domain anomalous cells.
void setParameters(const Box< dim, long int > &proc_box)
Set parameters to calculate the cell neighborhood.
T getLow(int i) const
get the i-coordinate of the low bound interval of the box
Definition: Box.hpp:479
grid_key_dx is the key to access any element in the grid
Definition: grid_key.hpp:18
void setNNParameters(openfpm::vector<::Box< dim, size_t >> &loc_box, const grid_key_dx< dim > &shift, const grid_sm< dim, void > &gs)
Set parameters to calculate the cell neighborhood.
T getHigh(int i) const
get the high interval of the box
Definition: Box.hpp:490
size_t size()
Stub size.
Definition: map_vector.hpp:70
openfpm::vector< size_t > & getCRSDomainCells()
Get the domain Cells.
openfpm::vector< size_t > & getDomainCells()
Get the domain Cells.
This class represent an N-dimensional box.
Definition: Box.hpp:56
Declaration grid_sm.
Definition: grid_sm.hpp:71
This class calculate processor domains and neighborhood of each processor domain. ...
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61