8#ifndef OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETLISTFAST_HPP_
9#define OPENFPM_DATA_SRC_NN_VERLETLIST_VERLETLISTFAST_HPP_
11#include "VerletNNIterator.hpp"
12#include "NN/CellList/CellList_util.hpp"
13#include "NN/Mem_type/MemFast.hpp"
14#include "NN/Mem_type/MemBalanced.hpp"
15#include "NN/Mem_type/MemMemoryWise.hpp"
17#define VERLET_STARTING_NSLOT 128
31template<
unsigned int dim,
typename T,
typename CellListImpl,
typename PartIt,
int type,
typename local_index>
45 template<
typename vector_pos_type>
46 static inline auto get(
const PartIt & it,
47 const vector_pos_type & v,
51 T r_cut) ->
decltype(cl.template getNNIterator<NO_CHECK>(0))
53 return cl.template getNNIterator<NO_CHECK>(cl.getCell(xp));
78template<
unsigned int dim,
typename T,
typename CellListImpl,
typename PartIt,
typename local_index>
79struct NNType<dim,T,CellListImpl,PartIt,WITH_RADIUS,local_index>
92 template<
typename vector_pos_type>
93 static inline auto get(
const PartIt & it,
94 const vector_pos_type & v,
98 T r_cut) ->
decltype(cl.template getNNIteratorRadius<NO_CHECK>(0,0.0))
100 return cl.template getNNIteratorRadius<NO_CHECK>(cl.getCell(xp),r_cut);
125template<
unsigned int dim,
typename T,
typename CellListImpl,
typename PartIt,
typename local_index>
126struct NNType<dim,T,CellListImpl,PartIt,VL_SYMMETRIC,local_index>
139 template<
typename vector_pos_type>
140 static inline auto get(
const PartIt & it,
141 const vector_pos_type & v,
145 T r_cut) ->
decltype(cl.template getNNIteratorSym<NO_CHECK>(0,0,vector_pos_type()))
147 return cl.template getNNIteratorSym<NO_CHECK>(cl.getCell(xp),p,v);
172template<
unsigned int dim,
typename T,
typename CellListImpl,
typename PartIt,
typename local_index>
173struct NNType<dim,T,CellListImpl,PartIt,VL_CRS_SYMMETRIC,local_index>
187 template<
typename vector_pos_type>
188 static inline auto get(
const PartIt & it,
189 const vector_pos_type & v,
193 T r_cut) ->
decltype(it.getNNIteratorCSR(v))
195 return it.getNNIteratorCSR(v);
217template<
unsigned int type,
unsigned int dim,
typename vector,
typename CellList>
237 return pos.getIteratorTo(end);
247template<
unsigned int dim,
typename vector,
typename CellList>
290template<
unsigned int dim,
301 typename Mem_type::local_index_type
slot;
323 void initCl(CellListImpl &
cli, vector_pos_type & pos,
size_t g_m,
size_t opt)
326 if (opt & VL_SYMMETRIC || opt & VL_CRS_SYMMETRIC)
327 {populate_cell_list(pos,
cli,context,g_m,CL_SYMMETRIC,cl_construct_opt::Full);}
329 {populate_cell_list(pos,
cli,context,g_m,CL_NON_SYMMETRIC,cl_construct_opt::Full);}
346 if (opt == VL_CRS_SYMMETRIC)
348 create_<CellNNIteratorSym<dim,CellListImpl,vector_pos_type,RUNTIME,NO_CHECK>,VL_CRS_SYMMETRIC>(pos,pos2,dom,anom,r_cut,g_m,cl,opt);
350 else if (opt == VL_SYMMETRIC)
352 create_<
decltype(cl.template getNNIteratorSym<NO_CHECK>(0,0,pos)),VL_SYMMETRIC>(pos,pos2,dom,anom,r_cut,g_m,cl,opt);
356 create_<
decltype(cl.template getNNIterator<NO_CHECK>(0)),VL_NON_SYMMETRIC>(pos,pos2,dom,anom,r_cut,g_m,cl,opt);
380 Mem_type::init_to_zero(
slot,end);
385 T r_cut2 = r_cut * r_cut;
390 typename Mem_type::local_index_type i = it.get();
394 auto NN =
NNType<dim,T,CellListImpl,
decltype(it),type,
typename Mem_type::local_index_type>
::get(it,pos,xp,i,
cli,r_cut);
395 NNType<dim,T,CellListImpl,
decltype(it),type,
typename Mem_type::local_index_type>
::add(i,
dp);
427 Mem_type::init_to_zero(
slot,g_m);
430 T r_cut2 = r_cut * r_cut;
433 for (
size_t i = 0 ; i < g_m ; i++)
438 auto NN = cl.template getNNIteratorRadius<NO_CHECK>(cl.getCell(p),r_cut);
472 return Mem_type::size();
483 Mem_type::addCell(part_id,
ele);
509 cli.Initialize(bt,div);
518 create(pos, pos,dom_c,anom_c,r_cut,g_m,
cli,opt);
539 CellDecomposer_sm<dim,T,shift<dim,T>> cd_sm;
542 cl_param_calculateSym<dim,T>(box,cd_sm,g,r_cut,pad);
545 cli.Initialize(cd_sm,dom,pad);
553 create(pos, pos,dom_c,anom_c,r_cut,g_m,
cli,VL_SYMMETRIC);
575 CellDecomposer_sm<dim,T,shift<dim,T>> cd_sm;
578 cl_param_calculateSym<dim,T>(box,cd_sm,g,r_cut,pad);
581 cli.Initialize(cd_sm,dom,pad);
598 create(pos, pos,dom_c,anom_c,r_cut,g_m,
cli,VL_CRS_SYMMETRIC);
618 create(pos, pos,dom_c,anom_c,r_cut,g_m,
cli,opt);
635 create(pos,pos,dom_c,anom_c,r_cut,g_m,
cli,VL_CRS_SYMMETRIC);
652 const vector_pos_type & pos,
653 const vector_pos_type & pos2,
654 size_t g_m,
size_t opt = VL_NON_SYMMETRIC)
661 for (
size_t i = 0 ; i < dim ; i++)
662 wr &= r_cut <= spacing.
get(i);
664 if (wr ==
true || opt == VL_SYMMETRIC)
669 create(pos,pos2,dom_c,anom_c,r_cut,g_m,
cli,opt);
676 create_<
decltype(
cli.template getNNIteratorRadius<NO_CHECK>(0,0.0)),WITH_RADIUS>(pos,pos2,dom_c,anom_c,r_cut,g_m,
cli,VL_NON_SYMMETRIC);
682 :Mem_type(VERLET_STARTING_NSLOT),
slot(VERLET_STARTING_NSLOT),
n_dec(0)
687 :Mem_type(VERLET_STARTING_NSLOT),
slot(VERLET_STARTING_NSLOT)
694 :Mem_type(VERLET_STARTING_NSLOT),
slot(VERLET_STARTING_NSLOT),
n_dec(0)
710 :
slot(VERLET_STARTING_NSLOT),CellDecomposer_sm<dim,T,transform>(box,div,mat,box.getP1(),pad)
775 Mem_type::operator=(vl);
795 Mem_type::operator=(vl);
814 return Mem_type::getNelements(part_id);
825 inline size_t get(
size_t i,
size_t j)
const
827 return Mem_type::get(i,j);
840 size_t vl_slot_tmp = vl.
slot;
846 size_t n_dec_tmp = vl.
n_dec;
860 template<
unsigned int impl=NO_CHECK>
884 inline const typename Mem_type::local_index_type &
885 getStart(
typename Mem_type::local_index_type part_id)
887 return Mem_type::getStartId(part_id);
897 inline const typename Mem_type::local_index_type &
898 getStop(
typename Mem_type::local_index_type part_id)
900 return Mem_type::getStopId(part_id);
910 inline const typename Mem_type::local_index_type &
911 get_lin(
const typename Mem_type::local_index_type * part_id)
913 return Mem_type::get_lin(part_id);
This class represent an N-dimensional box.
Class for FAST cell list implementation.
const NNc_array< dim,(unsigned int) openfpm::math::pow(3, dim)/2+1 > & getNNc_sym() const
Get the symmetric neighborhood.
This class implement an NxN (dense) matrix.
It is a class that work like a vector of vector.
void add(local_index cell_id, local_index ele)
Add an element to the cell.
static ParticleItCRS_Cells< dim, CellList, vector > 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)
It return the particle iterator.
In general different NN scheme like full symmetric or CRS require different iterators over particles ...
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 iterator iterate across the particles of a Cell-list following the Cell structure.
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
T distance2(const Point< dim, T > &q) const
It calculate the square distance between 2 points.
This class represent an N-dimensional box.
Class for Verlet list implementation.
const Mem_type::local_index_type & getStart(typename Mem_type::local_index_type part_id)
Return the starting point of the neighborhood for the particle p.
VerletList(SpaceBox< dim, T > &box, Box< dim, T > &dom, T r_cut, openfpm::vector< Point< dim, T > > &pos, size_t g_m, size_t slot=VERLET_STARTING_NSLOT)
Cell list constructor.
void createVerletCrs(T r_cut, size_t g_m, openfpm::vector< Point< dim, T > > &pos, openfpm::vector< size_t > &dom_c, openfpm::vector< subsub_lin< dim > > &anom_c)
Create the Verlet-list with the crossing scheme.
void updateCrs(const Box< dim, T > &dom, T r_cut, openfpm::vector< Point< dim, T > > &pos, size_t &g_m, const openfpm::vector< size_t > &dom_c, const openfpm::vector< subsub_lin< dim > > &anom_c)
update the Verlet list
size_t get_ndec()
Set the n_dec number.
void set_ndec(size_t n_dec)
Set the n_dec number.
VerletList()
Default Constructor.
void update(const Box< dim, T > &dom, T r_cut, openfpm::vector< Point< dim, T > > &pos, size_t &g_m, size_t opt)
update the Verlet list
const Mem_type::local_index_type & get_lin(const typename Mem_type::local_index_type *part_id)
Return the neighborhood id.
size_t get(size_t i, size_t j) const
Get the neighborhood element j for the particle i.
void create(const vector_pos_type &pos, const vector_pos_type &pos2, const openfpm::vector< size_t > &dom, const openfpm::vector< subsub_lin< dim > > &anom, T r_cut, size_t g_m, CellListImpl &cl, size_t opt)
Create the Verlet list from a given cell-list.
void clear()
Clear the cell list.
const Mem_type::local_index_type & getStop(typename Mem_type::local_index_type part_id)
Return the end point of the neighborhood for the particle p.
openfpm::vector< typename Mem_type::local_index_type > dp
Domain particles.
void Initialize(CellListImpl &cli, T r_cut, const vector_pos_type &pos, const vector_pos_type &pos2, size_t g_m, size_t opt=VL_NON_SYMMETRIC)
size_t size()
Return for how many particles has been constructed this verlet list.
VerletList(Box< dim, T > &box, T r_cut, openfpm::vector< Point< dim, T > > &pos, size_t g_m, size_t slot=VERLET_STARTING_NSLOT)
Verlet-list constructor.
void initCl(CellListImpl &cli, vector_pos_type &pos, size_t g_m, size_t opt)
Fill the cell-list with data.
Mem_type::local_index_type slot
Number of slot for each particle. Or maximum number of particles for each particle.
size_t n_dec
decomposition counter
void addPart(size_t part_id, size_t ele)
Add a neighborhood particle to a particle.
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)
VerletList(const VerletList< dim, T, Mem_type, transform, vector_pos_type, CellListImpl > &cell)
Copy constructor.
size_t getNNPart(size_t part_id) const
Return the number of neighborhood particles for the particle id.
void InitializeSym(const Box< dim, T > &box, const Box< dim, T > &dom, const Ghost< dim, T > &g, T r_cut, openfpm::vector< Point< dim, T > > &pos, size_t g_m)
Initialize the symmetric Verlet-list.
VerletList< dim, T, Mem_type, transform, vector_pos_type, CellListImpl > & operator=(VerletList< dim, T, Mem_type, transform, vector_pos_type, CellListImpl > &&vl)
Copy the verlet list.
CellListImpl & getInternalCellList()
Get the internal cell-list used to construct the Verlet-list.
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.
openfpm::vector< typename Mem_type::local_index_type > & getParticleSeq()
Return the domain particle sequence.
void InitializeCrs(const Box< dim, T > &box, const Box< dim, T > &dom, const Ghost< dim, T > &g, T r_cut, openfpm::vector< Point< dim, T > > &pos, size_t g_m)
Initialize the symmetric Verlet-list CRS scheme.
void swap(VerletList< dim, T, Mem_type, transform, vector_pos_type, CellListImpl > &vl)
Swap the memory.
void create_(const vector_pos_type &pos, const vector_pos_type &pos2, const openfpm::vector< size_t > &dom, const openfpm::vector< subsub_lin< dim > > &anom, T r_cut, size_t g_m, CellListImpl &cli, size_t opt)
Create the Verlet list from a given cell-list.
CellListImpl cli
Interlal cell-list.
CellListImpl CellListImpl_
CellList implementation used for Verlet list construction.
VerletList< dim, T, Mem_type, transform, vector_pos_type, CellListImpl > & operator=(const VerletList< dim, T, Mem_type, transform, vector_pos_type, CellListImpl > &vl)
Copy a verlet list.
Mem_type Mem_type_type
type for the local index
VerletList(VerletList< dim, T, Mem_type, transform, vector_pos_type, CellListImpl > &&cell)
Copy constructor.
size_t value_type
Object type that the structure store.
VerletNNIterator< dim, VerletList< dim, T, Mem_type, transform, vector_pos_type, CellListImpl > > getNNIterator(size_t part_id)
Get the Neighborhood iterator.
void createR(openfpm::vector< Point< dim, T > > &pos, T r_cut, size_t g_m, CellListImpl &cl)
Create the Verlet list from a given cell-list with a particular cut-off radius.
Iterator for the neighborhood of the cell structures.
Implementation of 1-D std::vector like structure.
static auto get(const PartIt &it, const vector_pos_type &v, Point< dim, T > &xp, size_t p, CellListImpl &cl, T r_cut) -> decltype(it.getNNIteratorCSR(v))
Get the neighborhood.
static void add(local_index p, openfpm::vector< local_index > &pc)
Add particle in the list of the domain particles.
static auto get(const PartIt &it, const vector_pos_type &v, Point< dim, T > &xp, size_t p, CellListImpl &cl, T r_cut) -> decltype(cl.template getNNIteratorSym< NO_CHECK >(0, 0, vector_pos_type()))
Get the neighborhood.
static void add(local_index p, openfpm::vector< local_index > &pc)
Add particle in the list of the domain particles.
static void add(local_index p, openfpm::vector< local_index > &pc)
Add particle in the list of the domain particles.
static auto get(const PartIt &it, const vector_pos_type &v, Point< dim, T > &xp, size_t p, CellListImpl &cl, T r_cut) -> decltype(cl.template getNNIteratorRadius< NO_CHECK >(0, 0.0))
Get the neighborhood.
Get the neighborhood iterator based on type.
static auto get(const PartIt &it, const vector_pos_type &v, Point< dim, T > &xp, size_t p, CellListImpl &cl, T r_cut) -> decltype(cl.template getNNIterator< NO_CHECK >(0))
Get the neighborhood.
static void add(local_index p, openfpm::vector< local_index > &pc)
Add particle in the list of the domain particles.
Linearized version of subsub.