Skip to content

Commit 5eea6d8

Browse files
committed
Refactor: remove GlobalC::GridD
1 parent 7d8fce1 commit 5eea6d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+544
-487
lines changed

source/module_base/tool_title.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ namespace ModuleBase
1717

1818
void TITLE(const std::string &class_name,const std::string &function_name,const bool disable)
1919
{
20-
if (disable)
21-
{
22-
return;//no output
23-
}
20+
// if (disable)
21+
// {
22+
// return;//no output
23+
// }
2424
#ifdef __NORMAL
2525
std::cout<<" ==> "<<class_name<<"::"<<function_name<<"\t"
2626
<<ModuleBase::GlobalFunc::MemAvailable()/1024.0/1024<<" GB\t"
@@ -37,10 +37,10 @@ void TITLE(const std::string &class_name,const std::string &function_name,const
3737

3838
void TITLE(std::ofstream &ofs,const std::string &class_name,const std::string &function_name,const bool disable)
3939
{
40-
if (disable)
41-
{
42-
return;//no output
43-
}
40+
// if (disable)
41+
// {
42+
// return;//no output
43+
// }
4444
#ifdef __NORMAL
4545
std::cout<<"\n\n ==> "<<class_name<<"::"<<function_name<<"\t"
4646
<<ModuleBase::GlobalFunc::MemAvailable()/1024.0/1024<<" GB\t"

source/module_cell/module_neighbor/sltk_grid_driver.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
#include <omp.h>
99
#endif
1010

11-
namespace GlobalC
12-
{
13-
Grid_Driver GridD;
14-
}
1511
Grid_Driver::Grid_Driver(
1612
const int &test_d_in,
1713
const int &test_grid_in)

source/module_cell/module_neighbor/sltk_grid_driver.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,4 @@ class Grid_Driver : public Grid
125125
const short box_y,
126126
const short box_z) const;
127127
};
128-
129-
namespace GlobalC
130-
{
131-
extern Grid_Driver GridD;
132-
}
133128
#endif

source/module_elecstate/module_dm/test/test_dm_R_init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class DMTest : public testing::Test
100100
#endif
101101
};
102102

103-
// test for construct DMR from GlobalC::GridD and UnitCell
103+
// test for construct DMR from GridD and UnitCell
104104
TEST_F(DMTest, DMInit1)
105105
{
106106
// initalize a kvectors

source/module_esolver/esolver_gets.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,25 @@ void ESolver_GetS::runner(UnitCell& ucell, const int istep)
9494
ucell.infoNL.get_rcutmax_Beta(),
9595
PARAM.globalv.gamma_only_local);
9696

97+
Grid_Driver gd;
98+
9799
atom_arrange::search(PARAM.inp.search_pbc,
98100
GlobalV::ofs_running,
99-
GlobalC::GridD,
101+
gd,
100102
ucell,
101103
search_radius,
102104
PARAM.inp.test_atom_input);
103105

104106
Record_adj RA;
105-
RA.for_2d(ucell, GlobalC::GridD, this->pv, PARAM.globalv.gamma_only_local, orb_.cutoffs());
107+
RA.for_2d(ucell, gd, this->pv, PARAM.globalv.gamma_only_local, orb_.cutoffs());
106108

