Loading...
Searching...
No Matches
NeighborList Class Reference

"Half" neighbor lists for atoms. More...

#include <NeighborList.h>

Public Member Functions

 NeighborList (Atoms *a, double rCut, double driftfactor=0.05, int defaultNeighborEstimate=50)
 Generate a neighbor list for atoms a with cutoff rCut.
 ~NeighborList ()
bool CheckAndUpdateNeighborList ()
 Check if the neighbor list can still be reused, update if not.
int GetNeighbors (int n, int *neighbors, Vec *diffs, double *diffs2, int &size, double r=-1.0) const
 Get all neighbors of atom n. The most important method :-).
void UpdateSuperCell (const SuperCell *superCell)
 Inform the neighbor list that the supercell has changed.
const int * GetList (int a, int &n)
 Low-level interface to the neighbor list.
const ImageGetImage (int i)
 Get the real atom corresponding to an image.
int MaxNeighborListLength () const
 Return the guaranteed maximal length of a single atom's NB list.
int GetNumberOfAtoms () const
 Get the number of atoms in the corresponding list of atoms.

Private Member Functions

void MakeList ()
 Generate a new neighbor list.
void UpdateImagePositions ()
 Update the positions of the images when the real atoms may have moved.
void Allocate ()
 (Re)allocate the memory for the neighbor list.

Private Attributes

Atomsatoms
 A pointer to the atoms.
int nAtoms
 The number of atoms.
int nSize
 Number of atoms including ghost atoms.
double rCut2
 The square of the cutoff radius.
double drift2
 The square of the maximally allowed drift of an atom.
double rMax
 Cutoff when generating neighbor list.
Vecpositions
 A pointer into the positions array of the atoms.
vector< VecreferencePositions
 The positions at the last update.
vector< Imageimages
 The images of neighbors through PBC.
int * neighborList
 The actual neighbor list.
int nMax
 The size of the neighborList array.
int * indices
 Offsets into neighborList giving each atom's neighbors.
int maxlistlen
 The length of the longest neighbor list of an atom.

Detailed Description

"Half" neighbor lists for atoms.

This implements a "half neighbor list", i.e. if atom a is on atom b's neighbor list, atom b will NOT be on atom a's neighbor list.

GetNeighbors(...) returns "half" of the neighbors inside a sphere of radius rCut. CheckAndUpdateNeighborLists() must be called every time the positions change. If an atom has moved more than "drift", CheckAndUpdateNeighborLists() will call MakeList(), and a new list is generated.

Definition at line 24 of file NeighborList.h.

Constructor & Destructor Documentation

◆ NeighborList()

NeighborList::NeighborList ( Atoms * a,
double rCut,
double driftfactor = 0.05,
int defaultNeighborEstimate = 50 )

Generate a neighbor list for atoms a with cutoff rCut.

The neighbor list will contain all neighbors within the distance rCut. The neighborlist can be reused until an atom has moved more than rCut*driftfactor.

◆ ~NeighborList()

NeighborList::~NeighborList ( )

Member Function Documentation

◆ Allocate()

void NeighborList::Allocate ( )
private

(Re)allocate the memory for the neighbor list.

◆ CheckAndUpdateNeighborList()

bool NeighborList::CheckAndUpdateNeighborList ( )

Check if the neighbor list can still be reused, update if not.

◆ GetImage()

const Image & NeighborList::GetImage ( int i)
inline

Get the real atom corresponding to an image.

The input argument i is the number of the image counted from the first image. It is thus the number returned by GetList minus the number of atoms. The return value is a const reference to an Image.

Definition at line 77 of file NeighborList.h.

77{ return images[i]; }
vector< Image > images
The images of neighbors through PBC.

◆ GetList()

const int * NeighborList::GetList ( int a,
int & n )

Low-level interface to the neighbor list.

