Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cppcheck fixes #908

Merged
merged 3 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions amr-wind/core/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ void Field::advance_states() noexcept
for (int i = num_time_states() - 1; i > 0; --i) {
const auto sold = static_cast<FieldState>(i);
const auto snew = static_cast<FieldState>(i - 1);
// cppcheck-suppress constVariableReference
auto& old_field = state(sold);
const auto& new_field = state(snew);
for (int lev = 0; lev < m_repo.num_active_levels(); ++lev) {
Expand All @@ -309,7 +308,6 @@ 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);

Expand Down
3 changes: 2 additions & 1 deletion amr-wind/equation_systems/PDEOps.H
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ struct SrcTermOpBase
}

//! Update source terms during time-integration procedure
void operator()(const FieldState fstate, const bool /* mesh_mapping */)
virtual void
operator()(const FieldState fstate, const bool /* mesh_mapping */)
{
// Zero out source term
this->fields.src_term.setVal(0.0);
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/icns/icns_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct SrcTermOp<ICNS> : SrcTermOpBase<ICNS>
: SrcTermOpBase<ICNS>(fields_in), grad_p(fields_in.repo.get_field("gp"))
{}

void operator()(const FieldState fstate, const bool mesh_mapping)
void operator()(const FieldState fstate, const bool mesh_mapping) override
{
const auto rhostate = field_impl::phi_state(fstate);
const auto& density = m_density.state(rhostate);
Expand Down
2 changes: 0 additions & 2 deletions amr-wind/immersed_boundary/bluff_body/bluff_body_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ 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 constVariableReference
auto& velocity = sim.repo().get_field("velocity");
auto& m_conv_taylor_green =
sim.physics_manager().get<ctv::ConvectingTaylorVortex>();
Expand Down Expand Up @@ -77,7 +76,6 @@ void apply_dirichlet_vel(CFDSim& sim, const amrex::Vector<amrex::Real>& vel_bc)
{
const int nlevels = sim.repo().num_active_levels();
auto& geom = sim.mesh().Geom();
// cppcheck-suppress constVariableReference
auto& velocity = sim.repo().get_field("velocity");
auto& levelset = sim.repo().get_field("ib_levelset");
levelset.fillpatch(sim.time().current_time());
Expand Down
2 changes: 2 additions & 0 deletions amr-wind/physics/SyntheticTurbulence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class LinearShearProfile : public MeanProfile

~LinearShearProfile() override = default;

// cppcheck-suppress duplInheritedMember
LinearShearOp device_instance() const { return m_op; }

private:
Expand Down Expand Up @@ -87,6 +88,7 @@ class PowerLawProfile : public MeanProfile

~PowerLawProfile() override = default;

// cppcheck-suppress duplInheritedMember
PowerLawOp device_instance() const { return m_op; }

private:
Expand Down
3 changes: 0 additions & 3 deletions amr-wind/physics/multiphase/MultiPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,8 @@ void MultiPhase::calculate_advected_facedensity()
amrex::Real c_r2 = m_rho2;

// Get advected vof terms at each face
// cppcheck-suppress constVariableReference
auto& advalpha_x = m_sim.repo().get_field("advalpha_x");
// cppcheck-suppress constVariableReference
auto& advalpha_y = m_sim.repo().get_field("advalpha_y");
// cppcheck-suppress constVariableReference
auto& advalpha_z = m_sim.repo().get_field("advalpha_z");

for (int lev = 0; lev < nlevels; ++lev) {
Expand Down
1 change: 0 additions & 1 deletion amr-wind/setup/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ void incflo::InitialIterations()

// Add mean pressure back if available
if (m_repo.field_exists("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++) {
Expand Down
1 change: 0 additions & 1 deletion amr-wind/turbulence/LES/OneEqKsgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ void OneEqKsgsM84<Transport>::post_advance_work()
// Update sdr field based on sfs ke

auto& tke = *(this->m_tke);
// cppcheck-suppress constVariableReference
auto& sdr = *(this->m_sdr);
const amrex::Real Ce = this->m_Ce;

Expand Down
1 change: 0 additions & 1 deletion amr-wind/turbulence/RANS/KOmegaSST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ void KOmegaSST<Transport>::update_turbulent_viscosity(
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 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);
Expand Down
1 change: 1 addition & 0 deletions amr-wind/turbulence/RANS/KOmegaSSTIDDES.H
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ template <typename Transport>
class KOmegaSSTIDDES : public KOmegaSST<Transport>
{
public:
// cppcheck-suppress duplInheritedMember
static std::string identifier()
{
return "KOmegaSSTIDDES-" + Transport::identifier();
Expand Down
1 change: 0 additions & 1 deletion amr-wind/turbulence/RANS/KOmegaSSTIDDES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ void KOmegaSSTIDDES<Transport>::update_turbulent_viscosity(
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 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);
Expand Down
4 changes: 2 additions & 2 deletions amr-wind/utilities/FieldPlaneAveraging.H
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public:

~FPlaneAveraging() = default;

void operator()();
virtual void operator()();

/** evaluate line average at specific location for any average component */
amrex::Real line_average_interpolated(amrex::Real x, int comp) const;
Expand Down Expand Up @@ -139,7 +139,7 @@ public:

~VelPlaneAveraging() = default;

void operator()();
void operator()() override;

private:
amrex::Vector<amrex::Real>
Expand Down
4 changes: 2 additions & 2 deletions amr-wind/utilities/FieldPlaneAveragingFine.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public:

~FPlaneAveragingFine() = default;

void operator()();
virtual void operator()();

void convert_x_to_ind(amrex::Real x, int& ind, amrex::Real& c) const;

Expand Down Expand Up @@ -118,7 +118,7 @@ public:

~VelPlaneAveragingFine() = default;

void operator()();
void operator()() override;

private:
amrex::Vector<amrex::Real>
Expand Down
1 change: 1 addition & 0 deletions amr-wind/utilities/sampling/DTUSpinnerSampler.H
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace amr_wind::sampling {
class DTUSpinnerSampler : public LidarSampler
{
public:
// cppcheck-suppress duplInheritedMember
static std::string identifier() { return "DTUSpinnerSampler"; }

explicit DTUSpinnerSampler(const CFDSim& /*sim*/);
Expand Down
1 change: 1 addition & 0 deletions amr-wind/utilities/sampling/LidarSampler.H
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace amr_wind::sampling {
class LidarSampler : public LineSampler
{
public:
// cppcheck-suppress duplInheritedMember
static std::string identifier() { return "LidarSampler"; }

explicit LidarSampler(const CFDSim& /*sim*/);
Expand Down
3 changes: 2 additions & 1 deletion tools/utilities/refine-chkpt/RefineCheckpt.H
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public:
virtual ~RefineCheckpt() = default;

virtual void
ErrorEst(int lev, amrex::TagBoxArray& tags, amrex::Real time, int ngrow);
ErrorEst(int lev, amrex::TagBoxArray& tags, amrex::Real time, int ngrow)
override;

void read_chkpt_file();

Expand Down
2 changes: 0 additions & 2 deletions unit_tests/core/test_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,7 @@ TEST_F(FieldRepoTest, int_fields)
initialize_mesh();

auto& frepo = mesh().field_repo();
// cppcheck-suppress constVariableReference
auto& ibcell = frepo.declare_int_field("iblank_cell", 1, 0, 1);
// cppcheck-suppress constVariableReference
auto& ibnode = frepo.declare_int_field(
"iblank_node", 1, 0, 1, amr_wind::FieldLoc::NODE);

Expand Down
2 changes: 0 additions & 2 deletions unit_tests/utilities/test_free_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ class FSRefineMesh : public AmrTestMesh
public:
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; }
void init_refiner() { m_mesh_refiner->initialize(); }
void remesh() { regrid(0, 0.0); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace vs = amr_wind::vs;

struct Joukowsky : public act::Joukowsky
{
// cppcheck-suppress duplInheritedMember
static std::string identifier() { return "TestJoukowsky"; }
};

Expand Down
Loading