Web Analytics Made Easy - Statcounter
Skip to content

Class SBSNeighborSearchParticleSystemGrid#

ClassList > SBSNeighborSearchParticleSystemGrid

This class describes a grid-based neighbor search algorithm that can be applied to particle systems. More...

  • #include <SBSNeighborSearchParticleSystemGrid.hpp>

Inherits the following classes: SBSNeighborSearchParticleSystem

Public Functions#

Type Name
SBSNeighborSearchParticleSystemGrid (SBParticleSystem * particleSystem, const SBQuantity::length & cutoffDistance)
Constructs a neighbor search particle system grid for the given particle system and the given cutoff radius.
virtual bool areNeighbors (unsigned int i, unsigned int j) override const
Returns whether atoms with indices i andj are neighbors.
virtual bool areNeighbors (SBAtom * atomI, SBAtom * atomJ) override const
Returns whether atoms atomI andatomJ are neighbors.
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 .
bool getParallelizationEnabled () const
Returns whether the parallelization is enabled. By default, it is enabled and will be used if some criteria (e.g. the minimum number of atoms) are met.
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.
void setParallelizationEnabled (bool enabled)
Sets whether the parallelization is enabled. If set to true then the parallel implementation will be used if some criteria (e.g. the minimum number of atoms) are met, else the serial implementation will be used.
virtual void updateNeighborLists () override
Updates the neighbor lists.
virtual ~SBSNeighborSearchParticleSystemGrid ()
Destructor.

Public Functions inherited from SBSNeighborSearchParticleSystem#

See SBSNeighborSearchParticleSystem

Type Name
virtual bool areNeighbors (unsigned int i, unsigned int j) const
Returns whether atoms with indices i andj are neighbors.
virtual bool areNeighbors (SBAtom * atomI, SBAtom * atomJ) const
Returns whether atoms atomI andatomJ are neighbors.
SBVector< SBAtom * > const * 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 ~SBSNeighborSearchParticleSystem ()
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
SBHashMap< GridKey, GridCell *, GridKeyFunctor, GridKeyComparator > * grid
SBVector< GridKey > * gridKeyVector
SBHashMap< std::pair< unsigned int, unsigned int >, bool > * neighborMap
Hashmap which caches whether two atoms are neighbors.

Protected Attributes inherited from SBSNeighborSearchParticleSystem#

See SBSNeighborSearchParticleSystem

Type Name
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
SBSNeighborSearchParticleSystemGrid (SBParticleSystem * particleSystem, const SBQuantity::length & cutoffDistance, SBSNeighborSearchParticleSystemGridData * dataPointer)
Protected constructor.

Protected Functions inherited from SBSNeighborSearchParticleSystem#

See SBSNeighborSearchParticleSystem

