Skip to content

Commit ecedb55

Browse files
committed
Clang-tidy fixes
1 parent 6887b33 commit ecedb55

11 files changed

Lines changed: 158 additions & 101 deletions

src/mesh/interpolation/xz/impls/bilinear_xz.cxx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@
2222

2323
#include "bilinear_xz.hxx"
2424

25+
#include "bout/assert.hxx"
26+
#include "bout/bout_types.hxx"
27+
#include "bout/boutexception.hxx"
28+
#include "bout/field2d.hxx"
29+
#include "bout/field3d.hxx"
2530
#include "bout/globals.hxx"
31+
#include "bout/interpolation_xz.hxx"
32+
#include "bout/mask.hxx"
2633
#include "bout/mesh.hxx"
34+
#include "bout/region.hxx"
2735

36+
#include <cmath>
2837
#include <string>
29-
#include <vector>
3038

3139
XZBilinear::XZBilinear(int y_offset, Mesh* mesh)
3240
: XZInterpolation(y_offset, mesh), w0(localmesh), w1(localmesh), w2(localmesh),
@@ -111,10 +119,10 @@ Field3D XZBilinear::interpolate(const Field3D& f, const std::string& region) con
111119
const int z_mod = ((k_corner(x, y, z) % ncz) + ncz) % ncz;
112120
const int z_mod_p1 = (z_mod + 1) % ncz;
113121

114-
f_interp(x, y_next, z) = f(i_corner(x, y, z), y_next, z_mod) * w0(x, y, z)
115-
+ f(i_corner(x, y, z) + 1, y_next, z_mod) * w1(x, y, z)
116-
+ f(i_corner(x, y, z), y_next, z_mod_p1) * w2(x, y, z)
117-
+ f(i_corner(x, y, z) + 1, y_next, z_mod_p1) * w3(x, y, z);
122+
f_interp(x, y_next, z) = (f(i_corner(x, y, z), y_next, z_mod) * w0(x, y, z))
123+
+ (f(i_corner(x, y, z) + 1, y_next, z_mod) * w1(x, y, z))
124+
+ (f(i_corner(x, y, z), y_next, z_mod_p1) * w2(x, y, z))
125+
+ (f(i_corner(x, y, z) + 1, y_next, z_mod_p1) * w3(x, y, z));
118126
}
119127
return f_interp;
120128
}

src/mesh/interpolation/xz/impls/bilinear_xz.hxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#ifndef BOUT_XZBILINEAR_HXX
22
#define BOUT_XZBILINEAR_HXX
33

4+
#include "bout/field3d.hxx"
45
#include "bout/interpolation_xz.hxx"
6+
#include "bout/mask.hxx"
7+
#include "bout/utils.hxx"
8+
9+
#include <string>
510

611
/// XZBilinear interpolation class
712
///

src/mesh/interpolation/xz/impls/hermite_spline_xz.cxx

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,24 @@
2323
#include "hermite_spline_xz.hxx"
2424

2525
#include "../../../impls/bout/boutmesh.hxx"
26+
27+
#include "bout/assert.hxx"
2628
#include "bout/bout.hxx"
29+
#include "bout/bout_types.hxx"
30+
#include "bout/boutexception.hxx"
31+
#include "bout/field2d.hxx"
2732
#include "bout/globals.hxx"
2833
#include "bout/index_derivs_interface.hxx"
2934
#include "bout/interpolation_xz.hxx"
35+
#include "bout/mask.hxx"
36+
#include "bout/paralleltransform.hxx"
37+
#include "bout/region.hxx"
3038

31-
#include <vector>
39+
#include <fmt/format.h>
3240

41+
#include <cmath>
42+
#include <string>
43+
#include <vector>
3344

