Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5502ce3
Allow XZHermiteSpline also without y-offset
dschwoerer Sep 27, 2024
c74d330
Add communication routine for FCI operation
dschwoerer Jan 15, 2025
afc68d9
Unify XZMonotonicHermiteSpline and XZMonotonicHermiteSpline
dschwoerer Jan 15, 2025
84237c8
Use x-splitting for monotonichermitespline test
dschwoerer Jan 15, 2025
0662449
Set region for lagrange4pt
dschwoerer Jan 16, 2025
f77849e
Add monotonic check also to other code branches
dschwoerer Jan 21, 2025
820f0a5
use lower_bound instead of find
dschwoerer Jan 21, 2025
1178243
Do not shadow mapping
dschwoerer Jan 21, 2025
3d6f587
Ensure setup has been called
dschwoerer Jan 21, 2025
265c8cd
Use pointer to data
dschwoerer Jan 21, 2025
16a162e
Call setup before communicator is used
dschwoerer Jan 21, 2025
e5878c1
Deduplicate code
dschwoerer Jan 21, 2025
aee2713
Fix tags for comm
dschwoerer Jan 21, 2025
b4f7be5
Use pointer instead of std::vector
dschwoerer Jan 21, 2025
578ee8d
Do not reuse requests if the array is still in use
dschwoerer Jan 21, 2025
bf9c9eb
rename offset to getOffsets
dschwoerer Jan 22, 2025
2155f06
Fix: mixup of sending / receiving size
dschwoerer Jan 22, 2025
0662247
Fix receive data offset
dschwoerer Jan 22, 2025
28d4e28
Add check to ensure the proc layout is as expected
dschwoerer Jan 22, 2025
e4507d9
clang-format
dschwoerer Jan 22, 2025
d7ba297
Use BOUT++ assert
dschwoerer Jan 22, 2025
f55f8e4
Fix check
dschwoerer Jan 22, 2025
0e9f7d6
Take periodicity into account
dschwoerer Jan 28, 2025
944adfb
Sort a reference, not a copy
dschwoerer Jan 28, 2025
6daec20
Only communicate non-empty vectors
dschwoerer Jan 28, 2025
3444dd0
Make check stricter
dschwoerer Jan 31, 2025
91bee68
Fix: include global offset in monotonic spline
dschwoerer Jan 31, 2025
d7aeae4
make fci_comm openmp thread safe
dschwoerer Jan 31, 2025
ac5cc70
Fix communication for fci
dschwoerer Feb 7, 2025
885b465
Add check to reduce risk of bugs
dschwoerer Feb 7, 2025
a1c4033
tests: Increase nx for hermitespline interpolation boundary problem
ZedThree Oct 9, 2025
1c25b0e
region may be not used
dschwoerer Feb 2, 2026
c7f8504
Fix [[maybe_unused]] location
dschwoerer Feb 2, 2026
96aa2bd
Add some wiggle room for monotonichermitespline
dschwoerer Feb 4, 2026
65880e4
[bot] Apply format changes
dschwoerer Mar 3, 2026
a91d3e7
[bot] Add last format changes commit to ignore file
dschwoerer Mar 3, 2026
f473a6b
Apply fixes from clang-format
dschwoerer Mar 4, 2026
f341037
Apply clang-tidy changes
dschwoerer Mar 4, 2026
999d4ca
Apply clang-tidy improvements
dschwoerer Mar 4, 2026
614a727
MPI_Request may not be a pointer
dschwoerer Mar 4, 2026
d1cfb8a
[bot] Apply format changes
dschwoerer Mar 4, 2026
5c0d41d
[bot] Add last format changes commit to ignore file
dschwoerer Mar 4, 2026
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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ a71cad2dd6ace5741a754e2ca7daacd4bb094e0e
2c2402ed59c91164eaff46dee0f79386b7347e9e
05b7c571544c3bcb153fce67d12b9ac48947fc2d
c8f38049359170a34c915e209276238ea66b9a1e
65880e4af16cb95438437bf057c4b9fdb427b142
d1cfb8abd6aa5c76e6c1a4d7ab20929c65f8afc2
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,12 @@ set(BOUT_SOURCES
./src/mesh/interpolation/hermite_spline_z.cxx
./src/mesh/interpolation/interpolation_z.cxx
./src/mesh/interpolation/lagrange_4pt_xz.cxx
./src/mesh/interpolation/monotonic_hermite_spline_xz.cxx
./src/mesh/invert3x3.hxx
./src/mesh/mesh.cxx
./src/mesh/parallel/fci.cxx
./src/mesh/parallel/fci.hxx
./src/mesh/parallel/fci_comm.cxx
./src/mesh/parallel/fci_comm.hxx
./src/mesh/parallel/identity.cxx
./src/mesh/parallel/shiftedmetric.cxx
./src/mesh/parallel/shiftedmetricinterp.cxx
Expand Down
90 changes: 28 additions & 62 deletions include/bout/interpolation_xz.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <bout/bout_types.hxx>
#include <bout/generic_factory.hxx>
#include <bout/mask.hxx>
#include <array>

#define USE_NEW_WEIGHTS 1
#if BOUT_HAS_PETSC
Expand All @@ -38,6 +39,7 @@
#endif

class Options;
class GlobalField3DAccess;

/// Interpolate a field onto a perturbed set of points
const Field3D interpolate(const Field3D& f, const Field3D& delta_x,
Expand Down Expand Up @@ -135,14 +137,26 @@ public:
}
};

