Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ CheckOptions:
# otherwise this breaks `ASSERT` macros!
- key: readability-simplify-boolean-expr.IgnoreMacros
value: 'true'

- key: misc-include-cleaner.IgnoreHeaders
value: 'petsc.*\.h;mpi\.h'
---

Disabled checks and reasons:
Expand Down
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,13 @@ set(BOUT_SOURCES
./src/invert/laplace/impls/hypre3d/hypre3d_laplace.cxx
./src/invert/laplace/impls/hypre3d/hypre3d_laplace.hxx
./src/invert/laplace/invert_laplace.cxx
./src/invert/laplacexy/impls/hypre/laplacexy-hypre.cxx
./src/invert/laplacexy/impls/hypre/laplacexy-hypre.hxx
./src/invert/laplacexy/impls/petsc/laplacexy-petsc.cxx
./src/invert/laplacexy/impls/petsc/laplacexy-petsc.hxx
./src/invert/laplacexy/impls/petsc2/laplacexy-petsc2.cxx
./src/invert/laplacexy/impls/petsc2/laplacexy-petsc2.hxx
./src/invert/laplacexy/laplacexy.cxx
./include/bout/invert/laplacexy2.hxx
./src/invert/laplacexy2/laplacexy2.cxx
./include/bout/invert/laplacexy2_hypre.hxx
./src/invert/laplacexy2/laplacexy2_hypre.cxx
./src/invert/laplacexz/impls/cyclic/laplacexz-cyclic.cxx
./src/invert/laplacexz/impls/cyclic/laplacexz-cyclic.hxx
./src/invert/laplacexz/impls/petsc/laplacexz-petsc.cxx
Expand Down
1 change: 0 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ add_subdirectory(invertable_operator)
add_subdirectory(laplacexy/alfven-wave)
add_subdirectory(laplacexy/laplace_perp)
add_subdirectory(laplacexy/simple)
add_subdirectory(laplacexy/simple-hypre)
add_subdirectory(monitor-newapi)
add_subdirectory(orszag-tang)
add_subdirectory(preconditioning/wave)
Expand Down
2 changes: 1 addition & 1 deletion examples/dalf3/dalf3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class DALF3 : public PhysicsModel {
// LaplaceXY for n=0 solve
if (split_n0) {
// Create an XY solver for n=0 component
laplacexy = std::make_unique<LaplaceXY>(mesh);
laplacexy = LaplaceXY::create(mesh);
phi2D = 0.0; // Starting guess
}

Expand Down
37 changes: 14 additions & 23 deletions examples/elm-pb-outerloop/elm_pb_outerloop.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,26 @@

/*******************************************************************************/

#include "bout/build_defines.hxx"
#include "bout/options.hxx"
#include <bout/bout.hxx>
#include <bout/constants.hxx>
#include <bout/derivs.hxx>
#include <bout/field_factory.hxx>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: duplicate include [readability-duplicate-include]

examples/elm-pb-outerloop/elm_pb_outerloop.cxx:34:

- #include <bout/derivs.hxx>
- #include <bout/derivs.hxx>
+ #include <bout/derivs.hxx>

#include <bout/initialprofiles.hxx>
#include <bout/interpolation.hxx>
#include <bout/invert/laplacexy.hxx>
#include <bout/invert_laplace.hxx>
#include <bout/invert_parderiv.hxx>
#include <bout/msg_stack.hxx>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: duplicate include [readability-duplicate-include]

examples/elm-pb-outerloop/elm_pb_outerloop.cxx:40:

- #include <bout/invert_laplace.hxx>
- #include <bout/invert_laplace.hxx>
+ #include <bout/invert_laplace.hxx>

#include <bout/sourcex.hxx>
#include <bout/utils.hxx>

#include <math.h>

#include <bout/derivs.hxx>
#include <bout/invert_laplace.hxx>
#include <bout/physicsmodel.hxx>
#include <bout/rajalib.hxx> // Defines BOUT_FOR_RAJA
#include <bout/single_index_ops.hxx>
#include <bout/smoothing.hxx>
#include <bout/sourcex.hxx>
#include <bout/utils.hxx>

#include <bout/rajalib.hxx> // Defines BOUT_FOR_RAJA

#if BOUT_HAS_HYPRE
#include <bout/invert/laplacexy2_hypre.hxx>
#endif

#include <bout/field_factory.hxx>
#include <math.h>

CELL_LOC loc = CELL_CENTRE;

Expand Down Expand Up @@ -91,6 +84,10 @@ BOUT_OVERRIDE_DEFAULT_OPTION("phi:bndry_target", "neumann");
BOUT_OVERRIDE_DEFAULT_OPTION("phi:bndry_xin", "none");
BOUT_OVERRIDE_DEFAULT_OPTION("phi:bndry_xout", "none");

#if BOUT_HAS_HYPRE
BOUT_OVERRIDE_DEFAULT_OPTION("laplacexy:type", "hypre");
#endif

/// 3-field ELM simulation
class ELMpb : public PhysicsModel {
private:
Expand Down Expand Up @@ -242,11 +239,7 @@ class ELMpb : public PhysicsModel {

bool split_n0; // Solve the n=0 component of potential

#if BOUT_HAS_HYPRE
std::unique_ptr<LaplaceXY2Hypre> laplacexy{nullptr}; // Laplacian solver in X-Y (n=0)
#else
std::unique_ptr<LaplaceXY> laplacexy{nullptr}; // Laplacian solver in X-Y (n=0)
#endif

Field2D phi2D; // Axisymmetric phi

Expand Down Expand Up @@ -567,13 +560,11 @@ class ELMpb : public PhysicsModel {
split_n0 = options["split_n0"]
.doc("Solve zonal (n=0) component of potential using LaplaceXY?")
.withDefault(false);

if (split_n0) {
// Create an XY solver for n=0 component
#if BOUT_HAS_HYPRE
laplacexy = bout::utils::make_unique<LaplaceXY2Hypre>(mesh);
#else
laplacexy = bout::utils::make_unique<LaplaceXY>(mesh);
#endif
laplacexy = LaplaceXY::create(mesh);

// Set coefficients for Boussinesq solve
laplacexy->setCoefs(1.0, 0.0);
phi2D = 0.0; // Starting guess
Expand Down
19 changes: 6 additions & 13 deletions examples/elm-pb/elm_pb.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@

#include <math.h>

#if BOUT_HAS_HYPRE
#include <bout/invert/laplacexy2_hypre.hxx>
#endif

#include <bout/field_factory.hxx>

CELL_LOC loc = CELL_CENTRE;
Expand All @@ -36,6 +32,10 @@ BOUT_OVERRIDE_DEFAULT_OPTION("phi:bndry_target", "neumann");
BOUT_OVERRIDE_DEFAULT_OPTION("phi:bndry_xin", "none");
BOUT_OVERRIDE_DEFAULT_OPTION("phi:bndry_xout", "none");

#if BOUT_HAS_HYPRE
Copy link
Copy Markdown
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_HAS_HYPRE" is directly included [misc-include-cleaner]

examples/elm-pb/elm_pb.cxx:7:

- #include <bout/bout.hxx>
+ #include "bout/build_defines.hxx"
+ #include <bout/bout.hxx>

BOUT_OVERRIDE_DEFAULT_OPTION("laplacexy:type", "hypre");
#endif

/// 3-field ELM simulation
class ELMpb : public PhysicsModel {
private:
Expand Down Expand Up @@ -188,11 +188,7 @@ class ELMpb : public PhysicsModel {

bool split_n0; // Solve the n=0 component of potential

#if BOUT_HAS_HYPRE
std::unique_ptr<LaplaceXY2Hypre> laplacexy{nullptr}; // Laplacian solver in X-Y (n=0)
#else
std::unique_ptr<LaplaceXY> laplacexy{nullptr}; // Laplacian solver in X-Y (n=0)
#endif

Field2D phi2D; // Axisymmetric phi

Expand Down Expand Up @@ -525,11 +521,8 @@ class ELMpb : public PhysicsModel {
.withDefault(false);
if (split_n0) {
// Create an XY solver for n=0 component
#if BOUT_HAS_HYPRE
laplacexy = bout::utils::make_unique<LaplaceXY2Hypre>(mesh);
#else
laplacexy = bout::utils::make_unique<LaplaceXY>(mesh);
#endif
laplacexy = LaplaceXY::create(mesh);

// Set coefficients for Boussinesq solve
laplacexy->setCoefs(1.0, 0.0);
phi2D = 0.0; // Starting guess
Expand Down
7 changes: 4 additions & 3 deletions examples/laplacexy/alfven-wave/alfven.cxx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

#include <bout/field_factory.hxx>
#include <bout/invert/laplacexy.hxx>
#include <bout/invert/laplacexz.hxx>
#include <bout/invert_laplace.hxx>
#include <bout/physicsmodel.hxx>

#include <memory>

/// Fundamental constants
const BoutReal PI = 3.14159265;
const BoutReal e0 = 8.854e-12; // Permittivity of free space
Expand Down Expand Up @@ -32,7 +33,7 @@ class Alfven : public PhysicsModel {

bool laplace_perp; // Use Laplace_perp or Delp2?
bool split_n0; // Split solve into n=0 and n~=0?
LaplaceXY* laplacexy; // Laplacian solver in X-Y (n=0)
std::unique_ptr<LaplaceXY> laplacexy{nullptr}; // Laplacian solver in X-Y (n=0)

bool newXZsolver;
std::unique_ptr<Laplacian> phiSolver; // Old Laplacian in X-Z
Expand Down Expand Up @@ -80,7 +81,7 @@ class Alfven : public PhysicsModel {

if (split_n0) {
// Create an XY solver for n=0 component
laplacexy = new LaplaceXY(mesh);
laplacexy = LaplaceXY::create(mesh);
phi2D = 0.0; // Starting guess
}

Expand Down
4 changes: 2 additions & 2 deletions examples/laplacexy/laplace_perp/test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ int main(int argc, char** argv) {
FieldFactory::get()->create2D("input_field", Options::getRoot(), mesh);

// Create a LaplaceXY solver
LaplaceXY laplacexy{mesh};
auto laplacexy = LaplaceXY::create(mesh);

// Solve, using 0.0 as starting guess
Field2D solved = laplacexy.solve(input, 0.0);
Field2D solved = laplacexy->solve(input, 0.0);

// Need to communicate guard cells
mesh->communicate(solved);
Expand Down
1 change: 0 additions & 1 deletion examples/laplacexy/simple-hypre/.gitignore

This file was deleted.

15 changes: 0 additions & 15 deletions examples/laplacexy/simple-hypre/CMakeLists.txt

This file was deleted.

37 changes: 0 additions & 37 deletions examples/laplacexy/simple-hypre/data/BOUT.inp

This file was deleted.

30 changes: 0 additions & 30 deletions examples/laplacexy/simple-hypre/test-laplacexy-hypre.cxx

This file was deleted.

5 changes: 4 additions & 1 deletion examples/laplacexy/simple/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ if (NOT TARGET bout++::bout++)
find_package(bout++ REQUIRED)
endif()

bout_add_example(laplacexy-simple SOURCES test-laplacexy.cxx)
bout_add_example(laplacexy-simple
SOURCES test-laplacexy.cxx
DATA_DIRS data hypre
)
7 changes: 6 additions & 1 deletion examples/laplacexy/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and preconditioners. See the "ksptype" and "pctype" settings in BOUT.inp

Run with

$ ./test-laplacexy -ksp_monitor
$ ./test-laplacexy -laplacexy:petsc:ksp_monitor

which should print the KSP norms from PETSc:

Expand All @@ -31,3 +31,8 @@ which should print the KSP norms from PETSc:
16 KSP Residual norm 4.309526296050e-01
17 KSP Residual norm 1.115269396077e-01
18 KSP Residual norm 4.334487475743e-13

HYPRE
-----

Use the `hypre` directory to use the HYPRE preconditioner instead of PETSc.
23 changes: 23 additions & 0 deletions examples/laplacexy/simple/hypre/BOUT.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Simple test of the LaplaceXY solver using HYPRE
#
# Inverts a given function (rhs), writing "rhs" and solution "x" to file
#

[mesh]

# Mesh sizes
nx = 20
ny = 32
nz = 1

# mesh spacing
dx = 1.0
dy = 1.0
dz = 1.0

[laplacexy]
type = hypre

# Function to be inverted
rhs = sin(2*pi*x)*sin(y)
8 changes: 3 additions & 5 deletions examples/laplacexy/simple/test-laplacexy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ int main(int argc, char** argv) {
BoutInitialise(argc, argv);

/// Create a LaplaceXY object
LaplaceXY laplacexy(bout::globals::mesh);
auto laplacexy = LaplaceXY::create(bout::globals::mesh);
Copy link
Copy Markdown
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]

examples/laplacexy/simple/test-laplacexy.cxx:1:

- #include <bout/bout.hxx>
+ #include "bout/globals.hxx"
+ #include <bout/bout.hxx>


/// Generate rhs function
Field2D rhs = FieldFactory::get()->create2D("laplacexy:rhs", Options::getRoot(),
bout::globals::mesh);

/// Solution
Field2D x = 0.0;

x = laplacexy.solve(rhs, x);
Field2D result = laplacexy->solve(rhs, 0.0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'result' of type 'Field2D' can be declared 'const' [misc-const-correctness]

Suggested change
Field2D result = laplacexy->solve(rhs, 0.0);
Field2D const result = laplacexy->solve(rhs, 0.0);


Options dump;
dump["rhs"] = rhs;
dump["x"] = x;
dump["result"] = result;
bout::writeDefaultOutputFile(dump);

BoutFinalise();
Expand Down
Loading