Skip to content

Commit 4891b2e

Browse files
Refactor: add const for Grid_Driver (deepmodeling#5725)
* Refactor: add const for Grid_Driver * add const for Find_atom() in unittests * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 1f9779d commit 4891b2e

File tree

98 files changed

+693
-685
lines changed

Some content is hidden

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

98 files changed

+693
-685
lines changed

source/module_cell/module_neighbor/sltk_grid_driver.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ Grid_Driver::~Grid_Driver()
2121
{
2222
}
2323

24-
25-
void Grid_Driver::Find_atom(
26-
const UnitCell &ucell,
27-
const ModuleBase::Vector3<double> &cartesian_pos,
28-
const int &ntype,
29-
const int &nnumber,
30-
AdjacentAtomInfo *adjs)
24+
void Grid_Driver::Find_atom(const UnitCell& ucell,
25+
const ModuleBase::Vector3<double>& cartesian_pos,
26+
const int& ntype,
27+
const int& nnumber,
28+
AdjacentAtomInfo* adjs) const
3129
{
3230
ModuleBase::timer::tick("Grid_Driver","Find_atom");
3331
// std::cout << "lenght in Find atom = " << atomlink[offset].fatom.getAdjacentSet()->getLength() << std::endl;

source/module_cell/module_neighbor/sltk_grid_driver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Grid_Driver : public Grid
7070
const ModuleBase::Vector3<double>& cartesian_posi,
7171
const int& ntype,
7272
const int& nnumber,
73-
AdjacentAtomInfo* adjs = nullptr);
73+
AdjacentAtomInfo* adjs = nullptr) const;
7474

7575
//==========================================================
7676
// EXPLAIN : The adjacent information for the input

source/module_elecstate/module_dm/density_matrix.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class DensityMatrix
6666
* @param GridD_in pointer of Grid_Driver object (used to find ajacent atoms)
6767
* @param ucell pointer of UnitCell object
6868
*/
69-
void init_DMR(Grid_Driver* GridD_in, const UnitCell* ucell);
69+
void init_DMR(const Grid_Driver* GridD_in, const UnitCell* ucell);
7070

