OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
ProcKeys.hpp
1 /*
2  * ProcKeys.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_gen implementation
17  *
18  * \tparam dim Dimansionality of the space
19  */
20 template<unsigned int dim, typename CellList>
22 {
25 
26 public:
27 
30 
36  inline const openfpm::vector<size_t> & getKeys() const
37  {
38  return keys;
39  }
40 
49  template<typename S> void get_hkey(S & obj, grid_key_dx<dim> gk, size_t m)
50  {
51  size_t point[dim];
52 
53  for (size_t i = 0; i < dim; i++)
54  {
55  point[i] = gk.get(i) + obj.getPadding(i);
56  }
57 
58  keys.add(obj.getGrid().LinIdPtr(static_cast<size_t *>(point)));
59  }
60 
61  template<typename S> void linearize_hkeys(S & obj, size_t m)
62  {
63  return;
64  }
65 };
66 
71 template<unsigned int dim, typename CellList>
73 {
76 
79 
81  size_t m = 0;
82 
83 public:
84 
87 
93  inline const openfpm::vector<size_t> & getKeys() const
94  {
95  return keys;
96  }
97 
106  template<typename S> inline void get_hkey(S & obj, grid_key_dx<dim> gk, size_t m)
107  {
108  //An integer to handle errors
109  int err;
110 
111  uint64_t point[dim];
112 
113  for (size_t i = 0; i < dim; i++)
114  {
115  point[i] = gk.get(i);
116  }
117 
118  size_t hkey = getHKeyFromIntCoord(m, dim, point, &err);
119 
120  keys.add(hkey);
121  }
122 
130  template<typename S> inline void linearize_hkeys(S & obj, size_t m)
131  {
132  //An integer to handle errors
133  int err;
134 
135  //Array to handle output
136  uint64_t coord[dim];
137  size_t coord2[dim];
138 
139  keys.sort();
140 
141  openfpm::vector<size_t> keys_new;
142 
143  for(size_t i = 0; i < obj.getKeys().size(); i++)
144  {
145  getIntCoordFromHKey(coord, m, dim, obj.getKeys().get(i), &err);
146 
147  for (size_t j = 0 ; j < dim ; j++) {coord2[j] = coord[j] + obj.getPadding(j);}
148 
149  keys_new.add(obj.getGrid().LinIdPtr(static_cast<size_t *>(coord2)));
150  }
151 
152  keys.swap(keys_new);
153  }
154 };
155 
160 template<unsigned int dim, typename CellList>
162 {
165 
168 
170  size_t m = 0;
171 
172 public:
173 
176 
182  inline const openfpm::vector<size_t> & getKeys() const
183  {
184  return keys;
185  }
186 
195  template<typename S> inline void get_hkey(S & obj, grid_key_dx<dim> gk, size_t m)
196  {
197  //An integer to handle errors
198  int err;
199 
200  uint64_t point[dim];
201 
202  for (size_t i = 0; i < dim; i++)
203  {
204  point[i] = gk.get(i);
205  }
206 
207  size_t hkey = obj.getGrid().LinId(gk);
208 
209  keys.add(hkey);
210  }
211 
219  template<typename S> inline void linearize_hkeys(S & obj, size_t m)
220  {
221  }
222 };
223 
224 #endif /* OPENFPM_DATA_SRC_NN_CELLLIST_PROCKEYS_HPP_ */
void linearize_hkeys(S &obj, size_t m)
Get get the coordinates from hilbert key, linearize and add to the getKeys vector.
Definition: ProcKeys.hpp:130
grid_key_dx is the key to access any element in the grid
Definition: grid_key.hpp:18
Class for an hilbert order processing of cell keys for CellList_gen implementation.
Definition: ProcKeys.hpp:72
ParticleIt_CellP< CellList > Pit
Particle Iterator produced by this key generator.
Definition: ProcKeys.hpp:86
const openfpm::vector< size_t > & getKeys() const
Return cellkeys vector.
Definition: ProcKeys.hpp:182
mem_id get(size_t i) const
Get the i index.
Definition: grid_key.hpp:394
openfpm::vector< size_t > p_keys
vector for storing the particle keys
Definition: ProcKeys.hpp:167
size_t m
Order of an hilbert curve.
Definition: ProcKeys.hpp:170
const openfpm::vector< size_t > & getKeys() const
Return cellkeys vector.
Definition: ProcKeys.hpp:36
void get_hkey(S &obj, grid_key_dx< dim > gk, size_t m)
Get a linear (1D-like) key from the coordinates and add to the getKeys vector.
Definition: ProcKeys.hpp:49
size_t m
Order of an hilbert curve.
Definition: ProcKeys.hpp:81
ParticleIt_CellP< CellList > Pit
Particle Iterator produced by this key generator.
Definition: ProcKeys.hpp:175
const openfpm::vector< size_t > & getKeys() const
Return cellkeys vector.
Definition: ProcKeys.hpp:93
void get_hkey(S &obj, grid_key_dx< dim > gk, size_t m)
Get an hilbert key from the coordinates and add to the getKeys vector.
Definition: ProcKeys.hpp:195
void get_hkey(S &obj, grid_key_dx< dim > gk, size_t m)
Get an hilbert key from the coordinates and add to the getKeys vector.
Definition: ProcKeys.hpp:106
openfpm::vector< size_t > p_keys
vector for storing the particle keys
Definition: ProcKeys.hpp:78
ParticleIt_CellP< CellList > Pit
Particle Iterator produced by this key generator.
Definition: ProcKeys.hpp:29
openfpm::vector< size_t > keys
vector for storing the cell keys
Definition: ProcKeys.hpp:164
openfpm::vector< size_t > keys
stub object
Definition: ProcKeys.hpp:24
openfpm::vector< size_t > keys
vector for storing the cell keys
Definition: ProcKeys.hpp:75
void linearize_hkeys(S &obj, size_t m)
Get get the coordinates from hilbert key, linearize and add to the getKeys vector.
Definition: ProcKeys.hpp:219
Class for an hilbert order processing of cell keys for CellList_gen implementation.
Definition: ProcKeys.hpp:161