-
Notifications
You must be signed in to change notification settings - Fork 103
Add factory for LaplaceXY, LaplaceXY2, LaplaceXY2Hypre #3187
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
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 LaplaceXY { | ||
| class LaplaceXYFactory | ||
| : public Factory<LaplaceXY, LaplaceXYFactory, Mesh*, Options*, CELL_LOC> { |
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 "CELL_LOC" is directly included [misc-include-cleaner]
include/bout/invert/laplacexy.hxx:35:
- #include <bout/field2d.hxx>
+ #include "bout/bout_types.hxx"
+ #include <bout/field2d.hxx>| static constexpr auto default_type = "petsc"; | ||
|
|
||
| ReturnType create(Mesh* mesh = nullptr, Options* options = nullptr, | ||
| CELL_LOC loc = CELL_CENTRE) const { |
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 "CELL_CENTRE" is directly included [misc-include-cleaner]
CELL_LOC loc = CELL_CENTRE) const {
^| void setCoefs(const Field2D& UNUSED(A), const Field2D& UNUSED(B)) {} | ||
| const Field2D solve(const Field2D& UNUSED(rhs), const Field2D& UNUSED(x0)) { | ||
| throw BoutException("LaplaceXY requires PETSc. No LaplaceXY available"); | ||
| ReturnType create(const std::string& type, Options* options) const { |
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 "std::string" is directly included [misc-include-cleaner]
include/bout/invert/laplacexy.hxx:39:
+ #include <string>| void savePerformance(Solver& solver, const std::string& name = ""); | ||
| LaplaceXY(Mesh* m = nullptr, [[maybe_unused]] Options* options = nullptr, | ||
| const CELL_LOC loc = CELL_CENTRE) | ||
| : localmesh(m == nullptr ? bout::globals::mesh : m), location(loc) {} |
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 "bout::globals::mesh" is directly included [misc-include-cleaner]
include/bout/invert/laplacexy.hxx:35:
- #include <bout/field2d.hxx>
+ #include "bout/globals.hxx"
+ #include <bout/field2d.hxx>|
|
||
| virtual Field2D solve(const Field2D& b, const Field2D& x0) = 0; | ||
|
|
||
| static std::unique_ptr<LaplaceXY> create(Mesh* m = nullptr, Options* opt = nullptr, |
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 "std::unique_ptr" is directly included [misc-include-cleaner]
include/bout/invert/laplacexy.hxx:39:
+ #include <memory>| int n_calls = 0; | ||
|
|
||
| // Utility methods | ||
| void setPreallocationFiniteVolume(PetscInt* d_nnz, PetscInt* o_nnz); |
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 "PetscInt" is directly included [misc-include-cleaner]
src/invert/laplacexy/impls/petsc/laplacexy-petsc.hxx:37:
+ #include <petscsystypes.h>| // Monitor class used to reset performance-monitoring variables for a new | ||
| // output timestep | ||
| friend class LaplaceXYMonitor; | ||
| class LaplaceXYMonitor : public Monitor { |
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 "Monitor" is directly included [misc-include-cleaner]
src/invert/laplacexy/impls/petsc/laplacexy-petsc.hxx:37:
+ #include "bout/monitor.hxx"| auto sol = laplacexy->solve(rhs, 0.); | ||
| const auto error = (f - sol) / f; | ||
| const auto absolute_error = f - sol; | ||
| const auto max_error = max(abs(absolute_error), true); |
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 "abs" is directly included [misc-include-cleaner]
tests/integrated/test-laplacexy-short/test-laplacexy.cxx:31:
+ #include <cstdlib>| auto sol = laplacexy->solve(rhs, 0.); | ||
| const auto error = (f - sol) / f; | ||
| const auto absolute_error = f - sol; | ||
| const auto max_error = max(abs(absolute_error), true); |
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 "max" is directly included [misc-include-cleaner]
const auto max_error = max(abs(absolute_error), true);
^| const auto max_error = max(abs(absolute_error), true); | ||
|
|
||
| output << "Magnitude of maximum absolute error is " << max_error << endl; | ||
| output.write("Magnitude of maximum absolute error is {}\n", max_error); |
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 "output" is directly included [misc-include-cleaner]
tests/integrated/test-laplacexy-short/test-laplacexy.cxx:25:
- #include <bout/bout.hxx>
+ #include "bout/output.hxx"
+ #include <bout/bout.hxx>
Not quite sure why these were standalone classes, or if we indeed still want to keep all of them, but I've now squashed them into the generic factory capability so they can be switched between at runtime -- and we also avoid an annoying compiletime warning if compiling without PETSc or HYPRE!