Skip to content

Commit 6d2c711

Browse files
committed
change DM2D_tmp to dm2d_tmp, use vector instead of new
1 parent e6a1983 commit 6d2c711

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

source/source_lcao/module_gint/gint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class Gint {
265265
std::vector<hamilt::HContainer<double>*> DMRGint;
266266

267267
//! tmp tools used in transfer_DM2DtoGrid
268-
hamilt::HContainer<double>* DM2D_tmp = nullptr;
268+
hamilt::HContainer<double>* dm2d_tmp = nullptr;
269269

270270
std::vector<hamilt::HContainer<double>> pvdpRx_reduced;
271271
std::vector<hamilt::HContainer<double>> pvdpRy_reduced;

source/source_lcao/module_gint/gint_old.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Gint::~Gint() {
3333
delete this->hRGint_tmp[is];
3434
}
3535
#ifdef __MPI
36-
delete this->DM2D_tmp;
36+
delete this->dm2d_tmp;
3737
#endif
3838
}
3939

@@ -171,8 +171,8 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, const Grid_Driver* gd, cons
171171
this->hRGint_tmp[is] = new hamilt::HContainer<double>(ucell_in.nat);
172172
}
173173
#ifdef __MPI
174-
if (this->DM2D_tmp != nullptr) {
175-
delete this->DM2D_tmp;
174+
if (this->dm2d_tmp != nullptr) {
175+
delete this->dm2d_tmp;
176176
}
177177
#endif
178178
}
@@ -224,7 +224,7 @@ void Gint::reset_DMRGint(const int& nspin)
224224
{
225225
for (auto& d : this->DMRGint) { d->allocate(nullptr, false); }
226226
#ifdef __MPI
227-
delete this->DM2D_tmp;
227+
delete this->dm2d_tmp;
228228
#endif
229229
}
230230
}
@@ -260,24 +260,24 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
260260
int ng = DM2D[0]->get_paraV()->get_global_col_size()/2;
261261
int nb = DM2D[0]->get_paraV()->get_block_size()/2;
262262
int blacs_ctxt = DM2D[0]->get_paraV()->blacs_ctxt;
263-
int *iat2iwt = new int[ucell->nat];
263+
std::vector<int> iat2iwt(ucell->nat);
264264
for (int iat = 0; iat < ucell->nat; iat++) {
265265
iat2iwt[iat] = ucell->get_iat2iwt()[iat]/2;
266266
}
267267
Parallel_Orbitals *pv = new Parallel_Orbitals();
268268
pv->set(mg, ng, nb, blacs_ctxt);
269-
pv->set_atomic_trace(iat2iwt, ucell->nat, mg);
269+
pv->set_atomic_trace(iat2iwt.data(), ucell->nat, mg);
270270
auto ijr_info = DM2D[0]->get_ijr_info();
271-
this-> DM2D_tmp = new hamilt::HContainer<double>(pv, nullptr, &ijr_info);
272-
ModuleBase::Memory::record("Gint::DM2D_tmp", this->DM2D_tmp->get_memory_size());
271+
this-> dm2d_tmp = new hamilt::HContainer<double>(pv, nullptr, &ijr_info);
272+
ModuleBase::Memory::record("Gint::dm2d_tmp", this->dm2d_tmp->get_memory_size());
273273
for (int is = 0; is < 4; is++){
274274
for (int iap = 0; iap < DM2D[0]->size_atom_pairs(); ++iap) {
275275
auto& ap = DM2D[0]->get_atom_pair(iap);
276276
int iat1 = ap.get_atom_i();
277277
int iat2 = ap.get_atom_j();
278278
for (int ir = 0; ir < ap.get_R_size(); ++ir) {
279279
const ModuleBase::Vector3<int> r_index = ap.get_R_index(ir);
280-
double* matrix_out = this -> DM2D_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer();
280+
double* matrix_out = this -> dm2d_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer();
281281
double* matrix_in = ap.get_pointer(ir);
282282
for (int irow = 0; irow < ap.get_row_size()/2; irow ++) {
283283
for (int icol = 0; icol < ap.get_col_size()/2; icol++){
@@ -288,7 +288,7 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
288288
}
289289
}
290290
}
291-
hamilt::transferParallels2Serials( *(this->DM2D_tmp), this->DMRGint[is]);
291+
hamilt::transferParallels2Serials( *(this->dm2d_tmp), this->DMRGint[is]);
292292
}
293293
#else
294294
//this->DMRGint_full = DM2D[0];

source/source_lcao/module_gint/temp_gint/gint_common.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,24 +171,23 @@ void transfer_dm_2d_to_gint(
171171
int nb = dm[0]->get_paraV()->get_block_size()/2;
172172
int blacs_ctxt = dm[0]->get_paraV()->blacs_ctxt;
173173
const UnitCell* ucell = gint_info.get_ucell();
174-
int *iat2iwt = new int[ucell->nat];
174+
std::vector<int> iat2iwt(ucell->nat);
175175
for (int iat = 0; iat < ucell->nat; iat++) {
176176
iat2iwt[iat] = ucell->get_iat2iwt()[iat]/2;
177177
}
178178
Parallel_Orbitals *pv = new Parallel_Orbitals();
179179
pv->set(mg, ng, nb, blacs_ctxt);
180-
pv->set_atomic_trace(iat2iwt, ucell->nat, mg);
180+
pv->set_atomic_trace(iat2iwt.data(), ucell->nat, mg);
181181
auto ijr_info = dm[0]->get_ijr_info();
182-
HContainer<T>* DM2D_tmp = new hamilt::HContainer<T>(pv, nullptr, &ijr_info);
183-
//ModuleBase::Memory::record("Gint::DM2D_tmp", this->DM2D_tmp->get_memory_size());
182+
HContainer<T>* dm2d_tmp = new hamilt::HContainer<T>(pv, nullptr, &ijr_info);
184183
for (int is = 0; is < 4; is++){
185184
for (int iap = 0; iap < dm[0]->size_atom_pairs(); ++iap) {
186185
auto& ap = dm[0]->get_atom_pair(iap);
187186
int iat1 = ap.get_atom_i();
188187
int iat2 = ap.get_atom_j();
189188
for (int ir = 0; ir < ap.get_R_size(); ++ir) {
190189
const ModuleBase::Vector3<int> r_index = ap.get_R_index(ir);
191-
T* matrix_out = DM2D_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer();
190+
T* matrix_out = dm2d_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer();
192191
T* matrix_in = ap.get_pointer(ir);
193192
for (int irow = 0; irow < ap.get_row_size()/2; irow ++) {
194193
for (int icol = 0; icol < ap.get_col_size()/2; icol ++) {
@@ -199,7 +198,7 @@ void transfer_dm_2d_to_gint(
199198
}
200199
}
201200
}
202-
hamilt::transferParallels2Serials( *DM2D_tmp, &dm_gint[is]);
201+
hamilt::transferParallels2Serials( *dm2d_tmp, &dm_gint[is]);
203202
}
204203
#else
205204
//HContainer<T>& dm_full = *(dm[0]);

source/source_lcao/module_lr/utils/gint_move.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ Gint& Gint::operator=(Gint&& rhs)
6060
this->pvdpRz_reduced = std::move(rhs.pvdpRz_reduced);
6161
this->DMRGint = std::move(rhs.DMRGint);
6262
this->hRGint_tmp = std::move(rhs.hRGint_tmp);
63-
this->DM2D_tmp = rhs.DM2D_tmp;
64-
rhs.DM2D_tmp = nullptr;
63+
this->dm2d_tmp = rhs.dm2d_tmp;
64+
rhs.dm2d_tmp = nullptr;
6565

6666
return *this;
6767
}

0 commit comments

Comments
 (0)