Web Analytics Made Easy - Statcounter
Skip to content

Class SBSNeighborSearchParticleSystemGridPBC#

ClassList > SBSNeighborSearchParticleSystemGridPBC

This class describes a grid-based neighbor search algorithm that can be applied to particle systems with periodic boundary conditions (PBC). More...

  • #include <SBSNeighborSearchParticleSystemGridPBC.hpp>

Inherits the following classes: SBSNeighborSearchParticleSystemPBC

Public Functions#

Type Name
SBSNeighborSearchParticleSystemGridPBC (SBParticleSystem * particleSystem, const SBQuantity::length & cutoffDistance)
Constructs a neighbor search particle system grid with PBC for the given particle system and the given cutoff radius.
virtual void getNeighbors (SBVector< SBAtom * > & neighborVector, const SBPosition3 & position, const SBQuantity::length & radius) override const
Appends to neighborVector all atoms that are at a distance smaller than or equal toradius from the specifiedposition .
virtual void getNeighbors (SBVector< SBAtom * > & neighborVector, const SBIAPosition3 & box) override const
Appends to neighborVector all atoms inside thebox .
virtual void initializeNeighborLists () override
Initializes the neighbor lists.
void onDynamicalEvent (SBDynamicalEvent * dynamicalEvent)
Handles dynamical model events.
virtual void print (unsigned int offset=0) override const
Prints debugging information.
virtual void updateNeighborLists () override
Updates the neighbor lists.
virtual ~SBSNeighborSearchParticleSystemGridPBC ()
Destructor.

Public Functions inherited from SBSNeighborSearchParticleSystemPBC#

See SBSNeighborSearchParticleSystemPBC

Type Name
SBVector< SBAtom * > * getNeighborVector (unsigned int i)
Returns the neighbor list for the i-th particle.
virtual void getNeighbors (SBVector< SBAtom * > & neighborVector, const SBPosition3 & position, const SBQuantity::length & radius) const
Appends to neighborVector all atoms that are at a distance smaller than or equal toradius from the specifiedposition .
virtual void getNeighbors (SBVector< SBAtom * > & neighborVector, const SBIAPosition3 & box) const
Appends to neighborVector all atoms inside thebox .
virtual void initializeNeighborLists ()
Initializes the neighbor lists.
void onDynamicalEvent (SBDynamicalEvent * dynamicalEvent)
Handles dynamical model events.
virtual void print (unsigned int offset=0) override const
Prints debugging information.
virtual void updateNeighborLists ()
Updates the neighbor lists.
virtual ~SBSNeighborSearchParticleSystemPBC ()
Destructor.

Public Functions inherited from SBSNeighborSearch#

See SBSNeighborSearch

Type Name
virtual void print (unsigned int offset=0) const
Prints debugging information.
virtual ~SBSNeighborSearch ()
Destructor.

Public Functions inherited from SBCReferenceTarget#

See SBCReferenceTarget

Type Name
SBCReferenceTarget ()
Builds the reference target.
unsigned int getMemoryFootprint () const
Returns the memory footprint.
void printReferencesToOwners () const
Prints the references to the owners of this reference target.
virtual ~SBCReferenceTarget ()
Destructor.

Protected Attributes#

Type Name
SBPointerIndexer< SBAtom > const * atomIndexer
SBQuantity::length * cutoffDistance
The cutoff distance.
SBHashMap< GridKey, GridCell *, GridKeyFunctor, GridKeyComparator > * grid
SBVector< GridKey > * gridKeyVector

Protected Attributes inherited from SBSNeighborSearchParticleSystemPBC#

See SBSNeighborSearchParticleSystemPBC

Type Name
SBIAPosition3 * boxPBC
The box's periodic boundary conditions bounds.
SBQuantity::length * boxSizeX
The box's size in x-direction.
SBQuantity::length * boxSizeY
The box's size in y-direction.
SBQuantity::length * boxSizeZ
The box's size in z-direction.
SBQuantity::squareLength * cutoffDistanceSquared
The squared cutoff distance.
SBQuantity::inverseLength * inverseCutoffDistance
The inverse cutoff distance.
SBBuffer< SBVector< SBAtom * > * > * neighborVectorBuffer
The buffer containing the neighbor lists associated to each atom.
SBPointer< SBParticleSystem > * particleSystem
The particle system the neighbor search algorithm is attached to.

