"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 Image & | GetImage (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 | |
| Atoms * | atoms |
| 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. | |
| Vec * | positions |
| A pointer into the positions array of the atoms. | |
| vector< Vec > | referencePositions |
| The positions at the last update. | |
| vector< Image > | images |
| 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. | |
"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.
| 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 | ( | ) |
|
private |
(Re)allocate the memory for the neighbor list.
| bool NeighborList::CheckAndUpdateNeighborList | ( | ) |
Check if the neighbor list can still be reused, update if not.
|
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.
| 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.
| 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.
|
inline |
Get the number of atoms in the corresponding list of atoms.
Definition at line 87 of file NeighborList.h.
|
private |
Generate a new neighbor list.
|
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.
|
private |
Update the positions of the images when the real atoms may have moved.
| void NeighborList::UpdateSuperCell | ( | const SuperCell * | superCell | ) |
Inform the neighbor list that the supercell has changed.
|
private |
A pointer to the atoms.
Definition at line 97 of file NeighborList.h.
|
private |
The square of the maximally allowed drift of an atom.
Definition at line 101 of file NeighborList.h.
The images of neighbors through PBC.
Definition at line 105 of file NeighborList.h.
|
private |
Offsets into neighborList giving each atom's neighbors.
Definition at line 108 of file NeighborList.h.
|
private |
The length of the longest neighbor list of an atom.
Definition at line 109 of file NeighborList.h.
|
private |
The number of atoms.
Definition at line 98 of file NeighborList.h.
|
private |
The actual neighbor list.
Definition at line 106 of file NeighborList.h.
|
private |
The size of the neighborList array.
Definition at line 107 of file NeighborList.h.
|
private |
Number of atoms including ghost atoms.
Definition at line 99 of file NeighborList.h.
|
private |
A pointer into the positions array of the atoms.
Definition at line 103 of file NeighborList.h.
|
private |
The square of the cutoff radius.
Definition at line 100 of file NeighborList.h.
The positions at the last update.
Definition at line 104 of file NeighborList.h.
|
private |
Cutoff when generating neighbor list.
Definition at line 102 of file NeighborList.h.