class XZHermiteSpline : public XZInterpolation {
/// Monotonic Hermite spline interpolator
///
/// Similar to XZHermiteSpline, so uses most of the same code.
/// Forces the interpolated result to be in the range of the
/// neighbouring cell values. This prevents unphysical overshoots,
/// but also degrades accuracy near maxima and minima.
/// Perhaps should only impose near boundaries, since that is where
/// problems most obviously occur.
template <bool monotonic>
class XZHermiteSplineBase : public XZInterpolation {
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: class 'XZHermiteSplineBase' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]

class XZHermiteSplineBase : public XZInterpolation {
      ^

protected:
/// This is protected rather than private so that it can be
/// extended and used by HermiteSplineMonotonic

Tensor<SpecificInd<IND_TYPE::IND_3D>> i_corner; // index of bottom-left grid point
Tensor<int> k_corner; // z-index of bottom-left grid point

std::unique_ptr<GlobalField3DAccess> gf3daccess;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: member variable 'gf3daccess' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]

  std::unique_ptr<GlobalField3DAccess> gf3daccess;
                                       ^

Tensor<std::array<int, 4>> g3dinds;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: member variable 'g3dinds' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]

  Tensor<std::array<int, 4>> g3dinds;
                             ^


// Basis functions for cubic Hermite spline interpolation
// see http://en.wikipedia.org/wiki/Cubic_Hermite_spline
// The h00 and h01 basis functions are applied to the function itself
Expand All @@ -167,15 +181,20 @@ protected:
Vec rhs, result;
#endif

/// Factors to allow for some wiggleroom
BoutReal abs_fac_monotonic{1e-2};
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: member variable 'abs_fac_monotonic' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]

  BoutReal abs_fac_monotonic{1e-2};
           ^

BoutReal rel_fac_monotonic{1e-1};
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: member variable 'rel_fac_monotonic' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]

  BoutReal rel_fac_monotonic{1e-1};
           ^