107109
if (this->p_hamilt == nullptr)
108110
{
109111
if (PARAM.inp.nspin == 4)
110112
{
111113
this->p_hamilt
112114
= new hamilt::HamiltLCAO<std::complex<double>, std::complex<double>>(ucell,
113-
GlobalC::GridD,
115+
gd,
114116
&this->pv,
115117
this->kv,
116118
*(two_center_bundle_.overlap_orb),
@@ -121,7 +123,7 @@ void ESolver_GetS::runner(UnitCell& ucell, const int istep)
121123
else
122124
{
123125
this->p_hamilt = new hamilt::HamiltLCAO<std::complex<double>, double>(ucell,
124-
GlobalC::GridD,
126+
gd,
125127
&this->pv,
126128
this->kv,
127129
*(two_center_bundle_.overlap_orb),
@@ -132,13 +134,13 @@ void ESolver_GetS::runner(UnitCell& ucell, const int istep)
132134

133135
const std::string fn = PARAM.globalv.global_out_dir + "SR.csr";
134136
std::cout << " The file is saved in " << fn << std::endl;
135-
ModuleIO::output_SR(pv, GlobalC::GridD, this->p_hamilt, fn);
137+
ModuleIO::output_SR(pv, gd, this->p_hamilt, fn);
136138

137139
if (PARAM.inp.out_mat_r)
138140
{
139141
cal_r_overlap_R r_matrix;
140142
r_matrix.init(ucell,pv, orb_);
141-
r_matrix.out_rR(ucell,istep);
143+
r_matrix.out_rR(ucell, gd, istep);
142144
}
143145

144146
ModuleBase::timer::tick("ESolver_GetS", "runner");

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,17 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
259259
// 14) initialize rdmft, added by jghan
260260
if( PARAM.inp.rdmft == true )
261261
{
262-
rdmft_solver.init( this->GG, this->GK, this->pv, ucell, this->kv, *(this->pelec),
263-
this->orb_, two_center_bundle_, PARAM.inp.dft_functional, PARAM.inp.rdmft_power_alpha);
262+
rdmft_solver.init(this->GG,
263+
this->GK,
264+
this->pv,
265+
ucell,
266+
this->gd,
267+
this->kv,
268+
*(this->pelec),
269+
this->orb_,
270+
two_center_bundle_,
271+
PARAM.inp.dft_functional,
272+
PARAM.inp.rdmft_power_alpha);
264273
}
265274

266275
ModuleBase::timer::tick("ESolver_KS_LCAO", "before_all_runners");
@@ -296,6 +305,7 @@ void ESolver_KS_LCAO<TK, TR>::cal_force(UnitCell& ucell, ModuleBase::matrix& for
296305
PARAM.inp.test_force,
297306
PARAM.inp.test_stress,
298307
ucell,
308+
this->gd,
299309
this->pv,
300310
this->pelec,
301311
this->psi,
@@ -458,7 +468,7 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
458468
this->kv,
459469
orb_.cutoffs(),
460470
this->pelec->wg,
461-
GlobalC::GridD
471+
this->gd
462472
#ifdef __EXX
463473
,
464474
this->exx_lri_double ? &this->exx_lri_double->Hexxs : nullptr,
@@ -484,7 +494,7 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
484494
this->GK,
485495
this->kv,
486496
this->pelec->wg,
487-
GlobalC::GridD,
497+
this->gd,
488498
orb_.cutoffs(),
489499
this->two_center_bundle_
490500
#ifdef __EXX
@@ -1036,7 +1046,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
10361046
this->pelec->klist->kvec_d,
10371047
ucell,
10381048
orb_,
1039-
GlobalC::GridD,
1049+
this->gd,
10401050
&(this->pv),
10411051
*(this->psi),
10421052
dynamic_cast<const elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM(),
@@ -1136,14 +1146,23 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
11361146
two_center_bundle_,
11371147
orb_,
11381148
ucell,
1139-
GlobalC::GridD,
1149+
this->gd,
11401150
this->kv,
11411151
this->p_hamilt);
1142-
1152+
11431153
//! Perform Mulliken charge analysis
11441154
if (PARAM.inp.out_mul)
11451155
{
1146-
ModuleIO::cal_mag(&(this->pv), this->p_hamilt, this->kv, this->pelec, this->two_center_bundle_, this->orb_, ucell, istep, true);
1156+
ModuleIO::cal_mag(&(this->pv),
1157+
this->p_hamilt,
1158+
this->kv,
1159+
this->pelec,
1160+
this->two_center_bundle_,
1161+
this->orb_,
1162+
ucell,
1163+
this->gd,
1164+
istep,
1165+
true);
11471166
}
11481167
}
11491168

@@ -1189,7 +1208,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
11891208
&hR,
11901209
&ucell,
11911210
orb_.cutoffs(),
1192-
&GlobalC::GridD,
1211+
&this->gd,
11931212
two_center_bundle_.kinetic_orb.get());
11941213

11951214
const int nspin_k = (PARAM.inp.nspin == 2 ? 2 : 1);
@@ -1228,12 +1247,12 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12281247
PARAM.inp.wannier_spin);
12291248

12301249
myWannier.calculate(ucell,
1231-
this->pelec->ekb,
1232-
this->pw_wfc,
1233-
this->pw_big,
1234-
this->sf,
1235-
this->kv,
1236-
this->psi,
1250+
this->pelec->ekb,
1251+
this->pw_wfc,
1252+
this->pw_big,
1253+
this->sf,
1254+
this->kv,
1255+
this->psi,
12371256
&(this->pv));
12381257
}
12391258
else if (PARAM.inp.wannier_method == 2)
@@ -1247,7 +1266,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12471266
PARAM.inp.wannier_spin,
12481267
orb_);
12491268

