Skip to content

Commit

Permalink
Merge pull request #238 from awslabs/sjg/clang-format-18
Browse files Browse the repository at this point in the history
Updates for clang-format-18, the new Homebrew default
  • Loading branch information
sebastiangrimberg authored Apr 24, 2024
2 parents 4cad5af + 459e95e commit 5ded92a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
- name: Install clang-format
run: |
wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-16 main'
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main'
sudo apt-get update -q
sudo apt-get install -y clang-format-16
sudo apt-get install -y clang-format-18
- name: Check style
run: |
./scripts/format-source --clang-format clang-format-16
./scripts/format-source --clang-format clang-format-18
if [[ `git status -s | wc -l` -ne 0 ]]; then
echo 'Error: Commit is not formatted!'
echo 'Run '\`'./scripts/format-source'\`' in the source root directory'
Expand Down
4 changes: 2 additions & 2 deletions palace/linalg/chebyshev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ inline void ApplyOrderK(const double sd, const double sr, const Vector &dinv,
const auto *DI = dinv.Read(use_dev);
const auto *R = r.Read(use_dev);
auto *D = d.ReadWrite(use_dev);
mfem::forall_switch(
use_dev, N, [=] MFEM_HOST_DEVICE(int i) { D[i] = sd * D[i] + sr * DI[i] * R[i]; });
mfem::forall_switch(use_dev, N, [=] MFEM_HOST_DEVICE(int i)
{ D[i] = sd * D[i] + sr * DI[i] * R[i]; });
}

template <bool Transpose = false>
Expand Down
3 changes: 1 addition & 2 deletions palace/linalg/vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,7 @@ void SetRandomSign(MPI_Comm comm, Vector &x, int seed)
const bool use_dev = x.UseDevice();
const int N = x.Size();
auto *X = x.ReadWrite(use_dev);
mfem::forall_switch(use_dev, N,
[=] MFEM_HOST_DEVICE(int i)
mfem::forall_switch(use_dev, N, [=] MFEM_HOST_DEVICE(int i)
{ X[i] = (X[i] > 0.0) ? 1.0 : ((X[i] < 0.0) ? -1.0 : 0.0); });
}

Expand Down
6 changes: 3 additions & 3 deletions palace/utils/dorfler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ std::array<double, 2> ComputeDorflerCoarseningThreshold(const mfem::ParMesh &mes
for (int i = 0; i < derefinement_table.Size(); i++)
{
derefinement_table.GetRow(i, row);
coarse_error[i] = std::sqrt(std::accumulate(
row.begin(), row.end(), 0.0,
[&elem_error](double s, int i) { return s += std::pow(elem_error[i], 2.0); }));
coarse_error[i] = std::sqrt(
std::accumulate(row.begin(), row.end(), 0.0, [&elem_error](double s, int i)
{ return s += std::pow(elem_error[i], 2.0); }));
}

// Given the coarse errors, we use the Dörfler marking strategy to identify the
Expand Down
10 changes: 4 additions & 6 deletions palace/utils/geodata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,10 +947,9 @@ BoundingBox BoundingBoxFromPointCloud(MPI_Comm comm,
};

// Collect the furthest point from the plane.
auto max_distance = OutOfPlaneDistance(
*std::max_element(vertices.begin(), vertices.end(),
[OutOfPlaneDistance](const auto &x, const auto &y)
{ return OutOfPlaneDistance(x) < OutOfPlaneDistance(y); }));
auto max_distance = OutOfPlaneDistance(*std::max_element(
vertices.begin(), vertices.end(), [OutOfPlaneDistance](const auto &x, const auto &y)
{ return OutOfPlaneDistance(x) < OutOfPlaneDistance(y); }));

constexpr double rel_tol = 1e-6;
box.planar = max_distance < (rel_tol * (v_111 - v_000).norm());
Expand Down Expand Up @@ -982,8 +981,7 @@ BoundingBox BoundingBoxFromPointCloud(MPI_Comm comm,
Vector3dMap(box.normals[2].data()) = 0.5 * (v_111 - v_011);

// Make sure the longest dimension comes first.
std::sort(box.normals.begin(), box.normals.end(),
[](const auto &x, const auto &y)
std::sort(box.normals.begin(), box.normals.end(), [](const auto &x, const auto &y)
{ return CVector3dMap(x.data()).norm() > CVector3dMap(y.data()).norm(); });
}

Expand Down
3 changes: 1 addition & 2 deletions palace/utils/meshio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,7 @@ void WriteGmsh(std::ostream &buffer, const std::vector<double> &node_coords,
const bool use_lo_type)
{
// Write the Gmsh file header (version 2.2).
buffer << "$MeshFormat\n2.2 "
<<
buffer << "$MeshFormat\n2.2 " <<
#if defined(GMSH_BIN)
"1 " <<
#else
Expand Down

0 comments on commit 5ded92a

Please sign in to comment.