public:
XZHermiteSpline(Mesh* mesh = nullptr, [[maybe_unused]] Options* options = nullptr)
: XZHermiteSpline(0, mesh) {}
XZHermiteSpline(int y_offset = 0, Mesh* mesh = nullptr);
XZHermiteSpline(const BoutMask& mask, int y_offset = 0, Mesh* mesh = nullptr)
: XZHermiteSpline(y_offset, mesh) {
XZHermiteSplineBase(Mesh* mesh = nullptr, [[maybe_unused]] Options* options = nullptr)
: XZHermiteSplineBase(0, mesh, options) {}
XZHermiteSplineBase(int y_offset = 0, Mesh* mesh = nullptr, Options* options = nullptr);
XZHermiteSplineBase(const BoutMask& mask, int y_offset = 0, Mesh* mesh = nullptr,
Options* options = nullptr)
: XZHermiteSplineBase(y_offset, mesh, options) {
setRegion(regionFromMask(mask, localmesh));
}
~XZHermiteSpline() {
~XZHermiteSplineBase() override {
#if HS_USE_PETSC
if (isInit) {
MatDestroy(&petscWeights);
Expand Down Expand Up @@ -205,61 +224,8 @@ public:
getWeightsForYApproximation(int i, int j, int k, int yoffset) override;
};

/// Monotonic Hermite spline interpolator
///
/// Similar to XZHermiteSpline, so uses most of the same code.
/// Forces the interpolated result to be in the range of the
/// neighbouring cell values. This prevents unphysical overshoots,
/// but also degrades accuracy near maxima and minima.
/// Perhaps should only impose near boundaries, since that is where
/// problems most obviously occur.
///
/// You can control how tight the clipping to the range of the neighbouring cell
/// values through ``rtol`` and ``atol``:
///
/// diff = (max_of_neighours - min_of_neighours) * rtol + atol
///
/// and the interpolated value is instead clipped to the range
/// ``[min_of_neighours - diff, max_of_neighours + diff]``
class XZMonotonicHermiteSpline : public XZHermiteSpline {
/// Absolute tolerance for clipping
BoutReal atol = 0.0;
/// Relative tolerance for clipping
BoutReal rtol = 1.0;

public:
XZMonotonicHermiteSpline(Mesh* mesh = nullptr, Options* options = nullptr)
: XZHermiteSpline(0, mesh),
atol{(*options)["atol"]
.doc("Absolute tolerance for clipping overshoot")
.withDefault(0.0)},
rtol{(*options)["rtol"]
.doc("Relative tolerance for clipping overshoot")
.withDefault(1.0)} {
if (localmesh->getNXPE() > 1) {
throw BoutException("Do not support MPI splitting in X");
}
}
XZMonotonicHermiteSpline(int y_offset = 0, Mesh* mesh = nullptr)
: XZHermiteSpline(y_offset, mesh) {
if (localmesh->getNXPE() > 1) {
throw BoutException("Do not support MPI splitting in X");
}
}
XZMonotonicHermiteSpline(const BoutMask& mask, int y_offset = 0, Mesh* mesh = nullptr)
: XZHermiteSpline(mask, y_offset, mesh) {
if (localmesh->getNXPE() > 1) {
throw BoutException("Do not support MPI splitting in X");
}
}

using XZHermiteSpline::interpolate;
/// Interpolate using precalculated weights.
/// This function is called by the other interpolate functions
/// in the base class XZHermiteSpline.
Field3D interpolate(const Field3D& f,
const std::string& region = "RGN_NOBNDRY") const override;
};
using XZMonotonicHermiteSpline = XZHermiteSplineBase<true>;
using XZHermiteSpline = XZHermiteSplineBase<false>;

/// XZLagrange4pt interpolation class
///
Expand Down
2 changes: 1 addition & 1 deletion include/bout/msg_stack.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public:
}

void pop() {}
void pop(int [[maybe_unused]] id) {}
void pop([[maybe_unused]] int id) {}
void clear() {}

void dump() {}
Expand Down
3 changes: 2 additions & 1 deletion include/bout/region.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class BoutMask;
BOUT_FOR_OMP(index, (region), for schedule(BOUT_OPENMP_SCHEDULE) nowait)
// NOLINTEND(cppcoreguidelines-macro-usage,bugprone-macro-parentheses)

enum class IND_TYPE { IND_3D = 0, IND_2D = 1, IND_PERP = 2 };
enum class IND_TYPE { IND_3D = 0, IND_2D = 1, IND_PERP = 2, IND_GLOBAL_3D = 3 };
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: enum 'IND_TYPE' uses a larger base type ('int', size: 4 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size [performance-enum-size]

enum class IND_TYPE { IND_3D = 0, IND_2D = 1, IND_PERP = 2, IND_GLOBAL_3D = 3 };
           ^


/// Indices base class for Fields -- Regions are dereferenced into these
///
Expand Down Expand Up @@ -386,6 +386,7 @@ inline SpecificInd<N> operator-(SpecificInd<N> lhs, const SpecificInd<N>& rhs) {
using Ind3D = SpecificInd<IND_TYPE::IND_3D>;
using Ind2D = SpecificInd<IND_TYPE::IND_2D>;
using IndPerp = SpecificInd<IND_TYPE::IND_PERP>;
using IndG3D = SpecificInd<IND_TYPE::IND_GLOBAL_3D>;

/// Get string representation of Ind3D
inline std::string toString(const Ind3D& i) {
Expand Down
Loading