OpenFPM  5.2.0
Project that contain the implementation of distributed structures
CellList.hpp
1 /*
2  * CellList.hpp
3  *
4  * Created on: Mar 21, 2015
5  * Author: Pietro Incardona
6  */
7 
8 #ifndef CELLLIST_HPP_
9 #define CELLLIST_HPP_
10 
11 #include <unordered_map>
12 
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"
18 
19 #include "util/common.hpp"
20 
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"
33 
34 
36 template<typename key,typename val>
37 class wrap_unordered_map: public std::unordered_map<key,val>
38 {
39 };
40 
41 #ifdef HAVE_LIBQUADMATH
42 
43 #include <boost/multiprecision/float128.hpp>
44 
45 
47 template<typename val>
48 class wrap_unordered_map<boost::multiprecision::float128,val>
49 {
50 };
51 
52 #endif
53 
55 #define CELL_REALLOC 16ul
56 
57 #define STARTING_NSLOT 16
58 
59 // Cell list config options
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;
71 
78 template<unsigned int dim> void NNcalc_csr(openfpm::vector<std::pair<grid_key_dx<dim>,grid_key_dx<dim>>> & cNN)
79 {
80  // Calculate the NNc_full array, it is a structure to get the neighborhood array
81 
82  // compile-time array {0,0,0,....} {2,2,2,...} {1,1,1,...}
83 
84  typedef typename generate_array<size_t,dim, Fill_zero>::result NNzero;
85  typedef typename generate_array<size_t,dim, Fill_two>::result NNtwo;
86 
87  // Generate the sub-grid iterator
88 
89  size_t div[dim];
90 
91  // Calculate the divisions
92 
93  for (size_t i = 0 ; i < dim ; i++)
94  div[i] = 4;
95 
96  grid_sm<dim,void> gs(div);
97  grid_key_dx_iterator_sub<dim> gr_sub3(gs,NNzero::data,NNtwo::data);
98 
99  grid_key_dx<dim> src_; // Source cell
100  for (size_t i = 0; i < dim; i++)
101  src_.set_d(i,1);
102 
103  size_t middle = gs.LinId(src_);
104 
105  // Calculate the symmetric crs array
106  while (gr_sub3.isNext())
107  {
108  auto dst = gr_sub3.get();
109  grid_key_dx<dim> src = src_;
110 
111  if ((long int)middle > gs.LinId(dst))
112  {
113  ++gr_sub3;
114  continue;
115  }
116 
117  // Here we adjust src and dst to be in the positive quadrant
118 
119  for (size_t i = 0 ; i < dim; i++)
120  {
121  if (dst.get(i) == 0)
122  {
123  src.set_d(i,src.get(i) + 1);
124  dst.set_d(i,dst.get(i) + 1);
125  }
126  }
127 
128  src -= src_;
129  dst -= src_;
130 
131  cNN.add(std::pair<grid_key_dx<dim>,grid_key_dx<dim>>(src,dst));
132 
133  ++gr_sub3;
134 
135  }
136 };
137 
144 template<unsigned int dim> void NNcalc_sym(openfpm::vector<grid_key_dx<dim>> & cNN)
145 {
146  // Calculate the NNc_full array, it is a structure to get the neighborhood array
147 
148  // compile-time array {0,0,0,....} {2,2,2,...} {1,1,1,...}
149 
150  typedef typename generate_array<size_t,dim, Fill_zero>::result NNzero;
151  typedef typename generate_array<size_t,dim, Fill_two>::result NNtwo;
152 
153  // Generate the sub-grid iterator
154 
155  size_t div[dim];
156 
157  // Calculate the divisions
158 
159  for (size_t i = 0 ; i < dim ; i++)
160  div[i] = 4;
161 
162  grid_sm<dim,void> gs(div);
163  grid_key_dx_iterator_sub<dim> gr_sub3(gs,NNzero::data,NNtwo::data);
164 
165  grid_key_dx<dim> src_; // Source cell
166  for (size_t i = 0; i < dim; i++)
167  src_.set_d(i,1);
168 
169  size_t middle = gs.LinId(src_);
170 
171  // Calculate the symmetric array
172  while (gr_sub3.isNext())
173  {
174  auto dst = gr_sub3.get();
175 
176  if ((long int)middle > gs.LinId(dst))
177  {
178  ++gr_sub3;
179  continue;
180  }
181 
182  cNN.add(dst - src_);
183 
184  ++gr_sub3;
185 
186  }
187 };
188 
195 template<unsigned int dim> void NNcalc_full(openfpm::vector<grid_key_dx<dim>> & cNN)
196 {
197  // Calculate the NNc_full array, it is a structure to get the neighborhood array
198 
199  // compile-time array {0,0,0,....} {2,2,2,...} {1,1,1,...}
200 
201  typedef typename generate_array<size_t,dim, Fill_zero>::result NNzero;
202  typedef typename generate_array<size_t,dim, Fill_two>::result NNtwo;
203 
204  // Generate the sub-grid iterator
205 
206  size_t div[dim];
207 
208  // Calculate the divisions
209 
210  for (size_t i = 0 ; i < dim ; i++)
211  {div[i] = 4;}
212 
213  grid_sm<dim,void> gs(div);
214  grid_key_dx_iterator_sub<dim> gr_sub3(gs,NNzero::data,NNtwo::data);
215 
216  grid_key_dx<dim> src_; // Source cell
217  for (size_t i = 0; i < dim; i++)
218  src_.set_d(i,1);
219 
220  // Calculate the symmetric crs array
221  while (gr_sub3.isNext())
222  {
223  auto dst = gr_sub3.get();
224 
225  cNN.add(dst - src_);
226 
227  ++gr_sub3;
228  }
229 };
230 
231 
265 template<unsigned int dim, typename T, typename vector_type>
266 void NNcalc_rad(
267  T r_cut,
268  vector_type & radNeighborCellOffset,
269  const Box<dim,T> & unitCellSpaceBox,
270  const grid_sm<dim,void> & cellListGrid)
271 {
272  // 2*(r_cut / unitCellP2_{dim})+1
273  size_t nRadCellDim[dim];
274  size_t middleCellIndex[dim];
275  openfpm::vector<long int> radNeighborCellOffsetTemp;
276 
277  Point<dim,T> unitCellP2 = unitCellSpaceBox.getP2();
278 
279  for (size_t i = 0 ; i < dim ; i++)
280  {
281  nRadCellDim[i] = 2*(std::ceil(r_cut / unitCellP2.get(i)))+1;
282  middleCellIndex[i] = nRadCellDim[i] / 2;
283  }
284 
285  grid_sm<dim,void> radCellGrid(nRadCellDim);
286  grid_key_dx_iterator<dim> radCellGridIt(radCellGrid);
287 
288  Box<dim,T> middleCell;
289 
290  for (unsigned int i = 0 ; i < dim ; i++)
291  {
292  middleCell.setLow(i,middleCellIndex[i]*unitCellP2.get(i));
293  middleCell.setHigh(i,(middleCellIndex[i]+1)*unitCellP2.get(i));
294  }
295 
296  while (radCellGridIt.isNext())
297  {
298  auto key = radCellGridIt.get();
299 
300  Box<dim,T> cell;
301 
302  for (unsigned int i = 0 ; i < dim ; i++)
303  {
304  cell.setLow(i,key.get(i)*unitCellP2.get(i));
305  cell.setHigh(i,(key.get(i)+1)*unitCellP2.get(i));
306  }
307 
308  // here we check if the cell is in the radius.
309  if (cell.min_distance(middleCell) > r_cut) {
310  ++radCellGridIt; continue;
311  }
312 
313  for (size_t i = 0 ; i < dim ; i++)
314  {
315  key.set_d(i,key.get(i) - middleCellIndex[i]);
316  }
317 
318  radNeighborCellOffsetTemp.add(cellListGrid.LinId(key));
319 
320  ++radCellGridIt;
321  }
322 
323  radNeighborCellOffset.resize(radNeighborCellOffsetTemp.size());
324 
325  size_t index = 0;
326 
327  // start iteration with own cell
328  radNeighborCellOffset.template get<0>(index++) = 0;
329 
330  for (int i = 0; i < radNeighborCellOffsetTemp.size(); ++i)
331  {
332  int cellIndex = radNeighborCellOffsetTemp.template get<0>(i);
333 
334  if (cellIndex != 0)
335  radNeighborCellOffset.template get<0>(index++) = cellIndex;
336  }
337 }
338 
378 template<unsigned int dim, typename vector_type>
379 void NNcalc_box(
380  size_t NNeighbor,
381  vector_type & boxNeighborCellOffset,
382  const grid_sm<dim,void> & cellListGrid)
383 {
384  grid_key_dx<dim> cellPosStart;
385  grid_key_dx<dim> cellPosStop;
386  grid_key_dx<dim> cellPosMiddle;
387 
388  for (size_t i = 0 ; i < dim ; i++)
389  {
390  cellPosStart.set_d(i,0);
391  cellPosStop.set_d(i,2*NNeighbor);
392  cellPosMiddle.set_d(i,NNeighbor);
393  }
394 
395  boxNeighborCellOffset.resize(openfpm::math::pow(2*NNeighbor+1,dim));
396 
397  int cellIndexMiddle = cellListGrid.LinId(cellPosMiddle);
398  grid_key_dx_iterator_sub<dim> boxCellGridIt(cellListGrid, cellPosStart, cellPosStop);
399 
400  size_t index = 0;
401 
402  // start iteration with own cell
403  boxNeighborCellOffset.template get<0>(index++) = 0;
404 
405  while (boxCellGridIt.isNext())
406  {
407  int cellIndex = (int)cellListGrid.LinId(boxCellGridIt.get()) - cellIndexMiddle;
408 
409  if (cellIndex != 0)
410  boxNeighborCellOffset.template get<0>(index++) = cellIndex;
411 
412  ++boxCellGridIt;
413  }
414 }
415 
455 template<unsigned int dim, typename vector_type>
456 void NNcalc_boxSym(
457  size_t NNeighbor,
458  vector_type & boxNeighborCellOffset,
459  const grid_sm<dim,void> & cellListGrid)
460 {
461  grid_key_dx<dim> cellPosStart;
462  grid_key_dx<dim> cellPosStop;
463  grid_key_dx<dim> cellPosMiddle;
464 
465  for (size_t i = 0 ; i < dim ; i++)
466  {
467  cellPosStart.set_d(i,0);
468  cellPosStop.set_d(i,2*NNeighbor);
469  cellPosMiddle.set_d(i,NNeighbor);
470  }
471 
472  boxNeighborCellOffset.resize(0);
473 
474  int cellIndexMiddle = cellListGrid.LinId(cellPosMiddle);
475  grid_key_dx_iterator_sub<dim> boxCellGridIt(cellListGrid, cellPosStart, cellPosStop);
476 
477  size_t index = 0;
478 
479  // start iteration with own cell
480  boxNeighborCellOffset.add();
481  boxNeighborCellOffset.template get<0>(index++) = 0;
482 
483  while (boxCellGridIt.isNext())
484  {
485  int cellIndex = (int)cellListGrid.LinId(boxCellGridIt.get()) - cellIndexMiddle;
486 
487  if (cellIndex > 0) {
488  boxNeighborCellOffset.add();
489  boxNeighborCellOffset.template get<0>(index++) = cellIndex;
490  }
491 
492  ++boxCellGridIt;
493  }
494 }
495 
496 /* NOTE all the implementations
497  *
498  * has complexity O(1) in getting the cell id and the elements in a cell
499  * but with different constants
500  *
501  */
502 
550 template<
551  unsigned int dim,
552  typename T,
553  typename Mem_type = Mem_fast<>,
554  typename transform = no_transform<dim,T>,
555  typename vector_pos_type = openfpm::vector<Point<dim,T>>
556 >
557 class CellList : public CellDecomposer_sm<dim,T,transform>, public Mem_type
558 {
559 protected:
561  //
562  // * * *
563  // * x *
564  // * * *
565 
566 
567  NNc_array<dim,(unsigned int)openfpm::math::pow(3,dim)> NNc_full;
568 
570  //
571  // * * *
572  // x *
573  //
574 // long int NNc_sym[openfpm::math::pow(3,dim)/2+1];
575  NNc_array<dim,(unsigned int)openfpm::math::pow(3,dim)/2+1> NNc_sym;
576 
577  NNc_array<dim,(unsigned int)openfpm::math::pow(3,dim)> NNc_sym_local;
578 
579 private:
580 
582  size_t opt;
583 
586 
588  bool from_cd;
589 
592  size_t n_dec;
593 
596 
598  bool isInitSFC;
599 
602 
605 
607  void InitializeStructures(const size_t (& div)[dim], size_t tot_n_cell, size_t slot=STARTING_NSLOT)
608  {
609  Mem_type::init_to_zero(slot,tot_n_cell);
610 
611  NNc_full.set_size(div);
613 
614  NNc_sym.set_size(div);
615  NNc_sym.init_sym();
616 
617  NNc_sym_local.set_size(div);
618  NNc_sym_local.init_sym_local();
619  }
620 
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
622  {
623  size_t bc[dim];
624 
625  for (size_t i = 0 ; i < dim ; i++)
626  {bc[i] = NON_PERIODIC;}
627 
628  Box<dim,long int> bx = cd_sm.convertDomainSpaceIntoCellUnits(dom_box,bc);
629 
630  size_t div[dim];
631  size_t div_big[dim];
632 
633  for (size_t i = 0 ; i < dim ; i++)
634  {
635  div[i] = bx.getHigh(i) - bx.getLow(i);
636  div_big[i] = cd_sm.getDiv()[i] - 2*cd_sm.getPadding(i);
637  }
638 
639  cd.setDimensions(cd_sm.getDomain(),div_big,div, pad, bx.getP1());
640  }
641 
645  template <typename SFC_type>
646  inline void initSFC(SFC_type& SFC)
647  {
648  size_t pad = this->getPadding(0);
649  size_t sz[dim];
650  //Get grid_sm without padding (gs_small)
651  for (size_t i = 0; i < dim ; i++)
652  sz[i] = this->getGrid().size(i) - 2*pad;
653 
654  grid_sm<dim,void> gs_small(sz);
655 
656  size_t a = gs_small.size(0);
657 
658  for (size_t i = 1 ; i < dim ; i++)
659  {
660  if (a < gs_small.size(i))
661  a = gs_small.size(i);
662  }
663 
664  size_t m;
665 
666  //Calculate an hilberts curve order
667  for (m = 0; ; m++)
668  {
669  if ((1ul << m) >= a)
670  break;
671  }
672 
673  grid_key_dx_iterator<dim> it(gs_small);
674 
675  while (it.isNext())
676  {
677  auto gk = it.get();
678 
679  // Get a key of each cell and add to 'keys' vector
680  SFC.get_hkey(*this,gk,m);
681 
682  ++it;
683  }
684 
685  // Sort and linearize keys
686  SFC.linearize_hkeys(*this,m);
687  this->SFCKeys = SFC.getKeys();
688 
689  isInitSFC = true;
690  }
691 
692 public:
693 
695  typedef Mem_type Mem_type_type;
696 
698 
700  typedef typename Mem_type::local_index_type value_type;
701 
703  typedef T stype;
704 
706  typedef vector_pos_type internal_vector_pos_type;
707 
714  {
715  return CellDecomposer_sm<dim,T,transform>::getGrid();
716  }
717 
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)
732  {
733  size_t bc[dim];
734  for (size_t i = 0 ; i < dim ; i++) {bc[i] = NON_PERIODIC;}
735 
736  Box<dim,long int> bx = cd_sm.convertDomainSpaceIntoCellUnits(dom_box,bc);
737 
738  setCellDecomposer(*this,cd_sm,dom_box,pad);
739 
740  size_t div_w_pad[dim];
741  size_t tot_cell = 1;
742 
743  for (size_t i = 0 ; i < dim ; i++)
744  {
745  div_w_pad[i] = bx.getHigh(i) - bx.getLow(i) + 2*pad;
746  tot_cell *= div_w_pad[i];
747  }
748 
749  // here we set the cell-shift for the CellDecomposer
750 
751  InitializeStructures(div_w_pad,tot_cell);
752 
753  // Initialized from CellDecomposer
754  from_cd = true;
755  }
756 
765  void Initialize(const Box<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
766  {
767  Matrix<dim,T> mat;
768 
769  CellDecomposer_sm<dim,T,transform>::setDimensions(box,div, mat, pad);
770  Mem_type::set_slot(slot);
771 
772  // create the array that store the number of particle on each cell and se it to 0
773  InitializeStructures(this->cellListGrid.getSize(),this->cellListGrid.size());
774 
775  from_cd = false;
776  }
777 
779  CellList() : opt(CL_NON_SYMMETRIC | CL_LINEAR_CELL_KEYS), Mem_type(STARTING_NSLOT), isInitSFC(false) {};
780 
783  :Mem_type(STARTING_NSLOT)
784  {
785  this->operator=(cell);
786  }
787 
790  :Mem_type(STARTING_NSLOT)
791  {
792  this->operator=(cell);
793  }
794 
795 
805  CellList(Box<dim,T> & box, const size_t (&div)[dim], Matrix<dim,T> mat, const size_t pad = 1, size_t slot=STARTING_NSLOT)
806  :Mem_type(slot),
807  isInitSFC(false),
808  opt(CL_NON_SYMMETRIC | CL_LINEAR_CELL_KEYS),
809  CellDecomposer_sm<dim,T,transform>(box,div,mat,box.getP1(),pad)
810  {
811  Box<dim,T> sbox(box);
812  Initialize(sbox,div,pad,slot);
813  }
814 
823  CellList(Box<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
824  :Mem_type(slot),
825  isInitSFC(false),
826  opt(CL_NON_SYMMETRIC | CL_LINEAR_CELL_KEYS)
827  {
828  Initialize(box,div,pad,slot);
829  }
830 
841  CellList(CellDecomposer_sm<dim,T,transform> & cd_sm, const Box<dim,T> & box, const size_t pad = 1, size_t slot=STARTING_NSLOT)
842  :Mem_type(slot),
843  n_dec(0),
844  isInitSFC(false),
845  opt(CL_NON_SYMMETRIC | CL_LINEAR_CELL_KEYS)
846  {
847  Initialize(cd_sm,box,pad,slot);
848  }
849 
855  {}
856 
865  {
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]);
869 
870  Mem_type::swap(static_cast<Mem_type &&>(cell));
871 
872  static_cast<CellDecomposer_sm<dim,T,transform> &>(*this).swap(cell);
873 
874  n_dec = cell.n_dec;
875  from_cd = cell.from_cd;
876  ghostMarker = cell.ghostMarker;
877  opt = cell.opt;
878 
879  isInitSFC = cell.isInitSFC;
880  SFCKeys = cell.SFCKeys;
881 
882  return *this;
883  }
884 
893  {
894  NNc_full = cell.NNc_full;
895  NNc_sym = cell.NNc_sym;
896  NNc_sym_local = cell.NNc_sym_local;
897 
898  Mem_type::operator=(static_cast<const Mem_type &>(cell));
899 
900  static_cast<CellDecomposer_sm<dim,T,transform> &>(*this) = static_cast<const CellDecomposer_sm<dim,T,transform> &>(cell);
901 
902  n_dec = cell.n_dec;
903  from_cd = cell.from_cd;
904  ghostMarker = cell.ghostMarker;
905  opt = cell.opt;
906 
907  isInitSFC = cell.isInitSFC;
908  SFCKeys = cell.SFCKeys;
909 
910  return *this;
911  }
912 
920  template<typename Mem_type2>
922  {
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();
926 
927  Mem_type::copy_general(static_cast<const Mem_type2 &>(cell));
928 
929  static_cast<CellDecomposer_sm<dim,T,transform> &>(*this) = static_cast<const CellDecomposer_sm<dim,T,transform> &>(cell);
930 
931  n_dec = cell.get_ndec();
932  from_cd = cell.private_get_from_cd();
933  ghostMarker = cell.getGhostMarker();
934  opt = cell.getOpt();
935 
936  isInitSFC = false;
937 
938  return *this;
939  }
940 
946  void setRadius(T radius)
947  {
948  NNcalc_rad(radius,nnc_rad,this->getCellBox(),this->getGrid());
949  }
950 
959  {
960  ParticleIt_Cells<dim,CellList<dim,T,Mem_fast<>,transform>> it(*this,dom_cells);
961 
962  return it;
963  }
964 
971  inline void add(const T (& pos)[dim], typename Mem_type::local_index_type ele)
972  {
973  // calculate the Cell id
974  size_t cell_id = this->getCell(pos);
975 
976  Mem_type::addCell(cell_id,ele);
977  }
978 
985  inline void add(const Point<dim,T> & pos, typename Mem_type::local_index_type ele)
986  {
987  // calculate the Cell id
988  size_t cell_id = this->getCell(pos);
989 
990  Mem_type::addCell(cell_id,ele);
991  }
992 
993 
1002  inline void addDom(const T (& pos)[dim], typename Mem_type::local_index_type ele)
1003  {
1004  // calculate the Cell id
1005 
1006  size_t cell_id = this->getCellDom(pos);
1007 
1008  // add the element to the cell
1009 
1010  Mem_type::addCell(cell_id,ele);
1011  }
1012 
1021  inline void addDom(const Point<dim,T> & pos, typename Mem_type::local_index_type ele)
1022  {
1023  // calculate the Cell id
1024 
1025  size_t cell_id = this->getCellDom(pos);
1026 
1027  // add the element to the cell
1028 
1029  Mem_type::addCell(cell_id,ele);
1030  }
1031 
1040  inline void addPad(const T (& pos)[dim], typename Mem_type::local_index_type ele)
1041  {
1042  // calculate the Cell id
1043 
1044  size_t cell_id = this->getCellPad(pos);
1045 
1046  // add the element to the cell
1047 
1048  Mem_type::addCell(cell_id,ele);
1049  }
1050 
1059  inline void addPad(const Point<dim,T> & pos, typename Mem_type::local_index_type ele)
1060  {
1061  // calculate the Cell id
1062 
1063  size_t cell_id = this->getCell(pos);
1064 
1065  // add the element to the cell
1066 
1067  Mem_type::addCell(cell_id,ele);
1068  }
1069 
1074  inline void addCellGhostMarkers()
1075  {
1076  Mem_type::addCellGhostMarkers();
1077  }
1078 
1085  inline void remove(size_t cell, size_t ele)
1086  {
1087  Mem_type::remove(cell,ele);
1088  }
1089 
1094  inline size_t getNCells() const
1095  {
1096  return Mem_type::size();
1097  }
1098 
1106  inline size_t getNelements(const size_t cell_id) const
1107  {
1108  return Mem_type::getNelements(cell_id);
1109  }
1110 
1121  inline auto get(size_t cell, size_t ele) -> decltype(this->Mem_type::get(cell,ele))
1122  {
1123  return Mem_type::get(cell,ele);
1124  }
1125 
1136  inline auto get(size_t cell, size_t ele) const -> decltype(this->Mem_type::get(cell,ele))
1137  {
1138  return Mem_type::get(cell,ele);
1139  }
1140 
1147  {
1148  NNc_full.swap(cl.NNc_full);
1149  NNc_sym.swap(cl.NNc_sym);
1150  NNc_sym_local.swap(cl.NNc_sym_local);
1151 
1152  Mem_type::swap(static_cast<Mem_type &>(cl));
1153 
1154  static_cast<CellDecomposer_sm<dim,T,transform> &>(*this).swap(static_cast<CellDecomposer_sm<dim,T,transform> &>(cl));
1155 
1156  n_dec = cl.n_dec;
1157  from_cd = cl.from_cd;
1158 
1159  size_t optTmp = opt;
1160  opt = cl.opt;
1161  cl.opt = optTmp;
1162  }
1163 
1172  {
1174  }
1175 
1197  {
1199  return cln;
1200  }
1201 
1222  __attribute__((always_inline)) inline CellNNIterator<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,(int)FULL> getNNIteratorBox(size_t cell)
1223  {
1225  return cln;
1226 
1227  }
1228 
1240  {
1241  openfpm::vector<long int> & NNc = rcache[r_cut];
1242 
1243  if (NNc.size() == 0)
1244  {NNcalc_rad(r_cut,NNc,this->getCellBox(),this->getGrid());}
1245 
1247 
1248  return cln;
1249  }
1250 
1251 
1252 
1274  getNNIteratorBoxSym(size_t cell, size_t p, const vector_pos_type & v)
1275  {
1276 #ifdef SE_CLASS1
1277  if (from_cd == false)
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;}
1279 #endif
1280 
1282  return cln;
1283  }
1284 
1306  getNNIteratorBoxSymLocal(size_t cell, size_t p, const vector_pos_type & v)
1307  {
1308 #ifdef SE_CLASS1
1309  // if (from_cd == false)
1310  // {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;}
1311 #endif
1312 
1313  CellNNIteratorSymLocal<dim,CellList<dim,T,Mem_type,transform,vector_pos_type>,vector_pos_type,FULL> cln(cell,p,NNc_sym_local,*this,v);
1314  return cln;
1315  }
1316 
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)
1342  {
1343 #ifdef SE_CLASS1
1344  if (from_cd == false)
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;
1346 #endif
1347 
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);
1349  return cln;
1350  }
1351 
1357  const NNc_array<dim,(unsigned int)openfpm::math::pow(3,dim)/2+1> & getNNc_sym() const
1358  {
1359  return NNc_sym;
1360  }
1361 
1368  size_t getOpt() const
1369  {
1370  return opt;
1371  }
1372 
1378  void setOpt(size_t opt)
1379  {
1380  this->opt = opt;
1381  }
1382 
1383 
1391  size_t getPadding(size_t i) const
1392  {
1393  return CellDecomposer_sm<dim,T,transform>::getPadding(i);
1394  }
1395 
1402  size_t (& getPadding())[dim]
1403  {
1404  return CellDecomposer_sm<dim,T,transform>::getPadding();
1405  }
1406 
1410  void clear()
1411  {
1412  Mem_type::clear();
1413  isInitSFC = false;
1414  }
1415 
1419  void clear(typename Mem_type::local_index_type cell_id)
1420  {
1421  Mem_type::clear(cell_id);
1422  }
1423 
1427  void destroy()
1428  {
1429  Mem_type::destroy();
1430  }
1431 
1439  __attribute__((always_inline)) inline const typename Mem_type::local_index_type & getStartId(typename Mem_type::local_index_type cell_id) const
1440  {
1441  return Mem_type::getStartId(cell_id);
1442  }
1443 
1451  __attribute__((always_inline)) inline const typename Mem_type::local_index_type & getStopId(typename Mem_type::local_index_type cell_id) const
1452  {
1453  return Mem_type::getStopId(cell_id);
1454  }
1455 
1463  __attribute__((always_inline)) inline const typename Mem_type::local_index_type & get_lin(const typename Mem_type::local_index_type * part_id) const
1464  {
1465  return Mem_type::get_lin(part_id);
1466  }
1467 
1469 
1471  size_t ghostMarker = 0;
1472 
1478  inline size_t getGhostMarker() const
1479  {
1480  return ghostMarker;
1481  }
1482 
1488  inline void setGhostMarker(size_t ghostMarker)
1489  {
1490  this->ghostMarker = ghostMarker;
1491  }
1492 
1493 
1500  {
1501  if (isInitSFC == false)
1502  {
1503  if (opt & CL_HILBERT_CELL_KEYS) {
1504  SFCKeysHilbert<dim> SFC;
1505  initSFC(SFC);
1506  } else {
1507  SFCKeysLinear<dim> SFC;
1508  initSFC(SFC);
1509  }
1510  }
1511 
1512  return CellParticleIterator(*this);
1513  }
1514 
1521  {
1522  if (isInitSFC == false)
1523  {
1524  if (opt & CL_HILBERT_CELL_KEYS) {
1525  SFCKeysHilbert<dim> SFC;
1526  initSFC(SFC);
1527  } else {
1528  SFCKeysLinear<dim> SFC;
1529  initSFC(SFC);
1530  }
1531  }
1532 
1533  return this->SFCKeys;
1534  }
1535 
1541  inline bool isSFCInit() const {
1542  return isInitSFC;
1543  }
1544 
1545 #ifdef CUDA_GPU
1546 
1548  {
1549  typedef typename Mem_type::local_index_type ids_type;
1550 
1551  openfpm::array<T,dim> spacing_c;
1554 
1555  for (size_t i = 0 ; i < dim ; i++)
1556  {
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);
1560  }
1561 
1563  spacing_c,
1564  div_c,
1565  off,
1566  this->cellListGrid,
1567  this->cellShift,
1568  this->unitCellSpaceBox,
1569  CellDecomposer_sm<dim,T,transform>::getTransform()
1570  );
1571 
1572  return cl;
1573  }
1574 
1575 
1576  void hostToDevice()
1577  {
1578  Mem_type::hostToDevice();
1579  }
1580 
1581 #endif
1582 
1583  const NNc_array<dim,(unsigned int)openfpm::math::pow(3,dim)> & private_get_NNc_full () const
1584  {
1585  return NNc_full;
1586  }
1587 
1588  const NNc_array<dim,(unsigned int)openfpm::math::pow(3,dim)/2+1> & private_get_NNc_sym () const
1589  {
1590  return NNc_sym;
1591  }
1592 
1593  const NNc_array<dim,(unsigned int)openfpm::math::pow(3,dim)> & private_get_NNc_sym_local () const
1594  {
1595  return NNc_sym_local;
1596  }
1597 
1598  bool private_get_from_cd() const
1599  {
1600  return from_cd;
1601  }
1602 
1604 
1605  void resetBoxNN()
1606  {}
1607 
1609 
1615  void set_ndec(size_t n_dec)
1616  {
1617  this->n_dec = n_dec;
1618  }
1619 
1625  size_t get_ndec() const
1626  {
1627  return n_dec;
1628  }
1629 
1637  // vector_pos_type is a class level template parameter
1638  template<typename vector_pos_type2, typename vector_prp_type>
1639  void fill(
1640  vector_pos_type2 & vPos,
1641  vector_prp_type & vPrp,
1642  size_t ghostMarker)
1643  {
1644  this->clear();
1645  this->ghostMarker = ghostMarker;
1646  if (opt & CL_SYMMETRIC) {
1647 
1648  for (size_t i = 0; i < ghostMarker; i++)
1649  this->addDom(vPos.get(i), i);
1650 
1651  for (size_t i = ghostMarker; i < vPos.size(); i++)
1652  this->addPad(vPos.get(i), i);
1653  }
1654 
1655  else if (opt & CL_LOCAL_SYMMETRIC) {
1656 
1657  for (size_t i = 0; i < ghostMarker ; i++)
1658  this->add(vPos.get(i), i);
1659 
1660  this->addCellGhostMarkers();
1661 
1662  for (size_t i = ghostMarker; i < vPos.size() ; i++)
1663  this->add(vPos.get(i), i);
1664  }
1665 
1666  else if (opt & CL_NON_SYMMETRIC) {
1667 
1668  for (size_t i = 0; i < vPos.size() ; i++)
1669  {
1670  this->add(vPos.get(i), i);
1671  }
1672  }
1673 
1674  else {
1675  std::cerr << "No mode is selected to fill Cell List!\n";
1676  }
1677  }
1678 
1680 };
1681 
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)
1691 {
1692  // calculate the parameters of the cell list
1693 
1694  // extend by the ghost
1695  pbox.enlarge(enlarge);
1696 
1697  // Calculate the division array and the cell box
1698  for (size_t i = 0; i < dim; i++)
1699  {
1700  div[i] = static_cast<size_t>((pbox.getP2().get(i) - pbox.getP1().get(i)) / r_cut);
1701  div[i]++;
1702  pbox.setHigh(i,pbox.getLow(i) + div[i]*r_cut);
1703  }
1704 }
1705 
1715 template<unsigned int dim, typename St> static
1716 inline void cl_param_calculateSym(const Box<dim,St> & dom,
1717  CellDecomposer_sm<dim,St,shift<dim,St>> & cd_sm,
1718  Ghost<dim,St> g,
1719  St r_cut,
1720  size_t & pad)
1721 {
1722  size_t div[dim];
1723 
1724  for (size_t i = 0 ; i < dim ; i++)
1725  div[i] = (dom.getHigh(i) - dom.getLow(i)) / r_cut;
1726 
1727  g.magnify(1.013);
1728 
1729  // Calculate the maximum padding
1730  for (size_t i = 0 ; i < dim ; i++)
1731  {
1732  size_t tmp = std::ceil(fabs(g.getLow(i)) / r_cut);
1733  pad = (pad > tmp)?pad:tmp;
1734 
1735  tmp = std::ceil(fabs(g.getHigh(i)) / r_cut);
1736  pad = (pad > tmp)?pad:tmp;
1737  }
1738 
1739  cd_sm.setDimensions(dom,div,pad);
1740 }
1741 
1742 
1752 template<unsigned int dim, typename St>
1753 static inline void cl_param_calculateSym(const Box<dim,St> & dom,
1754  CellDecomposer_sm<dim,St,shift<dim,St>> & cd_sm,
1755  Ghost<dim,St> g,
1756  size_t & pad)
1757 {
1758  size_t div[dim];
1759 
1760  for (size_t i = 0 ; i < dim ; i++)
1761  div[i] = (dom.getHigh(i) - dom.getLow(i)) / g.getHigh(i);
1762 
1763  g.magnify(1.013);
1764 
1765  pad = 1;
1766 
1767  cd_sm.setDimensions(dom,div,pad);
1768 }
1769 
1770 
1771 template<unsigned int dim, typename St> using CELL_MEMFAST = CellList<dim, St, Mem_fast<>, shift<dim, St>>;
1772 template<unsigned int dim, typename St> using CELL_MEMBAL = CellList<dim, St, Mem_bal<>, shift<dim, St>>;
1773 template<unsigned int dim, typename St> using CELL_MEMMW = CellList<dim, St, Mem_mw<>, shift<dim, St>>;
1774 
1775 #endif /* CELLLIST_HPP_ */
This class represent an N-dimensional box.
Definition: Box.hpp:60
Point< dim, T > getP1() const
Get the point p1.
Definition: Box.hpp:707
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the box
Definition: Box.hpp:555
__device__ __host__ T getHigh(int i) const
get the high interval of the box
Definition: Box.hpp:566
Point< dim, T > getP2() const
Get the point p2.
Definition: Box.hpp:721
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
Definition: Box.hpp:822
void magnify(T mg)
Magnify the box.
Definition: Box.hpp:888
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
Definition: Box.hpp:543
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
Definition: Box.hpp:532
it iterate through the elements of a cell
Class for FAST cell list implementation.
Definition: CellList.hpp:558
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.
Definition: CellList.hpp:921
const openfpm::vector< size_t > & getCellSFCKeys()
Get the space filling curve object.
Definition: CellList.hpp:1520
size_t getNelements(const size_t cell_id) const
Return the number of elements in the cell.
Definition: CellList.hpp:1106
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.
Definition: CellList.hpp:892
auto get(size_t cell, size_t ele) const -> decltype(this->Mem_type::get(cell, ele))
Get an element in the cell.
Definition: CellList.hpp:1136
void setGhostMarker(size_t ghostMarker)
Set the ghost marker.
Definition: CellList.hpp:1488
__attribute__((always_inline)) inline const typename Mem_type size_t getGhostMarker() const
Return the starting point of the cell p.
Definition: CellList.hpp:1478
const grid_sm< dim, void > & getGrid()
Return the underlying grid information of the cell list.
Definition: CellList.hpp:713
const NNc_array< dim,(unsigned int) openfpm::math::pow(3, dim)/2+1 > & getNNc_sym() const
Get the symmetric neighborhood.
Definition: CellList.hpp:1357
wrap_unordered_map< T, openfpm::vector< long int > > rcache
Caching of r_cutoff radius.
Definition: CellList.hpp:585
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.
Definition: CellList.hpp:575
CellParticleIterator getCellParticleIterator()
return the celllist iterator (across cells)
Definition: CellList.hpp:1499
auto get(size_t cell, size_t ele) -> decltype(this->Mem_type::get(cell, ele))
Get an element in the cell.
Definition: CellList.hpp:1121
void add(const T(&pos)[dim], typename Mem_type::local_index_type ele)
Add an element in the cell list.
Definition: CellList.hpp:971
__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.
Definition: CellList.hpp:1059
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.
Definition: CellList.hpp:567
Mem_type Mem_type_type
Type of internal memory structure.
Definition: CellList.hpp:695
void clear()
Clear the cell list.
Definition: CellList.hpp:1410
bool isInitSFC
Space filling curve cells keys have to be filled once.
Definition: CellList.hpp:598
bool from_cd
True if has been initialized from CellDecomposer.
Definition: CellList.hpp:588
void InitializeStructures(const size_t(&div)[dim], size_t tot_n_cell, size_t slot=STARTING_NSLOT)
Initialize the structures of the data structure.
Definition: CellList.hpp:607
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.
Definition: CellList.hpp:1021
__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.
Definition: CellList.hpp:864
void set_ndec(size_t n_dec)
Set the n_dec number.
Definition: CellList.hpp:1615
void fill(vector_pos_type2 &vPos, vector_prp_type &vPrp, size_t ghostMarker)
Fill cell list with particles at positions vPos.
Definition: CellList.hpp:1639
size_t getNCells() const
Get the number of cells this cell-list contain.
Definition: CellList.hpp:1094
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.
Definition: CellList.hpp:805
__attribute__((always_inline)) inline CellNNIterator< dim
Get the Neighborhood iterator.
void destroy()
Litterary destroy the memory of the cell list, including the retained one.
Definition: CellList.hpp:1427
size_t(& getPadding())[dim]
Return the number of padding cells of the Cell decomposer as an array.
Definition: CellList.hpp:1402
ParticleIt_CellP< CellList< dim, T, Mem_type, transform, vector_pos_type > > CellParticleIterator
Cell particle iterator that follows space filling curve.
Definition: CellList.hpp:601
void initSFC(SFC_type &SFC)
Initialize Space-filling-curve (SFC)
Definition: CellList.hpp:646
size_t n_dec
Definition: CellList.hpp:592
void swap(CellList< dim, T, Mem_type, transform, vector_pos_type > &cl)
Swap the memory.
Definition: CellList.hpp:1146
~CellList()
Destructor.
Definition: CellList.hpp:854
void Initialize(const Box< dim, T > &box, const size_t(&div)[dim], const size_t pad=1, size_t slot=STARTING_NSLOT)
Definition: CellList.hpp:765
void remove(size_t cell, size_t ele)
remove an element from the cell
Definition: CellList.hpp:1085
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.
Definition: CellList.hpp:841
CellList(CellList< dim, T, Mem_type, transform, vector_pos_type > &&cell)
Copy constructor.
Definition: CellList.hpp:789
void addCellGhostMarkers()
add ghost marker in each cell
Definition: CellList.hpp:1074
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.
Definition: CellList.hpp:1002
void setRadius(T radius)
Set the radius for the getNNIteratorRadius.
Definition: CellList.hpp:946
size_t getPadding(size_t i) const
Return the number of padding cells of the Cell decomposer.
Definition: CellList.hpp:1391
void setOpt(size_t opt)
Sets the option flags that control the cell list.
Definition: CellList.hpp:1378
T stype
Type of the coordinate space (double float)
Definition: CellList.hpp:703
openfpm::vector< size_t > SFCKeys
Cell keys that follow space filling curve.
Definition: CellList.hpp:604
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.
Definition: CellList.hpp:958
size_t getOpt() const
Returns the option flags that control the cell list.
Definition: CellList.hpp:1368
CellList(const CellList< dim, T, Mem_type, transform, vector_pos_type > &cell)
Copy constructor.
Definition: CellList.hpp:782
bool isSFCInit() const
Returns a bool flag of SFC keys vector being filled.
Definition: CellList.hpp:1541
CellIterator< CellList< dim, T, Mem_type, transform > > getParticleInCellIterator(size_t cell)
Get the Cell iterator.
Definition: CellList.hpp:1171
size_t get_ndec() const
Set the n_dec number.
Definition: CellList.hpp:1625
void clear(typename Mem_type::local_index_type cell_id)
Clear one cell of the cell list.
Definition: CellList.hpp:1419
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.
Definition: CellList.hpp:1040
CellList(Box< dim, T > &box, const size_t(&div)[dim], const size_t pad=1, size_t slot=STARTING_NSLOT)
Cell list constructor.
Definition: CellList.hpp:823
void add(const Point< dim, T > &pos, typename Mem_type::local_index_type ele)
Add an element in the cell list.
Definition: CellList.hpp:985
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:731
size_t opt
Option flags.
Definition: CellList.hpp:582
CellList()
Default Constructor.
Definition: CellList.hpp:779
__attribute__((always_inline)) inline CellNNIteratorRadius< dim
Get the symmetric Neighborhood iterator.
openfpm::vector< long int > nnc_rad
Cells for the neighborhood radius.
Definition: CellList.hpp:595
Mem_type::local_index_type value_type
Object type that the structure store.
Definition: CellList.hpp:700
__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.
Definition: CellList.hpp:1196
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.
Definition: Matrix.hpp:33
It is a class that work like a vector of vector.
Definition: MemFast.hpp:88
const local_index & get_lin(const local_index *part_id) const
Just return the value pointed by part_id.
Definition: MemFast.hpp:418
const local_index & getStartId(local_index cell_id) const
Get the first element of a cell (as reference)
Definition: MemFast.hpp:382
local_index slot
Number of slot for each cell.
Definition: MemFast.hpp:90
const local_index & getStopId(local_index cell_id) const
Get the last element of a cell (as reference)
Definition: MemFast.hpp:406
void swap(NNc_array< dim, size, thr > &nnc)
swap NNc_array
Definition: NNc_array.hpp:181
void init_sym()
Initialize the NNc array with symmetric neighborhood cells indexes.
Definition: NNc_array.hpp:104
void init_full()
Initialize the NNc array with full neighborhood cells indexes.
Definition: NNc_array.hpp:76
void init_sym_local()
Initialize the NNc array with symmetric local neighborhood cells indexes.
Definition: NNc_array.hpp:148
void set_size(const size_t(&sz)[dim])
Set the size in each.
Definition: NNc_array.hpp:47
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.
Definition: Point.hpp:28
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Definition: Point.hpp:172
Class for an hilbert order processing of cell keys for CellList implementation.
Definition: SFCKeys.hpp:69
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.
Definition: grid_key.hpp:516
__device__ __host__ index_type get(index_type i) const
Get the i index.
Definition: grid_key.hpp:503
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.
Definition: grid_sm.hpp:454
__device__ __host__ const size_t(& getSize() const)[N]
Return the size of the grid as an array.
Definition: grid_sm.hpp:760
__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.
Definition: map_vector.hpp:204
size_t size()
Stub size.
Definition: map_vector.hpp:212
Distributed vector.
void resize(size_t rs)
Resize the vector (locally)
void add()
Add local particle.
Wrapper of the unordered map.
Definition: CellList.hpp:38
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data