OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
VerletListM.hpp
1/*
2 * VerletListM.hpp
3 *
4 * Created on: Oct 15, 2016
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETLISTM_HPP_
9#define OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETLISTM_HPP_
10
11#include "NN/VerletList/VerletNNIteratorM.hpp"
12#include "VerletList.hpp"
13
14
24template<unsigned int dim, typename T, typename CellListImpl, typename PartIt, int type>
25struct NNTypeM
26{
38 static inline auto get(const PartIt & it,
39 const typename CellListImpl::internal_vector_pos_type & pos,
41 Point<dim,T> & xp,
42 size_t pp,
43 size_t p,
44 CellListImpl & cl,
45 T r_cut) -> decltype(cl.template getNNIterator<NO_CHECK>(0))
46 {
47 return cl.template getNNIterator<NO_CHECK>(cl.getCell(xp));
48 }
49};
50
61template<unsigned int dim, typename T, typename CellListImpl, typename PartIt>
62struct NNTypeM<dim,T,CellListImpl,PartIt,VL_CRS_SYMMETRIC>
63{
76 static inline auto get(const PartIt & it,
77 const typename CellListImpl::internal_vector_pos_type & pos,
79 Point<dim,T> & xp,
80 size_t pp,
81 size_t p,
82 CellListImpl & cl,
83 T r_cut) -> decltype(it.getNNIteratorCSRM(pos,v))
84 {
85 return it.getNNIteratorCSRM(pos,v);
86 }
87};
88
99template<unsigned int dim, typename T, typename CellListImpl, typename PartIt>
100struct NNTypeM<dim,T,CellListImpl,PartIt,VL_SYMMETRIC>
101{
113 static inline auto get(const PartIt & it,
114 const typename CellListImpl::internal_vector_pos_type & pos,
116 Point<dim,T> & xp,
117 size_t pp,
118 size_t p,
119 CellListImpl & cl,
120 T r_cut) -> decltype(cl.template getNNIteratorSym<NO_CHECK>(0,0,0,typename CellListImpl::internal_vector_pos_type(),openfpm::vector<pos_v<typename CellListImpl::internal_vector_pos_type>>()))
121 {
122 return cl.template getNNIteratorSym<NO_CHECK>(cl.getCell(xp),pp,p,pos,v);
123 }
124};
125
126
127
135template<unsigned int dim,
136 typename T,
137 unsigned int sh_byte ,
138 typename CellListImpl=CellListM<dim,T,sh_byte>,
139 typename transform = shift<dim,T>,
140 typename vector_pos_type = openfpm::vector<Point<dim,T>>,
141 typename VerletBase=VerletList<dim,T,Mem_fast<>,transform, vector_pos_type> >
143{
144
146 typedef boost::high_bit_mask_t<sh_byte> mask_high;
147
149 typedef boost::low_bits_mask_t<sizeof(size_t)*8-sh_byte> mask_low;
150
163 inline void create(const vector_pos_type & pos,
165 const openfpm::vector<size_t> & dom,
166 const openfpm::vector<subsub_lin<dim>> & anom,
167 size_t pp,
168 T r_cut,
169 size_t g_m,
170 CellListImpl & cl,
171 size_t opt)
172 {
173 if (opt == VL_CRS_SYMMETRIC)
174 {
175 create_<CellNNIteratorSymM<dim,CellListImpl,sh_byte,RUNTIME,NO_CHECK>,VL_CRS_SYMMETRIC>(pos,pos2,dom,anom,pp,r_cut,g_m,cl,opt);
176 }
177 else if (opt == VL_SYMMETRIC)
178 {
179 create_<decltype(cl.template getNNIteratorSym<NO_CHECK>(0,0,0,pos,pos2)),VL_SYMMETRIC>(pos,pos2,dom,anom,pp,r_cut,g_m,cl,opt);
180 }
181 else
182 {
183 create_<decltype(cl.template getNNIterator<NO_CHECK>(0)),VL_NON_SYMMETRIC>(pos,pos2,dom,anom,pp,r_cut,g_m,cl,opt);
184 }
185 }
186
201 template<typename NN_type, int type> inline void create_(const vector_pos_type & pos,
203 const openfpm::vector<size_t> & dom,
204 const openfpm::vector<subsub_lin<dim>> & anom,
205 size_t pp,
206 T r_cut,
207 size_t g_m,
208 CellListImpl & cli,
209 size_t opt)
210 {
211 size_t end;
212
213 auto it = PartItNN<type,dim,vector_pos_type,CellListImpl>::get(pos,dom,anom,cli,g_m,end);
214
215/* this->cl_n.resize(end);
216 this->cl_base.resize(end*this->slot);
217 this->cl_n.fill(0);*/
218
219 this->init_to_zero(this->slot,end);
220
221 // square of the cutting radius
222 T r_cut2 = r_cut * r_cut;
223
224 // iterate the particles
225 while (it.isNext())
226 {
227 size_t i = it.get();
228 Point<dim,T> xp = pos.template get<0>(i);
229
230 // Get the neighborhood of the particle
231 NN_type NN = NNTypeM<dim,T,CellListImpl,decltype(it),type>::get(it,pos,pos2,xp,pp,i,cli,r_cut);
232
233 while (NN.isNext())
234 {
235 size_t nnp = NN.getP();
236 size_t v = NN.getV();
237 size_t nnp_a = NN.get();
238
239 Point<dim,T> xq = pos2.get(v).pos.template get<0>(nnp);
240
241 if (xp.distance2(xq) < r_cut2)
242 this->addPart(i,nnp_a);
243
244 // Next particle
245 ++NN;
246 }
247
248 ++it;
249 }
250 }
251
252public:
253
267 void Initialize(CellListImpl & cli, size_t pp,
268 T r_cut, const vector_pos_type & pos,
269 const openfpm::vector<struct pos_v<vector_pos_type>> & pos2, size_t g_m,
270 size_t opt = VL_NON_SYMMETRIC)
271 {
272// this->cl_n.resize(g_m);
273// this->cl_base.resize(g_m*this->slot);
274
275 Point<dim,T> spacing = cli.getCellBox().getP2();
276
277 // Create with radius or not
278 bool wr = true;
279
280 for (size_t i = 0 ; i < dim ; i++)
281 {wr &= r_cut <= spacing.get(i);}
282
283 if (wr == true || opt == VL_SYMMETRIC)
284 {
287
288 create(pos,pos2,dom_c,anom_c,pp,r_cut,g_m,cli,opt);
289 }
290 else
291 {
292 std::cerr << __FILE__ << ":" << __LINE__ << " error iterator with radius is not implemented yet " << std::endl;
293 }
294 }
295
306 inline size_t getP(size_t part, size_t ele) const
307 {
308 return VerletBase::get(part,ele) & mask_low::sig_bits_fast;
309 }
310
321 inline size_t getV(size_t part, size_t ele) const
322 {
323 return (VerletBase::get(part,ele)) >> (sizeof(size_t)*8-sh_byte);
324 }
325
336 {
338
339 return vln;
340 }
341};
342
343
344#endif /* OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETLISTM_HPP_ */
Class for Multi-Phase cell-list.
Definition CellListM.hpp:52
static auto get(const vector &pos, const openfpm::vector< size_t > &dom, const openfpm::vector< subsub_lin< dim > > &anom, CellList &cli, size_t g_m, size_t &end) -> decltype(pos.getIteratorTo(0))
It return the particle iterator.
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Definition Point.hpp:172
T distance2(const Point< dim, T > &q) const
It calculate the square distance between 2 points.
Definition Point.hpp:269
Class for Verlet list implementation with Multiphase.
size_t getP(size_t part, size_t ele) const
Get the element-id in the cell.
size_t getV(size_t part, size_t ele) const
Get the element vector in the cell.
boost::high_bit_mask_t< sh_byte > mask_high
Mask to get the high bits of a number.
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)
boost::low_bits_mask_t< sizeof(size_t) *8-sh_byte > mask_low
Mask to get the low bits of a number.
void create_(const vector_pos_type &pos, const openfpm::vector< pos_v< vector_pos_type > > &pos2, const openfpm::vector< size_t > &dom, const openfpm::vector< subsub_lin< dim > > &anom, size_t pp, T r_cut, size_t g_m, CellListImpl &cli, size_t opt)
Create the Verlet list from a given cell-list.
void create(const vector_pos_type &pos, const openfpm::vector< pos_v< vector_pos_type > > &pos2, const openfpm::vector< size_t > &dom, const openfpm::vector< subsub_lin< dim > > &anom, size_t pp, T r_cut, size_t g_m, CellListImpl &cl, size_t opt)
Create the Verlet list from a given cell-list.
VerletNNIteratorM< dim, VerletListM< dim, T, sh_byte, CellListImpl, transform, vector_pos_type, VerletBase >, sh_byte > getNNIterator(size_t part_id)
Get the Neighborhood iterator.
Class for Verlet list implementation.
Iterator for the neighborhood of the cell structures.
Implementation of 1-D std::vector like structure.
static auto get(const PartIt &it, const typename CellListImpl::internal_vector_pos_type &pos, const openfpm::vector< pos_v< typename CellListImpl::internal_vector_pos_type > > &v, Point< dim, T > &xp, size_t pp, size_t p, CellListImpl &cl, T r_cut) -> decltype(it.getNNIteratorCSRM(pos, v))
Get the neighborhood.
static auto get(const PartIt &it, const typename CellListImpl::internal_vector_pos_type &pos, const openfpm::vector< pos_v< typename CellListImpl::internal_vector_pos_type > > &v, Point< dim, T > &xp, size_t pp, size_t p, CellListImpl &cl, T r_cut) -> decltype(cl.template getNNIteratorSym< NO_CHECK >(0, 0, 0, typename CellListImpl::internal_vector_pos_type(), openfpm::vector< pos_v< typename CellListImpl::internal_vector_pos_type > >()))
Get the neighborhood.
Get the neighborhood iterator based on type.
static auto get(const PartIt &it, const typename CellListImpl::internal_vector_pos_type &pos, const openfpm::vector< pos_v< typename CellListImpl::internal_vector_pos_type > > &v, Point< dim, T > &xp, size_t pp, size_t p, CellListImpl &cl, T r_cut) -> decltype(cl.template getNNIterator< NO_CHECK >(0))
Get the neighborhood.
Structure that contain a reference to a vector of particles.
Linearized version of subsub.