11 #include <unordered_map>
13 #include "Vector/map_vector.hpp"
14 #include "Space/Ghost.hpp"
15 #include "Space/Shape/Box.hpp"
16 #include "util/mathutil.hpp"
17 #include "Space/Shape/HyperCube.hpp"
19 #include "util/common.hpp"
21 #include "NN/Mem_type/MemFast.hpp"
22 #include "NN/Mem_type/MemBalanced.hpp"
23 #include "NN/Mem_type/MemMemoryWise.hpp"
24 #include "NN/CellList/CellDecomposer.hpp"
25 #include "NN/CellList/NNc_array.hpp"
26 #include "NN/CellList/SFCKeys.hpp"
27 #include "NN/CellList/CellNNIterator.hpp"
28 #include "NN/CellList/CellNNIteratorRadius.hpp"
29 #include "NN/CellList/CellListIterator.hpp"
30 #include "NN/CellList/ParticleIt_Cells.hpp"
31 #include "NN/CellList/ParticleItCRS_Cells.hpp"
32 #include "NN/CellList/cuda/CellList_cpu_ker.cuh"
36 template<
typename key,
typename val>
41 #ifdef HAVE_LIBQUADMATH
43 #include <boost/multiprecision/float128.hpp>
47 template<
typename val>
55 #define CELL_REALLOC 16ul
57 #define STARTING_NSLOT 16
60 constexpr
int CL_SYMMETRIC = 1;
61 constexpr
int CL_NON_SYMMETRIC = 2;
62 constexpr
int CL_LOCAL_SYMMETRIC = 8;
63 constexpr
int CL_LINEAR_CELL_KEYS = 16;
64 constexpr
int CL_HILBERT_CELL_KEYS = 32;
65 constexpr
int CL_GPU_REORDER_POSITION = 64;
66 constexpr
int CL_GPU_REORDER_PROPERTY = 128;
67 constexpr
int CL_GPU_RESTORE_POSITION = 256;
68 constexpr
int CL_GPU_RESTORE_PROPERTY = 512;
69 constexpr
int CL_GPU_SKIP_CONSTRUCT_ON_STATIC_DOMAIN = 1024;
70 constexpr
int CL_GPU_REORDER = CL_GPU_REORDER_POSITION | CL_GPU_REORDER_PROPERTY | CL_GPU_RESTORE_POSITION | CL_GPU_RESTORE_PROPERTY;
84 typedef typename generate_array<size_t,dim, Fill_zero>::result NNzero;
85 typedef typename generate_array<size_t,dim, Fill_two>::result NNtwo;
93 for (
size_t i = 0 ; i < dim ; i++)
100 for (
size_t i = 0; i < dim; i++)
103 size_t middle = gs.LinId(src_);
106 while (gr_sub3.isNext())
108 auto dst = gr_sub3.get();
111 if ((
long int)middle > gs.LinId(dst))
119 for (
size_t i = 0 ; i < dim; i++)
124 dst.set_d(i,dst.get(i) + 1);
150 typedef typename generate_array<size_t,dim, Fill_zero>::result NNzero;
151 typedef typename generate_array<size_t,dim, Fill_two>::result NNtwo;
159 for (
size_t i = 0 ; i < dim ; i++)
166 for (
size_t i = 0; i < dim; i++)
169 size_t middle = gs.LinId(src_);
172 while (gr_sub3.isNext())
174 auto dst = gr_sub3.get();
176 if ((
long int)middle > gs.LinId(dst))
201 typedef typename generate_array<size_t,dim, Fill_zero>::result NNzero;
202 typedef typename generate_array<size_t,dim, Fill_two>::result NNtwo;
210 for (
size_t i = 0 ; i < dim ; i++)
217 for (
size_t i = 0; i < dim; i++)
221 while (gr_sub3.isNext())
223 auto dst = gr_sub3.get();
265 template<
unsigned int dim,
typename T,
typename vector_type>
273 size_t nRadCellDim[dim];
274 size_t middleCellIndex[dim];
279 for (
size_t i = 0 ; i < dim ; i++)
281 nRadCellDim[i] = 2*(std::ceil(r_cut / unitCellP2.
get(i)))+1;
282 middleCellIndex[i] = nRadCellDim[i] / 2;
290 for (
unsigned int i = 0 ; i < dim ; i++)
292 middleCell.
setLow(i,middleCellIndex[i]*unitCellP2.
get(i));
293 middleCell.
setHigh(i,(middleCellIndex[i]+1)*unitCellP2.
get(i));
296 while (radCellGridIt.isNext())
298 auto key = radCellGridIt.get();
302 for (
unsigned int i = 0 ; i < dim ; i++)
304 cell.
setLow(i,key.get(i)*unitCellP2.
get(i));
305 cell.
setHigh(i,(key.get(i)+1)*unitCellP2.
get(i));
309 if (cell.min_distance(middleCell) > r_cut) {
310 ++radCellGridIt;
continue;
313 for (
size_t i = 0 ; i < dim ; i++)
315 key.set_d(i,key.get(i) - middleCellIndex[i]);
318 radNeighborCellOffsetTemp.add(cellListGrid.
LinId(key));
323 radNeighborCellOffset.
resize(radNeighborCellOffsetTemp.
size());
328 radNeighborCellOffset.template get<0>(index++) = 0;
330 for (
int i = 0; i < radNeighborCellOffsetTemp.
size(); ++i)
332 int cellIndex = radNeighborCellOffsetTemp.template get<0>(i);
335 radNeighborCellOffset.template get<0>(index++) = cellIndex;
378 template<
unsigned int dim,
typename vector_type>
388 for (
size_t i = 0 ; i < dim ; i++)
390 cellPosStart.
set_d(i,0);
391 cellPosStop.
set_d(i,2*NNeighbor);
392 cellPosMiddle.
set_d(i,NNeighbor);
395 boxNeighborCellOffset.
resize(openfpm::math::pow(2*NNeighbor+1,dim));
397 int cellIndexMiddle = cellListGrid.
LinId(cellPosMiddle);
403 boxNeighborCellOffset.template get<0>(index++) = 0;
405 while (boxCellGridIt.isNext())
407 int cellIndex = (
int)cellListGrid.
LinId(boxCellGridIt.get()) - cellIndexMiddle;
410 boxNeighborCellOffset.template get<0>(index++) = cellIndex;
455 template<
unsigned int dim,
typename vector_type>
465 for (
size_t i = 0 ; i < dim ; i++)
467 cellPosStart.
set_d(i,0);
468 cellPosStop.
set_d(i,2*NNeighbor);
469 cellPosMiddle.
set_d(i,NNeighbor);
472 boxNeighborCellOffset.
resize(0);
474 int cellIndexMiddle = cellListGrid.
LinId(cellPosMiddle);
480 boxNeighborCellOffset.
add();
481 boxNeighborCellOffset.template get<0>(index++) = 0;
483 while (boxCellGridIt.isNext())
485 int cellIndex = (
int)cellListGrid.
LinId(boxCellGridIt.get()) - cellIndexMiddle;
488 boxNeighborCellOffset.
add();
489 boxNeighborCellOffset.template get<0>(index++) = cellIndex;
557 class CellList :
public CellDecomposer_sm<dim,T,transform>,
public Mem_type
577 NNc_array<dim,(
unsigned int)openfpm::math::pow(3,dim)> NNc_sym_local;
609 Mem_type::init_to_zero(
slot,tot_n_cell);
621 void setCellDecomposer(CellDecomposer_sm<dim,T,transform> & cd,
const CellDecomposer_sm<dim,T,transform> & cd_sm,
const Box<dim,T> & dom_box,
size_t pad)
const
625 for (
size_t i = 0 ; i < dim ; i++)
626 {bc[i] = NON_PERIODIC;}
633 for (
size_t i = 0 ; i < dim ; i++)
636 div_big[i] = cd_sm.getDiv()[i] - 2*cd_sm.getPadding(i);
639 cd.setDimensions(cd_sm.getDomain(),div_big,div, pad, bx.
getP1());
645 template <
typename SFC_type>
651 for (
size_t i = 0; i < dim ; i++)
656 size_t a = gs_small.
size(0);
658 for (
size_t i = 1 ; i < dim ; i++)
660 if (a < gs_small.
size(i))
661 a = gs_small.
size(i);
680 SFC.get_hkey(*
this,gk,m);
686 SFC.linearize_hkeys(*
this,m);
687 this->SFCKeys = SFC.getKeys();
706 typedef vector_pos_type internal_vector_pos_type;
715 return CellDecomposer_sm<dim,T,transform>::getGrid();
731 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)
734 for (
size_t i = 0 ; i < dim ; i++) {bc[i] = NON_PERIODIC;}
738 setCellDecomposer(*
this,cd_sm,dom_box,pad);
740 size_t div_w_pad[dim];
743 for (
size_t i = 0 ; i < dim ; i++)
746 tot_cell *= div_w_pad[i];
769 CellDecomposer_sm<dim,T,transform>::setDimensions(box,div, mat, pad);
770 Mem_type::set_slot(
slot);
783 :Mem_type(STARTING_NSLOT)
790 :Mem_type(STARTING_NSLOT)
808 opt(CL_NON_SYMMETRIC | CL_LINEAR_CELL_KEYS),
809 CellDecomposer_sm<dim,T,transform>(box,div,mat,box.getP1(),pad)
826 opt(CL_NON_SYMMETRIC | CL_LINEAR_CELL_KEYS)
841 CellList(CellDecomposer_sm<dim,T,transform> & cd_sm,
const Box<dim,T> & box,
const size_t pad = 1,
size_t slot=STARTING_NSLOT)
845 opt(CL_NON_SYMMETRIC | CL_LINEAR_CELL_KEYS)
866 std::copy(&cell.NNc_full[0],&cell.NNc_full[openfpm::math::pow(3,dim)],&
NNc_full[0]);
867 std::copy(&cell.NNc_sym[0],&cell.NNc_sym[openfpm::math::pow(3,dim)/2+1],&
NNc_sym[0]);
868 std::copy(&cell.NNc_sym_local[0],&cell.NNc_sym_local[openfpm::math::pow(3,dim)],&NNc_sym_local[0]);
870 Mem_type::swap(
static_cast<Mem_type &&
>(cell));
872 static_cast<CellDecomposer_sm<dim,T,transform> &
>(*this).swap(cell);
876 ghostMarker = cell.ghostMarker;
896 NNc_sym_local = cell.NNc_sym_local;
898 Mem_type::operator=(
static_cast<const Mem_type &
>(cell));
900 static_cast<CellDecomposer_sm<dim,T,transform> &
>(*this) =
static_cast<const CellDecomposer_sm<dim,T,transform> &
>(cell);
904 ghostMarker = cell.ghostMarker;
920 template<
typename Mem_type2>
923 NNc_full = cell.private_get_NNc_full();
924 NNc_sym = cell.private_get_NNc_sym();
925 NNc_sym_local = cell.private_get_NNc_sym_local();
927 Mem_type::copy_general(
static_cast<const Mem_type2 &
>(cell));
929 static_cast<CellDecomposer_sm<dim,T,transform> &
>(*this) =
static_cast<const CellDecomposer_sm<dim,T,transform> &
>(cell);
932 from_cd = cell.private_get_from_cd();
971 inline void add(
const T (& pos)[dim],
typename Mem_type::local_index_type
ele)
974 size_t cell_id = this->getCell(pos);
976 Mem_type::addCell(cell_id,
ele);
988 size_t cell_id = this->getCell(pos);
990 Mem_type::addCell(cell_id,
ele);
1002 inline void addDom(
const T (& pos)[dim],
typename Mem_type::local_index_type
ele)
1006 size_t cell_id = this->getCellDom(pos);
1010 Mem_type::addCell(cell_id,
ele);
1025 size_t cell_id = this->getCellDom(pos);
1029 Mem_type::addCell(cell_id,
ele);
1040 inline void addPad(
const T (& pos)[dim],
typename Mem_type::local_index_type
ele)
1044 size_t cell_id = this->getCellPad(pos);
1048 Mem_type::addCell(cell_id,
ele);
1063 size_t cell_id = this->getCell(pos);
1067 Mem_type::addCell(cell_id,
ele);
1076 Mem_type::addCellGhostMarkers();
1087 Mem_type::remove(cell,
ele);
1096 return Mem_type::size();
1108 return Mem_type::getNelements(cell_id);
1121 inline auto get(
size_t cell,
size_t ele) -> decltype(this->Mem_type::get(cell,
ele))
1123 return Mem_type::get(cell,
ele);
1136 inline auto get(
size_t cell,
size_t ele)
const -> decltype(this->Mem_type::get(cell,
ele))
1138 return Mem_type::get(cell,
ele);
1150 NNc_sym_local.
swap(cl.NNc_sym_local);
1152 Mem_type::swap(
static_cast<Mem_type &
>(cl));
1154 static_cast<CellDecomposer_sm<dim,T,transform> &
>(*this).swap(
static_cast<CellDecomposer_sm<dim,T,transform> &
>(cl));
1159 size_t optTmp =
opt;
1243 if (NNc.
size() == 0)
1244 {NNcalc_rad(r_cut,NNc,this->getCellBox(),this->
getGrid());}
1274 getNNIteratorBoxSym(
size_t cell,
size_t p,
const vector_pos_type & v)
1278 {std::cerr << __FILE__ <<
":" << __LINE__ <<
" Warning when you try to get a symmetric neighborhood iterator, you must construct the Cell-list in a symmetric way" << std::endl;}
1281 CellNNIteratorSym<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type,SYM> cln(cell,p,
NNc_sym,*
this,v);
1306 getNNIteratorBoxSymLocal(
size_t cell,
size_t p,
const vector_pos_type & v)
1313 CellNNIteratorSymLocal<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type,FULL> cln(cell,p,NNc_sym_local,*
this,v);
1339 template<
typename vector_pos_type2>
1341 getNNIteratorBoxSymMP(
size_t cell,
size_t p,
const vector_pos_type2 & v_p1,
const vector_pos_type2 & v_p2)
1345 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Warning when you try to get a symmetric neighborhood iterator, you must construct the Cell-list in a symmetric way" << std::endl;
1348 CellNNIteratorSymMP<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type2,SYM> cln(cell,p,
NNc_sym,*
this,v_p1,v_p2);
1393 return CellDecomposer_sm<dim,T,transform>::getPadding(i);
1404 return CellDecomposer_sm<dim,T,transform>::getPadding();
1419 void clear(
typename Mem_type::local_index_type cell_id)
1421 Mem_type::clear(cell_id);
1429 Mem_type::destroy();
1439 __attribute__((always_inline))
inline const typename Mem_type::local_index_type &
getStartId(
typename Mem_type::local_index_type cell_id)
const
1441 return Mem_type::getStartId(cell_id);
1451 __attribute__((always_inline))
inline const typename Mem_type::local_index_type &
getStopId(
typename Mem_type::local_index_type cell_id)
const
1453 return Mem_type::getStopId(cell_id);
1463 __attribute__((always_inline))
inline const typename Mem_type::local_index_type &
get_lin(
const typename Mem_type::local_index_type * part_id)
const
1465 return Mem_type::get_lin(part_id);
1471 size_t ghostMarker = 0;
1490 this->ghostMarker = ghostMarker;
1503 if (
opt & CL_HILBERT_CELL_KEYS) {
1524 if (
opt & CL_HILBERT_CELL_KEYS) {
1549 typedef typename Mem_type::local_index_type ids_type;
1555 for (
size_t i = 0 ; i < dim ; i++)
1557 spacing_c[i] = CellDecomposer_sm<dim,T,transform>::getCellBox().getHigh(i);
1558 div_c[i] = CellDecomposer_sm<dim,T,transform>::getDiv()[i];
1559 off[i] = CellDecomposer_sm<dim,T,transform>::getPadding(i);
1568 this->unitCellSpaceBox,
1569 CellDecomposer_sm<dim,T,transform>::getTransform()
1578 Mem_type::hostToDevice();
1583 const NNc_array<dim,(
unsigned int)openfpm::math::pow(3,dim)> & private_get_NNc_full ()
const
1588 const NNc_array<dim,(
unsigned int)openfpm::math::pow(3,dim)/2+1> & private_get_NNc_sym ()
const
1593 const NNc_array<dim,(
unsigned int)openfpm::math::pow(3,dim)> & private_get_NNc_sym_local ()
const
1595 return NNc_sym_local;
1598 bool private_get_from_cd()
const
1617 this->n_dec =
n_dec;
1638 template<
typename vector_pos_type2,
typename vector_prp_type>
1640 vector_pos_type2 & vPos,
1641 vector_prp_type & vPrp,
1645 this->ghostMarker = ghostMarker;
1646 if (
opt & CL_SYMMETRIC) {
1648 for (
size_t i = 0; i < ghostMarker; i++)
1649 this->
addDom(vPos.get(i), i);
1651 for (
size_t i = ghostMarker; i < vPos.size(); i++)
1652 this->
addPad(vPos.get(i), i);
1655 else if (
opt & CL_LOCAL_SYMMETRIC) {
1657 for (
size_t i = 0; i < ghostMarker ; i++)
1658 this->
add(vPos.get(i), i);
1662 for (
size_t i = ghostMarker; i < vPos.size() ; i++)
1663 this->
add(vPos.get(i), i);
1666 else if (
opt & CL_NON_SYMMETRIC) {
1668 for (
size_t i = 0; i < vPos.size() ; i++)
1670 this->
add(vPos.get(i), i);
1675 std::cerr <<
"No mode is selected to fill Cell List!\n";
1690 template<
unsigned int dim,
typename St>
static inline void cl_param_calculate(
Box<dim, St> & pbox,
size_t (&div)[dim], St r_cut,
const Ghost<dim, St> & enlarge)
1698 for (
size_t i = 0; i < dim; i++)
1700 div[i] =
static_cast<size_t>((pbox.
getP2().get(i) - pbox.
getP1().get(i)) / r_cut);
1715 template<
unsigned int dim,
typename St>
static
1716 inline void cl_param_calculateSym(
const Box<dim,St> & dom,
1724 for (
size_t i = 0 ; i < dim ; i++)
1730 for (
size_t i = 0 ; i < dim ; i++)
1732 size_t tmp = std::ceil(fabs(g.
getLow(i)) / r_cut);
1733 pad = (pad > tmp)?pad:tmp;
1735 tmp = std::ceil(fabs(g.
getHigh(i)) / r_cut);
1736 pad = (pad > tmp)?pad:tmp;
1739 cd_sm.setDimensions(dom,div,pad);
1752 template<
unsigned int dim,
typename St>
1753 static inline void cl_param_calculateSym(
const Box<dim,St> & dom,
1760 for (
size_t i = 0 ; i < dim ; i++)
1767 cd_sm.setDimensions(dom,div,pad);
This class represent an N-dimensional box.
Point< dim, T > getP1() const
Get the point p1.
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
__device__ __host__ T getHigh(int i) const
get the high interval of the box
Point< dim, T > getP2() const
Get the point p2.
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
void magnify(T mg)
Magnify the box.
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
it iterate through the elements of a cell
Class for FAST cell list implementation.
CellList< dim, T, Mem_type, transform, vector_pos_type > & operator=(const CellList< dim, T, Mem_type2, transform, vector_pos_type > &cell)
Constructor from a temporal object.
const openfpm::vector< size_t > & getCellSFCKeys()
Get the space filling curve object.
size_t getNelements(const size_t cell_id) const
Return the number of elements in the cell.
CellList< dim, T, Mem_type, transform, vector_pos_type > & operator=(const CellList< dim, T, Mem_type, transform, vector_pos_type > &cell)
Constructor from a temporal object.
auto get(size_t cell, size_t ele) const -> decltype(this->Mem_type::get(cell, ele))
Get an element in the cell.
void setGhostMarker(size_t ghostMarker)
Set the ghost marker.
__attribute__((always_inline)) inline const typename Mem_type size_t getGhostMarker() const
Return the starting point of the cell p.
const grid_sm< dim, void > & getGrid()
Return the underlying grid information of the cell list.
const NNc_array< dim,(unsigned int) openfpm::math::pow(3, dim)/2+1 > & getNNc_sym() const
Get the symmetric neighborhood.
wrap_unordered_map< T, openfpm::vector< long int > > rcache
Caching of r_cutoff radius.
NNc_array< dim,(unsigned int) openfpm::math::pow(3, dim)/2+1 > NNc_sym
The array contain the neighborhood of the cell-id in case of symmetric interaction.
CellParticleIterator getCellParticleIterator()
return the celllist iterator (across cells)
auto get(size_t cell, size_t ele) -> decltype(this->Mem_type::get(cell, ele))
Get an element in the cell.
void add(const T(&pos)[dim], typename Mem_type::local_index_type ele)
Add an element in the cell list.
__attribute__((always_inline)) inline CellNNIteratorSymMP< dim
Get the symmetric Neighborhood iterator.
void addPad(const Point< dim, T > &pos, typename Mem_type::local_index_type ele)
Add an element in the cell list forcing to be in the padding cells.
NNc_array< dim,(unsigned int) openfpm::math::pow(3, dim)> NNc_full
The array contain the neighborhood of the cell-id in case of asymmetric interaction.
Mem_type Mem_type_type
Type of internal memory structure.
void clear()
Clear the cell list.
bool isInitSFC
Space filling curve cells keys have to be filled once.
bool from_cd
True if has been initialized from CellDecomposer.
void InitializeStructures(const size_t(&div)[dim], size_t tot_n_cell, size_t slot=STARTING_NSLOT)
Initialize the structures of the data structure.
void addDom(const Point< dim, T > &pos, typename Mem_type::local_index_type ele)
Add an element in the cell list forcing to be in the domain cells.
__attribute__((always_inline)) inline CellNNIteratorSym< dim
Get the symmetric Neighborhood iterator.
CellList< dim, T, Mem_type, transform > & operator=(CellList< dim, T, Mem_type, transform > &&cell)
Constructor from a temporal object.
void set_ndec(size_t n_dec)
Set the n_dec number.
void fill(vector_pos_type2 &vPos, vector_prp_type &vPrp, size_t ghostMarker)
Fill cell list with particles at positions vPos.
size_t getNCells() const
Get the number of cells this cell-list contain.
CellList(Box< dim, T > &box, const size_t(&div)[dim], Matrix< dim, T > mat, const size_t pad=1, size_t slot=STARTING_NSLOT)
Cell list constructor.
__attribute__((always_inline)) inline CellNNIterator< dim
Get the Neighborhood iterator.
void destroy()
Litterary destroy the memory of the cell list, including the retained one.
size_t(& getPadding())[dim]
Return the number of padding cells of the Cell decomposer as an array.
ParticleIt_CellP< CellList< dim, T, Mem_type, transform, vector_pos_type > > CellParticleIterator
Cell particle iterator that follows space filling curve.
void initSFC(SFC_type &SFC)
Initialize Space-filling-curve (SFC)
void swap(CellList< dim, T, Mem_type, transform, vector_pos_type > &cl)
Swap the memory.
void Initialize(const Box< dim, T > &box, const size_t(&div)[dim], const size_t pad=1, size_t slot=STARTING_NSLOT)
void remove(size_t cell, size_t ele)
remove an element from the cell
CellList(CellDecomposer_sm< dim, T, transform > &cd_sm, const Box< dim, T > &box, const size_t pad=1, size_t slot=STARTING_NSLOT)
Cell list constructor from a cell decomposer.
CellList(CellList< dim, T, Mem_type, transform, vector_pos_type > &&cell)
Copy constructor.
void addCellGhostMarkers()
add ghost marker in each cell
void addDom(const T(&pos)[dim], typename Mem_type::local_index_type ele)
Add an element in the cell list forcing to be in the domain cells.
void setRadius(T radius)
Set the radius for the getNNIteratorRadius.
size_t getPadding(size_t i) const
Return the number of padding cells of the Cell decomposer.
void setOpt(size_t opt)
Sets the option flags that control the cell list.
T stype
Type of the coordinate space (double float)
openfpm::vector< size_t > SFCKeys
Cell keys that follow space filling curve.
ParticleIt_Cells< dim, CellList< dim, T, Mem_fast<>, transform > > getDomainIterator(openfpm::vector< size_t > &dom_cells)
Get an iterator over particles following the cell structure.
size_t getOpt() const
Returns the option flags that control the cell list.
CellList(const CellList< dim, T, Mem_type, transform, vector_pos_type > &cell)
Copy constructor.
bool isSFCInit() const
Returns a bool flag of SFC keys vector being filled.
CellIterator< CellList< dim, T, Mem_type, transform > > getParticleInCellIterator(size_t cell)
Get the Cell iterator.
size_t get_ndec() const
Set the n_dec number.
void clear(typename Mem_type::local_index_type cell_id)
Clear one cell of the cell list.
void addPad(const T(&pos)[dim], typename Mem_type::local_index_type ele)
Add an element in the cell list forcing to be in the padding cells.
CellList(Box< dim, T > &box, const size_t(&div)[dim], const size_t pad=1, size_t slot=STARTING_NSLOT)
Cell list constructor.
void add(const Point< dim, T > &pos, typename Mem_type::local_index_type ele)
Add an element in the cell list.
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)
CellList()
Default Constructor.
__attribute__((always_inline)) inline CellNNIteratorRadius< dim
Get the symmetric Neighborhood iterator.
openfpm::vector< long int > nnc_rad
Cells for the neighborhood radius.
Mem_type::local_index_type value_type
Object type that the structure store.
__attribute__((always_inline)) inline CellNNIteratorSymLocal< dim
Get the symmetric local Neighborhood iterator.
CellNNIteratorRadius< dim, CellList< dim, T, Mem_type, transform > > getNNIteratorRadius(size_t cell)
Get the Neighborhood iterator.
Iterator for the neighborhood of the cell structures with free radius.
Symmetric local iterator for the neighborhood of the cell structures.
Symmetric iterator for the neighborhood of the cell structures.
Symmetric iterator for the neighborhood of the cell structures.
Iterator for the neighborhood of the cell structures.
This class implement an NxN (dense) matrix.
It is a class that work like a vector of vector.
const local_index & get_lin(const local_index *part_id) const
Just return the value pointed by part_id.
const local_index & getStartId(local_index cell_id) const
Get the first element of a cell (as reference)
local_index slot
Number of slot for each cell.
const local_index & getStopId(local_index cell_id) const
Get the last element of a cell (as reference)
void swap(NNc_array< dim, size, thr > &nnc)
swap NNc_array
void init_sym()
Initialize the NNc array with symmetric neighborhood cells indexes.
void init_full()
Initialize the NNc array with full neighborhood cells indexes.
void init_sym_local()
Initialize the NNc array with symmetric local neighborhood cells indexes.
void set_size(const size_t(&sz)[dim])
Set the size in each.
This iterator iterate across the particles of a Cell-list following the Cell structure.
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Class for an hilbert order processing of cell keys for CellList implementation.
const grid_key_dx< dim > & get() const
Get the actual key.
bool isNext()
Check if there is the next element.
__device__ __host__ void set_d(index_type i, index_type id)
Set the i index.
__device__ __host__ index_type get(index_type i) const
Get the i index.
mem_id LinId(const grid_key_dx< N, ids_type > &gk, const signed char sum_id[N]) const
Linearization of the grid_key_dx with a specified shift.
__device__ __host__ const size_t(& getSize() const)[N]
Return the size of the grid as an array.
__device__ __host__ size_t size() const
Return the size of the grid.
Implementation of 1-D std::vector like structure.
void resize(size_t rs)
Resize the vector (locally)
void add()
Add local particle.
Wrapper of the unordered map.
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data