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

Fix some warnings #883

Merged
merged 13 commits into from
Jul 20, 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
13 changes: 7 additions & 6 deletions amr-wind/CFDSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -45,7 +46,7 @@ void CFDSim::init_physics()
amrex::Vector<std::string> phys_names;
pp.queryarr("physics", phys_names);

for (auto& phy : phys_names) {
for (const auto& phy : phys_names) {
m_physics_mgr.create(phy, *this);
}
}
Expand Down
2 changes: 2 additions & 0 deletions amr-wind/boundary_conditions/BCInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ std::pair<const std::string, const std::string> BCIface::get_dirichlet_udfs()
"faces");
} else {
inflow_udf = val;
has_inflow_udf = true;
}
}
}
Expand All @@ -146,6 +147,7 @@ std::pair<const std::string, const std::string> BCIface::get_dirichlet_udfs()
"faces");
} else {
wall_udf = val;
has_wall_udf = true;
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions amr-wind/core/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -296,8 +296,9 @@ 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);
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());
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/AdvOp_Godunov.H
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/AdvOp_MOL.H
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions amr-wind/equation_systems/icns/icns_advection.H
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ struct AdvectionOp<ICNS, fvm::Godunov>

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);

Expand Down Expand Up @@ -550,8 +550,7 @@ struct AdvectionOp<ICNS, fvm::MOL>
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
Expand Down Expand Up @@ -579,7 +578,7 @@ struct AdvectionOp<ICNS, fvm::MOL>

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);
Expand Down
3 changes: 1 addition & 2 deletions amr-wind/equation_systems/icns/icns_diffusion.H
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<amrex::Real> theta_ht, theta_vals;
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/tke/source_terms/KsgsM84Src.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions amr-wind/equation_systems/tke/tke_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct PostSolveOp<TKE>

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();
Expand Down
18 changes: 9 additions & 9 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,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<ctv::ConvectingTaylorVortex>();
Expand All @@ -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];
Expand All @@ -77,7 +77,7 @@ 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 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());
Expand All @@ -94,13 +94,13 @@ void apply_dirichlet_vel(CFDSim& sim, const amrex::Vector<amrex::Real>& 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 {
Expand Down
8 changes: 4 additions & 4 deletions amr-wind/immersed_boundary/bluff_body/box_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ struct InitDataOp<Box>
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();
Expand All @@ -61,8 +61,8 @@ struct InitDataOp<Box>
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];
Expand Down
16 changes: 8 additions & 8 deletions amr-wind/immersed_boundary/bluff_body/cylinder_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ struct InitDataOp<Cylinder>
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();
Expand All @@ -59,7 +59,7 @@ struct InitDataOp<Cylinder>
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];
Expand All @@ -69,23 +69,23 @@ struct InitDataOp<Cylinder>
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) {
Expand Down
10 changes: 5 additions & 5 deletions amr-wind/immersed_boundary/bluff_body/sphere_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ struct InitDataOp<Sphere>
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();
Expand All @@ -58,7 +58,7 @@ struct InitDataOp<Sphere>

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];
Expand All @@ -74,12 +74,12 @@ struct InitDataOp<Sphere>
(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];
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/ocean_waves/relaxation_zones/hos_waves_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void ReadHOSFileLev(
}

void StoreHOSDataLoop(
HOSWaves::MetaType& wdata,
const HOSWaves::MetaType& wdata,
amrex::Array4<amrex::Real> const& phi,
amrex::Array4<amrex::Real> const& vel,
const amrex::Real* dev_eta_data,
Expand Down
15 changes: 8 additions & 7 deletions amr-wind/ocean_waves/relaxation_zones/linear_waves_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,17 @@ struct InitDataOp<LinearWaves>

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);
Expand Down Expand Up @@ -108,9 +109,9 @@ struct UpdateRelaxZonesOp<LinearWaves>
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();
Expand All @@ -121,8 +122,8 @@ struct UpdateRelaxZonesOp<LinearWaves>
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;
Expand Down
Loading
Loading