From b9ebe80bd3b00db0f50710048e50bac01212ef2b Mon Sep 17 00:00:00 2001 From: "Marc T. Henry de Frahan" Date: Thu, 10 Oct 2024 14:19:31 -0600 Subject: [PATCH] Update clang-tidy (#856) --- .clang-tidy | 5 ++-- .github/workflows/ci.yml | 10 +++---- Source/InitEB.cpp | 6 ++-- Source/LES.H | 19 +++++++++++++ Source/LES.cpp | 61 ++++++++++++++++++++++------------------ Source/PeleC.cpp | 4 +-- Source/Sources.cpp | 8 ++++++ Source/Utilities.H | 4 +-- Submodules/PelePhysics | 2 +- 9 files changed, 75 insertions(+), 44 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 81cd58a38..40f20c836 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -16,13 +16,14 @@ Checks: 'bugprone-*, -readability-identifier-naming, -readability-isolate-declaration, -readability-avoid-const-params-in-decls, + -readability-avoid-nested-conditional-operator, + -readability-math-missing-parentheses, -readability-static-accessed-through-instance, -readability-identifier-length, -readability-function-cognitive-complexity, -readability-function-size' WarningsAsErrors: '' -HeaderFilterRegex: 'PeleC\/Source|PeleC\/Exec|PeleC\/Submodules\/PelePhysics\/Source|PeleC\/Submodules\/PelePhysics\/Mechanism' -AnalyzeTemporaryDtors: false +HeaderFilterRegex: 'PeleC\/Source|PeleC\/Exec|PeleC\/Submodules\/PelePhysics\/Source|PeleC\/Submodules\/PelePhysics\/Mechanisms' FormatStyle: none User: user CheckOptions: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3dd33843b..360edbaa9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -581,7 +581,7 @@ jobs: # exit ${return} Lint-clang-tidy: needs: Formatting - runs-on: macos-13 + runs-on: macos-latest steps: - name: Clone uses: actions/checkout@v4 @@ -594,9 +594,10 @@ jobs: echo "CCACHE_COMPRESSLEVEL=1" >> $GITHUB_ENV echo "CCACHE_LOGFILE=${{github.workspace}}/ccache.log.txt" >> $GITHUB_ENV echo "CCACHE_MAXSIZE=500M" >> $GITHUB_ENV - - name: Install Ccache + - name: Dependencies run: | brew install ccache + brew install llvm - name: Set Up Ccache uses: actions/cache@v4 with: @@ -606,7 +607,7 @@ jobs: ccache-${{github.workflow}}-${{github.job}}-git- - name: Configure run: | - export PATH=$(brew --prefix llvm@15)/bin:${PATH} + export PATH=$(brew --prefix llvm)/bin:${PATH} cmake -B${{runner.workspace}}/build-clang-tidy \ -DCMAKE_BUILD_TYPE:STRING=Release \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ @@ -622,8 +623,7 @@ jobs: - name: Check working-directory: ${{runner.workspace}}/build-clang-tidy run: | - #set -eu -o pipefail - export PATH=$(brew --prefix llvm@15)/bin:${PATH} + export PATH=$(brew --prefix llvm)/bin:${PATH} cmake --build . --parallel ${{env.NPROCS}} 2>&1 | tee -a clang-tidy-full-report.txt egrep "warning:|error:" clang-tidy-full-report.txt \ | egrep -v "Submodules/amrex|Submodules/sundials" \ diff --git a/Source/InitEB.cpp b/Source/InitEB.cpp index 9f8032350..acac4c795 100644 --- a/Source/InitEB.cpp +++ b/Source/InitEB.cpp @@ -38,7 +38,7 @@ PeleC::initialize_eb2_structs() amrex::Print() << "Initializing EB2 structs" << std::endl; static_assert( - std::is_standard_layout::value, + std::is_standard_layout_v, "EBBndryGeom is not standard layout"); const auto& ebfactory = @@ -560,9 +560,7 @@ PeleC::extend_signed_distance( +((j - jj) * dx[1] * (j - jj) * dx[1]), +((k - kk) * dx[2] * (k - kk) * dx[2]))); const amrex::Real distToEB = distToCell + sd_cc(ii, jj, kk); - if (distToEB < closestEBDist) { - closestEBDist = distToEB; - } + closestEBDist = amrex::min(distToEB, closestEBDist); } } } diff --git a/Source/LES.H b/Source/LES.H index cf7b8fb20..b3434f114 100644 --- a/Source/LES.H +++ b/Source/LES.H @@ -1109,5 +1109,24 @@ pc_vreman_sfs_term( flx(iv, UEDEN) = flx(iv, UEDEN) * a(iv); } +void computeTangentialVelDerivs( + const amrex::Array& eboxes, + amrex::Array& tander_ec, + amrex::GpuArray, AMREX_SPACEDIM>& tanders, + const amrex::Array4& q_ar, + const amrex::GpuArray dx); + +void resizeAndSetFlux( + const amrex::Array& eboxes, + amrex::GpuArray, AMREX_SPACEDIM>& flx, + amrex::Array& flux_ec); + +void computeFluxDiv( + amrex::MultiFab& LESTerm, + const amrex::MFIter& mfi, + const amrex::Box& vbox, + amrex::GpuArray, AMREX_SPACEDIM>& flx, + const amrex::MultiFab& volume); + #endif // AMREX_SPACEDIM == 3 #endif diff --git a/Source/LES.cpp b/Source/LES.cpp index b900a1ee6..312ad3e1f 100644 --- a/Source/LES.cpp +++ b/Source/LES.cpp @@ -152,8 +152,8 @@ PeleC::getLESTerm( void computeTangentialVelDerivs( - const amrex::Box eboxes[AMREX_SPACEDIM], - amrex::FArrayBox tander_ec[AMREX_SPACEDIM], + const amrex::Array& eboxes, + amrex::Array& tander_ec, amrex::GpuArray, AMREX_SPACEDIM>& tanders, const amrex::Array4& q_ar, const amrex::GpuArray dx) @@ -176,9 +176,9 @@ computeTangentialVelDerivs( void resizeAndSetFlux( - const amrex::Box eboxes[AMREX_SPACEDIM], + const amrex::Array& eboxes, amrex::GpuArray, AMREX_SPACEDIM>& flx, - amrex::FArrayBox flux_ec[AMREX_SPACEDIM]) + amrex::Array& flux_ec) { for (int dir = 0; dir < AMREX_SPACEDIM; dir++) { flux_ec[dir].resize(eboxes[dir], NVAR, amrex::The_Async_Arena()); @@ -215,7 +215,7 @@ PeleC::updateFluxRegistersLES( amrex::Real dt, const amrex::MFIter& mfi, amrex::FabType typ, - const std::array& flux_ec) + const amrex::Array& flux_ec) { if (do_reflux && reflux_factor != 0) { amrex::FArrayBox dm_as_fine( @@ -287,16 +287,17 @@ PeleC::getSmagorinskyLESTerm( } // Get the tangential derivatives - amrex::FArrayBox tander_ec[AMREX_SPACEDIM]; - const amrex::Box eboxes[AMREX_SPACEDIM] = {AMREX_D_DECL( - amrex::surroundingNodes(cbox, 0), amrex::surroundingNodes(cbox, 1), - amrex::surroundingNodes(cbox, 2))}; + amrex::Array tander_ec; + const amrex::Array eboxes = { + AMREX_D_DECL( + amrex::surroundingNodes(cbox, 0), amrex::surroundingNodes(cbox, 1), + amrex::surroundingNodes(cbox, 2))}; amrex::GpuArray, AMREX_SPACEDIM> tanders; computeTangentialVelDerivs(eboxes, tander_ec, tanders, q_ar, dx); // Compute extensive LES fluxes, F.A - amrex::FArrayBox flux_ec[AMREX_SPACEDIM]; + amrex::Array flux_ec; const amrex::GpuArray< const amrex::Array4, AMREX_SPACEDIM> a{{AMREX_D_DECL( @@ -324,7 +325,7 @@ PeleC::getSmagorinskyLESTerm( // Refluxing updateFluxRegistersLES( reflux_factor, LESTerm, dt, mfi, typ, - {AMREX_D_DECL(&flux_ec[0], &flux_ec[1], &flux_ec[2])}); + {AMREX_D_DECL(flux_ec.data(), &flux_ec[1], &flux_ec[2])}); } // End of MFIter scope } // End of OMP scope #endif @@ -521,9 +522,10 @@ PeleC::getDynamicSmagorinskyLESTerm( // 6. Get the SFS term // First step: move everything needed to compute fluxes to ec (faces) - const amrex::Box eboxes[AMREX_SPACEDIM] = {AMREX_D_DECL( - amrex::surroundingNodes(cbox, 0), amrex::surroundingNodes(cbox, 1), - amrex::surroundingNodes(cbox, 2))}; + const amrex::Array eboxes = { + AMREX_D_DECL( + amrex::surroundingNodes(cbox, 0), amrex::surroundingNodes(cbox, 1), + amrex::surroundingNodes(cbox, 2))}; amrex::FArrayBox coeff_ec[AMREX_SPACEDIM]; amrex::FArrayBox alphaij_ec[AMREX_SPACEDIM]; amrex::FArrayBox alpha_ec[AMREX_SPACEDIM]; @@ -579,7 +581,7 @@ PeleC::getDynamicSmagorinskyLESTerm( // Compute the fluxes at the faces: all values passed are at faces // except for Q, V, and Lterm - amrex::FArrayBox flux_ec[AMREX_SPACEDIM]; + amrex::Array flux_ec; const amrex::GpuArray< const amrex::Array4, AMREX_SPACEDIM> a{{AMREX_D_DECL( @@ -604,7 +606,7 @@ PeleC::getDynamicSmagorinskyLESTerm( // Refluxing updateFluxRegistersLES( reflux_factor, LESTerm, dt, mfi, typ, - {AMREX_D_DECL(&flux_ec[0], &flux_ec[1], &flux_ec[2])}); + {AMREX_D_DECL(flux_ec.data(), &flux_ec[1], &flux_ec[2])}); } } #endif @@ -673,15 +675,17 @@ PeleC::getWALELESTerm( } // Get the tangential derivatives - amrex::FArrayBox tander_ec[AMREX_SPACEDIM]; - const amrex::Box eboxes[AMREX_SPACEDIM] = {AMREX_D_DECL( - amrex::surroundingNodes(cbox, 0), amrex::surroundingNodes(cbox, 1), - amrex::surroundingNodes(cbox, 2))}; + amrex::Array tander_ec; + const amrex::Array eboxes = { + AMREX_D_DECL( + amrex::surroundingNodes(cbox, 0), amrex::surroundingNodes(cbox, 1), + amrex::surroundingNodes(cbox, 2))}; amrex::GpuArray, AMREX_SPACEDIM> tanders; computeTangentialVelDerivs(eboxes, tander_ec, tanders, q_ar, dx); // Compute extensive LES fluxes, F.A - amrex::FArrayBox flux_ec[AMREX_SPACEDIM]; + amrex::Array flux_ec; + const amrex::GpuArray< const amrex::Array4, AMREX_SPACEDIM> a{{AMREX_D_DECL( @@ -709,7 +713,7 @@ PeleC::getWALELESTerm( // Refluxing updateFluxRegistersLES( reflux_factor, LESTerm, dt, mfi, typ, - {AMREX_D_DECL(&flux_ec[0], &flux_ec[1], &flux_ec[2])}); + {AMREX_D_DECL(flux_ec.data(), &flux_ec[1], &flux_ec[2])}); } // End of MFIter scope } // End of OMP scope #endif @@ -778,16 +782,17 @@ PeleC::getVremanLESTerm( } // Get the tangential derivatives - amrex::FArrayBox tander_ec[AMREX_SPACEDIM]; - const amrex::Box eboxes[AMREX_SPACEDIM] = {AMREX_D_DECL( - amrex::surroundingNodes(cbox, 0), amrex::surroundingNodes(cbox, 1), - amrex::surroundingNodes(cbox, 2))}; + amrex::Array tander_ec; + const amrex::Array eboxes = { + AMREX_D_DECL( + amrex::surroundingNodes(cbox, 0), amrex::surroundingNodes(cbox, 1), + amrex::surroundingNodes(cbox, 2))}; amrex::GpuArray, AMREX_SPACEDIM> tanders; computeTangentialVelDerivs(eboxes, tander_ec, tanders, q_ar, dx); // Compute extensive LES fluxes, F.A - amrex::FArrayBox flux_ec[AMREX_SPACEDIM]; + amrex::Array flux_ec; const amrex::GpuArray< const amrex::Array4, AMREX_SPACEDIM> a{{AMREX_D_DECL( @@ -815,7 +820,7 @@ PeleC::getVremanLESTerm( // Refluxing updateFluxRegistersLES( reflux_factor, LESTerm, dt, mfi, typ, - {AMREX_D_DECL(&flux_ec[0], &flux_ec[1], &flux_ec[2])}); + {AMREX_D_DECL(flux_ec.data(), &flux_ec[1], &flux_ec[2])}); } // End of MFIter scope } // End of OMP scope #endif diff --git a/Source/PeleC.cpp b/Source/PeleC.cpp index 070dc189e..f4aa75731 100644 --- a/Source/PeleC.cpp +++ b/Source/PeleC.cpp @@ -2054,8 +2054,8 @@ PeleC::init_les() amrex::Print() << "WARNING: LES is not supported for multi-component systems" << std::endl; #endif - if (std::is_same< - pele::physics::PhysicsType::eos_type, pele::physics::eos::SRK>::value) { + if (std::is_same_v< + pele::physics::PhysicsType::eos_type, pele::physics::eos::SRK>) { amrex::Abort("LES is not supported for non-ideal equations of state"); } } diff --git a/Source/Sources.cpp b/Source/Sources.cpp index 6bc7d2e92..992f95222 100644 --- a/Source/Sources.cpp +++ b/Source/Sources.cpp @@ -47,6 +47,10 @@ PeleC::construct_old_source( construct_old_mms_source(time); break; #endif + + default: + amrex::Abort("Unrecognized source term"); + break; } // end switch } @@ -95,6 +99,10 @@ PeleC::construct_new_source( construct_new_mms_source(time); break; #endif + + default: + amrex::Abort("Unrecognized source term"); + break; } // end switch } diff --git a/Source/Utilities.H b/Source/Utilities.H index 9837e82aa..a02b82c7f 100644 --- a/Source/Utilities.H +++ b/Source/Utilities.H @@ -53,8 +53,8 @@ pc_rst_int_e( const amrex::Real dual_energy_eta2, const int /*verbose*/) { - if (std::is_same< - pele::physics::PhysicsType::eos_type, pele::physics::eos::SRK>::value) { + if (std::is_same_v< + pele::physics::PhysicsType::eos_type, pele::physics::eos::SRK>) { if ((!allow_small_energy) || (!allow_negative_energy)) { amrex::Error("Small/negative energy must be allowed for nonideal EOS"); } diff --git a/Submodules/PelePhysics b/Submodules/PelePhysics index 45ae8ba14..57614815d 160000 --- a/Submodules/PelePhysics +++ b/Submodules/PelePhysics @@ -1 +1 @@ -Subproject commit 45ae8ba14f2a14e8f692c83a3b675883f7018bfd +Subproject commit 57614815dced2f9d53dec128e0da0fcccd4dec05