-
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?
Changes from all commits
74b736d
eb589e1
c0cc84b
2eda48c
636bf28
16318ec
14b4b11
da0d4c4
2f83692
0cde140
37dc273
9ac46e8
5974a6e
6ab945e
16c3718
3d3ff65
79f9d0f
cee3e44
88d8db8
9d9922c
e961e75
2674a58
f00db39
0efe4e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,9 @@ | |
| #ifndef BOUT_INTERP_XZ_H | ||
| #define BOUT_INTERP_XZ_H | ||
|
|
||
| #include "bout/mask.hxx" | ||
| #include <bout/bout_types.hxx> | ||
| #include <bout/generic_factory.hxx> | ||
| #include <bout/mask.hxx> | ||
|
|
||
| #define USE_NEW_WEIGHTS 1 | ||
| #if BOUT_HAS_PETSC | ||
|
|
@@ -166,7 +168,8 @@ protected: | |
| #endif | ||
|
|
||
| public: | ||
| XZHermiteSpline(Mesh* mesh = nullptr) : XZHermiteSpline(0, mesh) {} | ||
| 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) { | ||
|
|
@@ -210,9 +213,29 @@ public: | |
| /// 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) : XZHermiteSpline(0, mesh) { | ||
| 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"); | ||
| } | ||
|
|
@@ -248,7 +271,8 @@ class XZLagrange4pt : public XZInterpolation { | |
| Field3D t_x, t_z; | ||
|
|
||
| public: | ||
| XZLagrange4pt(Mesh* mesh = nullptr) : XZLagrange4pt(0, mesh) {} | ||
| XZLagrange4pt(Mesh* mesh = nullptr, [[maybe_unused]] Options* options = nullptr) | ||
| : XZLagrange4pt(0, mesh) {} | ||
| XZLagrange4pt(int y_offset = 0, Mesh* mesh = nullptr); | ||
| XZLagrange4pt(const BoutMask& mask, int y_offset = 0, Mesh* mesh = nullptr) | ||
| : XZLagrange4pt(y_offset, mesh) { | ||
|
|
@@ -284,7 +308,8 @@ class XZBilinear : public XZInterpolation { | |
| Field3D w0, w1, w2, w3; | ||
|
|
||
| public: | ||
| XZBilinear(Mesh* mesh = nullptr) : XZBilinear(0, mesh) {} | ||
| XZBilinear(Mesh* mesh = nullptr, [[maybe_unused]] Options* options = nullptr) | ||
| : XZBilinear(0, mesh) {} | ||
| XZBilinear(int y_offset = 0, Mesh* mesh = nullptr); | ||
| XZBilinear(const BoutMask& mask, int y_offset = 0, Mesh* mesh = nullptr) | ||
| : XZBilinear(y_offset, mesh) { | ||
|
|
@@ -308,18 +333,18 @@ public: | |
| }; | ||
|
|
||
| class XZInterpolationFactory | ||
| : public Factory<XZInterpolation, XZInterpolationFactory, Mesh*> { | ||
| : public Factory<XZInterpolation, XZInterpolationFactory, Mesh*, Options*> { | ||
| public: | ||
| static constexpr auto type_name = "XZInterpolation"; | ||
| static constexpr auto section_name = "xzinterpolation"; | ||
| static constexpr auto option_name = "type"; | ||
| static constexpr auto default_type = "hermitespline"; | ||
|
|
||
| ReturnType create(Options* options = nullptr, Mesh* mesh = nullptr) const { | ||
| return Factory::create(getType(options), mesh); | ||
| return Factory::create(getType(options), mesh, options); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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);
^ |
||
| } | ||
| ReturnType create(const std::string& type, [[maybe_unused]] Options* options) const { | ||
| return Factory::create(type, nullptr); | ||
| ReturnType create(const std::string& type, Options* options) const { | ||
| return Factory::create(type, nullptr, options); | ||
| } | ||
|
|
||
| static void ensureRegistered(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,7 +171,19 @@ void XZHermiteSpline::calcWeights(const Field3D& delta_x, const Field3D& delta_z | |
| BoutReal t_x = delta_x(x, y, z) - static_cast<BoutReal>(i_corn); | ||
| BoutReal t_z = delta_z(x, y, z) - static_cast<BoutReal>(k_corner(x, y, z)); | ||
|
|
||
| // NOTE: A (small) hack to avoid one-sided differences | ||
| // NOTE: A (small) hack to avoid one-sided differences. We need at | ||
| // least 2 interior points due to an awkwardness with the | ||
| // boundaries. The splines need derivatives in x, but we don't | ||
| // know the value in the boundaries, so _any_ interpolation in the | ||
| // last interior cell can't be done. Instead, we fudge the | ||
| // interpolation in the last cell to be at the extreme right-hand | ||
| // edge of the previous cell (that is, exactly on the last | ||
| // interior point). However, this doesn't work with only one | ||
| // interior point, because we have to do something similar to the | ||
| // _first_ cell, and these two fudges cancel out and we end up | ||
| // indexing into the boundary anyway. | ||
| // TODO(peter): Can we remove this if we apply (dirichlet?) BCs to | ||
| // the X derivatives? Note that we need at least _2_ | ||
|
Comment on lines
+185
to
+186
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ... |
||
| if (i_corn >= xend) { | ||
| i_corn = xend - 1; | ||
| t_x = 1.0; | ||
|
|
||
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: