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
4 changes: 2 additions & 2 deletions externalpackages/PVODE/include/pvode/band.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ typedef struct bandmat_type {
* *
******************************************************************/

#define PVODE_BAND_ELEM(A, i, j) ((A->data)[j][i - j + (A->smu)])
#define PVODE_BAND_ELEM(A, i, j) (((A)->data)[j][(i) - (j) + ((A)->smu)])
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: function-like macro 'PVODE_BAND_ELEM' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]

#define PVODE_BAND_ELEM(A, i, j) (((A)->data)[j][(i) - (j) + ((A)->smu)])
        ^


/******************************************************************
* *
Expand All @@ -153,7 +153,7 @@ typedef struct bandmat_type {
* *
******************************************************************/

#define PVODE_BAND_COL(A, j) (((A->data)[j]) + (A->smu))
#define PVODE_BAND_COL(A, j) ((((A)->data)[j]) + ((A)->smu))
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: function-like macro 'PVODE_BAND_COL' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]

#define PVODE_BAND_COL(A, j) ((((A)->data)[j]) + ((A)->smu))
        ^


/******************************************************************
* *
Expand Down
2 changes: 1 addition & 1 deletion externalpackages/PVODE/precon/band.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ typedef struct bandmat_type {
* *
******************************************************************/

#define PVODE_BAND_COL(A, j) (((A->data)[j]) + (A->smu))
#define PVODE_BAND_COL(A, j) ((((A)->data)[j]) + ((A)->smu))
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: function-like macro 'PVODE_BAND_COL' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]

#define PVODE_BAND_COL(A, j) ((((A)->data)[j]) + ((A)->smu))
        ^


/******************************************************************
* *
Expand Down
7 changes: 5 additions & 2 deletions include/bout/boundary_iterator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public:
return (f[ind()] * 3 - yprev(f)) * 0.5;
}

BoutReal extrapolate_next_o2(const Field3D& f) const { return (2 * f[ind()]) - yprev(f); }
BoutReal extrapolate_next_o2(const Field3D& f) const {
return (2 * f[ind()]) - yprev(f);
}

BoutReal
extrapolate_next_o2(const std::function<BoutReal(int yoffset, Ind3D ind)>& f) const {
Expand Down Expand Up @@ -149,7 +151,8 @@ public:
#endif

const int dir;
virtual ~BoundaryRegionIter = default;
virtual ~BoundaryRegionIter() = default;

protected:
int z{0};
int x;
Expand Down
2 changes: 1 addition & 1 deletion include/bout/field.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ class Field3DParallel;
T result{emptyFrom(f)}; \
BOUT_FOR(d, result.getRegion(rgn)) { result[d] = func(f[d]); } \
if constexpr (std::is_base_of_v<Field3DParallel, T>) { \
for (size_t i = 0; i < f.numberParallelSlices(); ++i) { \
for (size_t i = 0; i < f.numberParallelSlices(); ++i) { \
result.yup(i) = func(f.yup(i)); \
result.ydown(i) = func(f.ydown(i)); \
} \
Expand Down
4 changes: 2 additions & 2 deletions include/bout/interpolation_xz.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ protected:
#if HS_USE_PETSC
PetscLib* petsclib;
bool isInit{false};
Mat petscWeights;
Vec rhs, result;
Mat petscWeights{};
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: member variable 'petscWeights' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]

  Mat petscWeights{};
      ^

Vec rhs{}, result{};
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: member variable 'result' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]

  Vec rhs{}, result{};
             ^

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: member variable 'rhs' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]

  Vec rhs{}, result{};
      ^

#endif

public:
Expand Down
2 changes: 1 addition & 1 deletion include/bout/options.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ Tensor<BoutReal> Options::as<Tensor<BoutReal>>(const Tensor<BoutReal>& similar_t
std::string toString(const Options& value);

/// Save the parallel fields
void saveParallel(Options& opt, const std::string name, const Field3D& tosave);
void saveParallel(Options& opt, const std::string& name, const Field3D& tosave);

/// Output a stringified \p value to a stream
///
Expand Down
4 changes: 4 additions & 0 deletions src/field/field2d.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
*
**************************************************************************/

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

#include "bout/unused.hxx"
#include <bout/boutcomm.hxx>
#include <bout/rvec.hxx>

