OpenFPM  5.2.0
Project that contain the implementation of distributed structures
SFCKeys.hpp
1 /*
2  * SFCKeys.hpp
3  *
4  * Created on: Mar 14, 2017
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_DATA_SRC_NN_CELLLIST_PROCKEYS_HPP_
9 #define OPENFPM_DATA_SRC_NN_CELLLIST_PROCKEYS_HPP_
10 
11 extern "C"
12 {
13 #include "hilbertKey.h"
14 }
15 
16 /* !Brief Class for a linear (1D-like) order processing of cell keys for CellList implementation
17  *
18  * \tparam dim Dimansionality of the space
19  */
20 template<unsigned int dim>
22 {
25 
26 public:
32  inline const openfpm::vector<size_t> & getKeys() const
33  {
34  return keys;
35  }
36 
45  template<typename CellList_type> void get_hkey(CellList_type & cellList, grid_key_dx<dim> gridKey, size_t m)
46  {
47  size_t point[dim];
48 
49  for (size_t i = 0; i < dim; i++)
50  {
51  point[i] = gridKey.get(i) + cellList.getPadding(i);
52  }
53 
54  keys.add(cellList.getGrid().LinIdPtr(static_cast<size_t *>(point)));
55  }
56 
57  template<typename CellList_type> void linearize_hkeys(CellList_type & cellList, size_t m)
58  {
59  return;
60  }
61 };
62 
67 template<unsigned int dim>
69 {
72 
74  size_t m = 0;
75 
76 public:
82  inline const openfpm::vector<size_t> & getKeys() const
83  {
84  return keys;
85  }
86 
95  template<typename CellList_type> inline void get_hkey(CellList_type & cellList, grid_key_dx<dim> gridKey, size_t m)
96  {
97  //An integer to handle errors
98  int err;
99 
100  uint64_t point[dim];
101 
102  for (size_t i = 0; i < dim; i++)
103  {
104  point[i] = gridKey.get(i);
105  }
106 
107  size_t hkey = getHKeyFromIntCoord(m, dim, point, &err);
108 
109  keys.add(hkey);
110  }
111 
119  template<typename CellList_type> inline void linearize_hkeys(CellList_type & cellList, size_t m)
120  {
121  //An integer to handle errors
122  int err;
123 
124  //Array to handle output
125  uint64_t coord[dim];
126  size_t coord2[dim];
127 
128  keys.sort();
129 
130  openfpm::vector<size_t> keys_new;
131 
132  for(size_t i = 0; i < keys.size(); i++)
133  {
134  getIntCoordFromHKey(coord, m, dim, keys.get(i), &err);
135 
136  for (size_t j = 0 ; j < dim ; j++) {coord2[j] = coord[j] + cellList.getPadding(j);}
137 
138  keys_new.add(cellList.getGrid().LinIdPtr(static_cast<size_t *>(coord2)));
139  }
140 
141  keys.swap(keys_new);
142  }
143 };
144 
149 template<unsigned int dim>
151 {
154 
156  size_t m = 0;
157 
158 public:
164  inline const openfpm::vector<size_t> & getKeys() const
165  {
166  return keys;
167  }
168 
177  template<typename CellList_type> inline void get_hkey(CellList_type & cellList, grid_key_dx<dim> gridKey, size_t m)
178  {
179  uint64_t point[dim];
180 
181  for (size_t i = 0; i < dim; i++)
182  {
183  point[i] = gridKey.get(i);
184  }
185 
186  size_t hkey = cellList.getGrid().LinId(gridKey);
187 
188  keys.add(hkey);
189  }
190 
198  template<typename CellList_type> inline void linearize_hkeys(CellList_type & cellList, size_t m)
199  {
200  }
201 };
202 
203 #endif /* OPENFPM_DATA_SRC_NN_CELLLIST_PROCKEYS_HPP_ */
Class for an hilbert order processing of cell keys for CellList implementation.
Definition: SFCKeys.hpp:151
void get_hkey(CellList_type &cellList, grid_key_dx< dim > gridKey, size_t m)
Get an hilbert key from the coordinates and add to the getKeys vector.
Definition: SFCKeys.hpp:177
void linearize_hkeys(CellList_type &cellList, size_t m)
Get get the coordinates from hilbert key, linearize and add to the getKeys vector.
Definition: SFCKeys.hpp:198
openfpm::vector< size_t > keys
vector for storing the cell keys
Definition: SFCKeys.hpp:153
size_t m
Order of an hilbert curve.
Definition: SFCKeys.hpp:156
const openfpm::vector< size_t > & getKeys() const
Return cellkeys vector.
Definition: SFCKeys.hpp:164
Class for an hilbert order processing of cell keys for CellList implementation.
Definition: SFCKeys.hpp:69
void get_hkey(CellList_type &cellList, grid_key_dx< dim > gridKey, size_t m)
Get an hilbert key from the coordinates and add to the getKeys vector.
Definition: SFCKeys.hpp:95
void linearize_hkeys(CellList_type &cellList, size_t m)
Get get the coordinates from hilbert key, linearize and add to the getKeys vector.
Definition: SFCKeys.hpp:119
const openfpm::vector< size_t > & getKeys() const
Return cellkeys vector.
Definition: SFCKeys.hpp:82
openfpm::vector< size_t > keys
vector for storing the cell keys
Definition: SFCKeys.hpp:71
size_t m
Order of an hilbert curve.
Definition: SFCKeys.hpp:74
void get_hkey(CellList_type &cellList, grid_key_dx< dim > gridKey, size_t m)
Get a linear (1D-like) key from the coordinates and add to the getKeys vector.
Definition: SFCKeys.hpp:45
const openfpm::vector< size_t > & getKeys() const
Return cellkeys vector.
Definition: SFCKeys.hpp:32
openfpm::vector< size_t > keys
stub object
Definition: SFCKeys.hpp:24
__device__ __host__ index_type get(index_type i) const
Get the i index.
Definition: grid_key.hpp:503
size_t size()
Stub size.
Definition: map_vector.hpp:212