#include <grid.h>
Abstracts a list of cells that partition the particles in the experiment into regions of space that can interact / cannot interact.
This class is used to construct a helper data structure to reduce the combinatorics of finding particle pairs that could interact (scatter). It takes a list of ParticleData objects and sorts them in such a way that it is easy to look only at lists of particles that have a chance of interacting.
Options | This policy parameter determines whether ghost cells are created to support periodic boundaries, or not. |
Public Member Functions | |
Grid (const Particles &particles, double min_cell_length, CellSizeStrategy strategy=CellSizeStrategy::Optimal) | |
Constructs a grid from the given particle list particles . More... | |
Grid (const std::pair< std::array< double, 3 >, std::array< double, 3 >> &min_and_length, const Particles &particles, double min_cell_length, CellSizeStrategy strategy=CellSizeStrategy::Optimal) | |
Constructs a grid with the given minimum grid coordinates and grid length. More... | |
void | iterate_cells (const std::function< void(const ParticleList &)> &search_cell_callback, const std::function< void(const ParticleList &, const ParticleList &)> &neighbor_cell_callback) const |
Iterates over all cells in the grid and calls the callback arguments with a search cell and 0 to 13 neighbor cells. More... | |
template<> | |
void | iterate_cells (const std::function< void(const ParticleList &)> &search_cell_callback, const std::function< void(const ParticleList &, const ParticleList &)> &neighbor_cell_callback) const |
Specialization of iterate_cells. More... | |
template<> | |
void | iterate_cells (const std::function< void(const ParticleList &)> &search_cell_callback, const std::function< void(const ParticleList &, const ParticleList &)> &neighbor_cell_callback) const |
Specialization of iterate_cells. More... | |
Private Member Functions | |
SizeType | make_index (SizeType x, SizeType y, SizeType z) const |
SizeType | make_index (std::array< SizeType, 3 > idx) const |
Private Attributes | |
const std::array< double, 3 > | length_ |
The 3 lengths of the complete grid. Used for periodic boundary wrapping. More... | |
std::array< int, 3 > | number_of_cells_ |
The number of cells in x, y, and z direction. More... | |
std::vector< ParticleList > | cells_ |
The cell storage. More... | |
Additional Inherited Members | |
![]() | |
typedef int | SizeType |
A type to store the sizes. More... | |
![]() | |
static std::pair< std::array< double, 3 >, std::array< double, 3 > > | find_min_and_length (const Particles &particles) |
|
inline |
Constructs a grid from the given particle list particles
.
It automatically determines the necessary size for the grid from the positions of the particles.
[in] | particles | The particles to place onto the grid. |
[in] | min_cell_length | The minimal length a cell must have. |
[in] | strategy | The strategy for determining the cell size |
Definition at line 90 of file grid.h.
template smash::Grid< Options >::Grid | ( | const std::pair< std::array< double, 3 >, std::array< double, 3 >> & | min_and_length, |
const Particles & | particles, | ||
double | min_cell_length, | ||
CellSizeStrategy | strategy = CellSizeStrategy::Optimal |
||
) |
Constructs a grid with the given minimum grid coordinates and grid length.
If you need periodic boundaries you have to use this constructor to set the correct length to use for wrapping particles around the borders.
[in] | min_and_length | A pair consisting of the three min coordinates and the three lengths. |
[in] | particles | The particles to place onto the grid. |
[in] | min_cell_length | The minimal length a cell must have. |
[in] | strategy | The strategy for determining the cell size |
Definition at line 100 of file grid.cc.
void smash::Grid< Options >::iterate_cells | ( | const std::function< void(const ParticleList &)> & | search_cell_callback, |
const std::function< void(const ParticleList &, const ParticleList &)> & | neighbor_cell_callback | ||
) | const |
Iterates over all cells in the grid and calls the callback arguments with a search cell and 0 to 13 neighbor cells.
The neighbor cells are constructed like this:
[in] | search_cell_callback | A callable called for/with every non-empty cell in the grid. |
[in] | neighbor_cell_callback | A callable called for/with every non-empty cell and adjacent cell combination. For a periodic grid, the first argument will be adjusted to wrap around the grid. |
|
inlineprivate |
x
, y
, z
. Definition at line 244 of file grid.cc.
|
inlineprivate |
idx
. This is a convenience overload for the above function. Definition at line 143 of file grid.h.
void smash::Grid< GridOptions::Normal >::iterate_cells | ( | const std::function< void(const ParticleList &)> & | search_cell_callback, |
const std::function< void(const ParticleList &, const ParticleList &)> & | neighbor_cell_callback | ||
) | const |
Specialization of iterate_cells.
Definition at line 251 of file grid.cc.
void smash::Grid< GridOptions::PeriodicBoundaries >::iterate_cells | ( | const std::function< void(const ParticleList &)> & | search_cell_callback, |
const std::function< void(const ParticleList &, const ParticleList &)> & | neighbor_cell_callback | ||
) | const |
Specialization of iterate_cells.
Definition at line 321 of file grid.cc.
|
private |
|
private |
|
private |