Skip to content

Commit

Permalink
fix clang-tidy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lucafedeli88 committed Sep 17, 2024
1 parent b43adaa commit fe87f93
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 57 deletions.
4 changes: 2 additions & 2 deletions Source/BoundaryConditions/PML_RZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ PML_RZ::FillBoundaryE (ablastr::fields::MultiFabRegister& fields, PatchType patc
if (patch_type == PatchType::fine && pml_Er->nGrowVect().max() > 0)
{
amrex::Periodicity const& period = m_geom->periodicity();
amrex::Vector<amrex::MultiFab*> mf = {pml_Er, pml_Et};
const amrex::Vector<amrex::MultiFab*> mf = {pml_Er, pml_Et};
ablastr::utils::communication::FillBoundary(mf, WarpX::do_single_precision_comms, period, nodal_sync);
}
}
Expand All @@ -152,7 +152,7 @@ PML_RZ::FillBoundaryB (ablastr::fields::MultiFabRegister& fields, PatchType patc
amrex::MultiFab * pml_Bt = fields.get("pml_B_fp", Direction{1}, 0);

amrex::Periodicity const& period = m_geom->periodicity();
amrex::Vector<amrex::MultiFab*> mf = {pml_Br, pml_Bt};
const amrex::Vector<amrex::MultiFab*> mf = {pml_Br, pml_Bt};
ablastr::utils::communication::FillBoundary(mf, WarpX::do_single_precision_comms, period, nodal_sync);
}
}
Expand Down
8 changes: 4 additions & 4 deletions Source/Evolve/WarpXEvolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ WarpX::OneStep_multiJ (const amrex::Real cur_time)
// (after checking that pointer to rho_fp on MR level 0 is not null)
if (m_fields.has("rho_fp", 0) && rho_in_time == RhoInTime::Linear)
{
ablastr::fields::MultiLevelScalarField rho_fp = m_fields.get_mr_levels("rho_fp", finest_level);
ablastr::fields::MultiLevelScalarField rho_cp = m_fields.get_mr_levels("rho_fp", finest_level);
const ablastr::fields::MultiLevelScalarField rho_fp = m_fields.get_mr_levels("rho_fp", finest_level);
const ablastr::fields::MultiLevelScalarField rho_cp = m_fields.get_mr_levels("rho_fp", finest_level);

// Deposit rho at relative time -dt
// (dt[0] denotes the time step on mesh refinement level 0)
Expand Down Expand Up @@ -732,8 +732,8 @@ WarpX::OneStep_multiJ (const amrex::Real cur_time)
// (after checking that pointer to rho_fp on MR level 0 is not null)
if (m_fields.has("rho_fp", 0))
{
ablastr::fields::MultiLevelScalarField rho_fp = m_fields.get_mr_levels("rho_fp", finest_level);
ablastr::fields::MultiLevelScalarField rho_cp = m_fields.get_mr_levels("rho_cp", finest_level);
const ablastr::fields::MultiLevelScalarField rho_fp = m_fields.get_mr_levels("rho_fp", finest_level);
const ablastr::fields::MultiLevelScalarField rho_cp = m_fields.get_mr_levels("rho_cp", finest_level);

// Move rho from new to old if rho is linear in time
if (rho_in_time == RhoInTime::Linear) { PSATDMoveRhoNewToRhoOld(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ void LabFrameExplicitES::ComputeSpaceChargeField (
using ablastr::fields::MultiLevelScalarField;
using ablastr::fields::MultiLevelVectorField;

MultiLevelScalarField rho_fp = fields.get_mr_levels("rho_fp", max_level);
MultiLevelScalarField rho_cp = fields.get_mr_levels("rho_cp", max_level);
const MultiLevelScalarField rho_fp = fields.get_mr_levels("rho_fp", max_level);
const MultiLevelScalarField rho_cp = fields.get_mr_levels("rho_cp", max_level);
MultiLevelScalarField phi_fp = fields.get_mr_levels("phi_fp", max_level);
MultiLevelVectorField Efield_fp = fields.get_mr_levels_alldirs("Efield_fp", max_level);
const MultiLevelVectorField Efield_fp = fields.get_mr_levels_alldirs("Efield_fp", max_level);

mpc.DepositCharge(rho_fp, 0.0_rt);
if (mfl) {
Expand All @@ -41,7 +41,7 @@ void LabFrameExplicitES::ComputeSpaceChargeField (
}

// Apply filter, perform MPI exchange, interpolate across levels
Vector<std::unique_ptr<MultiFab> > rho_buf(num_levels);
const Vector<std::unique_ptr<MultiFab> > rho_buf(num_levels);
auto & warpx = WarpX::GetInstance();
warpx.SyncRho( rho_fp, rho_cp, amrex::GetVecOfPtrs(rho_buf) );

Expand Down
4 changes: 2 additions & 2 deletions Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ void FiniteDifferenceSolver::EvolveB (
[[maybe_unused]] amrex::Real const dt ) {

using ablastr::fields::Direction;
ablastr::fields::VectorField Bfield = patch_type == PatchType::fine ?
const ablastr::fields::VectorField Bfield = patch_type == PatchType::fine ?
fields.get_alldirs("Bfield_fp", lev) : fields.get_alldirs("Bfield_cp", lev);
ablastr::fields::VectorField Efield = patch_type == PatchType::fine ?
const ablastr::fields::VectorField Efield = patch_type == PatchType::fine ?
fields.get_alldirs("Efield_fp", lev) : fields.get_alldirs("Efield_cp", lev);

// Select algorithm (The choice of algorithm is a runtime option,
Expand Down
4 changes: 2 additions & 2 deletions Source/FieldSolver/FiniteDifferenceSolver/EvolveBPML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ void FiniteDifferenceSolver::EvolveBPML (
WARPX_ABORT_WITH_MESSAGE(
"PML are not implemented in cylindrical geometry.");
#else
ablastr::fields::VectorField Bfield = (patch_type == PatchType::fine) ?
const ablastr::fields::VectorField Bfield = (patch_type == PatchType::fine) ?
fields.get_alldirs("pml_B_fp", level) : fields.get_alldirs("pml_B_cp", level);
ablastr::fields::VectorField Efield = (patch_type == PatchType::fine) ?
const ablastr::fields::VectorField Efield = (patch_type == PatchType::fine) ?
fields.get_alldirs("pml_E_fp", level) : fields.get_alldirs("pml_E_cp", level);

if (m_grid_type == ablastr::utils::enums::GridType::Collocated) {
Expand Down
20 changes: 8 additions & 12 deletions Source/FieldSolver/FiniteDifferenceSolver/EvolveE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ void FiniteDifferenceSolver::EvolveE (
)
{
using ablastr::fields::Direction;
ablastr::fields::VectorField Bfield = patch_type == PatchType::fine ?
const ablastr::fields::VectorField Bfield = patch_type == PatchType::fine ?
fields.get_alldirs("Bfield_fp", lev) : fields.get_alldirs("Bfield_cp", lev);
ablastr::fields::VectorField Jfield = patch_type == PatchType::fine ?
const ablastr::fields::VectorField Jfield = patch_type == PatchType::fine ?
fields.get_alldirs("current_fp", lev) : fields.get_alldirs("current_cp", lev);

amrex::MultiFab* Ffield = nullptr;
Expand All @@ -71,23 +71,19 @@ void FiniteDifferenceSolver::EvolveE (

ablastr::fields::VectorField edge_lengths;
if (fields.has("edge_lengths", Direction{0}, lev)) {
edge_lengths = patch_type == PatchType::fine ?
fields.get_alldirs("edge_lengths", lev) : fields.get_alldirs("edge_lengths", lev);
edge_lengths = fields.get_alldirs("edge_lengths", lev);
}
ablastr::fields::VectorField face_areas;
if (fields.has("face_areas", Direction{0}, lev)) {
face_areas = patch_type == PatchType::fine ?
fields.get_alldirs("face_areas", lev) : fields.get_alldirs("face_areas", lev);
face_areas = fields.get_alldirs("face_areas", lev);
}
ablastr::fields::VectorField area_mod;
if (fields.has("face_areas", Direction{0}, lev)) {
area_mod = patch_type == PatchType::fine ?
fields.get_alldirs("area_mod", lev) : fields.get_alldirs("area_mod", lev);
if (fields.has("area_mod", Direction{0}, lev)) {
area_mod = fields.get_alldirs("area_mod", lev);
}
ablastr::fields::VectorField ECTRhofield;
if (fields.has("ECTRhofield", Direction{0}, lev)) {
ECTRhofield = patch_type == PatchType::fine ?
fields.get_alldirs("ECTRhofield", lev) : fields.get_alldirs("ECTRhofield", lev);
ECTRhofield = fields.get_alldirs("ECTRhofield", lev);
}

// Select algorithm (The choice of algorithm is a runtime option,
Expand Down Expand Up @@ -221,7 +217,7 @@ void FiniteDifferenceSolver::EvolveECartesian (
if (Ffield) {

// Extract field data for this grid/tile
Array4<Real const> F = Ffield->array(mfi);
const Array4<Real const> F = Ffield->array(mfi);

// Loop over the cells and update the fields
amrex::ParallelFor(tex, tey, tez,
Expand Down
6 changes: 3 additions & 3 deletions Source/FieldSolver/FiniteDifferenceSolver/EvolveEPML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ void FiniteDifferenceSolver::EvolveEPML (
"PML are not implemented in cylindrical geometry.");
#else
using ablastr::fields::Direction;
ablastr::fields::VectorField Efield = (patch_type == PatchType::fine) ?
const ablastr::fields::VectorField Efield = (patch_type == PatchType::fine) ?
fields.get_alldirs("pml_E_fp", level) : fields.get_alldirs("pml_E_cp", level);
ablastr::fields::VectorField Bfield = (patch_type == PatchType::fine) ?
const ablastr::fields::VectorField Bfield = (patch_type == PatchType::fine) ?
fields.get_alldirs("pml_B_fp", level) : fields.get_alldirs("pml_B_cp", level);
ablastr::fields::VectorField Jfield = (patch_type == PatchType::fine) ?
const ablastr::fields::VectorField Jfield = (patch_type == PatchType::fine) ?
fields.get_alldirs("pml_j_fp", level) : fields.get_alldirs("pml_j_cp", level);
ablastr::fields::VectorField edge_lengths;
if (fields.has("pml_edge_lengths", Direction{0}, level)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class FiniteDifferenceSolver
void EvolveFCylindrical (
amrex::MultiFab* Ffield,
ablastr::fields::VectorField const & Efield,
amrex::MultiFab* const rhofield,
amrex::MultiFab* rhofield,
int rhocomp,
amrex::Real dt );

Expand Down Expand Up @@ -322,7 +322,7 @@ class FiniteDifferenceSolver
template< typename T_Algo >
void EvolveBPMLCartesian (
std::array< amrex::MultiFab*, 3 > Bfield,
ablastr::fields::VectorField const Efield,
ablastr::fields::VectorField Efield,
amrex::Real dt,
bool dive_cleaning);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ void HybridPICModel::HybridPICSolveE (
auto& warpx = WarpX::GetInstance();

ablastr::fields::VectorField current_fp_ampere = warpx.m_fields.get_alldirs("hybrid_current_fp_ampere", lev);
ablastr::fields::VectorField current_fp_external = warpx.m_fields.get_alldirs("hybrid_current_fp_external", lev);
ablastr::fields::ScalarField electron_pressure_fp = warpx.m_fields.get("hybrid_electron_pressure_fp", lev);
const ablastr::fields::VectorField current_fp_external = warpx.m_fields.get_alldirs("hybrid_current_fp_external", lev);
const ablastr::fields::ScalarField electron_pressure_fp = warpx.m_fields.get("hybrid_electron_pressure_fp", lev);

// Solve E field in regular cells
warpx.get_pointer_fdtd_solver_fp(lev)->HybridPICSolveE(
Expand Down
4 changes: 2 additions & 2 deletions Source/FieldSolver/ImplicitSolvers/WarpXSolverVec.H
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public:
[[nodiscard]] inline bool IsDefined () const { return m_is_defined; }

void Define ( WarpX* a_WarpX,
std::string a_vector_type_name,
std::string a_scalar_type_name = "none" );
const std::string& a_vector_type_name,
const std::string& a_scalar_type_name = "none" );

inline
void Define ( const WarpXSolverVec& a_solver_vec )
Expand Down
6 changes: 3 additions & 3 deletions Source/FieldSolver/ImplicitSolvers/WarpXSolverVec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ WarpXSolverVec::~WarpXSolverVec ()
}

void WarpXSolverVec::Define ( WarpX* a_WarpX,
std::string a_vector_type_name,
std::string a_scalar_type_name )
const std::string& a_vector_type_name,
const std::string& a_scalar_type_name )
{
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
!IsDefined(),
Expand All @@ -41,7 +41,7 @@ void WarpXSolverVec::Define ( WarpX* a_WarpX,
m_array_type = FieldType::Efield_fp;
}
else if (m_vector_type_name=="Bfield_fp") {
m_array_type = FieldType::Efield_fp;
m_array_type = FieldType::Bfield_fp;
}
else if (m_vector_type_name=="vector_potential_fp_nodal") {
m_array_type = FieldType::vector_potential_fp;
Expand Down
10 changes: 5 additions & 5 deletions Source/FieldSolver/WarpXPushFieldsEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,11 @@ WarpX::PushPSATD ()

const int rho_old = spectral_solver_fp[0]->m_spectral_index.rho_old;
const int rho_new = spectral_solver_fp[0]->m_spectral_index.rho_new;
ablastr::fields::MultiLevelScalarField rho_fp = m_fields.get_mr_levels("rho_fp", finest_level);
ablastr::fields::MultiLevelScalarField rho_cp = m_fields.get_mr_levels("rho_fp", finest_level);
ablastr::fields::MultiLevelVectorField current_fp = m_fields.get_mr_levels_alldirs("current_fp", finest_level);
ablastr::fields::MultiLevelVectorField current_cp = m_fields.get_mr_levels_alldirs("current_cp", finest_level);
ablastr::fields::MultiLevelVectorField current_buf = m_fields.get_mr_levels_alldirs("current_buf", finest_level);
const ablastr::fields::MultiLevelScalarField rho_fp = m_fields.get_mr_levels("rho_fp", finest_level);
const ablastr::fields::MultiLevelScalarField rho_cp = m_fields.get_mr_levels("rho_fp", finest_level);
const ablastr::fields::MultiLevelVectorField current_fp = m_fields.get_mr_levels_alldirs("current_fp", finest_level);
const ablastr::fields::MultiLevelVectorField current_cp = m_fields.get_mr_levels_alldirs("current_cp", finest_level);
const ablastr::fields::MultiLevelVectorField current_buf = m_fields.get_mr_levels_alldirs("current_buf", finest_level);

if (fft_periodic_single_box)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/WarpX.H
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public:
* Set the dotMask container
*/
void SetDotMask( std::unique_ptr<amrex::iMultiFab>& field_dotMask,
std::string field_name, int lev, int dir ) const;
const std::string& field_name, int lev, int dir ) const;

[[nodiscard]] bool DoPML () const {return do_pml;}
[[nodiscard]] bool DoFluidSpecies () const {return do_fluid_species;}
Expand Down
18 changes: 9 additions & 9 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2530,9 +2530,9 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm
}
if (mypc->m_B_ext_particle_s == "read_from_file") {
// These fields will be added to the fields that the particles see, and need to match the index type
auto Bfield_aux_levl_0 = m_fields.get("Bfield_aux", Direction{0}, lev);
auto Bfield_aux_levl_1 = m_fields.get("Bfield_aux", Direction{1}, lev);
auto Bfield_aux_levl_2 = m_fields.get("Bfield_aux", Direction{2}, lev);
auto* Bfield_aux_levl_0 = m_fields.get("Bfield_aux", Direction{0}, lev);
auto* Bfield_aux_levl_1 = m_fields.get("Bfield_aux", Direction{1}, lev);
auto* Bfield_aux_levl_2 = m_fields.get("Bfield_aux", Direction{2}, lev);

// Same as Bfield_fp for reading external field data
m_fields.alloc_init( "B_external_particle_field", Direction{0}, lev, amrex::convert(ba, Bfield_aux_levl_0->ixType()),
Expand All @@ -2553,9 +2553,9 @@ WarpX::AllocLevelMFs (int lev, const BoxArray& ba, const DistributionMapping& dm
}
if (mypc->m_E_ext_particle_s == "read_from_file") {
// These fields will be added to the fields that the particles see, and need to match the index type
auto Efield_aux_levl_0 = m_fields.get("Efield_aux", Direction{0}, lev);
auto Efield_aux_levl_1 = m_fields.get("Efield_aux", Direction{1}, lev);
auto Efield_aux_levl_2 = m_fields.get("Efield_aux", Direction{2}, lev);
auto* Efield_aux_levl_0 = m_fields.get("Efield_aux", Direction{0}, lev);
auto* Efield_aux_levl_1 = m_fields.get("Efield_aux", Direction{1}, lev);
auto* Efield_aux_levl_2 = m_fields.get("Efield_aux", Direction{2}, lev);

// Same as Efield_fp for reading external field data
m_fields.alloc_init( "E_external_particle_field", Direction{0}, lev, amrex::convert(ba, Efield_aux_levl_0->ixType()),
Expand Down Expand Up @@ -2966,14 +2966,14 @@ WarpX::ComputeDivE(amrex::MultiFab& divE, const int lev)
{
if ( WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::PSATD ) {
#ifdef WARPX_USE_FFT
ablastr::fields::VectorField Efield_aux_lev = m_fields.get_alldirs("Efield_aux", lev);
const ablastr::fields::VectorField Efield_aux_lev = m_fields.get_alldirs("Efield_aux", lev);
spectral_solver_fp[lev]->ComputeSpectralDivE(lev, Efield_aux_lev, divE);
#else
WARPX_ABORT_WITH_MESSAGE(
"ComputeDivE: PSATD requested but not compiled");
#endif
} else {
ablastr::fields::VectorField Efield_aux_lev = m_fields.get_alldirs("Efield_aux", lev);
const ablastr::fields::VectorField Efield_aux_lev = m_fields.get_alldirs("Efield_aux", lev);
m_fdtd_solver_fp[lev]->ComputeDivE(Efield_aux_lev, divE);
}
}
Expand Down Expand Up @@ -3410,7 +3410,7 @@ WarpX::getFieldDotMaskPointer ( FieldType field_type, int lev, int dir ) const
}

void WarpX::SetDotMask( std::unique_ptr<amrex::iMultiFab>& field_dotMask,
std::string field_name, int lev, int dir ) const
const std::string& field_name, int lev, int dir ) const
{
// Define the dot mask for this field_type needed to properly compute dotProduct()
// for field values that have shared locations on different MPI ranks
Expand Down
10 changes: 6 additions & 4 deletions Source/ablastr/fields/MultiFabRegister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,12 @@ namespace ablastr::fields
// C++20: Replace with std::erase_if
for (auto first = m_mf_register.begin(), last = m_mf_register.end(); first != last;)
{
if (first->second.m_level == level)
if (first->second.m_level == level){
first = m_mf_register.erase(first);
else
}
else{
++first;
}
}
}

Expand Down Expand Up @@ -627,7 +629,7 @@ namespace ablastr::fields
const amrex::Vector<std::array< std::unique_ptr<amrex::MultiFab>, 3 > >& old_vector_on_levels
)
{
int const finest_level = old_vector_on_levels.size() - 1u;
auto const finest_level = static_cast<int>(old_vector_on_levels.size() - 1u);

MultiLevelVectorField field_on_level;
field_on_level.reserve(finest_level+1);
Expand All @@ -653,7 +655,7 @@ namespace ablastr::fields
const amrex::Vector<std::unique_ptr<amrex::MultiFab> >& old_scalar_on_levels
)
{
int const finest_level = old_scalar_on_levels.size() - 1u;
auto const finest_level = static_cast<int>(old_scalar_on_levels.size() - 1u);

MultiLevelScalarField field_on_level;
field_on_level.reserve(finest_level+1);
Expand Down

0 comments on commit fe87f93

Please sign in to comment.