From a587fffb7fc2d797a9e96533f25e5ab9e088ebc5 Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Thu, 30 Dec 2021 14:31:06 -0700 Subject: [PATCH] Reintroduce readability-qualified-auto check. (#539) --- .clang-tidy | 2 +- amr-wind/boundary_conditions/BCInterface.cpp | 2 +- amr-wind/core/Field.cpp | 2 +- amr-wind/core/ScratchField.cpp | 4 ++-- amr-wind/equation_systems/icns/icns_advection.cpp | 2 +- amr-wind/physics/FreeStream.cpp | 4 ++-- amr-wind/physics/VortexRing.cpp | 2 +- amr-wind/physics/multiphase/MultiPhase.cpp | 2 +- amr-wind/physics/multiphase/VortexPatch.cpp | 2 +- amr-wind/physics/multiphase/ZalesakDisk.cpp | 2 +- amr-wind/physics/multiphase/wave_basin/NWB.cpp | 2 +- amr-wind/projection/incflo_apply_nodal_projection.cpp | 2 +- amr-wind/utilities/DerivedQuantity.cpp | 2 +- amr-wind/utilities/io.cpp | 2 +- amr-wind/utilities/sampling/FreeSurface.cpp | 2 +- amr-wind/utilities/sampling/SamplingContainer.cpp | 4 ++-- amr-wind/wind_energy/ABLWallFunction.cpp | 8 ++++---- amr-wind/wind_energy/actuator/ActuatorContainer.cpp | 2 +- unit_tests/core/test_field.cpp | 2 +- unit_tests/fvm/test_fvm_operators.cpp | 6 +++--- unit_tests/fvm/test_fvm_ops.cpp | 8 ++++---- 21 files changed, 32 insertions(+), 32 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 81a8ae9b96..6c8984864a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: 'clang-diagnostic-*,clang-analyzer-*,corecppguidelines-*,modernize-*,readability-*,-readability-magic-numbers,-readability-identifier-naming,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-implicit-bool-conversion,-readability-isolate-declaration,-readability-braces-around-statements,-readability-inconsistent-declaration-parameter-name,-modernize-use-emplace,-readability-qualified-auto,-modernize-pass-by-value,-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-core.NonNullParamChecker' +Checks: 'clang-diagnostic-*,clang-analyzer-*,corecppguidelines-*,modernize-*,readability-*,-readability-magic-numbers,-readability-identifier-naming,-modernize-avoid-c-arrays,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-implicit-bool-conversion,-readability-isolate-declaration,-readability-braces-around-statements,-readability-inconsistent-declaration-parameter-name,-modernize-use-emplace,-modernize-pass-by-value,-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-core.NonNullParamChecker' WarningsAsErrors: '' HeaderFilterRegex: '^((?!/amrex/Src/|/googletest/).)*$' AnalyzeTemporaryDtors: false diff --git a/amr-wind/boundary_conditions/BCInterface.cpp b/amr-wind/boundary_conditions/BCInterface.cpp index f9f755e83f..c74f8381d6 100644 --- a/amr-wind/boundary_conditions/BCInterface.cpp +++ b/amr-wind/boundary_conditions/BCInterface.cpp @@ -49,7 +49,7 @@ void BCIface::read_bctype() { const std::string key = m_field.name() + "_type"; auto& ibctype = m_field.bc_type(); - auto& geom = m_field.repo().mesh().Geom(0); + const auto& geom = m_field.repo().mesh().Geom(0); for (amrex::OrientationIter oit; oit; ++oit) { auto ori = oit(); const auto& bcid = bcnames[ori]; diff --git a/amr-wind/core/Field.cpp b/amr-wind/core/Field.cpp index 90e13d748c..efcb425b10 100644 --- a/amr-wind/core/Field.cpp +++ b/amr-wind/core/Field.cpp @@ -39,7 +39,7 @@ bool FieldInfo::bc_initialized() // Check that BC has been initialized properly bool has_bogus = false; for (int dir = 0; dir < m_ncomp; ++dir) { - auto* bcrec = m_bcrec[dir].vect(); + const auto* bcrec = m_bcrec[dir].vect(); for (int i = 0; i < AMREX_SPACEDIM * 2; ++i) { if (bcrec[i] == amrex::BCType::bogus) { has_bogus = true; diff --git a/amr-wind/core/ScratchField.cpp b/amr-wind/core/ScratchField.cpp index 9a63b5737d..05c3414f38 100644 --- a/amr-wind/core/ScratchField.cpp +++ b/amr-wind/core/ScratchField.cpp @@ -67,7 +67,7 @@ void ScratchField::fillpatch( amrex::MultiFab& mfab, const amrex::IntVect& nghost) noexcept { - auto& mesh = repo().mesh(); + const auto& mesh = repo().mesh(); auto bcrec = scratch_field_bcrec(mesh.Geom(lev), num_comp()); fillpatch(lev, time, mfab, nghost, bcrec); } @@ -79,7 +79,7 @@ void ScratchField::fillpatch( const amrex::IntVect& nghost, amrex::Vector& bcrec) noexcept { - auto& mesh = repo().mesh(); + const auto& mesh = repo().mesh(); amrex::Interpolater* mapper = &amrex::cell_cons_interp; if (lev == 0) { diff --git a/amr-wind/equation_systems/icns/icns_advection.cpp b/amr-wind/equation_systems/icns/icns_advection.cpp index 2cdf0f7e97..9e6459d131 100644 --- a/amr-wind/equation_systems/icns/icns_advection.cpp +++ b/amr-wind/equation_systems/icns/icns_advection.cpp @@ -123,7 +123,7 @@ void MacProjOp::init_projector(const amrex::Real beta) noexcept void MacProjOp::operator()(const FieldState fstate, const amrex::Real dt) { BL_PROFILE("amr-wind::ICNS::advection_mac_project"); - auto& geom = m_repo.mesh().Geom(); + const auto& geom = m_repo.mesh().Geom(); const auto& pressure = m_repo.get_field("p"); auto& u_mac = m_repo.get_field("u_mac"); auto& v_mac = m_repo.get_field("v_mac"); diff --git a/amr-wind/physics/FreeStream.cpp b/amr-wind/physics/FreeStream.cpp index c9989ff81e..66656f3d83 100644 --- a/amr-wind/physics/FreeStream.cpp +++ b/amr-wind/physics/FreeStream.cpp @@ -27,12 +27,12 @@ void FreeStream::pre_init_actions() const auto& repo = m_sim.repo(); m_field_funcs["density"] = process_field_func(repo.get_field("density")); - auto& pde_mgr = m_sim.pde_manager(); + const auto& pde_mgr = m_sim.pde_manager(); { auto& vel = pde_mgr.icns().fields().field; m_field_funcs[vel.name()] = process_field_func(vel); } - for (auto& eqn : pde_mgr.scalar_eqns()) { + for (const auto& eqn : pde_mgr.scalar_eqns()) { auto& fld = eqn->fields().field; m_field_funcs[fld.name()] = process_field_func(fld); } diff --git a/amr-wind/physics/VortexRing.cpp b/amr-wind/physics/VortexRing.cpp index d4f9012f10..c1b6abe931 100644 --- a/amr-wind/physics/VortexRing.cpp +++ b/amr-wind/physics/VortexRing.cpp @@ -186,7 +186,7 @@ void VortexRing::initialize_velocity(const VortexRingType& vorticity_theta) } amrex::LPInfo info; - auto& mesh = m_velocity.repo().mesh(); + const auto& mesh = m_velocity.repo().mesh(); amrex::MLNodeLaplacian linop( mesh.Geom(0, mesh.finestLevel()), mesh.boxArray(0, mesh.finestLevel()), diff --git a/amr-wind/physics/multiphase/MultiPhase.cpp b/amr-wind/physics/multiphase/MultiPhase.cpp index ab6ef131e0..688fc497a8 100644 --- a/amr-wind/physics/multiphase/MultiPhase.cpp +++ b/amr-wind/physics/multiphase/MultiPhase.cpp @@ -102,7 +102,7 @@ amrex::Real MultiPhase::volume_fraction_sum() BL_PROFILE("amr-wind::multiphase::ComputeVolumeFractionSum"); const int nlevels = m_sim.repo().num_active_levels(); const auto& geom = m_sim.mesh().Geom(); - auto& mesh = m_sim.mesh(); + const auto& mesh = m_sim.mesh(); amrex::Real total_volume_frac = 0.0; diff --git a/amr-wind/physics/multiphase/VortexPatch.cpp b/amr-wind/physics/multiphase/VortexPatch.cpp index 9442c89eed..3095f260cc 100644 --- a/amr-wind/physics/multiphase/VortexPatch.cpp +++ b/amr-wind/physics/multiphase/VortexPatch.cpp @@ -35,7 +35,7 @@ void VortexPatch::initialize_fields(int level, const amrex::Geometry& geom) const amrex::Real zc = m_loc[2]; const amrex::Real radius = m_radius; - auto& mphase = m_sim.physics_manager().get(); + const auto& mphase = m_sim.physics_manager().get(); const amrex::Real rho1 = mphase.rho1(); const amrex::Real rho2 = mphase.rho2(); diff --git a/amr-wind/physics/multiphase/ZalesakDisk.cpp b/amr-wind/physics/multiphase/ZalesakDisk.cpp index 944f6e3561..5ab20b75c5 100644 --- a/amr-wind/physics/multiphase/ZalesakDisk.cpp +++ b/amr-wind/physics/multiphase/ZalesakDisk.cpp @@ -32,7 +32,7 @@ void ZalesakDisk::initialize_fields(int level, const amrex::Geometry& geom) const auto& dx = geom.CellSizeArray(); const auto& problo = geom.ProbLoArray(); - auto& mphase = m_sim.physics_manager().get(); + const auto& mphase = m_sim.physics_manager().get(); const amrex::Real rho1 = mphase.rho1(); const amrex::Real rho2 = mphase.rho2(); diff --git a/amr-wind/physics/multiphase/wave_basin/NWB.cpp b/amr-wind/physics/multiphase/wave_basin/NWB.cpp index 909dd47a9f..2a8d233d27 100644 --- a/amr-wind/physics/multiphase/wave_basin/NWB.cpp +++ b/amr-wind/physics/multiphase/wave_basin/NWB.cpp @@ -25,7 +25,7 @@ void NWB::initialize_fields(int level, const amrex::Geometry& geom) auto& levelset = m_levelset(level); auto& density = m_density(level); - auto& mphase = m_sim.physics_manager().get(); + const auto& mphase = m_sim.physics_manager().get(); const amrex::Real rho1 = mphase.rho1(); const amrex::Real rho2 = mphase.rho2(); velocity.setVal(0.0, 0, AMREX_SPACEDIM); diff --git a/amr-wind/projection/incflo_apply_nodal_projection.cpp b/amr-wind/projection/incflo_apply_nodal_projection.cpp index df800a543d..6848894a1f 100644 --- a/amr-wind/projection/incflo_apply_nodal_projection.cpp +++ b/amr-wind/projection/incflo_apply_nodal_projection.cpp @@ -18,7 +18,7 @@ void incflo::set_inflow_velocity( auto& phy_mgr = m_sim.physics_manager(); if (phy_mgr.contains("ABL")) { auto& abl = phy_mgr.get(); - auto& bndry_plane = abl.bndry_plane(); + const auto& bndry_plane = abl.bndry_plane(); bndry_plane.populate_data(lev, time, velocity, vel); } } diff --git a/amr-wind/utilities/DerivedQuantity.cpp b/amr-wind/utilities/DerivedQuantity.cpp index e52dfa607c..9b3ceb0db7 100644 --- a/amr-wind/utilities/DerivedQuantity.cpp +++ b/amr-wind/utilities/DerivedQuantity.cpp @@ -104,7 +104,7 @@ bool DerivedQtyMgr::contains(const std::string& key) const noexcept void DerivedQtyMgr::var_names( amrex::Vector& plt_var_names) const noexcept { - for (auto& qty : m_derived_vec) { + for (const auto& qty : m_derived_vec) { qty->var_names(plt_var_names); } } diff --git a/amr-wind/utilities/io.cpp b/amr-wind/utilities/io.cpp index 621bb9ee8c..76f01b8256 100644 --- a/amr-wind/utilities/io.cpp +++ b/amr-wind/utilities/io.cpp @@ -194,7 +194,7 @@ void incflo::ReadCheckpointFile() for (int d = 0; d < AMREX_SPACEDIM; d++) { auto new_domain = ba_rep.minimalBox(); - auto hi_vect = new_domain.hiVect(); + const auto* hi_vect = new_domain.hiVect(); if (hi_vect[d] + 1 != n_cell_input[d]) { amrex::Abort( diff --git a/amr-wind/utilities/sampling/FreeSurface.cpp b/amr-wind/utilities/sampling/FreeSurface.cpp index 106d162b36..6357c90e5b 100644 --- a/amr-wind/utilities/sampling/FreeSurface.cpp +++ b/amr-wind/utilities/sampling/FreeSurface.cpp @@ -110,7 +110,7 @@ void FreeSurface::post_advance_work() level_mask.setVal(1); } - auto& vof = m_vof(lev); + const auto& vof = m_vof(lev); const auto& geom = m_sim.mesh().Geom(lev); const amrex::GpuArray dx = geom.CellSizeArray(); diff --git a/amr-wind/utilities/sampling/SamplingContainer.cpp b/amr-wind/utilities/sampling/SamplingContainer.cpp index 1e44140eef..f4d5a1153e 100644 --- a/amr-wind/utilities/sampling/SamplingContainer.cpp +++ b/amr-wind/utilities/sampling/SamplingContainer.cpp @@ -102,7 +102,7 @@ void SamplingContainer::initialize_particles( if (owner != iproc) return; int num_particles = 0; - for (auto& probes : samplers) num_particles += probes->num_points(); + for (const auto& probes : samplers) num_particles += probes->num_points(); m_total_particles = num_particles; const int grid_id = 0; @@ -116,7 +116,7 @@ void SamplingContainer::initialize_particles( const int nextid = ParticleType::NextID(); auto* pstruct = ptile.GetArrayOfStructs()().data(); SamplerBase::SampleLocType locs; - for (auto& probe : samplers) { + for (const auto& probe : samplers) { probe->sampling_locations(locs); const int npts = locs.size(); const auto probe_id = probe->id(); diff --git a/amr-wind/wind_energy/ABLWallFunction.cpp b/amr-wind/wind_energy/ABLWallFunction.cpp index b8ee1d4a47..5cd38a39a8 100644 --- a/amr-wind/wind_energy/ABLWallFunction.cpp +++ b/amr-wind/wind_energy/ABLWallFunction.cpp @@ -169,10 +169,10 @@ void ABLVelWallFunc::wall_model( const auto& domain = geom.Domain(); amrex::MFItInfo mfi_info{}; - auto& rho_lev = density(lev); + const auto& rho_lev = density(lev); auto& vold_lev = velocity.state(FieldState::Old)(lev); auto& vel_lev = velocity(lev); - auto& eta_lev = viscosity(lev); + const auto& eta_lev = viscosity(lev); if (amrex::Gpu::notInLaunchRegion()) mfi_info.SetDynamic(true); #ifdef _OPENMP @@ -293,11 +293,11 @@ void ABLTempWallFunc::wall_model( const auto& domain = geom.Domain(); amrex::MFItInfo mfi_info{}; - auto& rho_lev = density(lev); + const auto& rho_lev = density(lev); auto& vold_lev = velocity.state(FieldState::Old)(lev); auto& told_lev = temperature.state(FieldState::Old)(lev); auto& theta = temperature(lev); - auto& eta_lev = alpha(lev); + const auto& eta_lev = alpha(lev); if (amrex::Gpu::notInLaunchRegion()) mfi_info.SetDynamic(true); #ifdef _OPENMP diff --git a/amr-wind/wind_energy/actuator/ActuatorContainer.cpp b/amr-wind/wind_energy/actuator/ActuatorContainer.cpp index 29bad74018..4a48a64981 100644 --- a/amr-wind/wind_energy/actuator/ActuatorContainer.cpp +++ b/amr-wind/wind_energy/actuator/ActuatorContainer.cpp @@ -157,7 +157,7 @@ void ActuatorContainer::update_positions() AMREX_ALWAYS_ASSERT(m_container_initialized && !m_is_scattered); const auto dpos = gpu::device_view(m_data.position); - const auto dptr = dpos.data(); + const auto* const dptr = dpos.data(); const int nlevels = m_mesh.finestLevel() + 1; for (int lev = 0; lev < nlevels; ++lev) { for (ParIterType pti(*this, lev); pti.isValid(); ++pti) { diff --git a/unit_tests/core/test_field.cpp b/unit_tests/core/test_field.cpp index 749d698641..0d51e6fd44 100644 --- a/unit_tests/core/test_field.cpp +++ b/unit_tests/core/test_field.cpp @@ -28,7 +28,7 @@ TEST_F(FieldRepoTest, field_pre_declare) int num_cc = 0; int num_nd = 0; int num_invalid = 0; - for (auto& field : frepo.fields()) { + for (const auto& field : frepo.fields()) { switch (field->field_location()) { case amr_wind::FieldLoc::CELL: ++num_cc; diff --git a/unit_tests/fvm/test_fvm_operators.cpp b/unit_tests/fvm/test_fvm_operators.cpp index de6d4ef5af..9d67710b59 100644 --- a/unit_tests/fvm/test_fvm_operators.cpp +++ b/unit_tests/fvm/test_fvm_operators.cpp @@ -58,7 +58,7 @@ amrex::Real grad_test_impl(amr_wind::Field& vel, const int pdegree) amrex::Gpu::DeviceVector cv(ncoeff, 0.00213); amrex::Gpu::DeviceVector cw(ncoeff, 0.00346); - auto& geom = vel.repo().mesh().Geom(); + const auto& geom = vel.repo().mesh().Geom(); run_algorithm(vel, [&](const int lev, const amrex::MFIter& mfi) { auto vel_arr = vel(lev).array(mfi); @@ -139,7 +139,7 @@ amrex::Real laplacian_test_impl(amr_wind::Field& vel, const int pdegree) amrex::Gpu::DeviceVector cv(ncoeff, 0.00213); amrex::Gpu::DeviceVector cw(ncoeff, 0.00346); - auto& geom = vel.repo().mesh().Geom(); + const auto& geom = vel.repo().mesh().Geom(); run_algorithm(vel, [&](const int lev, const amrex::MFIter& mfi) { auto vel_arr = vel(lev).array(mfi); @@ -196,7 +196,7 @@ amrex::Real divergence_test_impl(amr_wind::Field& vel, const int pdegree) amrex::Gpu::DeviceVector cv(ncoeff, 0.00213); amrex::Gpu::DeviceVector cw(ncoeff, 0.00346); - auto& geom = vel.repo().mesh().Geom(); + const auto& geom = vel.repo().mesh().Geom(); run_algorithm(vel, [&](const int lev, const amrex::MFIter& mfi) { auto vel_arr = vel(lev).array(mfi); diff --git a/unit_tests/fvm/test_fvm_ops.cpp b/unit_tests/fvm/test_fvm_ops.cpp index fd5c1a35c2..fb66b2ea7c 100644 --- a/unit_tests/fvm/test_fvm_ops.cpp +++ b/unit_tests/fvm/test_fvm_ops.cpp @@ -63,7 +63,7 @@ amrex::Real strainrate_test_impl(amr_wind::Field& vel, const int pdegree) amrex::Gpu::DeviceVector cv(ncoeff, 0.00213); amrex::Gpu::DeviceVector cw(ncoeff, 0.00346); - auto& geom = vel.repo().mesh().Geom(); + const auto& geom = vel.repo().mesh().Geom(); run_algorithm(vel, [&](const int lev, const amrex::MFIter& mfi) { auto vel_arr = vel(lev).array(mfi); @@ -120,7 +120,7 @@ amrex::Real vorticity_test_impl(amr_wind::Field& vel, const int pdegree) amrex::Gpu::DeviceVector cv(ncoeff, 0.000463); amrex::Gpu::DeviceVector cw(ncoeff, 0.000386); - auto& geom = vel.repo().mesh().Geom(); + const auto& geom = vel.repo().mesh().Geom(); run_algorithm(vel, [&](const int lev, const amrex::MFIter& mfi) { auto vel_arr = vel(lev).array(mfi); @@ -185,7 +185,7 @@ amrex::Real vorticity_mag_test_impl(amr_wind::Field& vel, const int pdegree) amrex::Gpu::DeviceVector cv(ncoeff, 0.00213); amrex::Gpu::DeviceVector cw(ncoeff, 0.00346); - auto& geom = vel.repo().mesh().Geom(); + const auto& geom = vel.repo().mesh().Geom(); run_algorithm(vel, [&](const int lev, const amrex::MFIter& mfi) { auto vel_arr = vel(lev).array(mfi); @@ -250,7 +250,7 @@ amrex::Real q_criterion_test_impl(amr_wind::Field& vel, const int pdegree) amrex::Gpu::DeviceVector cv(ncoeff, 0.00213); amrex::Gpu::DeviceVector cw(ncoeff, 0.00346); - auto& geom = vel.repo().mesh().Geom(); + const auto& geom = vel.repo().mesh().Geom(); run_algorithm(vel, [&](const int lev, const amrex::MFIter& mfi) { auto vel_arr = vel(lev).array(mfi);