Skip to content

Commit

Permalink
chore: Solve format/tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo Milani committed Jun 18, 2024
1 parent 806f351 commit 1e919ee
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 81 deletions.
8 changes: 4 additions & 4 deletions include/CoMMA/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,17 +449,17 @@ void build_coarse_graph(
// For these, we have the final size
c_volumes.clear();
c_volumes.resize(n_cells);
std::fill(c_volumes.begin(), c_volumes.end(), RealT(0));
std::fill(c_volumes.begin(), c_volumes.end(), RealT{0});
c_n_bnd.clear();
c_n_bnd.resize(n_cells);
c_priority.clear();
c_priority.resize(n_cells);
std::fill(c_n_bnd.begin(), c_n_bnd.end(), IntT(0));
std::fill(c_n_bnd.begin(), c_n_bnd.end(), IntT{0});
c_centers.clear();
c_centers.reserve(n_cells);
for (auto cc = decltype(n_cells){0}; cc < n_cells; ++cc) {
// https://stackoverflow.com/questions/18189362/how-best-to-fill-a-vector-of-vectors-avoiding-wasting-memory-and-unnecessary-al
auto tmp = std::vector<RealT>(dim, RealT(0));
auto tmp = std::vector<RealT>(dim, RealT{0});
c_centers.emplace_back(std::move(tmp));
} // for cc
// Now building
Expand All @@ -477,7 +477,7 @@ void build_coarse_graph(
} // for fc
for (auto cc = decltype(n_cells){0}; cc < n_cells; ++cc) {
const auto &fcs = c2f[cc];
const RealT ov_n_fc(RealT(1.) / fcs.size());
const RealT ov_n_fc(RealT{1.} / fcs.size());
// Finishing center
for (auto xyz = decltype(dim){0}; xyz < dim; ++xyz)
c_centers[cc][xyz] *= ov_n_fc;
Expand Down
12 changes: 6 additions & 6 deletions tests/DualGraphExamples.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ using DGEIndexT = comma::CoMMAIndexT;
using DGEIntT = comma::CoMMAIntT;
using DGEWeightT = comma::CoMMAWeightT;

constexpr DGEWeightT _1ov3 = 1. / 3.;
constexpr DGEWeightT _3_1ov3 = 10. / 3.;
constexpr DGEWeightT one_third = 1. / 3.;
constexpr DGEWeightT ten_ov_three = 10. / 3.;
const DGEWeightT sqrt2 = std::sqrt(2.);
const DGEWeightT sqrt101 = std::sqrt(101.);

Expand Down Expand Up @@ -309,13 +309,13 @@ class DualGEx_Tria_BL : public BaseDualGEx {
/* volumes */ {5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00},
/* centers */ {
// Bottom left, 0 and 1
{-_3_1ov3, -2.*_1ov3}, {-2.*_3_1ov3, -_1ov3},
{-ten_ov_three, -2.*one_third}, {-2.*ten_ov_three, -one_third},
// Bottom right, 2 and 3
{+2.*_3_1ov3, -2*_1ov3}, {+_3_1ov3, -_1ov3},
{+2.*ten_ov_three, -2*one_third}, {+ten_ov_three, -one_third},
// Top left, 4 and 5
{-_3_1ov3, +_1ov3}, {-2.*_3_1ov3, 2.*_1ov3},
{-ten_ov_three, +one_third}, {-2.*ten_ov_three, 2.*one_third},
// Top right, 6 and 7
{2.*_3_1ov3, _1ov3}, {_3_1ov3, 2.*_1ov3}
{2.*ten_ov_three, one_third}, {ten_ov_three, 2.*one_third}
}
// clang-on
) {}
Expand Down
20 changes: 12 additions & 8 deletions tests/test_anisoagglo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,16 +850,20 @@ the line grows vertically
const auto n_lines = agglomerationLines_Idx.size() - 1;
REQUIRE(static_cast<CoMMAIndexT>(n_lines) == aniso_agg._nb_lines[0]);
auto read_line = aniso_agg._v_lines[0].cbegin();
for (auto ref_line = agglomerationLines_Idx.cbegin() + 1;
for (auto ref_line = next(agglomerationLines_Idx.cbegin());
ref_line != agglomerationLines_Idx.cend();
++ref_line, ++read_line) {
// I am not sure how to treat this...
// NOLINTNEXTLINE
for (auto ref_fc = agglomerationLines.cbegin() + *std::prev(ref_line);
ref_fc != agglomerationLines.cbegin() + (*ref_line);
// NOLINTBEGIN(cppcoreguidelines-narrowing-conversions)
// NOLINTBEGIN(bugprone-narrowing-conversions)
for (auto ref_fc =
next(agglomerationLines.cbegin(), *std::prev(ref_line));
ref_fc != next(agglomerationLines.cbegin(), *ref_line);
++ref_fc) {
REQUIRE_THAT(**read_line, Contains(*ref_fc));
}
// NOLINTEND(bugprone-narrowing-conversions)
// NOLINTEND(cppcoreguidelines-narrowing-conversions)
}
}
}
Expand Down Expand Up @@ -1214,8 +1218,8 @@ SCENARIO("Testing cell coupling", "[Anisotropic.CellCoupling]") {
CoMMACellCouplingT::MIN_DISTANCE,
0
);
const CoMMAWeightT x_dist = _3_1ov3;
const CoMMAWeightT y_dist = _1ov3;
const CoMMAWeightT x_dist = ten_ov_three;
const CoMMAWeightT y_dist = one_third;
const CoMMAWeightT same_block = 1. / (_sq(x_dist) + _sq(y_dist));
const CoMMAWeightT side_block = 1. / (_sq(2. * x_dist) + _sq(y_dist));
const CoMMAWeightT vert_block = 1. / (_sq(x_dist) + _sq(2. * y_dist));
Expand Down Expand Up @@ -1257,8 +1261,8 @@ SCENARIO("Testing cell coupling", "[Anisotropic.CellCoupling]") {
CoMMACellCouplingT::MIN_DISTANCE,
0
);
const CoMMAWeightT x_dist = _3_1ov3;
const CoMMAWeightT y_dist = _1ov3;
const CoMMAWeightT x_dist = ten_ov_three;
const CoMMAWeightT y_dist = one_third;
const CoMMAWeightT same_block = 1. / (_sq(x_dist) + _sq(y_dist));
const CoMMAWeightT side_block = 1. / (_sq(2. * x_dist) + _sq(y_dist));
const CoMMAWeightT vert_block = 1. / (_sq(x_dist) + _sq(2. * y_dist));
Expand Down
Loading

0 comments on commit 1e919ee

Please sign in to comment.