Skip to content

Commit

Permalink
Clang-Tidy: readability-braces-around-statements (ECP-WarpX#4511)
Browse files Browse the repository at this point in the history
Fixed by clang-tidy --fix.
  • Loading branch information
dpgrote committed Dec 19, 2023
1 parent 67cd890 commit beed243
Show file tree
Hide file tree
Showing 112 changed files with 910 additions and 709 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Checks: '
-performance-unnecessary-value-param,
portability-*,
readability-*,
-readability-braces-around-statements,
-readability-convert-member-functions-to-static,
-readability-else-after-return,
-readability-function-cognitive-complexity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ HardEdgedPlasmaLensDevice::InitHardEdgedPlasmaLensDevice (HardEdgedPlasmaLens co

nelements = h_plasmalens.nelements;

if (nelements == 0) return;
if (nelements == 0) { return; }

d_zs_arr = h_plasmalens.d_zs.data();
d_ze_arr = h_plasmalens.d_ze.data();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ HardEdgedQuadrupoleDevice::InitHardEdgedQuadrupoleDevice (HardEdgedQuadrupole co

nelements = h_quad.nelements;

if (nelements == 0) return;
if (nelements == 0) { return; }

d_zs_arr = h_quad.d_zs.data();
d_ze_arr = h_quad.d_ze.data();
Expand Down
14 changes: 8 additions & 6 deletions Source/BoundaryConditions/PML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ MultiSigmaBox::MultiSigmaBox (const BoxArray& ba, const DistributionMapping& dm,
void
MultiSigmaBox::ComputePMLFactorsB (const Real* dx, Real dt)
{
if (dt == dt_B) return;
if (dt == dt_B) { return; }

dt_B = dt;

Expand All @@ -529,7 +529,7 @@ MultiSigmaBox::ComputePMLFactorsB (const Real* dx, Real dt)
void
MultiSigmaBox::ComputePMLFactorsE (const Real* dx, Real dt)
{
if (dt == dt_E) return;
if (dt == dt_E) { return; }

dt_E = dt;

Expand Down Expand Up @@ -597,7 +597,9 @@ PML::PML (const int lev, const BoxArray& grid_ba, const DistributionMapping& gri
auto nge = IntVect(AMREX_D_DECL(2, 2, 2));
auto ngb = IntVect(AMREX_D_DECL(2, 2, 2));
int ngf_int = 0;
if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::CKC) ngf_int = std::max( ngf_int, 1 );
if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::CKC) {
ngf_int = std::max( ngf_int, 1 );
}
auto ngf = IntVect(AMREX_D_DECL(ngf_int, ngf_int, ngf_int));

if (do_moving_window) {
Expand Down Expand Up @@ -1074,9 +1076,9 @@ void PML::Exchange (const std::array<amrex::MultiFab*,3>& mf_pml,
const int do_pml_in_domain)
{
const amrex::Geometry& geom = (patch_type == PatchType::fine) ? *m_geom : *m_cgeom;
if (mf_pml[0] && mf[0]) Exchange(*mf_pml[0], *mf[0], geom, do_pml_in_domain);
if (mf_pml[1] && mf[1]) Exchange(*mf_pml[1], *mf[1], geom, do_pml_in_domain);
if (mf_pml[2] && mf[2]) Exchange(*mf_pml[2], *mf[2], geom, do_pml_in_domain);
if (mf_pml[0] && mf[0]) { Exchange(*mf_pml[0], *mf[0], geom, do_pml_in_domain); }
if (mf_pml[1] && mf[1]) { Exchange(*mf_pml[1], *mf[1], geom, do_pml_in_domain); }
if (mf_pml[2] && mf[2]) { Exchange(*mf_pml[2], *mf[2], geom, do_pml_in_domain); }
}

void
Expand Down
12 changes: 6 additions & 6 deletions Source/BoundaryConditions/WarpXEvolvePML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ void
WarpX::DampPML (const int lev)
{
DampPML(lev, PatchType::fine);
if (lev > 0) DampPML(lev, PatchType::coarse);
if (lev > 0) { DampPML(lev, PatchType::coarse); }
}

void
WarpX::DampPML (const int lev, PatchType patch_type)
{
if (!do_pml) return;
if (!do_pml) { return; }

WARPX_PROFILE("WarpX::DampPML()");
#if (defined WARPX_DIM_RZ) && (defined WARPX_USE_PSATD)
Expand Down Expand Up @@ -228,15 +228,15 @@ void
WarpX::DampJPML (int lev)
{
DampJPML(lev, PatchType::fine);
if (lev > 0) DampJPML(lev, PatchType::coarse);
if (lev > 0) { DampJPML(lev, PatchType::coarse); }
}

void
WarpX::DampJPML (int lev, PatchType patch_type)
{
if (!do_pml) return;
if (!do_pml_j_damping) return;
if (!pml[lev]) return;
if (!do_pml) { return; }
if (!do_pml_j_damping) { return; }
if (!pml[lev]) { return; }

WARPX_PROFILE("WarpX::DampJPML()");

Expand Down
9 changes: 5 additions & 4 deletions Source/BoundaryConditions/WarpXFieldBoundaries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ void WarpX::ApplyBfieldBoundary (const int lev, PatchType patch_type, DtType a_d
applySilverMueller = true;
}
}
if(applySilverMueller) m_fdtd_solver_fp[0]->ApplySilverMuellerBoundary(
if(applySilverMueller) { m_fdtd_solver_fp[0]->ApplySilverMuellerBoundary(
Efield_fp[lev], Bfield_fp[lev],
Geom(lev).Domain(), dt[lev],
WarpX::field_boundary_lo,
WarpX::field_boundary_hi);
}
}
}

Expand All @@ -105,14 +106,14 @@ void WarpX::ApplyBfieldBoundary (const int lev, PatchType patch_type, DtType a_d
void WarpX::ApplyRhofieldBoundary (const int lev, MultiFab* rho,
PatchType patch_type)
{
if (PEC::isAnyBoundaryPEC()) PEC::ApplyPECtoRhofield(rho, lev, patch_type);
if (PEC::isAnyBoundaryPEC()) { PEC::ApplyPECtoRhofield(rho, lev, patch_type); }
}

void WarpX::ApplyJfieldBoundary (const int lev, amrex::MultiFab* Jx,
amrex::MultiFab* Jy, amrex::MultiFab* Jz,
PatchType patch_type)
{
if (PEC::isAnyBoundaryPEC()) PEC::ApplyPECtoJfield(Jx, Jy, Jz, lev, patch_type);
if (PEC::isAnyBoundaryPEC()) { PEC::ApplyPECtoJfield(Jx, Jy, Jz, lev, patch_type); }
}

#ifdef WARPX_DIM_RZ
Expand All @@ -139,7 +140,7 @@ WarpX::ApplyFieldBoundaryOnAxis (amrex::MultiFab* Er, amrex::MultiFab* Et, amrex
const amrex::Real rmin = xyzmin[0];

// Skip blocks that don't touch the axis
if (rmin > 0._rt) continue;
if (rmin > 0._rt) { continue; }

amrex::Array4<amrex::Real> const& Er_arr = Er->array(mfi);
amrex::Array4<amrex::Real> const& Et_arr = Et->array(mfi);
Expand Down
23 changes: 12 additions & 11 deletions Source/BoundaryConditions/WarpX_PEC.H
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ using namespace amrex;
: (dom_hi[idim] + 1 - ig));
GuardCell = true;
// tangential components are inverted across PEC boundary
if (is_tangent_to_PEC) sign *= -1._rt;
if (is_tangent_to_PEC) { sign *= -1._rt; }
#if (defined WARPX_DIM_RZ)
if (icomp == 0 && idim == 0 && iside == 1) {
// Add radial scale so that drEr/dr = 0.
Expand Down Expand Up @@ -329,7 +329,7 @@ using namespace amrex;
: (dom_hi[idim] + 1 - ig));
GuardCell = true;
// Sign of the normal component in guard cell is inverted
if (is_normal_to_PEC) sign *= -1._rt;
if (is_normal_to_PEC) { sign *= -1._rt; }
#if (defined WARPX_DIM_RZ)
if (icomp == 0 && idim == 0 && iside == 1) {
// Add radial scale so that drBr/dr = 0.
Expand Down Expand Up @@ -391,17 +391,17 @@ using namespace amrex;
{
for (int iside = 0; iside < 2; ++iside)
{
if (!is_pec[idim][iside]) continue;
if (!is_pec[idim][iside]) { continue; }

// Get the mirror guard cell index
amrex::IntVect iv_mirror = ijk_vec;
iv_mirror[idim] = mirrorfac[idim][iside] - ijk_vec[idim];

// On the PEC boundary the charge/current density is set to 0
if (ijk_vec == iv_mirror) field(ijk_vec, n) = 0._rt;
if (ijk_vec == iv_mirror) {
field(ijk_vec, n) = 0._rt;
// otherwise update the internal cell if the mirror guard cell exists
else if (fabbox.contains(iv_mirror))
{
} else if (fabbox.contains(iv_mirror)) {
field(ijk_vec,n) += psign[idim][iside] * field(iv_mirror,n);
}
}
Expand All @@ -412,16 +412,17 @@ using namespace amrex;
{
for (int iside = 0; iside < 2; ++iside)
{
if (!is_pec[idim][iside]) continue;
if (!is_pec[idim][iside]) { continue; }

amrex::IntVect iv_mirror = ijk_vec;
iv_mirror[idim] = mirrorfac[idim][iside] - ijk_vec[idim];
if (ijk_vec != iv_mirror && fabbox.contains(iv_mirror))
{
if (tangent_to_bndy[idim])
if (tangent_to_bndy[idim]) {
field(iv_mirror, n) = -field(ijk_vec, n);
else
} else {
field(iv_mirror, n) = field(ijk_vec, n);
}
}
}
}
Expand Down Expand Up @@ -454,7 +455,7 @@ using namespace amrex;
{
for (int iside = 0; iside < 2; ++iside)
{
if (!is_pec[idim][iside]) continue;
if (!is_pec[idim][iside]) { continue; }

// Get the mirror guard cell index
amrex::IntVect iv_mirror = ijk_vec;
Expand All @@ -464,7 +465,7 @@ using namespace amrex;
// first value in the domain (nodal fields)
if (ijk_vec == iv_mirror) {
iv_mirror[idim] += (iside == 0) ? 1 : -1;
if (fabbox.contains(iv_mirror)) field(ijk_vec, n) = field(iv_mirror, n);
if (fabbox.contains(iv_mirror)) { field(ijk_vec, n) = field(iv_mirror, n); }
}
// otherwise set the mirror guard cell equal to the internal cell value
else if (fabbox.contains(iv_mirror))
Expand Down
26 changes: 13 additions & 13 deletions Source/BoundaryConditions/WarpX_PEC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ using namespace amrex::literals;
bool
PEC::isAnyBoundaryPEC() {
for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
if ( WarpX::field_boundary_lo[idim] == FieldBoundaryType::PEC) return true;
if ( WarpX::field_boundary_hi[idim] == FieldBoundaryType::PEC) return true;
if ( WarpX::field_boundary_lo[idim] == FieldBoundaryType::PEC) { return true; }
if ( WarpX::field_boundary_hi[idim] == FieldBoundaryType::PEC) { return true; }
}
return false;
}
Expand Down Expand Up @@ -250,8 +250,8 @@ PEC::ApplyPECtoRhofield (amrex::MultiFab* rho, const int lev, PatchType patch_ty
for (int idim=0; idim < AMREX_SPACEDIM; ++idim) {
is_pec[idim][0] = WarpX::field_boundary_lo[idim] == FieldBoundaryType::PEC;
is_pec[idim][1] = WarpX::field_boundary_hi[idim] == FieldBoundaryType::PEC;
if (!is_pec[idim][0]) grown_domain_box.growLo(idim, ng_fieldgather[idim]);
if (!is_pec[idim][1]) grown_domain_box.growHi(idim, ng_fieldgather[idim]);
if (!is_pec[idim][0]) { grown_domain_box.growLo(idim, ng_fieldgather[idim]); }
if (!is_pec[idim][1]) { grown_domain_box.growHi(idim, ng_fieldgather[idim]); }

// rho values inside guard cells are updated the same as tangential
// components of the current density
Expand All @@ -276,7 +276,7 @@ PEC::ApplyPECtoRhofield (amrex::MultiFab* rho, const int lev, PatchType patch_ty

// If grown_domain_box contains fabbox it means there are no PEC
// boundaries to handle so continue to next box
if (grown_domain_box.contains(fabbox)) continue;
if (grown_domain_box.contains(fabbox)) { continue; }

// Extract field data
auto const& rho_array = rho->array(mfi);
Expand Down Expand Up @@ -342,8 +342,8 @@ PEC::ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
for (int idim=0; idim < AMREX_SPACEDIM; ++idim) {
is_pec[idim][0] = WarpX::field_boundary_lo[idim] == FieldBoundaryType::PEC;
is_pec[idim][1] = WarpX::field_boundary_hi[idim] == FieldBoundaryType::PEC;
if (!is_pec[idim][0]) grown_domain_box.growLo(idim, ng_fieldgather[idim]);
if (!is_pec[idim][1]) grown_domain_box.growHi(idim, ng_fieldgather[idim]);
if (!is_pec[idim][0]) { grown_domain_box.growLo(idim, ng_fieldgather[idim]); }
if (!is_pec[idim][1]) { grown_domain_box.growHi(idim, ng_fieldgather[idim]); }

for (int icomp=0; icomp < 3; ++icomp) {
// Set the psign value correctly for each current component for each
Expand Down Expand Up @@ -398,7 +398,7 @@ PEC::ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
// If grown_domain_box contains fabbox it means there are no PEC
// boundaries to handle so continue to next box
grown_domain_box.convert(Jx_nodal);
if (grown_domain_box.contains(fabbox)) continue;
if (grown_domain_box.contains(fabbox)) { continue; }

// Extract field data
auto const& Jx_array = Jx->array(mfi);
Expand Down Expand Up @@ -433,7 +433,7 @@ PEC::ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
// If grown_domain_box contains fabbox it means there are no PEC
// boundaries to handle so continue to next box
grown_domain_box.convert(Jy_nodal);
if (grown_domain_box.contains(fabbox)) continue;
if (grown_domain_box.contains(fabbox)) { continue; }

// Extract field data
auto const& Jy_array = Jy->array(mfi);
Expand Down Expand Up @@ -468,7 +468,7 @@ PEC::ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
// If grown_domain_box contains fabbox it means there are no PEC
// boundaries to handle so continue to next box
grown_domain_box.convert(Jz_nodal);
if (grown_domain_box.contains(fabbox)) continue;
if (grown_domain_box.contains(fabbox)) { continue; }

// Extract field data
auto const& Jz_array = Jz->array(mfi);
Expand Down Expand Up @@ -520,8 +520,8 @@ PEC::ApplyPECtoElectronPressure (amrex::MultiFab* Pefield, const int lev,
for (int idim=0; idim < AMREX_SPACEDIM; ++idim) {
is_pec[idim][0] = WarpX::field_boundary_lo[idim] == FieldBoundaryType::PEC;
is_pec[idim][1] = WarpX::field_boundary_hi[idim] == FieldBoundaryType::PEC;
if (!is_pec[idim][0]) grown_domain_box.growLo(idim, ng_fieldgather[idim]);
if (!is_pec[idim][1]) grown_domain_box.growHi(idim, ng_fieldgather[idim]);
if (!is_pec[idim][0]) { grown_domain_box.growLo(idim, ng_fieldgather[idim]); }
if (!is_pec[idim][1]) { grown_domain_box.growHi(idim, ng_fieldgather[idim]); }

mirrorfac[idim][0] = 2*domain_lo[idim] - (1 - Pe_nodal[idim]);
mirrorfac[idim][1] = 2*domain_hi[idim] + (1 - Pe_nodal[idim]);
Expand All @@ -538,7 +538,7 @@ PEC::ApplyPECtoElectronPressure (amrex::MultiFab* Pefield, const int lev,

// If grown_domain_box contains fabbox it means there are no PEC
// boundaries to handle so continue to next box
if (grown_domain_box.contains(fabbox)) continue;
if (grown_domain_box.contains(fabbox)) { continue; }

// Extract field data
auto const& Pe_array = Pefield->array(mfi);
Expand Down
16 changes: 8 additions & 8 deletions Source/Diagnostics/BTD_Plotfile_Header_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ BTDPlotfileHeaderImpl::WriteHeader ()
HeaderFile.open(m_Header_path.c_str(), std::ofstream::out |
std::ofstream::trunc |
std::ofstream::binary);
if ( !HeaderFile.good()) amrex::FileOpenFailed(m_Header_path);
if ( !HeaderFile.good()) { amrex::FileOpenFailed(m_Header_path); }

HeaderFile.precision(17);

Expand Down Expand Up @@ -241,7 +241,7 @@ BTDMultiFabHeaderImpl::ReadMultiFabHeader ()
m_minval[ifab].resize(m_ncomp);
for (int icomp = 0; icomp < m_ncomp; ++icomp) {
is >> m_minval[ifab][icomp] >> ch;
if( ch != ',' ) amrex::Error("Expected a ',' got something else");
if( ch != ',' ) { amrex::Error("Expected a ',' got something else"); }
}
}
ablastr::utils::text::goto_next_line(is);
Expand All @@ -251,7 +251,7 @@ BTDMultiFabHeaderImpl::ReadMultiFabHeader ()
m_maxval[ifab].resize(m_ncomp);
for (int icomp = 0; icomp < m_ncomp; ++icomp) {
is >> m_maxval[ifab][icomp] >> ch;
if( ch != ',' ) amrex::Error("Expected a ',' got something else");
if( ch != ',' ) { amrex::Error("Expected a ',' got something else"); }
}
}

Expand All @@ -266,9 +266,9 @@ BTDMultiFabHeaderImpl::WriteMultiFabHeader ()
}
std::ofstream FabHeaderFile;
FabHeaderFile.open(m_Header_path.c_str(), std::ofstream::out |
std::ofstream::trunc |
std::ofstream::binary);
if ( !FabHeaderFile.good()) amrex::FileOpenFailed(m_Header_path);
std::ofstream::trunc |
std::ofstream::binary);
if ( !FabHeaderFile.good()) { amrex::FileOpenFailed(m_Header_path); }

FabHeaderFile.precision(17);

Expand Down Expand Up @@ -421,7 +421,7 @@ BTDSpeciesHeaderImpl::WriteHeader ()
HeaderFile.open(m_Header_path.c_str(), std::ofstream::out |
std::ofstream::trunc |
std::ofstream::binary);
if ( !HeaderFile.good()) amrex::FileOpenFailed(m_Header_path);
if ( !HeaderFile.good()) { amrex::FileOpenFailed(m_Header_path); }

HeaderFile.precision(17);

Expand Down Expand Up @@ -525,7 +525,7 @@ BTDParticleDataHeaderImpl::WriteHeader ()
HeaderFile.open(m_Header_path.c_str(), std::ofstream::out |
std::ofstream::trunc |
std::ofstream::binary);
if ( !HeaderFile.good()) amrex::FileOpenFailed(m_Header_path);
if ( !HeaderFile.good()) { amrex::FileOpenFailed(m_Header_path); }

HeaderFile.precision(17);
m_ba.writeOn(HeaderFile);
Expand Down
Loading

0 comments on commit beed243

Please sign in to comment.