ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
BinManager Class Reference

Manager for binning atoms to accelerate neighbor search. More...

#include <bin_manager.h>

Collaboration diagram for BinManager:

Public Member Functions

void init_bins (double sr, const std::vector< NeighborAtom > &all_atoms)
 Initialize the bin grid based on atom positions and search radius.
void do_binning (const std::vector< NeighborAtom > &atoms)
 Assign atoms to their corresponding bins.
void build_atom_neighbors (NeighborList &neighbor_list, const std::vector< NeighborAtom > &atoms, const std::vector< NeighborAtom > &binned_atoms)
 Build neighbor list by searching adjacent bins.
void clear ()
 Clear all bins and reset internal state.
int get_nbinx () const
 Get the number of bins in X direction.
int get_nbiny () const
 Get the number of bins in Y direction.
int get_nbinz () const
 Get the number of bins in Z direction.
int get_total_bins () const
 Get the total number of bins.
int get_bin_atom_count (int bin_index) const
 Get the number of atoms in a specific bin.

Private Member Functions

int bin_index (int ix, int iy, int iz) const
 Compute the flat index for a bin from its 3D coordinates.

Private Attributes

double sradius_ = 0.0
 Search radius in lattice units.
double x_min_ = 0.0
 Minimum coordinates of the binned region.
double y_min_ = 0.0
double z_min_ = 0.0
double x_max_ = 0.0
 Maximum coordinates of the binned region.
double y_max_ = 0.0
double z_max_ = 0.0
double bin_sizex_ = 0.0
 Size of each bin in each direction.
double bin_sizey_ = 0.0
double bin_sizez_ = 0.0
int nbinx_ = 1
 Number of bins in each direction.
int nbiny_ = 1
int nbinz_ = 1
std::vector< Bin > bins_
 All bins in the 3D grid (stored as flat array).

Detailed Description

Manager for binning atoms to accelerate neighbor search.

This class implements a spatial binning strategy where atoms are sorted into a 3D grid of bins. Neighbor search then only needs to check adjacent bins, significantly reducing the search complexity.

The workflow is:

  1. Call init_bins() to set up the bin grid based on atom positions
  2. Call do_binning() to assign atoms to bins
  3. Call build_atom_neighbors() to construct the neighbor list
  4. Call clear() to reset for the next search

Member Function Documentation

◆ bin_index()

int BinManager::bin_index ( int ix,
int iy,
int iz ) const
private

Compute the flat index for a bin from its 3D coordinates.

Parameters
ixX index of the bin.
iyY index of the bin.
izZ index of the bin.
Returns
Flat index in the bins_ array.
Here is the caller graph for this function:

◆ build_atom_neighbors()

void BinManager::build_atom_neighbors ( NeighborList & neighbor_list,
const std::vector< NeighborAtom > & atoms,
const std::vector< NeighborAtom > & binned_atoms )

Build neighbor list by searching adjacent bins.

For each atom, searches its containing bin and all adjacent bins to find neighbors within the search radius.

Parameters
neighbor_listOutput neighbor list to populate.
atomsAtoms for which to build neighbors.
binned_atomsAll atoms assigned to bins by do_binning().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void BinManager::clear ( )

Clear all bins and reset internal state.

Here is the caller graph for this function:

◆ do_binning()

void BinManager::do_binning ( const std::vector< NeighborAtom > & atoms)

Assign atoms to their corresponding bins.

Must be called after init_bins(). Each atom is placed into the bin that contains its spatial position.

Parameters
atomsAll atoms to assign to bins.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_bin_atom_count()

int BinManager::get_bin_atom_count ( int bin_index) const

Get the number of atoms in a specific bin.

Parameters
bin_indexIndex of the bin in the flat array.
Returns
Number of atoms in that bin.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_nbinx()

int BinManager::get_nbinx ( ) const

Get the number of bins in X direction.

Returns
Number of bins in X.
Here is the caller graph for this function:

◆ get_nbiny()

int BinManager::get_nbiny ( ) const

Get the number of bins in Y direction.

Returns
Number of bins in Y.
Here is the caller graph for this function:

◆ get_nbinz()

int BinManager::get_nbinz ( ) const

Get the number of bins in Z direction.

Returns
Number of bins in Z.
Here is the caller graph for this function:

◆ get_total_bins()

int BinManager::get_total_bins ( ) const

Get the total number of bins.

Returns
Total bin count (nbinx * nbiny * nbinz).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_bins()

void BinManager::init_bins ( double sr,
const std::vector< NeighborAtom > & all_atoms )

Initialize the bin grid based on atom positions and search radius.

Computes the spatial bounds from atom positions and divides the region into bins of size approximately equal to the search radius.

Parameters
srSearch radius in lattice units.
inside_atomsAtoms inside the local MPI domain.
ghost_atomsGhost atoms from neighboring domains.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ bin_sizex_

double BinManager::bin_sizex_ = 0.0
private

Size of each bin in each direction.

◆ bin_sizey_

double BinManager::bin_sizey_ = 0.0
private

◆ bin_sizez_

double BinManager::bin_sizez_ = 0.0
private

◆ bins_

std::vector<Bin> BinManager::bins_
private

All bins in the 3D grid (stored as flat array).

◆ nbinx_

int BinManager::nbinx_ = 1
private

Number of bins in each direction.

◆ nbiny_

int BinManager::nbiny_ = 1
private

◆ nbinz_

int BinManager::nbinz_ = 1
private

◆ sradius_

double BinManager::sradius_ = 0.0
private

Search radius in lattice units.

◆ x_max_

double BinManager::x_max_ = 0.0
private

Maximum coordinates of the binned region.

◆ x_min_

double BinManager::x_min_ = 0.0
private

Minimum coordinates of the binned region.

◆ y_max_

double BinManager::y_max_ = 0.0
private

◆ y_min_

double BinManager::y_min_ = 0.0
private

◆ z_max_

double BinManager::z_max_ = 0.0
private

◆ z_min_

double BinManager::z_min_ = 0.0
private

The documentation for this class was generated from the following files: