struct rgpot::nlist::CellGrid

Overview

Cell decomposition of one configuration: atoms sorted by cell (CSR). More…

#include <cell_visit.hpp>
 
struct CellGrid {
    // fields
 
    std::array<int, 3> nc {{1, 1, 1}};
    std::array<bool, 3> wrap {{false, false, false}};
    std::vector<int32_t> start;
    std::vector<int32_t> atoms;
 
    // methods
 
    long neighbour(int cx, int cy, int cz, const int o[3]) const;
    bool build(const double* points, std::size_t n, const double w[3], const double inv[3], double rl);
};

Detailed Documentation

Cell decomposition of one configuration: atoms sorted by cell (CSR).

Fields

std::vector<int32_t> start

ncells + 1 row starts into atoms.

std::vector<int32_t> atoms

Atom indices grouped by cell.

Methods

long neighbour(int cx, int cy, int cz, const int o[3]) const

Linear index of cell (cx, cy, cz) shifted by stencil offset o, or -1 when the shift leaves a free axis.

bool build(const double* points, std::size_t n, const double w[3], const double inv[3], double rl)

Bin points into cells no narrower than rl. w[k] is the periodic width and inv[k] its inverse, zero for a free axis. Returns false when a grid cannot serve (fewer than three cells along a periodic axis, or fewer than kMinCellsForGrid cells in all) or would not pay (the cell scan’s pair tests for this occupancy, plus the stencil walk, above half the brute-force scan’s n (n - 1) / 2: a cluster in a mostly empty box crowds a few cells), in which case the caller uses the brute-force scan.