OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
14template<typename Vector, typename CL, typename T>
16createVerlet(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
25template<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>
26createVerletM(size_t pp, Vector & v, Vector1 & phases, CL & cl, T r_cut)
27{
29
31
32 for (size_t i = 0 ; i < phases.size() ; i++)
33 {v_phases.add(pos_v<typename Vector::internal_position_vector_type>(phases.get(i).getPosVector()));}
34
35 ver.Initialize(cl,pp,r_cut,v.getPosVector(),v_phases,v.size_local());
36
37 return ver;
38}
39
40template<unsigned int nbit, typename Vector, typename T>
42createCellListM(openfpm::vector<Vector> & phases, T r_cut)
43{
44 size_t div[3];
46
48 if (phases.size() == 0)
49 return NN;
50
51 box_cl = phases.get(0).getDecomposition().getProcessorBounds();
52 phases.get(0).getCellListParams(r_cut,div,box_cl);
53
54 NN.Initialize(box_cl,div);
55
56 // for all the phases i
57 for (size_t i = 0; i < phases.size() ; i++)
58 {
59 // iterate across all the particle of the phase i
60 auto it = phases.get(i).getDomainAndGhostIterator();
61 while (it.isNext())
62 {
63 auto key = it.get();
64
65 Point<Vector::dims,T> xp = phases.get(i).getPos(key);
66
67 // Add the particle of the phase i to the cell list
68 NN.add(xp, key.getKey(), i);
69
70 ++it;
71 }
72 }
73
74 return NN;
75}
76
77
79
80template<typename Vector,typename CL, typename T>
82createVerletSym(Vector & v, Vector & v1, CL & cl, T r_cut)
83{
85
86 ver.Initialize(cl,r_cut,v.getPosVector(),v1.getPosVector(),v.size_local());
87
88 return ver;
89}
90
91template<unsigned int sh_byte, typename Vector, typename Vector1 ,typename CL, typename T>
93createVerletSymM(size_t pp, Vector & v, Vector1 & phases, CL & cl, T r_cut)
94{
96
98
99 for (size_t i = 0 ; i < phases.size() ; i++)
100 {v_phases.add(pos_v<typename CL::internal_vector_pos_type>(phases.get(i).getPosVector()));}
101
102 ver.Initialize(cl,pp,r_cut,v.getPosVector(),v_phases,v.size_local(),VL_SYMMETRIC);
103
104 return ver;
105}
106
107template<unsigned int nbit, typename Vector, typename T>
109createCellListSymM(openfpm::vector<Vector> & phases, T r_cut)
110{
112
114 if (phases.size() == 0)
115 {return NN;}
116
117 // Calculate the Cell list division for this CellList
118 CellDecomposer_sm<Vector::dims,typename Vector::stype,shift<Vector::dims,typename Vector::stype>> cd_sm;
119
120 size_t pad = 0;
121 cl_param_calculateSym(phases.get(0).getDecomposition().getDomain(),cd_sm,phases.get(0).getDecomposition().getGhost(),r_cut,pad);
122
123 // Processor bounding box
124 Box<Vector::dims, typename Vector::stype> pbox = phases.get(0).getDecomposition().getProcessorBounds();
125
126 // Ghost padding extension
128 NN.Initialize(cd_sm,pbox,pad);
129
130 // for all the phases i
131 for (size_t i = 0; i < phases.size() ; i++)
132 {
133 // iterate across all the particle of the phase i
134 auto it = phases.get(i).getDomainAndGhostIterator();
135 while (it.isNext())
136 {
137 auto key = it.get();
138
139 Point<Vector::dims,T> xp = phases.get(i).getPos(key);
140
141 // Add the particle of the phase i to the cell list
142 NN.add(xp, key.getKey(), i);
143
144 ++it;
145 }
146 }
147
148 return NN;
149}
150
151#endif /* SRC_VECTOR_VECTOR_DIST_MULTIPHASE_FUNCTIONS_HPP_ */
This class represent an N-dimensional box.
Definition Box.hpp:61
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.
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.
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 g_m, size_t opt=VL_NON_SYMMETRIC)
Class for Verlet list implementation.
void Initialize(const Box< dim, T > &box, const Box< dim, T > &dom, T r_cut, vector_pos_type &pos, size_t g_m, size_t opt=VL_NON_SYMMETRIC)
Implementation of 1-D std::vector like structure.
size_t size()
Stub size.
Structure that contain a reference to a vector of particles.