OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
CellListFast_gen.hpp
1/*
2 * CellListFast_hilb.hpp
3 *
4 * Created on: May 17, 2016
5 * Author: Yaroslav Zaluzhnyi
6 */
7
8#ifndef OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTFAST_GEN_HPP_
9#define OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTFAST_GEN_HPP_
10
11//#define HILBERT 1
12
13#include "CellList.hpp"
14#include "ProcKeys.hpp"
15
16/* \brief Cell list implementation with particle iterator over cells
17 *
18 * \see CellList<dim,T,FAST,transform,base>
19 *
20 * \tparam dim Dimensionality of the space
21 * \tparam T type of the space float, double, complex
22 * \tparam Prock indicate the cell iterator over the Cell
23 * \tparam Mem_type indicate how the Cell-list are implemented in memory
24 * \tparam base Base structure that store the information
25 *
26 */
27template<unsigned int dim,
28 typename T,
29 template <unsigned int, typename> class Prock,
30 typename Mem_type = Mem_fast<>,
31 typename transform = no_transform<dim,T>,
32 typename vector_pos_type = openfpm::vector<Point<dim,T>>>
33class CellList_gen : public CellList<dim,T,Mem_type,transform,vector_pos_type>
34{
35private:
36
38 size_t g_m = 0;
39
42 Prock<dim,CellList_gen<dim,T,Prock,Mem_type,transform,vector_pos_type>> SFC;
43
46
52 void initialize_sfc(size_t pad)
53 {
54 size_t sz[dim];
55
56 //Get grid_sm without padding (gs_small)
57 for (size_t i = 0; i < dim ; i++)
58 sz[i] = this->getGrid().size(i) - 2*pad;
59
60 grid_sm<dim,void> gs_small(sz);
61
62 size_t a = gs_small.size(0);
63
64 for (size_t i = 1 ; i < dim ; i++)
65 {
66 if (a < gs_small.size(i))
67 a = gs_small.size(i);
68 }
69
70 size_t m;
71
72 //Calculate an hilberts curve order
73 for (m = 0; ; m++)
74 {
75 if ((1ul << m) >= a)
76 break;
77 }
78
79 grid_key_dx_iterator<dim> it(gs_small);
80
81 while (it.isNext())
82 {
83 auto gk = it.get();
84
85 // Get a key of each cell and add to 'keys' vector
86 SFC.get_hkey(*this,gk,m);
87
88 ++it;
89 }
90
91 // Sort and linearize keys
92 SFC.linearize_hkeys(*this,m);
93 }
94
95public:
96
98 :CellList<dim,T,Mem_type,transform,vector_pos_type>(),init_sfc(false)
99 {};
100
101
107 const Prock<dim,CellList_gen<dim,T,Prock,Mem_type,transform,vector_pos_type>> & getCellSFC() const
108 {
109 return SFC;
110 }
111
115 inline void init_SFC()
116 {
117 // Initialize SFC
118 if (init_sfc == false)
119 {
120 initialize_sfc(this->getPadding(0));
121 init_sfc = true;
122 }
123 }
124
130 inline typename Prock<dim,CellList_gen<dim,T,Prock,Mem_type,transform,vector_pos_type>>::Pit getIterator()
131 {
132 init_SFC();
133
134 return typename Prock<dim,CellList_gen<dim,T,Prock,Mem_type,transform,vector_pos_type>>::Pit(*this);
135 }
136
146 void Initialize(const Box<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
147 {
149 }
150
151
158 {
159 return SFC.getKeys();
160 }
161
167 inline size_t get_gm()
168 {
169 return g_m;
170 }
171
176 inline void set_gm(size_t g_m)
177 {
178 this->g_m = g_m;
179 }
180};
181
182#endif /* OPENFPM_DATA_SRC_NN_CELLLIST_CELLLISTFAST_GEN_HPP_ */
This class represent an N-dimensional box.
Definition Box.hpp:61
size_t g_m
Ghost marker.
void Initialize(const Box< dim, T > &box, const size_t(&div)[dim], const size_t pad=1, size_t slot=STARTING_NSLOT)
void set_gm(size_t g_m)
Set the ghost marker.
bool init_sfc
Init SFC.
size_t get_gm()
return the ghost marker
const openfpm::vector< size_t > & getKeys()
Return cellkeys vector.
Prock< dim, CellList_gen< dim, T, Prock, Mem_type, transform, vector_pos_type > >::Pit getIterator()
return the celllist iterator (across cells)
Prock< dim, CellList_gen< dim, T, Prock, Mem_type, transform, vector_pos_type > > SFC
const Prock< dim, CellList_gen< dim, T, Prock, Mem_type, transform, vector_pos_type > > & getCellSFC() const
Get the space filling curve object.
void init_SFC()
Initialize Space-filling-curve (SFC)
void initialize_sfc(size_t pad)
Initialize the space-filling-curve.
Class for FAST cell list implementation.
Definition CellList.hpp:357
void Initialize(CellDecomposer_sm< dim, T, transform > &cd_sm, const Box< dim, T > &dom_box, const size_t pad=1, size_t slot=STARTING_NSLOT)
Definition CellList.hpp:465
It is a class that work like a vector of vector.
Definition MemFast.hpp:89
const grid_key_dx< dim > & get() const
Get the actual key.
bool isNext()
Check if there is the next element.
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
No transformation.
Implementation of 1-D std::vector like structure.