Conversation
ZedThree
commented
Nov 4, 2025
- Add MMS tests for all the main FCI derivative operators
- A bunch of drive-by fixes for clang-tidy warnings
dschwoerer
left a comment
There was a problem hiding this comment.
Looks good!
Thanks @ZedThree
| // TODO(peter): Can we remove this if we apply (dirichlet?) BCs to | ||
| // the X derivatives? Note that we need at least _2_ |
There was a problem hiding this comment.
I do not think that applying dirichlet BCs will be in general a good idea.
I think in general this is not really an issue - anything that takes the case below should be i_corn == xend and t_x = 0. Other cases should be boundaries, and should not take this path.
There was a problem hiding this comment.
Ah, that's true about the boundaries. The pain here is for grids where there's only one point in either x or z, so this fudge ends up cancelling out and breaking things. That's probably not super common, so maybe we just need ASSERT4(mesh.Nx() >= 2) or something
There was a problem hiding this comment.
Yes, I think that is only an issue for tests, that try to have a minimal grid. I do not think we should to much effort in for them ...
| // TODO(peter): Should we apply dirichlet BCs to derivatives? | ||
|
|
There was a problem hiding this comment.
I do not think so. What would be the motivation? So we do not need two x-guard cells?
| // Div_par operators require B parallel slices: | ||
| // Coordinates::geometry doesn't ensure this (yet) | ||
| auto& Bxy = mesh->getCoordinates()->Bxy; | ||
| mesh->communicate(Bxy); |
There was a problem hiding this comment.
In general you would need to apply parallel BCs, but I guess the tested grids do not have this?
There was a problem hiding this comment.
Correct, no BCs set because all the input fields are created from expressions
There was a problem hiding this comment.
I think B should be loaded also for the parallel slices, in which case we do not need to communicate at all ...
There was a problem hiding this comment.
It doesn't seem to be the case -- the communicate was necessary here to get any parallel slices on Bxy
There was a problem hiding this comment.
Yes, these changes are not in next, only in f3dwy (PR #3197 )
|
Thanks @ZedThree ! |
|
Note that this is not https://en.wikipedia.org/wiki/Monotone_cubic_interpolation - but hermitespline - with the value cropped to the bound of the 4 surrounding values. |
|
Ah, the test do not always pass - they still fail if order is negative 😇 |
|
Ok, so the errors are just coming from extrema in the input function. The question now is what is the appropriate fix:
For reference, here's the error scaling for the different operators for
Note that they're not even first order |
|
I've used @dschwoerer's suggestion and added |
|
|
||
| class XZInterpolationFactory | ||
| : public Factory<XZInterpolation, XZInterpolationFactory, Mesh*> { | ||
| : public Factory<XZInterpolation, XZInterpolationFactory, Mesh*, Options*> { |
There was a problem hiding this comment.
warning: no header providing "Factory" is directly included [misc-include-cleaner]
include/bout/interpolation_xz.hxx:27:
- #include "bout/mask.hxx"
+ #include "bout/generic_factory.hxx"
+ #include "bout/mask.hxx"|
|
||
| ReturnType create(Options* options = nullptr, Mesh* mesh = nullptr) const { | ||
| return Factory::create(getType(options), mesh); | ||
| return Factory::create(getType(options), mesh, options); |
There was a problem hiding this comment.
warning: no header providing "Factory" is directly included [misc-include-cleaner]
return Factory::create(getType(options), mesh, options);
^- 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