Protected Attributes inherited from SBCReferenceTarget#

See SBCReferenceTarget

Type Name
SBCReferenceTargetData * dataPointer
A pointer to the private data.

Protected Functions#

Type Name
SBSNeighborSearchParticleSystemGridPBC (SBParticleSystem * p, const SBQuantity::length & cutoffDistance, SBSNeighborSearchParticleSystemGridPBCData * dataPointer)
Protected constructor.
bool cellCrossesTheBox (GridKey & gridKey)
Determines whether a grid cell lies completely inside the periodic box.
void checkCell (GridCell * gridCellJ, int i, std::set< unsigned int > & neighbors)
Checks a neighboring grid cell for potential neighbors of a given atom.
void checkCellsAroundBigBox (GridKey & gridKeyI, int i)
Checks neighboring cells around a given cell for the large-box case.
void checkCellsAroundCellByCell ()
Checks each grid cell against neighboring cells and mirror cells to identify cross-cell interactions.
void checkCellsAroundSmallBox (GridKey & gridKeyI, int i)
Checks neighboring cells around a given cell for the small-box case.
void checkCellsCross (GridCell * gridCellI, GridCell * gridCellJ)
Checks pairs of atoms from two grid cells that may be neighbors across periodic boundaries.
void getCellCoordinates (SBPosition3 const & position, SBVector3 & coordinates)
Computes the integer grid cell coordinates for a given particle position.
void getMirrorCellKey (GridKey & gridKey, GridKey & gridKeyMirror)
Computes the mirror cell key for a grid cell that lies outside the box.
bool isInTheBox (SBPosition3 const & position)
Determines whether a position lies inside the periodic boundary condition box.
void updateLists ()
Updates neighbor lists based on the current atom positions.

Protected Functions inherited from SBSNeighborSearchParticleSystemPBC#

See SBSNeighborSearchParticleSystemPBC

Type Name
SBSNeighborSearchParticleSystemPBC (SBParticleSystem * particleSystem, const SBQuantity::length & cutoffDistance)
Protected constructor.
SBSNeighborSearchParticleSystemPBC (SBParticleSystem * particleSystem, const SBQuantity::length & cutoffDistance, SBSNeighborSearchParticleSystemPBCData * dataPointer)
Protected constructor.

Protected Functions inherited from SBSNeighborSearch#

See SBSNeighborSearch

Type Name
SBSNeighborSearch ()
Protected constructor.
SBSNeighborSearch (SBSNeighborSearchData * dataPointer)
Protected constructor.

Protected Functions inherited from SBCReferenceTarget#

See SBCReferenceTarget

Type Name
SBCReferenceTarget (SBCReferenceTargetData * dataPointer)
Protected constructor.
void removeAllReferenceOwners ()
Stops all the reference owners from referencing this reference target.

Detailed Description#

Short name: SBNeighborSearchParticleSystemGridPBC

Public Functions Documentation#

function SBSNeighborSearchParticleSystemGridPBC [2/2]#

Constructs a neighbor search particle system grid with PBC for the given particle system and the given cutoff radius.

SBSNeighborSearchParticleSystemGridPBC::SBSNeighborSearchParticleSystemGridPBC (
    SBParticleSystem * particleSystem,
    const SBQuantity::length & cutoffDistance
) 

Constructs a neighbor search grid for a particle system with periodic boundary conditions.

Parameters:

  • p Pointer to the particle system.
  • c Cutoff distance for neighbor searching.

function getNeighbors [1/2]#

Appends to neighborVector all atoms that are at a distance smaller than or equal toradius from the specifiedposition .

virtual void SBSNeighborSearchParticleSystemGridPBC::getNeighbors (
    SBVector< SBAtom * > & neighborVector,
    const SBPosition3 & position,
    const SBQuantity::length & radius
) override const

