hemocell
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
hemo::ParticleGrid Class Reference

Cell list that bins the particles of one atomic block onto its lattice nodes. More...

#include <particleGrid.h>

Public Member Functions

void build (const std::vector< HemoCellParticle > &particles, const plb::Dot3D &location, plint nx, plint ny, plint nz)
 (Re)build the grid.
 
unsigned int index (plint x, plint y, plint z) const
 Linear index of block-local node (x,y,z); the caller guarantees it is inside the grid.
 
const unsigned int * begin (unsigned int node) const
 First particle index of node node (see class description).
 
const unsigned int * end (unsigned int node) const
 One past the last particle index of node node.
 
unsigned int count (unsigned int node) const
 Number of particles binned in node node.
 
plint getNx () const
 
plint getNy () const
 
plint getNz () const
 

Private Attributes

plint nx = 0
 
plint ny = 0
 
plint nz = 0
 
std::vector< unsigned int > nodeStart
 nx*ny*nz+1 offsets into particleIndices
 
std::vector< unsigned int > particleIndices
 particle indices, grouped per node
 
std::vector< unsigned int > nodeOfParticle
 scratch: node of each particle (or sentinel)
 

Detailed Description

Cell list that bins the particles of one atomic block onto its lattice nodes.

Used for short-range neighbour searches (particle-particle repulsion, particle-wall repulsion, solidification). Each particle is assigned to the nearest node, nearestNode(position - location), per axis. Particles whose node falls outside [0,nx) x [0,ny) x [0,nz) are not binned.

Storage is compressed (CSR-like): nodeStart holds nx*ny*nz+1 offsets into particleIndices, so the particles of node n are particleIndices[nodeStart[n] .. nodeStart[n+1]). Unlike the previous fixed-capacity grid there is no limit on the number of particles per node, and no capacity checks are needed while filling it. Within a node, particle indices are stored in ascending order.

The stored indices refer to the particle vector passed to build(). Any insertion, removal or reordering of that vector, and any change of particle positions, invalidates the grid; the owner must rebuild it before use.

Not thread safe; one instance per atomic block.

Member Function Documentation

◆ begin()

const unsigned int * hemo::ParticleGrid::begin ( unsigned int  node) const
inline

First particle index of node node (see class description).

◆ build()

void hemo::ParticleGrid::build ( const std::vector< HemoCellParticle > &  particles,
const plb::Dot3D &  location,
plint  nx,
plint  ny,
plint  nz 
)

(Re)build the grid.

Parameters
[in]particlesParticles of the atomic block (absolute lattice coordinates).
[in]locationAbsolute lattice position of node (0,0,0) of the block.
[in]nx,ny,nzNumber of lattice nodes of the block along each axis.

Cost: O(nx*ny*nz + particles.size()). Buffers are reused between builds.

◆ count()

unsigned int hemo::ParticleGrid::count ( unsigned int  node) const
inline

Number of particles binned in node node.

◆ end()

const unsigned int * hemo::ParticleGrid::end ( unsigned int  node) const
inline

One past the last particle index of node node.

◆ getNx()

plint hemo::ParticleGrid::getNx ( ) const
inline

◆ getNy()

plint hemo::ParticleGrid::getNy ( ) const
inline

◆ getNz()

plint hemo::ParticleGrid::getNz ( ) const
inline

◆ index()

unsigned int hemo::ParticleGrid::index ( plint  x,
plint  y,
plint  z 
) const
inline

Linear index of block-local node (x,y,z); the caller guarantees it is inside the grid.

Member Data Documentation

◆ nodeOfParticle

std::vector<unsigned int> hemo::ParticleGrid::nodeOfParticle
private

scratch: node of each particle (or sentinel)

◆ nodeStart

std::vector<unsigned int> hemo::ParticleGrid::nodeStart
private

nx*ny*nz+1 offsets into particleIndices

◆ nx

plint hemo::ParticleGrid::nx = 0
private

◆ ny

plint hemo::ParticleGrid::ny = 0
private

◆ nz

plint hemo::ParticleGrid::nz = 0
private

◆ particleIndices

std::vector<unsigned int> hemo::ParticleGrid::particleIndices
private

particle indices, grouped per node