@@ -16,7 +16,7 @@ void Stress_Func<FPTYPE, Device>::stress_loc(ModuleBase::matrix& sigma,
16
16
ModuleBase::TITLE (" Stress_Func" ," stress_loc" );
17
17
ModuleBase::timer::tick (" Stress_Func" ," stress_loc" );
18
18
19
- FPTYPE * dvloc = new FPTYPE[ rho_basis->npw ] ;
19
+ std::vector< FPTYPE> dvloc ( rho_basis->npw ) ;
20
20
FPTYPE evloc=0.0 ;
21
21
FPTYPE fact=1.0 ;
22
22
@@ -26,7 +26,7 @@ void Stress_Func<FPTYPE, Device>::stress_loc(ModuleBase::matrix& sigma,
26
26
27
27
28
28
29
- std::complex<FPTYPE> *aux = new std::complex<FPTYPE> [ rho_basis->nmaxgr ] ;
29
+ std::vector< std::complex<FPTYPE>> aux ( rho_basis->nmaxgr ) ;
30
30
31
31
/*
32
32
blocking rho_basis->nrxx for data locality.
@@ -58,7 +58,7 @@ void Stress_Func<FPTYPE, Device>::stress_loc(ModuleBase::matrix& sigma,
58
58
}
59
59
}
60
60
}
61
- rho_basis->real2recip (aux,aux);
61
+ rho_basis->real2recip (aux. data () ,aux. data () );
62
62
63
63
// if(INPUT.gamma_only==1) fact=2.0;
64
64
// else fact=1.0;
@@ -87,7 +87,7 @@ void Stress_Func<FPTYPE, Device>::stress_loc(ModuleBase::matrix& sigma,
87
87
//
88
88
// special case: pseudopotential is coulomb 1/r potential
89
89
//
90
- this ->dvloc_coulomb (atom->ncpp .zv , dvloc, rho_basis);
90
+ this ->dvloc_coulomb (atom->ncpp .zv , dvloc. data () , rho_basis);
91
91
//
92
92
}
93
93
else
@@ -96,7 +96,7 @@ void Stress_Func<FPTYPE, Device>::stress_loc(ModuleBase::matrix& sigma,
96
96
// normal case: dvloc contains dV_loc(G)/dG
97
97
//
98
98
this ->dvloc_of_g ( atom->ncpp .msh , atom->ncpp .rab , atom->ncpp .r ,
99
- atom->ncpp .vloc_at , atom->ncpp .zv , dvloc, rho_basis);
99
+ atom->ncpp .vloc_at , atom->ncpp .zv , dvloc. data () , rho_basis);
100
100
//
101
101
}
102
102
#ifndef _OPENMP
@@ -156,8 +156,7 @@ void Stress_Func<FPTYPE, Device>::stress_loc(ModuleBase::matrix& sigma,
156
156
sigma (m,l) = sigma (l,m);
157
157
}
158
158
}
159
- delete[] dvloc;
160
- delete[] aux;
159
+
161
160
162
161
163
162
ModuleBase::timer::tick (" Stress_Func" ," stress_loc" );
@@ -185,14 +184,14 @@ ModulePW::PW_Basis* rho_basis
185
184
// FPTYPE dvloc[ngl];
186
185
// the fourier transform dVloc/dG
187
186
//
188
- FPTYPE *aux1;
187
+
189
188
190
189
int igl0;
191
190
// counter on erf functions or gaussians
192
191
// counter on g shells vectors
193
192
// first shell with g != 0
194
-
195
- aux1 = new FPTYPE[ msh] ;
193
+
194
+ std::vector< FPTYPE> aux1 ( msh) ;
196
195
197
196
// the G=0 component is not computed
198
197
if (rho_basis->gg_uniq [0 ] < 1.0e-8 )
@@ -223,8 +222,7 @@ ModulePW::PW_Basis* rho_basis
223
222
aux1[i] = r [i] * vloc_at [i] + zp * ModuleBase::e2 * erf (r[i]);
224
223
}
225
224
226
- FPTYPE *aux;
227
- aux = new FPTYPE[msh];
225
+ std::vector<FPTYPE> aux (msh);
228
226
aux[0 ] = 0.0 ;
229
227
#ifdef _OPENMP
230
228
#pragma omp for
@@ -247,19 +245,19 @@ ModulePW::PW_Basis* rho_basis
247
245
}
248
246
FPTYPE vlcp=0 ;
249
247
// simpson (msh, aux, rab, vlcp);
250
- ModuleBase::Integral::Simpson_Integral (msh, aux, rab, vlcp );
248
+ ModuleBase::Integral::Simpson_Integral (msh, aux. data () , rab, vlcp );
251
249
// DV(g^2)/Dg^2 = (DV(g)/Dg)/2g
252
250
vlcp *= ModuleBase::FOUR_PI / GlobalC::ucell.omega / 2.0 / gx;
253
251
// subtract the long-range term
254
252
FPTYPE g2a = gx2 / 4.0 ;
255
253
vlcp += ModuleBase::FOUR_PI / GlobalC::ucell.omega * zp * ModuleBase::e2 * ModuleBase::libm::exp ( - g2a) * (g2a + 1 ) / pow (gx2 , 2 );
256
254
dvloc [igl] = vlcp;
257
255
}
258
- delete[] aux;
256
+
259
257
#ifdef _OPENMP
260
258
}
261
259
#endif
262
- delete[] aux1;
260
+
263
261
264
262
return ;
265
263
}
0 commit comments