Gromacs  2026.0-dev-20250418-2a07af2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
grid.cpp File Reference
#include "gmxpre.h"
#include "grid.h"
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <array>
#include <filesystem>
#include <string>
#include "gromacs/math/functions.h"
#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/gmx_omp_nthreads.h"
#include "gromacs/mdlib/updategroupscog.h"
#include "gromacs/mdtypes/atominfo.h"
#include "gromacs/nbnxm/atomdata.h"
#include "gromacs/nbnxm/nbnxm_enums.h"
#include "gromacs/nbnxm/pairlist.h"
#include "gromacs/simd/simd.h"
#include "gromacs/simd/vector_operations.h"
#include "gromacs/utility/allocator.h"
#include "gromacs/utility/enumerationhelpers.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxassert.h"
#include "boundingbox.h"
#include "boundingbox_simd.h"
#include "gridsetdata.h"
#include "nbnxm.h"
#include "nbnxm_geometry.h"
#include "pairlistparams.h"
+ Include dependency graph for grid.cpp:

Description

Implements the Grid class.

Author
Berk Hess hess@.nosp@m.kth..nosp@m.se

Functions

static real gmx::gridAtomDensity (int numAtoms, const RVec &gridBoundingBoxSize)
 Returns the atom density (> 0) of a rectangular grid.
 
static std::array< real, DIM-1 > gmx::getTargetCellLength (const Grid::Geometry &geometry, const real atomDensity)
 Get approximate dimensions of each cell. Returns the length along X and Y.
 
static int gmx::getMaxNumCells (const Grid::Geometry &geometry, const int numAtoms, const int numColumns)
 
static bool gmx::isHomeZone (const int ddZone)
 Returns whether ddZone is the home zone.
 
static void gmx::sort_atoms (int dim, gmx_bool Backwards, int gmx_unused dd_zone, bool gmx_unused relevantAtomsAreWithinGridBounds, int *a, int n, ArrayRef< const RVec > x, real h0, real invh, int n_per_h, ArrayRef< int > sort)
 Sorts particle index a on coordinates x along dim. More...
 
static float gmx::R2F_D (const float x)
 Returns x.
 
static float gmx::R2F_U (const float x)
 Returns x.
 
static void gmx::calc_bounding_box (const int numAtoms, const int stride, const real *x, BoundingBox *bb)
 Computes the bounding box for na coordinates in order x,y,z, bb order xyz0.
 
template<int packSize>
static void gmx::calcBoundingBoxXPacked (const int numAtoms, const real *x, BoundingBox *bb)
 Computes the bounding box for packed coordinates. More...
 
template<int packSize>
static gmx_unused void gmx::calcBoundingBoxHalves (const int numAtoms, const real *x, BoundingBox *bb, BoundingBox *bbj)
 Computes the whole plus half bounding boxes for packed coordinates. More...
 
static void gmx::calc_bounding_box_xxxx (int na, int stride, const real *x, float *bb)
 Computes the bounding box for na coordinates in order xyz, bb order xxxxyyyyzzzz.
 
static void gmx::combine_bounding_box_pairs (const Grid &grid, ArrayRef< const BoundingBox > bb, ArrayRef< BoundingBox > bbj)
 Combines pairs of consecutive bounding boxes.
 
static void gmx::print_bbsizes_simple (FILE *fp, const Grid &grid)
 Prints the average bb size, used for debug output.
 
static void gmx::print_bbsizes_supersub (FILE *fp, const Grid &grid)
 Prints the average bb size, used for debug output.
 
static void gmx::sort_cluster_on_flag (int numAtomsInCluster, int atomStart, int atomEnd, ArrayRef< const int32_t > atomInfo, ArrayRef< int > order, int *flags)
 Set non-bonded interaction flags for the current cluster. More...
 
static void gmx::setCellAndAtomCount (ArrayRef< int > cell, int cellIndex, ArrayRef< int > cxy_na, int atomIndex)
 Sets the cell index in the cell array for atom atomIndex and increments the atom count for the grid column.
 
static void gmx::resizeForNumberOfCells (const int numNbnxnAtoms, const int numAtomsMoved, const int ddZone, GridSetData *gridSetData, nbnxn_atomdata_t *nbat)
 Resizes grid and atom data which depend on the number of cells.
 
real gmx::generateAndFill2DGrid (Grid *grid, 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 computeGridDensityRatio)
 Sets the 2D search grid dimensions puts the atoms on the 2D grid. More...
 

Variables

constexpr bool gmx::anonymous_namespace{grid.cpp}::allocatorShouldPropagateDuringCopyConstruction = true
 Named constant. More...
 
static constexpr int gmx::c_sortGridRatio = 4
 Ratio of grid cells to atoms.
 
static constexpr int gmx::c_sortGridMaxSizeFactor = c_sortGridRatio + 1
 Maximum ratio of holes used, in the worst case all particles end up in the last hole and we need num. atoms extra holes at the end.