numerics
Loading...
Searching...
No Matches
num::CellList2D< Scalar > Class Template Reference

#include <cell_list.hpp>

Public Member Functions

 CellList2D (Scalar cell_size, Scalar xmin, Scalar xmax, Scalar ymin, Scalar ymax)
 
template<typename PosAccessor >
void build (PosAccessor &&get_pos, int n)
 Rebuild the cell list from n particles.
 
template<typename F >
void query (Scalar px, Scalar py, F &&f) const
 Point query: calls f(int j) for every particle in the 3x3 cell neighbourhood of (px, py).
 
template<typename F >
void iterate_pairs (F &&f) const
 Newton's 3rd law pair traversal.
 
IntRange cell_particles (int cx, int cy) const noexcept
 Direct access to sorted particle indices for cell (cx, cy).
 
int nx () const noexcept
 
int ny () const noexcept
 
int n_particles () const noexcept
 

Detailed Description

template<typename Scalar>
class num::CellList2D< Scalar >

Definition at line 69 of file cell_list.hpp.

Constructor & Destructor Documentation

◆ CellList2D()

template<typename Scalar >
num::CellList2D< Scalar >::CellList2D ( Scalar  cell_size,
Scalar  xmin,
Scalar  xmax,
Scalar  ymin,
Scalar  ymax 
)
inline
Parameters
cell_sizeWidth of one cell (use kernel support radius 2h).
xmin,xmax,ymin,ymaxSimulation domain. Particles outside are clamped to the boundary cell (safe, just no missed neighbours).

Definition at line 74 of file cell_list.hpp.

Member Function Documentation

◆ build()

template<typename Scalar >
template<typename PosAccessor >
void num::CellList2D< Scalar >::build ( PosAccessor &&  get_pos,
int  n 
)
inline

Rebuild the cell list from n particles.

PosAccessor: callable int -> std::pair<Scalar,Scalar> (x, y)

Complexity: O(n + C) (two passes over particles + one prefix sum)

Definition at line 93 of file cell_list.hpp.

References num::ipow().

Referenced by physics::SpatialHash::build().

◆ cell_particles()

template<typename Scalar >
IntRange num::CellList2D< Scalar >::cell_particles ( int  cx,
int  cy 
) const
inlinenoexcept

Direct access to sorted particle indices for cell (cx, cy).

Definition at line 185 of file cell_list.hpp.

References num::ipow().

◆ iterate_pairs()

template<typename Scalar >
template<typename F >
void num::CellList2D< Scalar >::iterate_pairs ( F &&  f) const
inline

Newton's 3rd law pair traversal.

Calls f(int i, int j) for every unique unordered pair {i,j} whose cells lie within the 3x3 neighbourhood. Each pair appears exactly once. Caller can apply equal-and-opposite contributions to i and j.

Complexity: O(n*k/2) where k = average neighbour count.

Definition at line 145 of file cell_list.hpp.

References num::ipow().

Referenced by physics::SpatialHash::iterate_pairs().

◆ n_particles()

template<typename Scalar >
int num::CellList2D< Scalar >::n_particles ( ) const
inlinenoexcept

Definition at line 193 of file cell_list.hpp.

◆ nx()

template<typename Scalar >
int num::CellList2D< Scalar >::nx ( ) const
inlinenoexcept

Definition at line 191 of file cell_list.hpp.

◆ ny()

template<typename Scalar >
int num::CellList2D< Scalar >::ny ( ) const
inlinenoexcept

Definition at line 192 of file cell_list.hpp.

◆ query()

template<typename Scalar >
template<typename F >
void num::CellList2D< Scalar >::query ( Scalar  px,
Scalar  py,
F &&  f 
) const
inline

Point query: calls f(int j) for every particle in the 3x3 cell neighbourhood of (px, py).

Caller must still verify |r_ij| < cutoff – this returns candidates.

Definition at line 121 of file cell_list.hpp.

References num::ipow().

Referenced by physics::SpatialHash::query().


The documentation for this class was generated from the following file: