OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
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/CellListM.hpp"
12 #include "NN/VerletList/VerletListM.hpp"
13 
14 template<typename Vector, typename CL, typename T>
16 createVerlet(Vector & v, Vector & v1, CL & cl, T r_cut)
17 {
19 
20  ver.Initialize(cl,r_cut,v.getPosVector(),v1.getPosVector(),v.size_local());
21 
22  return ver;
23 }
24 
25 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>> createVerletM(size_t pp, Vector & v, Vector1 & phases, CL & cl, T r_cut)
26 {
28 
30 
31  for (size_t i = 0 ; i < phases.size() ; i++)
32  v_phases.add(pos_v<Vector::dims,typename Vector::stype>(phases.get(i).getPosVector()));
33 
34  ver.Initialize(cl,pp,r_cut,v.getPosVector(),v_phases,v.size_local());
35 
36  return ver;
37 }
38 
39 template<unsigned int nbit, typename Vector, typename T> CellListM<Vector::dims,typename Vector::stype,nbit> createCellListM(openfpm::vector<Vector> & phases, T r_cut)
40 {
41  size_t div[3];
43 
45  if (phases.size() == 0)
46  return NN;
47 
48  box_cl = phases.get(0).getDecomposition().getProcessorBounds();
49  phases.get(0).getCellListParams(r_cut,div,box_cl);
50 
51  NN.Initialize(box_cl,div);
52 
53  // for all the phases i
54  for (size_t i = 0; i < phases.size() ; i++)
55  {
56  // iterate across all the particle of the phase i
57  auto it = phases.get(i).getDomainAndGhostIterator();
58  while (it.isNext())
59  {
60  auto key = it.get();
61 
62  Point<Vector::dims,T> xp = phases.get(i).getPos(key);
63 
64  // Add the particle of the phase i to the cell list
65  NN.add(xp, key.getKey(), i);
66 
67  ++it;
68  }
69  }
70 
71  return NN;
72 }
73 
74 
76 
77 template<typename Vector,typename CL, typename T>
79 createVerletSym(Vector & v, Vector & v1, CL & cl, T r_cut)
80 {
82 
83  ver.Initialize(cl,r_cut,v.getPosVector(),v1.getPosVector(),v.size_local());
84 
85  return ver;
86 }
87 
88 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>> createVerletSymM(size_t pp, Vector & v, Vector1 & phases, CL & cl, T r_cut)
89 {
91 
93 
94  for (size_t i = 0 ; i < phases.size() ; i++)
95  {v_phases.add(pos_v<Vector::dims,typename Vector::stype>(phases.get(i).getPosVector()));}
96 
97  ver.Initialize(cl,pp,r_cut,v.getPosVector(),v_phases,v.size_local(),VL_SYMMETRIC);
98 
99  return ver;
100 }
101 
102 template<unsigned int nbit, typename Vector, typename T> CellListM<Vector::dims,typename Vector::stype,nbit> createCellListSymM(openfpm::vector<Vector> & phases, T r_cut)
103 {
105 
107  if (phases.size() == 0)
108  return NN;
109 
110  // Calculate the Cell list division for this CellList
111  CellDecomposer_sm<Vector::dims,typename Vector::stype,shift<Vector::dims,typename Vector::stype>> cd_sm;
112 
113  size_t pad = 0;
114  cl_param_calculateSym(phases.get(0).getDecomposition().getDomain(),cd_sm,phases.get(0).getDecomposition().getGhost(),r_cut,pad);
115 
116  // Processor bounding box
117  Box<Vector::dims, typename Vector::stype> pbox = phases.get(0).getDecomposition().getProcessorBounds();
118 
119  // Ghost padding extension
121  NN.Initialize(cd_sm,pbox,pad);
122 
123  // for all the phases i
124  for (size_t i = 0; i < phases.size() ; i++)
125  {
126  // iterate across all the particle of the phase i
127  auto it = phases.get(i).getDomainAndGhostIterator();
128  while (it.isNext())
129  {
130  auto key = it.get();
131 
132  Point<Vector::dims,T> xp = phases.get(i).getPos(key);
133 
134  // Add the particle of the phase i to the cell list
135  NN.add(xp, key.getKey(), i);
136 
137  ++it;
138  }
139  }
140 
141  return NN;
142 }
143 
144 #endif /* SRC_VECTOR_VECTOR_DIST_MULTIPHASE_FUNCTIONS_HPP_ */
Sparse Matrix implementation stub object when OpenFPM is compiled with no linear algebra support...
Definition: Vector.hpp:39
Class for Verlet list implementation.
size_t size()
Stub size.
Definition: map_vector.hpp:70
This class implement the point shape in an N-dimensional space.
Definition: Point.hpp:22
Structure that contain a reference to a vector of particles.
void Initialize(const Box< dim, T > &box, const Box< dim, T > &dom, T r_cut, openfpm::vector< Point< dim, T >> &pos, size_t g_m, size_t opt=VL_NON_SYMMETRIC)
Definition: Ghost.hpp:39
Class for Verlet list implementation with Multiphase.
Class for Multi-Phase cell-list.
Definition: CellListM.hpp:53
This class represent an N-dimensional box.
Definition: Box.hpp:56
This class is a trick to indicate the compiler a specific specialization pattern. ...
Definition: memory_c.hpp:201
void add(const T(&pos)[dim], size_t ele, size_t v_id)
Add an element in the cell list.
Definition: CellListM.hpp:145
void Initialize(CellListImpl &cli, size_t pp, T r_cut, const openfpm::vector< Point< dim, T >> &pos, const openfpm::vector< struct pos_v< dim, T >> &pos2, size_t g_m, size_t opt=VL_NON_SYMMETRIC)
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:61