Type Name
SBSNeighborSearchParticleSystem (SBParticleSystem * particleSystem, const SBQuantity::length & cutoffDistance)
Protected constructor.
SBSNeighborSearchParticleSystem (SBParticleSystem * particleSystem, const SBQuantity::length & cutoffDistance, SBSNeighborSearchParticleSystemData * 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: SBNeighborSearchParticleSystemGrid

Public Functions Documentation#

function SBSNeighborSearchParticleSystemGrid [2/2]#

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

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

Constructs a neighbor search particle system grid for the given particle system and cutoff distance.

Parameters:

  • p Pointer to the particle system.
  • c Cutoff distance.

function areNeighbors [1/2]#

Returns whether atoms with indices i andj are neighbors.

virtual bool SBSNeighborSearchParticleSystemGrid::areNeighbors (
    unsigned int i,
    unsigned int j
) override const

Parameters:

  • i Index of the first atom.
  • j Index of the second atom.

Returns:

true if the atoms are neighbors, false otherwise.

Implements SBSNeighborSearchParticleSystem::areNeighbors


function areNeighbors [2/2]#

Returns whether atoms atomI andatomJ are neighbors.

virtual bool SBSNeighborSearchParticleSystemGrid::areNeighbors (
    SBAtom * atomI,
    SBAtom * atomJ
) override const

Parameters:

  • atomI Pointer to the first atom.
  • atomJ Pointer to the second atom.

Returns:

true if the atoms are neighbors, false otherwise.

Implements SBSNeighborSearchParticleSystem::areNeighbors


function getNeighbors [1/2]#

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

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

Appends to neighborVector all atoms within a given radius around position.

Parameters:

  • neighborVector Vector to which neighbor atoms are appended.
  • position Center position for the neighbor search.
  • radius Search radius.

Implements SBSNeighborSearchParticleSystem::getNeighbors


function getNeighbors [2/2]#

Appends to neighborVector all atoms inside thebox .

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

Appends to neighborVector all atoms inside the specified box.

Parameters:

  • neighborVector Vector to which neighbor atoms are appended.
  • box Axis-aligned box defining the region of interest.

Implements SBSNeighborSearchParticleSystem::getNeighbors


function getParallelizationEnabled#

Returns whether the parallelization is enabled. By default, it is enabled and will be used if some criteria (e.g. the minimum number of atoms) are met.

bool SBSNeighborSearchParticleSystemGrid::getParallelizationEnabled () const

Returns whether parallelization is enabled for neighbor list calculations.

Returns:

true if parallelization is enabled; otherwise false.


function initializeNeighborLists#

Initializes the neighbor lists.

virtual void SBSNeighborSearchParticleSystemGrid::initializeNeighborLists () override

Initializes neighbor lists for all atoms based on the current particle positions.

This method clears any existing neighbor data and populates neighbor lists and the neighbor map by examining atoms within neighboring grid cells and within the cutoff distance.

Implements SBSNeighborSearchParticleSystem::initializeNeighborLists


function onDynamicalEvent#

Handles dynamical model events.

void SBSNeighborSearchParticleSystemGrid::onDynamicalEvent (
    SBDynamicalEvent * dynamicalEvent
) 

Handles a dynamical event for the particle system.

Parameters:

  • dynamicalEvent Pointer to the dynamic event.

function print#

Prints debugging information.

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

Prints debugging information for the neighbor search grid.

Parameters:

  • offset Optional indentation offset for the output.

Implements SBSNeighborSearchParticleSystem::print


function setParallelizationEnabled#

Sets whether the parallelization is enabled. If set to true then the parallel implementation will be used if some criteria (e.g. the minimum number of atoms) are met, else the serial implementation will be used.

void SBSNeighborSearchParticleSystemGrid::setParallelizationEnabled (
    bool enabled
) 

Sets the parallelization flag for neighbor list calculations.

Parameters:

  • enabled True to enable parallelization; false to disable it.

function updateNeighborLists#

Updates the neighbor lists.

virtual void SBSNeighborSearchParticleSystemGrid::updateNeighborLists () override

Updates the neighbor lists for the particle system.

This method updates the neighbor lists by pruning outdated neighbor relationships, updating the grid based on atom position changes, and detecting new neighbor relationships. The update may be performed using either a serial or a parallel implementation depending on the configuration and system size.

Implements SBSNeighborSearchParticleSystem::updateNeighborLists


function ~SBSNeighborSearchParticleSystemGrid#

Destructor.

virtual SBSNeighborSearchParticleSystemGrid::~SBSNeighborSearchParticleSystemGrid () 

Destroys the neighbor search particle system grid and releases allocated resources.


Protected Attributes Documentation#

variable grid#

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

variable gridKeyVector#

SBVector<GridKey>* SBSNeighborSearchParticleSystemGrid::gridKeyVector;

variable neighborMap#

Hashmap which caches whether two atoms are neighbors.

SBHashMap<std::pair<unsigned int, unsigned int>, bool>* SBSNeighborSearchParticleSystemGrid::neighborMap;


Protected Functions Documentation#

function SBSNeighborSearchParticleSystemGrid [1/2]#

Protected constructor.

SBSNeighborSearchParticleSystemGrid::SBSNeighborSearchParticleSystemGrid (
    SBParticleSystem * particleSystem,
    const SBQuantity::length & cutoffDistance,
    SBSNeighborSearchParticleSystemGridData * dataPointer
) 

Constructs a neighbor search particle system grid with a specific data pointer.

Parameters:

  • p Pointer to the particle system.
  • c Cutoff distance.
  • dataPointer Pointer to the data structure used by the grid.