OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
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 "Vector/map_vector.hpp"
12 #include "CellDecomposer.hpp"
13 #include "Space/SpaceBox.hpp"
14 #include "util/mathutil.hpp"
15 #include "CellNNIterator.hpp"
16 #include "Space/Shape/HyperCube.hpp"
17 #include "CellListNNIteratorRadius.hpp"
18 #include <unordered_map>
19 
20 #include "CellListIterator.hpp"
21 #include "ParticleIt_Cells.hpp"
22 #include "ParticleItCRS_Cells.hpp"
23 #include "util/common.hpp"
24 
25 #include "NN/Mem_type/MemFast.hpp"
26 #include "NN/Mem_type/MemBalanced.hpp"
27 #include "NN/Mem_type/MemMemoryWise.hpp"
28 #include "NN/CellList/NNc_array.hpp"
29 
31 template<typename key,typename val>
32 class wrap_unordered_map: public std::unordered_map<key,val>
33 {
34 };
35 
36 #ifdef HAVE_LIBQUADMATH
37 
38 #include <boost/multiprecision/float128.hpp>
39 
40 
42 template<typename val>
43 class wrap_unordered_map<boost::multiprecision::float128,val>
44 {
45 };
46 
47 #endif
48 
50 #define CELL_REALLOC 16ul
51 
52 #define STARTING_NSLOT 16
53 
60 template<unsigned int dim> void NNcalc_csr(openfpm::vector<std::pair<grid_key_dx<dim>,grid_key_dx<dim>>> & cNN)
61 {
62  // Calculate the NNc_full array, it is a structure to get the neighborhood array
63 
64  // compile-time array {0,0,0,....} {2,2,2,...} {1,1,1,...}
65 
66  typedef typename generate_array<size_t,dim, Fill_zero>::result NNzero;
67  typedef typename generate_array<size_t,dim, Fill_two>::result NNtwo;
68 
69  // Generate the sub-grid iterator
70 
71  size_t div[dim];
72 
73  // Calculate the divisions
74 
75  for (size_t i = 0 ; i < dim ; i++)
76  div[i] = 4;
77 
78  grid_sm<dim,void> gs(div);
79  grid_key_dx_iterator_sub<dim> gr_sub3(gs,NNzero::data,NNtwo::data);
80 
81  grid_key_dx<dim> src_; // Source cell
82  for (size_t i = 0; i < dim; i++)
83  src_.set_d(i,1);
84 
85  size_t middle = gs.LinId(src_);
86 
87  // Calculate the symmetric crs array
88  while (gr_sub3.isNext())
89  {
90  auto dst = gr_sub3.get();
91  grid_key_dx<dim> src = src_;
92 
93  if ((long int)middle > gs.LinId(dst))
94  {
95  ++gr_sub3;
96  continue;
97  }
98 
99  // Here we adjust src and dst to be in the positive quadrant
100 
101  for (size_t i = 0 ; i < dim; i++)
102  {
103  if (dst.get(i) == 0)
104  {
105  src.set_d(i,src.get(i) + 1);
106  dst.set_d(i,dst.get(i) + 1);
107  }
108  }
109 
110  src -= src_;
111  dst -= src_;
112 
113  cNN.add(std::pair<grid_key_dx<dim>,grid_key_dx<dim>>(src,dst));
114 
115  ++gr_sub3;
116 
117  }
118 };
119 
126 template<unsigned int dim> void NNcalc_sym(openfpm::vector<grid_key_dx<dim>> & cNN)
127 {
128  // Calculate the NNc_full array, it is a structure to get the neighborhood array
129 
130  // compile-time array {0,0,0,....} {2,2,2,...} {1,1,1,...}
131 
132  typedef typename generate_array<size_t,dim, Fill_zero>::result NNzero;
133  typedef typename generate_array<size_t,dim, Fill_two>::result NNtwo;
134 
135  // Generate the sub-grid iterator
136 
137  size_t div[dim];
138 
139  // Calculate the divisions
140 
141  for (size_t i = 0 ; i < dim ; i++)
142  div[i] = 4;
143 
144  grid_sm<dim,void> gs(div);
145  grid_key_dx_iterator_sub<dim> gr_sub3(gs,NNzero::data,NNtwo::data);
146 
147  grid_key_dx<dim> src_; // Source cell
148  for (size_t i = 0; i < dim; i++)
149  src_.set_d(i,1);
150 
151  size_t middle = gs.LinId(src_);
152 
153  // Calculate the symmetric array
154  while (gr_sub3.isNext())
155  {
156  auto dst = gr_sub3.get();
157 
158  if ((long int)middle > gs.LinId(dst))
159  {
160  ++gr_sub3;
161  continue;
162  }
163 
164  cNN.add(dst - src_);
165 
166  ++gr_sub3;
167 
168  }
169 };
170 
177 template<unsigned int dim> void NNcalc_full(openfpm::vector<grid_key_dx<dim>> & cNN)
178 {
179  // Calculate the NNc_full array, it is a structure to get the neighborhood array
180 
181  // compile-time array {0,0,0,....} {2,2,2,...} {1,1,1,...}
182 
183  typedef typename generate_array<size_t,dim, Fill_zero>::result NNzero;
184  typedef typename generate_array<size_t,dim, Fill_two>::result NNtwo;
185 
186  // Generate the sub-grid iterator
187 
188  size_t div[dim];
189 
190  // Calculate the divisions
191 
192  for (size_t i = 0 ; i < dim ; i++)
193  {div[i] = 4;}
194 
195  grid_sm<dim,void> gs(div);
196  grid_key_dx_iterator_sub<dim> gr_sub3(gs,NNzero::data,NNtwo::data);
197 
198  grid_key_dx<dim> src_; // Source cell
199  for (size_t i = 0; i < dim; i++)
200  src_.set_d(i,1);
201 
202  // Calculate the symmetric crs array
203  while (gr_sub3.isNext())
204  {
205  auto dst = gr_sub3.get();
206 
207  cNN.add(dst - src_);
208 
209  ++gr_sub3;
210  }
211 };
212 
213 
214 /* NOTE all the implementations
215  *
216  * has complexity O(1) in getting the cell id and the elements in a cell
217  * but with different constants
218  *
219  */
220 
268 template<unsigned int dim, typename T, typename Mem_type, typename transform = no_transform<dim,T>, typename base=openfpm::vector<size_t>>
269 class CellList : public CellDecomposer_sm<dim,T,transform>, public Mem_type
270 {
271 protected:
273  //
274  // * * *
275  // * x *
276  // * * *
277 
278 
280 // long int NNc_full[openfpm::math::pow(3,dim)];
281 
283  //
284  // * * *
285  // x *
286  //
287 // long int NNc_sym[openfpm::math::pow(3,dim)/2+1];
288  NNc_array<dim,(unsigned int)openfpm::math::pow(3,dim)/2+1> NNc_sym;
289 
290 private:
291 
294 
296  bool from_cd;
297 
300  size_t n_dec;
301 
335  void NNcalc(T r_cut, openfpm::vector<long int> & NNcell)
336  {
337  size_t n_cell[dim];
338  size_t n_cell_mid[dim];
339 
340  Point<dim,T> spacing = this->getCellBox().getP2();
341  const grid_sm<dim,void> & gs = this->getGrid();
342 
343  for (size_t i = 0 ; i < dim ; i++)
344  {
345  n_cell[i] = 2*(std::ceil(r_cut / spacing.get(i)))+1;
346  n_cell_mid[i] = n_cell[i] / 2;
347  }
348 
349  grid_sm<dim,void> gsc(n_cell);
350  grid_key_dx_iterator<dim> gkdi(gsc);
351 
352  while (gkdi.isNext())
353  {
354  auto key = gkdi.get();
355 
356  for (size_t i = 0 ; i < dim ; i++)
357  key.set_d(i,key.get(i) - n_cell_mid[i]);
358 
359  NNcell.add(gs.LinId(key));
360 
361  ++gkdi;
362  }
363  }
364 
366  void InitializeStructures(const size_t (& div)[dim], size_t tot_n_cell, size_t slot=STARTING_NSLOT)
367  {
368  Mem_type::init_to_zero(slot,tot_n_cell);
369 
370  NNc_full.set_size(div);
372 
373  NNc_sym.set_size(div);
374  NNc_sym.init_sym();
375  }
376 
377  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
378  {
379  size_t bc[dim];
380 
381  for (size_t i = 0 ; i < dim ; i++)
382  bc[i] = NON_PERIODIC;
383 
384  Box<dim,long int> bx = cd_sm.convertDomainSpaceIntoCellUnits(dom_box,bc);
385 
386  size_t div[dim];
387  size_t div_big[dim];
388 
389  for (size_t i = 0 ; i < dim ; i++)
390  {
391  div[i] = bx.getHigh(i) - bx.getLow(i);
392  div_big[i] = cd_sm.getDiv()[i] - 2*cd_sm.getPadding(i);
393  }
394 
395  cd.setDimensions(cd_sm.getDomain(),div_big,div, pad, bx.getP1());
396  }
397 
398 public:
399 
401  typedef Mem_type Mem_type_type;
402 
404 
406  typedef typename base::value_type value_type;
407 
409  typedef T stype;
410 
417  {
418  return CellDecomposer_sm<dim,T,transform>::getGrid();
419  }
420 
434  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)
435  {
436  size_t bc[dim];
437  for (size_t i = 0 ; i < dim ; i++) {bc[i] = NON_PERIODIC;}
438 
439  Box<dim,long int> bx = cd_sm.convertDomainSpaceIntoCellUnits(dom_box,bc);
440 
441  setCellDecomposer(*this,cd_sm,dom_box,pad);
442 
443  size_t div_w_pad[dim];
444  size_t tot_cell = 1;
445 
446  for (size_t i = 0 ; i < dim ; i++)
447  {
448  div_w_pad[i] = bx.getHigh(i) - bx.getLow(i) + 2*pad;
449  tot_cell *= div_w_pad[i];
450  }
451 
452  // here we set the cell-shift for the CellDecomposer
453 
454  InitializeStructures(div_w_pad,tot_cell);
455 
456  // Initialized from CellDecomposer
457  from_cd = true;
458  }
459 
468  void Initialize(const Box<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
469  {
470  SpaceBox<dim,T> sbox(box);
471 
472  // Initialize point transformation
473 
474  Initialize(sbox,div,pad,slot);
475  }
476 
485  void Initialize(const SpaceBox<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
486  {
487  Matrix<dim,T> mat;
488 
489  CellDecomposer_sm<dim,T,transform>::setDimensions(box,div, mat, pad);
490  Mem_type::set_slot(slot);
491 
492  // create the array that store the number of particle on each cell and se it to 0
493  InitializeStructures(this->gr_cell.getSize(),this->gr_cell.size());
494 
495  from_cd = false;
496  }
497 
500 
501  :Mem_type(STARTING_NSLOT)
502  {};
503 
506  :Mem_type(STARTING_NSLOT)
507  {
508  this->operator=(cell);
509  }
510 
513  :Mem_type(STARTING_NSLOT)
514  {
515  this->operator=(cell);
516  }
517 
518 
528  CellList(Box<dim,T> & box, const size_t (&div)[dim], Matrix<dim,T> mat, const size_t pad = 1, size_t slot=STARTING_NSLOT)
529  :Mem_type(slot),CellDecomposer_sm<dim,T,transform>(box,div,mat,box.getP1(),pad)
530  {
531  SpaceBox<dim,T> sbox(box);
532  Initialize(sbox,div,pad,slot);
533  }
534 
543  CellList(Box<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
544  :Mem_type(slot),n_dec(0)
545  {
546  SpaceBox<dim,T> sbox(box);
547  Initialize(sbox,div,pad,slot);
548  }
549 
558  CellList(SpaceBox<dim,T> & box, const size_t (&div)[dim], const size_t pad = 1, size_t slot=STARTING_NSLOT)
559  :Mem_type(slot)
560  {
561  Initialize(box,div,pad,slot);
562  }
563 
574  CellList(CellDecomposer_sm<dim,T,transform> & cd_sm, const Box<dim,T> & box, const size_t pad = 1, size_t slot=STARTING_NSLOT)
575  :Mem_type(slot),n_dec(0)
576  {
577  Initialize(cd_sm,box,pad,slot);
578  }
579 
585  {}
586 
595  {
596  std::copy(&cell.NNc_full[0],&cell.NNc_full[openfpm::math::pow(3,dim)],&NNc_full[0]);
597  std::copy(&cell.NNc_sym[0],&cell.NNc_sym[openfpm::math::pow(3,dim)/2+1],&NNc_sym[0]);
598 
599  Mem_type::swap(static_cast<Mem_type &&>(cell));
600 
601  static_cast<CellDecomposer_sm<dim,T,transform> &>(*this).swap(cell);
602 
603  n_dec = cell.n_dec;
604  from_cd = cell.from_cd;
605 
606  return *this;
607  }
608 
617  {
618  NNc_full = cell.NNc_full;
619  NNc_sym = cell.NNc_sym;
620 
621  Mem_type::operator=(static_cast<const Mem_type &>(cell));
622 
623  static_cast<CellDecomposer_sm<dim,T,transform> &>(*this) = static_cast<const CellDecomposer_sm<dim,T,transform> &>(cell);
624 
625  n_dec = cell.n_dec;
626  from_cd = cell.from_cd;
627 
628  return *this;
629  }
630 
639  {
640  ParticleIt_Cells<dim,CellList<dim,T,Mem_fast<>,transform,base>> it(*this,dom_cells);
641 
642  return it;
643  }
644 
651  inline void addCell(size_t cell_id, typename base::value_type ele)
652  {
653  Mem_type::addCell(cell_id,ele);
654  }
655 
662  inline void add(const T (& pos)[dim], typename base::value_type ele)
663  {
664  // calculate the Cell id
665  size_t cell_id = this->getCell(pos);
666 
667  Mem_type::add(cell_id,ele);
668  }
669 
676  inline void add(const Point<dim,T> & pos, typename base::value_type ele)
677  {
678  // calculate the Cell id
679  size_t cell_id = this->getCell(pos);
680 
681  Mem_type::add(cell_id,ele);
682  }
683 
684 
693  inline void addDom(const T (& pos)[dim], typename base::value_type ele)
694  {
695  // calculate the Cell id
696 
697  size_t cell_id = this->getCellDom(pos);
698 
699  // add the element to the cell
700 
701  addCell(cell_id,ele);
702  }
703 
712  inline void addDom(const Point<dim,T> & pos, typename base::value_type ele)
713  {
714  // calculate the Cell id
715 
716  size_t cell_id = this->getCellDom(pos);
717 
718  // add the element to the cell
719 
720  addCell(cell_id,ele);
721  }
722 
731  inline void addPad(const T (& pos)[dim], typename base::value_type ele)
732  {
733  // calculate the Cell id
734 
735  size_t cell_id = this->getCellPad(pos);
736 
737  // add the element to the cell
738 
739  addCell(cell_id,ele);
740  }
741 
750  inline void addPad(const Point<dim,T> & pos, typename base::value_type ele)
751  {
752  // calculate the Cell id
753 
754  size_t cell_id = this->getCell(pos);
755 
756  // add the element to the cell
757 
758  addCell(cell_id,ele);
759  }
760 
767  inline void remove(size_t cell, size_t ele)
768  {
769  Mem_type::remove(cell,ele);
770  }
771 
779  inline size_t getNelements(const size_t cell_id) const
780  {
781  return Mem_type::getNelements(cell_id);
782  }
783 
794  inline auto get(size_t cell, size_t ele) -> decltype(this->Mem_type::get(cell,ele))
795  {
796  return Mem_type::get(cell,ele);
797  }
798 
809  inline auto get(size_t cell, size_t ele) const -> decltype(this->Mem_type::get(cell,ele))
810  {
811  return Mem_type::get(cell,ele);
812  }
813 
820  {
821  NNc_full.swap(cl.NNc_full);
822  NNc_sym.swap(cl.NNc_sym);
823 
824  Mem_type::swap(static_cast<Mem_type &>(cl));
825 
826  static_cast<CellDecomposer_sm<dim,T,transform> &>(*this) = static_cast<const CellDecomposer_sm<dim,T,transform> &>(cl);
827  }
828 
837  {
839  }
840 
861  template<unsigned int impl=NO_CHECK> inline CellNNIterator<dim,CellList<dim,T,Mem_type,transform,base>,(int)FULL,impl> getNNIterator(size_t cell)
862  {
864  return cln;
865 
866  }
867 
878  template<unsigned int impl=NO_CHECK> inline CellNNIteratorRadius<dim,CellList<dim,T,Mem_type,transform,base>,impl> getNNIteratorRadius(size_t cell, T r_cut)
879  {
880  openfpm::vector<long int> & NNc = rcache[r_cut];
881 
882  if (NNc.size() == 0)
883  NNcalc(r_cut,NNc);
884 
886 
887  return cln;
888  }
889 
890 
891 
912  template<unsigned int impl>
914  getNNIteratorSym(size_t cell, size_t p, const openfpm::vector<Point<dim,T>> & v)
915  {
916 #ifdef SE_CLASS1
917  if (from_cd == false)
918  {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;}
919 #endif
920 
922  return cln;
923  }
924 
947  template<unsigned int impl>
949  getNNIteratorSymMP(size_t cell, size_t p, const openfpm::vector<Point<dim,T>> & v_p1, const openfpm::vector<Point<dim,T>> & v_p2)
950  {
951 #ifdef SE_CLASS1
952  if (from_cd == false)
953  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;
954 #endif
955 
956  CellNNIteratorSymMP<dim,CellList<dim,T,Mem_type,transform,base>,SYM,impl> cln(cell,p,NNc_sym,*this,v_p1,v_p2);
957  return cln;
958  }
959 
965  const NNc_array<dim,(unsigned int)openfpm::math::pow(3,dim)/2+1> & getNNc_sym() const
966  {
967  return NNc_sym;
968  }
969 
977  size_t getPadding(size_t i) const
978  {
979  return CellDecomposer_sm<dim,T,transform>::getPadding(i);
980  }
981 
988  size_t (& getPadding())[dim]
989  {
990  return CellDecomposer_sm<dim,T,transform>::getPadding();
991  }
992 
996  void clear()
997  {
998  Mem_type::clear();
999  }
1000 
1008  inline const typename Mem_type::loc_index & getStartId(typename Mem_type::loc_index cell_id) const
1009  {
1010  return Mem_type::getStartId(cell_id);
1011  }
1012 
1020  inline const typename Mem_type::loc_index & getStopId(typename Mem_type::loc_index cell_id) const
1021  {
1022  return Mem_type::getStopId(cell_id);
1023  }
1024 
1032  inline const typename Mem_type::loc_index & get_lin(const typename Mem_type::loc_index * part_id) const
1033  {
1034  return Mem_type::get_lin(part_id);
1035  }
1036 
1038 
1040  size_t g_m = 0;
1041 
1047  inline size_t get_gm()
1048  {
1049  return g_m;
1050  }
1051 
1057  inline void set_gm(size_t g_m)
1058  {
1059  this->g_m = g_m;
1060  }
1061 
1063 
1065 
1071  void set_ndec(size_t n_dec)
1072  {
1073  this->n_dec = n_dec;
1074  }
1075 
1081  size_t get_ndec() const
1082  {
1083  return n_dec;
1084  }
1085 
1087 };
1088 
1097 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)
1098 {
1099  // calculate the parameters of the cell list
1100 
1101  // extend by the ghost
1102  pbox.enlarge(enlarge);
1103 
1104  // Calculate the division array and the cell box
1105  for (size_t i = 0; i < dim; i++)
1106  {
1107  div[i] = static_cast<size_t>((pbox.getP2().get(i) - pbox.getP1().get(i)) / r_cut);
1108  div[i]++;
1109  pbox.setHigh(i,pbox.getLow(i) + div[i]*r_cut);
1110  }
1111 }
1112 
1122 template<unsigned int dim, typename St> static
1123 inline void cl_param_calculateSym(const Box<dim,St> & dom,
1124  CellDecomposer_sm<dim,St,shift<dim,St>> & cd_sm,
1125  Ghost<dim,St> g,
1126  St r_cut,
1127  size_t & pad)
1128 {
1129  size_t div[dim];
1130 
1131  for (size_t i = 0 ; i < dim ; i++)
1132  div[i] = (dom.getHigh(i) - dom.getLow(i)) / r_cut;
1133 
1134  g.magnify(1.013);
1135 
1136  // Calculate the maximum padding
1137  for (size_t i = 0 ; i < dim ; i++)
1138  {
1139  size_t tmp = std::ceil(fabs(g.getLow(i)) / r_cut);
1140  pad = (pad > tmp)?pad:tmp;
1141 
1142  tmp = std::ceil(fabs(g.getHigh(i)) / r_cut);
1143  pad = (pad > tmp)?pad:tmp;
1144  }
1145 
1146  cd_sm.setDimensions(dom,div,pad);
1147 }
1148 
1149 
1159 template<unsigned int dim, typename St>
1160 static inline void cl_param_calculateSym(const Box<dim,St> & dom,
1161  CellDecomposer_sm<dim,St,shift<dim,St>> & cd_sm,
1162  Ghost<dim,St> g,
1163  size_t & pad)
1164 {
1165  size_t div[dim];
1166 
1167  for (size_t i = 0 ; i < dim ; i++)
1168  div[i] = (dom.getHigh(i) - dom.getLow(i)) / g.getHigh(i);
1169 
1170  g.magnify(1.013);
1171 
1172  pad = 1;
1173 
1174  cd_sm.setDimensions(dom,div,pad);
1175 }
1176 
1177 
1178 #endif /* CELLLIST_HPP_ */
ParticleIt_Cells< dim, CellList< dim, T, Mem_fast<>, transform, base > > getDomainIterator(openfpm::vector< size_t > &dom_cells)
Get an iterator over particles following the cell structure.
Definition: CellList.hpp:638
~CellList()
Destructor.
Definition: CellList.hpp:584
void add(const T(&pos)[dim], typename base::value_type ele)
Add an element in the cell list.
Definition: CellList.hpp:662
This class represent an N-dimensional box.
Definition: SpaceBox.hpp:26
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:279
const Mem_type::loc_index & getStartId(typename Mem_type::loc_index cell_id) const
Return the starting point of the cell p.
Definition: CellList.hpp:1008
mem_id LinId(const grid_key_dx< N > &gk, const char sum_id[N]) const
Linearization of the grid_key_dx with a specified shift.
Definition: grid_sm.hpp:337
Mem_type Mem_type_type
Type of internal memory structure.
Definition: CellList.hpp:401
size_t get_gm()
return the ghost marker
Definition: CellList.hpp:1047
T getLow(int i) const
get the i-coordinate of the low bound interval of the box
Definition: Box.hpp:479
grid_key_dx is the key to access any element in the grid
Definition: grid_key.hpp:18
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:528
CellNNIteratorSymMP< dim, CellList< dim, T, Mem_type, transform, base >,(unsigned int) SYM, impl > getNNIteratorSymMP(size_t cell, size_t p, const openfpm::vector< Point< dim, T >> &v_p1, const openfpm::vector< Point< dim, T >> &v_p2)
Get the symmetric Neighborhood iterator.
Definition: CellList.hpp:949
const Mem_type::loc_index & get_lin(const typename Mem_type::loc_index *part_id) const
Return the neighborhood id.
Definition: CellList.hpp:1032
const Mem_type::loc_index & getStopId(typename Mem_type::loc_index cell_id) const
Return the end point of the cell p.
Definition: CellList.hpp:1020
size_t getNelements(const size_t cell_id) const
Return the number of elements in the cell.
Definition: CellList.hpp:779
size_t get_ndec() const
Set the n_dec number.
Definition: CellList.hpp:1081
void magnify(T mg)
Magnify the box.
Definition: Box.hpp:766
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:434
CellNNIteratorSym< dim, CellList< dim, T, Mem_type, transform, base >,(unsigned int) SYM, impl > getNNIteratorSym(size_t cell, size_t p, const openfpm::vector< Point< dim, T >> &v)
Get the symmetric Neighborhood iterator.
Definition: CellList.hpp:914
T getHigh(int i) const
get the high interval of the box
Definition: Box.hpp:490
void addPad(const Point< dim, T > &pos, typename base::value_type ele)
Add an element in the cell list forcing to be in the padding cells.
Definition: CellList.hpp:750
void setHigh(int i, T val)
set the high interval of the box
Definition: Box.hpp:467
size_t size()
Stub size.
Definition: map_vector.hpp:70
CellList()
Default Constructor.
Definition: CellList.hpp:499
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:22
Symmetric iterator for the neighborhood of the cell structures.
Point< dim, T > getP1() const
Get the point p1.
Definition: Box.hpp:605
const NNc_array< dim,(unsigned int) openfpm::math::pow(3, dim)/2+1 > & getNNc_sym() const
Get the symmetric neighborhood.
Definition: CellList.hpp:965
Symmetric iterator for the neighborhood of the cell structures.
void Initialize(const SpaceBox< dim, T > &box, const size_t(&div)[dim], const size_t pad=1, size_t slot=STARTING_NSLOT)
Definition: CellList.hpp:485
void set_size(const size_t(&sz)[dim])
Set the size in each.
Definition: NNc_array.hpp:47
void swap(CellList< dim, T, Mem_type, transform, base > &cl)
Swap the memory.
Definition: CellList.hpp:819
mem_id get(size_t i) const
Get the i index.
Definition: grid_key.hpp:394
CellNNIteratorRadius< dim, CellList< dim, T, Mem_type, transform, base >, impl > getNNIteratorRadius(size_t cell, T r_cut)
Get the symmetric Neighborhood iterator.
Definition: CellList.hpp:878
CellList(const CellList< dim, T, Mem_type, transform, base > &cell)
Copy constructor.
Definition: CellList.hpp:505
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:366
CellIterator< CellList< dim, T, Mem_type, transform, base > > getCellIterator(size_t cell)
Get the Cell iterator.
Definition: CellList.hpp:836
size_t(& getPadding())[dim]
Return the number of padding cells of the Cell decomposer as an array.
Definition: CellList.hpp:988
void enlarge(const Box< dim, T > &gh)
Enlarge the box with ghost margin.
Definition: Box.hpp:700
T stype
Type of the coordinate space (double float)
Definition: CellList.hpp:409
size_t getPadding(size_t i) const
Return the number of padding cells of the Cell decomposer.
Definition: CellList.hpp:977
const grid_key_dx< dim > & get() const
Get the actual key.
This class implement an NxN (dense) matrix.
Definition: Matrix.hpp:32
const T & get(size_t i) const
Get coordinate.
Definition: Point.hpp:142
it iterate through the elements of a cell
CellList(CellList< dim, T, Mem_type, transform, base > &&cell)
Copy constructor.
Definition: CellList.hpp:512
size_t n_dec
Definition: CellList.hpp:300
void init_sym()
Initialize the NNc array with symmetric neighborhood cells indexes.
Definition: NNc_array.hpp:104
bool isNext()
Check if there is the next element.
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:543
void addPad(const T(&pos)[dim], typename base::value_type ele)
Add an element in the cell list forcing to be in the padding cells.
Definition: CellList.hpp:731
This class represent an N-dimensional box.
Definition: Box.hpp:56
wrap_unordered_map< T, openfpm::vector< long int > > rcache
Caching of r_cutoff radius.
Definition: CellList.hpp:293
This class is a trick to indicate the compiler a specific specialization pattern. ...
Definition: memory_c.hpp:201
void set_ndec(size_t n_dec)
Set the n_dec number.
Definition: CellList.hpp:1071
CellList(SpaceBox< dim, T > &box, const size_t(&div)[dim], const size_t pad=1, size_t slot=STARTING_NSLOT)
Cell list constructor.
Definition: CellList.hpp:558
void clear()
Clear the cell list.
Definition: CellList.hpp:996
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:468
void addDom(const Point< dim, T > &pos, typename base::value_type ele)
Add an element in the cell list forcing to be in the domain cells.
Definition: CellList.hpp:712
void addDom(const T(&pos)[dim], typename base::value_type ele)
Add an element in the cell list forcing to be in the domain cells.
Definition: CellList.hpp:693
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:288
const grid_sm< dim, void > & getGrid()
Return the underlying grid information of the cell list.
Definition: CellList.hpp:416
This iterator iterate across the particles of a Cell-list following the Cell structure.
void swap(NNc_array< dim, size, thr > &nnc)
swap NNc_array
Definition: NNc_array.hpp:169
void set_gm(size_t g_m)
Set the ghost marker.
Definition: CellList.hpp:1057
void addCell(size_t cell_id, typename base::value_type ele)
Add to the cell.
Definition: CellList.hpp:651
CellNNIterator< dim, CellList< dim, T, Mem_type, transform, base >,(int) FULL, impl > getNNIterator(size_t cell)
Get the Neighborhood iterator.
Definition: CellList.hpp:861
void init_full()
Initialize the NNc array with full neighborhood cells indexes.
Definition: NNc_array.hpp:76
size_t g_m
Ghost marker.
Definition: CellList.hpp:1040
bool from_cd
True if has been initialized from CellDecomposer.
Definition: CellList.hpp:296
void set_d(size_t i, mem_id id)
Set the i index.
Definition: grid_key.hpp:407
CellList< dim, T, Mem_type, transform, base > & operator=(CellList< dim, T, Mem_type, transform, base > &&cell)
Constructor from a temporal object.
Definition: CellList.hpp:594
CellList< dim, T, Mem_type, transform, base > & operator=(const CellList< dim, T, Mem_type, transform, base > &cell)
Constructor from a temporal object.
Definition: CellList.hpp:616
Iterator for the neighborhood of the cell structures with free radius.
Wrapper of the unordered map.
Definition: CellList.hpp:32
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61
base::value_type value_type
Object type that the structure store.
Definition: CellList.hpp:406
Class for FAST cell list implementation.
Definition: CellList.hpp:269
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:574
Iterator for the neighborhood of the cell structures.
Point< dim, T > getP2() const
Get the point p2.
Definition: Box.hpp:619
void add(const Point< dim, T > &pos, typename base::value_type ele)
Add an element in the cell list.
Definition: CellList.hpp:676
void NNcalc(T r_cut, openfpm::vector< long int > &NNcell)
Definition: CellList.hpp:335