Skip to content

Commit

Permalink
make clang-tidy recognize .H as a header (#3832)
Browse files Browse the repository at this point in the history
the output of `clang-tidy --dump-config` shows that .H is not recognized
as a header

fix warnings

---------

Co-authored-by: Weiqun Zhang <weiqunzhang@lbl.gov>
  • Loading branch information
zingale and WeiqunZhang authored Apr 2, 2024
1 parent f2536be commit d78e241
Show file tree
Hide file tree
Showing 31 changed files with 230 additions and 209 deletions.
15 changes: 15 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,18 @@ Checks: >
# Files not ending with nolint.H will be filtered in.
HeaderFilterRegex: '([^n].....|[^o]....|[^l]...|[^i]..|[^n].|[^t])\.H$'

CheckOptions:
- key: bugprone-dynamic-static-initializers.HeaderFileExtensions
value: ';H;h;hh;hpp;hxx'
- key: bugprone-suspicious-include.HeaderFileExtensions
value: ';H;h;hh;hpp;hxx'
- key: google-global-names-in-headers.HeaderFileExtensions
value: ';H;h;hh;hpp;hxx'
- key: google-build-namespaces.HeaderFileExtensions
value: ';H;h;hh;hpp;hxx'
- key: misc-definitions-in-headers.HeaderFileExtensions
value: ';H;h;hh;hpp;hxx'
- key: misc-use-anonymous-namespace.HeaderFileExtensions
value: ';H;h;hh;hpp;hxx'

22 changes: 11 additions & 11 deletions Src/AmrCore/AMReX_FillPatchUtil_I.H
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ InterpFace (InterpBase *interp,
}


namespace {
namespace detail {

// ======== FArrayBox

Expand Down Expand Up @@ -739,7 +739,7 @@ namespace {
}
}

} // Anonymous namespace
} // namespace detail

