Skip to content

Commit 0f0c838

Browse files
authored
Remove DiagH Base class in pw (#5225)
* Remove DiagoDavid Base class * Remove Diago_DavSubspace Base class * Remove DiagoCG Base class * Remove DiagoBPCG Base class * Remove DiagoBPCG Base class override * Update docs * Remove DiagH_mock in test_hsolver * Remove DiagH_mock in test_hsolver
1 parent e9250db commit 0f0c838

File tree

6 files changed

+13
-37
lines changed

6 files changed

+13
-37
lines changed

source/module_hsolver/diago_bpcg.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace hsolver {
2424
* @tparam Device The device used for calculations (e.g., cpu or gpu).
2525
*/
2626
template <typename T = std::complex<double>, typename Device = base_device::DEVICE_CPU>
27-
class DiagoBPCG : public DiagH<T, Device>
27+
class DiagoBPCG
2828
{
2929
private:
3030
// Note GetTypeReal<T>::type will
@@ -56,15 +56,15 @@ class DiagoBPCG : public DiagH<T, Device>
5656
void init_iter(const psi::Psi<T, Device> &psi_in);
5757

5858
/**
59-
* @brief Diagonalize the Hamiltonian using the CG method.
59+
* @brief Diagonalize the Hamiltonian using the BPCG method.
6060
*
61-
* This function is an override function for the CG method. It is called by the HsolverPW::solve() function.
61+
* This function is called by the HsolverPW::solve() function.
6262
*
6363
* @param phm_in A pointer to the hamilt::Hamilt object representing the Hamiltonian operator.
6464
* @param psi The input wavefunction psi matrix with [dim: n_basis x n_band, column major].
6565
* @param eigenvalue_in Pointer to the eigen array with [dim: n_band, column major].
6666
*/
67-
void diag(hamilt::Hamilt<T, Device> *phm_in, psi::Psi<T, Device> &psi, Real *eigenvalue_in) override;
67+
void diag(hamilt::Hamilt<T, Device> *phm_in, psi::Psi<T, Device> &psi, Real *eigenvalue_in);
6868

6969

7070
private:

source/module_hsolver/diago_cg.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace hsolver {
1414

1515
template <typename T, typename Device = base_device::DEVICE_CPU>
16-
class DiagoCG final : public DiagH<T, Device>
16+
class DiagoCG final
1717
{
1818
// private: accessibility within class is private by default
1919
// Note GetTypeReal<T>::type will
@@ -36,11 +36,11 @@ class DiagoCG final : public DiagH<T, Device>
3636
const int& pw_diag_nmax,
3737
const int& nproc_in_pool);
3838

39-
~DiagoCG() override;
39+
~DiagoCG();
4040

4141
// virtual void init(){};
4242
// refactor hpsi_info
43-
// this is the override function diag() for CG method
43+
// this is the diag() function for CG method
4444
void diag(const Func& hpsi_func, const Func& spsi_func, ct::Tensor& psi, ct::Tensor& eigen, const ct::Tensor& prec = {});
4545

4646
private:

source/module_hsolver/diago_dav_subspace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace hsolver
1111
{
1212

1313
template <typename T = std::complex<double>, typename Device = base_device::DEVICE_CPU>
14-
class Diago_DavSubspace : public DiagH<T, Device>
14+
class Diago_DavSubspace
1515
{
1616
private:
1717
// Note GetTypeReal<T>::type will
@@ -29,7 +29,7 @@ class Diago_DavSubspace : public DiagH<T, Device>
2929
const bool& need_subspace_in,
3030
const diag_comm_info& diag_comm_in);
3131

32-
virtual ~Diago_DavSubspace() override;
32+
~Diago_DavSubspace();
3333

3434
// See diago_david.h for information on the HPsiFunc function type
3535
using HPsiFunc = std::function<void(T*, T*, const int, const int)>;

source/module_hsolver/diago_david.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace hsolver
88
{
99

1010
template <typename T = std::complex<double>, typename Device = base_device::DEVICE_CPU>
11-
class DiagoDavid : public DiagH<T, Device>
11+
class DiagoDavid
1212
{
1313
private:
1414
// Note GetTypeReal<T>::type will
@@ -25,7 +25,7 @@ class DiagoDavid : public DiagH<T, Device>
2525
const bool use_paw_in,
2626
const diag_comm_info& diag_comm_in);
2727

28-
virtual ~DiagoDavid() override;
28+
~DiagoDavid();
2929

3030

3131
// declare type of matrix-blockvector functions.

source/module_hsolver/hsolver_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void HSolverPW<T, Device>::solve(hamilt::Hamilt<T, Device>* pHamilt,
228228
const std::initializer_list<std::string> _methods = {"cg", "dav", "dav_subspace", "bpcg"};
229229
if (std::find(std::begin(_methods), std::end(_methods), this->method) == std::end(_methods))
230230
{
231-
ModuleBase::WARNING_QUIT("HSolverPW::solve", "This method of DiagH is not supported!");
231+
ModuleBase::WARNING_QUIT("HSolverPW::solve", "This type of eigensolver is not supported!");
232232
}
233233

234234
// prepare for the precondition of diagonalization

source/module_hsolver/test/test_hsolver.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,4 @@ class TestHSolver : public ::testing::Test
8383

8484
// double test_diagethr_d = hs_d.set_diagethr(0.0, 0, 0, 0.0);
8585
// EXPECT_EQ(test_diagethr_d, 0.0);
86-
// }
87-
namespace hsolver
88-
{
89-
template <typename T, typename Device = base_device::DEVICE_CPU>
90-
class DiagH_mock : public DiagH<T, Device>
91-
{
92-
private:
93-
using Real = typename GetTypeReal<T>::type;
94-
95-
public:
96-
DiagH_mock()
97-
{
98-
}
99-
~DiagH_mock()
100-
{
101-
}
102-
103-
void diag(hamilt::Hamilt<T, Device>* phm_in, psi::Psi<T, Device>& psi, Real* eigenvalue_in)
104-
{
105-
return;
106-
}
107-
};
108-
template class DiagH_mock<std::complex<float>>;
109-
template class DiagH_mock<std::complex<double>>;
110-
}
86+
// }

0 commit comments

Comments
 (0)