|
Gromacs
2027.0-dev-20261110-b871b63f
|
#include <gromacs/nbnxm/grid.h>
A pair-search grid object for one domain decomposition zone.
This is a rectangular 3D grid covering a potentially non-rectangular volume which is either the whole unit cell or the local zone or part of a non-local zone when using domain decomposition. An uniformly space grid is used along dimensions x and y. Along dimension z atoms are organized in bins with equal atom count. Each bin is sub-divided into atom clusters. With a CPU geometry, each bin contains 1 or 2 clusters. With a GPU geometry, each bin contains 8 clusters. The geometry is set by the pairlist type which is the only argument of the constructor.
When multiple grids are used, i.e. with domain decomposition, we want to avoid the overhead of multiple coordinate arrays or extra indexing. Therefore each grid stores a bin offset, so a contiguous bin index can be used to index atom arrays. All methods returning atom indices return indices which index into a full atom array.
Note that when atom groups, instead of individual atoms, are assigned to grid bins, individual atoms can be geometrically outside the bin and grid that they have been assigned to (as determined by the center or geometry of the atom group they belong to).
Classes | |
| struct | Geometry |
| The cluster and bin geometry of a grid. More... | |
Public Member Functions | |
| Grid (PairlistType pairlistType, int ddZone, const bool &haveFep, const HostAllocationPolicy &hostAllocationPolicy) | |
| Constructs a grid given the type of pairlist. | |
| const Geometry & | geometry () const |
| Returns the geometry of the grid bins. | |
| int | ddZone () const |
| Returns the zone this grid belong to. | |
| const GridDimensions & | dimensions () const |
| Returns the dimensions of the grid. | |
| int | numCells () const |
| Returns the total number of grid cells. | |
| int | numBins () const |
| Returns the total number of grid bins. | |
| int | binOffset () const |
| Returns the bin offset of (the first bin of) this grid in the list of bins combined over all grids. | |
| int | maxNumBinsPerCell () const |
| Returns the maximum number of grid bins in a cell. | |
| int | firstBinInCell (int cellIndex) const |
| Returns the first bin index in the grid, starting at 0 in this grid. | |
| int | numBinsInCell (int cellIndex) const |
| Returns the number of bins in the cell. | |
| int | firstAtomInCell (int cellIndex) const |
| Returns the index of the first atom in the cell. | |
| int | numAtomsInCell (int cellIndex) const |
| Returns the number of real atoms in the cell. | |
| ArrayRef< const int > | numAtomsPerCell () const |
| Returns a view of the number of non-filler, atoms for each grid cell. | |
| ArrayRef< const int > | cellToBin () const |
| Returns a view of the grid-local bin index for each grid cell. | |
| int | numAtomsPerBin () const |
| Returns the number of atoms in a bin. | |
| int | paddedNumAtomsInCell (int cellIndex) const |
| Returns the number of atoms in the cell including padding. | |
| int | atomIndexEnd () const |
| Returns the end of the atom index range on the grid, including padding. | |
| bool | clusterIsPerturbed (int clusterIndex) const |
| Returns whether any atom in the cluster is perturbed. | |
| bool | atomIsPerturbed (int clusterIndex, int atomIndexInCluster) const |
| Returns whether the given atom in the cluster is perturbed. | |
| unsigned int | fepBits (int clusterIndex) const |
| Returns the free-energy perturbation bits for the cluster. | |
| ArrayRef< const BoundingBox > | iBoundingBoxes () const |
| Returns the i-bounding boxes for all clusters on the grid. | |
| ArrayRef< const BoundingBox > | jBoundingBoxes () const |
| Returns the j-bounding boxes for all clusters on the grid. | |
| ArrayRef< const float > | packedBoundingBoxes () const |
| Returns the packed bounding boxes for all clusters on the grid, empty with a CPU list. | |
| ArrayRef< const BoundingBox1D > | zBoundingBoxes () const |
| Returns the bounding boxes along z for all i-bins on the grid. | |
| ArrayRef< const int > | clusterFlags () const |
| Returns the flags for all clusters on the grid. | |
| ArrayRef< const int > | numClustersPerBin () const |
| Returns the number of clusters for all bins on the grid, empty with a CPU geometry. | |
| int | atomToCluster (int atomIndex) const |
| Returns the cluster index for an atom. | |
| int | numClusters () const |
| Returns the total number of clusters on the grid. | |
| RVec | averageBinSize () const |
| Returns the average spatial size of a grid bin. | |
| real | generateAndFill2D (ArrayRef< GridWork > gridWork, HostVector< int > *cells, const rvec lowerCorner, const rvec upperCorner, const UpdateGroupsCog *updateGroupsCog, Range< int > atomRange, int numGridAtomsWithoutFillers, real *atomDensity, real maxAtomGroupRadius, ArrayRef< const RVec > x, int ddZone, const int *move, bool computeEffectiveAtomDensity) |
| Sets the 2D search grid dimensions puts the atoms on the 2D grid. More... | |
| void | setBinIndices (int ddZone, int binOffset, GridSetData *gridSetData, ArrayRef< GridWork > gridWork, Range< int > atomRange, ArrayRef< const int32_t > atomInfo, ArrayRef< const RVec > x, nbnxm_atomdata_t *nbat) |
Sets the bin indices using indices in gridSetData and gridWork. | |
| void | setNonLocalGrid (int ddZone, const GridDimensions &dimensions, ArrayRef< const std::pair< int, int >> clusterRanges, int binOffset, ArrayRef< const int32_t > atomInfo, ArrayRef< const RVec > x, GridSetData *gridSetData, nbnxm_atomdata_t *nbat) |
| Sets a non-local grid using data communicated from a different domain. More... | |
Static Public Member Functions | |
| static void | calcCellIndices (const GridDimensions &gridDims, const UpdateGroupsCog *updateGroupsCog, Range< int > atomRange, ArrayRef< const RVec > x, int dd_zone, const int *move, int thread, int nthread, ArrayRef< int > bins, int numCellsZ, ArrayRef< int > numAtomsPerCell) |
Determine in which grid cells atoms should go, store bins and atom counts in bins and numAtomsPerCell. | |
| real gmx::Grid::generateAndFill2D | ( | ArrayRef< GridWork > | gridWork, |
| HostVector< int > * | cells, | ||
| const rvec | lowerCorner, | ||
| const rvec | upperCorner, | ||
| const UpdateGroupsCog * | updateGroupsCog, | ||
| Range< int > | atomRange, | ||
| int | numGridAtomsWithoutFillers, | ||
| real * | atomDensity, | ||
| real | maxAtomGroupRadius, | ||
| ArrayRef< const RVec > | x, | ||
| int | ddZone, | ||
| const int * | move, | ||
| bool | computeEffectiveAtomDensity | ||
| ) |
Sets the 2D search grid dimensions puts the atoms on the 2D grid.
The atomDensity parameter is used to set the, uniform, grid size. When atomDensity <= 0, it is computed as the atom count divided by the zone volume. For inhomogenous systems this can result in very sub-optimal performance due to many zero interactions in the list. To avoid this, this function can return an estimate of the effective atom density, which puts more weights on denser areas. This estimate is accurate for dimensions x and y, but uses the global std.dev. of the z-coordinates.
| [in,out] | gridWork | Working data for each thread |
| [in,out] | cells | The grid cell list |
| [in] | lowerCorner | The minimum Cartesian coordinates of the grid |
| [in] | upperCorner | The maximum Cartesian coordinates of the grid |
| [in] | updateGroupsCog | The center of geometry of update groups, can be nullptr |
| [in] | atomRange | The range of atoms to put on this grid, may include moved atoms |
| [in] | numGridAtomsWithoutFillers | The number of atoms that are not filler particles and have not moved by to another domain by DD |
| [in,out] | atomDensity | The atom density, will be computed when <= 0 |
| [in] | maxAtomGroupRadius | The maximum radius of atom groups |
| [in] | x | The coordinates of the atoms |
| [in] | ddZone | The domain decomposition zone |
| [in] | move | Tells whether atoms have moved to another DD domain |
| [in] | computeEffectiveAtomDensity | When true, return an estimate of the atom density |
computeEffectiveAtomDensity==true, an estimate of the effective atom density | void gmx::Grid::setNonLocalGrid | ( | int | ddZone, |
| const GridDimensions & | dimensions, | ||
| ArrayRef< const std::pair< int, int >> | clusterRanges, | ||
| int | binOffset, | ||
| ArrayRef< const int32_t > | atomInfo, | ||
| ArrayRef< const RVec > | x, | ||
| GridSetData * | gridSetData, | ||
| nbnxm_atomdata_t * | nbat | ||
| ) |
Sets a non-local grid using data communicated from a different domain.
clusterRanges use a size of the maximum of the i- and j-cluster size in atoms, whereas Grid use the i-cluster size.| [in] | ddZone | The domain decomposition zone this grid belongs to |
| [in] | dimensions | The dimensions of the grid |
| [in] | clusterRanges | A list of cell indices and number of clusters for a cell, the list should be ordered on cell index, the same cell index can appear multiple times; note that the clusters here have size of the maximum of the i- and j-sizes |
| [in] | binOffset | The offset of this grid in the list of bins over all grids |
| [in] | atomInfo | A list of information for all local and non-local atoms |
| [in] | x | The coordinates for all local and non-local atoms |
| [in,out] | gridSetData | The data shared over all grids |
| [in,out] | nbat | The NBNxM atom data, used here for storing the atom coordinates |
1.8.5