Skip to content

Commit 0b727a0

Browse files
author
abacus_fixer
committed
refactor(exx): ESolver_KS owns Exx_Info value object
Change ESolver_KS from holding a pointer to GlobalC::exx_info to owning its own Exx_Info value member (exx_info_obj_). The constructor copies the content from GlobalC::exx_info (initialized by Input_Conv::Convert) into the owned object, so ESolver internals now operate on their own copy. The exx_info_ pointer still points to exx_info_obj_ for uniform access, preserving the parameter-passing pattern established in the previous commits. This breaks the runtime dependency on GlobalC::exx_info from ESolver internals and prepares for removing the global entirely in the next commit. GlobalC::exx_info is kept for now as other modules still reference it during the transition.
1 parent 2dc055d commit 0b727a0

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

source/source_esolver/esolver_ks.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ namespace ModuleESolver
2121

2222
ESolver_KS::ESolver_KS()
2323
{
24-
exx_info_ = &GlobalC::exx_info;
24+
// ESolver owns its own Exx_Info object, copied from the global instance
25+
// initialized by Input_Conv::Convert(). This breaks the dependency on
26+
// GlobalC::exx_info from ESolver internals; the global will be removed
27+
// in a follow-up commit.
28+
exx_info_obj_ = GlobalC::exx_info;
2529
}
2630

2731

source/source_esolver/esolver_ks.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
#include "source_estate/module_charge/charge_mixing.h" // use charge mixing
88
#include "source_hamilt/hamilt.h" // use Hamiltonian
99
#include "source_hamilt/hamilt_base.h" // use Hamiltonian base class
10+
#include "source_hamilt/module_xc/exx_info.h" // ESolver owns Exx_Info value
1011
#include "source_lcao/module_dftu/dftu.h" // mohan add 20251107
1112
#include "source_pw/module_pwdft/vnl_pw.h"
1213

13-
/// forward declaration for EXX info bridge
14-
struct Exx_Info;
15-
1614
namespace ModuleESolver
1715
{
1816

@@ -77,8 +75,12 @@ class ESolver_KS : public ESolver_FP
7775
bool oscillate_esolver = false; // whether esolver is oscillated
7876
bool scf_nmax_flag = false; // whether scf has reached nmax, mohan add 20250921
7977

80-
/// EXX info bridge, points to GlobalC::exx_info for now
81-
Exx_Info* exx_info_ = nullptr;
78+
/// EXX info owned by ESolver, copied from GlobalC::exx_info during construction.
79+
/// Will become the sole owner after GlobalC::exx_info is removed.
80+
Exx_Info exx_info_obj_;
81+
82+
/// Pointer to the owned Exx_Info object, for uniform access pattern.
83+
Exx_Info* exx_info_ = &exx_info_obj_;
8284
};
8385
} // namespace ModuleESolver
8486
#endif

0 commit comments

Comments
 (0)