Skip to content

Commit 38093a1

Browse files
committed
add teardown function in setup_pwrho
1 parent 3268459 commit 38093a1

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

source/source_esolver/esolver_fp.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ ESolver_FP::ESolver_FP()
2727

2828
ESolver_FP::~ESolver_FP()
2929
{
30-
if (pw_rho_flag == true)
31-
{
32-
delete this->pw_rho;
33-
this->pw_rho_flag = false;
34-
}
35-
if (PARAM.globalv.double_grid)
36-
{
37-
delete this->pw_rhod;
38-
}
3930
delete this->pelec;
4031
}
4132

@@ -265,6 +256,9 @@ void ESolver_FP::after_all_runners(UnitCell& ucell)
265256
GlobalV::ofs_running << std::setprecision(16);
266257
GlobalV::ofs_running << " !FINAL_ETOT_IS " << this->pelec->f_en.etot * ModuleBase::Ry_to_eV << " eV" << std::endl;
267258
GlobalV::ofs_running << " --------------------------------------------\n\n" << std::endl;
259+
260+
// mohan add 20251005
261+
pw::teardown_pwrho(this->pw_rho_flag, PARAM.globalv.double_grid, this->pw_rho, this->pw_rhod);
268262
}
269263

270264
} // namespace ModuleESolver

source/source_pw/module_pwdft/setup_pwrho.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,23 @@ void pw::setup_pwrho(
117117
return;
118118
}
119119

120+
121+
void pw::teardown_pwrho(bool &pw_rho_flag,
122+
const bool double_grid,
123+
ModulePW::PW_Basis* &pw_rho, // pw for rhod
124+
ModulePW::PW_Basis* &pw_rhod) // pw for rhod
125+
{
126+
if (pw_rho_flag == true)
127+
{
128+
delete pw_rho;
129+
pw_rho_flag = false;
130+
}
131+
132+
if (double_grid)
133+
{
134+
delete pw_rhod;
135+
}
136+
137+
return;
138+
}
139+

source/source_pw/module_pwdft/setup_pwrho.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ void setup_pwrho(
2020
const std::string &classname,
2121
const Input_para& inp); // input parameters *
2222

23+
24+
void teardown_pwrho(bool &pw_rho_flag,
25+
const bool double_grid,
26+
ModulePW::PW_Basis* &pw_rho, // pw for rhod
27+
ModulePW::PW_Basis* &pw_rhod); // pw for rhod
28+
2329
}
2430

2531

0 commit comments

Comments
 (0)