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

Neighbor search algorithm for building atom neighbor lists. More...

#include <neighbor_search.h>

Collaboration diagram for NeighborSearch:

Public Member Functions

 NeighborSearch ()=default
 Default constructor.
 ~NeighborSearch ()=default
 Default destructor.
void init (BaseCell &cell, double sr)
 Initialize the neighbor search with unit cell and search radius.
void build_neighbors ()
 Build the neighbor list for all inside atoms.
void refresh_mdcell (const MDCell &cell, double cutoff)
NeighborList & get_neighbor_list ()
 Get the constructed neighbor list.
const NeighborList & get_neighbor_list () const
 Get the constructed neighbor list (const version).
double get_search_radius () const
 Get the search radius.
const std::vector< NeighborAtom > & get_all_atoms () const
 Get all atoms (including periodic images).
const std::vector< NeighborAtom > & get_inside_atoms () const
 Get atoms inside the local MPI domain.
const std::vector< NeighborAtom > & get_ghost_atoms () const
 Get ghost atoms (neighbors of inside atoms).

Private Member Functions

double cross_product_norm (double a1, double a2, double a3, double b1, double b2, double b3)
void init_from_unitcell_ (const UnitCell &ucell, double sr)
 Check and compute expansion layer counts.
void init_from_mdcell_ (const MDCell &cell, double sr)
void check_expand_condition (const UnitCell &ucell, int &glayerX_minus, int &glayerX, int &glayerY_minus, int &glayerY, int &glayerZ_minus, int &glayerZ)
void set_member_variables (const UnitCell &ucell, int glayerX_minus, int glayerX, int glayerY_minus, int glayerY, int glayerZ_minus, int glayerZ)
 Set member variables by generating periodic images.
void filter_candidate_neighbors_ (double cutoff, double lat0)

Private Attributes

double search_radius_ = 0.0
 Search radius in lattice units.
std::vector< NeighborAtom > all_atoms_
 All atoms including periodic images.
std::vector< NeighborAtom > inside_atoms_
 Atoms inside the local MPI domain.
std::vector< NeighborAtom > ghost_atoms_
 Ghost atoms (neighbors from other domains or images).
NeighborList neighbor_list_
 The constructed neighbor list.
NeighborList candidate_neighbor_list_
BinManager bin_manager_
 Bin manager for efficient neighbor search.

Static Private Attributes

static constexpr int positive_layer_offset = 1
 Offset added to expansion layers in positive directions.
static constexpr int neighbor_reserve_factor = 2
 Reserve factor for neighbor list capacity estimation.

Detailed Description

Neighbor search algorithm for building atom neighbor lists.

This class implements a neighbor search algorithm that finds all atoms within a given cutoff radius. It uses a binning strategy for efficiency and supports MPI parallelization by decomposing the simulation domain.

The workflow is:

  1. Call init() to initialize with unit cell and search radius
  2. Call build_neighbors() to construct the neighbor list
  3. Access results via get_neighbor_list()

Constructor & Destructor Documentation

◆ NeighborSearch()

NeighborSearch::NeighborSearch ( )
default

Default constructor.

◆ ~NeighborSearch()

NeighborSearch::~NeighborSearch ( )
default

Default destructor.

Member Function Documentation

◆ build_neighbors()

void NeighborSearch::build_neighbors ( )

Build the neighbor list for all inside atoms.

Must be called after init(). Uses binning to efficiently find all neighbors within the search radius.

Here is the caller graph for this function:

◆ check_expand_condition()

void NeighborSearch::check_expand_condition ( const UnitCell & ucell,
int & glayerX_minus,
int & glayerX,
int & glayerY_minus,
int & glayerY,
int & glayerZ_minus,
int & glayerZ )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cross_product_norm()

double NeighborSearch::cross_product_norm ( double a1,
double a2,
double a3,
double b1,
double b2,
double b3 )
private
Here is the caller graph for this function:

◆ filter_candidate_neighbors_()

