Skip to content

Commit 851d8bf

Browse files
[pre-commit.ci lite] apply automatic fixes
1 parent eb7c145 commit 851d8bf

File tree

2 files changed

+55
-28
lines changed

2 files changed

+55
-28
lines changed

source/module_basis/module_pw/pw_basis_sup.cpp

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ void PW_Basis_Sup::distribution_method3(const ModulePW::PW_Basis* pw_rho)
100100
this->npw_per = new int[this->poolnproc]; // number of planewaves on each core.
101101
delete[] this->fftixy2ip;
102102
this->fftixy2ip = new int[this->fftnxy]; // ip of core which contains the stick on (x, y).
103-
for (int ixy = 0; ixy < this->fftnxy; ++ixy)
103+
for (int ixy = 0; ixy < this->fftnxy; ++ixy) {
104104
this->fftixy2ip[ixy] = -1; // meaning this stick has not been distributed or there is no stick on (x, y).
105+
}
105106
if (poolrank == 0)
106107
{
107108
// (1) Count the total number of planewaves (tot_npw) and sticks (this->nstot).
@@ -212,10 +213,11 @@ void PW_Basis_Sup::divide_sticks_3(
212213
int fftnx_s = nx_s;
213214
if (this->gamma_only)
214215
{
215-
if (this->xprime)
216+
if (this->xprime) {
216217
fftnx_s = int(nx_s / 2) + 1;
217-
else
218+
} else {
218219
fftny_s = int(ny_s / 2) + 1;
220+
}
219221
}
220222

221223
int fftnxy_s = fftnx_s * fftny_s;
@@ -225,15 +227,19 @@ void PW_Basis_Sup::divide_sticks_3(
225227
{
226228
int ix = ixy / fftny_s;
227229
int iy = ixy % fftny_s;
228-
if (ix >= int(nx_s / 2) + 1)
230+
if (ix >= int(nx_s / 2) + 1) {
229231
ix -= nx_s;
230-
if (iy >= int(ny_s / 2) + 1)
232+
}
233+
if (iy >= int(ny_s / 2) + 1) {
231234
iy -= ny_s;
235+
}
232236

233-
if (ix < 0)
237+
if (ix < 0) {
234238
ix += nx;
235-
if (iy < 0)
239+
}
240+
if (iy < 0) {
236241
iy += ny;
242+
}
237243
int index = ix * this->fftny + iy;
238244
int ip = fftixy2ip_s[ixy];
239245
if (ip >= 0)
@@ -349,8 +355,9 @@ void PW_Basis_Sup::get_ig2isz_is2fftixy(
349355
fftixy2is[ixy] = st_move;
350356
st_move++;
351357
}
352-
if (st_move == this->nst)
358+
if (st_move == this->nst) {
353359
break;
360+
}
354361
}
355362

356363
// distribute planewaves in the same order as smooth grids first.
@@ -363,28 +370,35 @@ void PW_Basis_Sup::get_ig2isz_is2fftixy(
363370
int ixy = pw_rho->is2fftixy[is];
364371
int ix = ixy / pw_rho->fftny;
365372
int iy = ixy % pw_rho->fftny;
366-
if (ix >= int(pw_rho->nx / 2) + 1)
373+
if (ix >= int(pw_rho->nx / 2) + 1) {
367374
ix -= pw_rho->nx;
368-
if (iy >= int(pw_rho->ny / 2) + 1)
375+
}
376+
if (iy >= int(pw_rho->ny / 2) + 1) {
369377
iy -= pw_rho->ny;
370-
if (iz >= int(pw_rho->nz / 2) + 1)
378+
}
379+
if (iz >= int(pw_rho->nz / 2) + 1) {
371380
iz -= pw_rho->nz;
381+
}
372382

373-
if (ix < 0)
383+
if (ix < 0) {
374384
ix += this->nx;
375-
if (iy < 0)
385+
}
386+
if (iy < 0) {
376387
iy += this->ny;
377-
if (iz < 0)
388+
}
389+
if (iz < 0) {
378390
iz += this->nz;
391+
}
379392
int ixy_now = ix * this->fftny + iy;
380393
int index = ixy_now * this->nz + iz;
381394
int is_now = fftixy2is[ixy_now];
382395
int isz_now = is_now * this->nz + iz;
383396
this->ig2isz[ig] = isz_now;
384397
pw_filled++;
385398
found[index] = true;
386-
if (xprime && ix == 0)
399+
if (xprime && ix == 0) {
387400
ng_xeq0++;
401+
}
388402
}
389403
assert(pw_filled == pw_rho->npw);
390404

@@ -397,21 +411,24 @@ void PW_Basis_Sup::get_ig2isz_is2fftixy(
397411
for (int iz = zstart; iz < zstart + st_length2D[ixy]; ++iz)
398412
{
399413
int z = iz;
400-
if (z < 0)
414+
if (z < 0) {
401415
z += this->nz;
416+
}
402417
if (!found[ixy * this->nz + z])
403418
{
404419
found[ixy * this->nz + z] = true;
405420
int is = fftixy2is[ixy];
406421
this->ig2isz[pw_filled] = is * this->nz + z;
407422
pw_filled++;
408-
if (xprime && ixy / fftny == 0)
423+
if (xprime && ixy / fftny == 0) {
409424
ng_xeq0++;
425+
}
410426
}
411427
}
412428
}
413-
if (pw_filled == this->npw)
429+
if (pw_filled == this->npw) {
414430
break;
431+
}
415432
}
416433

417434
delete[] fftixy2is;

source/module_basis/module_pw/pw_distributeg.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ void PW_Basis::count_pw_st(
101101
// so that its index in st_length and st_bottom is 9 * 10 + 2 = 92.
102102
int x = ix;
103103
int y = iy;
104-
if (x < 0) x += this->nx;
105-
if (y < 0) y += this->ny;
104+
if (x < 0) { x += this->nx;
105+
}
106+
if (y < 0) { y += this->ny;
107+
}
106108
int index = x * this->fftny + y;
107109

108110
int length = 0; // number of planewave on stick (x, y).
@@ -114,13 +116,18 @@ void PW_Basis::count_pw_st(
114116
double modulus = f * (this->GGT * f);
115117
if (modulus <= this->ggecut || this->full_pw)
116118
{
117-
if (length == 0) st_bottom2D[index] = iz; // length == 0 means this point is the bottom of stick (x, y).
119+
if (length == 0) { st_bottom2D[index] = iz; // length == 0 means this point is the bottom of stick (x, y).
120+
}
118121
++this->npwtot;
119122
++length;
120-
if(iy < this->riy) this->riy = iy;
121-
if(iy > this->liy) this->liy = iy;
122-
if(ix < this->rix) this->rix = ix;
123-
if(ix > this->lix) this->lix = ix;
123+
if(iy < this->riy) { this->riy = iy;
124+
}
125+
if(iy > this->liy) { this->liy = iy;
126+
}
127+
if(ix < this->rix) { this->rix = ix;
128+
}
129+
if(ix > this->lix) { this->lix = ix;
130+
}
124131
}
125132
}
126133
if (length > 0)
@@ -182,15 +189,18 @@ void PW_Basis::get_ig2isz_is2fftixy(
182189
for (int iz = zstart; iz < zstart + st_length2D[ixy]; ++iz)
183190
{
184191
int z = iz;
185-
if (z < 0) z += this->nz;
192+
if (z < 0) { z += this->nz;
193+
}
186194
this->ig2isz[pw_filled] = st_move * this->nz + z;
187195
pw_filled++;
188196
}
189197
this->is2fftixy[st_move] = ixy;
190198
st_move++;
191-
if(xprime && ixy/fftny == 0) ng_xeq0 = pw_filled;
199+
if(xprime && ixy/fftny == 0) { ng_xeq0 = pw_filled;
200+
}
192201
}
193-
if (st_move == this->nst && pw_filled == this->npw) break;
202+
if (st_move == this->nst && pw_filled == this->npw) { break;
203+
}
194204
}
195205
#if defined(__CUDA) || defined(__ROCM)
196206
if (this->device == "gpu") {

0 commit comments

Comments
 (0)