Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/bout/interpolation_xz.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ public:
const std::string& region = "RGN_NOBNDRY") const override;
};

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

/// XZBilinear interpolation calss
///
/// Does not support MPI splitting in X.
class XZBilinear : public XZInterpolation {
Tensor<int> i_corner; // x-index of bottom-left grid point
Tensor<int> k_corner; // z-index of bottom-left grid point
Expand Down
4 changes: 4 additions & 0 deletions src/mesh/interpolation/bilinear_xz.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ XZBilinear::XZBilinear(int y_offset, Mesh* mesh)
: XZInterpolation(y_offset, mesh), w0(localmesh), w1(localmesh), w2(localmesh),
w3(localmesh) {

if (localmesh->getNXPE() > 1) {
throw BoutException("XZBilinear interpolation does not support MPI splitting in X");
}

// Index arrays contain guard cells in order to get subscripts right
i_corner.reallocate(localmesh->LocalNx, localmesh->LocalNy, localmesh->LocalNz);
k_corner.reallocate(localmesh->LocalNx, localmesh->LocalNy, localmesh->LocalNz);
Expand Down
15 changes: 9 additions & 6 deletions src/mesh/interpolation/hermite_spline_xz.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class IndConverter {
}
};

XZHermiteSpline::XZHermiteSpline(int y_offset, Mesh* mesh)
: XZInterpolation(y_offset, mesh), h00_x(localmesh), h01_x(localmesh),
XZHermiteSpline::XZHermiteSpline(int y_offset, Mesh* meshin)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: constructor does not initialize these fields: petscWeights, rhs, result [cppcoreguidelines-pro-type-member-init]

include/bout/interpolation_xz.hxx:163:

-   Mat petscWeights;
-   Vec rhs, result;
+   Mat petscWeights{};
+   Vec rhs{}, result{};

: XZInterpolation(y_offset, meshin), h00_x(localmesh), h01_x(localmesh),
h10_x(localmesh), h11_x(localmesh), h00_z(localmesh), h01_z(localmesh),
h10_z(localmesh), h11_z(localmesh) {

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

const auto region2 =
y_offset == 0 ? "RGN_NOY" : fmt::format("RGN_YPAR_{:+d}", y_offset);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "fmt::format" is directly included [misc-include-cleaner]

src/mesh/interpolation/hermite_spline_xz.cxx:23:

- #include "bout/globals.hxx"
+ #include "fmt/format.h"
+ #include "bout/globals.hxx"


#if USE_NEW_WEIGHTS
#ifdef HS_USE_PETSC
BoutReal* ptr;
Expand All @@ -355,7 +358,6 @@ Field3D XZHermiteSpline::interpolate(const Field3D& f, const std::string& region
VecRestoreArray(rhs, &ptr);
MatMult(petscWeights, rhs, result);
VecGetArrayRead(result, &cptr);
const auto region2 = y_offset == 0 ? region : fmt::format("RGN_YPAR_{:+d}", y_offset);
BOUT_FOR(i, f.getRegion(region2)) {
f_interp[i] = cptr[int(i)];
ASSERT2(std::isfinite(cptr[int(i)]));
Expand All @@ -375,11 +377,10 @@ Field3D XZHermiteSpline::interpolate(const Field3D& f, const std::string& region
}
}
#endif
return f_interp;
#else
// Derivatives are used for tension and need to be on dimensionless
// coordinates
const auto region2 = fmt::format("RGN_YPAR_{:+d}", y_offset);

// f has been communcated, and thus we can assume that the x-boundaries are
// also valid in the y-boundary. Thus the differentiated field needs no
// extra comms.
Expand Down Expand Up @@ -418,8 +419,10 @@ Field3D XZHermiteSpline::interpolate(const Field3D& f, const std::string& region
ASSERT2(std::isfinite(f_interp[iyp]) || i.x() < localmesh->xstart
|| i.x() > localmesh->xend);
}
return f_interp;
#endif
f_interp.setRegion(region2);
ASSERT2(f_interp.getRegionID());
return f_interp;
}

Field3D XZHermiteSpline::interpolate(const Field3D& f, const Field3D& delta_x,
Expand Down
5 changes: 5 additions & 0 deletions src/mesh/interpolation/lagrange_4pt_xz.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
XZLagrange4pt::XZLagrange4pt(int y_offset, Mesh* mesh)
: XZInterpolation(y_offset, mesh), t_x(localmesh), t_z(localmesh) {

if (localmesh->getNXPE() > 1) {
throw BoutException(
"XZLagrange4pt interpolation does not support MPI splitting in X");
}

// Index arrays contain guard cells in order to get subscripts right
i_corner.reallocate(localmesh->LocalNx, localmesh->LocalNy, localmesh->LocalNz);
k_corner.reallocate(localmesh->LocalNx, localmesh->LocalNy, localmesh->LocalNz);
Expand Down
Loading