Retrieves atoms within a spherical region around a given position.

All atoms whose distance from position is less than or equal to radius are appended to neighborVector.

Parameters:

  • neighborVector Output vector that will contain the neighboring atoms.
  • position Center of the spherical search region.
  • radius Search radius.

Implements SBSNeighborSearchParticleSystemPBC::getNeighbors


function getNeighbors [2/2]#

Appends to neighborVector all atoms inside thebox .

virtual void SBSNeighborSearchParticleSystemGridPBC::getNeighbors (
    SBVector< SBAtom * > & neighborVector,
    const SBIAPosition3 & box
) override const

Retrieves atoms inside a specified axis-aligned box.

All atoms whose positions lie within box are appended to neighborVector.

Parameters:

  • neighborVector Output vector that will contain the neighboring atoms.
  • box Axis-aligned box defining the search region.

Implements SBSNeighborSearchParticleSystemPBC::getNeighbors


function initializeNeighborLists#

Initializes the neighbor lists.

virtual void SBSNeighborSearchParticleSystemGridPBC::initializeNeighborLists () override

Initializes neighbor lists for all atoms in the particle system.

Implements SBSNeighborSearchParticleSystemPBC::initializeNeighborLists


function onDynamicalEvent#

Handles dynamical model events.

void SBSNeighborSearchParticleSystemGridPBC::onDynamicalEvent (
    SBDynamicalEvent * dynamicalEvent
) 

Handles a dynamical model event.

This method processes the provided event to update internal state as needed.

Parameters:

  • event The dynamical event to be handled.

function print#

Prints debugging information.

virtual void SBSNeighborSearchParticleSystemGridPBC::print (
    unsigned int offset=0
) override const

Prints debugging information about neighbor relationships and grid cells.

The output includes the list of neighbor pairs, the number of grid cells, and the total number of neighbor pairs. The offset parameter can be used to indent the output.

Parameters:

  • offset Number of spaces to indent each line of output.

Implements SBSNeighborSearchParticleSystemPBC::print


function updateNeighborLists#

Updates the neighbor lists.

virtual void SBSNeighborSearchParticleSystemGridPBC::updateNeighborLists () override

Updates neighbor lists after atoms have changed positions and updates the grid cells.

This function removes outdated neighbor entries for atoms whose positions have changed, updates the grid cell assignment for those atoms, and recomputes the neighbor relationships for the entire system.

Implements SBSNeighborSearchParticleSystemPBC::updateNeighborLists


function ~SBSNeighborSearchParticleSystemGridPBC#

Destructor.

virtual SBSNeighborSearchParticleSystemGridPBC::~SBSNeighborSearchParticleSystemGridPBC () 

Destroys the neighbor search grid and releases allocated resources.


Protected Attributes Documentation#

variable atomIndexer#

SBPointerIndexer<SBAtom> const* SBSNeighborSearchParticleSystemGridPBC::atomIndexer;

variable cutoffDistance#

The cutoff distance.

SBQuantity::length* SBSNeighborSearchParticleSystemGridPBC::cutoffDistance;


variable grid#

SBHashMap<GridKey, GridCell*, GridKeyFunctor, GridKeyComparator>* SBSNeighborSearchParticleSystemGridPBC::grid;

variable gridKeyVector#

SBVector<GridKey>* SBSNeighborSearchParticleSystemGridPBC::gridKeyVector;

Protected Functions Documentation#

function SBSNeighborSearchParticleSystemGridPBC [1/2]#

Protected constructor.

SBSNeighborSearchParticleSystemGridPBC::SBSNeighborSearchParticleSystemGridPBC (
    SBParticleSystem * p,
    const SBQuantity::length & cutoffDistance,
    SBSNeighborSearchParticleSystemGridPBCData * dataPointer
) 

Constructs a neighbor search grid for a particle system with periodic boundary conditions, using a preallocated data object.

Parameters:

  • p Pointer to the particle system.
  • c Cutoff distance for neighbor searching.
  • dataPointer Pointer to the internal data structure.

