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 
   31 template<
unsigned int dim, 
typename T, 
typename CellListImpl, 
typename PartIt, 
int type, 
typename local_index>
 
   45     static inline auto get(
const PartIt & it,
 
   50                            T r_cut) -> decltype(cl.template getNNIterator<NO_CHECK>(0))
 
   52         return cl.template getNNIterator<NO_CHECK>(cl.getCell(xp));
 
   77 template<
unsigned int dim, 
typename T, 
typename CellListImpl, 
typename PartIt, 
typename local_index>
 
   78 struct NNType<dim,T,CellListImpl,PartIt,WITH_RADIUS,local_index>
 
   91     static inline auto get(
const PartIt & it,
 
   96                            T r_cut) -> decltype(cl.template getNNIteratorRadius<NO_CHECK>(0,0.0))
 
   98         return cl.template getNNIteratorRadius<NO_CHECK>(cl.getCell(xp),r_cut);
 
  123 template<
unsigned int dim, 
typename T, 
typename CellListImpl, 
typename PartIt, 
typename local_index>
 
  124 struct NNType<dim,T,CellListImpl,PartIt,VL_SYMMETRIC,local_index>
 
  137     static inline auto get(
const PartIt & it, 
const openfpm::vector<Point<dim,T>> & v, 
Point<dim,T> & xp, 
size_t p, CellListImpl & cl, T r_cut) -> decltype(cl.template getNNIteratorSym<NO_CHECK>(0,0,
openfpm::vector<
Point<dim,T>>()))
 
  139         return cl.template getNNIteratorSym<NO_CHECK>(cl.getCell(xp),p,v);
 
  164 template<
unsigned int dim, 
typename T, 
typename CellListImpl, 
typename PartIt, 
typename local_index>
 
  165 struct NNType<dim,T,CellListImpl,PartIt,VL_CRS_SYMMETRIC,local_index>
 
  181         return it.getNNIteratorCSR(v);
 
  202 template<
unsigned int type, 
unsigned int dim, 
typename vector, 
typename CellList>
 
  222         return pos.getIteratorTo(end);
 
  232 template<
unsigned int dim, 
typename vector, 
typename CellList>
 
  275 template<
unsigned int dim,
 
  285     typename Mem_type::loc_index 
slot;
 
  309         if (opt & VL_SYMMETRIC || opt & VL_CRS_SYMMETRIC)
 
  310             populate_cell_list(pos,cli,g_m,CL_SYMMETRIC);
 
  312             populate_cell_list(pos,cli,g_m,CL_NON_SYMMETRIC);
 
  329         if (opt == VL_CRS_SYMMETRIC)
 
  331             create_<CellNNIteratorSym<dim,CellListImpl,RUNTIME,NO_CHECK>,VL_CRS_SYMMETRIC>(pos,pos2,dom,anom,r_cut,g_m,cl,opt);
 
  333         else if (opt == VL_SYMMETRIC)
 
  335             create_<decltype(cl.template getNNIteratorSym<NO_CHECK>(0,0,pos)),VL_SYMMETRIC>(pos,pos2,dom,anom,r_cut,g_m,cl,opt);
 
  339             create_<decltype(cl.template getNNIterator<NO_CHECK>(0)),VL_NON_SYMMETRIC>(pos,pos2,dom,anom,r_cut,g_m,cl,opt);
 
  357     template<
typename NN_type, 
int type> 
inline void create_(
const openfpm::vector<
Point<dim,T>> & pos, 
const openfpm::vector<
Point<dim,T>> & 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)
 
  363         Mem_type::init_to_zero(
slot,end);
 
  368         T r_cut2 = r_cut * r_cut;
 
  373             typename Mem_type::loc_index i = it.get();
 
  377             NN_type NN = 
