OpenFPM  5.2.0
Project that contain the implementation of distributed structures
VerletList.hpp
1 #ifndef OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETLIST_HPP_
2 #define OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETLIST_HPP_
3 
4 #include "Vector/map_vector.hpp"
5 
6 #include "VerletNNIterator.hpp"
7 #include "NN/CellList/CellList.hpp"
8 #include "NN/CellList/CellList_util.hpp"
9 #include "NN/Mem_type/MemFast.hpp"
10 #include "NN/Mem_type/MemBalanced.hpp"
11 #include "NN/Mem_type/MemMemoryWise.hpp"
12 
13 
14 // Verlet list config options
15 constexpr int VL_NON_SYMMETRIC = 1;
16 constexpr int VL_SYMMETRIC = 2;
17 constexpr int VL_CRS_SYMMETRIC = 4;
18 constexpr int VL_ADAPTIVE_RCUT = 8;
19 constexpr int VL_NMAX_NEIGHBOR = 16;
20 constexpr int VL_SKIP_REF_PART = 32;
21 
22 constexpr int VERLET_STARTING_NSLOT = 128;
23 
24 #ifdef LOCAL_INDEX64
25 typedef size_t local_index_;
26 #else
27 typedef unsigned int local_index_;
28 #endif
29 
30 
39 template<bool isNMax, bool skipRefPart>
41 
57 template<>
58 struct iteratePartNeighbor<false, false> {
59 
60  template<typename NeighborIter_type, typename VerletList_type, typename vPos_type, unsigned int dim, typename T>
61  inline void operator() (
62  VerletList_type& verletList,
63  NeighborIter_type & it,
64  const vPos_type & pos,
65  size_t p, Point<dim,T> xp,
66  T r_cut, size_t neighborMaxNum)
67  {
68  T r_cut2 = r_cut * r_cut;
69 
70  while (it.isNext())
71  {
72  size_t q = it.get();
73 
74  Point<dim,T> xq = pos.template get<0>(q);
75 
76  if (xp.distance2(xq) < r_cut2) {
77  verletList.addPart(p,q);
78  }
79 
80  ++it;
81  }
82  }
83 };
84 
100 template<>
101 struct iteratePartNeighbor<false, true> {
102 
103  template<typename NeighborIter_type, typename VerletList_type, typename vPos_type, unsigned int dim, typename T>
104  inline void operator() (
105  VerletList_type& verletList,
106  NeighborIter_type & it,
107  const vPos_type & pos,
108  size_t p, Point<dim,T> xp,
109  T r_cut, size_t neighborMaxNum)
110  {
111  T r_cut2 = r_cut * r_cut;
112 
113  while (it.isNext())
114  {
115  auto q = it.get();
116 
117  Point<dim,T> xq = pos.template get<0>(q);
118 
119  if (xp.distance2(xq) < r_cut2 && p != q) {
120  verletList.addPart(p,q);
121  }
122  ++it;
123  }
124  }
125 };
126 
143 template<>
144 struct iteratePartNeighbor<true, false> {
145  template<typename NeighborIter_type, typename VerletList_type, typename vPos_type, unsigned int dim, typename T>
146  inline void operator() (
147  VerletList_type& verletList,
148  NeighborIter_type & it,
149  const vPos_type & pos,
150  size_t p, Point<dim,T> xp,
151  T r_cut, size_t neighborMaxNum)
152  {
153  struct ReorderType {
154  T dist;
155  size_t id;
156  bool operator<(const ReorderType &other) const { return this->dist < other.dist; }
157  };
158 
159  openfpm::vector<ReorderType> neighborList;
160 
161  while (it.isNext())
162  {
163  auto q = it.get();
164 
165  Point<dim,T> xq = pos.template get<0>(q);
166 
167  if (xp.distance(xq) < r_cut) {
168  ReorderType qReorder;
169  qReorder.dist = xp.distance(xq);
170  qReorder.id = q;
171  neighborList.add(qReorder);
172  }
173 
174  ++it;
175  }
176 
177  neighborList.sort();
178  for(size_t i = 0; i < neighborList.size(); ++i) {
179  if (i < neighborMaxNum)
180  verletList.addPart(p, neighborList.get(i).id);
181  }
182  }
183 };
184 
201 template<>
202 struct iteratePartNeighbor<true, true> {
203 
204  template<typename NeighborIter_type, typename VerletList_type, typename vPos_type, unsigned int dim, typename T>
205  inline void operator() (
206  VerletList_type& verletList,
207  NeighborIter_type & it,
208  const vPos_type & pos,
209  size_t p, Point<dim,T> xp,
210  T r_cut, size_t neighborMaxNum)
211  {
212  struct ReorderType {
213  T dist;
214  size_t id;
215  bool operator<(const ReorderType &other) const { return this->dist < other.dist; }
216  };
217 
218  openfpm::vector<ReorderType> neighborList;
219 
220  while (it.isNext())
221  {
222  auto q = it.get();
223 
224  Point<dim,T> xq = pos.template get<0>(q);
225 
226  if (xp.distance(xq) < r_cut) {
227  ReorderType qReorder;
228  qReorder.dist = xp.distance(xq);
229  qReorder.id = q;
230  neighborList.add(qReorder);
231  }
232 
233  ++it;
234  }
235 
236  neighborList.sort();
237  for(size_t i = 0; i < neighborList.size(); ++i) {
238  if (i < neighborMaxNum && p != neighborList.get(i).id)
239  verletList.addPart(p, neighborList.get(i).id);
240  }
241  }
242 };
243 
244 
261 template<unsigned int dim,
262  typename T,
263  unsigned int opt = VL_NON_SYMMETRIC,
264  typename Mem_type = Mem_fast<HeapMemory,local_index_>,
265  typename transform = no_transform<dim,T>,
266  typename vPos_type = openfpm::vector<Point<dim,T>>,
267  typename CellListImpl = CellList<dim,T,Mem_fast<HeapMemory,typename Mem_type::local_index_type>,transform,vPos_type> >
268 class VerletList: public Mem_type
269 {
270 protected:
271 
273  typename Mem_type::local_index_type slot;
274 
277 
279  size_t neighborMaxNum=0;
280 
282  T rCut;
283 
285  // Not used by default unless filled with fillNonSymmAdaptive
287 
288 private:
289 
291  size_t n_dec;
292 
294  CellListImpl cellList;
295 
296 public:
305  void initCl(CellListImpl & cellList, const vPos_type & vPos, size_t ghostMarker)
306  {
307  // CellList_gpu receives a property vector to potentially reorder it during cell list construction
308  // stub because of legacy naming
310 
311  if (opt & VL_SYMMETRIC || opt & VL_CRS_SYMMETRIC)
312  cellList.setOpt(CL_SYMMETRIC);
313  else
314  cellList.setOpt(CL_NON_SYMMETRIC);
315 
316  cellList.fill(vPos, vPropStub, ghostMarker);
317  }
318 
331  inline void fillCRSSymmetric(
332  const vPos_type & pos,
333  T r_cut,
334  size_t ghostMarker,
335  const openfpm::vector<size_t> & dom,
336  const openfpm::vector<subsub_lin<dim>>& anom)
337  {
338  size_t end = pos.size();
339 
340  Mem_type::init_to_zero(slot,end);
341  domainParticlesCRS.clear();
342 
343  // iterate the particles
344  auto it = ParticleItCRS_Cells<dim,CellListImpl,vPos_type>(cellList,dom,anom,cellList.getNNc_sym());
345  while (it.isNext())
346  {
347  typename Mem_type::local_index_type p = it.get();
348  Point<dim,T> xp = pos.template get<0>(p);
349 
350  domainParticlesCRS.add(p);
351 
352  // Get the neighborhood of the particle
353  auto NN = it.getNNIteratorCSR(pos);
354 
355  iteratePartNeighbor<(bool)(opt&VL_NMAX_NEIGHBOR),(bool)(opt&VL_SKIP_REF_PART)>{}(*this, NN, pos, p, xp, r_cut, neighborMaxNum);
356  ++it;
357  }
358  }
359 
370  inline void fillSymmetric(
371  const vPos_type & pos,
372  T r_cut,
373  size_t ghostMarker,
374  CellListImpl & cellList)
375  {
376  size_t end = ghostMarker;
377 
378  Mem_type::init_to_zero(slot,end);
379  domainParticlesCRS.clear();
380 
381  // iterate the particles
382  auto it = pos.getIteratorTo(end);
383  while (it.isNext())
384  {
385  typename Mem_type::local_index_type p = it.get();
386  Point<dim,T> xp = pos.template get<0>(p);
387 
388  // Get the neighborhood of the particle
389  auto NN = cellList.getNNIteratorBoxSym(cellList.getCell(xp),p,pos);
390 
391  iteratePartNeighbor<(bool)(opt&VL_NMAX_NEIGHBOR),(bool)(opt&VL_SKIP_REF_PART)>{}(*this, NN, pos, p, xp, r_cut, neighborMaxNum);
392  ++it;
393  }
394  }
395 
406  inline void fillNonSymmetric(
407  const vPos_type & pos,
408  T r_cut,
409  size_t ghostMarker,
410  CellListImpl & cellList)
411  {
412  size_t end = ghostMarker;
413 
414  Mem_type::init_to_zero(slot,end);
415 
416  // iterate the particles
417  auto it = pos.getIteratorTo(end);
418  while (it.isNext())
419  {
420  typename Mem_type::local_index_type p = it.get();
421  Point<dim,T> xp = pos.template get<0>(p);
422 
423  // Get the neighborhood of the particle
424  auto NN = cellList.getNNIteratorBox(cellList.getCell(xp));
425 
426  iteratePartNeighbor<(bool)(opt&VL_NMAX_NEIGHBOR),(bool)(opt&VL_SKIP_REF_PART)>{}(*this, NN, pos, p, xp, r_cut, neighborMaxNum);
427  ++it;
428  }
429  }
430 
442  template <typename domainIterator_type>
444  domainIterator_type& it,
445  const vPos_type & pos,
446  T r_cut,
447  size_t ghostMarker,
448  CellListImpl & cellList)
449  {
450  fillNonSymmetricIterator<domainIterator_type>(it, pos, pos, r_cut, ghostMarker, cellList);
451  }
452 
465  template <typename domainIterator_type, typename vPos_type2>
467  domainIterator_type& it,
468  const vPos_type2 & domainPos,
469  const vPos_type & supportPos,
470  T r_cut,
471  size_t ghostMarker,
472  CellListImpl & cellList)
473  {
474  size_t end = ghostMarker;
475 
476  Mem_type::init_to_zero(slot,end);
477 
478  while (it.isNext())
479  {
480  typename Mem_type::local_index_type p = it.get();
481  Point<dim,T> xp = domainPos.template get<0>(p);
482 
483  // Get the neighborhood of the particle
484  auto NN = cellList.getNNIteratorBox(cellList.getCell(xp));
485 
486  iteratePartNeighbor<(bool)(opt&VL_NMAX_NEIGHBOR),(bool)(opt&VL_SKIP_REF_PART)>{}(*this, NN, supportPos, p, xp, r_cut, neighborMaxNum);
487  ++it;
488  }
489  }
490 
503  const Box<dim,T> & box,
505  const vPos_type & pos,
506  size_t ghostMarker)
507  {
508  if (rCuts.size() != pos.size())
509  {
510  std::cerr << __FILE__ << ":" << __LINE__
511  << " ERROR: when constructing adaptive cut-off Verlet list, pos.size() != rCuts.size(), ["
512  << rCuts.size() << "!=" << pos.size() << "]" << std::endl;
513  std::runtime_error("Runtime adaptive cut-off Verlet list error");
514  }
515 
516  this->rCuts = rCuts;
517  T rCutMax = 0.0;
518 
519  // Assign rCutMax for Cell List as
520  // the largest cut-off radius from rCuts
521  for (size_t i = 0; i < rCuts.size(); ++i)
522  if (rCuts.get(i) > rCutMax)
523  rCutMax = rCuts.get(i);
524 
525  // Number of divisions
526  size_t div[dim];
527 
528  Box<dim,T> bt = box;
529 
530  // Calculate the divisions for the Cell-lists
531  cl_param_calculate(bt,div,rCutMax,Ghost<dim,T>(0.0));
532 
533  // Initialize a cell-list
534  cellList.Initialize(bt,div);
535 
536  initCl(cellList,pos,ghostMarker);
537 
538  Mem_type::init_to_zero(slot,ghostMarker);
539 
540  // iterate the particles
541  auto it = pos.getIteratorTo(ghostMarker);
542  while (it.isNext())
543  {
544  typename Mem_type::local_index_type p = it.get();
545  Point<dim,T> xp = pos.template get<0>(p);
546 
547  // Get the neighborhood of the particle
548  auto boxIterator = cellList.getNNIteratorBox(cellList.getCell(xp));
549 
550  iteratePartNeighbor<(bool)(opt&VL_NMAX_NEIGHBOR),(bool)(opt&VL_SKIP_REF_PART)>{}(
551  *this, boxIterator, pos, p, xp, rCuts.get(p), neighborMaxNum);
552  ++it;
553  }
554  }
555 
567  template <typename domainIterator_type, typename vPos_type2>
569  domainIterator_type& it,
570  const vPos_type2 & domainPos,
571  const vPos_type & supportPos,
573  size_t ghostMarker)
574  {
575  if (rCuts.size() != ghostMarker)
576  {
577  std::cerr << __FILE__ << ":" << __LINE__
578  << " ERROR: when constructing adaptive cut-off Verlet list, pos.size_local() != rCuts.size(), ["
579  << rCuts.size() << "!=" << domainPos.size_local() << "]" << std::endl;
580  std::runtime_error("Runtime adaptive cut-off Verlet list error");
581  }
582 
583  size_t end = ghostMarker;
584 
585  Mem_type::init_to_zero(slot,end);
586 
587  // iterate the particles
588  while (it.isNext())
589  {
590  typename Mem_type::local_index_type p = it.get();
591  Point<dim,T> xp = domainPos.template get<0>(p);
592 
593  // iterate the whole domain instead of neighborhood iteration
594  // no auxillary cell list is needed
595  auto NN = supportPos.getIteratorTo(supportPos.size_local());
596  T r_cut = rCuts.get(p);
597 
598  iteratePartNeighbor<(bool)(opt&VL_NMAX_NEIGHBOR),(bool)(opt&VL_SKIP_REF_PART)>{}(*this, NN, supportPos, p, xp, r_cut, neighborMaxNum);
599  ++it;
600  }
601  }
602 
614  const vPos_type & pos,
615  T r_cut,
616  size_t ghostMarker,
617  CellListImpl & cellList)
618  {
619  size_t end = ghostMarker;
620 
621  Mem_type::init_to_zero(slot,end);
622 
623  // iterate the particles
624  auto it = pos.getIteratorTo(end);
625  while (it.isNext())
626  {
627  typename Mem_type::local_index_type p = it.get();
628  Point<dim,T> xp = pos.template get<0>(p);
629 
630  // Get the neighborhood of the particle
631  auto NN = cellList.getNNIteratorRadius(cellList.getCell(xp),r_cut);
632 
633  iteratePartNeighbor<(bool)(opt&VL_NMAX_NEIGHBOR),(bool)(opt&VL_SKIP_REF_PART)>{}(*this, NN, pos, p, xp, r_cut, neighborMaxNum);
634  ++it;
635  }
636  }
637 
639  typedef Mem_type Mem_type_type;
640 
642  typedef size_t value_type;
643 
649  size_t size()
650  {
651  return Mem_type::size();
652  }
653 
660  inline void addPart(size_t p, size_t q)
661  {
662  Mem_type::addCell(p,q);
663  }
664 
671  inline void replaceNeighbParts(size_t p, const openfpm::vector<size_t> &buffer)
672  {
673  Mem_type::clear(p);
674  for (size_t i = 0; i < buffer.size(); i++)
675  {
676  Mem_type::addCell(p,buffer.get(i));
677  }
678  }
679 
691  const Box<dim,T> & box,
692  T r_cut,
693  vPos_type & pos,
694  size_t ghostMarker)
695  {
696  this->rCut = r_cut;
697  // Number of divisions
698  size_t div[dim];
699 
700  Box<dim,T> bt = box;
701 
702  // Calculate the divisions for the Cell-lists
703  cl_param_calculate(bt,div,r_cut,Ghost<dim,T>(0.0));
704 
705  // Initialize a cell-list
706  cellList.Initialize(bt,div);
707 
708  initCl(cellList,pos,ghostMarker);
709 
710  fillNonSymmetric(pos,r_cut,ghostMarker,cellList);
711  }
712 
724  template <typename domainIterator_type>
726  CellListImpl& cellList,
727  T r_cut,
728  domainIterator_type& it,
729  const vPos_type& pos,
730  size_t ghostMarker)
731  {
732  this->rCut = r_cut;
733  this->cellList = cellList;
734 
735  fillNonSymmetricIterator(it,pos,r_cut,ghostMarker,cellList);
736  }
737 
750  template <typename domainIterator_type>
752  CellListImpl& cellList,
753  T r_cut,
754  domainIterator_type& it,
755  const vPos_type& domainPos,
756  const vPos_type& supportPos,
757  size_t ghostMarker)
758  {
759  this->rCut = r_cut;
760  this->cellList = cellList;
761 
762  fillNonSymmetricIterator(it,domainPos,supportPos,r_cut,ghostMarker,cellList);
763  }
764 
778  const Box<dim,T> & box,
779  const Box<dim,T> & dom,
780  const Ghost<dim,T> & ghostSize,
781  T r_cut,
782  vPos_type & pos,
783  size_t ghostMarker)
784  {
785  this->rCut = r_cut;
786  // Padding
787  size_t pad = 0;
788 
789  // Cell decomposer
790  CellDecomposer_sm<dim,T,shift<dim,T>> cd_sm;
791 
792  // Calculate the divisions for the Cell-lists
793  cl_param_calculateSym<dim,T>(box,cd_sm,ghostSize,r_cut,pad);
794 
795  // Initialize a cell-list
796  cellList.Initialize(cd_sm,dom,pad);
797  initCl(cellList,pos,ghostMarker);
798 
799  // create verlet
800  fillSymmetric(pos, r_cut, ghostMarker, cellList);
801  }
802 
803 
817  const Box<dim,T> & box,
818  const Box<dim,T> & dom,
819  const Ghost<dim,T> & ghostSize,
820  T r_cut,
821  vPos_type & pos,
822  size_t ghostMarker)
823  {
824  this->rCut = r_cut;
825  // Padding
826  size_t pad = 0;
827 
828  // Cell decomposer
829  CellDecomposer_sm<dim,T,shift<dim,T>> cd_sm;
830 
831  // Calculate the divisions for the Cell-lists
832  cl_param_calculateSym<dim,T>(box,cd_sm,ghostSize,r_cut,pad);
833 
834  // Initialize a cell-list
835  cellList.Initialize(cd_sm,dom,pad);
836  initCl(cellList,pos,ghostMarker);
837  }
838 
847  void update(
848  const Box<dim,T> & dom,
849  T r_cut,
850  vPos_type & pos,
851  size_t & ghostMarker)
852  {
853  initCl(cellList,pos,ghostMarker);
854 
855  if (opt & VL_SYMMETRIC)
856  fillSymmetric(pos,r_cut,ghostMarker,cellList);
857  else
858  fillNonSymmetric(pos,r_cut,ghostMarker,cellList);
859  }
860 
871  void updateCrs(
872  vPos_type & pos,
873  T r_cut,
874  size_t & ghostMarker,
875  const openfpm::vector<size_t> & dom_c,
876  const openfpm::vector<subsub_lin<dim>> & anom_c)
877  {
878  initCl(cellList,pos,ghostMarker);
879  fillCRSSymmetric(pos,r_cut,ghostMarker,dom_c,anom_c);
880  }
881 
884  :Mem_type(VERLET_STARTING_NSLOT),slot(VERLET_STARTING_NSLOT),n_dec(0)
885  {};
886 
889  :Mem_type(VERLET_STARTING_NSLOT),slot(VERLET_STARTING_NSLOT)
890  {
891  this->operator=(cell);
892  }
893 
896  :Mem_type(VERLET_STARTING_NSLOT),slot(VERLET_STARTING_NSLOT),n_dec(0)
897  {
898  this->operator=(cell);
899  }
900 
901 
911  VerletList(Box<dim,T> & box, T r_cut, Matrix<dim,T> mat, const size_t pad = 1, size_t slot=STARTING_NSLOT)
912  :slot(VERLET_STARTING_NSLOT),CellDecomposer_sm<dim,T,transform>(box,div,mat,box.getP1(),pad)
913  {
914  Box<dim,T> sbox(box);
915  Initialize(sbox,r_cut,pad,slot);
916  }
917 
931  VerletList(Box<dim,T> & box, T r_cut, vPos_type & pos, size_t ghostMarker, size_t slot=VERLET_STARTING_NSLOT)
932  :slot(slot)
933  {
934  Box<dim,T> sbox(box);
935  Initialize(sbox,r_cut,pos,ghostMarker);
936  }
937 
952  VerletList(Box<dim,T> & box, Box<dim,T> & dom, T r_cut, vPos_type & pos, size_t ghostMarker, size_t slot=VERLET_STARTING_NSLOT)
953  :slot(slot)
954  {
955  Initialize(box,r_cut,pos);
956  }
957 
963  {}
964 
974  {
975  slot = vl.slot;
976 
977  Mem_type::operator=(vl);
978  domainParticlesCRS.swap(vl.domainParticlesCRS);
979 
980  n_dec = vl.n_dec;
981 
982  return *this;
983  }
984 
994  {
995  slot = vl.slot;
996 
997  Mem_type::operator=(vl);
998 
999  cellList = vl.cellList;
1000 
1002  n_dec = vl.n_dec;
1003 
1004  return *this;
1005  }
1006 
1014  inline size_t getNNPart(size_t p) const
1015  {
1016  return Mem_type::getNelements(p);
1017  }
1018 
1027  inline size_t get(size_t p, size_t q) const
1028  {
1029  return Mem_type::get(p,q);
1030  }
1031 
1038  {
1039  Mem_type::swap(vl);
1041 
1042  size_t vl_slot_tmp = vl.slot;
1043  vl.slot = slot;
1044  slot = vl_slot_tmp;
1045 
1046  cellList.swap(vl.cellList);
1047 
1048  size_t n_dec_tmp = vl.n_dec;
1049  vl.n_dec = n_dec;
1050  n_dec = n_dec_tmp;
1051  }
1052 
1063  getNNIterator(size_t p)
1064  {
1066 
1067  return vln;
1068  }
1069 
1073  void clear()
1074  {
1075  Mem_type::clear();
1076  }
1077 
1085  inline const typename Mem_type::local_index_type &
1086  getStart(typename Mem_type::local_index_type p)
1087  {
1088  return Mem_type::getStartId(p);
1089  }
1090 
1098  inline const typename Mem_type::local_index_type &
1099  getStop(typename Mem_type::local_index_type p)
1100  {
1101  return Mem_type::getStopId(p);
1102  }
1103 
1111  inline const typename Mem_type::local_index_type &
1112  get_lin(const typename Mem_type::local_index_type * p)
1113  {
1114  return Mem_type::get_lin(p);
1115  }
1116 
1122  CellListImpl & getInternalCellList()
1123  {
1124  return cellList;
1125  }
1126 
1132  void set_ndec(size_t n_dec)
1133  {
1134  this->n_dec = n_dec;
1135 
1136  cellList.set_ndec(n_dec);
1137  }
1138 
1144  size_t get_ndec()
1145  {
1146  return n_dec;
1147  }
1148 
1155  size_t getNeighborMaxNum() const
1156  {
1157  return neighborMaxNum;
1158  }
1159 
1167  {
1168  this->neighborMaxNum = neighborMaxNum;
1169  }
1170 
1177  size_t getOpt() const
1178  {
1179  return opt;
1180  }
1181 
1188  {
1189  return domainParticlesCRS;
1190  }
1191 
1198  {
1199  return rCut;
1200  }
1201 
1209  T getRCuts(size_t p)
1210  {
1211  return rCuts.get(p);
1212  }
1213 
1218  void clear(typename Mem_type::local_index_type p)
1219  {
1220  Mem_type::clear(p);
1221  }
1222 };
1223 
1224 template<unsigned int dim, typename St, unsigned int opt> using VERLET_MEMFAST = VerletList<dim,St,opt,Mem_fast<>,shift<dim,St>>;
1225 template<unsigned int dim, typename St, unsigned int opt> using VERLET_MEMBAL = VerletList<dim,St,opt,Mem_bal<>,shift<dim,St>>;
1226 template<unsigned int dim, typename St, unsigned int opt> using VERLET_MEMMW = VerletList<dim,St,opt,Mem_mw<>,shift<dim,St>>;
1227 
1228 template<unsigned int dim, typename St, unsigned int opt> using VERLET_MEMFAST_INT = VerletList<dim,St,opt,Mem_fast<HeapMemory,unsigned int>,shift<dim,St>>;
1229 template<unsigned int dim, typename St, unsigned int opt> using VERLET_MEMBAL_INT = VerletList<dim,St,opt,Mem_bal<unsigned int>,shift<dim,St>>;
1230 template<unsigned int dim, typename St, unsigned int opt> using VERLET_MEMMW_INT = VerletList<dim,St,opt,Mem_mw<unsigned int>,shift<dim,St>>;
1231 
1232 
1233 #endif /* OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETLIST_HPP_ */
This class represent an N-dimensional box.
Definition: Box.hpp:60
Class for FAST cell list implementation.
Definition: CellList.hpp:558
Definition: Ghost.hpp:40
This class implement an NxN (dense) matrix.
Definition: Matrix.hpp:33
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__ T distance(const Point< dim, T > &q) const
It calculate the distance between 2 points.
Definition: Point.hpp:265
T distance2(const Point< dim, T > &q) const
It calculate the square distance between 2 points.
Definition: Point.hpp:284
Class for Verlet list implementation.
Definition: VerletList.hpp:269
void initCl(CellListImpl &cellList, const vPos_type &vPos, size_t ghostMarker)
Fill the cell-list with data.
Definition: VerletList.hpp:305
openfpm::vector< typename Mem_type::local_index_type > domainParticlesCRS
Domain particles.
Definition: VerletList.hpp:276
VerletList(Box< dim, T > &box, T r_cut, Matrix< dim, T > mat, const size_t pad=1, size_t slot=STARTING_NSLOT)
Verlet-list constructor.
Definition: VerletList.hpp:911
void updateCrs(vPos_type &pos, T r_cut, size_t &ghostMarker, const openfpm::vector< size_t > &dom_c, const openfpm::vector< subsub_lin< dim >> &anom_c)
update the Verlet list
Definition: VerletList.hpp:871
openfpm::vector< typename Mem_type::local_index_type > & getParticleSeq()
Return the domain particle sequence.
void InitializeNonSymmAdaptive(const Box< dim, T > &box, openfpm::vector< T > &rCuts, const vPos_type &pos, size_t ghostMarker)
Initialize non-symmetric adaptive r-cut Verlet list from a list of cut-off radii.
Definition: VerletList.hpp:502
void InitializeSym(const Box< dim, T > &box, const Box< dim, T > &dom, const Ghost< dim, T > &ghostSize, T r_cut, vPos_type &pos, size_t ghostMarker)
Initialize the symmetric Verlet-list.
Definition: VerletList.hpp:777
void fillNonSymmetricIterator(domainIterator_type &it, const vPos_type2 &domainPos, const vPos_type &supportPos, T r_cut, size_t ghostMarker, CellListImpl &cellList)
Fill Non-symmetric Verlet list from a given cell-list.
Definition: VerletList.hpp:466
Mem_type::local_index_type slot
Number of slot for each particle. Or maximum number of particles for each particle.
Definition: VerletList.hpp:273
VerletNNIterator< dim, VerletList< dim, T, opt, Mem_type, transform, vPos_type, CellListImpl > > getNNIterator(size_t p)
Get the Neighborhood iterator.
void set_ndec(size_t n_dec)
Set the n_dec number.
const Mem_type::local_index_type & get_lin(const typename Mem_type::local_index_type *p)
Return the neighborhood id.
CellListImpl cellList
Internal cell-list.
Definition: VerletList.hpp:294
T rCut
Cut-off radius.
Definition: VerletList.hpp:282
VerletList(Box< dim, T > &box, T r_cut, vPos_type &pos, size_t ghostMarker, size_t slot=VERLET_STARTING_NSLOT)
Verlet-list constructor.
Definition: VerletList.hpp:931
void swap(VerletList< dim, T, opt, Mem_type, transform, vPos_type, CellListImpl > &vl)
Swap the memory.
size_t getNNPart(size_t p) const
Return the number of neighborhood particles for the particle id.
VerletList(Box< dim, T > &box, Box< dim, T > &dom, T r_cut, vPos_type &pos, size_t ghostMarker, size_t slot=VERLET_STARTING_NSLOT)
Cell list constructor.
Definition: VerletList.hpp:952
CellListImpl & getInternalCellList()
Get the internal cell-list used to construct the Verlet-list.
void update(const Box< dim, T > &dom, T r_cut, vPos_type &pos, size_t &ghostMarker)
update the Verlet list
Definition: VerletList.hpp:847
openfpm::vector< T > rCuts
Cut-off radius vector.
Definition: VerletList.hpp:286
VerletList< dim, T, opt, Mem_type, transform, vPos_type, CellListImpl > & operator=(const VerletList< dim, T, opt, Mem_type, transform, vPos_type, CellListImpl > &vl)
Copy a verlet list.
Definition: VerletList.hpp:993
Mem_type Mem_type_type
type for the local index
Definition: VerletList.hpp:639
void fillNonSymmetricRadius(const vPos_type &pos, T r_cut, size_t ghostMarker, CellListImpl &cellList)
Fill Non-symmetric Verlet list from a given cell-list (Radius)
Definition: VerletList.hpp:613
void setNeighborMaxNum(size_t neighborMaxNum)
Sets the max number of neighbors per particle. Only with opt | VL_NMAX_NEIGHBOR.
VerletList(const VerletList< dim, T, opt, Mem_type, transform, vPos_type, CellListImpl > &cell)
Copy constructor.
Definition: VerletList.hpp:888
void Initialize(CellListImpl &cellList, T r_cut, domainIterator_type &it, const vPos_type &domainPos, const vPos_type &supportPos, size_t ghostMarker)
Definition: VerletList.hpp:751
~VerletList()
Destructor.
Definition: VerletList.hpp:962
const Mem_type::local_index_type & getStart(typename Mem_type::local_index_type p)
Return the starting point of the neighborhood for the particle p.
void fillNonSymmetricIterator(domainIterator_type &it, const vPos_type &pos, T r_cut, size_t ghostMarker, CellListImpl &cellList)
Fill Non-symmetric Verlet list from a given cell-list.
Definition: VerletList.hpp:443
void initializeCrs(const Box< dim, T > &box, const Box< dim, T > &dom, const Ghost< dim, T > &ghostSize, T r_cut, vPos_type &pos, size_t ghostMarker)
Initialize the symmetric Verlet-list CRS scheme.
Definition: VerletList.hpp:816
VerletList()
Default Constructor.
Definition: VerletList.hpp:883
size_t size()
Return for how many particles has been constructed this verlet list.
Definition: VerletList.hpp:649
void replaceNeighbParts(size_t p, const openfpm::vector< size_t > &buffer)
Replace the neighborhood particles for the particle id p with the given buffer.
Definition: VerletList.hpp:671
VerletList(VerletList< dim, T, opt, Mem_type, transform, vPos_type, CellListImpl > &&cell)
Copy constructor.
Definition: VerletList.hpp:895
void clear()
Clear the cell list.
void clear(typename Mem_type::local_index_type p)
Clear support of one particle in the verlet list.
size_t getNeighborMaxNum() const
Returns the max number of neighbors per particle. Only with opt | VL_NMAX_NEIGHBOR.
VerletList< dim, T, opt, Mem_type, transform, vPos_type, CellListImpl > & operator=(VerletList< dim, T, opt, Mem_type, transform, vPos_type, CellListImpl > &&vl)
Copy the verlet list.
Definition: VerletList.hpp:973
size_t neighborMaxNum
Max number of Nieghbors. Only with opt |= VL_NMAX_NEIGHBOR.
Definition: VerletList.hpp:279
void Initialize(CellListImpl &cellList, T r_cut, domainIterator_type &it, const vPos_type &pos, size_t ghostMarker)
Definition: VerletList.hpp:725
void fillNonSymmAdaptiveIterator(domainIterator_type &it, const vPos_type2 &domainPos, const vPos_type &supportPos, openfpm::vector< T > &rCuts, size_t ghostMarker)
Fill non-symmetric adaptive r-cut Verlet list from a list of cut-off radii.
Definition: VerletList.hpp:568
void Initialize(const Box< dim, T > &box, T r_cut, vPos_type &pos, size_t ghostMarker)
Definition: VerletList.hpp:690
size_t get_ndec()
Set the n_dec number.
T getRCuts(size_t p)
Return the cut-off radii for individual particles.
size_t n_dec
decomposition counter
Definition: VerletList.hpp:291
size_t value_type
Object type that the structure store.
Definition: VerletList.hpp:642
void fillNonSymmetric(const vPos_type &pos, T r_cut, size_t ghostMarker, CellListImpl &cellList)
Fill Non-symmetric Verlet list from a given cell-list.
Definition: VerletList.hpp:406
void fillSymmetric(const vPos_type &pos, T r_cut, size_t ghostMarker, CellListImpl &cellList)
Fill Symmetric Verlet list from a given cell-list.
Definition: VerletList.hpp:370
void addPart(size_t p, size_t q)
Add a neighborhood particle to a particle.
Definition: VerletList.hpp:660
size_t getOpt() const
Returns the option flag template parameter opt that controls the Verlet list.
void fillCRSSymmetric(const vPos_type &pos, T r_cut, size_t ghostMarker, const openfpm::vector< size_t > &dom, const openfpm::vector< subsub_lin< dim >> &anom)
Fill CRS Symmetric Verlet list from a given cell-list.
Definition: VerletList.hpp:331
size_t get(size_t p, size_t q) const
Get the neighborhood element q for the particle p.
const Mem_type::local_index_type & getStop(typename Mem_type::local_index_type p)
Return the end point of the neighborhood for the particle p.
T getRCut()
Return the cut-off radius of the Verlet list.
Iterator for the neighborhood of the cell structures.
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
Linearized version of subsub.