Returns a const pointer to the internal list of neighbors of atom a, the length of the list is placed in n. The list will contain all neighbors within the cutoff radius, and some neighbors outside the cutoff. Some neighbors will be image atoms instead of real atoms (if they are neighbors thanks to the periodic boundaries), use GetImage to get the number of the real atom.

◆ GetNeighbors()

int NeighborList::GetNeighbors ( int n,
int * neighbors,
Vec * diffs,
double * diffs2,
int & size,
double r = -1.0 ) const

Get all neighbors of atom n. The most important method :-).

Input values: n is the number of the atom. r (optional) is a cutoff, must be less than rCut in the constructor (not checked!).

In-out values: size contains the maximum space in the arrays. It is decremented by the number of neighbors placed in the arrays. It is an error to call GetNeighbors with too small a value of size.

Out values: neighbors[] contains the numbers of the atoms, diffs[] contains the relative positions of the atoms, diffs2[] contains the norms of the diffs vectors.

Return value: The number of neighbors.

◆ GetNumberOfAtoms()

int NeighborList::GetNumberOfAtoms ( ) const
inline

Get the number of atoms in the corresponding list of atoms.

Definition at line 87 of file NeighborList.h.

87{ return nAtoms; } // Used from swig.
int nAtoms
The number of atoms.

◆ MakeList()

void NeighborList::MakeList ( )
private

Generate a new neighbor list.

◆ MaxNeighborListLength()

int NeighborList::MaxNeighborListLength ( ) const
inline

Return the guaranteed maximal length of a single atom's NB list.

Call this before using GetNeighbors() to make sure the arrays are big enough. The value may change when the neighbor list is updated.

Definition at line 84 of file NeighborList.h.

84{ return maxlistlen; }
int maxlistlen
The length of the longest neighbor list of an atom.

◆ UpdateImagePositions()

void NeighborList::UpdateImagePositions ( )
private

Update the positions of the images when the real atoms may have moved.

◆ UpdateSuperCell()

void NeighborList::UpdateSuperCell ( const SuperCell * superCell)

Inform the neighbor list that the supercell has changed.

Member Data Documentation

◆ atoms

Atoms* NeighborList::atoms
private

A pointer to the atoms.

Definition at line 97 of file NeighborList.h.

◆ drift2

double NeighborList::drift2
private

The square of the maximally allowed drift of an atom.

Definition at line 101 of file NeighborList.h.

◆ images

vector<Image> NeighborList::images
private

The images of neighbors through PBC.

Definition at line 105 of file NeighborList.h.

◆ indices

int* NeighborList::indices
private

Offsets into neighborList giving each atom's neighbors.

Definition at line 108 of file NeighborList.h.

◆ maxlistlen

int NeighborList::maxlistlen
private

The length of the longest neighbor list of an atom.

Definition at line 109 of file NeighborList.h.

◆ nAtoms

int NeighborList::nAtoms
private

The number of atoms.

Definition at line 98 of file NeighborList.h.

◆ neighborList

int* NeighborList::neighborList
private

The actual neighbor list.

Definition at line 106 of file NeighborList.h.

◆ nMax

int NeighborList::nMax
private

The size of the neighborList array.

Definition at line 107 of file NeighborList.h.

◆ nSize

int NeighborList::nSize
private

Number of atoms including ghost atoms.

Definition at line 99 of file NeighborList.h.

◆ positions

Vec* NeighborList::positions
private

A pointer into the positions array of the atoms.

Definition at line 103 of file NeighborList.h.

◆ rCut2

double NeighborList::rCut2
private

The square of the cutoff radius.

Definition at line 100 of file NeighborList.h.

◆ referencePositions

vector<Vec> NeighborList::referencePositions
private

The positions at the last update.

Definition at line 104 of file NeighborList.h.

◆ rMax

double NeighborList::rMax
private

Cutoff when generating neighbor list.

Definition at line 102 of file NeighborList.h.


The documentation for this class was generated from the following file:
  • /home/runner/work/eOn/eOn/include/eon/potentials/EMT/Asap/NeighborList.h