NNType<dim,T,CellListImpl,decltype(it),type,typename Mem_type::loc_index>::get(it,pos,xp,i,
cli,r_cut);
 
  386                 if (xp.distance2(xq) < r_cut2)
 
  410         Mem_type::init_to_zero(
slot,g_m);
 
  413         T r_cut2 = r_cut * r_cut;
 
  416         for (
size_t i = 0 ; i < g_m ; i++)
 
  421             auto NN = cl.template getNNIteratorRadius<NO_CHECK>(cl.getCell(p),r_cut);
 
  455         return Mem_type::size();
 
  464     inline void addPart(
size_t part_id, 
size_t ele)
 
  466         Mem_type::addCell(part_id,ele);
 
  492         cli.Initialize(bt,div);
 
  500         create(pos, pos,dom_c,anom_c,r_cut,g_m,
cli,opt);
 
  521         CellDecomposer_sm<dim,T,shift<dim,T>> cd_sm;
 
  524         cl_param_calculateSym<dim,T>(box,cd_sm,g,r_cut,pad);
 
  527         cli.Initialize(cd_sm,dom,pad);
 
  535         create(pos, pos,dom_c,anom_c,r_cut,g_m,
cli,VL_SYMMETRIC);
 
  557         CellDecomposer_sm<dim,T,shift<dim,T>> cd_sm;
 
  560         cl_param_calculateSym<dim,T>(box,cd_sm,g,r_cut,pad);
 
  563         cli.Initialize(cd_sm,dom,pad);
 
  580         create(pos, pos,dom_c,anom_c,r_cut,g_m,
cli,VL_CRS_SYMMETRIC);
 
  600         create(pos, pos,dom_c,anom_c,r_cut,g_m,
cli,opt);
 
  617         create(pos,pos,dom_c,anom_c,r_cut,g_m,
cli,VL_CRS_SYMMETRIC);
 
  636                     size_t g_m, 
size_t opt = VL_NON_SYMMETRIC)
 
  643         for (
size_t i = 0 ; i < dim ; i++)
 
  644             wr &= r_cut <= spacing.
get(i);
 
  646         if (wr == 
true || opt == VL_SYMMETRIC)
 
  651             create(pos,pos2,dom_c,anom_c,r_cut,g_m,cli,opt);
 
  658             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);
 
  664     :Mem_type(VERLET_STARTING_NSLOT),
slot(VERLET_STARTING_NSLOT),
n_dec(0)
 
  669     :Mem_type(VERLET_STARTING_NSLOT),
slot(VERLET_STARTING_NSLOT)
 
  676     :Mem_type(VERLET_STARTING_NSLOT),
slot(VERLET_STARTING_NSLOT),
n_dec(0)
 
  692     :
slot(VERLET_STARTING_NSLOT),CellDecomposer_sm<dim,T,transform>(box,div,mat,box.getP1(),pad)
 
  757         Mem_type::operator=(vl);
 
  776         Mem_type::operator=(vl);
 
  795         return Mem_type::getNelements(part_id);
 
  806     inline size_t get(
size_t i, 
size_t j) 
const 
  808         return Mem_type::get(i,j);
 
  821         size_t vl_slot_tmp = vl.
slot;
 
  827         size_t n_dec_tmp = vl.
n_dec;
 
  841     template<
unsigned int impl=NO_CHECK>
 
  865     inline const typename Mem_type::loc_index &
 
  868         return Mem_type::getStartId(part_id);
 
  878     inline const typename Mem_type::loc_index &
 
  881         return Mem_type::getStopId(part_id);
 
  891     inline const typename Mem_type::loc_index &
 
  892     get_lin(
const typename Mem_type::loc_index * part_id)
 
  894         return Mem_type::get_lin(part_id);
 
