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
6
7namespace sparse_format
8{
9#ifdef __MPI
10// Synchronize all processes' R coordinates,
11// otherwise HS_Arrays.all_R_coor would have different sizes on different processes,
12// causing MPI communication errors.
13void sync_all_R_coor(std::set<Abfs::Vector3_Order<int>>& all_R_coor, MPI_Comm comm);
14#endif
15
16template <typename T>
17std::set<Abfs::Vector3_Order<int>> get_R_range(const hamilt::HContainer<T>& hR)
18{
19 std::set<Abfs::Vector3_Order<int>> all_R_coor;
20 for (int iap = 0; iap < hR.size_atom_pairs(); ++iap)
21 {
22 const hamilt::AtomPair<T>& atom_pair = hR.get_atom_pair(iap);
23 for (int iR = 0; iR < atom_pair.get_R_size(); ++iR)
24 {
25 const auto& r_index = atom_pair.get_R_index(iR);
26 Abfs::Vector3_Order<int> dR(r_index.x, r_index.y, r_index.z);
27 all_R_coor.insert(dR);
28 }
29 }
30
31#ifdef __MPI
32 // Fix: Sync all_R_coor across processes
33 sparse_format::sync_all_R_coor(all_R_coor, MPI_COMM_WORLD);
34#endif
35
36 return all_R_coor;
37};
38
39using TAC = std::pair<int, std::array<int, 3>>;
40template <typename TK>
41void cal_HSR(const UnitCell& ucell,
42 const Parallel_Orbitals& pv,
43 LCAO_HS_Arrays& HS_Arrays,
44 const Grid_Driver& grid,
45 const int& current_spin,
46 const double& sparse_thr,
47 const int (&nmp)[3],
49#ifdef __EXX
50 ,
51 const std::vector<std::map<int, std::map<TAC, RI::Tensor<double>>>>* Hexxd = nullptr,
52 const std::vector<std::map<int, std::map<TAC, RI::Tensor<std::complex<double>>>>>* Hexxc = nullptr
53#endif
54);
55
56template <typename TI, typename TO = TI>
58 const double& sparse_thr,
59 const hamilt::HContainer<TI>& hR,
60 std::map<Abfs::Vector3_Order<int>, std::map<size_t, std::map<size_t, TO>>>& target);
61
62void clear_zero_elements(LCAO_HS_Arrays& HS_Arrays, const int& current_spin, const double& sparse_thr);
63
64void destroy_HS_R_sparse(LCAO_HS_Arrays& HS_Arrays);
65
66} // namespace sparse_format
67
68#endif
Definition abfs-vector3_order.h:16
Definition sltk_grid_driver.h:43
Definition LCAO_HS_arrays.hpp:9
Definition parallel_orbitals.h:9
Definition unitcell.h:17
Definition atom_pair.h:42
ModuleBase::Vector3< int > get_R_index(const int &index) const
Definition atom_pair.cpp:795
size_t get_R_size() const
Definition atom_pair.h:288
Definition hcontainer.h:144
size_t size_atom_pairs() const
calculate number of AtomPairs for current R index
Definition hcontainer.cpp:576
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:353
Definition hamilt.h:16
Definition spar_dh.h:13
std::pair< int, std::array< int, 3 > > TAC
Definition spar_hsr.h:39
void destroy_HS_R_sparse(LCAO_HS_Arrays &HS_Arrays)
Definition spar_hsr.cpp:346
void cal_HSR(const UnitCell &ucell, const Parallel_Orbitals &pv, LCAO_HS_Arrays &HS_Arrays, const Grid_Driver &grid, const int &current_spin, const double &sparse_thr, const int(&nmp)[3], hamilt::Hamilt< TK > *p_ham)
Definition spar_hsr.cpp:71
std::set< Abfs::Vector3_Order< int > > get_R_range(const hamilt::HContainer< T > &hR)
Definition spar_hsr.h:17
void clear_zero_elements(LCAO_HS_Arrays &HS_Arrays, const int &current_spin, const double &sparse_thr)
Definition spar_hsr.cpp:232
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:189
base device SOURCES math_hegvd_test cpp endif() if(ENABLE_GOOGLEBENCH) AddTest(TARGET PERF_MODULE_HSOLVER_KERNELS LIBS parameter $
Definition CMakeLists.txt:10