template <typename MF, typename BC, typename Interp, typename PreInterpHook, typename PostInterpHook>
std::enable_if_t<IsFabArray<MF>::value>
Expand All @@ -761,7 +761,7 @@ FillPatchTwoLevels (MF& mf, IntVect const& nghost, Real time,
#else
EB2::IndexSpace const* index_space = nullptr;
#endif
FillPatchTwoLevels_doit(mf,nghost,time,cmf,ct,fmf,ft,
detail::FillPatchTwoLevels_doit(mf,nghost,time,cmf,ct,fmf,ft,
scomp,dcomp,ncomp,cgeom,fgeom,
cbc,cbccomp,fbc,fbccomp,ratio,mapper,bcs,bcscomp,
pre_interp,post_interp,index_space);
Expand All @@ -788,7 +788,7 @@ FillPatchTwoLevels (MF& mf, Real time,
EB2::IndexSpace const* index_space = nullptr;
#endif

FillPatchTwoLevels_doit(mf,mf.nGrowVect(),time,cmf,ct,fmf,ft,
detail::FillPatchTwoLevels_doit(mf,mf.nGrowVect(),time,cmf,ct,fmf,ft,
scomp,dcomp,ncomp,cgeom,fgeom,
cbc,cbccomp,fbc,fbccomp,ratio,mapper,bcs,bcscomp,
pre_interp,post_interp,index_space);
Expand All @@ -815,7 +815,7 @@ FillPatchTwoLevels (Array<MF*, AMREX_SPACEDIM> const& mf, IntVect const& nghost,
EB2::IndexSpace const* index_space = nullptr;
#endif

FillPatchTwoLevels_doit(mf,nghost,time,cmf,ct,fmf,ft,
detail::FillPatchTwoLevels_doit(mf,nghost,time,cmf,ct,fmf,ft,
scomp,dcomp,ncomp,cgeom,fgeom,
cbc,cbccomp,fbc,fbccomp,ratio,mapper,bcs,bcscomp,
pre_interp,post_interp,index_space);
Expand Down Expand Up @@ -846,7 +846,7 @@ FillPatchTwoLevels (Array<MF*, AMREX_SPACEDIM> const& mf, IntVect const& nghost,
Array<int, AMREX_SPACEDIM> fbccomp_arr = {AMREX_D_DECL(fbccomp,fbccomp,fbccomp)};
Array<int, AMREX_SPACEDIM> bcscomp_arr = {AMREX_D_DECL(bcscomp,bcscomp,bcscomp)};

FillPatchTwoLevels_doit(mf,nghost,time,cmf,ct,fmf,ft,
detail::FillPatchTwoLevels_doit(mf,nghost,time,cmf,ct,fmf,ft,
scomp,dcomp,ncomp,cgeom,fgeom,
cbc,cbccomp_arr,fbc,fbccomp_arr,ratio,mapper,bcs,bcscomp_arr,
pre_interp,post_interp,index_space);
Expand Down Expand Up @@ -877,7 +877,7 @@ FillPatchTwoLevels (Array<MF*, AMREX_SPACEDIM> const& mf, Real time,
Array<int, AMREX_SPACEDIM> fbccomp_arr = {AMREX_D_DECL(fbccomp,fbccomp,fbccomp)};
Array<int, AMREX_SPACEDIM> bcscomp_arr = {AMREX_D_DECL(bcscomp,bcscomp,bcscomp)};

FillPatchTwoLevels_doit(mf,mf[0]->nGrowVect(),time,cmf,ct,fmf,ft,
detail::FillPatchTwoLevels_doit(mf,mf[0]->nGrowVect(),time,cmf,ct,fmf,ft,
scomp,dcomp,ncomp,cgeom,fgeom,
cbc,cbccomp_arr,fbc,fbccomp_arr,ratio,mapper,bcs,bcscomp_arr,
pre_interp,post_interp,index_space);
Expand All @@ -900,7 +900,7 @@ FillPatchTwoLevels (MF& mf, IntVect const& nghost, Real time,
const PreInterpHook& pre_interp,
const PostInterpHook& post_interp)
{
FillPatchTwoLevels_doit(mf,nghost,time,cmf,ct,fmf,ft,
detail::FillPatchTwoLevels_doit(mf,nghost,time,cmf,ct,fmf,ft,
scomp,dcomp,ncomp,cgeom,fgeom,
cbc,cbccomp,fbc,fbccomp,ratio,mapper,bcs,bcscomp,
pre_interp,post_interp,&index_space);
Expand All @@ -922,7 +922,7 @@ FillPatchTwoLevels (MF& mf, Real time,
const PreInterpHook& pre_interp,
const PostInterpHook& post_interp)
{
FillPatchTwoLevels_doit(mf,mf.nGrowVect(),time,cmf,ct,fmf,ft,
detail::FillPatchTwoLevels_doit(mf,mf.nGrowVect(),time,cmf,ct,fmf,ft,
scomp,dcomp,ncomp,cgeom,fgeom,
cbc,cbccomp,fbc,fbccomp,ratio,mapper,bcs,bcscomp,
pre_interp,post_interp,&index_space);
Expand Down Expand Up @@ -1016,7 +1016,7 @@ InterpFromCoarseLevel (MF& mf, IntVect const& nghost, Real time,
{
mf_crse_patch.define(ba_crse_patch, dm, ncomp, 0);
}
mf_set_domain_bndry (mf_crse_patch, cgeom);
detail::mf_set_domain_bndry (mf_crse_patch, cgeom);

mf_crse_patch.ParallelCopy(cmf, scomp, 0, ncomp, cgeom.periodicity());

Expand Down Expand Up @@ -1131,7 +1131,7 @@ InterpFromCoarseLevel (Array<MF*, AMREX_SPACEDIM> const& mf, IntVect const& ngho
#else
mf_crse_patch[d].define(ba_crse_idxed, dm, ncomp, 0);
#endif
mf_set_domain_bndry(mf_crse_patch[d], cgeom);
detail::mf_set_domain_bndry(mf_crse_patch[d], cgeom);

mf_crse_patch[d].ParallelCopy(*(cmf[d]), scomp, 0, ncomp, cgeom.periodicity());
cbc[d](mf_crse_patch[d], 0, ncomp, mf_crse_patch[d].nGrowVect(), time, cbccomp);
Expand Down
12 changes: 6 additions & 6 deletions Src/AmrCore/AMReX_FillPatcher.H
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ FillPatcher<MF>::fillCoarseFineBoundary (MF& mf, IntVect const& nghost, Real tim
{
if (m_cf_fine_data == nullptr) {
m_cf_fine_data = std::make_unique<MF>
(make_mf_fine_patch<MF>(fpc, m_ncomp));
(detail::make_mf_fine_patch<MF>(fpc, m_ncomp));
}

int ncmfs = cmf.size();
Expand All @@ -320,7 +320,7 @@ FillPatcher<MF>::fillCoarseFineBoundary (MF& mf, IntVect const& nghost, Real tim
});

if (it == std::end(m_cf_crse_data)) {
MF mf_crse_patch = make_mf_crse_patch<MF>(fpc, m_ncomp);
MF mf_crse_patch = detail::make_mf_crse_patch<MF>(fpc, m_ncomp);
mf_crse_patch.ParallelCopy(*cmf[icmf], m_cgeom.periodicity());

std::pair<Real,std::unique_ptr<MF>> tmp;
Expand All @@ -332,7 +332,7 @@ FillPatcher<MF>::fillCoarseFineBoundary (MF& mf, IntVect const& nghost, Real tim

if (m_cf_crse_data_tmp == nullptr) {
m_cf_crse_data_tmp = std::make_unique<MF>
(make_mf_crse_patch<MF>(fpc, m_ncomp));
(detail::make_mf_crse_patch<MF>(fpc, m_ncomp));
}

int const ng_space_interp = 8; // Need to be big enough
Expand Down Expand Up @@ -419,7 +419,7 @@ void FillPatcher<MF>::storeRKCoarseData (Real /*time*/, Real dt, MF const& S_old

for (auto& tmf : m_cf_crse_data) {
tmf.first = std::numeric_limits<Real>::lowest(); // because we don't need it
tmf.second = std::make_unique<MF>(make_mf_crse_patch<MF>(fpc, m_ncomp));
tmf.second = std::make_unique<MF>(detail::make_mf_crse_patch<MF>(fpc, m_ncomp));
}
m_cf_crse_data[0].second->ParallelCopy(S_old, m_cgeom.periodicity());
for (std::size_t i = 0; i < order; ++i) {
Expand All @@ -444,7 +444,7 @@ void FillPatcher<MF>::fillRK (int stage, int iteration, int ncycle,
auto const& fpc = getFPinfo();
if (m_cf_crse_data_tmp == nullptr) {
m_cf_crse_data_tmp = std::make_unique<MF>
(make_mf_crse_patch<MF>(fpc, m_ncomp));
(detail::make_mf_crse_patch<MF>(fpc, m_ncomp));
}

auto const& u = m_cf_crse_data_tmp->arrays();
Expand Down Expand Up @@ -596,7 +596,7 @@ void FillPatcher<MF>::fillRK (int stage, int iteration, int ncycle,
cbc(*m_cf_crse_data_tmp, 0, m_ncomp, m_nghost, time, 0);

if (m_cf_fine_data == nullptr) {
m_cf_fine_data = std::make_unique<MF>(make_mf_fine_patch<MF>(fpc, m_ncomp));
m_cf_fine_data = std::make_unique<MF>(detail::make_mf_fine_patch<MF>(fpc, m_ncomp));
}

FillPatchInterp(*m_cf_fine_data, 0, *m_cf_crse_data_tmp, 0,
Expand Down
6 changes: 5 additions & 1 deletion Src/AmrCore/AMReX_Interp_2D_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pcinterp_interp (Box const& bx,
}
}

namespace {
namespace interp_detail {
constexpr int ix = 0;
constexpr int iy = 1;
constexpr int ixy = 2;
Expand All @@ -39,6 +39,8 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void
nodebilin_slopes (Box const& bx, Array4<T> const& slope, Array4<T const> const& u,
const int icomp, const int ncomp, IntVect const& ratio) noexcept
{
using namespace interp_detail;

const auto lo = amrex::lbound(bx);
const auto hi = amrex::ubound(bx);

Expand Down Expand Up @@ -67,6 +69,8 @@ nodebilin_interp (Box const& bx, Array4<T> const& fine, const int fcomp, const i
Array4<T const> const& slope, Array4<T const> const& crse,
const int ccomp, IntVect const& ratio) noexcept
{
using namespace interp_detail;

const auto lo = amrex::lbound(bx);
const auto hi = amrex::ubound(bx);
const auto chi = amrex::ubound(slope);
Expand Down
6 changes: 5 additions & 1 deletion Src/AmrCore/AMReX_Interp_3D_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pcinterp_interp (Box const& bx,
}
}

namespace {
namespace interp_detail {
constexpr int ix = 0;
constexpr int iy = 1;
constexpr int iz = 2;
Expand All @@ -49,6 +49,8 @@ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void
nodebilin_slopes (Box const& bx, Array4<T> const& slope, Array4<T const> const& u,
const int icomp, const int ncomp, IntVect const& ratio) noexcept
{
using namespace interp_detail;

const auto lo = amrex::lbound(bx);
const auto hi = amrex::ubound(bx);

Expand Down Expand Up @@ -91,6 +93,8 @@ nodebilin_interp (Box const& bx, Array4<T> const& fine, const int fcomp, const i
Array4<T const> const& slope, Array4<T const> const& crse,
const int ccomp, IntVect const& ratio) noexcept
{
using namespace interp_detail;

const auto lo = amrex::lbound(bx);
const auto hi = amrex::ubound(bx);
const auto chi = amrex::ubound(slope);
Expand Down
4 changes: 0 additions & 4 deletions Src/AmrCore/AMReX_MFInterp_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

namespace amrex {

namespace {

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
Real mf_compute_slopes_x (int i, int j, int k, Array4<Real const> const& u, int nu,
Box const& domain, BCRec const& bc)
Expand Down Expand Up @@ -252,8 +250,6 @@ Real mf_cell_quadratic_compute_slopes_yz (int i, int j, int k,
return yz;
}

} // namespace

} // namespace amrex

#if (AMREX_SPACEDIM == 1)
Expand Down
10 changes: 4 additions & 6 deletions Src/Boundary/AMReX_YAFluxRegister_K.H
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
#define AMREX_YAFLUXREGISTER_K_H_
#include <AMReX_Config.H>

namespace {
// must be same as in AMReX_YAFluxRegister.H
constexpr int amrex_yafluxreg_crse_cell = 0;
constexpr int amrex_yafluxreg_crse_fine_boundary_cell = 1;
constexpr int amrex_yafluxreg_fine_cell = 2;
}
// must be same as in AMReX_YAFluxRegister.H
constexpr int amrex_yafluxreg_crse_cell = 0;
constexpr int amrex_yafluxreg_crse_fine_boundary_cell = 1;
constexpr int amrex_yafluxreg_fine_cell = 2;

#if (AMREX_SPACEDIM == 1)
#include <AMReX_YAFluxRegister_1D_K.H>
Expand Down
4 changes: 3 additions & 1 deletion Src/EB/AMReX_EB2_2D_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ amrex_eb2_build_types (Box const& tbx, Box const& bxg2,
});
}

namespace {
namespace detail {
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
int num_cuts (Real a, Real b) noexcept {
return (a >= 0.0_rt && b < 0.0_rt) || (b >= 0.0_rt && a < 0.0_rt);
Expand All @@ -76,6 +76,8 @@ namespace {
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
int check_mvmc (int i, int j, int, Array4<Real const> const& fine)
{
using detail::num_cuts;

constexpr int k = 0;
i *= 2;
j *= 2;
Expand Down
8 changes: 6 additions & 2 deletions Src/EB/AMReX_EB2_3D_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ amrex_eb2_build_types (Box const& tbx, Box const& bxg2,
});
}

namespace {
namespace detail {
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
int num_cuts (Real a, Real b) noexcept {
return (a >= 0.0_rt && b < 0.0_rt) || (b >= 0.0_rt && a < 0.0_rt);
Expand All @@ -169,6 +169,8 @@ namespace {
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
int check_mvmc (int i, int j, int k, Array4<Real const> const& fine)
{
using detail::num_cuts;

int ierr = 0;

i *= 2;
Expand Down Expand Up @@ -272,7 +274,7 @@ int check_mvmc (int i, int j, int k, Array4<Real const> const& fine)
return ierr;
}

namespace {
namespace detail {
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
Real coarsen_edge_cent (Real f1, Real f2)
{
Expand Down Expand Up @@ -320,6 +322,8 @@ int coarsen_from_fine (int i, int j, int k, Box const& bx, int ngrow,
Array4<Real const> const& fecy, Array4<Real const> const& fecz,
Array4<EBCellFlag const> const& fflag)
{
using detail::coarsen_edge_cent;

const Box& gbx = amrex::grow(bx,ngrow);
const Box& xbx = amrex::surroundingNodes(bx,0); // face boxes
const Box& ybx = amrex::surroundingNodes(bx,1);
Expand Down
22 changes: 10 additions & 12 deletions Src/EB/AMReX_EBFluxRegister_2D_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,18 @@ void eb_flux_reg_crseadd_va(int i, int j, int k, Array4<Real> const& d,
}
}

namespace {
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
Real eb_flux_reg_cvol (int i, int j, Array4<Real const> const& vfrac,
Dim3 const& ratio, Real threshold) noexcept
{
Real cvol = Real(0.0);
constexpr int kk = 0;
for (int jj = j*ratio.y; jj < (j+1)*ratio.y; ++jj) {
for (int ii = i*ratio.x; ii < (i+1)*ratio.x; ++ii) {
cvol += vfrac(ii,jj,kk);
}
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
Real eb_flux_reg_cvol (int i, int j, Array4<Real const> const& vfrac,
Dim3 const& ratio, Real threshold) noexcept
{
Real cvol = Real(0.0);
constexpr int kk = 0;
for (int jj = j*ratio.y; jj < (j+1)*ratio.y; ++jj) {
for (int ii = i*ratio.x; ii < (i+1)*ratio.x; ++ii) {
cvol += vfrac(ii,jj,kk);
}
return (cvol > threshold) ? Real(1.0)/cvol : Real(0.0);
}
return (cvol > threshold) ? Real(1.0)/cvol : Real(0.0);
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
Expand Down
22 changes: 10 additions & 12 deletions Src/EB/AMReX_EBFluxRegister_3D_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,19 @@ void eb_flux_reg_crseadd_va(int i, int j, int k, Array4<Real> const& d,
}
}

namespace {
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
Real eb_flux_reg_cvol (int i, int j, int k, Array4<Real const> const& vfrac,
Dim3 const& ratio, Real small) noexcept
{
Real cvol = Real(0.0);
for (int kk = k*ratio.z; kk < (k+1)*ratio.z; ++kk) {
for (int jj = j*ratio.y; jj < (j+1)*ratio.y; ++jj) {
for (int ii = i*ratio.x; ii < (i+1)*ratio.x; ++ii) {
cvol += vfrac(ii,jj,kk);
}
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
Real eb_flux_reg_cvol (int i, int j, int k, Array4<Real const> const& vfrac,
Dim3 const& ratio, Real small) noexcept
{
Real cvol = Real(0.0);
for (int kk = k*ratio.z; kk < (k+1)*ratio.z; ++kk) {
for (int jj = j*ratio.y; jj < (j+1)*ratio.y; ++jj) {
for (int ii = i*ratio.x; ii < (i+1)*ratio.x; ++ii) {
cvol += vfrac(ii,jj,kk);
}
}
return (cvol > small) ? Real(1.0)/cvol : Real(0.0);
}
return (cvol > small) ? Real(1.0)/cvol : Real(0.0);
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
Expand Down
3 changes: 0 additions & 3 deletions Src/EB/AMReX_EB_Slopes_2D_K.H
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include <AMReX_EBFArrayBox.H>
#include <AMReX_EBCellFlag.H>

namespace {

// amrex_calc_slopes_eb calculates the slope in each coordinate direction using a
// least squares linear fit to the 8 nearest neighbors, with the function
// going through the centroid of cell(i,j,k). This does not assume that the cell centroids,
Expand Down Expand Up @@ -882,5 +880,4 @@ amrex_lim_slopes_extdir_eb (int i, int j, int k, int n,
return {alpha_lim[0]*slopes[0],alpha_lim[1]*slopes[1]};
}

}
#endif
Loading

0 comments on commit d78e241

Please sign in to comment.