|
seams-core v2.14.0
libyodaLib, the C++ engine of d-SEAMS
|
Functions for building neighbour lists. More...
Classes | |
| class | CutoffSkin |
| In-situ cutoff list. More... | |
| class | SkinNeighborList |
| Persistent neighbour list with a LAMMPS skin. More... | |
Enumerations | |
| enum class | BondGraph { Cutoff , KnnMutual , KnnUnion } |
| Bond graph for TUM. More... | |
Functions | |
| void | dumpBoundsToH (const std::vector< double > &box, const std::vector< double > &boxLow, double H[3][3], double origin[3]) |
| LAMMPS dump bound spans to restricted triclinic H (rows a, b, c). | |
| void | dumpCellLengths (const std::vector< double > &box, const std::vector< double > &boxLow, double lengths[3]) |
| Recovered restricted-triclinic lengths lx, ly, lz (H diagonal). | |
| int | dumpAxialDim (const std::vector< double > &box, const std::vector< double > &boxLow) |
| Longest recovered length: 0 = x, 1 = y, 2 = z. | |
| int | dumpAxialDim (const molSys::PointCloud< molSys::Point< double >, double > &yCloud) |
| void | dumpToFrac (const double H[3][3], const double origin[3], double x, double y, double z, double s[3]) |
| Cartesian to fractional coordinates via dump H. | |
| void | dumpFromFrac (const double H[3][3], const double origin[3], const double s[3], double r[3]) |
| Fractional to cartesian coordinates via dump H. | |
| double | dumpVolume (const std::vector< double > &box, const std::vector< double > &boxLow) |
| Triclinic dump-cell volume, the absolute value of det(H), from dumpBoundsToH. | |
| double | dumpVolume (const molSys::PointCloud< molSys::Point< double >, double > &yCloud) |
| bool | setBoxFromLammpsEdges (std::vector< double > &box, std::vector< double > &boxLow, double xlo, double ylo, double zlo, double lx, double ly, double lz, double xy, double xz, double yz) |
| LAMMPS edge origin and edge lengths, plus tilt, as a dump box. | |
| bool | setBoxFromLengthsAngles (std::vector< double > &box, std::vector< double > &boxLow, double a, double b, double c, double alphaDeg, double betaDeg, double gammaDeg) |
| Crystallographic lengths and angles in degrees, stored as a dump box. | |
| std::vector< std::vector< int > > | neighList (double rcutoff, const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int typeI, int typeJ) |
| All these functions use atom IDs and not indices. | |
| std::vector< std::vector< int > > | neighListPair (double rcutoff, const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int typeI, int typeJ) |
| const std::vector< std::vector< int > > & | reusedShellList (double rcutoff, const molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< char > *source) |
| bool | blockWindowRows (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, double rcutoff, const std::vector< char > *source, std::vector< std::vector< int > > &rows, bool byId=true, bool everyRow=false) |
| bool | cellListRowsThreaded (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< int > &subset, double rcutoff, std::vector< std::vector< int > > &rows) |
| void | preferSerialCutoff (bool on) |
| When set, neighListO stays on the one-thread builder even if the OpenMP team is wider. | |
| bool | orthoFullCsr (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< int > *subset, double rcutoff, std::vector< int > &offsets, std::vector< int > &cols, bool half=false, std::vector< std::vector< int > > *directRows=nullptr, const int *indexToID=nullptr, bool *wroteRows=nullptr, bool branchy=false) |
| Full cutoff list as CSR of cloud indices. | |
| bool | refillNeighListO (double rcutoff, const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int typeI, std::vector< std::vector< int > > &rows) |
| bool | refillIndexRows (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, double cutoff, std::vector< std::vector< int > > &rows) |
| Same rows as getNewNeighbourListByIndex, written into rows. | |
| bool | directedKNearestCsr (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int k, double candidateCutoff, std::vector< int > &offsets, std::vector< int > &cols) |
| Directed k nearest neighbours as a CSR of cloud indices, no self entry. | |
| std::vector< std::vector< int > > | idRowsFromCsr (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< int > &indexToID, const std::vector< int > &offsets, const std::vector< int > &cols) |
| Atom-ID rows, self first, from a CSR of cloud indices. | |
| std::vector< std::vector< int > > | indexRowsFromCsr (int nop, const std::vector< int > &offsets, const std::vector< int > &cols) |
| Index rows, self first, from a CSR of cloud indices. | |
| std::vector< std::vector< int > > | halfIdRowsFromCsr (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< int > &indexToID, const std::vector< int > &offsets, const std::vector< int > &cols) |
| Half list by atom ID. The lower cloud index owns the pair. | |
| std::vector< std::vector< int > > | neighListO (double rcutoff, const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int typeI) |
| std::vector< std::vector< int > > | neighListLinkcell (double rcutoff, const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int typeI) |
| std::vector< std::vector< int > > | halfNeighList (double rcutoff, const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int typeI=1) |
| std::vector< std::vector< int > > | neighbourListByIndex (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, const std::vector< std::vector< int > > &nList) |
| std::vector< std::vector< int > > | getNewNeighbourListByIndex (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, double cutoff) |
| std::vector< std::vector< int > > | kNearestNeighbourList (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int k, double candidateCutoff, int typeI, bool mutual=true) |
| Bonded graph from the k nearest neighbours of each particle rather than a distance cutoff. | |
| void | kNearestCsr (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int k, double candidateCutoff, int typeI, bool mutual, std::vector< int > &offsets, std::vector< int > &cols, bool park=true) |
| void | kNearestPacked (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int k, double candidateCutoff, int typeI, std::vector< double > &xyz, std::vector< int > &nom) |
| std::vector< std::vector< int > > | kNearestNeighbourList (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int k, double candidateCutoff, const std::vector< int > &types, bool mutual=true) |
| k-nearest graph on a type set (water oxygens). | |
| std::pair< std::vector< std::vector< int > >, std::vector< std::vector< int > > > | kNearestNeighbourPair (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int k, double candidateCutoff, int typeI) |
| Mutual and union k-nearest graphs from one candidate search. | |
| std::pair< std::vector< std::vector< int > >, std::vector< std::vector< int > > > | kNearestNeighbourPair (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int k, double candidateCutoff, const std::vector< int > &types) |
| std::pair< double, double > | shellSeparation (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int k, int typeI) |
| The shell-separation certificate for the exact reduction of the k-nearest graph to the cutoff graph: returns {max_i d_k(i), min_i d_{k+1}(i)} over particles of the type. | |
| std::vector< std::tuple< int, int, double > > | nearestUnlike (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int typeI, int typeJ) |
| Nearest unlike image of each typeI particle among typeJ particles. | |
| std::vector< std::pair< int, int > > | mutualNearestUnlike (const molSys::PointCloud< molSys::Point< double >, double > &yCloud, int typeI, int typeJ) |
| Subset of nearestUnlike where j's nearest typeI is i (mutual). | |
| int | clearNeighbourList (std::vector< std::vector< int > > &nList) |
| Erases memory for a vector of vectors for the neighbour list. | |
| BondGraph | bondGraphFromName (const std::string &name) |
| const char * | bondGraphName (BondGraph graph) |
Functions for building neighbour lists.
This namespace contains functions that build neighbour lists (vesin cell list, with a brute-force fallback), saving either the atom IDs or atom indices (according to a PointCloud) in a row-ordered vector of vectors. Whether the atom IDs or atom indices (i.e. the indices of the elements in the vector pts inside the PointCloud) are saved, the neighbour lists are constructed such that the first element is the 'central atom', whose neighbours are being saved on that particular line. The central atom is followed by the atom IDs or indices of the nearest neighbours.
In a 'full' neighbour list, if 1 is a neighbour of 2 then 1 is saved in the neighbour list of 2 AND 2 is also saved in the neighbour list of 1.
In a 'half' neighbour list, if 1 is a neighbour of 2, then 2 is saved in the neighbour list of 1 but not vice versa.
|
strong |
Bond graph for TUM.
Chosen at runtime so the three published assignments can be compared on the same frames. cutoff: pairs inside the distance cutoff (2020 graph). knn: mutual k-nearest (TUM v2 without hysteresis). knn-union: union k-nearest (the completion graph of the seeded rule).
| Enumerator | |
|---|---|
| Cutoff | |
| KnnMutual | |
| KnnUnion | |
Definition at line 601 of file neighbours.hpp.
| bool nneigh::blockWindowRows | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| double | rcutoff, | ||
| const std::vector< char > * | source, | ||
| std::vector< std::vector< int > > & | rows, | ||
| bool | byId = true, | ||
| bool | everyRow = false ) |
Neighbour rows on a cell grid that covers the owned block plus its halo. Anchors are folded onto the first owned atom. Every atom, ghosts included, is shifted by a box length so it sits against that block. An axis whose empty gap is wider than the cutoff does not wrap, and the fused cutoff list runs on that window rather than on the periodic box. Returns false when the atoms fill the box or the box is not orthorhombic. Rows are atom IDs when byId is set, and cloud indices otherwise. Self is first, then partners in ascending order, matching neighListO. A null source marks every atom as an anchor; otherwise only marked atoms receive partners. With everyRow the source still places the window, and every atom in it receives partners.
| BondGraph nneigh::bondGraphFromName | ( | const std::string & | name | ) |
| const char * nneigh::bondGraphName | ( | BondGraph | graph | ) |
| bool nneigh::cellListRowsThreaded | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| const std::vector< int > & | subset, | ||
| double | rcutoff, | ||
| std::vector< std::vector< int > > & | rows ) |
|
nodiscard |
Erases memory for a vector of vectors for the neighbour list.
| bool nneigh::directedKNearestCsr | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| int | k, | ||
| double | candidateCutoff, | ||
| std::vector< int > & | offsets, | ||
| std::vector< int > & | cols ) |
Directed k nearest neighbours as a CSR of cloud indices, no self entry.
candidateCutoff is the cell-size hint used by the k-nearest search. Rows are nearest first. Returns false when the cloud has no box.
|
inline |
Definition at line 132 of file neighbours.hpp.
|
inline |
Longest recovered length: 0 = x, 1 = y, 2 = z.
Definition at line 118 of file neighbours.hpp.
|
inline |
LAMMPS dump bound spans to restricted triclinic H (rows a, b, c).
box[0..2] are xhi_bound - xlo_bound etc. Optional box[3..5] are tilt xy, xz, yz. boxLow is the bound lo. Inverse of xlo_bound = xlo + min(0, xy, xz, xy+xz).
Definition at line 75 of file neighbours.hpp.
|
inline |
Recovered restricted-triclinic lengths lx, ly, lz (H diagonal).
Definition at line 106 of file neighbours.hpp.
|
inline |
Fractional to cartesian coordinates via dump H.
Definition at line 152 of file neighbours.hpp.
|
inline |
Cartesian to fractional coordinates via dump H.
Definition at line 138 of file neighbours.hpp.
|
inline |
Definition at line 170 of file neighbours.hpp.
|
inline |
Triclinic dump-cell volume, the absolute value of det(H), from dumpBoundsToH.
Bound spans Lx*Ly*Lz are not the cell volume when tilt is present.
Definition at line 161 of file neighbours.hpp.
| std::vector< std::vector< int > > nneigh::getNewNeighbourListByIndex | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| double | cutoff ) |
Gets a neighbour list by index, according to a pointCloud given as the input. Assume no slices or other skullduggery
| std::vector< std::vector< int > > nneigh::halfIdRowsFromCsr | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| const std::vector< int > & | indexToID, | ||
| const std::vector< int > & | offsets, | ||
| const std::vector< int > & | cols ) |
Half list by atom ID. The lower cloud index owns the pair.
| std::vector< std::vector< int > > nneigh::halfNeighList | ( | double | rcutoff, |
| const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, | ||
| int | typeI = 1 ) |
Half neighbour list for one type (vesin cell list, brute-force fallback) You can only use this for neighbour lists with one type
| std::vector< std::vector< int > > nneigh::idRowsFromCsr | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| const std::vector< int > & | indexToID, | ||
| const std::vector< int > & | offsets, | ||
| const std::vector< int > & | cols ) |
Atom-ID rows, self first, from a CSR of cloud indices.
| std::vector< std::vector< int > > nneigh::indexRowsFromCsr | ( | int | nop, |
| const std::vector< int > & | offsets, | ||
| const std::vector< int > & | cols ) |
Index rows, self first, from a CSR of cloud indices.
| void nneigh::kNearestCsr | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| int | k, | ||
| double | candidateCutoff, | ||
| int | typeI, | ||
| bool | mutual, | ||
| std::vector< int > & | offsets, | ||
| std::vector< int > & | cols, | ||
| bool | park = true ) |
Same neighbours as kNearestNeighbourList, as a CSR of cloud indices with no self entry. Column order matches that list after the atom-id rows are mapped back to indices.
| std::vector< std::vector< int > > nneigh::kNearestNeighbourList | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| int | k, | ||
| double | candidateCutoff, | ||
| const std::vector< int > & | types, | ||
| bool | mutual = true ) |
k-nearest graph on a type set (water oxygens).
Substrate, ions and other species never appear as neighbours. An empty set is no atoms.
| std::vector< std::vector< int > > nneigh::kNearestNeighbourList | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| int | k, | ||
| double | candidateCutoff, | ||
| int | typeI, | ||
| bool | mutual = true ) |
Bonded graph from the k nearest neighbours of each particle rather than a distance cutoff.
The default intersection symmetrization (mutual = true) bonds i and j only when each lists the other among its k nearest; the union alternative bonds on either nomination. In a crystal the first shell is mutual and the two coincide; on disordered packings the mutual graph is sparser, which starves accidental ring structure – measured on the dense null, mutual scores zero false crystal where union reaches 2.5%. Nominations are a periodic linked-cell k-nearest search via linkcell (Allen and Tildesley): vesin is cutoff-only and KD-trees have no minimum-image convention. candidateCutoff is only a cell-size hint. On an undistorted tetrahedral lattice with k = 4 this graph equals the first-shell cutoff graph. Rows are by atom ID with the leading self entry, like neighListO.
| std::pair< std::vector< std::vector< int > >, std::vector< std::vector< int > > > nneigh::kNearestNeighbourPair | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| int | k, | ||
| double | candidateCutoff, | ||
| const std::vector< int > & | types ) |
| std::pair< std::vector< std::vector< int > >, std::vector< std::vector< int > > > nneigh::kNearestNeighbourPair | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| int | k, | ||
| double | candidateCutoff, | ||
| int | typeI ) |
Mutual and union k-nearest graphs from one candidate search.
Seeded affiliation needs both; building them separately repeats the cell list.
| void nneigh::kNearestPacked | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| int | k, | ||
| double | candidateCutoff, | ||
| int | typeI, | ||
| std::vector< double > & | xyz, | ||
| std::vector< int > & | nom ) |
Packed nominations from the same search as kNearestNeighbourList. xyz is n by 3 and nom is n by k cloud indices, nearest first, with unused slots set to -1. The rows are not symmetrized.
| std::vector< std::pair< int, int > > nneigh::mutualNearestUnlike | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| int | typeI, | ||
| int | typeJ ) |
Subset of nearestUnlike where j's nearest typeI is i (mutual).
A contact pair is this mutual edge, not first-shell membership.
| std::vector< std::tuple< int, int, double > > nneigh::nearestUnlike | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| int | typeI, | ||
| int | typeJ ) |
Nearest unlike image of each typeI particle among typeJ particles.
Returns cloud-index pairs (i, j) and the MIC distance (sqrt of gen::periodicDistSq). On an ion cloud, typeI = 1 (cation vertex) and typeJ = 2 (anion vertex). This is the nearest unlike neighbour, not a coordination number.
| std::vector< std::vector< int > > nneigh::neighbourListByIndex | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| const std::vector< std::vector< int > > & | nList ) |
The following function outputs a neighbour list using indices and NOT atom IDs
Converts the neighbour list build with atom IDs into a neighbour list of atom indices, according to the pointCloud
| std::vector< std::vector< int > > nneigh::neighList | ( | double | rcutoff, |
| const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, | ||
| int | typeI, | ||
| int | typeJ ) |
All these functions use atom IDs and not indices.
Full neighbour list for pairs of type I and type J (vesin cell list, brute-force fallback). The neighbour list does not differentiate between the types of atoms
| std::vector< std::vector< int > > nneigh::neighListLinkcell | ( | double | rcutoff, |
| const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, | ||
| int | typeI ) |
Cutoff rows from the threaded linkcell list. Empty when linkcell is not built or the call fails; the caller then uses neighListO. The width is the OpenMP team, and the OpenMP team is left running.
| std::vector< std::vector< int > > nneigh::neighListO | ( | double | rcutoff, |
| const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, | ||
| int | typeI ) |
Full neighbour list for one type (threaded cell list from 2048 atoms when OpenMP is compiled, vesin cell list, brute-force fallback) You can only use this for neighbour lists with one type
| std::vector< std::vector< int > > nneigh::neighListPair | ( | double | rcutoff, |
| const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, | ||
| int | typeI, | ||
| int | typeJ ) |
I-J neighbour list (I==J is like-type and reuses neighListO). Unlike-type pairs use the same dump MIC as neighListO.
| bool nneigh::orthoFullCsr | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| const std::vector< int > * | subset, | ||
| double | rcutoff, | ||
| std::vector< int > & | offsets, | ||
| std::vector< int > & | cols, | ||
| bool | half = false, | ||
| std::vector< std::vector< int > > * | directRows = nullptr, | ||
| const int * | indexToID = nullptr, | ||
| bool * | wroteRows = nullptr, | ||
| bool | branchy = false ) |
Full cutoff list as CSR of cloud indices.
Orthorhombic, or a restricted triclinic cell stored as bound spans plus xy, xz, yz.
Orthorhombic boxes (box.size() == 3) and restricted triclinic dump boxes (box.size() >= 6) both use the parallel cell sort. A null subset is every atom. cols[offsets[i] .. offsets[i + 1]] is sorted and has no self entry. A neighbour is kept when the squared minimum image is strictly below the cutoff squared. half keeps the pair only on the lower cloud index. The pair set does not depend on the thread count. Scratch buffers stay allocated and are refilled on the next call. Returns false when the box is not usable.
| void nneigh::preferSerialCutoff | ( | bool | on | ) |
When set, neighListO stays on the one-thread builder even if the OpenMP team is wider.
The team is left in place for the caller.
| bool nneigh::refillIndexRows | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| double | cutoff, | ||
| std::vector< std::vector< int > > & | rows ) |
Same rows as getNewNeighbourListByIndex, written into rows.
| bool nneigh::refillNeighListO | ( | double | rcutoff, |
| const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, | ||
| int | typeI, | ||
| std::vector< std::vector< int > > & | rows ) |
Same rows as neighListO, written into rows. A row keeps the capacity of the previous call, so a repeated frame does not allocate per atom.
| const std::vector< std::vector< int > > & nneigh::reusedShellList | ( | double | rcutoff, |
| const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, | ||
| const std::vector< char > * | source ) |
Threaded cell-list neighbour rows. rows[k] holds the indices within rcutoff of subset[k] under the minimum image convention, ascending and without the atom itself. Atoms are binned in fractional coordinates of the recovered triclinic cell H; every axis needs at least three cells of perpendicular width rcutoff, so that the nearest image of every neighbour sits in one of the 27 surrounding cells. Returns false, with rows untouched, when the cell is too small for that, and the caller takes the vesin or brute-force path. Each row is built by one thread. Cutoff rows by atom ID, self first, for every atom or only the atoms marked in source. The cell counts and the row storage stay allocated on the calling thread and are refilled in place, so overlapping calls do not share them. The returned reference is valid on this thread until the next call on this thread. Same partners as neighListO for the rows that are filled.
|
inline |
LAMMPS edge origin and edge lengths, plus tilt, as a dump box.
lx, ly, lz are xhi - xlo and not the bound spans. A zero tilt stays three spans so the orthorhombic pair loop is unchanged. Returns false when an edge is not positive.
Definition at line 180 of file neighbours.hpp.
|
inline |
Crystallographic lengths and angles in degrees, stored as a dump box.
alpha is between b and c, beta between a and c, gamma between a and b. The basis is the reduced triclinic frame: a along x, b in the xy plane. Returns false when the cell is not a positive volume.
Definition at line 210 of file neighbours.hpp.
| std::pair< double, double > nneigh::shellSeparation | ( | const molSys::PointCloud< molSys::Point< double >, double > & | yCloud, |
| int | k, | ||
| int | typeI ) |
The shell-separation certificate for the exact reduction of the k-nearest graph to the cutoff graph: returns {max_i d_k(i), min_i d_{k+1}(i)} over particles of the type.
When max_i d_k(i) <= rcutoff <= min_i d_{k+1}(i), the two graphs coincide edge for edge and every downstream graph predicate is identical. Brute force, intended for validation. A particle of the type with fewer than k others of that type returns {infinity, 0}: no cutoff gives it k neighbours.