Skip to content

Commit 2de0d4e

Browse files
authored
Merge pull request #3244 from boutproject/more-zstart-zend-loops
Use `zstart/zend` in more loops
2 parents 0883eda + b20d19d commit 2de0d4e

22 files changed

Lines changed: 240 additions & 240 deletions

File tree

examples/elm-pb/elm_pb.cxx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ class ELMpb : public PhysicsModel {
13661366
// Calculate a single phi boundary value for all Y slices
13671367
BoutReal philocal = 0.0;
13681368
for (int j = mesh->ystart; j <= mesh->yend; j++) {
1369-
for (int k = 0; k < mesh->LocalNz; k++) {
1369+
for (int k = mesh->zstart; k <= mesh->zend; k++) {
13701370
philocal += phi(mesh->xstart, j, k);
13711371
}
13721372
}
@@ -1379,7 +1379,7 @@ class ELMpb : public PhysicsModel {
13791379
for (int j = mesh->ystart; j <= mesh->yend; j++) {
13801380
if (!phi_core_averagey) {
13811381
phivalue = 0.0; // Calculate phi boundary for each Y index separately
1382-
for (int k = 0; k < mesh->LocalNz; k++) {
1382+
for (int k = mesh->zstart; k <= mesh->zend; k++) {
13831383
phivalue += phi(mesh->xstart, j, k);
13841384
}
13851385
phivalue /= mesh->LocalNz; // Average in Z of point next to boundary
@@ -1393,7 +1393,7 @@ class ELMpb : public PhysicsModel {
13931393
BoutReal const newvalue = weight * oldvalue + (1. - weight) * phivalue;
13941394

13951395
// Set phi at the boundary to this value
1396-
for (int k = 0; k < mesh->LocalNz; k++) {
1396+
for (int k = mesh->zstart; k <= mesh->zend; k++) {
13971397
phi(mesh->xstart - 1, j, k) = 2. * newvalue - phi(mesh->xstart, j, k);
13981398
phi(mesh->xstart - 2, j, k) = phi(mesh->xstart - 1, j, k);
13991399
}
@@ -1403,7 +1403,7 @@ class ELMpb : public PhysicsModel {
14031403
if (mesh->lastX()) {
14041404
for (int j = mesh->ystart; j <= mesh->yend; j++) {
14051405
BoutReal phivalue = 0.0;
1406-
for (int k = 0; k < mesh->LocalNz; k++) {
1406+
for (int k = mesh->zstart; k <= mesh->zend; k++) {
14071407
phivalue += phi(mesh->xend, j, k);
14081408
}
14091409
phivalue /= mesh->LocalNz; // Average in Z of point next to boundary
@@ -1416,7 +1416,7 @@ class ELMpb : public PhysicsModel {
14161416
BoutReal const newvalue = weight * oldvalue + (1. - weight) * phivalue;
14171417

14181418
// Set phi at the boundary to this value
1419-
for (int k = 0; k < mesh->LocalNz; k++) {
1419+
for (int k = mesh->zstart; k <= mesh->zend; k++) {
14201420
phi(mesh->xend + 1, j, k) = 2. * newvalue - phi(mesh->xend, j, k);
14211421
phi(mesh->xend + 2, j, k) = phi(mesh->xend + 1, j, k);
14221422
}
@@ -1441,7 +1441,7 @@ class ELMpb : public PhysicsModel {
14411441

14421442
if (mesh->firstX()) {
14431443
for (int j = mesh->ystart; j <= mesh->yend; j++) {
1444-
for (int k = 0; k < mesh->LocalNz; k++) {
1444+
for (int k = mesh->zstart; k <= mesh->zend; k++) {
14451445
// Average phi + Pi at the boundary, and set the boundary cell
14461446
// to this value. The phi solver will then put the value back
14471447
// onto the cell mid-point
@@ -1453,7 +1453,7 @@ class ELMpb : public PhysicsModel {
14531453

14541454
if (mesh->lastX()) {
14551455
for (int j = mesh->ystart; j <= mesh->yend; j++) {
1456-
for (int k = 0; k < mesh->LocalNz; k++) {
1456+
for (int k = mesh->zstart; k <= mesh->zend; k++) {
14571457
phi_shift(mesh->xend + 1, j, k) =
14581458
0.5 * (phi_shift(mesh->xend + 1, j, k) + phi_shift(mesh->xend, j, k));
14591459
}
@@ -1513,7 +1513,7 @@ class ELMpb : public PhysicsModel {
15131513
if (mesh->firstX()) {
15141514
for (int i = mesh->xstart - 2; i >= 0; --i) {
15151515
for (int j = mesh->ystart; j <= mesh->yend; ++j) {
1516-
for (int k = 0; k < mesh->LocalNz; ++k) {
1516+
for (int k = mesh->zstart; k <= mesh->zend; ++k) {
15171517
phi(i, j, k) = phi(i + 1, j, k);
15181518
}
15191519
}
@@ -1523,7 +1523,7 @@ class ELMpb : public PhysicsModel {
15231523
if (mesh->lastX()) {
15241524
for (int i = mesh->xend + 2; i < mesh->LocalNx; ++i) {
15251525
for (int j = mesh->ystart; j <= mesh->yend; ++j) {
1526-
for (int k = 0; k < mesh->LocalNz; ++k) {
1526+
for (int k = mesh->zstart; k <= mesh->zend; ++k) {
15271527
phi(i, j, k) = phi(i - 1, j, k);
15281528
}
15291529
}

examples/performance/iterator-offsets/iterator-offsets.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int main(int argc, char** argv) {
6565
ITERATOR_TEST_BLOCK(
6666
"Nested loop", for (int i = 0; i < mesh->LocalNx; ++i) {
6767
for (int j = mesh->ystart; j < mesh->yend; ++j) {
68-
for (int k = 0; k < mesh->LocalNz; ++k) {
68+
for (int k = mesh->zstart; k <= mesh->zend; ++k) {
6969
result(i, j, k) = (a(i, j + 1, k) - a(i, j - 1, k));
7070
}
7171
}
@@ -76,7 +76,7 @@ int main(int argc, char** argv) {
7676
BOUT_OMP_PERF(parallel for)
7777
for(int i=0;i<mesh->LocalNx;++i) {
7878
for (int j = mesh->ystart; j < mesh->yend; ++j) {
79-
for (int k = 0; k < mesh->LocalNz; ++k) {
79+
for (int k = mesh->zstart; k <= mesh->zend; ++k) {
8080
result(i, j, k) = (a(i, j + 1, k) - a(i, j - 1, k));
8181
}
8282
}

examples/performance/iterator/iterator.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ int main(int argc, char** argv) {
7777
ITERATOR_TEST_BLOCK(
7878
"Nested loop", for (int i = 0; i < mesh->LocalNx; ++i) {
7979
for (int j = 0; j < mesh->LocalNy; ++j) {
80-
for (int k = 0; k < mesh->LocalNz; ++k) {
80+
for (int k = mesh->zstart; k <= mesh->zend; ++k) {
8181
result(i, j, k) = a(i, j, k) + b(i, j, k);
8282
}
8383
}
@@ -88,7 +88,7 @@ int main(int argc, char** argv) {
8888
BOUT_OMP_PERF(parallel for)
8989
for(int i=0;i<mesh->LocalNx;++i) {
9090
for (int j = 0; j < mesh->LocalNy; ++j) {
91-
for (int k = 0; k < mesh->LocalNz; ++k) {
91+
for (int k = mesh->zstart; k <= mesh->zend; ++k) {
9292
result(i, j, k) = a(i, j, k) + b(i, j, k);
9393
}
9494
}

include/bout/fv_ops.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ const Field3D Div_par(const Field3D& f_in, const Field3D& v_in,
258258
BoutReal flux_factor_lm =
259259
common_factor / (coord->dy(i, j - 1) * coord->J(i, j - 1));
260260
#endif
261-
for (int k = 0; k < mesh->LocalNz; k++) {
261+
for (int k = mesh->zstart; k <= mesh->zend; k++) {
262262
#if BOUT_USE_METRIC_3D
263263
// For right cell boundaries
264264
BoutReal common_factor =

manual/sphinx/developer_docs/data_types.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ parallelise and vectorise. Some tuning of this is possible, see below
255255
for details. It replaces the C-style triple-nested loop::
256256

257257
Field3D f(0.0);
258-
for (int i = mesh->xstart; i < mesh->xend; ++i) {
259-
for (int j = mesh->ystart; j < mesh->yend; ++j) {
260-
for (int k = 0; k < mesh->LocalNz; ++k) {
258+
for (int i = mesh->xstart; i <= mesh->xend; ++i) {
259+
for (int j = mesh->ystart; j <= mesh->yend; ++j) {
260+
for (int k = mesh->zstart; k <= mesh->zend; ++k) {
261261
f(i,j,k) = a(i,j,k) + b(i,j,k)
262262
}
263263
}

manual/sphinx/user_docs/boundary_options.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ and implemented in ``boundary_standard.cxx``
575575

576576
void BoundaryNeumann::apply(Field3D &f) {
577577
for(bndry->first(); !bndry->isDone(); bndry->next())
578-
for(int z=0;z<mesh->LocalNz;z++)
578+
for(int z= mesh->zstart; z <= mesh->zend;z++)
579579
f[bndry->x][bndry->y][z] = f[bndry->x - bndry->bx][bndry->y -
580580
bndry->by][z];
581581
}

src/invert/laplace/impls/naulin/naulin_laplace.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ void LaplaceNaulin::copy_x_boundaries(Field3D& x, const Field3D& x0, Mesh* local
402402
if (localmesh->firstX()) {
403403
for (int i = localmesh->xstart - 1; i >= 0; --i) {
404404
for (int j = localmesh->ystart; j <= localmesh->yend; ++j) {
405-
for (int k = 0; k < localmesh->LocalNz; ++k) {
405+
for (int k = localmesh->zstart; k <= localmesh->zend; ++k) {
406406
x(i, j, k) = x0(i, j, k);
407407
}
408408
}
@@ -411,7 +411,7 @@ void LaplaceNaulin::copy_x_boundaries(Field3D& x, const Field3D& x0, Mesh* local
411411
if (localmesh->lastX()) {
412412
for (int i = localmesh->xend + 1; i < localmesh->LocalNx; ++i) {
413413
for (int j = localmesh->ystart; j <= localmesh->yend; ++j) {
414-
for (int k = 0; k < localmesh->LocalNz; ++k) {
414+
for (int k = localmesh->zstart; k <= localmesh->zend; ++k) {
415415
x(i, j, k) = x0(i, j, k);
416416
}
417417
}

src/invert/laplace/impls/petsc/petsc_laplace.cxx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ LaplacePetsc::LaplacePetsc(Options* opt, const CELL_LOC loc, Mesh* mesh_in,
145145
if (fourth_order) {
146146
// first and last 2*localmesh-LocalNz entries are the edge x-values that (may) have 'off-diagonal' components (i.e. on another processor)
147147
if (localmesh->firstX() && localmesh->lastX()) {
148-
for (int i = 0; i < localmesh->LocalNz; i++) {
148+
for (int i = localmesh->zstart; i <= localmesh->zend; i++) {
149149
d_nnz[i] = 15;
150150
d_nnz[localN - 1 - i] = 15;
151151
o_nnz[i] = 0;
@@ -158,7 +158,7 @@ LaplacePetsc::LaplacePetsc(Options* opt, const CELL_LOC loc, Mesh* mesh_in,
158158
o_nnz[localN - 1 - i] = 0;
159159
}
160160
} else if (localmesh->firstX()) {
161-
for (int i = 0; i < localmesh->LocalNz; i++) {
161+
for (int i = localmesh->zstart; i <= localmesh->zend; i++) {
162162
d_nnz[i] = 15;
163163
d_nnz[localN - 1 - i] = 15;
164164
o_nnz[i] = 0;
@@ -171,7 +171,7 @@ LaplacePetsc::LaplacePetsc(Options* opt, const CELL_LOC loc, Mesh* mesh_in,
171171
o_nnz[localN - 1 - i] = 5;
172172
}
173173
} else if (localmesh->lastX()) {
174-
for (int i = 0; i < localmesh->LocalNz; i++) {
174+
for (int i = localmesh->zstart; i <= localmesh->zend; i++) {
175175
d_nnz[i] = 15;
176176
d_nnz[localN - 1 - i] = 15;
177177
o_nnz[i] = 10;
@@ -184,7 +184,7 @@ LaplacePetsc::LaplacePetsc(Options* opt, const CELL_LOC loc, Mesh* mesh_in,
184184
o_nnz[localN - 1 - i] = 0;
185185
}
186186
} else {
187-
for (int i = 0; i < localmesh->LocalNz; i++) {
187+
for (int i = localmesh->zstart; i <= localmesh->zend; i++) {
188188
d_nnz[i] = 15;
189189
d_nnz[localN - 1 - i] = 15;
190190
o_nnz[i] = 10;
@@ -215,28 +215,28 @@ LaplacePetsc::LaplacePetsc(Options* opt, const CELL_LOC loc, Mesh* mesh_in,
215215
} else {
216216
// first and last localmesh->LocalNz entries are the edge x-values that (may) have 'off-diagonal' components (i.e. on another processor)
217217
if (localmesh->firstX() && localmesh->lastX()) {
218-
for (int i = 0; i < localmesh->LocalNz; i++) {
218+
for (int i = localmesh->zstart; i <= localmesh->zend; i++) {
219219
d_nnz[i] = 6;
220220
d_nnz[localN - 1 - i] = 6;
221221
o_nnz[i] = 0;
222222
o_nnz[localN - 1 - i] = 0;
223223
}
224224
} else if (localmesh->firstX()) {
225-
for (int i = 0; i < localmesh->LocalNz; i++) {
225+
for (int i = localmesh->zstart; i <= localmesh->zend; i++) {
226226
d_nnz[i] = 6;
227227
d_nnz[localN - 1 - i] = 6;
228228
o_nnz[i] = 0;
229229
o_nnz[localN - 1 - i] = 3;
230230
}
231231
} else if (localmesh->lastX()) {
232-
for (int i = 0; i < localmesh->LocalNz; i++) {
232+
for (int i = localmesh->zstart; i <= localmesh->zend; i++) {
233233
d_nnz[i] = 6;
234234
d_nnz[localN - 1 - i] = 6;
235235
o_nnz[i] = 3;
236236
o_nnz[localN - 1 - i] = 0;
237237
}
238238
} else {
239-
for (int i = 0; i < localmesh->LocalNz; i++) {
239+
for (int i = localmesh->zstart; i <= localmesh->zend; i++) {
240240
d_nnz[i] = 6;
241241
d_nnz[localN - 1 - i] = 6;
242242
o_nnz[i] = 3;
@@ -377,7 +377,7 @@ FieldPerp LaplacePetsc::solve(const FieldPerp& b, const FieldPerp& x0) {
377377
// Set the values for the inner boundary region
378378
if (localmesh->firstX()) {
379379
for (int x = 0; x < localmesh->xstart; x++) {
380-
for (int z = 0; z < localmesh->LocalNz; z++) {
380+
for (int z = localmesh->zstart; z <= localmesh->zend; z++) {
381381
PetscScalar val; // Value of element to be set in the matrix
382382
// If Neumann Boundary Conditions are set.
383383
if (isInnerBoundaryFlagSet(INVERT_AC_GRAD)) {
@@ -461,7 +461,7 @@ FieldPerp LaplacePetsc::solve(const FieldPerp& b, const FieldPerp& x0) {
461461

462462
// Set the values for the main domain
463463
for (int x = localmesh->xstart; x <= localmesh->xend; x++) {
464-
for (int z = 0; z < localmesh->LocalNz; z++) {
464+
for (int z = localmesh->zstart; z <= localmesh->zend; z++) {
465465
// NOTE: Only A0 is the A from setCoefA ()
466466
BoutReal A0, A1, A2, A3, A4, A5;
467467
A0 = A(x, y, z);
@@ -639,7 +639,7 @@ FieldPerp LaplacePetsc::solve(const FieldPerp& b, const FieldPerp& x0) {
639639
// Set the values for the outer boundary region
640640
if (localmesh->lastX()) {
641641
for (int x = localmesh->xend + 1; x < localmesh->LocalNx; x++) {
642-
for (int z = 0; z < localmesh->LocalNz; z++) {
642+
for (int z = localmesh->zstart; z <= localmesh->zend; z++) {
643643
// Set Diagonal Values to 1
644644
PetscScalar val = 1;
645645
Element(i, x, z, 0, 0, val, MatA);
@@ -829,7 +829,7 @@ FieldPerp LaplacePetsc::solve(const FieldPerp& b, const FieldPerp& x0) {
829829
// Set the inner boundary values
830830
if (localmesh->firstX()) {
831831
for (int x = 0; x < localmesh->xstart; x++) {
832-
for (int z = 0; z < localmesh->LocalNz; z++) {
832+
for (int z = localmesh->zstart; z <= localmesh->zend; z++) {
833833
PetscScalar val = 0;
834834
VecGetValues(xs, 1, &i, &val);
835835
sol[x][z] = val;
@@ -840,7 +840,7 @@ FieldPerp LaplacePetsc::solve(const FieldPerp& b, const FieldPerp& x0) {
840840

841841
// Set the main domain values
842842
for (int x = localmesh->xstart; x <= localmesh->xend; x++) {
843-
for (int z = 0; z < localmesh->LocalNz; z++) {
843+
for (int z = localmesh->zstart; z <= localmesh->zend; z++) {
844844
PetscScalar val = 0;
845845
VecGetValues(xs, 1, &i, &val);
846846
sol[x][z] = val;
@@ -851,7 +851,7 @@ FieldPerp LaplacePetsc::solve(const FieldPerp& b, const FieldPerp& x0) {
851851
// Set the outer boundary values
852852
if (localmesh->lastX()) {
853853
for (int x = localmesh->xend + 1; x < localmesh->LocalNx; x++) {
854-
for (int z = 0; z < localmesh->LocalNz; z++) {
854+
for (int z = localmesh->zstart; z <= localmesh->zend; z++) {
855855
PetscScalar val = 0;
856856
VecGetValues(xs, 1, &i, &val);
857857
sol[x][z] = val;
@@ -1076,7 +1076,7 @@ void LaplacePetsc::vecToField(Vec xs, FieldPerp& f) {
10761076
int i = Istart;
10771077
if (localmesh->firstX()) {
10781078
for (int x = 0; x < localmesh->xstart; x++) {
1079-
for (int z = 0; z < localmesh->LocalNz; z++) {
1079+
for (int z = localmesh->zstart; z <= localmesh->zend; z++) {
10801080
PetscScalar val;
10811081
VecGetValues(xs, 1, &i, &val);
10821082
f[x][z] = val;
@@ -1086,7 +1086,7 @@ void LaplacePetsc::vecToField(Vec xs, FieldPerp& f) {
10861086
}
10871087

10881088
for (int x = localmesh->xstart; x <= localmesh->xend; x++) {
1089-
for (int z = 0; z < localmesh->LocalNz; z++) {
1089+
for (int z = localmesh->zstart; z <= localmesh->zend; z++) {
10901090
PetscScalar val;
10911091
VecGetValues(xs, 1, &i, &val);
10921092
f[x][z] = val;
@@ -1096,7 +1096,7 @@ void LaplacePetsc::vecToField(Vec xs, FieldPerp& f) {
10961096

10971097
if (localmesh->lastX()) {
10981098
for (int x = localmesh->xend + 1; x < localmesh->LocalNx; x++) {
1099-
for (int z = 0; z < localmesh->LocalNz; z++) {
1099+
for (int z = localmesh->zstart; z <= localmesh->zend; z++) {
11001100
PetscScalar val;
11011101
VecGetValues(xs, 1, &i, &val);
11021102
f[x][z] = val;
@@ -1113,7 +1113,7 @@ void LaplacePetsc::fieldToVec(const FieldPerp& f, Vec bs) {
11131113
int i = Istart;
11141114
if (localmesh->firstX()) {
11151115
for (int x = 0; x < localmesh->xstart; x++) {
1116-
for (int z = 0; z < localmesh->LocalNz; z++) {
1116+
for (int z = localmesh->zstart; z <= localmesh->zend; z++) {
11171117
PetscScalar val = f[x][z];
11181118
VecSetValues(bs, 1, &i, &val, INSERT_VALUES);
11191119
i++; // Increment row in Petsc matrix
@@ -1122,7 +1122,7 @@ void LaplacePetsc::fieldToVec(const FieldPerp& f, Vec bs) {
11221122
}
11231123

11241124
for (int x = localmesh->xstart; x <= localmesh->xend; x++) {
1125-
for (int z = 0; z < localmesh->LocalNz; z++) {
1125+
for (int z = localmesh->zstart; z <= localmesh->zend; z++) {
11261126
PetscScalar val = f[x][z];
11271127
VecSetValues(bs, 1, &i, &val, INSERT_VALUES);
11281128
i++; // Increment row in Petsc matrix
@@ -1131,7 +1131,7 @@ void LaplacePetsc::fieldToVec(const FieldPerp& f, Vec bs) {
11311131

11321132
if (localmesh->lastX()) {
11331133
for (int x = localmesh->xend + 1; x < localmesh->LocalNx; x++) {
1134-
for (int z = 0; z < localmesh->LocalNz; z++) {
1134+
for (int z = localmesh->zstart; z <= localmesh->zend; z++) {
11351135
PetscScalar val = f[x][z];
11361136
VecSetValues(bs, 1, &i, &val, INSERT_VALUES);
11371137
i++; // Increment row in Petsc matrix

src/invert/laplace/impls/spt/spt.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ FieldPerp LaplaceSPT::solve(const FieldPerp& b, const FieldPerp& x0) {
9595
if (isInnerBoundaryFlagSetOnFirstX(INVERT_SET)) {
9696
// Copy x0 inner boundary into bs
9797
for (int ix = 0; ix < xbndry; ix++) {
98-
for (int iz = 0; iz < localmesh->LocalNz; iz++) {
98+
for (int iz = localmesh->zstart; iz <= localmesh->zend; iz++) {
9999
bs[ix][iz] = x0[ix][iz];
100100
}
101101
}
102102
}
103103
if (isOuterBoundaryFlagSetOnLastX(INVERT_SET)) {
104104
// Copy x0 outer boundary into bs
105105
for (int ix = localmesh->LocalNx - 1; ix >= localmesh->LocalNx - xbndry; ix--) {
106-
for (int iz = 0; iz < localmesh->LocalNz; iz++) {
106+
for (int iz = localmesh->zstart; iz <= localmesh->zend; iz++) {
107107
bs[ix][iz] = x0[ix][iz];
108108
}
109109
}
@@ -181,7 +181,7 @@ Field3D LaplaceSPT::solve(const Field3D& b, const Field3D& x0) {
181181
// Copy x0 inner boundary into bs
182182
for (int ix = 0; ix < xbndry; ix++) {
183183
for (int iy = 0; iy < localmesh->LocalNy; iy++) {
184-
for (int iz = 0; iz < localmesh->LocalNz; iz++) {
184+
for (int iz = localmesh->zstart; iz <= localmesh->zend; iz++) {
185185
bs(ix, iy, iz) = x0(ix, iy, iz);
186186
}
187187
}
@@ -191,7 +191,7 @@ Field3D LaplaceSPT::solve(const Field3D& b, const Field3D& x0) {
191191
// Copy x0 outer boundary into bs
192192
for (int ix = localmesh->LocalNx - 1; ix >= localmesh->LocalNx - xbndry; ix--) {
193193
for (int iy = 0; iy < localmesh->LocalNy; iy++) {
194-
for (int iz = 0; iz < localmesh->LocalNz; iz++) {
194+
for (int iz = localmesh->zstart; iz <= localmesh->zend; iz++) {
195195
bs(ix, iy, iz) = x0(ix, iy, iz);
196196
}
197197
}
@@ -519,15 +519,15 @@ void LaplaceSPT::finish(SPT_data& data, FieldPerp& x) {
519519
if (!localmesh->firstX()) {
520520
// Set left boundary to zero (Prevent unassigned values in corners)
521521
for (int ix = 0; ix < localmesh->xstart; ix++) {
522-
for (int kz = 0; kz < localmesh->LocalNz; kz++) {
522+
for (int kz = localmesh->zstart; kz <= localmesh->zend; kz++) {
523523
x(ix, kz) = 0.0;
524524
}
525525
}
526526
}
527527
if (!localmesh->lastX()) {
528528
// Same for right boundary
529529
for (int ix = localmesh->xend + 1; ix < localmesh->LocalNx; ix++) {
530-
for (int kz = 0; kz < localmesh->LocalNz; kz++) {
530+
for (int kz = localmesh->zstart; kz <= localmesh->zend; kz++) {
531531
x(ix, kz) = 0.0;
532532
}
533533
}

0 commit comments

Comments
 (0)