Skip to content

Conversation

@ZedThree
Copy link
Member

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!

@ZedThree ZedThree requested a review from bendudson October 23, 2025 17:19
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

*/
class LaplaceXY {
class LaplaceXYFactory
: public Factory<LaplaceXY, LaplaceXYFactory, Mesh*, Options*, CELL_LOC> {
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 "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 {
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 "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 {
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 "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) {}
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 "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,
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 "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);
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 "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 {
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 "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);
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 "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);
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 "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);
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 "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>

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.

1 participant