Skip to content
Open
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: 2 additions & 1 deletion include/bout/array.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <omp.h>
#endif

#include "bout/build_config.hxx"
#include "bout/build_defines.hxx"

#if BOUT_HAS_UMPIRE
Expand Down Expand Up @@ -98,7 +99,7 @@ struct ArrayData {
}
iterator<T> begin() const { return data; }
iterator<T> end() const { return data + len; }
int size() const { return len; }
BOUT_FORCEINLINE int size() const { return len; }

/// Copy assignment
/// Copy the underlying data from one array to the other
Expand Down
40 changes: 23 additions & 17 deletions include/bout/assert.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,54 @@

#include "bout/boutexception.hxx"

#include <string_view>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

clang-tidy is complaining because std::string_view is only used in a macro, so add this include-what-you-use pragma to silence the warning:

Suggested change
#include <string_view>
#include <string_view> // IWYU pragma: export


Comment thread
ZedThree marked this conversation as resolved.
#ifndef CHECK
#define CHECKLEVEL 0
#else
#define CHECKLEVEL CHECK
#endif

#if CHECKLEVEL >= 0
#define ASSERT0(condition) \
if (!(condition)) { \
throw BoutException("Assertion failed in {:s}, line {:d}: {:s}", __FILE__, __LINE__, \
#condition); \
#define ASSERT0(condition) \
if (!(condition)) { \
throw BoutException("Assertion failed in {:s}, line {:d}: {:s}", \
std::string_view(__FILE__), __LINE__, \
std::string_view(#condition)); \
}
#else // CHECKLEVEL >= 0
#define ASSERT0(condition)
#endif

#if CHECKLEVEL >= 1
#define ASSERT1(condition) \
if (!(condition)) { \
throw BoutException("Assertion failed in {:s}, line {:d}: {:s}", __FILE__, __LINE__, \
#condition); \
abort(); \
#define ASSERT1(condition) \
if (!(condition)) { \
throw BoutException("Assertion failed in {:s}, line {:d}: {:s}", \
std::string_view(__FILE__), __LINE__, \
std::string_view(#condition)); \
abort(); \
}
#else // CHECKLEVEL >= 1
#define ASSERT1(condition)
#endif

#if CHECKLEVEL >= 2
#define ASSERT2(condition) \
if (!(condition)) { \
throw BoutException("Assertion failed in {:s}, line {:d}: {:s}", __FILE__, __LINE__, \
#condition); \
#define ASSERT2(condition) \
if (!(condition)) { \
throw BoutException("Assertion failed in {:s}, line {:d}: {:s}", \
std::string_view(__FILE__), __LINE__, \
std::string_view(#condition)); \
}
#else // CHECKLEVEL >= 2
#define ASSERT2(condition)
#endif

#if CHECKLEVEL >= 3
#define ASSERT3(condition) \
if (!(condition)) { \
throw BoutException("Assertion failed in {:s}, line {:d}: {:s}", __FILE__, __LINE__, \
#condition); \
#define ASSERT3(condition) \
if (!(condition)) { \
throw BoutException("Assertion failed in {:s}, line {:d}: {:s}", \
std::string_view(__FILE__), __LINE__, \
std::string_view(#condition)); \
}
#else // CHECKLEVEL >= 3
#define ASSERT3(condition)
Expand Down
2 changes: 2 additions & 0 deletions include/bout/boundary_op.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public:
BoundaryModifier() = default;
BoundaryModifier(BoundaryOp* operation) : BoundaryOp(operation->bndry), op(operation) {}
virtual BoundaryOp* cloneMod(BoundaryOp* op, const std::list<std::string>& args) = 0;

using BoundaryOp::clone;
BoundaryOp* clone(BoundaryRegion* UNUSED(region),
const std::list<std::string>& UNUSED(args)) override {
throw BoutException("This must not be used!");
Expand Down
3 changes: 2 additions & 1 deletion include/bout/fieldops.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "bout/bout_types.hxx"
#include "bout/build_config.hxx"
#include "bout/build_defines.hxx"
#include "bout/build_config.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]

include/bout/fieldops.hxx:8:

- #include "bout/build_defines.hxx"
- #include "bout/build_config.hxx"
+ #include "bout/build_defines.hxx"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

easy fix :)

#include "bout/region.hxx"

#include <cstddef>
Expand Down Expand Up @@ -366,7 +367,7 @@ struct BinaryExpr {
BinaryExpr& operator=(const BinaryExpr&) = delete;
BinaryExpr& operator=(BinaryExpr&&) = delete;

BOUT_HOST_DEVICE BOUT_FORCEINLINE int size() const { return indices.size(); }
BOUT_FORCEINLINE int size() const { return indices.size(); }
BOUT_HOST_DEVICE BOUT_FORCEINLINE BoutReal operator()(int idx) const {
return f(idx, lhs, rhs); // single‐pass fusion
}
Expand Down
6 changes: 3 additions & 3 deletions include/bout/fieldperp.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ inline FieldPerp emptyFrom<FieldPerp>(const FieldPerp& f) {
#if CHECK > 0
void checkData(const FieldPerp& f, const std::string& region = "RGN_NOX");
#else
inline void checkData(const FieldPerp& UNUSED(f),
const std::string& UNUSED(region) = "RGN_NOX") {}
inline void checkData([[maybe_unused]] const FieldPerp& f,
[[maybe_unused]] const std::string& region = "RGN_NOX") {}
#endif

/// Force guard cells of passed field \p var to NaN
Expand All @@ -452,7 +452,7 @@ inline void invalidateGuards(FieldPerp& UNUSED(var)) {}
/// toString template specialisation
/// Defined in utils.hxx
template <>
inline std::string toString<>(const FieldPerp& UNUSED(val)) {
inline std::string toString<>([[maybe_unused]] const FieldPerp& val) {
return "<FieldPerp>";
}

Expand Down
2 changes: 2 additions & 0 deletions include/bout/griddata.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ public:
*/
bool hasVar(const std::string& name) const override;

using GridDataSource::get;

/*!
* Reads strings from options. Uses Options::get to handle
* expressions
Expand Down
8 changes: 8 additions & 0 deletions include/bout/paralleltransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public:
*/
void calcParallelSlices(Field3D& f) override;

using ParallelTransform::toFieldAligned;

/*!
* The field is already aligned in Y, so this
* does nothing
Expand All @@ -141,6 +143,8 @@ public:
return result.setDirectionY(YDirectionType::Aligned);
}

using ParallelTransform::fromFieldAligned;

/*!
* The field is already aligned in Y, so this
* does nothing
Expand Down Expand Up @@ -196,6 +200,8 @@ public:
*/
void calcParallelSlices(Field3D& f) override;

using ParallelTransform::toFieldAligned;

/*!
* Uses FFTs and a phase shift to align the grid points
* with the y coordinate (along magnetic field usually).
Expand All @@ -209,6 +215,8 @@ public:
FieldPerp toFieldAligned(const FieldPerp& f,
const std::string& region = "RGN_ALL") override;

using ParallelTransform::fromFieldAligned;

/*!
* Converts a field back to X-Z orthogonal coordinates
* from field aligned coordinates.
Expand Down
2 changes: 2 additions & 0 deletions include/bout/region.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ struct SpecificInd {
case (DIRECTION::Z):
return zp(dd);
}
return *this;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, would be nicer if we could just use some unreachable thing here, as this is not really correct (and we check we've exhausted all enum values). C++23 has std::unreachable -- I think I added a macro to hermes that could be used, although I'm not sure if I tested it with nvcc. Worth using that here too?

}

/// Templated routine to return index.?m(offset), where `?` is one of {x,y,z}
Expand All @@ -274,6 +275,7 @@ struct SpecificInd {
case (DIRECTION::Z):
return zm(dd);
}
return *this;
}

inline SpecificInd xp(int dx = 1) const { return {ind + (dx * ny * nz), ny, nz}; }
Expand Down
57 changes: 28 additions & 29 deletions src/mesh/fv_ops.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -571,103 +571,102 @@ Field3D Div_Perp_Lap(const Field3D& a, const Field3D& f, CELL_LOC outloc) {

// Explicit instantiations of flux-limited finite volume methods
template Field3D Div_par_fvv<Upwind>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_par<Upwind>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_f_v<Upwind>(const Field3D& n_in, const Vector3D& v, bool bndry_flux);
template Field3D Div_par_mod<Upwind>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, Field3D& flow_ylow,
bool fixflux = true);
bool fixflux);
template Field3D Div_par_fvv_heating<Upwind>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in,
Field3D& flow_ylow, bool fixflux = true);
Field3D& flow_ylow, bool fixflux);
template Field3D Div_a_Grad_perp_limit<Upwind>(const Field3D& a, const Field3D& g,
const Field3D& f);

template Field3D Div_par_fvv<Fromm>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_par<Fromm>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_f_v<Fromm>(const Field3D& n_in, const Vector3D& v, bool bndry_flux);
template Field3D Div_par_mod<Fromm>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, Field3D& flow_ylow,
bool fixflux = true);
bool fixflux);
template Field3D Div_par_fvv_heating<Fromm>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in,
Field3D& flow_ylow, bool fixflux = true);
Field3D& flow_ylow, bool fixflux);
template Field3D Div_a_Grad_perp_limit<Fromm>(const Field3D& a, const Field3D& g,
const Field3D& f);

template Field3D Div_par_fvv<MinMod>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_par<MinMod>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_f_v<MinMod>(const Field3D& n_in, const Vector3D& v, bool bndry_flux);
template Field3D Div_par_mod<MinMod>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, Field3D& flow_ylow,
bool fixflux = true);
bool fixflux);
template Field3D Div_par_fvv_heating<MinMod>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in,
Field3D& flow_ylow, bool fixflux = true);
Field3D& flow_ylow, bool fixflux);
template Field3D Div_a_Grad_perp_limit<MinMod>(const Field3D& a, const Field3D& g,
const Field3D& f);

template Field3D Div_par_fvv<MC>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_par<MC>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_f_v<MC>(const Field3D& n_in, const Vector3D& v, bool bndry_flux);
template Field3D Div_par_mod<MC>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, Field3D& flow_ylow,
bool fixflux = true);
bool fixflux);
template Field3D Div_par_fvv_heating<MC>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, Field3D& flow_ylow,
bool fixflux = true);
bool fixflux);
template Field3D Div_a_Grad_perp_limit<MC>(const Field3D& a, const Field3D& g,
const Field3D& f);

template Field3D Div_par_fvv<Superbee>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_par<Superbee>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_f_v<Superbee>(const Field3D& n_in, const Vector3D& v,
bool bndry_flux);
template Field3D Div_par_mod<Superbee>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, Field3D& flow_ylow,
bool fixflux = true);
bool fixflux);
template Field3D Div_par_fvv_heating<Superbee>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in,
Field3D& flow_ylow, bool fixflux = true);
Field3D& flow_ylow, bool fixflux);
template Field3D Div_a_Grad_perp_limit<Superbee>(const Field3D& a, const Field3D& g,
const Field3D& f);

template Field3D Div_par_fvv<VanAlbada>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in,
bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_par<VanAlbada>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_f_v<VanAlbada>(const Field3D& n_in, const Vector3D& v,
bool bndry_flux);
template Field3D Div_par_mod<VanAlbada>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, Field3D& flow_ylow,
bool fixflux = true);
bool fixflux);
template Field3D Div_par_fvv_heating<VanAlbada>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in,
Field3D& flow_ylow, bool fixflux = true);
Field3D& flow_ylow, bool fixflux);
template Field3D Div_a_Grad_perp_limit<VanAlbada>(const Field3D& a, const Field3D& g,
const Field3D& f);

template Field3D Div_par_fvv<WENO3>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_par<WENO3>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, bool fixflux = true);
const Field3D& wave_speed_in, bool fixflux);
template Field3D Div_f_v<WENO3>(const Field3D& n_in, const Vector3D& v, bool bndry_flux);
template Field3D Div_par_mod<WENO3>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in, Field3D& flow_ylow,
bool fixflux = true);
bool fixflux);
template Field3D Div_par_fvv_heating<WENO3>(const Field3D& f_in, const Field3D& v_in,
const Field3D& wave_speed_in,
Field3D& flow_ylow, bool fixflux = true);
Field3D& flow_ylow, bool fixflux);
template Field3D Div_a_Grad_perp_limit<WENO3>(const Field3D& a, const Field3D& g,
const Field3D& f);
} // Namespace FV
Loading
Loading