Skip to content

Commit f18ee27

Browse files
authored
Merge pull request #3206 from boutproject/add-assert-non-parallel
Add some asserts for non parallelised XZ interpolation
2 parents 182975e + 49028fe commit f18ee27

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

include/bout/interpolation_xz.hxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ public:
238238
const std::string& region = "RGN_NOBNDRY") const override;
239239
};
240240

241+
/// XZLagrange4pt interpolation class
242+
///
243+
/// Does not support MPI splitting in X
241244
class XZLagrange4pt : public XZInterpolation {
242245
Tensor<int> i_corner; // x-index of bottom-left grid point
243246
Tensor<int> k_corner; // z-index of bottom-left grid point
@@ -271,6 +274,9 @@ public:
271274
BoutReal lagrange_4pt(const BoutReal v[], BoutReal offset) const;
272275
};
273276

277+
/// XZBilinear interpolation calss
278+
///
279+
/// Does not support MPI splitting in X.
274280
class XZBilinear : public XZInterpolation {
275281
Tensor<int> i_corner; // x-index of bottom-left grid point
276282
Tensor<int> k_corner; // z-index of bottom-left grid point

src/mesh/interpolation/bilinear_xz.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ XZBilinear::XZBilinear(int y_offset, Mesh* mesh)
3131
: XZInterpolation(y_offset, mesh), w0(localmesh), w1(localmesh), w2(localmesh),
3232
w3(localmesh) {
3333

34+
if (localmesh->getNXPE() > 1) {
35+
throw BoutException("XZBilinear interpolation does not support MPI splitting in X");
36+
}
37+
3438
// Index arrays contain guard cells in order to get subscripts right
3539
i_corner.reallocate(localmesh->LocalNx, localmesh->LocalNy, localmesh->LocalNz);
3640
k_corner.reallocate(localmesh->LocalNx, localmesh->LocalNy, localmesh->LocalNz);

src/mesh/interpolation/hermite_spline_xz.cxx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ class IndConverter {
101101
}
102102
};
103103

104-
XZHermiteSpline::XZHermiteSpline(int y_offset, Mesh* mesh)
105-
: XZInterpolation(y_offset, mesh), h00_x(localmesh), h01_x(localmesh),
104+
XZHermiteSpline::XZHermiteSpline(int y_offset, Mesh* meshin)
105+
: XZInterpolation(y_offset, meshin), h00_x(localmesh), h01_x(localmesh),
106106
h10_x(localmesh), h11_x(localmesh), h00_z(localmesh), h01_z(localmesh),
107107
h10_z(localmesh), h11_z(localmesh) {
108108

@@ -346,6 +346,9 @@ Field3D XZHermiteSpline::interpolate(const Field3D& f, const std::string& region
346346
ASSERT1(f.getMesh() == localmesh);
347347
Field3D f_interp{emptyFrom(f)};
348348

349+
const auto region2 =
350+
y_offset == 0 ? "RGN_NOY" : fmt::format("RGN_YPAR_{:+d}", y_offset);
351+
349352
#if USE_NEW_WEIGHTS
350353
#ifdef HS_USE_PETSC
351354
BoutReal* ptr;
@@ -355,7 +358,6 @@ Field3D XZHermiteSpline::interpolate(const Field3D& f, const std::string& region
355358
VecRestoreArray(rhs, &ptr);
356359
MatMult(petscWeights, rhs, result);
357360
VecGetArrayRead(result, &cptr);
358-
const auto region2 = y_offset == 0 ? region : fmt::format("RGN_YPAR_{:+d}", y_offset);
359361
BOUT_FOR(i, f.getRegion(region2)) {
360362
f_interp[i] = cptr[int(i)];
361363
ASSERT2(std::isfinite(cptr[int(i)]));
@@ -375,11 +377,10 @@ Field3D XZHermiteSpline::interpolate(const Field3D& f, const std::string& region
375377
}
376378
}
377379
#endif
378-
return f_interp;
379380
#else
380381
// Derivatives are used for tension and need to be on dimensionless
381382
// coordinates
382-
const auto region2 = fmt::format("RGN_YPAR_{:+d}", y_offset);
383+
383384
// f has been communcated, and thus we can assume that the x-boundaries are
384385
// also valid in the y-boundary. Thus the differentiated field needs no
385386
// extra comms.
@@ -418,8 +419,10 @@ Field3D XZHermiteSpline::interpolate(const Field3D& f, const std::string& region
418419
ASSERT2(std::isfinite(f_interp[iyp]) || i.x() < localmesh->xstart
419420
|| i.x() > localmesh->xend);
420421
}
421-
return f_interp;
422422
#endif
423+
f_interp.setRegion(region2);
424+
ASSERT2(f_interp.getRegionID());
425+
return f_interp;
423426
}
424427

425428
Field3D XZHermiteSpline::interpolate(const Field3D& f, const Field3D& delta_x,

src/mesh/interpolation/lagrange_4pt_xz.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
XZLagrange4pt::XZLagrange4pt(int y_offset, Mesh* mesh)
3030
: XZInterpolation(y_offset, mesh), t_x(localmesh), t_z(localmesh) {
3131

32+
if (localmesh->getNXPE() > 1) {
33+
throw BoutException(
34+
"XZLagrange4pt interpolation does not support MPI splitting in X");
35+
}
36+
3237
// Index arrays contain guard cells in order to get subscripts right
3338
i_corner.reallocate(localmesh->LocalNx, localmesh->LocalNy, localmesh->LocalNz);
3439
k_corner.reallocate(localmesh->LocalNx, localmesh->LocalNy, localmesh->LocalNz);

0 commit comments

Comments
 (0)