function cellCrossesTheBox#

Determines whether a grid cell lies completely inside the periodic box.

bool SBSNeighborSearchParticleSystemGridPBC::cellCrossesTheBox (
    GridKey & gridKey
) 

The function checks if the cell identified by gridKey does not cross any boundary of the simulation box.

Parameters:

  • gridKey Coordinates of the grid cell to test.

Returns:

true if the cell is fully inside the box; otherwise false.


function checkCell#

Checks a neighboring grid cell for potential neighbors of a given atom.

void SBSNeighborSearchParticleSystemGridPBC::checkCell (
    GridCell * gridCellJ,
    int i,
    std::set< unsigned int > & neighbors
) 

Parameters:

  • gridCellJ Pointer to the neighboring grid cell to be examined.
  • i Index of the atom for which neighbors are being sought.
  • neighbors Reference to a set of atom indices that have already been visited.

function checkCellsAroundBigBox#

Checks neighboring cells around a given cell for the large-box case.

void SBSNeighborSearchParticleSystemGridPBC::checkCellsAroundBigBox (
    GridKey & gridKeyI,
    int i
) 

The method iterates over adjacent cells of gridKeyI, including mirror cells when necessary, and updates the neighbor set for atom i.

Parameters:

  • gridKeyI Grid cell of the reference atom.
  • i Index of the reference atom.

function checkCellsAroundCellByCell#

Checks each grid cell against neighboring cells and mirror cells to identify cross-cell interactions.

void SBSNeighborSearchParticleSystemGridPBC::checkCellsAroundCellByCell () 

This method iterates over all grid cells in the internal hash map, examines each cell and its neighboring cells (including periodic image cells) to determine which pairs of cells may contain atoms that are within the cutoff distance. For each relevant pair, it invokes checkCellsCross to process potential neighbor relationships.


function checkCellsAroundSmallBox#

Checks neighboring cells around a given cell for the small-box case.

void SBSNeighborSearchParticleSystemGridPBC::checkCellsAroundSmallBox (
    GridKey & gridKeyI,
    int i
) 

The method iterates over adjacent cells of gridKeyI and updates the neighbor set for atom i based on atoms found in those cells.

Parameters:

  • gridKeyI Grid cell of the reference atom.
  • i Index of the reference atom.

function checkCellsCross#

Checks pairs of atoms from two grid cells that may be neighbors across periodic boundaries.

void SBSNeighborSearchParticleSystemGridPBC::checkCellsCross (
    GridCell * gridCellI,
    GridCell * gridCellJ
) 

Parameters:

  • gridCellI Pointer to the first grid cell.
  • gridCellJ Pointer to the second grid cell.

function getCellCoordinates#

Computes the integer grid cell coordinates for a given particle position.

void SBSNeighborSearchParticleSystemGridPBC::getCellCoordinates (
    SBPosition3 const & position,
    SBVector3 & coordinates
) 

Parameters:

  • currentPosition Reference to the particle's position.
  • coordinates Reference to a vector that will receive the computed coordinates.

function getMirrorCellKey#

Computes the mirror cell key for a grid cell that lies outside the box.

void SBSNeighborSearchParticleSystemGridPBC::getMirrorCellKey (
    GridKey & gridKey,
    GridKey & gridKeyMirror
) 

For a cell that crosses the periodic boundary, this method determines the corresponding cell inside the box that mirrors the original cell.

Parameters:

  • gridKey Input grid cell coordinates.
  • gridKeyMirror Output mirror cell coordinates.

function isInTheBox#

Determines whether a position lies inside the periodic boundary condition box.

bool SBSNeighborSearchParticleSystemGridPBC::isInTheBox (
    SBPosition3 const & position
) 

Parameters:

  • position Reference to the position to test.

Returns:

true if the position is inside the box, false otherwise.


function updateLists#

Updates neighbor lists based on the current atom positions.

void SBSNeighborSearchParticleSystemGridPBC::updateLists () 

Note: this function does not appear to work at the moment. Please rebuild a grid at each step.