Expand All @@ -45,6 +47,8 @@

#include <bout/output.hxx>
#include <cmath>
#include <cstddef>
#include <optional>

#include <bout/assert.hxx>

Expand Down
6 changes: 5 additions & 1 deletion src/field/field3d.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@
*
**************************************************************************/

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

#include <bout/boutcomm.hxx>
#include <bout/globals.hxx>

#include <cmath>
#include <cstddef>
#include <fmt/format.h>
#include <optional>

#include "bout/parallel_boundary_op.hxx"
#include "bout/parallel_boundary_region.hxx"
Expand Down Expand Up @@ -989,7 +993,7 @@ template Options* Field3D::track<Field2D>(const Field2D&, std::string);
template Options* Field3D::track<FieldPerp>(const FieldPerp&, std::string);

Options* Field3D::track(const BoutReal& change, std::string operation) {
if (tracking and tracking_state) {
if ((tracking != nullptr) and (tracking_state != 0)) {
const std::string outname{fmt::format("track_{:s}_{:d}", selfname, tracking_state++)};
tracking->set(outname, change, "tracking");
(*tracking)[outname].setAttributes({
Expand Down
3 changes: 3 additions & 0 deletions src/field/fieldperp.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
*
**************************************************************************/

#include "bout/unused.hxx"
#include <bout/boutcomm.hxx>
#include <bout/globals.hxx>

#include <cmath>
#include <cstddef>
#include <optional>

#include <bout/boutexception.hxx>
#include <bout/fieldperp.hxx>
Expand Down
3 changes: 3 additions & 0 deletions src/field/generated_fieldops.cxx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// This file is autogenerated - see gen_fieldops.py
#include "bout/assert.hxx"
#include "bout/build_defines.hxx"
#include <bout/field2d.hxx>
#include <bout/field3d.hxx>
#include <bout/globals.hxx>
#include <bout/interpolation.hxx>
#include <bout/mesh.hxx>
#include <bout/region.hxx>
#include <cstddef>
#include <fmt/format.h>

// Provide the C++ wrapper for multiplication of Field3D and Field3D
Field3D operator*(const Field3D& lhs, const Field3D& rhs) {
Expand Down
10 changes: 7 additions & 3 deletions src/invert/laplace/impls/petsc/petsc_laplace.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
**************************************************************************/

#include "bout/build_defines.hxx"
#include <cmath>
#include <memory>

#if BOUT_HAS_PETSC

#include "petsc_laplace.hxx"

#include <math.h>

#include <bout/assert.hxx>
#include <bout/boutcomm.hxx>
#include <bout/mesh.hxx>
Expand Down Expand Up @@ -380,7 +384,7 @@ FieldPerp LaplacePetsc::solve(const FieldPerp& b, const FieldPerp& x0,
if (localmesh->firstX()) {
for (int x = 0; x < localmesh->xstart; x++) {
for (int z = 0; z < localmesh->LocalNz; z++) {
PetscScalar val; // Value of element to be set in the matrix
PetscScalar val = NAN; // Value of element to be set in the matrix
// If Neumann Boundary Conditions are set.
if (isInnerBoundaryFlagSet(INVERT_AC_GRAD)) {
// Set values corresponding to nodes adjacent in x
Expand Down Expand Up @@ -814,7 +818,7 @@ FieldPerp LaplacePetsc::solve(const FieldPerp& b, const FieldPerp& x0,

// Call the actual solver
{
Timer timer("petscsolve");
const Timer timer("petscsolve");
KSPSolve(ksp, bs, xs); // Call the solver to solve the system
}

Expand All @@ -830,7 +834,7 @@ FieldPerp LaplacePetsc::solve(const FieldPerp& b, const FieldPerp& x0,
}
} else {
timer.reset();
PetscErrorCode err = MatMult(MatA, bs, xs);
const PetscErrorCode err = MatMult(MatA, bs, xs);
if (err != PETSC_SUCCESS) {
throw BoutException("MatMult failed with {:d}", static_cast<int>(err));
}
Expand Down
3 changes: 2 additions & 1 deletion src/invert/laplace/invert_laplace.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ Field3D Laplacian::forward(const Field3D& b) {
ASSERT1(localmesh == b.getMesh());

// Setting the start and end range of the y-slices
int ys = localmesh->ystart, ye = localmesh->yend;
int ys = localmesh->ystart;
int ye = localmesh->yend;
if (include_yguards && localmesh->hasBndryLowerY()) {
ys = 0; // Mesh contains a lower boundary
}
Expand Down
1 change: 1 addition & 0 deletions src/mesh/boundary_factory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <bout/options.hxx>
#include <bout/utils.hxx>

#include <array>
#include <list>
#include <map>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/boundary_standard.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ void BoundaryNeumann_NonOrthogonal::apply(Field3D& f) {

void BoundaryNeumann::apply(Field2D & f) { BoundaryNeumann::apply(f, 0.); }

void BoundaryNeumann::apply([[maybe_unused]] Field2D & f, BoutReal t) {
void BoundaryNeumann::apply([[maybe_unused]] Field2D & f, [[maybe_unused]] BoutReal t) {
// Set (at 2nd order / 3rd order) the value at the mid-point between
// the guard cell and the grid cell to be val
// N.B. First guard cells (closest to the grid) is 2nd order, while
Expand Down
8 changes: 5 additions & 3 deletions src/mesh/coordinates.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* given the contravariant metric tensor terms
**************************************************************************/

#include "bout/region.hxx"
#include <bout/assert.hxx>
#include <bout/constants.hxx>
#include <bout/coordinates.hxx>
Expand All @@ -18,6 +19,7 @@
#include <bout/output_bout_types.hxx>

#include <bout/globals.hxx>
#include <vector>

#include "invert3x3.hxx"
#include "parallel/fci.hxx"
Expand Down Expand Up @@ -619,7 +621,7 @@ Coordinates::Coordinates(Mesh* mesh, Options* options)
maxError = std::max(std::abs(local - 1), maxError);
}
}
BoutReal allowedError = (*options)["allowedFluxError"].withDefault(1e-6);
const BoutReal allowedError = (*options)["allowedFluxError"].withDefault(1e-6);
if (maxError < allowedError / 100) {
output_info.write("\tInfo: The maximum flux conservation error is {:e}", maxError);
} else if (maxError < allowedError) {
Expand Down Expand Up @@ -1617,9 +1619,9 @@ Field3D Coordinates::Div_par(const Field3DParallel& f, CELL_LOC outloc,
return Bxy * Grad_par(f / Bxy_floc, outloc, method);
}

auto coords = f.getCoordinates();
auto* coords = f.getCoordinates();
// Need to modify yup and ydown fields
Field3D Jg = coords->J / sqrt(coords->g_22.asField3DParallel());
const Field3D Jg = coords->J / sqrt(coords->g_22.asField3DParallel());
return setName(Jg * Grad_par(f / Jg, outloc, method), "Div_par({:s})", f.name);
}

Expand Down
2 changes: 2 additions & 0 deletions src/mesh/fv_ops.cxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "bout/boutexception.hxx"
#include "bout/difops.hxx"
#include <bout/fv_ops.hxx>
#include <bout/globals.hxx>
#include <bout/msg_stack.hxx>
Expand Down
4 changes: 2 additions & 2 deletions src/mesh/impls/bout/boutmesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ int BoutMesh::load() {
}
ASSERT0(MXG >= 0);

bool meshHasMyg = Mesh::get(MYG, "MYG") == 0;
int meshMyg;
const bool meshHasMyg = Mesh::get(MYG, "MYG") == 0;
int meshMyg = 0;
if (!meshHasMyg) {
MYG = 2;
} else {
Expand Down
1 change: 1 addition & 0 deletions src/mesh/interpolation/bilinear_xz.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*
**************************************************************************/

#include "bout/boutexception.hxx"
#include "bout/globals.hxx"
#include "bout/interpolation_xz.hxx"
#include "bout/mesh.hxx"
Expand Down
37 changes: 19 additions & 18 deletions src/mesh/interpolation/hermite_spline_xz.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
#include "bout/globals.hxx"
#include "bout/index_derivs_interface.hxx"
#include "bout/interpolation_xz.hxx"
#include "bout/mask.hxx"
#include "bout/utils.hxx"

#include <algorithm>
#include <memory>
#include <string>
#include <vector>

class IndConverter {
Expand Down Expand Up @@ -529,21 +534,21 @@ Field3D XZMonotonicHermiteSplineLegacy::interpolate(const Field3D& f,
localmesh->communicateXZ(fx);
// communicate in y, but do not calculate parallel slices
{
auto h = localmesh->sendY(fx);
auto* h = localmesh->sendY(fx);
localmesh->wait(h);
}
Field3D fz = bout::derivatives::index::DDZ(f, CELL_DEFAULT, "DEFAULT", "RGN_ALL");
localmesh->communicateXZ(fz);
// communicate in y, but do not calculate parallel slices
{
auto h = localmesh->sendY(fz);
auto* h = localmesh->sendY(fz);
localmesh->wait(h);
}
Field3D fxz = bout::derivatives::index::DDX(fz, CELL_DEFAULT, "DEFAULT");
localmesh->communicateXZ(fxz);
// communicate in y, but do not calculate parallel slices
{
auto h = localmesh->sendY(fxz);
auto* h = localmesh->sendY(fxz);
localmesh->wait(h);
}

Expand All @@ -557,24 +562,24 @@ Field3D XZMonotonicHermiteSplineLegacy::interpolate(const Field3D& f,
const auto icxpzp = iczp.xp();

// Interpolate f in X at Z
const BoutReal f_z =
f[ic] * h00_x[i] + f[icxp] * h01_x[i] + fx[ic] * h10_x[i] + fx[icxp] * h11_x[i];
const BoutReal f_z = (f[ic] * h00_x[i]) + (f[icxp] * h01_x[i]) + (fx[ic] * h10_x[i])
+ (fx[icxp] * h11_x[i]);

// Interpolate f in X at Z+1
const BoutReal f_zp1 = f[iczp] * h00_x[i] + f[icxpzp] * h01_x[i] + fx[iczp] * h10_x[i]
+ fx[icxpzp] * h11_x[i];
const BoutReal f_zp1 = (f[iczp] * h00_x[i]) + (f[icxpzp] * h01_x[i])
+ (fx[iczp] * h10_x[i]) + (fx[icxpzp] * h11_x[i]);

// Interpolate fz in X at Z
const BoutReal fz_z = fz[ic] * h00_x[i] + fz[icxp] * h01_x[i] + fxz[ic] * h10_x[i]
+ fxz[icxp] * h11_x[i];
const BoutReal fz_z = (fz[ic] * h00_x[i]) + (fz[icxp] * h01_x[i])
+ (fxz[ic] * h10_x[i]) + (fxz[icxp] * h11_x[i]);

// Interpolate fz in X at Z+1
const BoutReal fz_zp1 = fz[iczp] * h00_x[i] + fz[icxpzp] * h01_x[i]
+ fxz[iczp] * h10_x[i] + fxz[icxpzp] * h11_x[i];
const BoutReal fz_zp1 = (fz[iczp] * h00_x[i]) + (fz[icxpzp] * h01_x[i])
+ (fxz[iczp] * h10_x[i]) + (fxz[icxpzp] * h11_x[i]);

// Interpolate in Z
BoutReal result =
+f_z * h00_z[i] + f_zp1 * h01_z[i] + fz_z * h10_z[i] + fz_zp1 * h11_z[i];
(+f_z * h00_z[i]) + (f_zp1 * h01_z[i]) + (fz_z * h10_z[i]) + (fz_zp1 * h11_z[i]);

ASSERT2(std::isfinite(result) || i.x() < localmesh->xstart
|| i.x() > localmesh->xend);
Expand All @@ -594,12 +599,8 @@ Field3D XZMonotonicHermiteSplineLegacy::interpolate(const Field3D& f,
ASSERT2(std::isfinite(localmin) || i.x() < localmesh->xstart
|| i.x() > localmesh->xend);

if (result > localmax) {
result = localmax;
}
if (result < localmin) {
result = localmin;
}
result = std::min(result, localmax);
result = std::max(result, localmin);

f_interp[iyp] = result;
}
Expand Down
2 changes: 2 additions & 0 deletions src/mesh/interpolation/lagrange_4pt_xz.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
*
**************************************************************************/

#include "bout/boutexception.hxx"
#include "bout/globals.hxx"
#include "bout/interpolation_xz.hxx"
#include "bout/mesh.hxx"

#include <fmt/format.h>
#include <vector>

XZLagrange4pt::XZLagrange4pt(int y_offset, Mesh* mesh)
Expand Down
Loading
Loading