7171
/**
7272
* @brief initialize density matrix DMR from UnitCell and RA

source/module_elecstate/module_dm/density_matrix_io.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace elecstate
1212

1313
// initialize density matrix DMR from UnitCell (mainly used in UnitTest)
1414
template <typename TK, typename TR>
15-
void DensityMatrix<TK, TR>::init_DMR(Grid_Driver* GridD_in, const UnitCell* ucell)
15+
void DensityMatrix<TK, TR>::init_DMR(const Grid_Driver* GridD_in, const UnitCell* ucell)
1616
{
1717
ModuleBase::TITLE("DensityMatrix", "init_DMR");
1818
// ensure _DMR is empty

source/module_elecstate/module_dm/test/test_dm_io.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void Grid_Driver::Find_atom(const UnitCell& ucell,
4848
const ModuleBase::Vector3<double>& tau,
4949
const int& T,
5050
const int& I,
51-
AdjacentAtomInfo* adjs)
51+
AdjacentAtomInfo* adjs) const
5252
{
5353
}
5454
Grid::Grid(const int& test_grid_in) : test_grid(test_grid_in)

source/module_elecstate/module_dm/test/tmp_mocks.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void Grid_Driver::Find_atom(const UnitCell& ucell,
7878
const ModuleBase::Vector3<double>& tau,
7979
const int& T,
8080
const int& I,
81-
AdjacentAtomInfo* adjs)
81+
AdjacentAtomInfo* adjs) const
8282
{
8383
adjs->adj_num = ucell.nat - 1;
8484
adjs->adjacent_tau.resize(ucell.nat);

source/module_hamilt_lcao/hamilt_lcaodft/FORCE.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Force_LCAO
5151
const bool isstress,
5252
ForceStressArrays& fsr, // mohan add 2024-06-16
5353
const UnitCell& ucell,
54-
Grid_Driver& gd,
54+
const Grid_Driver& gd,
5555
const psi::Psi<T>* psi,
5656
const elecstate::ElecState* pelec,
5757
ModuleBase::matrix& foverlap,
@@ -74,7 +74,7 @@ class Force_LCAO
7474

7575
// get the ds, dt, dvnl.
7676
void allocate(const UnitCell& ucell,
77-
Grid_Driver& gd,
77+
const Grid_Driver& gd,
7878
const Parallel_Orbitals& pv,
7979
ForceStressArrays& fsr, // mohan add 2024-06-15
8080
const TwoCenterBundle& two_center_bundle,

source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void Force_Stress_LCAO<T>::getForceStress(const bool isforce,
3636
const bool istestf,
3737
const bool istests,
3838
const UnitCell& ucell,
39-
Grid_Driver& gd,
39+
const Grid_Driver& gd,
4040
Parallel_Orbitals& pv,
4141
const elecstate::ElecState* pelec,
4242
const psi::Psi<T>* psi,
@@ -870,7 +870,7 @@ void Force_Stress_LCAO<double>::integral_part(const bool isGammaOnly,
870870
const bool isforce,
871871
const bool isstress,
872872
const UnitCell& ucell,
873-
Grid_Driver& gd,
873+
const Grid_Driver& gd,
874874
ForceStressArrays& fsr, // mohan add 2024-06-15
875875
const elecstate::ElecState* pelec,
876876
const psi::Psi<double>* psi,
@@ -923,7 +923,7 @@ void Force_Stress_LCAO<std::complex<double>>::integral_part(const bool isGammaOn
923923
const bool isforce,
924924
const bool isstress,
925925
const UnitCell& ucell,
926-
Grid_Driver& gd,
926+
const Grid_Driver& gd,
927927
ForceStressArrays& fsr, // mohan add 2024-06-15
928928
const elecstate::ElecState* pelec,
929929
const psi::Psi<std::complex<double>>* psi,

source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Force_Stress_LCAO
3434
const bool istestf,
3535
const bool istests,
3636
const UnitCell& ucell,
37-
Grid_Driver& gd,
37+
const Grid_Driver& gd,
3838
Parallel_Orbitals& pv,
3939
const elecstate::ElecState* pelec,
4040
const psi::Psi<T>* psi,
@@ -82,7 +82,7 @@ class Force_Stress_LCAO
8282
const bool isforce,
8383
const bool isstress,
8484
const UnitCell& ucell,
85-
Grid_Driver& gd,
85+
const Grid_Driver& gd,
8686
ForceStressArrays& fsr, // mohan add 2024-06-15
8787
const elecstate::ElecState* pelec,
8888
const psi::Psi<T>* psi,

source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
template <>
1919
void Force_LCAO<double>::allocate(const UnitCell& ucell,
20-
Grid_Driver& gd,
20+
const Grid_Driver& gd,
2121
const Parallel_Orbitals& pv,
2222
ForceStressArrays& fsr, // mohan add 2024-06-15
2323
const TwoCenterBundle& two_center_bundle,
@@ -176,7 +176,7 @@ void Force_LCAO<double>::ftable(const bool isforce,
176176
const bool isstress,
177177
ForceStressArrays& fsr, // mohan add 2024-06-16
178178
const UnitCell& ucell,
179-
Grid_Driver& gd,
179+
const Grid_Driver& gd,
180180
const psi::Psi<double>* psi,
181181
const elecstate::ElecState* pelec,
182182
ModuleBase::matrix& foverlap,

source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
template <>
2929
void Force_LCAO<std::complex<double>>::allocate(const UnitCell& ucell,
30-
Grid_Driver& gd,
30+
const Grid_Driver& gd,
3131
const Parallel_Orbitals& pv,
3232
ForceStressArrays& fsr, // mohan add 2024-06-15
3333
const TwoCenterBundle& two_center_bundle,
@@ -272,7 +272,7 @@ void Force_LCAO<std::complex<double>>::ftable(const bool isforce,
272272
const bool isstress,
273273
ForceStressArrays& fsr, // mohan add 2024-06-15
274274
const UnitCell& ucell,
275-
Grid_Driver& gd,
275+
const Grid_Driver& gd,
276276
const psi::Psi<std::complex<double>>* psi,
277277
const elecstate::ElecState* pelec,
278278
ModuleBase::matrix& foverlap,

source/module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ void init_basis_lcao(Parallel_Orbitals& pv,
2525
TwoCenterBundle& two_center_bundle,
2626
LCAO_Orbitals& orb);
2727

28-
2928
void build_Nonlocal_mu_new(const Parallel_Orbitals& pv,
3029
ForceStressArrays& fsr, // mohan 2024-06-16
3130
double* HlocR,
3231
const bool& calc_deri,
3332
const UnitCell& ucell,
3433
const LCAO_Orbitals& orb,
3534
const TwoCenterIntegrator& intor_orb_beta,
36-
Grid_Driver* GridD);
35+
const Grid_Driver* GridD);
3736

3837
/**
3938
* @brief prepare gird integration
@@ -164,7 +163,7 @@ void build_ST_new(ForceStressArrays& fsr,
164163
const LCAO_Orbitals& orb,
165164
const Parallel_Orbitals& pv,
166165
const TwoCenterBundle& two_center_bundle,
167-
Grid_Driver* GridD,
166+
const Grid_Driver* GridD,
168167
double* SHlocR,
169168
bool cal_syns = false,
170169
double dmax = 0.0);

source/module_hamilt_lcao/hamilt_lcaodft/LCAO_nl_mu.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void build_Nonlocal_mu_new(const Parallel_Orbitals& pv,
1616
const UnitCell& ucell,
1717
const LCAO_Orbitals& orb,
1818
const TwoCenterIntegrator& intor_orb_beta,
19-
Grid_Driver* GridD)
19+
const Grid_Driver* GridD)
2020
{
2121
ModuleBase::TITLE("LCAO_domain", "vnl_mu_new");
2222
ModuleBase::timer::tick("LCAO_domain", "vnl_mu_new");

source/module_hamilt_lcao/hamilt_lcaodft/LCAO_set_st.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ void build_ST_new(ForceStressArrays& fsr,
316316
const LCAO_Orbitals& orb,
317317
const Parallel_Orbitals& pv,
318318
const TwoCenterBundle& two_center_bundle,
319-
Grid_Driver* GridD,
319+
const Grid_Driver* GridD,
320320
double* HSloc,
321321
bool cal_syns,
322322
double dmax)

source/module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace hamilt
4545

4646
template <typename TK, typename TR>
4747
HamiltLCAO<TK, TR>::HamiltLCAO(const UnitCell& ucell,
48-
Grid_Driver& grid_d,
48+
const Grid_Driver& grid_d,
4949
const Parallel_Orbitals* paraV,
5050
const K_Vectors& kv_in,
5151
const TwoCenterIntegrator& intor_overlap_orb,
@@ -74,7 +74,7 @@ template <typename TK, typename TR>
7474
HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
7575
Gint_k* GK_in,
7676
const UnitCell& ucell,
77-
Grid_Driver& grid_d,
77+
const Grid_Driver& grid_d,
7878
const Parallel_Orbitals* paraV,
7979
elecstate::Potential* pot_in,
8080
const K_Vectors& kv_in,

source/module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class HamiltLCAO : public Hamilt<TK>
3333
HamiltLCAO(Gint_Gamma* GG_in,
3434
Gint_k* GK_in,
3535
const UnitCell& ucell,
36-
Grid_Driver& grid_d,
36+
const Grid_Driver& grid_d,
3737
const Parallel_Orbitals* paraV,
3838
elecstate::Potential* pot_in,
3939
const K_Vectors& kv_in,
@@ -52,7 +52,7 @@ class HamiltLCAO : public Hamilt<TK>
5252
* @brief Constructor of vacuum Operators, only HR and SR will be initialed as empty HContainer
5353
*/
5454
HamiltLCAO(const UnitCell& ucell,
55-
Grid_Driver& grid_d,
55+
const Grid_Driver& grid_d,
5656
const Parallel_Orbitals* paraV,
5757
const K_Vectors& kv_in,
5858
const TwoCenterIntegrator& intor_overlap_orb,

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/deepks_lcao.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DeePKS<OperatorLCAO<TK, TR>>::DeePKS(HS_Matrix_K<TK>* hsk_in,
2020
const std::vector<ModuleBase::Vector3<double>>& kvec_d_in,
2121
HContainer<TR>* hR_in,
2222
const UnitCell* ucell_in,
23-
Grid_Driver* GridD_in,
23+
const Grid_Driver* GridD_in,
2424
const TwoCenterIntegrator* intor_orb_alpha,
2525
const LCAO_Orbitals* ptr_orb,
2626
const int& nks_in,
@@ -47,7 +47,7 @@ DeePKS<OperatorLCAO<TK, TR>>::~DeePKS()
4747
#ifdef __DEEPKS
4848
// initialize_HR()
4949
template <typename TK, typename TR>
50-
void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::initialize_HR(Grid_Driver* GridD)
50+
void hamilt::DeePKS<hamilt::OperatorLCAO<TK, TR>>::initialize_HR(const Grid_Driver* GridD)
5151
{
5252
ModuleBase::TITLE("DeePKS", "initialize_HR");
5353
ModuleBase::timer::tick("DeePKS", "initialize_HR");

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/deepks_lcao.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DeePKS<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
3333
const std::vector<ModuleBase::Vector3<double>>& kvec_d_in,
3434
HContainer<TR>* hR_in,
3535
const UnitCell* ucell_in,
36-
Grid_Driver* GridD_in,
36+
const Grid_Driver* GridD_in,
3737
const TwoCenterIntegrator* intor_orb_alpha,
3838
const LCAO_Orbitals* ptr_orb,
3939
const int& nks_in,
@@ -59,7 +59,7 @@ class DeePKS<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
5959

6060
const UnitCell* ucell = nullptr;
6161

62-
Grid_Driver* gd = nullptr;
62+
const Grid_Driver* gd = nullptr;
6363

6464
HContainer<TR>* H_V_delta = nullptr;
6565

@@ -74,7 +74,7 @@ class DeePKS<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
7474
* HContainer is used to store the DeePKS real space Hamiltonian correction with specific <I,J,R> atom-pairs
7575
* the size of HR will be fixed after initialization
7676
*/
77-
void initialize_HR(Grid_Driver* GridD);
77+
void initialize_HR(const Grid_Driver* GridD);
7878

7979
/**
8080
* @brief calculate the DeePKS correction matrix with specific <I,J,R> atom-pairs

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/dftu_lcao.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ hamilt::DFTU<hamilt::OperatorLCAO<TK, TR>>::DFTU(HS_Matrix_K<TK>* hsk_in,
1616
const std::vector<ModuleBase::Vector3<double>>& kvec_d_in,
1717
hamilt::HContainer<TR>* hR_in,
1818
const UnitCell& ucell_in,
19-
Grid_Driver* GridD_in,
19+
const Grid_Driver* GridD_in,
2020
const TwoCenterIntegrator* intor,
2121
const std::vector<double>& orb_cutoff,
2222
ModuleDFTU::DFTU* dftu_in)
@@ -42,7 +42,7 @@ hamilt::DFTU<hamilt::OperatorLCAO<TK, TR>>::~DFTU()
4242

4343
// initialize_HR()
4444
template <typename TK, typename TR>
45-
void hamilt::DFTU<hamilt::OperatorLCAO<TK, TR>>::initialize_HR(Grid_Driver* GridD)
45+
void hamilt::DFTU<hamilt::OperatorLCAO<TK, TR>>::initialize_HR(const Grid_Driver* GridD)
4646
{
4747
ModuleBase::TITLE("DFTU", "initialize_HR");
4848
ModuleBase::timer::tick("DFTU", "initialize_HR");

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/dftu_lcao.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class DFTU<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
3030
const std::vector<ModuleBase::Vector3<double>>& kvec_d_in,
3131
hamilt::HContainer<TR>* hR_in,
3232
const UnitCell& ucell_in,
33-
Grid_Driver* gridD_in,
33+
const Grid_Driver* gridD_in,
3434
const TwoCenterIntegrator* intor,
3535
const std::vector<double>& orb_cutoff,
3636
ModuleDFTU::DFTU* dftu_in);
@@ -67,7 +67,7 @@ class DFTU<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
6767
* the size of HR will not change in DFTU,
6868
* because I don't want to expand HR larger than Nonlocal operator caused by DFTU
6969
*/
70-
void initialize_HR(Grid_Driver* gridD_in);
70+
void initialize_HR(const Grid_Driver* gridD_in);
7171

7272
/**
7373
* @brief calculate the <phi|alpha^I> overlap values and save them in this->nlm_tot

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/dspin_lcao.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
#include "module_parameter/parameter.h"
99

1010
template <typename TK, typename TR>
11-
hamilt::DeltaSpin<hamilt::OperatorLCAO<TK, TR>>::DeltaSpin(
12-
HS_Matrix_K<TK>* hsk_in,
13-
const std::vector<ModuleBase::Vector3<double>>& kvec_d_in,
14-
hamilt::HContainer<TR>* hR_in,
15-
const UnitCell& ucell_in,
16-
Grid_Driver* gridD_in,
17-
const TwoCenterIntegrator* intor,
18-
const std::vector<double>& orb_cutoff)
11+
hamilt::DeltaSpin<hamilt::OperatorLCAO<TK, TR>>::DeltaSpin(HS_Matrix_K<TK>* hsk_in,
12+
const std::vector<ModuleBase::Vector3<double>>& kvec_d_in,
13+
hamilt::HContainer<TR>* hR_in,
14+
const UnitCell& ucell_in,
15+
const Grid_Driver* gridD_in,
16+
const TwoCenterIntegrator* intor,
17+
const std::vector<double>& orb_cutoff)
1918
: hamilt::OperatorLCAO<TK, TR>(hsk_in, kvec_d_in, hR_in), intor_(intor), orb_cutoff_(orb_cutoff)
2019
{
2120
this->cal_type = calculation_type::lcao_sc_lambda;

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/dspin_lcao.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ class DeltaSpin<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
2727
{
2828
public:
2929
DeltaSpin<OperatorLCAO<TK, TR>>(HS_Matrix_K<TK>* hsk_in,
30-
const std::vector<ModuleBase::Vector3<double>>& kvec_d_in,
31-
hamilt::HContainer<TR>* hR_in,
32-
const UnitCell& ucell_in,
33-
Grid_Driver* gridD_in,
34-
const TwoCenterIntegrator* intor,
35-
const std::vector<double>& orb_cutoff);
30+
const std::vector<ModuleBase::Vector3<double>>& kvec_d_in,
31+
hamilt::HContainer<TR>* hR_in,
32+
const UnitCell& ucell_in,
33+
const Grid_Driver* gridD_in,
34+
const TwoCenterIntegrator* intor,
35+
const std::vector<double>& orb_cutoff);
3636
~DeltaSpin<OperatorLCAO<TK, TR>>();
3737

3838
/**
@@ -69,7 +69,7 @@ class DeltaSpin<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
6969
private:
7070
const UnitCell* ucell = nullptr;
7171

72-
Grid_Driver* gridD = nullptr;
72+
const Grid_Driver* gridD = nullptr;
7373

7474
const Parallel_Orbitals* paraV = nullptr;
7575

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/ekinetic_new.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ hamilt::EkineticNew<hamilt::OperatorLCAO<TK, TR>>::EkineticNew(
1414
hamilt::HContainer<TR>* hR_in,
1515
const UnitCell* ucell_in,
1616
const std::vector<double>& orb_cutoff,
17-
Grid_Driver* GridD_in,
17+
const Grid_Driver* GridD_in,
1818
const TwoCenterIntegrator* intor)
1919
: hamilt::OperatorLCAO<TK, TR>(hsk_in, kvec_d_in, hR_in), orb_cutoff_(orb_cutoff), intor_(intor)
2020
{
@@ -40,7 +40,7 @@ hamilt::EkineticNew<hamilt::OperatorLCAO<TK, TR>>::~EkineticNew()
4040

4141
// initialize_HR()
4242
template <typename TK, typename TR>
43-
void hamilt::EkineticNew<hamilt::OperatorLCAO<TK, TR>>::initialize_HR(Grid_Driver* GridD)
43+
void hamilt::EkineticNew<hamilt::OperatorLCAO<TK, TR>>::initialize_HR(const Grid_Driver* GridD)
4444
{
4545
ModuleBase::TITLE("EkineticNew", "initialize_HR");
4646
ModuleBase::timer::tick("EkineticNew", "initialize_HR");

0 commit comments

Comments
 (0)