OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
CellDecomposer_gpu_ker.cuh
1/*
2 * CellDecomposer_gpu_ker.hpp
3 *
4 * Created on: Apr 28, 2019
5 * Author: i-bird
6 */
7
8#ifndef CELLDECOMPOSER_GPU_KER_HPP_
9#define CELLDECOMPOSER_GPU_KER_HPP_
10
11#include "util/cuda_launch.hpp"
12#include "util/multi_array_openfpm/array_openfpm.hpp"
13#include "Grid/grid_sm.hpp"
14#include "NN/CellList/cuda/Cuda_cell_list_util_func.hpp"
15#include "NN/CellList/CellDecomposer.hpp"
16
17template <unsigned int dim, typename T, typename cnt_type, typename ids_type, typename transform>
19{
22
25
28
30 transform t;
31
34
37
40public:
41
42 __device__ __host__ CellDecomposer_gpu_ker()
43 {}
44
45 __device__ __host__ CellDecomposer_gpu_ker(
49 const transform & t)
51 {}
52
53 __device__ __host__ CellDecomposer_gpu_ker(
57 const transform & t,
63 {}
64
65 __device__ __host__ grid_sm<dim,void> getGrid()
66 {
67 size_t sz[dim];
68
69 for (size_t i = 0 ; i < dim ; i++)
70 {
71 sz[i] = div_c[i];
72 }
73
74 return grid_sm<dim,void> (sz);
75 }
76
77 __device__ __host__ void getGridSize(size_t (& sz)[dim]) const
78 {
79 for (size_t i = 0 ; i < dim ; i++)
80 {
81 sz[i] = div_c[i] + 2*off[i];
82 }
83 }
84
85 template<typename ids_type2>
86 __device__ __host__ mem_id getGridLinId(const grid_key_dx<dim,ids_type2> & gk) const
87 {
88 mem_id lid = gk.get(0);
89 for (mem_id i = 1 ; i < dim ; i++)
90 {
91 lid += gk.get(i) * (div_c[i-1] + 2*off[i-1]);
92 }
93
94 return lid;
95 }
96
97 __device__ __host__ inline grid_key_dx<dim,ids_type> getCell(const Point<dim,T> & xp) const
98 {
100 }
101
102 __device__ __host__ inline cnt_type LinId(const grid_key_dx<dim,ids_type> & k) const
103 {
105 }
106
107 __device__ inline const openfpm::array<T,dim,cnt_type> & get_spacing_c() const
108 {
109 return spacing_c;
110 }
111
112 __device__ __host__ inline const openfpm::array<ids_type,dim,cnt_type> & get_div_c() const
113 {
114 return div_c;
115 }
116
117 __device__ __host__ inline const openfpm::array<ids_type,dim,cnt_type> & get_off() const
118 {
119 return off;
120 }
121
122 __device__ __host__ inline const transform & get_t() const
123 {
124 return t;
125 }
126
127 __device__ __host__ inline grid_key_dx<dim> getCellGrid(const T (& pos)[dim]) const
128 {
130 key.set_d(0,ConvertToID(pos,0));
131
132 for (size_t s = 1 ; s < dim ; s++)
133 {
134 key.set_d(s,ConvertToID(pos,s));
135 }
136
137 return key;
138 }
139
140 __device__ __host__ inline grid_key_dx<dim> getCellGrid(const Point<dim,T> & pos) const
141 {
143 key.set_d(0,ConvertToID(pos,0));
144
145 for (size_t s = 1 ; s < dim ; s++)
146 {
147 key.set_d(s,ConvertToID(pos,s));
148 }
149
150 return key;
151 }
152
153 __device__ __host__ inline size_t ConvertToID(const T (&x)[dim] ,size_t s) const
154 {
155 size_t id = openfpm::math::size_t_floor(t.transform(x,s) / box_unit.getHigh(s)) + off[s];
156 id = (id >= gr_cell.size(s))?(gr_cell.size(s)-1-cell_shift.get(s)):id-cell_shift.get(s);
157 return id;
158 }
159
160 __device__ __host__ inline size_t ConvertToID(const Point<dim,T> & x ,size_t s, size_t sc = 0) const
161 {
162 size_t id = openfpm::math::size_t_floor(t.transform(x,s) / box_unit.getHigh(s)) + off[s];
163 id = (id >= gr_cell.size(s))?(gr_cell.size(s)-1-cell_shift.get(s)):id-cell_shift.get(s);
164 return id;
165 }
166};
167
168#endif /* CELLDECOMPOSER_GPU_KER_HPP_ */
openfpm::array< T, dim, cnt_type > spacing_c
Spacing.
grid_sm< dim, void > gr_cell
Grid structure of the Cell list.
Point< dim, long int > cell_shift
cell_shift
transform t
transformation
openfpm::array< ids_type, dim, cnt_type > div_c
number of sub-divisions in each direction
SpaceBox< dim, T > box_unit
Unit box of the Cell list.
openfpm::array< ids_type, dim, cnt_type > off
cell offset
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Definition Point.hpp:172
This class represent an N-dimensional box.
Definition SpaceBox.hpp:27
grid_key_dx is the key to access any element in the grid
Definition grid_key.hpp:19
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
Definition grid_key.hpp:516
__device__ __host__ index_type get(index_type i) const
Get the i index.
Definition grid_key.hpp:503
Declaration grid_sm.
Definition grid_sm.hpp:167
__device__ __host__ size_t size() const
Return the size of the grid.
Definition grid_sm.hpp:657
Definition ids.hpp:169