-
Notifications
You must be signed in to change notification settings - Fork 104
Add more tests for FCI operators #3196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
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
- 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.
* next: (78 commits) Apply clang-format changes Add `has_hypre` to python `boutconfig` Update examples for LaplaceXY factory Fix call to virtual function in ctor CI: Don't warn about including PETSc or MPI symbols directly Try to appease clang-tidy `misc-include-cleaner` Remove private variables from base class Fix typo in define Apply clang-format changes Add factory for LaplaceXY, LaplaceXY2, LaplaceXY2Hypre Enable non-const iteration over `Options` snes solver: Consider timestep change at output Bump DOI Add shim for ARKodeGetNumRhsEvals Suppress warning from `nodiscard` function Remove `boututils` from requirements; bump `boutdata` Fix deprecation warning Bump bundled fmt Fix some easy clang-tidy snes warnings Fix reorder warning from snes ...
There was a problem hiding this 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
dschwoerer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, no BCs set because all the input fields are created from expressions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, these changes are not in next, only in f3dwy (PR #3197 )
There was a problem hiding this 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
|
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 |
This allows the user to control the clipping, allowing some overshoot Also restore the FCI MMS test with this interpolator
|
I've used @dschwoerer's suggestion and added |
There was a problem hiding this 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
|
|
||
| class XZInterpolationFactory | ||
| : public Factory<XZInterpolation, XZInterpolationFactory, Mesh*> { | ||
| : public Factory<XZInterpolation, XZInterpolationFactory, Mesh*, Options*> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "Factory" is directly included [misc-include-cleaner]
return Factory::create(getType(options), mesh, options);
^
