ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
spar_hsr.h
Go to the documentation of this file.
1#ifndef SPARSE_FORMAT_HSR_H
2#define SPARSE_FORMAT_HSR_H
3
5
9
10#ifdef __EXX
11#include <RI/global/Tensor.h>
12#endif
13
14namespace sparse_format
15{
16#ifdef __MPI
17// Synchronize all processes' R coordinates,
18// otherwise HS_Arrays.all_R_coor would have different sizes on different processes,
19// causing MPI communication errors.
20void sync_all_R_coor(std::set<Abfs::Vector3_Order<int>>& all_R_coor, MPI_Comm comm);
21#endif
22
23template <typename T>
24std::set<Abfs::Vector3_Order<int>> get_R_range(const hamilt::HContainer<T>& hR)
25{
26 std::set<Abfs::Vector3_Order<int>> all_R_coor;
27 for (int iap = 0; iap < hR.size_atom_pairs(); ++iap)
28 {
29 const hamilt::AtomPair<T>& atom_pair = hR.get_atom_pair(iap);
30 for (int iR = 0; iR < atom_pair.get_R_size(); ++iR)
31 {
32 const ModuleBase::Vector3<int>& r_index = atom_pair.get_R_index(iR);
33 Abfs::Vector3_Order<int> dR(r_index.x, r_index.y, r_index.z);
34 all_R_coor.insert(dR);
35 }
36 }
37
38#ifdef __MPI
39 // Fix: Sync all_R_coor across processes
40 sparse_format::sync_all_R_coor(all_R_coor, MPI_COMM_WORLD);
41#endif
42
43 return all_R_coor;
44};
45
46template <typename TI, typename TO = TI>
48 const double& sparse_thr,
49 const hamilt::HContainer<TI>& hR,
50 std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, TO>>>& target);
51
52void clear_zero_elements(LCAO_HS_Arrays& HS_Arrays, const int& current_spin, const double& sparse_thr, TD_info* td_info);
53
54void destroy_HS_R_sparse(LCAO_HS_Arrays& HS_Arrays);
55
56} // namespace sparse_format
57
58#endif
Definition abfs_vector3_order.h:16
Definition lcao_hs_arrays.h:9
3 elements vector
Definition vector3.h:21
T x
Definition vector3.h:23
T y
Definition vector3.h:24
T z
Definition vector3.h:25
Definition parallel_orbitals.h:16
Definition td_info.h:18
Definition atom_pair.h:45
ModuleBase::Vector3< int > get_R_index(const int &index) const
Definition atom_pair.cpp:908
size_t get_R_size() const
Definition atom_pair.h:391
Definition hcontainer.h:147
size_t size_atom_pairs() const
calculate number of AtomPairs for current R index
Definition hcontainer.cpp:832
AtomPair< T > & get_atom_pair(int i, int j) const
return a reference of AtomPair with index of atom I and J in atom_pairs
Definition hcontainer.cpp:528
Definition spar_dh.h:14
void destroy_HS_R_sparse(LCAO_HS_Arrays &HS_Arrays)
Definition spar_hsr.cpp:228
void clear_zero_elements(LCAO_HS_Arrays &HS_Arrays, const int &current_spin, const double &sparse_thr, TD_info *td_info)
Definition spar_hsr.cpp:114
std::set< Abfs::Vector3_Order< int > > get_R_range(const hamilt::HContainer< T > &hR)
Definition spar_hsr.h:24
void sync_all_R_coor(std::set< Abfs::Vector3_Order< int > > &all_R_coor, MPI_Comm comm)
Definition spar_hsr.cpp:11
void cal_HContainer(const Parallel_Orbitals &pv, const double &sparse_thr, const hamilt::HContainer< TI > &hR, std::map< Abfs::Vector3_Order< int >, std::map< size_t, std::map< size_t, TO > > > &target)
Definition spar_hsr.cpp:71