Skip to content

Conversation

@ZedThree
Copy link
Member

@ZedThree ZedThree commented Dec 3, 2025

Includes #3200 for testing

  • Split out XZPetscHermiteSpline as a separate implementation, this allows us to remove all the #ifdef mess
  • Move all the XZInterpolations into the more usual impls/ directory layout

ZedThree and others added 30 commits December 3, 2025 14:25
- Include all relevant headers, remove unused ones, add some forward
  declarations
- Make data `private` instead of `protected`
- Add getter instead of `const` member
- Change member reference to pointer
- Move ctor to .cxx file
- Use `std::array` instead of C array
- Bunch of other small clang-tidy fixes
The Div_par operators use parallel slices of B -- with 2D metrics,
these are just the field itself, in 3D we need the actual
slices. While `Coordinates::geometry` does communicate the fields, it
puts off calculating the parallel slices because that needs the fully
constructed `Coordinates`.

Upcoming changes should fix this and remove the need to explicitly
communicate `Coordinates` members.
Co-authored-by: David Bold <dschwoerer@users.noreply.github.com>
This allows the user to control the clipping, allowing some overshoot

Also restore the FCI MMS test with this interpolator
Includes bug fix:

```diff
-    BoutReal gL = n.c - n.L;
-    BoutReal gR = n.R - n.c;
+    BoutReal gL = n.c - n.m;
+    BoutReal gR = n.p - n.c;
```
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@ZedThree ZedThree force-pushed the split-petsc-hermite-spline branch from ecedb55 to d6375f0 Compare December 4, 2025 12:00
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

/// Interpolate a field onto a perturbed set of points
const Field3D interpolate(const Field3D& f, const Field3D& delta_x,
const Field3D& delta_z);
Field3D interpolate(const Field3D& f, const Field3D& delta_x, const Field3D& delta_z);
Copy link
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 "Field3D" is directly included [misc-include-cleaner]

include/bout/interpolation_xz.hxx:26:

- #include <bout/bout_types.hxx>
+ #include "bout/field3d.hxx"
+ #include <bout/bout_types.hxx>

const Field3D interpolate(const Field2D& f, const Field3D& delta_x,
const Field3D& delta_z);
const Field3D interpolate(const Field2D& f, const Field3D& delta_x);
Field3D interpolate(const Field2D& f, const Field3D& delta_x, const Field3D& delta_z);
Copy link
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 "Field2D" is directly included [misc-include-cleaner]

include/bout/interpolation_xz.hxx:26:

- #include <bout/bout_types.hxx>
+ #include "bout/field2d.hxx"
+ #include <bout/bout_types.hxx>

@ZedThree ZedThree force-pushed the split-petsc-hermite-spline branch from 24b7c6a to 66b5f4b Compare December 4, 2025 13:34
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@ZedThree ZedThree force-pushed the split-petsc-hermite-spline branch from 66b5f4b to aff19f0 Compare December 4, 2025 14:40
Comment on lines +337 to +338
Field3D XZPetscHermiteSpline::interpolate(const Field3D& f,
const std::string& region) const {
Copy link
Member Author

Choose a reason for hiding this comment

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

@dschwoerer region isn't actually used here and I don't really understand why not. This technically makes this version behave differently to the other implementations. Should they actually all use RGN_NOY/YPAR_<N>?

It doesn't look like we ever actually call interpolate with a region anywhere, so perhaps it would be better to remove the argument and fix all the implementations?

Copy link
Contributor

Choose a reason for hiding this comment

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

@dschwoerer region isn't actually used here and I don't really understand why not.

Because I could not understand why any other region should ever be used.

This technically makes this version behave differently to the other implementations. Should they actually all use RGN_NOY/YPAR_<N>?

It doesn't look like we ever actually call interpolate with a region anywhere, so perhaps it would be better to remove the argument and fix all the implementations?

Yes, removing the argument is probably best.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the intention was we might be able to use the regions for things like embedded boundaries, but at the minute that isn't possible out of the box without changes to parallel transforms and communicate, so probably best to just remove the argument for now.

@dschwoerer
Copy link
Contributor

I unified all the HermiteSpline interpolations, because they have a fair bit in common, it is much easier to keep the different versions aligned.

Maybe we should move some of the #ifdef to if constexpr + templates?

@ZedThree
Copy link
Member Author

ZedThree commented Dec 5, 2025

Ok, I can make XZHermiteSpline a base class of XZPetscHermiteSpline too to avoid the duplication of the basis calculations. We could also add XZPetscMonotonicHermiteSpline by simply doing the interpolation and clipping afterwards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants