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#include "Grid/grid_dist_key.hpp"
13#include "Grid/map_grid.hpp"
14
15template<unsigned int dim>
16class grid_dist_testing
17{
18 grid_cpu<dim,aggregate<size_t>> grid_test;
19
20public:
21
22 /*! \brief It create a test map suitable for testing
23 *
24 * \param size of the grid with padding
25 *
26 */
27 grid_dist_testing(const size_t (& g_sz)[dim])
28 :grid_test(g_sz)
29 {
30 grid_test.setMemory();
31
32 // We fill the testing map
33
34 auto dom = grid_test.getIterator();
35 const auto & gs = grid_test.getGrid();
36
37 while (dom.isNext())
38 {
39 auto key = dom.get();
40
41 grid_test.template get<0>(key) = gs.LinId(key);
42
43 ++dom;
44 }
45 }
46
47 /*! \brief Get the element at position key
48 *
49 * \warning it is a stub object, it just return number in the underline grid
50 *
51 */
52 template <unsigned int p> size_t get(const grid_dist_key_dx<dim> & key) const
53 {
54 if (p != 0)
55 std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " mapping grid is suppose to have only one scalar size_t \n";
56
57 return grid_test.template get<0>(key.getKey());
58 }
59
60 /*! \brief Return the global key
61 *
62 * \warning it is a stub object, it just return the key
63 *
64 */
65 grid_key_dx<dim> getGKey(const grid_dist_key_dx<dim> & key) const
66 {
67 return key.getKey();
68 }
69};
70
71
72#endif /* OPENFPM_NUMERICS_SRC_UTIL_GRID_DIST_TESTING_HPP_ */
73