OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
CellList_cpu_ker.cuh
1/*
2 * CellList_gpu_ker.cuh
3 *
4 * Created on: Jul 30, 2018
5 * Author: i-bird
6 */
7
8#ifndef CELLLIST_CPU_KER_CUH_
9#define CELLLIST_CPU_KER_CUH_
10
11#include "Cuda_cell_list_util_func.hpp"
12
13template<unsigned int dim, typename T, typename Mem_type, typename transform>
14class CellList_cpu_ker: Mem_type
15{
16 typedef typename Mem_type::local_index_type cnt_type;
17
18 typedef typename Mem_type::local_index_type ids_type;
19
22
25
28
30 transform t;
31
34
37
40
41public:
42
43 CellList_cpu_ker(const Mem_type & mt,
50 const transform & t)
52 {}
53
54 inline __device__ unsigned int getCell(const Point<dim,T> & xp) const
55 {
57 }
58
64 const __device__ grid_sm<dim,void> & getGrid() const
65 {
66 return gr_cell;
67 }
68
78 inline __device__ grid_key_dx<dim> getCellGrid(const Point<dim,T> & pos) const
79 {
81 key.set_d(0,ConvertToID(pos,0));
82
83 for (size_t s = 1 ; s < dim ; s++)
84 {
85 key.set_d(s,ConvertToID(pos,s));
86 }
87
88 return key;
89 }
90
100 inline __device__ grid_key_dx<dim> getCellGrid(const T (& pos)[dim]) const
101 {
103 key.set_d(0,ConvertToID(pos,0));
104
105 for (size_t s = 1 ; s < dim ; s++)
106 {
107 key.set_d(s,ConvertToID(pos,s));
108 }
109
110 return key;
111 }
112
119 inline __device__ size_t ConvertToID(const T (&x)[dim], size_t s) const
120 {
121 size_t id = openfpm::math::size_t_floor(t.transform(x,s) / box_unit.getHigh(s)) + off[s];
122 id = (id >= gr_cell.size(s))?(gr_cell.size(s)-1-cell_shift.get(s)):id-cell_shift.get(s);
123 return id;
124 }
125
132 inline __device__ size_t ConvertToID(const Point<dim,T> & x, size_t s, size_t sc = 0) const
133 {
134 size_t id = openfpm::math::size_t_floor(t.transform(x,s) / box_unit.getHigh(s)) + off[s];
135 id = (id >= gr_cell.size(s))?(gr_cell.size(s)-1-cell_shift.get(s)):id-cell_shift.get(s);
136 return id;
137 }
138
146 inline __device__ int getNelements(unsigned int cell) const
147 {
148 return Mem_type::getNelements(cell);
149 }
150
161 inline __device__ unsigned int get(unsigned int cell, unsigned int ele)
162 {
163 return Mem_type::get(cell,ele);
164 }
165
166};
167
168
169#endif /* CELLLIST_GPU_KER_CUH_ */
This class represent an N-dimensional box.
Definition Box.hpp:61
openfpm::array< T, dim, cnt_type > spacing_c
Spacing.
__device__ grid_key_dx< dim > getCellGrid(const T(&pos)[dim]) const
Get the cell-ids.
__device__ unsigned int get(unsigned int cell, unsigned int ele)
Get an element in the cell.
__device__ size_t ConvertToID(const Point< dim, T > &x, size_t s, size_t sc=0) const
Convert the coordinates into id.
__device__ int getNelements(unsigned int cell) const
Return the number of elements in the cell.
Box< dim, T > box_unit
Unit box of the Cell list.
Point< dim, long int > cell_shift
cell_shift
__device__ grid_key_dx< dim > getCellGrid(const Point< dim, T > &pos) const
Get the cell-ids.
openfpm::array< ids_type, dim, cnt_type > off
cell padding
__device__ size_t ConvertToID(const T(&x)[dim], size_t s) const
Convert the coordinates into id.
openfpm::array< ids_type, dim, cnt_type > div_c
number of sub-divisions in each direction
const __device__ grid_sm< dim, void > & getGrid() const
Return the underlying grid information of the cell list.
grid_sm< dim, void > gr_cell
Grid structure of the Cell list.
transform t
transformation
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
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
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