3445
XZHermiteSpline::XZHermiteSpline(int y_offset, Mesh* meshin)
3546
: XZInterpolation(y_offset, meshin), h00_x(localmesh), h01_x(localmesh),
@@ -64,7 +75,7 @@ void XZHermiteSpline::calcWeights(const Field3D& delta_x, const Field3D& delta_z
6475

6576
const int ny = localmesh->LocalNy;
6677
const int nz = localmesh->LocalNz;
67-
const int xend = (localmesh->xend - localmesh->xstart + 1) * localmesh->getNXPE()
78+
const int xend = ((localmesh->xend - localmesh->xstart + 1) * localmesh->getNXPE())
6879
+ localmesh->xstart - 1;
6980

7081
BOUT_FOR(i, getRegion(region)) {
@@ -80,7 +91,7 @@ void XZHermiteSpline::calcWeights(const Field3D& delta_x, const Field3D& delta_z
8091
// t_x, t_z are the normalised coordinates \in [0,1) within the cell
8192
// calculated by taking the remainder of the floating point index
8293
BoutReal t_x = delta_x(x, y, z) - static_cast<BoutReal>(i_corn);
83-
BoutReal t_z = delta_z(x, y, z) - static_cast<BoutReal>(k_corner(x, y, z));
94+
BoutReal const t_z = delta_z(x, y, z) - static_cast<BoutReal>(k_corner(x, y, z));
8495

8596
// NOTE: A (small) hack to avoid one-sided differences. We need at
8697
// least 2 interior points due to an awkwardness with the
@@ -120,7 +131,7 @@ void XZHermiteSpline::calcWeights(const Field3D& delta_x, const Field3D& delta_z
120131
}
121132

122133
i_corner[i] = SpecificInd<IND_TYPE::IND_3D>(
123-
(((i_corn * ny) + (y + y_offset)) * nz + k_corner(x, y, z)), ny, nz);
134+
((((i_corn * ny) + (y + y_offset)) * nz) + k_corner(x, y, z)), ny, nz);
124135

125136
h00_x[i] = (2. * t_x * t_x * t_x) - (3. * t_x * t_x) + 1.;
126137
h00_z[i] = (2. * t_z * t_z * t_z) - (3. * t_z * t_z) + 1.;
@@ -167,8 +178,8 @@ XZHermiteSpline::getWeightsForYApproximation(int i, int j, int k, int yoffset) {
167178
const int k_mod_p2 = (k_mod_p1 == nz) ? 0 : k_mod_p1 + 1;
168179

169180
return {{i, j + yoffset, k_mod_m1, -0.5 * h10_z(i, j, k)},
170-
{i, j + yoffset, k_mod, h00_z(i, j, k) - 0.5 * h11_z(i, j, k)},
171-
{i, j + yoffset, k_mod_p1, h01_z(i, j, k) + 0.5 * h10_z(i, j, k)},
181+
{i, j + yoffset, k_mod, h00_z(i, j, k) - (0.5 * h11_z(i, j, k))},
182+
{i, j + yoffset, k_mod_p1, h01_z(i, j, k) + (0.5 * h10_z(i, j, k))},
172183
{i, j + yoffset, k_mod_p2, 0.5 * h11_z(i, j, k)}};
173184
}
174185

@@ -199,24 +210,24 @@ Field3D XZHermiteSpline::interpolate(const Field3D& f, const std::string& region
199210
const auto icxpzp = iczp.xp();
200211

201212
// Interpolate f in X at Z
202-
const BoutReal f_z =
203-
f[ic] * h00_x[i] + f[icxp] * h01_x[i] + fx[ic] * h10_x[i] + fx[icxp] * h11_x[i];
213+
const BoutReal f_z = (f[ic] * h00_x[i]) + (f[icxp] * h01_x[i]) + (fx[ic] * h10_x[i])
214+
+ (fx[icxp] * h11_x[i]);
204215

205216
// Interpolate f in X at Z+1
206-
const BoutReal f_zp1 = f[iczp] * h00_x[i] + f[icxpzp] * h01_x[i] + fx[iczp] * h10_x[i]
207-
+ fx[icxpzp] * h11_x[i];
217+
const BoutReal f_zp1 = (f[iczp] * h00_x[i]) + (f[icxpzp] * h01_x[i])
218+
+ (fx[iczp] * h10_x[i]) + (fx[icxpzp] * h11_x[i]);
208219

209220
// Interpolate fz in X at Z
210-
const BoutReal fz_z = fz[ic] * h00_x[i] + fz[icxp] * h01_x[i] + fxz[ic] * h10_x[i]
211-
+ fxz[icxp] * h11_x[i];
221+
const BoutReal fz_z = (fz[ic] * h00_x[i]) + (fz[icxp] * h01_x[i])
222+
+ (fxz[ic] * h10_x[i]) + (fxz[icxp] * h11_x[i]);
212223

213224
// Interpolate fz in X at Z+1
214-
const BoutReal fz_zp1 = fz[iczp] * h00_x[i] + fz[icxpzp] * h01_x[i]
215-
+ fxz[iczp] * h10_x[i] + fxz[icxpzp] * h11_x[i];
225+
const BoutReal fz_zp1 = (fz[iczp] * h00_x[i]) + (fz[icxpzp] * h01_x[i])
226+
+ (fxz[iczp] * h10_x[i]) + (fxz[icxpzp] * h11_x[i]);
216227

217228
// Interpolate in Z
218229
f_interp[iyp] =
219-
+f_z * h00_z[i] + f_zp1 * h01_z[i] + fz_z * h10_z[i] + fz_zp1 * h11_z[i];
230+
(+f_z * h00_z[i]) + (f_zp1 * h01_z[i]) + (fz_z * h10_z[i]) + (fz_zp1 * h11_z[i]);
220231

221232
ASSERT2(std::isfinite(f_interp[iyp]) || i.x() < localmesh->xstart
222233
|| i.x() > localmesh->xend);

src/mesh/interpolation/xz/impls/hermite_spline_xz.hxx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33

44
#include "bout/interpolation_xz.hxx"
55

6-
#include <bout/build_defines.hxx>
7-
#include <bout/bout_types.hxx>
6+
#include "bout/mask.hxx"
7+
#include "bout/paralleltransform.hxx"
8+
#include "bout/region.hxx"
9+
#include "bout/utils.hxx"
810
#include <bout/field3d.hxx>
911

12+
#include <string>
1013
#include <vector>
1114

1215
/// Hermite spline interpolation in XZ
@@ -45,7 +48,7 @@ public:
4548
: XZHermiteSpline(y_offset, mesh) {
4649
setRegion(regionFromMask(mask, localmesh));
4750
}
48-
~XZHermiteSpline() = default;
51+
~XZHermiteSpline() override = default;
4952

5053
void calcWeights(const Field3D& delta_x, const Field3D& delta_z,
5154
const std::string& region = "RGN_NOBNDRY") override;
@@ -66,7 +69,8 @@ public:
6669
};
6770

6871
namespace {
69-
const RegisterXZInterpolation<XZHermiteSpline> registerinterphermitespline{"hermitespline"};
72+
const RegisterXZInterpolation<XZHermiteSpline> registerinterphermitespline{
73+
"hermitespline"};
7074
}
7175

7276
#endif // BOUT_XZHERMITESPLINE_HXX

src/mesh/interpolation/xz/impls/lagrange_4pt_xz.cxx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@
2222

2323
#include "lagrange_4pt_xz.hxx"
2424

25+
#include "bout/assert.hxx"
26+
#include "bout/bout_types.hxx"
27+
#include "bout/boutexception.hxx"
28+
#include "bout/field2d.hxx"
29+
#include "bout/field3d.hxx"
2530
#include "bout/globals.hxx"
2631
#include "bout/interpolation_xz.hxx"
32+
#include "bout/mask.hxx"
2733
#include "bout/mesh.hxx"
34+
#include "bout/region.hxx"
2835

29-
#include <vector>
36+
#include <cmath>
37+
#include <string>
3038

3139
XZLagrange4pt::XZLagrange4pt(int y_offset, Mesh* mesh)
3240
: XZInterpolation(y_offset, mesh), t_x(localmesh), t_z(localmesh) {
@@ -156,13 +164,13 @@ Field3D XZLagrange4pt::interpolate(const Field3D& f, const Field3D& delta_x,
156164
// offset must be between 0 and 1
157165
BoutReal XZLagrange4pt::lagrange_4pt(const BoutReal v2m, const BoutReal vm,
158166
const BoutReal vp, const BoutReal v2p,
159-
const BoutReal offset) const {
160-
return -offset * (offset - 1.0) * (offset - 2.0) * v2m / 6.0
161-
+ 0.5 * (offset * offset - 1.0) * (offset - 2.0) * vm
162-
- 0.5 * offset * (offset + 1.0) * (offset - 2.0) * vp
163-
+ offset * (offset * offset - 1.0) * v2p / 6.0;
167+
const BoutReal offset) {
168+
return (-offset * (offset - 1.0) * (offset - 2.0) * v2m / 6.0)
169+
+ (0.5 * (offset * offset - 1.0) * (offset - 2.0) * vm)
170+
- (0.5 * offset * (offset + 1.0) * (offset - 2.0) * vp)
171+
+ (offset * (offset * offset - 1.0) * v2p / 6.0);
164172
}
165173

166-
BoutReal XZLagrange4pt::lagrange_4pt(const BoutReal v[], const BoutReal offset) const {
174+
BoutReal XZLagrange4pt::lagrange_4pt(const BoutReal v[], const BoutReal offset) {
167175
return lagrange_4pt(v[0], v[1], v[2], v[3], offset);
168176
}

src/mesh/interpolation/xz/impls/lagrange_4pt_xz.hxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#ifndef BOUT_XZLAGRANGE_HXX
22
#define BOUT_XZLAGRANGE_HXX
33

4+
#include "bout/bout_types.hxx"
5+
#include "bout/field3d.hxx"
46
#include "bout/interpolation_xz.hxx"
7+
#include "bout/mask.hxx"
8+
#include "bout/utils.hxx"
9+
#include <string>
510

611
/// XZLagrange4pt interpolation class
712
///
@@ -35,9 +40,9 @@ public:
3540
Field3D interpolate(const Field3D& f, const Field3D& delta_x, const Field3D& delta_z,
3641
const BoutMask& mask,
3742
const std::string& region = "RGN_NOBNDRY") override;
38-
BoutReal lagrange_4pt(BoutReal v2m, BoutReal vm, BoutReal vp, BoutReal v2p,
39-
BoutReal offset) const;
40-
BoutReal lagrange_4pt(const BoutReal v[], BoutReal offset) const;
43+
static BoutReal lagrange_4pt(BoutReal v2m, BoutReal vm, BoutReal vp, BoutReal v2p,
44+
BoutReal offset);
45+
static BoutReal lagrange_4pt(const BoutReal v[], BoutReal offset);
4146
};
4247

4348
namespace {

src/mesh/interpolation/xz/impls/monotonic_hermite_spline_xz.cxx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@
2222

2323
#include "monotonic_hermite_spline_xz.hxx"
2424

25+
#include "bout/assert.hxx"
26+
#include "bout/bout_types.hxx"
2527
#include "bout/globals.hxx"
2628
#include "bout/index_derivs_interface.hxx"
27-
#include "bout/interpolation_xz.hxx"
2829
#include "bout/mesh.hxx"
30+
#include "bout/region.hxx"
31+
#include "bout/utils.hxx"
2932

3033
#include <algorithm>
34+
#include <cmath>
35+
#include <string>
3136

3237
Field3D XZMonotonicHermiteSpline::interpolate(const Field3D& f,
3338
const std::string& region) const {
@@ -53,24 +58,24 @@ Field3D XZMonotonicHermiteSpline::interpolate(const Field3D& f,
5358
const auto icxpzp = iczp.xp();
5459

5560
// Interpolate f in X at Z
56-
const BoutReal f_z =
57-
f[ic] * h00_x[i] + f[icxp] * h01_x[i] + fx[ic] * h10_x[i] + fx[icxp] * h11_x[i];
61+
const BoutReal f_z = (f[ic] * h00_x[i]) + (f[icxp] * h01_x[i]) + (fx[ic] * h10_x[i])
62+
+ (fx[icxp] * h11_x[i]);
5863

5964
// Interpolate f in X at Z+1
60-
const BoutReal f_zp1 = f[iczp] * h00_x[i] + f[icxpzp] * h01_x[i] + fx[iczp] * h10_x[i]
61-
+ fx[icxpzp] * h11_x[i];
65+
const BoutReal f_zp1 = (f[iczp] * h00_x[i]) + (f[icxpzp] * h01_x[i])
66+
+ (fx[iczp] * h10_x[i]) + (fx[icxpzp] * h11_x[i]);
6267

6368
// Interpolate fz in X at Z
64-
const BoutReal fz_z = fz[ic] * h00_x[i] + fz[icxp] * h01_x[i] + fxz[ic] * h10_x[i]
65-
+ fxz[icxp] * h11_x[i];
69+
const BoutReal fz_z = (fz[ic] * h00_x[i]) + (fz[icxp] * h01_x[i])
70+
+ (fxz[ic] * h10_x[i]) + (fxz[icxp] * h11_x[i]);
6671

6772
// Interpolate fz in X at Z+1
68-
const BoutReal fz_zp1 = fz[iczp] * h00_x[i] + fz[icxpzp] * h01_x[i]
69-
+ fxz[iczp] * h10_x[i] + fxz[icxpzp] * h11_x[i];
73+
const BoutReal fz_zp1 = (fz[iczp] * h00_x[i]) + (fz[icxpzp] * h01_x[i])
74+
+ (fxz[iczp] * h10_x[i]) + (fxz[icxpzp] * h11_x[i]);
7075

7176
// Interpolate in Z
7277
BoutReal result =
73-
+f_z * h00_z[i] + f_zp1 * h01_z[i] + fz_z * h10_z[i] + fz_zp1 * h11_z[i];
78+
(+f_z * h00_z[i]) + (f_zp1 * h01_z[i]) + (fz_z * h10_z[i]) + (fz_zp1 * h11_z[i]);
7479

7580
ASSERT2(std::isfinite(result) || i.x() < localmesh->xstart
7681
|| i.x() > localmesh->xend);

src/mesh/interpolation/xz/impls/monotonic_hermite_spline_xz.hxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
#include "hermite_spline_xz.hxx"
55

6+
#include "bout/boutexception.hxx"
7+
#include "bout/field3d.hxx"
8+
#include "bout/interpolation_xz.hxx"
9+
#include "bout/mask.hxx"
10+
#include "bout/options.hxx"
611
#include <bout/bout_types.hxx>
712

813
/// Monotonic Hermite spline interpolator

0 commit comments

Comments
 (0)