OpenFPM  5.2.0
Project that contain the implementation of distributed structures
vector_dist_multiphase_functions.hpp
1 /*
2  * vector_dist_multiphase_functions.hpp
3  *
4  * Created on: Oct 14, 2016
5  * Author: i-bird
6  */
7 
8 #ifndef SRC_VECTOR_VECTOR_DIST_MULTIPHASE_FUNCTIONS_HPP_
9 #define SRC_VECTOR_VECTOR_DIST_MULTIPHASE_FUNCTIONS_HPP_
10 
11 #include "NN/CellList/multiphase/CellListM.hpp"
12 #include "NN/VerletList/VerletListM.hpp"
13 
14 template<typename Vector, typename Vector1, typename CL, typename T>
16 createVerletTwoPhase(Vector & v, Vector1 & v1, CL & cl, T r_cut)
17 {
19 
20  // auto it = v.getPosVector().getIteratorTo(v.size_local());
21  auto it = v.getDomainIterator();
22 
23  verletList.Initialize(cl,r_cut,it,v.getPosVector(),v1.getPosVector(),v.size_local());
24 
25  return verletList;
26 }
27 
28 template<typename Vector, typename Vector1, typename T>
30 createVerletTwoPhaseAdaptive(Vector & v, Vector1 & v1, openfpm::vector<T> &rCuts)
31 {
32 
34 
35  auto it = v.getDomainIterator();
36 
37  verletList.fillNonSymmAdaptiveIterator(it, v.getPosVector(), v1.getPosVector(), rCuts, v.size_local());
38 
39  return verletList;
40 }
41 
42 template<unsigned int sh_byte, typename Vector , typename Vector1,typename CL, typename T> VerletListM<Vector::dims,typename Vector::stype,sh_byte,CL,shift<Vector::dims,typename Vector::stype>,typename Vector::internal_position_vector_type>
43 createVerletM(size_t pp, Vector & v, Vector1 & phases, CL & cl, T r_cut)
44 {
46 
48 
49  for (size_t i = 0 ; i < phases.size() ; i++)
50  {v_phases.add(pos_v<typename Vector::internal_position_vector_type>(phases.get(i).getPosVector()));}
51 
52  verletList.Initialize(cl,pp,r_cut,v.getPosVector(),v_phases,v.size_local());
53 
54  return verletList;
55 }
56 
57 template<unsigned int nbit, typename Vector, typename T>
59 createCellListM(openfpm::vector<Vector> & phases, T r_cut)
60 {
61  size_t div[3];
63 
65  if (phases.size() == 0)
66  return NN;
67 
68  box_cl = phases.get(0).getDecomposition().getProcessorBounds();
69  phases.get(0).getCellListParams(r_cut,div,box_cl);
70 
71  NN.Initialize(box_cl,div);
72 
73  // for all the phases i
74  for (size_t i = 0; i < phases.size() ; i++)
75  {
76  // iterate across all the particle of the phase i
77  auto it = phases.get(i).getDomainAndGhostIterator();
78  while (it.isNext())
79  {
80  auto key = it.get();
81 
82  Point<Vector::dims,T> xp = phases.get(i).getPos(key);
83 
84  // Add the particle of the phase i to the cell list
85  NN.add(xp, key.getKey(), i);
86 
87  ++it;
88  }
89  }
90 
91  return NN;
92 }
93 
94 
96 
97 template<typename Vector,typename CL, typename T>
99 createVerletSym(Vector & v, Vector & v1, CL & cl, T r_cut)
100 {
102 
103  // auto it = v.getPosVector().getIteratorTo(v.size_local());
104  auto it = v.getDomainIterator();
105 
106  verletList.Initialize(cl,r_cut,it,v1.getPosVector(),v.size_local());
107 
108  return verletList;
109 }
110 
111 template<unsigned int sh_byte, typename Vector, typename Vector1 ,typename CL, typename T>
113 createVerletSymM(size_t pp, Vector & v, Vector1 & phases, CL & cl, T r_cut)
114 {
116 
118 
119  for (size_t i = 0 ; i < phases.size() ; i++)
120  {v_phases.add(pos_v<typename CL::internal_vector_pos_type>(phases.get(i).getPosVector()));}
121 
122  verletList.Initialize(cl,pp,r_cut,v.getPosVector(),v_phases,v.size_local(),VL_SYMMETRIC);
123 
124  return verletList;
125 }
126 
127 template<unsigned int nbit, typename Vector, typename T>
129 createCellListSymM(openfpm::vector<Vector> & phases, T r_cut)
130 {
132 
134  if (phases.size() == 0)
135  {return NN;}
136 
137  // Calculate the Cell list division for this CellList
138  CellDecomposer_sm<Vector::dims,typename Vector::stype,shift<Vector::dims,typename Vector::stype>> cd_sm;
139 
140  size_t pad = 0;
141  cl_param_calculateSym(phases.get(0).getDecomposition().getDomain(),cd_sm,phases.get(0).getDecomposition().getGhost(),r_cut,pad);
142 
143  // Processor bounding box
144  Box<Vector::dims, typename Vector::stype> pbox = phases.get(0).getDecomposition().getProcessorBounds();
145 
146  // Ghost padding extension
148  NN.Initialize(cd_sm,pbox,pad);
149 
150  // for all the phases i
151  for (size_t i = 0; i < phases.size() ; i++)
152  {
153  // iterate across all the particle of the phase i
154  auto it = phases.get(i).getDomainAndGhostIterator();
155  while (it.isNext())
156  {
157  auto key = it.get();
158 
159  Point<Vector::dims,T> xp = phases.get(i).getPos(key);
160 
161  // Add the particle of the phase i to the cell list
162  NN.add(xp, key.getKey(), i);
163 
164  ++it;
165  }
166  }
167 
168  return NN;
169 }
170 
171 #endif /* SRC_VECTOR_VECTOR_DIST_MULTIPHASE_FUNCTIONS_HPP_ */
This class represent an N-dimensional box.
Definition: Box.hpp:60
Class for Multi-Phase cell-list.
Definition: CellListM.hpp:52
void add(const T(&pos)[dim], size_t ele, size_t v_id)
Add an element in the cell list.
Definition: CellListM.hpp:143
Definition: Ghost.hpp:40
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:28
Sparse Matrix implementation stub object when OpenFPM is compiled with no linear algebra support.
Definition: Vector.hpp:40
Class for Verlet list implementation with Multiphase.
Definition: VerletListM.hpp:30
void Initialize(CellListImpl &cli, size_t pp, T r_cut, const vector_pos_type &pos, const openfpm::vector< struct pos_v< vector_pos_type >> &pos2, size_t ghostMarker, size_t opt=VL_NON_SYMMETRIC)
Class for Verlet list implementation.
Definition: VerletList.hpp:269
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 size()
Stub size.
Definition: map_vector.hpp:212
Structure that contain a reference to a vector of particles.