1250-
myWannier.calculate(ucell,this->pelec->ekb, this->kv, *(this->psi), &(this->pv));
1269+
myWannier.calculate(ucell, this->gd, this->pelec->ekb, this->kv, *(this->psi), &(this->pv));
12511270
}
12521271
std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "Wave function to Wannier90");
12531272
}
@@ -1259,12 +1278,10 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12591278
{
12601279
std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "Berry phase calculation");
12611280
berryphase bp(&(this->pv));
1262-
bp.lcao_init(ucell,
1263-
this->kv,
1264-
this->GridT,
1265-
orb_); // additional step before calling
1266-
// macroscopic_polarization (why capitalize
1267-
// the function name?)
1281+
bp.lcao_init(ucell, this->gd, this->kv, this->GridT, orb_);
1282+
// additional step before calling
1283+
// macroscopic_polarization (why capitalize
1284+
// the function name?)
12681285
bp.Macroscopic_polarization(ucell,this->pw_wfc->npwk_max, this->psi, this->pw_rho, this->pw_wfc, this->kv);
12691286
std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "Berry phase calculation");
12701287
}

source/module_esolver/esolver_ks_lcao.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class ESolver_KS_LCAO : public ESolver_KS<TK> {
5858
// we will get rid of this class soon, don't use it, mohan 2024-03-28
5959
Record_adj RA;
6060

61+
Grid_Driver gd;
62+
6163
// 2d block-cyclic distribution info
6264
Parallel_Orbitals pv;
6365

source/module_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ void ESolver_KS_LCAO_TDDFT::after_scf(UnitCell& ucell, const int istep)
299299
= dynamic_cast<elecstate::ElecStateLCAO<std::complex<double>>*>(this->pelec)->get_DM();
300300

301301
ModuleIO::write_current(ucell,
302+
this->gd,
302303
istep,
303304
this->psi,
304305
pelec,

source/module_esolver/lcao_before_scf.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
8181

8282
atom_arrange::search(PARAM.inp.search_pbc,
8383
GlobalV::ofs_running,
84-
GlobalC::GridD,
84+
this->gd,
8585
ucell,
8686
search_radius,
8787
PARAM.inp.test_atom_input);
@@ -111,7 +111,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
111111
this->pw_rho->nplane,
112112
this->pw_rho->startz_current,
113113
ucell,
114-
GlobalC::GridD,
114+
this->gd,
115115
dr_uniform,
116116
rcuts,
117117
psi_u,
@@ -128,7 +128,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
128128
// (2)For each atom, calculate the adjacent atoms in different cells
129129
// and allocate the space for H(R) and S(R).
130130
// If k point is used here, allocate HlocR after atom_arrange.
131-
this->RA.for_2d(ucell, GlobalC::GridD, this->pv, PARAM.globalv.gamma_only_local, orb_.cutoffs());
131+
this->RA.for_2d(ucell, this->gd, this->pv, PARAM.globalv.gamma_only_local, orb_.cutoffs());
132132

133133
// 2. density matrix extrapolation
134134

@@ -190,7 +190,7 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
190190
PARAM.globalv.gamma_only_local ? &(this->GG) : nullptr,
191191
PARAM.globalv.gamma_only_local ? nullptr : &(this->GK),
192192
ucell,
193-
GlobalC::GridD,
193+
this->gd,
194194
&this->pv,
195195
this->pelec->pot,
196196
this->kv,
@@ -214,15 +214,11 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
214214
{
215215
const Parallel_Orbitals* pv = &this->pv;
216216
// build and save <psi(0)|alpha(R)> at beginning
217-
GlobalC::ld.build_psialpha(PARAM.inp.cal_force,
218-
ucell,
219-
orb_,
220-
GlobalC::GridD,
221-
*(two_center_bundle_.overlap_orb_alpha));
217+
GlobalC::ld.build_psialpha(PARAM.inp.cal_force, ucell, orb_, this->gd, *(two_center_bundle_.overlap_orb_alpha));
222218

223219
if (PARAM.inp.deepks_out_unittest)
224220
{
225-
GlobalC::ld.check_psialpha(PARAM.inp.cal_force, ucell, orb_, GlobalC::GridD);
221+
GlobalC::ld.check_psialpha(PARAM.inp.cal_force, ucell, orb_, this->gd);
226222
}
227223
}
228224
#endif

0 commit comments

Comments
 (0)