void NeighborSearch::filter_candidate_neighbors_ ( double cutoff,
double lat0 )
private
Here is the caller graph for this function:

◆ get_all_atoms()

const std::vector< NeighborAtom > & NeighborSearch::get_all_atoms ( ) const

Get all atoms (including periodic images).

Returns
Const reference to the vector of all atoms.
Here is the caller graph for this function:

◆ get_ghost_atoms()

const std::vector< NeighborAtom > & NeighborSearch::get_ghost_atoms ( ) const

Get ghost atoms (neighbors of inside atoms).

Returns
Const reference to the vector of ghost atoms.

◆ get_inside_atoms()

const std::vector< NeighborAtom > & NeighborSearch::get_inside_atoms ( ) const

Get atoms inside the local MPI domain.

Returns
Const reference to the vector of inside atoms.
Here is the caller graph for this function:

◆ get_neighbor_list() [1/2]

NeighborList & NeighborSearch::get_neighbor_list ( )

Get the constructed neighbor list.

Returns
Reference to the NeighborList object.
Here is the caller graph for this function:

◆ get_neighbor_list() [2/2]

const NeighborList & NeighborSearch::get_neighbor_list ( ) const

Get the constructed neighbor list (const version).

Returns
Const reference to the NeighborList object.

◆ get_search_radius()

double NeighborSearch::get_search_radius ( ) const

Get the search radius.

Returns
Search radius in lattice units.

◆ init()

void NeighborSearch::init ( BaseCell & cell,
double sr )

Initialize the neighbor search with unit cell and search radius.

This method sets up the domain decomposition, identifies inside and ghost atoms, and prepares internal data structures.

Parameters
ucellUnit cell providing atom positions and lattice info.
srSearch radius (cutoff distance) in Bohr.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_from_mdcell_()

void NeighborSearch::init_from_mdcell_ ( const MDCell & cell,
double sr )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_from_unitcell_()

void NeighborSearch::init_from_unitcell_ ( const UnitCell & ucell,
double sr )
private

Check and compute expansion layer counts.

Determines how many periodic images are needed to cover the search radius in each lattice direction.

Parameters
ucellUnit cell providing lattice vectors.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ refresh_mdcell()

void NeighborSearch::refresh_mdcell ( const MDCell & cell,
double cutoff )

Refresh positions and derive the physical-cutoff list from a cached cutoff-plus-skin candidate list for an MDCell.

Here is the call graph for this function:

◆ set_member_variables()

void NeighborSearch::set_member_variables ( const UnitCell & ucell,
int glayerX_minus,
int glayerX,
int glayerY_minus,
int glayerY,
int glayerZ_minus,
int glayerZ )
private

Set member variables by generating periodic images.

Populates all_atoms_ with atoms from the unit cell and all required periodic images.

Parameters
ucellUnit cell providing atom positions.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ all_atoms_

std::vector<NeighborAtom> NeighborSearch::all_atoms_
private

All atoms including periodic images.

◆ bin_manager_

BinManager NeighborSearch::bin_manager_
private

Bin manager for efficient neighbor search.

◆ candidate_neighbor_list_

NeighborList NeighborSearch::candidate_neighbor_list_
private

◆ ghost_atoms_

std::vector<NeighborAtom> NeighborSearch::ghost_atoms_
private

Ghost atoms (neighbors from other domains or images).

◆ inside_atoms_

std::vector<NeighborAtom> NeighborSearch::inside_atoms_
private

Atoms inside the local MPI domain.

◆ neighbor_list_

NeighborList NeighborSearch::neighbor_list_
private

The constructed neighbor list.

◆ neighbor_reserve_factor

int NeighborSearch::neighbor_reserve_factor = 2
staticconstexprprivate

Reserve factor for neighbor list capacity estimation.

◆ positive_layer_offset

int NeighborSearch::positive_layer_offset = 1
staticconstexprprivate

Offset added to expansion layers in positive directions.

◆ search_radius_

double NeighborSearch::search_radius_ = 0.0
private

Search radius in lattice units.


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