seams-core v2.14.0
libyodaLib, the C++ engine of d-SEAMS
Loading...
Searching...
No Matches
nneigh Namespace Reference

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)

Detailed Description

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.

Changelog

Enumeration Type Documentation

◆ BondGraph

enum class nneigh::BondGraph
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.

Function Documentation

◆ blockWindowRows()

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.

◆ bondGraphFromName()

BondGraph nneigh::bondGraphFromName ( const std::string & name)

◆ bondGraphName()

const char * nneigh::bondGraphName ( BondGraph graph)

◆ cellListRowsThreaded()

bool nneigh::cellListRowsThreaded ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud,
const std::vector< int > & subset,
double rcutoff,
std::vector< std::vector< int > > & rows )

◆ clearNeighbourList()

int nneigh::clearNeighbourList ( std::vector< std::vector< int > > & nList)
nodiscard

Erases memory for a vector of vectors for the neighbour list.

◆ directedKNearestCsr()

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.

◆ dumpAxialDim() [1/2]

int nneigh::dumpAxialDim ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud)
inline

Definition at line 132 of file neighbours.hpp.

133 {
134 return dumpAxialDim(yCloud.box, yCloud.boxLow);
135}
int dumpAxialDim(const std::vector< double > &box, const std::vector< double > &boxLow)
Longest recovered length: 0 = x, 1 = y, 2 = z.
std::vector< T > box
Number of atoms.
Definition mol_sys.hpp:177
std::vector< T > boxLow
Periodic box lengths.
Definition mol_sys.hpp:178

◆ dumpAxialDim() [2/2]

int nneigh::dumpAxialDim ( const std::vector< double > & box,
const std::vector< double > & boxLow )
inline

Longest recovered length: 0 = x, 1 = y, 2 = z.

Definition at line 118 of file neighbours.hpp.

119 {
120 double lengths[3];
121 dumpCellLengths(box, boxLow, lengths);
122 int axial = 0;
123 if (lengths[1] > lengths[axial]) {
124 axial = 1;
125 }
126 if (lengths[2] > lengths[axial]) {
127 axial = 2;
128 }
129 return axial;
130}
void dumpCellLengths(const std::vector< double > &box, const std::vector< double > &boxLow, double lengths[3])
Recovered restricted-triclinic lengths lx, ly, lz (H diagonal).

◆ dumpBoundsToH()

void nneigh::dumpBoundsToH ( const std::vector< double > & box,
const std::vector< double > & boxLow,
double H[3][3],
double origin[3] )
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.

77 {
78 const double xspan = box.size() > 0 ? box[0] : 0.0;
79 const double yspan = box.size() > 1 ? box[1] : 0.0;
80 const double zspan = box.size() > 2 ? box[2] : 0.0;
81 const double xlo_b = boxLow.size() > 0 ? boxLow[0] : 0.0;
82 const double ylo_b = boxLow.size() > 1 ? boxLow[1] : 0.0;
83 const double zlo_b = boxLow.size() > 2 ? boxLow[2] : 0.0;
84 const double xy = box.size() >= 6 ? box[3] : 0.0;
85 const double xz = box.size() >= 6 ? box[4] : 0.0;
86 const double yz = box.size() >= 6 ? box[5] : 0.0;
87 const double xmin = std::min(std::min(0.0, xy), std::min(xz, xy + xz));
88 const double xmax = std::max(std::max(0.0, xy), std::max(xz, xy + xz));
89 const double ymin = std::min(0.0, yz);
90 const double ymax = std::max(0.0, yz);
91 H[0][0] = xspan - xmax + xmin;
92 H[0][1] = 0.0;
93 H[0][2] = 0.0;
94 H[1][0] = xy;
95 H[1][1] = yspan - ymax + ymin;
96 H[1][2] = 0.0;
97 H[2][0] = xz;
98 H[2][1] = yz;
99 H[2][2] = zspan;
100 origin[0] = xlo_b - xmin;
101 origin[1] = ylo_b - ymin;
102 origin[2] = zlo_b;
103}

◆ dumpCellLengths()

void nneigh::dumpCellLengths ( const std::vector< double > & box,
const std::vector< double > & boxLow,
double lengths[3] )
inline

Recovered restricted-triclinic lengths lx, ly, lz (H diagonal).

Definition at line 106 of file neighbours.hpp.

108 {
109 double H[3][3];
110 double origin[3];
111 dumpBoundsToH(box, boxLow, H, origin);
112 lengths[0] = H[0][0];
113 lengths[1] = H[1][1];
114 lengths[2] = H[2][2];
115}
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).

◆ dumpFromFrac()

void nneigh::dumpFromFrac ( const double H[3][3],
const double origin[3],
const double s[3],
double r[3] )
inline

Fractional to cartesian coordinates via dump H.

Definition at line 152 of file neighbours.hpp.

153 {
154 r[0] = origin[0] + H[0][0] * s[0] + H[1][0] * s[1] + H[2][0] * s[2];
155 r[1] = origin[1] + H[1][1] * s[1] + H[2][1] * s[2];
156 r[2] = origin[2] + H[2][2] * s[2];
157}

◆ dumpToFrac()

void nneigh::dumpToFrac ( const double H[3][3],
const double origin[3],
double x,
double y,
double z,
double s[3] )
inline

Cartesian to fractional coordinates via dump H.

