10 #ifndef CELLLISTBAL_HPP_
11 #define CELLLISTBAL_HPP_
13 #include "CellDecomposer.hpp"
14 #include "Space/SpaceBox.hpp"
15 #include "util/mathutil.hpp"
16 #include "CellNNIterator.hpp"
17 #include "Space/Shape/HyperCube.hpp"
38 template<
unsigned int dim,
typename T,
typename base>
39 class CellList<dim,T,BALANCED,base>:
public CellDecomposer_sm<dim,T>
47 long int NNc_full[openfpm::math::pow(3,dim)];
54 long int NNc_sym[openfpm::math::pow(3,dim)/2+1];
61 long int NNc_cr[openfpm::math::pow(2,dim)];
83 CellDecomposer_sm<dim,T>::getGrid();
97 Initialize(sbox,div,orig);
112 for (
size_t i = 0 ; i < dim ; i++)
113 div_pad[i] = div[i] + 2;
115 CellDecomposer_sm<dim,T>::setDimensions(box,div_pad, pad);
121 cl_base.resize(this->tot_n_cell);
124 for (
int i = 0; i < this->tot_n_cell; i++)
126 cl_base.
get(i) = base();
133 typedef typename generate_array<size_t,dim, Fill_zero>::result NNzero;
134 typedef typename generate_array<size_t,dim, Fill_two>::result NNtwo;
135 typedef typename generate_array<size_t,dim, Fill_one>::result NNone;
143 size_t middle = this->gr_cell.LinId(NNone::data);
147 NNc_full[i] = (
long int)this->gr_cell.LinId(gr_sub3.
get()) - middle;
161 size_t lin = this->gr_cell.LinId(
key);
170 NNc_sym[i] = lin - middle;
185 NNc_cr[i] = (
long int)this->gr_cell.LinId(
key);
210 Initialize(sbox,div,orig,pad);
222 Initialize(box,div,orig,pad);
231 void add(
const T (& pos)[dim],
typename base::value_type ele)
235 size_t cell_id = this->getCell(pos);
239 cl_base.get(cell_id)->add(ele);
252 size_t cell_id = this->getCell(pos);
256 cl_base.get(cell_id).add(ele);
265 void remove(
size_t cell,
size_t ele)
267 cl_base.get(cell).remove(ele);
279 return cl_base.get(cell_id).size();
288 auto get(
size_t cell,
size_t ele) -> decltype(cl_base.get(cell).get(ele))
290 return cl_base.get(cell).get(ele);
305 template<
unsigned int i>
inline auto get(
size_t cell,
size_t ele) -> decltype(cl_base.get(cell).get(ele))
307 return cl_base.template get<i>(cell)->
get(ele);
317 cl_base.swap(cl.cl_base);
This class represent an N-dimensional box.
CellList(Box< dim, T > &box, size_t(&div)[dim], Point< dim, T > &orig, const size_t pad=1)
Cell list.
CellList(SpaceBox< dim, T > &box, size_t(&div)[dim], Point< dim, T > &orig, const size_t pad=1)
Cell list.
CellList()
Default constructor.
bool isNext()
Check if there is the next element.
This class implement the point shape in an N-dimensional space.
void add(const T(&pos)[dim], typename base::value_type ele)
Add an element in the cell list.
CellIterator< CellList< dim, T, BALANCED, base > > getIterator(size_t cell)
Get the Cell iterator.
Class for BALANCED cell list implementation.
void add(const Point< dim, T > &pos, typename base::value_type ele)
Add an element in the cell list.
T get(int i) const
Get coordinate.
grid_key_dx< dim > get()
Return the actual grid key iterator.
it iterate through the elements of a cell
void reset()
Reset the iterator (it restart from the beginning)
This class represent an N-dimensional box.
This class is a trick to indicate the compiler a specific specialization pattern. ...
CellNNIterator< dim, CellList< dim, T, BALANCED, base >, FULL, impl > getNNIterator(size_t cell)
Get the Nearest Neighborhood iterator.
size_t getNelements(size_t cell_id)
Return the number of element in the cell.
void Initialize(SpaceBox< dim, T > &box, size_t(&div)[dim], Point< dim, T > &orig, const size_t pad=1)
grid_sm< dim, void > & getGrid()
Return the underlying grid information of the cell list.
void swap(CellList< dim, T, BALANCED, base > &cl)
Swap the memory.
Iterator for the neighborhood of the cell structures.
void Initialize(Box< dim, T > &box, size_t(&div)[dim], Point< dim, T > &orig, const size_t pad=1)