SimpleFastOpenAtomicVisualiser
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Neighbours Class Reference

Calculate neighbour lists. More...

#include <neighbours.h>

Public Member Functions

 Neighbours (const std::vector< Atom > &atoms, float domainSideLength=-1.0)
 Construct a Neighbour list from some Atoms.
 
void build (const std::vector< Atom > &atoms)
 Build the neighbour list from some Atoms.
 
void clear ()
 Reset the spatial domains.
 
std::vector< std::pair< uint64_t, float > > neighbours (const std::vector< Atom > &atoms, glm::vec3 position, float cutoff, bool noDirect=false, bool nearestImage=true) const
 Get the neighbours to a position within a cutoff using the spatial domains.
 
std::vector< std::pair< uint64_t, float > > neighboursDirect (const std::vector< Atom > &atoms, glm::vec3 position, float cutoff, bool nearestImage=true) const
 Get the neighbours to a position within a cutoff by a direct evaluation.
 

Detailed Description

Calculate neighbour lists.

Remarks
spatial hashing based upon a fixed grid.

Constructor & Destructor Documentation

◆ Neighbours()

Neighbours::Neighbours ( const std::vector< Atom > &  atoms,
float  domainSideLength = -1.0 
)
inline

Construct a Neighbour list from some Atoms.

Parameters
atomsthe Atoms to hash into spatial domains.

Member Function Documentation

◆ build()

void Neighbours::build ( const std::vector< Atom > &  atoms)
inline

Build the neighbour list from some Atoms.

Parameters
atomsthe Atoms to hash into spatial domains.

◆ clear()

void Neighbours::clear ( )
inline

Reset the spatial domains.

◆ neighbours()

std::vector< std::pair< uint64_t, float > > Neighbours::neighbours ( const std::vector< Atom > &  atoms,
glm::vec3  position,
float  cutoff,
bool  noDirect = false,
bool  nearestImage = true 
) const
inline

Get the neighbours to a position within a cutoff using the spatial domains.

Parameters
atomsthe Atoms passed to Neighbours::build.
positionthe position to find neighbours to.
cutoffthe spatial cutoff.
noDirectforce use of the spatial partitioning.
nearestImagewhether to use the nearest image convention.
Returns
std::vector<std::pair<uint64_t, float>> the indices of Atom neighbours to position and distances. In ascending distance order.
Remarks
The Atoms are passed as reference here and in Neighbours::build to avoid copying data. If different Atoms are passed in each distances will be wrong. If more Atoms are passed those with higher indices are ignored.
Atoms outside of bounds are ignored.
Unless noDirect is true. If the cutoff > the half-width of the spatial partitioning, a direct evaluation is performed.
Distance sorting ties are solved by atom index.

◆ neighboursDirect()

std::vector< std::pair< uint64_t, float > > Neighbours::neighboursDirect ( const std::vector< Atom > &  atoms,
glm::vec3  position,
float  cutoff,
bool  nearestImage = true 
) const
inline

Get the neighbours to a position within a cutoff by a direct evaluation.

Parameters
atomsthe Atoms passed to Neighbours::build.
positionthe position to find neighbours to.
cutoffthe spatial cutoff.
nearestImagewhether to use the nearest image convention.
Returns
std::vector<std::pair<uint64_t, float>> the indices of Atom neighbours to position and distances. In ascending distance order.
Remarks
A direct O(atoms.size()) comparision is performed.
Distance sorting ties are solved by atom index.

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