openfpm::vector< typename Mem_type::loc_index > dp
Domain particles. 
VerletList(const VerletList< dim, T, Mem_type, transform, CellListImpl > &cell)
Copy constructor. 
This class represent an N-dimensional box. 
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. 
size_t get(size_t i, size_t j) const 
Get the neighborhood element j for the particle i. 
const Mem_type::loc_index & getStart(typename Mem_type::loc_index part_id)
Return the starting point of the neighborhood for the particle p. 
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. 
Class for Verlet list implementation. 
size_t value_type
Object type that the structure store. 
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. 
static void add(local_index p, openfpm::vector< local_index > &pc)
Add particle in the list of the domain particles. 
It is a class that work like a vector of vector. 
size_t n_dec
decomposition counter 
This class implement the point shape in an N-dimensional space. 
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. 
Iterator for the neighborhood of the cell structures. 
void initCl(CellListImpl &cli, openfpm::vector< Point< dim, T >> &pos, size_t g_m, size_t opt)
Fill the cell-list with data. 
VerletList< dim, T, Mem_type, transform, CellListImpl > & operator=(const VerletList< dim, T, Mem_type, transform, CellListImpl > &vl)
Copy a verlet list. 
CellListImpl cli
Interlal cell-list. 
void clear()
Clear the cell list. 
static void add(local_index p, openfpm::vector< local_index > &pc)
Add particle in the list of the domain particles. 
This iterator iterate across the particles of a Cell-list following the Cell structure. 
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)
static void add(local_index p, openfpm::vector< local_index > &pc)
Add particle in the list of the domain particles. 
VerletNNIterator< dim, VerletList< dim, T, Mem_type, transform, CellListImpl > > getNNIterator(size_t part_id)
Get the Neighborhood iterator. 
Get the neighborhood iterator based on type. 
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 
CellListImpl CellListImpl_
CellList implementation used for Verlet list construction. 
static auto get(const PartIt &it, const openfpm::vector< Point< dim, T >> &v, Point< dim, T > &xp, size_t p, CellListImpl &cl, T r_cut) -> decltype(cl.template getNNIterator< NO_CHECK >(0))
Get the neighborhood. 
Mem_type Mem_type_type
type for the local index 
This class implement an NxN (dense) matrix. 
size_t getNNPart(size_t part_id) const 
Return the number of neighborhood particles for the particle id. 
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 
VerletList()
Default Constructor. 
const T & get(size_t i) const 
Get coordinate. 
In general different NN scheme like full symmetric or CRS require different iterators over particles ...
VerletList< dim, T, Mem_type, transform, CellListImpl > & operator=(VerletList< dim, T, Mem_type, transform, CellListImpl > &&vl)
Copy the verlet list. 
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. 
Mem_type::loc_index slot
Number of slot for each particle. Or maximum number of particles for each particle. 
This class represent an N-dimensional box. 
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. 
static void add(local_index p, openfpm::vector< local_index > &pc)
Add particle in the list of the domain particles. 
openfpm::vector< typename Mem_type::loc_index > & getParticleSeq()
Return the domain particle sequence. 
T distance2(const Point< dim, T > &q)
It calculate the square distance between 2 points. 
size_t get_ndec()
Set the n_dec number. 
void set_ndec(size_t n_dec)
Set the n_dec number. 
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 create(const openfpm::vector< Point< dim, T >> &pos, const openfpm::vector< Point< dim, T >> &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. 
VerletList(VerletList< dim, T, Mem_type, transform, CellListImpl > &&cell)
Copy constructor. 
void swap(VerletList< dim, T, Mem_type, transform, CellListImpl > &vl)
Swap the memory. 
const Mem_type::loc_index & getStop(typename Mem_type::loc_index part_id)
Return the end point of the neighborhood for the particle p. 
void create_(const openfpm::vector< Point< dim, T >> &pos, const openfpm::vector< Point< dim, T >> &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. 
Implementation of 1-D std::vector like structure. 
Class for FAST cell list implementation. 
void addPart(size_t part_id, size_t ele)
Add a neighborhood particle to a particle. 
void Initialize(CellListImpl &cli, T r_cut, const openfpm::vector< Point< dim, T >> &pos, const openfpm::vector< Point< dim, T >> &pos2, size_t g_m, size_t opt=VL_NON_SYMMETRIC)
Linearized version of subsub. 
size_t size()
Return for how many particles has been constructed this verlet list. 
const Mem_type::loc_index & get_lin(const typename Mem_type::loc_index *part_id)
Return the neighborhood id. 
CellListImpl & getInternalCellList()
Get the internal cell-list used to construct the Verlet-list.