diff --git a/amr-wind/CFDSim.cpp b/amr-wind/CFDSim.cpp index f85ff79e1d..b02e05f78a 100644 --- a/amr-wind/CFDSim.cpp +++ b/amr-wind/CFDSim.cpp @@ -23,18 +23,19 @@ CFDSim::~CFDSim() = default; void CFDSim::create_turbulence_model() { - std::string transport_model = "ConstTransport"; - std::string turbulence_model = "Laminar"; + std::string transport_model_name = "ConstTransport"; + std::string turbulence_model_name = "Laminar"; { amrex::ParmParse pp("transport"); - pp.query("model", transport_model); + pp.query("model", transport_model_name); } { amrex::ParmParse pp("turbulence"); - pp.query("model", turbulence_model); + pp.query("model", turbulence_model_name); } - const std::string identifier = turbulence_model + "-" + transport_model; + const std::string identifier = + turbulence_model_name + "-" + transport_model_name; m_turbulence = turbulence::TurbulenceModel::create(identifier, *this); m_turbulence->parse_model_coeffs(); } @@ -45,7 +46,7 @@ void CFDSim::init_physics() amrex::Vector phys_names; pp.queryarr("physics", phys_names); - for (auto& phy : phys_names) { + for (const auto& phy : phys_names) { m_physics_mgr.create(phy, *this); } } diff --git a/amr-wind/boundary_conditions/BCInterface.cpp b/amr-wind/boundary_conditions/BCInterface.cpp index d0c4acb72a..b17013afce 100644 --- a/amr-wind/boundary_conditions/BCInterface.cpp +++ b/amr-wind/boundary_conditions/BCInterface.cpp @@ -131,6 +131,7 @@ std::pair BCIface::get_dirichlet_udfs() "faces"); } else { inflow_udf = val; + has_inflow_udf = true; } } } @@ -146,6 +147,7 @@ std::pair BCIface::get_dirichlet_udfs() "faces"); } else { wall_udf = val; + has_wall_udf = true; } } } diff --git a/amr-wind/core/Field.cpp b/amr-wind/core/Field.cpp index 0ccf55f492..dd44acad04 100644 --- a/amr-wind/core/Field.cpp +++ b/amr-wind/core/Field.cpp @@ -268,7 +268,7 @@ void Field::fillphysbc(amrex::Real time) noexcept void Field::apply_bc_funcs(const FieldState rho_state) noexcept { BL_ASSERT(m_info->bc_initialized() && m_info->m_bc_copied_to_device); - for (auto& func : m_info->m_bc_func) { + for (const auto& func : m_info->m_bc_func) { (*func)(*this, rho_state); } } @@ -296,8 +296,9 @@ void Field::advance_states() noexcept for (int i = num_time_states() - 1; i > 0; --i) { const auto sold = static_cast(i); const auto snew = static_cast(i - 1); + // cppcheck-suppress constVariableReference auto& old_field = state(sold); - auto& new_field = state(snew); + const auto& new_field = state(snew); for (int lev = 0; lev < m_repo.num_active_levels(); ++lev) { amrex::MultiFab::Copy( old_field(lev), new_field(lev), 0, 0, num_comp(), num_grow()); @@ -308,6 +309,7 @@ void Field::advance_states() noexcept void Field::copy_state(FieldState to_state, FieldState from_state) noexcept { BL_PROFILE("amr-wind::Field::copy_state"); + // cppcheck-suppress constVariableReference auto& to_field = state(to_state); const auto& from_field = state(from_state); diff --git a/amr-wind/equation_systems/AdvOp_Godunov.H b/amr-wind/equation_systems/AdvOp_Godunov.H index 178c221812..2a93b8e6ea 100644 --- a/amr-wind/equation_systems/AdvOp_Godunov.H +++ b/amr-wind/equation_systems/AdvOp_Godunov.H @@ -84,7 +84,7 @@ struct AdvectionOp< const auto& geom = repo.mesh().Geom(); const auto& src_term = fields.src_term; - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& conv_term = fields.conv_term; const auto& dof_field = fields.field.state(fstate); diff --git a/amr-wind/equation_systems/AdvOp_MOL.H b/amr-wind/equation_systems/AdvOp_MOL.H index 1b61ba8b04..256876ef14 100644 --- a/amr-wind/equation_systems/AdvOp_MOL.H +++ b/amr-wind/equation_systems/AdvOp_MOL.H @@ -49,7 +49,7 @@ struct AdvectionOp< const auto& repo = fields.repo; const auto& geom = repo.mesh().Geom(); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& conv_term = fields.conv_term.state(fstate); const auto& dof_field = fields.field.state(fstate); const auto& den = density.state(fstate); diff --git a/amr-wind/equation_systems/icns/icns_advection.H b/amr-wind/equation_systems/icns/icns_advection.H index bf7e434380..d89e9c4dcf 100644 --- a/amr-wind/equation_systems/icns/icns_advection.H +++ b/amr-wind/equation_systems/icns/icns_advection.H @@ -314,11 +314,11 @@ struct AdvectionOp void operator()(const FieldState fstate, const amrex::Real dt) { - auto& repo = fields.repo; + const auto& repo = fields.repo; const auto& geom = repo.mesh().Geom(); const auto& src_term = fields.src_term; - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& conv_term = fields.conv_term; const auto& dof_field = fields.field.state(fstate); @@ -550,8 +550,7 @@ struct AdvectionOp const amrex::Real /*time*/) { - // cppcheck-suppress constVariable - auto& repo = fields.repo; + const auto& repo = fields.repo; auto& dof_field = fields.field.state(fstate); // computation of velocity on faces requires @@ -579,7 +578,7 @@ struct AdvectionOp const auto& repo = fields.repo; const auto& geom = repo.mesh().Geom(); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& conv_term = fields.conv_term.state(fstate); const auto& dof_field = fields.field.state(fstate); const auto& rho = repo.get_field("density").state(fstate); diff --git a/amr-wind/equation_systems/icns/icns_diffusion.H b/amr-wind/equation_systems/icns/icns_diffusion.H index c4872ad310..eb9f2daa72 100644 --- a/amr-wind/equation_systems/icns/icns_diffusion.H +++ b/amr-wind/equation_systems/icns/icns_diffusion.H @@ -443,8 +443,7 @@ public: { const FieldState fstate = FieldState::New; auto& repo = m_pdefields.repo; - // cppcheck-suppress constVariable - auto& field = m_pdefields.field; + const auto& field = m_pdefields.field; const auto& density = m_density.state(fstate); const int nlevels = repo.num_active_levels(); const int ndim = field.num_comp(); diff --git a/amr-wind/equation_systems/icns/source_terms/ABLMeanBoussinesq.H b/amr-wind/equation_systems/icns/source_terms/ABLMeanBoussinesq.H index 328b3f83f5..d479cd9965 100644 --- a/amr-wind/equation_systems/icns/source_terms/ABLMeanBoussinesq.H +++ b/amr-wind/equation_systems/icns/source_terms/ABLMeanBoussinesq.H @@ -53,7 +53,7 @@ private: bool m_const_profile{false}; //! Read a temperature profile from a text file - void read_temperature_profile(std::string profile_file_name); + void read_temperature_profile(const std::string& profile_file_name); }; } // namespace amr_wind::pde::icns diff --git a/amr-wind/equation_systems/icns/source_terms/ABLMeanBoussinesq.cpp b/amr-wind/equation_systems/icns/source_terms/ABLMeanBoussinesq.cpp index b15ad07aa7..390e37b705 100644 --- a/amr-wind/equation_systems/icns/source_terms/ABLMeanBoussinesq.cpp +++ b/amr-wind/equation_systems/icns/source_terms/ABLMeanBoussinesq.cpp @@ -126,7 +126,8 @@ void ABLMeanBoussinesq::mean_temperature_update(const FieldPlaneAveraging& tavg) tavg.line_average().end(), m_theta_vals.begin()); } -void ABLMeanBoussinesq::read_temperature_profile(std::string profile_file_name) +void ABLMeanBoussinesq::read_temperature_profile( + const std::string& profile_file_name) { amrex::Vector theta_ht, theta_vals; diff --git a/amr-wind/equation_systems/tke/source_terms/KsgsM84Src.cpp b/amr-wind/equation_systems/tke/source_terms/KsgsM84Src.cpp index 5e27b189c8..5855218366 100644 --- a/amr-wind/equation_systems/tke/source_terms/KsgsM84Src.cpp +++ b/amr-wind/equation_systems/tke/source_terms/KsgsM84Src.cpp @@ -36,7 +36,7 @@ void KsgsM84Src::operator()( const amrex::Real Ceps = this->m_Ceps; const amrex::Real CepsGround = this->m_CepsGround; - auto& repo = (this->m_tke).repo(); + const auto& repo = (this->m_tke).repo(); const auto geom = repo.mesh().Geom(lev); const amrex::Real dx = geom.CellSize()[0]; diff --git a/amr-wind/equation_systems/tke/tke_ops.H b/amr-wind/equation_systems/tke/tke_ops.H index 35b10bf318..11e32aef0c 100644 --- a/amr-wind/equation_systems/tke/tke_ops.H +++ b/amr-wind/equation_systems/tke/tke_ops.H @@ -36,6 +36,7 @@ struct PostSolveOp void operator()(const amrex::Real time) { + // cppcheck-suppress constVariableReference auto& field = m_fields.field; const auto& repo = field.repo(); const int nlevels = repo.num_active_levels(); diff --git a/amr-wind/immersed_boundary/bluff_body/bluff_body_ops.cpp b/amr-wind/immersed_boundary/bluff_body/bluff_body_ops.cpp index b2ef98916a..9988921584 100644 --- a/amr-wind/immersed_boundary/bluff_body/bluff_body_ops.cpp +++ b/amr-wind/immersed_boundary/bluff_body/bluff_body_ops.cpp @@ -31,7 +31,7 @@ void apply_mms_vel(CFDSim& sim) const int nlevels = sim.repo().num_active_levels(); const auto& levelset = sim.repo().get_field("ib_levelset"); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& velocity = sim.repo().get_field("velocity"); auto& m_conv_taylor_green = sim.physics_manager().get(); @@ -50,8 +50,8 @@ void apply_mms_vel(CFDSim& sim) for (amrex::MFIter mfi(levelset(lev)); mfi.isValid(); ++mfi) { const auto& bx = mfi.growntilebox(); - auto phi = levelset(lev).array(mfi); - auto varr = velocity(lev).array(mfi); + const auto& phi = levelset(lev).const_array(mfi); + const auto& varr = velocity(lev).array(mfi); amrex::ParallelFor( bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const amrex::Real x = problo[0] + (i + 0.5) * dx[0]; @@ -77,7 +77,7 @@ void apply_dirichlet_vel(CFDSim& sim, const amrex::Vector& vel_bc) { const int nlevels = sim.repo().num_active_levels(); auto& geom = sim.mesh().Geom(); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& velocity = sim.repo().get_field("velocity"); auto& levelset = sim.repo().get_field("ib_levelset"); levelset.fillpatch(sim.time().current_time()); @@ -94,13 +94,13 @@ void apply_dirichlet_vel(CFDSim& sim, const amrex::Vector& vel_bc) for (amrex::MFIter mfi(levelset(lev)); mfi.isValid(); ++mfi) { const auto& bx = mfi.tilebox(); - auto varr = velocity(lev).array(mfi); - auto phi_arr = levelset(lev).array(mfi); + const auto& varr = velocity(lev).array(mfi); + const auto& phi_arr = levelset(lev).const_array(mfi); auto norm_arr = normal(lev).array(mfi); - amrex::Real velx = vel_bc[0]; - amrex::Real vely = vel_bc[1]; - amrex::Real velz = vel_bc[2]; + const amrex::Real velx = vel_bc[0]; + const amrex::Real vely = vel_bc[1]; + const amrex::Real velz = vel_bc[2]; amrex::ParallelFor( bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { diff --git a/amr-wind/immersed_boundary/bluff_body/box_ops.H b/amr-wind/immersed_boundary/bluff_body/box_ops.H index 11bbaa1095..4c2175f7a0 100644 --- a/amr-wind/immersed_boundary/bluff_body/box_ops.H +++ b/amr-wind/immersed_boundary/bluff_body/box_ops.H @@ -48,9 +48,9 @@ struct InitDataOp const auto& wdata = data.meta(); auto& sim = data.sim(); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& mask_node = sim.repo().get_int_field("mask_node"); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& levelset = sim.repo().get_field("ib_levelset"); auto nlevels = sim.repo().num_active_levels(); @@ -61,8 +61,8 @@ struct InitDataOp const auto& dx = geom[lev].CellSizeArray(); for (amrex::MFIter mfi(levelset(lev)); mfi.isValid(); ++mfi) { const auto& bx = mfi.growntilebox(); - auto epsilon_node = mask_node(lev).array(mfi); - auto phi = levelset(lev).array(mfi); + const auto& epsilon_node = mask_node(lev).array(mfi); + const auto& phi = levelset(lev).array(mfi); const amrex::Real x0 = wdata.center_loc[0]; const amrex::Real y0 = wdata.center_loc[1]; diff --git a/amr-wind/immersed_boundary/bluff_body/cylinder_ops.H b/amr-wind/immersed_boundary/bluff_body/cylinder_ops.H index 82139ce601..2002f661b6 100644 --- a/amr-wind/immersed_boundary/bluff_body/cylinder_ops.H +++ b/amr-wind/immersed_boundary/bluff_body/cylinder_ops.H @@ -46,9 +46,9 @@ struct InitDataOp const auto& wdata = data.meta(); auto& sim = data.sim(); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& mask_node = sim.repo().get_int_field("mask_node"); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& levelset = sim.repo().get_field("ib_levelset"); auto nlevels = sim.repo().num_active_levels(); @@ -59,7 +59,7 @@ struct InitDataOp const auto& dx = geom[lev].CellSizeArray(); for (amrex::MFIter mfi(levelset(lev)); mfi.isValid(); ++mfi) { - auto phi = levelset(lev).array(mfi); + const auto& phi = levelset(lev).array(mfi); const amrex::Real x0 = wdata.center_loc[0]; const amrex::Real y0 = wdata.center_loc[1]; @@ -69,23 +69,23 @@ struct InitDataOp bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const amrex::Real x = problo[0] + (i + 0.5) * dx[0]; const amrex::Real y = problo[1] + (j + 0.5) * dx[1]; - amrex::Real phi_glob = phi(i, j, k); - amrex::Real r = std::sqrt( + const amrex::Real phi_glob = phi(i, j, k); + const amrex::Real r = std::sqrt( (x - x0) * (x - x0) + (y - y0) * (y - y0)); - amrex::Real phi_loc = r - R; + const amrex::Real phi_loc = r - R; phi(i, j, k) = std::min(phi_loc, phi_glob); }); const auto& nbx = mfi.nodaltilebox(); - auto epsilon_node = mask_node(lev).array(mfi); + const auto& epsilon_node = mask_node(lev).array(mfi); amrex::ParallelFor( nbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const amrex::Real x = problo[0] + i * dx[0]; const amrex::Real y = problo[1] + j * dx[1]; - amrex::Real r = std::sqrt( + const amrex::Real r = std::sqrt( (x - x0) * (x - x0) + (y - y0) * (y - y0)); if (r <= R) { diff --git a/amr-wind/immersed_boundary/bluff_body/sphere_ops.H b/amr-wind/immersed_boundary/bluff_body/sphere_ops.H index 630a5704cd..ec8fc94709 100644 --- a/amr-wind/immersed_boundary/bluff_body/sphere_ops.H +++ b/amr-wind/immersed_boundary/bluff_body/sphere_ops.H @@ -44,9 +44,9 @@ struct InitDataOp const auto& wdata = data.meta(); auto& sim = data.sim(); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& mask_node = sim.repo().get_int_field("mask_node"); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& levelset = sim.repo().get_field("ib_levelset"); auto nlevels = sim.repo().num_active_levels(); @@ -58,7 +58,7 @@ struct InitDataOp for (amrex::MFIter mfi(levelset(lev)); mfi.isValid(); ++mfi) { const auto& bx = mfi.growntilebox(); - auto phi = levelset(lev).array(mfi); + const auto& phi = levelset(lev).array(mfi); const amrex::Real x0 = wdata.center_loc[0]; const amrex::Real y0 = wdata.center_loc[1]; @@ -74,12 +74,12 @@ struct InitDataOp (x - x0) * (x - x0) + (y - y0) * (y - y0) + (z - z0) * (z - z0)); - amrex::Real phi_loc = r - R; + const amrex::Real phi_loc = r - R; phi(i, j, k) = std::min(phi_loc, phi_glob); }); const auto& nbx = mfi.nodaltilebox(); - auto epsilon_node = mask_node(lev).array(mfi); + const auto& epsilon_node = mask_node(lev).array(mfi); amrex::ParallelFor( nbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const amrex::Real x = problo[0] + i * dx[0]; diff --git a/amr-wind/ocean_waves/relaxation_zones/hos_waves_ops.H b/amr-wind/ocean_waves/relaxation_zones/hos_waves_ops.H index 105a12787e..408333129c 100644 --- a/amr-wind/ocean_waves/relaxation_zones/hos_waves_ops.H +++ b/amr-wind/ocean_waves/relaxation_zones/hos_waves_ops.H @@ -118,7 +118,7 @@ void ReadHOSFileLev( } void StoreHOSDataLoop( - HOSWaves::MetaType& wdata, + const HOSWaves::MetaType& wdata, amrex::Array4 const& phi, amrex::Array4 const& vel, const amrex::Real* dev_eta_data, diff --git a/amr-wind/ocean_waves/relaxation_zones/linear_waves_ops.H b/amr-wind/ocean_waves/relaxation_zones/linear_waves_ops.H index adb2eb23ec..eb79ebe0b5 100644 --- a/amr-wind/ocean_waves/relaxation_zones/linear_waves_ops.H +++ b/amr-wind/ocean_waves/relaxation_zones/linear_waves_ops.H @@ -35,16 +35,17 @@ struct InitDataOp auto& sim = data.sim(); + // cppcheck-suppress constVariableReference auto& m_levelset = sim.repo().get_field("levelset"); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& m_velocity = sim.repo().get_field("velocity"); const auto& problo = geom.ProbLoArray(); const auto& dx = geom.CellSizeArray(); for (amrex::MFIter mfi(m_levelset(level)); mfi.isValid(); ++mfi) { - auto phi = m_levelset(level).array(mfi); - auto vel = m_velocity(level).array(mfi); + const auto& phi = m_levelset(level).array(mfi); + const auto& vel = m_velocity(level).array(mfi); const amrex::Real zsl = wdata.zsl; const auto& gbx3 = mfi.growntilebox(3); @@ -108,9 +109,9 @@ struct UpdateRelaxZonesOp auto& sim = data.sim(); const auto& time = sim.time().new_time(); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& m_ow_levelset = sim.repo().get_field("ow_levelset"); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& m_ow_velocity = sim.repo().get_field("ow_velocity"); auto nlevels = sim.repo().num_active_levels(); @@ -121,8 +122,8 @@ struct UpdateRelaxZonesOp const auto& dx = geom[lev].CellSizeArray(); for (amrex::MFIter mfi(m_ow_levelset(lev)); mfi.isValid(); ++mfi) { - auto phi = m_ow_levelset(lev).array(mfi); - auto vel = m_ow_velocity(lev).array(mfi); + const auto& phi = m_ow_levelset(lev).array(mfi); + const auto& vel = m_ow_velocity(lev).array(mfi); const amrex::Real waveheight = wdata.wave_height; const amrex::Real wavelength = wdata.wave_length; diff --git a/amr-wind/ocean_waves/relaxation_zones/stokes_waves_ops.H b/amr-wind/ocean_waves/relaxation_zones/stokes_waves_ops.H index dbe5bea220..3fd83b9e5b 100644 --- a/amr-wind/ocean_waves/relaxation_zones/stokes_waves_ops.H +++ b/amr-wind/ocean_waves/relaxation_zones/stokes_waves_ops.H @@ -36,16 +36,16 @@ struct InitDataOp const auto& wdata = data.meta(); auto& sim = data.sim(); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& m_levelset = sim.repo().get_field("levelset"); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& velocity = sim.repo().get_field("velocity"); const auto& problo = geom.ProbLoArray(); const auto& dx = geom.CellSizeArray(); for (amrex::MFIter mfi(m_levelset(level)); mfi.isValid(); ++mfi) { - auto phi = m_levelset(level).array(mfi); - auto vel = velocity(level).array(mfi); + const auto& phi = m_levelset(level).array(mfi); + const auto& vel = velocity(level).array(mfi); const amrex::Real zsl = wdata.zsl; const auto& gbx3 = mfi.growntilebox(3); @@ -71,9 +71,9 @@ struct UpdateRelaxZonesOp auto& sim = data.sim(); const auto& time = sim.time().new_time(); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& m_ow_levelset = sim.repo().get_field("ow_levelset"); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& m_ow_velocity = sim.repo().get_field("ow_velocity"); auto nlevels = sim.repo().num_active_levels(); @@ -84,8 +84,8 @@ struct UpdateRelaxZonesOp const auto& dx = geom[lev].CellSizeArray(); for (amrex::MFIter mfi(m_ow_levelset(lev)); mfi.isValid(); ++mfi) { - auto phi = m_ow_levelset(lev).array(mfi); - auto vel = m_ow_velocity(lev).array(mfi); + const auto& phi = m_ow_levelset(lev).array(mfi); + const auto& vel = m_ow_velocity(lev).array(mfi); const amrex::Real waveheight = wdata.wave_height; const amrex::Real wavelength = wdata.wave_length; diff --git a/amr-wind/overset/TiogaInterface.cpp b/amr-wind/overset/TiogaInterface.cpp index 486c36d148..59e42d414d 100644 --- a/amr-wind/overset/TiogaInterface.cpp +++ b/amr-wind/overset/TiogaInterface.cpp @@ -103,7 +103,7 @@ void TiogaInterface::post_regrid_actions() void TiogaInterface::pre_overset_conn_work() { - auto& repo = m_sim.repo(); + const auto& repo = m_sim.repo(); const int num_ghost = m_sim.pde_manager().num_ghost_state(); m_iblank_cell_host = repo.create_int_scratch_field_on_host( "iblank_cell_host", 1, num_ghost, FieldLoc::CELL); @@ -122,7 +122,7 @@ void TiogaInterface::pre_overset_conn_work() void TiogaInterface::post_overset_conn_work() { - auto& repo = m_sim.repo(); + const auto& repo = m_sim.repo(); const int nlevels = repo.num_active_levels(); for (int lev = 0; lev < nlevels; ++lev) { htod_memcpy(m_iblank_cell(lev), (*m_iblank_cell_host)(lev), 0, 0, 1); @@ -389,7 +389,7 @@ void TiogaInterface::amr_to_tioga_mesh() void TiogaInterface::amr_to_tioga_iblank() { BL_PROFILE("amr-wind::TiogaInterface::amr_to_tioga_iblank"); - auto& mesh = m_sim.mesh(); + const auto& mesh = m_sim.mesh(); const int nlevels = mesh.finestLevel() + 1; // Reset local patch counter diff --git a/amr-wind/physics/multiphase/MultiPhase.cpp b/amr-wind/physics/multiphase/MultiPhase.cpp index 5dbc09aeb0..1dc99e2a77 100644 --- a/amr-wind/physics/multiphase/MultiPhase.cpp +++ b/amr-wind/physics/multiphase/MultiPhase.cpp @@ -366,11 +366,11 @@ void MultiPhase::calculate_advected_facedensity() amrex::Real c_r2 = m_rho2; // Get advected vof terms at each face - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& advalpha_x = m_sim.repo().get_field("advalpha_x"); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& advalpha_y = m_sim.repo().get_field("advalpha_y"); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& advalpha_z = m_sim.repo().get_field("advalpha_z"); for (int lev = 0; lev < nlevels; ++lev) { @@ -382,9 +382,9 @@ void MultiPhase::calculate_advected_facedensity() const auto& ybx = amrex::surroundingNodes(bx, 1); const auto& zbx = amrex::surroundingNodes(bx, 2); - auto aa_x = advalpha_x(lev).array(mfi); - auto aa_y = advalpha_y(lev).array(mfi); - auto aa_z = advalpha_z(lev).array(mfi); + const auto& aa_x = advalpha_x(lev).array(mfi); + const auto& aa_y = advalpha_y(lev).array(mfi); + const auto& aa_z = advalpha_z(lev).array(mfi); amrex::ParallelFor( bxg1, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { diff --git a/amr-wind/projection/incflo_apply_nodal_projection.cpp b/amr-wind/projection/incflo_apply_nodal_projection.cpp index 586ae26863..b7c1a9c5a2 100644 --- a/amr-wind/projection/incflo_apply_nodal_projection.cpp +++ b/amr-wind/projection/incflo_apply_nodal_projection.cpp @@ -414,7 +414,7 @@ void incflo::ApplyProjection( // Determine if reference pressure should be added back if (m_repo.field_exists("reference_pressure") && time != 0.0) { - auto& p0 = m_repo.get_field("reference_pressure"); + const auto& p0 = m_repo.get_field("reference_pressure"); for (int lev = 0; lev <= finest_level; lev++) { amrex::MultiFab::Add( pressure(lev), p0(lev), 0, 0, 1, pressure.num_grow()[0]); diff --git a/amr-wind/setup/init.cpp b/amr-wind/setup/init.cpp index 1181470147..2482a98baa 100644 --- a/amr-wind/setup/init.cpp +++ b/amr-wind/setup/init.cpp @@ -128,11 +128,12 @@ void incflo::InitialIterations() // Add mean pressure back if available if (m_repo.field_exists("reference_pressure")) { - auto& pressure = m_repo.get_field("p"); - auto& p0 = m_repo.get_field("reference_pressure"); + // cppcheck-suppress constVariableReference + auto& press = m_repo.get_field("p"); + const auto& p0 = m_repo.get_field("reference_pressure"); for (int lev = 0; lev <= finest_level; lev++) { amrex::MultiFab::Add( - pressure(lev), p0(lev), 0, 0, 1, pressure.num_grow()[0]); + press(lev), p0(lev), 0, 0, 1, press.num_grow()[0]); } } amrex::Print() << "Completed initial pressure iterations" << std::endl diff --git a/amr-wind/transport_models/TwoPhaseTransport.H b/amr-wind/transport_models/TwoPhaseTransport.H index 9aed3ea906..52b580fa30 100644 --- a/amr-wind/transport_models/TwoPhaseTransport.H +++ b/amr-wind/transport_models/TwoPhaseTransport.H @@ -65,16 +65,13 @@ public: if (m_ifacetype == InterfaceCapturingMethod::VOF) { - // cppcheck-suppress constVariable - auto& vof = m_repo.get_field("vof"); + const auto& vof = m_repo.get_field("vof"); for (int lev = 0; lev < m_repo.num_active_levels(); ++lev) { for (amrex::MFIter mfi((*mu)(lev)); mfi.isValid(); ++mfi) { const auto& vbx = mfi.growntilebox(); - const amrex::Array4& volfrac = - vof(lev).array(mfi); - const amrex::Array4& visc = - (*mu)(lev).array(mfi); + const auto& volfrac = vof(lev).const_array(mfi); + const auto& visc = (*mu)(lev).array(mfi); const amrex::Real mu1 = m_mu1; const amrex::Real mu2 = m_mu2; amrex::ParallelFor( @@ -88,18 +85,15 @@ public: } else if (m_ifacetype == InterfaceCapturingMethod::LS) { - // cppcheck-suppress constVariable - auto& levelset = m_repo.get_field("levelset"); + const auto& levelset = m_repo.get_field("levelset"); const auto& geom = m_repo.mesh().Geom(); for (int lev = 0; lev < m_repo.num_active_levels(); ++lev) { for (amrex::MFIter mfi((*mu)(lev)); mfi.isValid(); ++mfi) { const auto& vbx = mfi.growntilebox(); const auto& dx = geom[lev].CellSizeArray(); - const amrex::Array4& visc = - (*mu)(lev).array(mfi); - const amrex::Array4& phi = - levelset(lev).array(mfi); + const auto& visc = (*mu)(lev).array(mfi); + const auto& phi = levelset(lev).const_array(mfi); const amrex::Real eps = std::cbrt(2. * dx[0] * dx[1] * dx[2]); const amrex::Real mu1 = m_mu1; diff --git a/amr-wind/turbulence/LES/AMD.cpp b/amr-wind/turbulence/LES/AMD.cpp index 7629252fb6..18f8edd39d 100644 --- a/amr-wind/turbulence/LES/AMD.cpp +++ b/amr-wind/turbulence/LES/AMD.cpp @@ -11,6 +11,7 @@ namespace amr_wind { namespace turbulence { template +// cppcheck-suppress uninitMemberVar AMD::AMD(CFDSim& sim) : TurbModelBase(sim) , m_vel(sim.repo().get_field("velocity")) @@ -46,7 +47,7 @@ void AMD::update_turbulent_viscosity( "amr-wind::" + this->identifier() + "::update_turbulent_viscosity"); auto& mu_turb = this->mu_turb(); - auto& repo = mu_turb.repo(); + const auto& repo = mu_turb.repo(); const auto& vel = m_vel.state(fstate); const auto& temp = m_temperature.state(fstate); const auto& den = m_rho.state(fstate); @@ -227,7 +228,7 @@ void AMD::update_alphaeff(Field& alphaeff) BL_PROFILE("amr-wind::" + this->identifier() + "::update_alphaeff"); - auto& repo = alphaeff.repo(); + const auto& repo = alphaeff.repo(); const auto& geom_vec = repo.mesh().Geom(); const amrex::Real C_poincare = this->m_C; namespace stencil = amr_wind::fvm::stencil; diff --git a/amr-wind/turbulence/LES/AMDNoTherm.cpp b/amr-wind/turbulence/LES/AMDNoTherm.cpp index 1358c16073..310aac57f3 100644 --- a/amr-wind/turbulence/LES/AMDNoTherm.cpp +++ b/amr-wind/turbulence/LES/AMDNoTherm.cpp @@ -13,6 +13,7 @@ namespace amr_wind { namespace turbulence { template +// cppcheck-suppress uninitMemberVar AMDNoTherm::AMDNoTherm(CFDSim& sim) : TurbModelBase(sim) , m_vel(sim.repo().get_field("velocity")) @@ -35,7 +36,7 @@ void AMDNoTherm::update_turbulent_viscosity( "amr-wind::" + this->identifier() + "::update_turbulent_viscosity"); auto& mu_turb = this->mu_turb(); - auto& repo = mu_turb.repo(); + const auto& repo = mu_turb.repo(); const auto& vel = m_vel.state(fstate); const auto& den = m_rho.state(fstate); auto gradVel = repo.create_scratch_field(AMREX_SPACEDIM * AMREX_SPACEDIM); diff --git a/amr-wind/turbulence/LES/OneEqKsgs.cpp b/amr-wind/turbulence/LES/OneEqKsgs.cpp index 4660c5ff34..864f02eb34 100644 --- a/amr-wind/turbulence/LES/OneEqKsgs.cpp +++ b/amr-wind/turbulence/LES/OneEqKsgs.cpp @@ -233,7 +233,7 @@ void OneEqKsgsM84::post_advance_work() // Update sdr field based on sfs ke auto& tke = *(this->m_tke); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& sdr = *(this->m_sdr); const amrex::Real Ce = this->m_Ce; diff --git a/amr-wind/turbulence/RANS/KOmegaSST.cpp b/amr-wind/turbulence/RANS/KOmegaSST.cpp index d54e3208c2..bd107705d0 100644 --- a/amr-wind/turbulence/RANS/KOmegaSST.cpp +++ b/amr-wind/turbulence/RANS/KOmegaSST.cpp @@ -86,11 +86,10 @@ void KOmegaSST::update_turbulent_viscosity( const auto& den = this->m_rho.state(fstate); const auto& tke = (*this->m_tke).state(fstate); const auto& sdr = (*this->m_sdr).state(fstate); - // cppcheck-suppress constVariable - auto& repo = mu_turb.repo(); + const auto& repo = mu_turb.repo(); auto& tke_lhs = (this->m_sim).repo().get_field("tke_lhs_src_term"); tke_lhs.setVal(0.0); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& sdr_lhs = (this->m_sim).repo().get_field("sdr_lhs_src_term"); auto gradK = (this->m_sim.repo()).create_scratch_field(3, 0); diff --git a/amr-wind/turbulence/RANS/KOmegaSSTIDDES.cpp b/amr-wind/turbulence/RANS/KOmegaSSTIDDES.cpp index 9178369c6e..1d3f2cd6e3 100644 --- a/amr-wind/turbulence/RANS/KOmegaSSTIDDES.cpp +++ b/amr-wind/turbulence/RANS/KOmegaSSTIDDES.cpp @@ -19,6 +19,7 @@ template KOmegaSSTIDDES::~KOmegaSSTIDDES() = default; template +// cppcheck-suppress uninitMemberVar KOmegaSSTIDDES::KOmegaSSTIDDES(CFDSim& sim) : KOmegaSST(sim) , m_rans_ind(sim.repo().declare_field("rans_indicator", 1, 1, 1)) @@ -99,12 +100,11 @@ void KOmegaSSTIDDES::update_turbulent_viscosity( const auto& den = this->m_rho.state(fstate); const auto& tke = (*this->m_tke).state(fstate); const auto& sdr = (*this->m_sdr).state(fstate); - // cppcheck-suppress constVariable - auto& repo = mu_turb.repo(); + const auto& repo = mu_turb.repo(); const auto& geom_vec = repo.mesh().Geom(); auto& tke_lhs = (this->m_sim).repo().get_field("tke_lhs_src_term"); tke_lhs.setVal(0.0); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& sdr_lhs = (this->m_sim).repo().get_field("sdr_lhs_src_term"); auto gradK = (this->m_sim.repo()).create_scratch_field(3, 0); diff --git a/amr-wind/utilities/SecondMomentAveraging.cpp b/amr-wind/utilities/SecondMomentAveraging.cpp index 334674d86e..53d6a9ea08 100644 --- a/amr-wind/utilities/SecondMomentAveraging.cpp +++ b/amr-wind/utilities/SecondMomentAveraging.cpp @@ -137,8 +137,8 @@ void SecondMomentAveraging::compute_average( m_plane_average2.line_average().data(), m_plane_average2.line_average().size()); - amrex::Real* line_avg1 = lavg1.data(); - amrex::Real* line_avg2 = lavg2.data(); + const auto* line_avg1 = lavg1.data(); + const auto* line_avg2 = lavg2.data(); amrex::Real denom = 1.0 / (amrex::Real)m_plane_average1.ncell_plane(); diff --git a/amr-wind/utilities/ThirdMomentAveraging.cpp b/amr-wind/utilities/ThirdMomentAveraging.cpp index e31b11d489..e7cc421bb0 100644 --- a/amr-wind/utilities/ThirdMomentAveraging.cpp +++ b/amr-wind/utilities/ThirdMomentAveraging.cpp @@ -158,9 +158,9 @@ void ThirdMomentAveraging::compute_average( m_plane_average3.line_average().data(), m_plane_average3.line_average().size()); - amrex::Real* line_avg1 = lavg1.data(); - amrex::Real* line_avg2 = lavg2.data(); - amrex::Real* line_avg3 = lavg3.data(); + const auto* line_avg1 = lavg1.data(); + const auto* line_avg2 = lavg2.data(); + const auto* line_avg3 = lavg3.data(); amrex::Real denom = 1.0 / (amrex::Real)m_plane_average1.ncell_plane(); diff --git a/amr-wind/utilities/averaging/TimeAveraging.cpp b/amr-wind/utilities/averaging/TimeAveraging.cpp index 55e2e723e1..4c1d35c753 100644 --- a/amr-wind/utilities/averaging/TimeAveraging.cpp +++ b/amr-wind/utilities/averaging/TimeAveraging.cpp @@ -87,7 +87,7 @@ void TimeAveraging::post_advance_work() } const amrex::Real elapsed_time = (cur_time - m_start_time); - for (auto& avg : m_averages) { + for (const auto& avg : m_averages) { (*avg)(time, m_filter, elapsed_time); } } diff --git a/amr-wind/utilities/diagnostics.H b/amr-wind/utilities/diagnostics.H index 91f4b6d1e6..7605db0121 100644 --- a/amr-wind/utilities/diagnostics.H +++ b/amr-wind/utilities/diagnostics.H @@ -22,10 +22,10 @@ amrex::Real get_vel_min( const int vdir); amrex::Real get_vel_loc( - amrex::MultiFab& vel, - amrex::iMultiFab& level_mask, - int vdir, - int ldir, + const amrex::MultiFab& vel, + const amrex::iMultiFab& level_mask, + const int vdir, + const int ldir, amrex::Real vel_max, const amrex::GpuArray problo, const amrex::GpuArray dx); @@ -47,10 +47,10 @@ amrex::Real get_macvel_min( const int vdir); amrex::Real get_macvel_loc( - amrex::MultiFab& macvel, - amrex::iMultiFab& level_mask, - int vdir, - int ldir, + const amrex::MultiFab& macvel, + const amrex::iMultiFab& level_mask, + const int vdir, + const int ldir, amrex::Real vel_max, const amrex::GpuArray problo, const amrex::GpuArray dx); @@ -63,4 +63,4 @@ amrex::Array PrintMaxMACVelLocations( } // namespace amr_wind::diagnostics -#endif \ No newline at end of file +#endif diff --git a/amr-wind/utilities/diagnostics.cpp b/amr-wind/utilities/diagnostics.cpp index 5f2cc159e6..5cc4271602 100644 --- a/amr-wind/utilities/diagnostics.cpp +++ b/amr-wind/utilities/diagnostics.cpp @@ -41,10 +41,10 @@ amrex::Real amr_wind::diagnostics::get_vel_min( } amrex::Real amr_wind::diagnostics::get_vel_loc( - amrex::MultiFab& vel, - amrex::iMultiFab& level_mask, - int vdir, - int ldir, + const amrex::MultiFab& vel, + const amrex::iMultiFab& level_mask, + const int vdir, + const int ldir, amrex::Real vel_max, const amrex::GpuArray problo, const amrex::GpuArray dx) @@ -114,10 +114,10 @@ amrex::Real amr_wind::diagnostics::get_macvel_min( } amrex::Real amr_wind::diagnostics::get_macvel_loc( - amrex::MultiFab& macvel, - amrex::iMultiFab& level_mask, - int vdir, - int ldir, + const amrex::MultiFab& macvel, + const amrex::iMultiFab& level_mask, + const int vdir, + const int ldir, amrex::Real mvel_max, const amrex::GpuArray problo, const amrex::GpuArray dx) @@ -154,7 +154,7 @@ amrex::Array amr_wind::diagnostics::PrintMaxVelLocations( BL_PROFILE("amr-wind::diagnostics::PrintMaxVelLocations"); // Get fields - auto& vel = repo.get_field("velocity"); + const auto& vel = repo.get_field("velocity"); const int finest_level = repo.num_active_levels() - 1; // Get infinity norm of velocities @@ -335,9 +335,9 @@ amrex::Array amr_wind::diagnostics::PrintMaxMACVelLocations( BL_PROFILE("amr-wind::diagnostics::PrintMaxMACVelLocations"); // Get fields - auto& u_mac = repo.get_field("u_mac"); - auto& v_mac = repo.get_field("v_mac"); - auto& w_mac = repo.get_field("w_mac"); + const auto& u_mac = repo.get_field("u_mac"); + const auto& v_mac = repo.get_field("v_mac"); + const auto& w_mac = repo.get_field("w_mac"); const int finest_level = repo.num_active_levels() - 1; // Get infinity norm of mac velocities diff --git a/amr-wind/utilities/sampling/FieldNorms.cpp b/amr-wind/utilities/sampling/FieldNorms.cpp index 8798c28576..bd58dc540d 100644 --- a/amr-wind/utilities/sampling/FieldNorms.cpp +++ b/amr-wind/utilities/sampling/FieldNorms.cpp @@ -23,7 +23,7 @@ void FieldNorms::initialize() pp.query("output_frequency", m_out_freq); } - auto& io_mng = m_sim.io_manager(); + const auto& io_mng = m_sim.io_manager(); for (const auto& fld : io_mng.plot_fields()) { ioutils::add_var_names(m_var_names, fld->name(), fld->num_comp()); } diff --git a/amr-wind/utilities/sampling/Sampling.cpp b/amr-wind/utilities/sampling/Sampling.cpp index 36281e9133..40b745fd8d 100644 --- a/amr-wind/utilities/sampling/Sampling.cpp +++ b/amr-wind/utilities/sampling/Sampling.cpp @@ -52,7 +52,7 @@ void Sampling::initialize() // Load different probe types, default probe type is line int idx = 0; m_total_particles = 0; - for (auto& lbl : labels) { + for (const auto& lbl : labels) { const std::string key = m_label + "." + lbl; amrex::ParmParse pp1(key); std::string stype = "LineSampler"; diff --git a/amr-wind/wind_energy/ABLFieldInit.cpp b/amr-wind/wind_energy/ABLFieldInit.cpp index cd696d9d61..47d82173d8 100644 --- a/amr-wind/wind_energy/ABLFieldInit.cpp +++ b/amr-wind/wind_energy/ABLFieldInit.cpp @@ -160,10 +160,7 @@ void ABLFieldInit::operator()( } void ABLFieldInit::perturb_temperature( - const int lev, - const amrex::Geometry& geom, - // cppcheck-suppress constParameter - Field& temperature) const + const int lev, const amrex::Geometry& geom, Field& temperature) const { /** Perturbations for the temperature field * diff --git a/amr-wind/wind_energy/ABLStats.cpp b/amr-wind/wind_energy/ABLStats.cpp index 3640cf2a89..b75d5bf68f 100644 --- a/amr-wind/wind_energy/ABLStats.cpp +++ b/amr-wind/wind_energy/ABLStats.cpp @@ -102,7 +102,7 @@ void ABLStats::calc_sfs_stress_avgs( BL_PROFILE("amr-wind::ABLStats::calc_sfs_stress_avgs"); - auto& repo = m_sim.repo(); + const auto& repo = m_sim.repo(); const auto& m_vel = repo.get_field("velocity"); auto gradVel = repo.create_scratch_field(9); diff --git a/amr-wind/wind_energy/actuator/disk/Joukowsky_ops.H b/amr-wind/wind_energy/actuator/disk/Joukowsky_ops.H index a3bc010396..81a03c0f19 100644 --- a/amr-wind/wind_energy/actuator/disk/Joukowsky_ops.H +++ b/amr-wind/wind_energy/actuator/disk/Joukowsky_ops.H @@ -328,7 +328,7 @@ struct ProcessOutputsOp { private: // cppcheck-suppress uninitMemberVarPrivate - Joukowsky::DataType& m_data; + const Joukowsky::DataType& m_data; //! Path to the output directory (specified by Actuator physics class) std::string m_out_dir; @@ -340,7 +340,8 @@ private: public: // cppcheck-suppress constParameter - explicit ProcessOutputsOp(Joukowsky::DataType& data) + explicit ProcessOutputsOp( + const Joukowsky::DataType& data) : m_data(data) {} void operator()(Joukowsky::DataType& /*data*/) {} diff --git a/amr-wind/wind_energy/actuator/disk/uniform_ct_ops.H b/amr-wind/wind_energy/actuator/disk/uniform_ct_ops.H index d6616e0718..72ac4d7bdf 100644 --- a/amr-wind/wind_energy/actuator/disk/uniform_ct_ops.H +++ b/amr-wind/wind_energy/actuator/disk/uniform_ct_ops.H @@ -127,7 +127,7 @@ struct ProcessOutputsOp { private: // cppcheck-suppress uninitMemberVarPrivate - UniformCt::DataType& m_data; + const UniformCt::DataType& m_data; //! Path to the output directory (specified by Actuator physics class) std::string m_out_dir; @@ -139,7 +139,8 @@ private: public: // cppcheck-suppress constParameter - explicit ProcessOutputsOp(UniformCt::DataType& data) + explicit ProcessOutputsOp( + const UniformCt::DataType& data) : m_data(data) {} void operator()(UniformCt::DataType& /*unused*/) {} diff --git a/amr-wind/wind_energy/actuator/turbine/fast/FastIface.cpp b/amr-wind/wind_energy/actuator/turbine/fast/FastIface.cpp index 353078b0ca..4c4df585b9 100644 --- a/amr-wind/wind_energy/actuator/turbine/fast/FastIface.cpp +++ b/amr-wind/wind_energy/actuator/turbine/fast/FastIface.cpp @@ -253,7 +253,7 @@ void FastIface::fast_init_turbine(FastTurbine& fi) } } -// cppcheck-suppress constParameter +// cppcheck-suppress constParameterReference // NOLINTNEXTLINE(readability-convert-member-functions-to-static) void FastIface::fast_replay_turbine(FastTurbine& fi) { @@ -301,7 +301,6 @@ void FastIface::fast_replay_turbine(FastTurbine& fi) #endif } -// cppcheck-suppress constParameter // NOLINTNEXTLINE(readability-convert-member-functions-to-static) void FastIface::fast_restart_turbine(FastTurbine& fi) { diff --git a/unit_tests/aw_test_utils/MeshTest.cpp b/unit_tests/aw_test_utils/MeshTest.cpp index be13909f79..66555afdae 100644 --- a/unit_tests/aw_test_utils/MeshTest.cpp +++ b/unit_tests/aw_test_utils/MeshTest.cpp @@ -34,7 +34,7 @@ void MeshTest::reset_prob_domain() pp.getarr("is_periodic", periodic, 0, AMREX_SPACEDIM); amrex::RealBox rb(problo.data(), probhi.data()); - amrex::Geometry* gg = amrex::AMReX::top()->getDefaultGeometry(); + const amrex::Geometry* gg = amrex::AMReX::top()->getDefaultGeometry(); if (gg != nullptr) { amrex::Geometry::ResetDefaultProbDomain(rb); diff --git a/unit_tests/core/test_field.cpp b/unit_tests/core/test_field.cpp index 2eef72185c..7beaf67f2d 100644 --- a/unit_tests/core/test_field.cpp +++ b/unit_tests/core/test_field.cpp @@ -318,7 +318,7 @@ TEST_F(FieldRepoTest, int_scratch_fields) populate_parameters(); create_mesh_instance(); - auto& frepo = mesh().field_repo(); + const auto& frepo = mesh().field_repo(); // Check that int scratch field creation is disallowed before mesh is created #if !(defined(AMREX_USE_MPI) && defined(__APPLE__)) EXPECT_THROW( @@ -326,10 +326,8 @@ TEST_F(FieldRepoTest, int_scratch_fields) #endif initialize_mesh(); - // cppcheck-suppress constVariable auto ibcell_host = frepo.create_int_scratch_field_on_host( "iblank_cell_host", 1, 0, amr_wind::FieldLoc::CELL); - // cppcheck-suppress constVariable auto ibnode_host = frepo.create_int_scratch_field_on_host( "iblank_node_host", 1, 0, amr_wind::FieldLoc::NODE); @@ -351,9 +349,9 @@ TEST_F(FieldRepoTest, int_fields) initialize_mesh(); auto& frepo = mesh().field_repo(); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& ibcell = frepo.declare_int_field("iblank_cell", 1, 0, 1); - // cppcheck-suppress constVariable + // cppcheck-suppress constVariableReference auto& ibnode = frepo.declare_int_field( "iblank_node", 1, 0, 1, amr_wind::FieldLoc::NODE); diff --git a/unit_tests/multiphase/test_momflux.cpp b/unit_tests/multiphase/test_momflux.cpp index a098a1a2d0..5c1f3320a4 100644 --- a/unit_tests/multiphase/test_momflux.cpp +++ b/unit_tests/multiphase/test_momflux.cpp @@ -204,7 +204,7 @@ class MassMomFluxOpTest : public MeshTest const auto& advrho_f = repo.get_field("advalpha_" + sdir); // Get convective term - auto& conv_term = + const auto& conv_term = mom_eqn.fields().conv_term.state(amr_wind::FieldState::New); // Base level @@ -214,12 +214,12 @@ class MassMomFluxOpTest : public MeshTest const auto& problo = geom[lev].ProbLoArray(); for (amrex::MFIter mfi(vof(lev)); mfi.isValid(); ++mfi) { - const auto& um = umac(lev).array(mfi); - const auto& vm = vmac(lev).array(mfi); - const auto& wm = wmac(lev).array(mfi); - const auto& rf = advrho_f(lev).array(mfi); - const auto& vel = velocity(lev).array(mfi); - const auto& dqdt = conv_term(lev).array(mfi); + const auto& um = umac(lev).const_array(mfi); + const auto& vm = vmac(lev).const_array(mfi); + const auto& wm = wmac(lev).const_array(mfi); + const auto& rf = advrho_f(lev).const_array(mfi); + const auto& vel = velocity(lev).const_array(mfi); + const auto& dqdt = conv_term(lev).const_array(mfi); // Small mesh, loop in serial for check for (int i = 0; i < 2; ++i) { diff --git a/unit_tests/turbulence/test_turbulence_LES.cpp b/unit_tests/turbulence/test_turbulence_LES.cpp index 03d028665b..ef1cee932f 100644 --- a/unit_tests/turbulence/test_turbulence_LES.cpp +++ b/unit_tests/turbulence/test_turbulence_LES.cpp @@ -209,7 +209,7 @@ TEST_F(TurbLESTest, test_smag_setup_calc) // Update turbulent viscosity directly tmodel.update_turbulent_viscosity( amr_wind::FieldState::New, DiffusionType::Crank_Nicolson); - auto& muturb = sim().repo().get_field("mu_turb"); + const auto& muturb = sim().repo().get_field("mu_turb"); // Check values of turbulent viscosity auto min_val = utils::field_min(muturb); @@ -321,7 +321,7 @@ TEST_F(TurbLESTest, test_1eqKsgs_setup_calc) // Update turbulent viscosity directly tmodel.update_turbulent_viscosity( amr_wind::FieldState::New, DiffusionType::Crank_Nicolson); - auto& muturb = sim().repo().get_field("mu_turb"); + const auto& muturb = sim().repo().get_field("mu_turb"); // Check values of turbulent viscosity const auto min_val = utils::field_min(muturb); @@ -408,7 +408,7 @@ TEST_F(TurbLESTest, test_AMD_setup_calc) // Update turbulent viscosity directly tmodel.update_turbulent_viscosity( amr_wind::FieldState::New, DiffusionType::Crank_Nicolson); - auto& muturb = sim().repo().get_field("mu_turb"); + const auto& muturb = sim().repo().get_field("mu_turb"); // Check values of turbulent viscosity const auto min_val = utils::field_min(muturb); @@ -487,7 +487,7 @@ TEST_F(TurbLESTest, test_AMDNoTherm_setup_calc) // Update turbulent viscosity directly tmodel.update_turbulent_viscosity( amr_wind::FieldState::New, DiffusionType::Crank_Nicolson); - auto& muturb = sim().repo().get_field("mu_turb"); + const auto& muturb = sim().repo().get_field("mu_turb"); // Check values of turbulent viscosity const auto min_val = utils::field_min(muturb); diff --git a/unit_tests/utilities/test_free_surface.cpp b/unit_tests/utilities/test_free_surface.cpp index d85c560414..aef9912540 100644 --- a/unit_tests/utilities/test_free_surface.cpp +++ b/unit_tests/utilities/test_free_surface.cpp @@ -137,10 +137,7 @@ void init_vof_slope( class FSRefineMesh : public AmrTestMesh { public: - FSRefineMesh() - : m_sim(*this) - , m_repo(m_sim.repo()) - , m_mesh_refiner(new amr_wind::RefineCriteriaManager(m_sim)) + FSRefineMesh() : m_mesh_refiner(new amr_wind::RefineCriteriaManager(m_sim)) {} amr_wind::FieldRepo& field_repo() { return m_repo; } amr_wind::CFDSim& sim() { return m_sim; } @@ -193,8 +190,6 @@ class FSRefineMesh : public AmrTestMesh } private: - amr_wind::CFDSim m_sim; - amr_wind::FieldRepo& m_repo; std::unique_ptr m_mesh_refiner; }; diff --git a/unit_tests/wind_energy/actuator/test_actuator_joukowsky_disk.cpp b/unit_tests/wind_energy/actuator/test_actuator_joukowsky_disk.cpp index 23f9f064e0..d12293c861 100644 --- a/unit_tests/wind_energy/actuator/test_actuator_joukowsky_disk.cpp +++ b/unit_tests/wind_energy/actuator/test_actuator_joukowsky_disk.cpp @@ -163,7 +163,7 @@ struct ProcessOutputsOp<::amr_wind_tests::Joukowsky, ActSrcDisk> { ProcessOutputsOp<::amr_wind_tests::Joukowsky, ActSrcDisk>( ::amr_wind_tests::Joukowsky::DataType& /**/) - {} // cppcheck-suppress missingReturn + {} void operator()(::amr_wind_tests::Joukowsky::DataType& /*data*/) {} void read_io_options(const utils::ActParser& /**/) {} void prepare_outputs(const std::string& /**/) {} @@ -205,4 +205,4 @@ TEST_F(ActJoukowskyTest, execution) act.pre_init_actions(); act.post_init_actions(); } -} // namespace amr_wind_tests \ No newline at end of file +} // namespace amr_wind_tests diff --git a/unit_tests/wind_energy/actuator/test_disk_functions.cpp b/unit_tests/wind_energy/actuator/test_disk_functions.cpp index cd75fcbfa3..dca60c2dd4 100644 --- a/unit_tests/wind_energy/actuator/test_disk_functions.cpp +++ b/unit_tests/wind_energy/actuator/test_disk_functions.cpp @@ -39,7 +39,6 @@ class TestAreaComputer : public ::testing::TestWithParam amrex::Real area; }; -// cppcheck-suppress uninitDerivedMemberVar TEST_P(TestAreaComputer, area_matches) { const auto params = GetParam(); @@ -53,7 +52,6 @@ TEST_P(TestAreaComputer, area_matches) EXPECT_NEAR(area, area_computed, 1.e-12 * area); } -// cppcheck-suppress uninitDerivedMemberVar TEST_P(TestAreaComputer, weight_sums_to_one) { const auto params = GetParam(); diff --git a/unit_tests/wind_energy/test_abl_bc.cpp b/unit_tests/wind_energy/test_abl_bc.cpp index 811d1a4c8a..a702065612 100644 --- a/unit_tests/wind_energy/test_abl_bc.cpp +++ b/unit_tests/wind_energy/test_abl_bc.cpp @@ -143,7 +143,7 @@ TEST_F(ABLMeshTest, abl_wall_model) icns_eq.compute_mueff(amr_wind::FieldState::Old); // Check test setup by verifying mu - auto& viscosity = sim().repo().get_field("velocity_mueff"); + const auto& viscosity = sim().repo().get_field("velocity_mueff"); EXPECT_NEAR(mu, utils::field_max(viscosity), tol); EXPECT_NEAR(mu, utils::field_min(viscosity), tol); diff --git a/unit_tests/wind_energy/test_abl_src.cpp b/unit_tests/wind_energy/test_abl_src.cpp index 9a4a4377b4..ba4ccbaec6 100644 --- a/unit_tests/wind_energy/test_abl_src.cpp +++ b/unit_tests/wind_energy/test_abl_src.cpp @@ -364,7 +364,7 @@ TEST_F(ABLMeshTest, coriolis_const_vel) // Velocity in x-direction test { - amrex::Real golds[AMREX_SPACEDIM] = { + const amrex::Real golds[AMREX_SPACEDIM] = { 0.0, -corfac * latfac * vel_comp, corfac * latfac * vel_comp}; vel.setVal(0.0); src_term.setVal(0.0); @@ -388,7 +388,7 @@ TEST_F(ABLMeshTest, coriolis_const_vel) // Velocity in y-direction test { - amrex::Real golds[AMREX_SPACEDIM] = { + const amrex::Real golds[AMREX_SPACEDIM] = { corfac * latfac * vel_comp, 0.0, 0.0}; vel.setVal(0.0); src_term.setVal(0.0);