Definition at line 138 of file neighbours.hpp.

139 {
140 const double lx = H[0][0];
141 const double ly = H[1][1];
142 const double lz = H[2][2];
143 const double xy = H[1][0];
144 const double xz = H[2][0];
145 const double yz = H[2][1];
146 s[2] = (z - origin[2]) / lz;
147 s[1] = (y - origin[1] - yz * s[2]) / ly;
148 s[0] = (x - origin[0] - xy * s[1] - xz * s[2]) / lx;
149}

◆ dumpVolume() [1/2]

double nneigh::dumpVolume ( const molSys::PointCloud< molSys::Point< double >, double > & yCloud)
inline

Definition at line 170 of file neighbours.hpp.

171 {
172 return dumpVolume(yCloud.box, yCloud.boxLow);
173}
double dumpVolume(const std::vector< double > &box, const std::vector< double > &boxLow)
Triclinic dump-cell volume, the absolute value of det(H), from dumpBoundsToH.

◆ dumpVolume() [2/2]

double nneigh::dumpVolume ( const std::vector< double > & box,
const std::vector< double > & boxLow )
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.

162 {
163 double H[3][3];
164 double origin[3];
165 dumpBoundsToH(box, boxLow, H, origin);
166 const double vol = H[0][0] * H[1][1] * H[2][2];
167 return vol < 0.0 ? -vol : vol;
168}

◆ getNewNeighbourListByIndex()

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

◆ halfIdRowsFromCsr()

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.

◆ halfNeighList()

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

◆ idRowsFromCsr()

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.

◆ indexRowsFromCsr()

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.

◆ kNearestCsr()

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.

◆ kNearestNeighbourList() [1/2]

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.

◆ kNearestNeighbourList() [2/2]

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.

◆ kNearestNeighbourPair() [1/2]

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 )

◆ kNearestNeighbourPair() [2/2]

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.

◆ kNearestPacked()

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.

◆ mutualNearestUnlike()

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.

◆ nearestUnlike()

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.

◆ neighbourListByIndex()

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

◆ neighList()

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

◆ neighListLinkcell()

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.

◆ neighListO()

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

◆ neighListPair()

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.

◆ orthoFullCsr()

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.

◆ preferSerialCutoff()

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.

◆ refillIndexRows()

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.

◆ refillNeighListO()

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.

◆ reusedShellList()

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.

◆ setBoxFromLammpsEdges()

bool nneigh::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 )
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.

183 {
184 if (!(lx > 0.0 && ly > 0.0 && lz > 0.0)) {
185 box.clear();
186 boxLow.clear();
187 return false;
188 }
189 const bool tilt =
190 std::abs(xy) > 0.0 || std::abs(xz) > 0.0 || std::abs(yz) > 0.0;
191 if (!tilt) {
192 box = {lx, ly, lz};
193 boxLow = {xlo, ylo, zlo};
194 return true;
195 }
196 const double xmin = std::min(std::min(0.0, xy), std::min(xz, xy + xz));
197 const double xmax = std::max(std::max(0.0, xy), std::max(xz, xy + xz));
198 const double ymin = std::min(0.0, yz);
199 const double ymax = std::max(0.0, yz);
200 box = {lx + xmax - xmin, ly + ymax - ymin, lz, xy, xz, yz};
201 boxLow = {xlo + xmin, ylo + ymin, zlo};
202 return true;
203}

◆ setBoxFromLengthsAngles()

bool nneigh::setBoxFromLengthsAngles ( std::vector< double > & box,
std::vector< double > & boxLow,
double a,
double b,
double c,
double alphaDeg,
double betaDeg,
double gammaDeg )
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.

213 {
214 constexpr double kDeg = 3.14159265358979323846 / 180.0;
215 const double alpha = alphaDeg * kDeg;
216 const double beta = betaDeg * kDeg;
217 const double gamma = gammaDeg * kDeg;
218 const double cosA = std::cos(alpha);
219 const double cosB = std::cos(beta);
220 const double cosG = std::cos(gamma);
221 const double sinG = std::sin(gamma);
222 if (!(a > 0.0 && b > 0.0 && c > 0.0) || std::abs(sinG) < 1e-18) {
223 box.clear();
224 boxLow.clear();
225 return false;
226 }
227 double xy = b * cosG;
228 const double ly = b * sinG;
229 double xz = c * cosB;
230 double yz = c * (cosA - cosB * cosG) / sinG;
231 // cos(90 deg) is a few ulps, not zero. A right angle must stay
232 // orthorhombic, or the pair loop takes the triclinic path.
233 const double tol = 1e-10 * std::max(a, std::max(b, c));
234 if (std::abs(xy) < tol) {
235 xy = 0.0;
236 }
237 if (std::abs(xz) < tol) {
238 xz = 0.0;
239 }
240 if (std::abs(yz) < tol) {
241 yz = 0.0;
242 }
243 const double lz2 = c * c - xz * xz - yz * yz;
244 if (!(ly > 0.0) || !(lz2 > 0.0)) {
245 box.clear();
246 boxLow.clear();
247 return false;
248 }
249 return setBoxFromLammpsEdges(box, boxLow, 0.0, 0.0, 0.0, a, ly, std::sqrt(lz2),
250 xy, xz, yz);
251}
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.

◆ shellSeparation()

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.