numerics
Loading...
Searching...
No Matches
physics::SpatialHash Class Reference

#include <spatial_hash.hpp>

Public Member Functions

 SpatialHash (float cell_size, float xmin, float xmax, float ymin, float ymax)
 
void build (const std::vector< Particle > &particles)
 Rebuild from the particle array. O(n + C).
 
template<typename F >
void query (float px, float py, F &&f) const
 
template<typename F >
void iterate_pairs (F &&f) const
 

Detailed Description

Definition at line 30 of file spatial_hash.hpp.

Constructor & Destructor Documentation

◆ SpatialHash()

physics::SpatialHash::SpatialHash ( float  cell_size,
float  xmin,
float  xmax,
float  ymin,
float  ymax 
)
inline
Parameters
cell_sizeKernel support radius (2h).
xmin..ymaxSimulation domain – required by CellList2D for the flat grid (no hash collisions, zero false positives).

Definition at line 35 of file spatial_hash.hpp.

Member Function Documentation

◆ build()

void physics::SpatialHash::build ( const std::vector< Particle > &  particles)
inline

Rebuild from the particle array. O(n + C).

Definition at line 41 of file spatial_hash.hpp.

References num::CellList2D< Scalar >::build().

Referenced by physics::FluidSolver::step().

◆ iterate_pairs()

template<typename F >
void physics::SpatialHash::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 are within one cell of each other. Each pair appears exactly once. Caller can apply equal-and-opposite contributions to both i and j.

Definition at line 60 of file spatial_hash.hpp.

References num::CellList2D< Scalar >::iterate_pairs().

Referenced by physics::backends::seq::compute_density_pressure(), and physics::backends::seq::compute_forces().

◆ query()

template<typename F >
void physics::SpatialHash::query ( float  px,
float  py,
F &&  f 
) const
inline

Point query: calls f(int j) for every candidate in the 3x3 neighbourhood. Caller must verify |r_ij| < cutoff. (Same contract as before.)

Definition at line 51 of file spatial_hash.hpp.

References num::CellList2D< Scalar >::query().

Referenced by physics::backends::omp::compute_density_pressure(), physics::backends::omp::compute_forces(), physics::backends::omp::heat_compute(), and physics::backends::seq::heat_compute().


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