ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
bin_manager.h
Go to the documentation of this file.
1#ifndef BIN_MANAGER_H
2#define BIN_MANAGER_H
3
4#include <vector>
8
15class Bin
16{
17public:
21 Bin() = default;
22
26 ~Bin() = default;
27
28 // ========== Getter methods ==========
29
34 const std::vector<ModuleNeighList::LocalAtomIndex>& get_atom_indices() const;
35
36 // ========== Setter methods (internal use) ==========
37
44 void set_id(int ix, int iy, int iz);
45
49 void clear_atoms();
50
56
57private:
59 int id_x_ = 0;
60
62 int id_y_ = 0;
63
65 int id_z_ = 0;
66
68 std::vector<ModuleNeighList::LocalAtomIndex> atom_indices_;
69};
70
85{
86public:
97 void init_bins(
98 double sr,
99 const std::vector<NeighborAtom>& all_atoms
100 );
101
110 void do_binning(const std::vector<NeighborAtom>& atoms);
111
123 NeighborList& neighbor_list,
124 const std::vector<NeighborAtom>& atoms,
125 const std::vector<NeighborAtom>& binned_atoms
126 );
127
131 void clear();
132
133 // ========== Getter methods ==========
134
139 int get_nbinx() const;
140
145 int get_nbiny() const;
146
151 int get_nbinz() const;
152
157 int get_total_bins() const;
158
164 int get_bin_atom_count(int bin_index) const;
165
166private:
168 double sradius_ = 0.0;
169
171 double x_min_ = 0.0;
172 double y_min_ = 0.0;
173 double z_min_ = 0.0;
174
176 double x_max_ = 0.0;
177 double y_max_ = 0.0;
178 double z_max_ = 0.0;
179
181 double bin_sizex_ = 0.0;
182 double bin_sizey_ = 0.0;
183 double bin_sizez_ = 0.0;
184
186 int nbinx_ = 1;
187 int nbiny_ = 1;
188 int nbinz_ = 1;
189
191 std::vector<Bin> bins_;
192
200 int bin_index(int ix, int iy, int iz) const;
201};
202
203#endif // BIN_MANAGER_H
Manager for binning atoms to accelerate neighbor search.
Definition bin_manager.h:85
double y_min_
Definition bin_manager.h:172
double x_min_
Minimum coordinates of the binned region.
Definition bin_manager.h:171
double sradius_
Search radius in lattice units.
Definition bin_manager.h:168
int get_nbinx() const
Get the number of bins in X direction.
Definition bin_manager.cpp:30
int get_nbinz() const
Get the number of bins in Z direction.
Definition bin_manager.cpp:38
double y_max_
Definition bin_manager.h:177
double bin_sizey_
Definition bin_manager.h:182
int get_nbiny() const
Get the number of bins in Y direction.
Definition bin_manager.cpp:34
void init_bins(double sr, const std::vector< NeighborAtom > &all_atoms)
Initialize the bin grid based on atom positions and search radius.
Definition bin_manager.cpp:56
double x_max_
Maximum coordinates of the binned region.
Definition bin_manager.h:176
int get_total_bins() const
Get the total number of bins.
Definition bin_manager.cpp:42
void do_binning(const std::vector< NeighborAtom > &atoms)
Assign atoms to their corresponding bins.
Definition bin_manager.cpp:141
int get_bin_atom_count(int bin_index) const
Get the number of atoms in a specific bin.
Definition bin_manager.cpp:46
int nbinx_
Number of bins in each direction.
Definition bin_manager.h:186
double bin_sizex_
Size of each bin in each direction.
Definition bin_manager.h:181
std::vector< Bin > bins_
All bins in the 3D grid (stored as flat array).
Definition bin_manager.h:191
int nbiny_
Definition bin_manager.h:187
void clear()
Clear all bins and reset internal state.
Definition bin_manager.cpp:268
double z_max_
Definition bin_manager.h:178
double z_min_
Definition bin_manager.h:173
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.
Definition bin_manager.cpp:179
int bin_index(int ix, int iy, int iz) const
Compute the flat index for a bin from its 3D coordinates.
Definition bin_manager.cpp:175
int nbinz_
Definition bin_manager.h:188
double bin_sizez_
Definition bin_manager.h:183
const std::vector< ModuleNeighList::LocalAtomIndex > & get_atom_indices() const
Get the atom indices stored in this bin.
Definition bin_manager.cpp:10
std::vector< ModuleNeighList::LocalAtomIndex > atom_indices_
Indices into the atom vector passed to BinManager::do_binning().
Definition bin_manager.h:68
void clear_atoms()
Clear all atoms from this bin.
Definition bin_manager.cpp:20
int id_z_
Z index in the 3D bin grid.
Definition bin_manager.h:65
Bin()=default
Default constructor.
int id_y_
Y index in the 3D bin grid.
Definition bin_manager.h:62
int id_x_
X index in the 3D bin grid.
Definition bin_manager.h:59
void set_id(int ix, int iy, int iz)
Set the grid indices for this bin.
Definition bin_manager.cpp:14
void add_atom_index(ModuleNeighList::LocalAtomIndex atom_index)
Add an atom index to this bin.
Definition bin_manager.cpp:24
~Bin()=default
Default destructor.
Definition neighbor_list.h:10
std::int32_t LocalAtomIndex
Definition neighbor_types.h:13