8 #ifndef CELLLISTSTANDARD_HPP_
9 #define CELLLISTSTANDARD_HPP_
11 #include "CellDecomposer.hpp"
12 #include "Space/SpaceBox.hpp"
13 #include "util/mathutil.hpp"
14 #include "CellNNIterator.hpp"
15 #include "Space/Shape/HyperCube.hpp"
17 #include "util/common.hpp"
66 template<
unsigned int dim,
typename T,
typename transform,
typename base>
67 class CellList<dim,T,FAST,transform,base> :
public CellDecomposer_sm<dim,T,transform>
75 long int NNc_full[openfpm::math::pow(3,dim)];
82 long int NNc_sym[openfpm::math::pow(3,dim)/2+1];
89 long int NNc_cr[openfpm::math::pow(2,dim)];
108 base cl_base_(2*slot * cl_n.size());
111 for (
size_t i = 0 ; i < cl_n.size() ; i++)
113 for (
size_t j = 0 ; j < cl_n.get(i) ; j++)
114 cl_base_.
get(2*i*slot + j) = cl_base.get(slot * i + j);
121 cl_base.swap(cl_base_);
127 typedef T value_type;
136 return CellDecomposer_sm<dim,T,transform>::getGrid();
154 Initialize(sbox,div,orig,pad,slot);
169 CellDecomposer_sm<dim,T,transform>::setDimensions(box,div, mat, orig, pad);
175 cl_n.resize(this->tot_n_cell);
180 cl_base.resize(this->tot_n_cell * slot);
186 typedef typename generate_array<size_t,dim, Fill_zero>::result NNzero;
187 typedef typename generate_array<size_t,dim, Fill_two>::result NNtwo;
188 typedef typename generate_array<size_t,dim, Fill_one>::result NNone;
196 size_t middle = this->gr_cell.LinId(NNone::data);
200 NNc_full[i] = (
long int)this->gr_cell.LinId(gr_sub3.
get()) - middle;
214 size_t lin = this->gr_cell.LinId(
key);
223 NNc_sym[i] = lin - middle;
238 NNc_cr[i] = (
long int)this->gr_cell.LinId(
key);
253 this->operator=(cell);
259 this->operator=(cell);
269 std::copy(&cell.NNc_full[0],&cell.NNc_full[openfpm::math::pow(3,dim)],&NNc_full[0]);
270 std::copy(&cell.NNc_sym[0],&cell.NNc_sym[openfpm::math::pow(3,dim)/2+1],&NNc_sym[0]);
271 std::copy(&cell.NNc_cr[0],&cell.NNc_cr[openfpm::math::pow(2,dim)],&NNc_cr[0]);
277 cl_n.swap(cell.cl_n);
278 cl_base.swap(cell.cl_base);
294 std::copy(&cell.NNc_full[0],&cell.NNc_full[openfpm::math::pow(3,dim)],&NNc_full[0]);
295 std::copy(&cell.NNc_sym[0],&cell.NNc_sym[openfpm::math::pow(3,dim)/2+1],&NNc_sym[0]);
296 std::copy(&cell.NNc_cr[0],&cell.NNc_cr[openfpm::math::pow(2,dim)],&NNc_cr[0]);
301 cl_base = cell.cl_base;
319 :CellDecomposer_sm<dim,T,transform>(box,div,mat,orig,pad)
322 Initialize(sbox,div,orig,pad,slot);
337 Initialize(sbox,div,orig,pad,slot);
351 Initialize(box,div,orig,pad,slot);
361 inline void addCell(
size_t cell_id,
typename base::value_type ele)
365 size_t nl = getNelements(cell_id);
374 cl_base.get(slot * cell_id + cl_n.get(cell_id)) = ele;
384 inline void add(
const T (& pos)[dim],
typename base::value_type ele)
388 size_t cell_id = this->getCell(pos);
392 addCell(cell_id,ele);
405 size_t cell_id = this->getCell(pos);
409 addCell(cell_id,ele);
418 inline void remove(
size_t cell,
size_t ele)
432 return cl_n.get(cell_id);
445 inline auto get(
size_t cell,
size_t ele) -> decltype(cl_base.get(cell * slot + ele))
447 return cl_base.get(cell * slot + ele);
460 template<
unsigned int i>
inline auto get(
size_t cell,
size_t ele) -> decltype(cl_base.get(cell * slot + ele))
462 return cl_base.template get<i>(cell * slot + ele);
473 cl_base.swap(cl.cl_base);
This class represent an N-dimensional box.
bool isNext()
Check if there is the next element.
This class implement the point shape in an N-dimensional space.
T get(int i) const
Get coordinate.
grid_key_dx< dim > get()
Return the actual grid key iterator.
This class implement an NxN (dense) matrix.
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. ...
Iterator for the neighborhood of the cell structures.