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 | |
13 | template<unsigned int dim, typename T, typename Mem_type, typename transform> |
14 | class 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 | |
20 | //! Spacing |
21 | openfpm::array<T,dim,cnt_type> spacing_c; |
22 | |
23 | //! \brief number of sub-divisions in each direction |
24 | openfpm::array<ids_type,dim,cnt_type> div_c; |
25 | |
26 | //! \brief cell padding |
27 | openfpm::array<ids_type,dim,cnt_type> off; |
28 | |
29 | //! transformation |
30 | transform t; |
31 | |
32 | public: |
33 | |
34 | CellList_cpu_ker(const Mem_type & mt, |
35 | openfpm::array<T,dim,cnt_type> & spacing_c, |
36 | openfpm::array<ids_type,dim,cnt_type> & div_c, |
37 | openfpm::array<ids_type,dim,cnt_type> & off, |
38 | const transform & t) |
39 | :Mem_type(mt),spacing_c(spacing_c),div_c(div_c),off(off),t(t) |
40 | {} |
41 | |
42 | inline __device__ unsigned int getCell(const Point<dim,T> & xp) const |
43 | { |
44 | return cid_<dim,cnt_type,ids_type,transform>::get_cid(div_c,spacing_c,off,t,xp); |
45 | } |
46 | |
47 | /*! \brief Return the number of elements in the cell |
48 | * |
49 | * \param cell_id id of the cell |
50 | * |
51 | * \return number of elements in the cell |
52 | * |
53 | */ |
54 | inline __device__ int getNelements(unsigned int cell) const |
55 | { |
56 | return Mem_type::getNelements(cell); |
57 | } |
58 | |
59 | /*! \brief Get an element in the cell |
60 | * |
61 | * \tparam i property to get |
62 | * |
63 | * \param cell cell id |
64 | * \param ele element id |
65 | * |
66 | * \return The element value |
67 | * |
68 | */ |
69 | inline __device__ unsigned int get(unsigned int cell, unsigned int ele) |
70 | { |
71 | return Mem_type::get(cell,ele); |
72 | } |
73 | |
74 | }; |
75 | |
76 | |
77 | #endif /* CELLLIST_GPU_KER_CUH_ */ |
78 | |