OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
grid_dist_testing.hpp
1 /*
2  * grid_dist_testing.hpp
3  *
4  * Created on: Oct 28, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_NUMERICS_SRC_UTIL_GRID_DIST_TESTING_HPP_
9 #define OPENFPM_NUMERICS_SRC_UTIL_GRID_DIST_TESTING_HPP_
10 
11 #include "Grid/grid_dist_key.hpp"
12 
13 template<unsigned int dim>
15 {
17 
18 public:
19 
25  grid_dist_testing(const size_t (& g_sz)[dim])
26  :grid_test(g_sz)
27  {
28  grid_test.setMemory();
29 
30  // We fill the testing map
31 
32  auto dom = grid_test.getIterator();
33  const auto & gs = grid_test.getGrid();
34 
35  while (dom.isNext())
36  {
37  auto key = dom.get();
38 
39  grid_test.template get<0>(key) = gs.LinId(key);
40 
41  ++dom;
42  }
43  }
44 
50  template <unsigned int p> size_t get(const grid_dist_key_dx<dim> & key) const
51  {
52  if (p != 0)
53  std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " mapping grid is suppose to have only one scalar size_t \n";
54 
55  return grid_test.template get<0>(key.getKey());
56  }
57 
64  {
65  return key.getKey();
66  }
67 };
68 
69 
70 #endif /* OPENFPM_NUMERICS_SRC_UTIL_GRID_DIST_TESTING_HPP_ */
grid_key_dx is the key to access any element in the grid
Definition: grid_key.hpp:18
Grid key for a distributed grid.
grid_dist_testing(const size_t(&g_sz)[dim])
It create a test map suitable for testing.
This class is a trick to indicate the compiler a specific specialization pattern. ...
Definition: memory_c.hpp:201
grid_key_dx< dim > getGKey(const grid_dist_key_dx< dim > &key) const
Return the global key.
grid_key_dx< dim > getKey() const
Get the key.