OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
11extern "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 */
20template<unsigned int dim, typename CellList>
22{
25
26public:
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
71template<unsigned int dim, typename CellList>
73{
76
79
81 size_t m = 0;
82
83public:
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
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
160template<unsigned int dim, typename CellList>
162{
165
168
170 size_t m = 0;
171
172public:
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 uint64_t point[dim];
198
199 for (size_t i = 0; i < dim; i++)
200 {
201 point[i] = gk.get(i);
202 }
203
204 size_t hkey = obj.getGrid().LinId(gk);
205
206 keys.add(hkey);
207 }
208
216 template<typename S> inline void linearize_hkeys(S & obj, size_t m)
217 {
218 }
219};
220
221#endif /* OPENFPM_DATA_SRC_NN_CELLLIST_PROCKEYS_HPP_ */
Class for an hilbert order processing of cell keys for CellList_gen implementation.
Definition ProcKeys.hpp:162
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
openfpm::vector< size_t > keys
vector for storing the cell keys
Definition ProcKeys.hpp:164
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:216
ParticleIt_CellP< CellList > Pit
Particle Iterator produced by this key generator.
Definition ProcKeys.hpp:175
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
const openfpm::vector< size_t > & getKeys() const
Return cellkeys vector.
Definition ProcKeys.hpp:182
Class for an hilbert order processing of cell keys for CellList_gen implementation.
Definition ProcKeys.hpp:73
const openfpm::vector< size_t > & getKeys() const
Return cellkeys vector.
Definition ProcKeys.hpp:93
openfpm::vector< size_t > p_keys
vector for storing the particle keys
Definition ProcKeys.hpp:78
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
ParticleIt_CellP< CellList > Pit
Particle Iterator produced by this key generator.
Definition ProcKeys.hpp:86
openfpm::vector< size_t > keys
vector for storing the cell keys
Definition ProcKeys.hpp:75
size_t m
Order of an hilbert curve.
Definition ProcKeys.hpp:81
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
openfpm::vector< size_t > keys
stub object
Definition ProcKeys.hpp:24
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
const openfpm::vector< size_t > & getKeys() const
Return cellkeys vector.
Definition ProcKeys.hpp:36
ParticleIt_CellP< CellList > Pit
Particle Iterator produced by this key generator.
Definition ProcKeys.hpp:29
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
__device__ __host__ index_type get(index_type i) const
Get the i index.
Definition grid_key.hpp:503
Implementation of 1-D std::vector like structure.