ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
neighbor_search.h
Go to the documentation of this file.
1#ifndef NEIGHBOR_SEARCH_H
2#define NEIGHBOR_SEARCH_H
3
9
10class MDCell;
11class UnitCell;
12
26{
27public:
31 NeighborSearch() = default;
32
36 ~NeighborSearch() = default;
37
38 // ========== Main public interface ==========
39
49 void init(BaseCell& cell, double sr);
50
57 void build_neighbors();
58
61 void refresh_mdcell(const MDCell& cell, double cutoff);
62
63
64 // ========== Getter methods ==========
70
75 const NeighborList& get_neighbor_list() const;
76
81 double get_search_radius() const;
82
87 const std::vector<NeighborAtom>& get_all_atoms() const;
88
93 const std::vector<NeighborAtom>& get_inside_atoms() const;
94
99 const std::vector<NeighborAtom>& get_ghost_atoms() const;
100
101private:
102 // ========== Internal methods ==========
103
104 double cross_product_norm(double a1, double a2, double a3,
105 double b1, double b2, double b3);
106
115 void init_from_unitcell_(const UnitCell& ucell, double sr);
116
117 void init_from_mdcell_(const MDCell& cell, double sr);
118
119 void check_expand_condition(const UnitCell& ucell, int& glayerX_minus, int& glayerX, int& glayerY_minus, int& glayerY, int& glayerZ_minus, int& glayerZ);
120
129 void set_member_variables(const UnitCell& ucell, int glayerX_minus, int glayerX, int glayerY_minus, int glayerY, int glayerZ_minus, int glayerZ);
130
131 // ========== Data members ==========
132
134 double search_radius_ = 0.0;
135
137 std::vector<NeighborAtom> all_atoms_;
138
140 std::vector<NeighborAtom> inside_atoms_;
141
143 std::vector<NeighborAtom> ghost_atoms_;
144
148
151
152 void filter_candidate_neighbors_(double cutoff, double lat0);
153
154 // ========== Compile-time constants ==========
155
157 static constexpr int positive_layer_offset = 1;
158
160 static constexpr int neighbor_reserve_factor = 2;
161};
162
163#endif // NEIGHBOR_SEARCH_H
Definition basecell.h:9
Manager for binning atoms to accelerate neighbor search.
Definition bin_manager.h:85
Definition mdcell.h:29
Definition neighbor_list.h:10
~NeighborSearch()=default
Default destructor.
static constexpr int positive_layer_offset
Offset added to expansion layers in positive directions.
Definition neighbor_search.h:157
std::vector< NeighborAtom > inside_atoms_
Atoms inside the local MPI domain.
Definition neighbor_search.h:140
double get_search_radius() const
Get the search radius.
Definition neighbor_search.cpp:16
double search_radius_
Search radius in lattice units.
Definition neighbor_search.h:134
std::vector< NeighborAtom > ghost_atoms_
Ghost atoms (neighbors from other domains or images).
Definition neighbor_search.h:143
NeighborList & get_neighbor_list()
Get the constructed neighbor list.
Definition neighbor_search.cpp:32
NeighborSearch()=default
Default constructor.
BinManager bin_manager_
Bin manager for efficient neighbor search.
Definition neighbor_search.h:150
const std::vector< NeighborAtom > & get_inside_atoms() const
Get atoms inside the local MPI domain.
Definition neighbor_search.cpp:24
void check_expand_condition(const UnitCell &ucell, int &glayerX_minus, int &glayerX, int &glayerY_minus, int &glayerY, int &glayerZ_minus, int &glayerZ)
Definition neighbor_search.cpp:238
void build_neighbors()
Build the neighbor list for all inside atoms.
Definition neighbor_search.cpp:162
void filter_candidate_neighbors_(double cutoff, double lat0)
Definition neighbor_search.cpp:201
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.
Definition neighbor_search.cpp:262
void init_from_unitcell_(const UnitCell &ucell, double sr)
Check and compute expansion layer counts.
Definition neighbor_search.cpp:101
void refresh_mdcell(const MDCell &cell, double cutoff)
Definition neighbor_search.cpp:170
std::vector< NeighborAtom > all_atoms_
All atoms including periodic images.
Definition neighbor_search.h:137
const std::vector< NeighborAtom > & get_ghost_atoms() const
Get ghost atoms (neighbors of inside atoms).
Definition neighbor_search.cpp:28
double cross_product_norm(double a1, double a2, double a3, double b1, double b2, double b3)
Definition neighbor_search.cpp:229
NeighborList candidate_neighbor_list_
Definition neighbor_search.h:147
void init(BaseCell &cell, double sr)
Initialize the neighbor search with unit cell and search radius.
Definition neighbor_search.cpp:148
void init_from_mdcell_(const MDCell &cell, double sr)
Definition neighbor_search.cpp:42
const std::vector< NeighborAtom > & get_all_atoms() const
Get all atoms (including periodic images).
Definition neighbor_search.cpp:20
static constexpr int neighbor_reserve_factor
Reserve factor for neighbor list capacity estimation.
Definition neighbor_search.h:160
NeighborList neighbor_list_
The constructed neighbor list.
Definition neighbor_search.h:146
Provide the basic information about unitcell.
Definition unitcell.h:16