From a2a22dabc2c4c451807495e75558048c41467482 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Mon, 5 Jun 2023 11:07:28 -0700 Subject: [PATCH] Fix Clang-Tidy Header Filter (#3342) Fix regex in the clang-tidy header filter. The issue was the old regex filtered out headers like AMReX_Any.H (because of its letter n) and AMReX_IntVect.H (because of it's letter t before .H) in addition to files ending with nolint.H. Fix warnings. --- .clang-tidy | 3 +- .github/workflows/cuda.yml | 3 +- Src/Amr/AMReX_Derive.H | 40 +++-- Src/Amr/AMReX_LevelBld.H | 7 +- Src/AmrCore/AMReX_ErrorList.H | 87 ++++++---- Src/AmrCore/AMReX_ErrorList.cpp | 15 +- Src/Base/AMReX_Any.H | 34 ++-- Src/Base/AMReX_Arena.H | 11 +- Src/Base/AMReX_AsyncOut.H | 5 +- Src/Base/AMReX_BArena.H | 14 +- Src/Base/AMReX_BoxArray.cpp | 2 +- Src/Base/AMReX_BoxDomain.H | 9 +- Src/Base/AMReX_BoxList.H | 39 ++--- Src/Base/AMReX_CArena.H | 28 +-- Src/Base/AMReX_DistributionMapping.H | 34 ++-- Src/Base/AMReX_DistributionMapping.cpp | 8 +- Src/Base/AMReX_FabConv.H | 18 +- Src/Base/AMReX_GpuAsyncArray.H | 4 +- Src/Base/AMReX_GpuDevice.H | 14 +- Src/Base/AMReX_GpuDevice.cpp | 6 +- Src/Base/AMReX_GpuUtility.H | 6 +- Src/Base/AMReX_GpuUtility.cpp | 4 +- Src/Base/AMReX_IntVect.H | 41 +++-- Src/Base/AMReX_Machine.H | 5 +- Src/Base/AMReX_Morton.H | 12 +- Src/Base/AMReX_MultiFabUtil.H | 6 +- Src/Base/AMReX_MultiFabUtilI.H | 5 +- Src/Base/AMReX_Orientation.H | 28 ++- Src/Base/AMReX_PArena.H | 18 +- Src/Base/AMReX_ParallelContext.H | 23 +-- Src/Base/AMReX_Periodicity.H | 10 +- Src/Base/AMReX_PhysBCFunct.H | 79 +++++---- Src/Base/AMReX_PhysBCFunct.cpp | 16 +- Src/Base/AMReX_Print.H | 26 ++- Src/Base/AMReX_RealBox.H | 31 ++-- Src/Base/AMReX_RealVect.H | 47 +++-- Src/Base/AMReX_TagParallelFor.H | 14 +- Src/Base/AMReX_TypeTraits.H | 2 + Src/Base/AMReX_Utility.H | 9 +- Src/Base/AMReX_Utility.cpp | 7 +- Src/Boundary/AMReX_BoundCond.H | 4 +- Src/Boundary/AMReX_FabSet.H | 16 +- Src/EB/AMReX_EB2_IF_AllRegular.H | 1 - Src/EB/AMReX_EB2_IF_Box.H | 4 +- Src/EB/AMReX_EB2_IF_Complement.H | 4 +- Src/EB/AMReX_EB2_IF_Cylinder.H | 4 +- Src/EB/AMReX_EB2_IF_DevicePtr.H | 4 +- Src/EB/AMReX_EB2_IF_Difference.H | 4 +- Src/EB/AMReX_EB2_IF_Ellipsoid.H | 4 +- Src/EB/AMReX_EB2_IF_Extrusion.H | 4 +- Src/EB/AMReX_EB2_IF_Intersection.H | 16 +- Src/EB/AMReX_EB2_IF_Lathe.H | 4 +- Src/EB/AMReX_EB2_IF_Parser.H | 4 +- Src/EB/AMReX_EB2_IF_Plane.H | 4 +- Src/EB/AMReX_EB2_IF_Polynomial.H | 7 +- Src/EB/AMReX_EB2_IF_Rotation.H | 8 +- Src/EB/AMReX_EB2_IF_Scale.H | 4 +- Src/EB/AMReX_EB2_IF_Sphere.H | 4 +- Src/EB/AMReX_EB2_IF_Spline.H | 10 +- Src/EB/AMReX_EB2_IF_Torus.H | 4 +- Src/EB/AMReX_EB2_IF_Translation.H | 4 +- Src/EB/AMReX_EB2_IF_Union.H | 16 +- Src/EB/AMReX_EB2_IndexSpace_chkpt_file.H | 10 +- Src/EB/AMReX_EBDataCollection.H | 20 +-- Src/EB/AMReX_EB_STL_utils.H | 9 +- Src/EB/AMReX_EB_chkpt_file.H | 2 +- Src/EB/AMReX_EB_utils.H | 4 +- Src/EB/AMReX_EB_utils.cpp | 8 +- Src/EB/AMReX_algoim_K.H | 16 +- Src/EB/AMReX_distFcnElement.H | 36 ++-- Src/Extern/HYPRE/AMReX_HypreSolver.H | 24 +-- Src/Extern/PETSc/AMReX_PETSc.cpp | 4 +- .../MLMG/AMReX_MLABecLaplacian.H | 72 ++++---- Src/LinearSolvers/MLMG/AMReX_MLALaplacian.H | 55 +++--- Src/LinearSolvers/MLMG/AMReX_MLCGSolver.H | 20 ++- Src/LinearSolvers/MLMG/AMReX_MLCellABecLap.H | 4 +- Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H | 2 +- .../MLMG/AMReX_MLEBNodeFDLaplacian.H | 66 ++++---- .../MLMG/AMReX_MLEBNodeFDLaplacian.cpp | 8 +- Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.H | 36 ++-- Src/LinearSolvers/MLMG/AMReX_MLEBTensor_K.H | 2 +- Src/LinearSolvers/MLMG/AMReX_MLNodeLap_2D_K.H | 26 ++- Src/LinearSolvers/MLMG/AMReX_MLNodeLap_3D_K.H | 30 ++-- .../MLMG/AMReX_MLNodeLaplacian.H | 80 ++++----- .../MLMG/AMReX_MLNodeLaplacian_hypre.cpp | 20 +-- Src/LinearSolvers/MLMG/AMReX_MLNodeLinOp.H | 10 +- .../MLMG/AMReX_MLNodeTensorLaplacian.H | 56 +++--- .../MLMG/AMReX_MLNodeTensorLaplacian.cpp | 8 +- Src/LinearSolvers/MLMG/AMReX_MLPoisson_2D_K.H | 10 +- Src/LinearSolvers/MLMG/AMReX_MLTensorOp.H | 30 ++-- Src/Particle/AMReX_DenseBins.H | 24 ++- Src/Particle/AMReX_NeighborList.H | 58 +++---- Src/Particle/AMReX_NeighborParticlesGPUImpl.H | 10 +- Src/Particle/AMReX_NeighborParticlesI.H | 20 +-- Src/Particle/AMReX_ParticleCommunication.H | 62 +++---- Src/Particle/AMReX_ParticleCommunication.cpp | 4 +- Src/Particle/AMReX_ParticleIO.H | 160 +++++++++--------- Src/Particle/AMReX_ParticleInit.H | 36 ++-- Src/Particle/AMReX_ParticleTile.H | 74 ++++---- Src/Particle/AMReX_ParticleTransformation.H | 12 +- Src/Particle/AMReX_SparseBins.H | 22 +-- .../Exec/SingleVortex/face_velocity_2d_K.H | 20 +-- .../Exec/SingleVortex/face_velocity_3d_K.H | 24 +-- .../Exec/UniformVelocity/face_velocity_2d_K.H | 6 +- .../Exec/UniformVelocity/face_velocity_3d_K.H | 6 +- Tests/Amr/Advection_AmrLevel/Source/Adv.cpp | 6 +- .../Advection_AmrLevel/Source/AmrLevelAdv.H | 30 +--- .../Advection_AmrLevel/Source/bc_nullfill.cpp | 16 +- Tests/LinearSolvers/ABecLap_SP/MyTest.H | 6 +- Tests/LinearSolvers/ABecLaplacian_C/MyTest.H | 2 +- Tests/LinearSolvers/NodalPoisson/MyTest.H | 4 +- 111 files changed, 1099 insertions(+), 1075 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index b2ba7d85eed..84742de4e64 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -42,4 +42,5 @@ Checks: > mpi-* ' -HeaderFilterRegex: '[^n][^o][^l][^i][^n][^t]\.H$' +# Files not ending with nolint.H will be filtered in. +HeaderFilterRegex: '([^n].....|[^o]....|[^l]...|[^i]..|[^n].|[^t])\.H$' diff --git a/.github/workflows/cuda.yml b/.github/workflows/cuda.yml index a9f4e98dfee..95b42e87896 100644 --- a/.github/workflows/cuda.yml +++ b/.github/workflows/cuda.yml @@ -149,11 +149,12 @@ jobs: nvfortran --version cmake --version + # Disable Fortran due to space limit cmake -S . -B build \ -DCMAKE_VERBOSE_MAKEFILE=ON \ -DAMReX_ENABLE_TESTS=ON \ -DAMReX_PARTICLES=ON \ - -DAMReX_FORTRAN=ON \ + -DAMReX_FORTRAN=OFF \ -DAMReX_GPU_BACKEND=CUDA \ -DCMAKE_C_COMPILER=$(which nvc) \ -DCMAKE_CXX_COMPILER=$(which nvc++) \ diff --git a/Src/Amr/AMReX_Derive.H b/Src/Amr/AMReX_Derive.H index 672f071014e..7ce0c079de3 100644 --- a/Src/Amr/AMReX_Derive.H +++ b/Src/Amr/AMReX_Derive.H @@ -122,60 +122,65 @@ public: */ ~DeriveRec (); + DeriveRec (DeriveRec const&) = delete; + DeriveRec (DeriveRec &&) = delete; + DeriveRec& operator= (DeriveRec const&) = delete; + DeriveRec& operator= (DeriveRec &&) = delete; + /** * \brief The name of the derived type. */ - const std::string& name () const noexcept; + [[nodiscard]] const std::string& name () const noexcept; /** * \brief The names of components * * \param comp */ - const std::string& variableName (int comp) const noexcept; + [[nodiscard]] const std::string& variableName (int comp) const noexcept; /** * \brief The IndexType of the derived type. */ - IndexType deriveType () const noexcept; + [[nodiscard]] IndexType deriveType () const noexcept; /** * \brief The DeriveFunc used to calculate the derived type. */ - DeriveFunc derFunc () const noexcept; - DeriveFunc3D derFunc3D () const noexcept; - DeriveFuncFab derFuncFab () const noexcept; + [[nodiscard]] DeriveFunc derFunc () const noexcept; + [[nodiscard]] DeriveFunc3D derFunc3D () const noexcept; + [[nodiscard]] DeriveFuncFab derFuncFab () const noexcept; /** * \brief Maps state data box to derived data box. */ - DeriveBoxMap boxMap () const noexcept; + [[nodiscard]] DeriveBoxMap boxMap () const noexcept; /** * \brief Type of interpolater to use in computing derived type. */ - Interpolater* interp () const noexcept; + [[nodiscard]] Interpolater* interp () const noexcept; /** * \brief Number of components in the derived type. */ - int numDerive () const noexcept; + [[nodiscard]] int numDerive () const noexcept; /** * \brief Number of different chunks of state data needed for derived type. */ - int numRange () const noexcept; + [[nodiscard]] int numRange () const noexcept; /** * \brief Total number of state variables needed for derived type. */ - int numState () const noexcept; + [[nodiscard]] int numState () const noexcept; /** * \brief The boundary conditions. */ - const int* getBC () const noexcept; - const int* getBC3D () const noexcept; + [[nodiscard]] const int* getBC () const noexcept; + [[nodiscard]] const int* getBC3D () const noexcept; /** * \brief Sets state_indx, src_comp and num_comp for the kth @@ -344,22 +349,25 @@ public: */ DeriveList () = default; + ~DeriveList () = default; DeriveList (const DeriveList&) = delete; + DeriveList (DeriveList &&) = delete; DeriveList& operator= (const DeriveList&) = delete; + DeriveList& operator= (DeriveList &&) = delete; /** * \brief Determines whether quantity identified by \ is in the registry. * * \param name */ - bool canDerive (const std::string& name) const; + [[nodiscard]] bool canDerive (const std::string& name) const; /** * \brief Access the particular record in registry. * * \param name */ - const DeriveRec* get (const std::string& name) const; + [[nodiscard]] const DeriveRec* get (const std::string& name) const; /** * \brief Adds another entry to the registry. @@ -456,7 +464,7 @@ public: int s_comp, int n_comp); - std::list& dlist (); + [[nodiscard]] std::list& dlist (); void clear () { lst.clear(); } diff --git a/Src/Amr/AMReX_LevelBld.H b/Src/Amr/AMReX_LevelBld.H index de5b9d1a258..8b421265bfc 100644 --- a/Src/Amr/AMReX_LevelBld.H +++ b/Src/Amr/AMReX_LevelBld.H @@ -23,7 +23,12 @@ class LevelBld { public: - virtual ~LevelBld () {} + virtual ~LevelBld () = default; + LevelBld () noexcept = default; + LevelBld (LevelBld const&) = default; + LevelBld (LevelBld &&) noexcept = default; + LevelBld& operator= (LevelBld const&) = default; + LevelBld& operator= (LevelBld &&) noexcept = default; /** * \brief Perform any problem-dependent setup such as physical diff --git a/Src/AmrCore/AMReX_ErrorList.H b/Src/AmrCore/AMReX_ErrorList.H index b96f9ae05e3..fe2f88b2476 100644 --- a/Src/AmrCore/AMReX_ErrorList.H +++ b/Src/AmrCore/AMReX_ErrorList.H @@ -142,13 +142,18 @@ public: * \brief Return a ptr to a clone of this object. * It is the responsibility of the caller to delete the result. */ - virtual ErrorFunc* clone () const; + [[nodiscard]] virtual ErrorFunc* clone () const; /** * \brief Destructor. */ virtual ~ErrorFunc () = default; + ErrorFunc (ErrorFunc const&) = default; + ErrorFunc (ErrorFunc &&) = delete; + ErrorFunc& operator= (ErrorFunc const&) = default; + ErrorFunc& operator= (ErrorFunc &&) = delete; + /** * \brief Tag cells using "regular" function. * @@ -212,8 +217,8 @@ public: const int* level) const; protected: - ErrorFuncDefault m_func; - ErrorFunc3DDefault m_func3D; + ErrorFuncDefault m_func{nullptr}; + ErrorFunc3DDefault m_func3D{nullptr}; }; class ErrorFunc2 { @@ -236,13 +241,18 @@ public: * \brief Return a ptr to a clone of this object. * It is the responsibility of the caller to delete the result. */ - virtual ErrorFunc2* clone () const; + [[nodiscard]] virtual ErrorFunc2* clone () const; /** * \brief Destructor. */ virtual ~ErrorFunc2 () = default; + ErrorFunc2 (ErrorFunc2 const&) = default; + ErrorFunc2 (ErrorFunc2 &&) = delete; + ErrorFunc2& operator= (ErrorFunc2 const&) = default; + ErrorFunc2& operator= (ErrorFunc2 &&) = delete; + /** * \brief Tag cells cells using "v2" interface * @@ -271,7 +281,7 @@ public: const Real* dx, const int* level, const Real* avg) const; protected: - ErrorFunc2Default m_func; + ErrorFunc2Default m_func{nullptr}; }; /** @@ -288,28 +298,33 @@ public: ErrorRec (std::string nm, int ng, ErrorType etyp, const ErrorRec::ErrorFunc& f); - virtual ~ErrorRec(); + virtual ~ErrorRec (); + + ErrorRec (ErrorRec const&) = delete; + ErrorRec (ErrorRec &&) = delete; + ErrorRec& operator= (ErrorRec const&) = delete; + ErrorRec& operator= (ErrorRec &&) = delete; /** * \brief The name of the quantity to derive. */ - const std::string& name () const noexcept; + [[nodiscard]] const std::string& name () const noexcept; /** * \brief The number of extra zones needed for derivation. */ - int nGrow () const noexcept; + [[nodiscard]] int nGrow () const noexcept; /** * \brief The type of the error tagging. */ - ErrorType errType () const noexcept; + [[nodiscard]] ErrorType errType () const noexcept; /** * \brief The extern "C" functions to do the error tagging. */ - virtual const ErrorRec::ErrorFunc& errFunc () const; - virtual const ErrorRec::ErrorFunc2& errFunc2() const; + [[nodiscard]] virtual const ErrorRec::ErrorFunc& errFunc () const; + [[nodiscard]] virtual const ErrorRec::ErrorFunc2& errFunc2() const; private: @@ -337,12 +352,12 @@ private: class ErrorList { public: - ErrorList() noexcept {} + ErrorList() noexcept = default; /** * \brief The number of ErrorRecs in the list. */ - int size () const noexcept; + [[nodiscard]] int size () const noexcept; /** * \brief Append a new ErrorRec to the list. @@ -363,7 +378,7 @@ public: const ErrorRec::ErrorFunc2& func); //! The kth ErrorRec. - const ErrorRec& operator[] (int k) const noexcept; + [[nodiscard]] const ErrorRec& operator[] (int k) const noexcept; void clear (bool rs0 = false) { vec.clear(); if(rs0) { vec.resize(0); } } @@ -417,7 +432,12 @@ std::ostream& operator << (std::ostream& os, const ErrorList& elst); struct UserFunc { - virtual ~UserFunc () {} + virtual ~UserFunc () = default; + + UserFunc (UserFunc const&) = default; + UserFunc (UserFunc &&) = delete; + UserFunc& operator= (UserFunc const&) = default; + UserFunc& operator= (UserFunc &&) = delete; virtual void operator() (const amrex::Box& bx, amrex::Array4 const& dat, @@ -429,13 +449,13 @@ std::ostream& operator << (std::ostream& os, const ErrorList& elst); }; explicit AMRErrorTag (const AMRErrorTagInfo& info = AMRErrorTagInfo()) noexcept - : m_test(BOX), m_field(std::string()), m_info(info) {m_ngrow = SetNGrow();} + : m_info(info), m_ngrow(SetNGrow()) {} AMRErrorTag (amrex::Real value, AMRErrorTag::TEST test, - const std::string& field, + std::string field, const AMRErrorTagInfo& info = AMRErrorTagInfo()) noexcept - : m_test(test), m_field(field), m_info(info) + : m_test(test), m_field(std::move(field)), m_info(info) { m_value.resize(info.m_max_level); for (int i = 0; i < m_value.size(); ++i) { @@ -446,30 +466,35 @@ std::ostream& operator << (std::ostream& os, const ErrorList& elst); AMRErrorTag (amrex::Vector value, AMRErrorTag::TEST test, - const std::string& field, + std::string field, const AMRErrorTagInfo& info = AMRErrorTagInfo()) noexcept - : m_test(test), m_field(field), m_info(info) + : m_test(test), m_field(std::move(field)), m_info(info) { - AMREX_ASSERT(value.size() > 0); + AMREX_ASSERT(!value.empty()); m_value.resize(info.m_max_level); for (int i = 0; i < m_value.size() && i < value.size(); ++i) { m_value[i] = value[i]; } // If the user didn't provided a value for every level, // assume the last value holds for all higher levels. - for (int i = value.size(); i < m_value.size(); ++i) { + for (auto i = int(value.size()); i < m_value.size(); ++i) { m_value[i] = value[value.size()-1]; } m_ngrow = SetNGrow(); } AMRErrorTag (AMRErrorTag::UserFunc* userfunc, - const std::string& field, + std::string field, int ngrow, const AMRErrorTagInfo& info = AMRErrorTagInfo()) noexcept - : m_userfunc(userfunc), m_field(field), m_info(info), m_ngrow(ngrow) {} + : m_userfunc(userfunc), m_field(std::move(field)), m_info(info), m_ngrow(ngrow) {} + + virtual ~AMRErrorTag () = default; - virtual ~AMRErrorTag () {} + AMRErrorTag (AMRErrorTag const&) = default; + AMRErrorTag (AMRErrorTag &&) = delete; + AMRErrorTag& operator= (AMRErrorTag const&) = default; + AMRErrorTag& operator= (AMRErrorTag &&) = delete; virtual void operator() (amrex::TagBoxArray& tb, const amrex::MultiFab* mf, @@ -479,18 +504,18 @@ std::ostream& operator << (std::ostream& os, const ErrorList& elst); int level, const amrex::Geometry& geom) const noexcept; - int NGrow() const noexcept {return m_ngrow;} - const std::string& Field () const noexcept {return m_field;} + [[nodiscard]] int NGrow() const noexcept {return m_ngrow;} + [[nodiscard]] const std::string& Field () const noexcept {return m_field;} - AMRErrorTagInfo& GetInfo () noexcept {return m_info;} - AMRErrorTagInfo const& GetInfo () const noexcept {return m_info;} + [[nodiscard]] AMRErrorTagInfo& GetInfo () noexcept {return m_info;} + [[nodiscard]] AMRErrorTagInfo const& GetInfo () const noexcept {return m_info;} void SetInfo (AMRErrorTagInfo const& info) noexcept {m_info = info;} protected: - int SetNGrow () const noexcept; + [[nodiscard]] int SetNGrow () const noexcept; Vector m_value; - TEST m_test; + TEST m_test{BOX}; UserFunc* m_userfunc = nullptr; std::string m_field; AMRErrorTagInfo m_info; diff --git a/Src/AmrCore/AMReX_ErrorList.cpp b/Src/AmrCore/AMReX_ErrorList.cpp index 9448a4beddb..91ded63ce3b 100644 --- a/Src/AmrCore/AMReX_ErrorList.cpp +++ b/Src/AmrCore/AMReX_ErrorList.cpp @@ -7,21 +7,15 @@ namespace amrex { -ErrorRec::ErrorFunc::ErrorFunc () - : - m_func(nullptr), - m_func3D(nullptr) -{} +ErrorRec::ErrorFunc::ErrorFunc () = default; ErrorRec::ErrorFunc::ErrorFunc (ErrorFuncDefault inFunc) : - m_func(inFunc), - m_func3D(nullptr) + m_func(inFunc) {} ErrorRec::ErrorFunc::ErrorFunc (ErrorFunc3DDefault inFunc) : - m_func(nullptr), m_func3D(inFunc) {} @@ -71,10 +65,7 @@ ErrorRec::ErrorFunc::operator () (int* tag, const int* tlo, const int* thi, } // \endcond -ErrorRec::ErrorFunc2::ErrorFunc2 () - : - m_func(nullptr) -{} +ErrorRec::ErrorFunc2::ErrorFunc2 () = default; ErrorRec::ErrorFunc2::ErrorFunc2 (ErrorFunc2Default inFunc) : diff --git a/Src/Base/AMReX_Any.H b/Src/Base/AMReX_Any.H index d0cc463aa04..2b9edc084b7 100644 --- a/Src/Base/AMReX_Any.H +++ b/Src/Base/AMReX_Any.H @@ -4,13 +4,14 @@ #include #include +#include namespace amrex { /** - * This class is similar to std::any. However, amrex::Any is for storing + * This class is similar to std::any. However, amrex::Any can store * move-only types (e.g., amrex::MultiFab), whereas std::any is for copy - * constructible types. An object of this class is non-copyable. + * constructible types only. An object of this class is non-copyable. */ class Any { @@ -26,20 +27,22 @@ public: Any& operator= (Any && rhs) = default; //! Constructs by moving the given object. - template - Any (MF && mf) + template >,int> = 0> + Any (MF && mf) // NOLINT(bugprone-forwarding-reference-overload) : m_ptr(std::make_unique >(std::forward(mf))) {} //! Assigns by moving the given object. - template + template >,int> = 0> Any& operator= (MF && mf) { m_ptr = std::make_unique >(std::forward(mf)); return *this; } //! Returns the contained type. - const std::type_info& Type () const { + [[nodiscard]] const std::type_info& Type () const { if (m_ptr) { return m_ptr->Type(); } else { @@ -49,7 +52,7 @@ public: //! Returns a reference to the contained object. template - MF& get () { + [[nodiscard]] MF& get () { if (auto p0 = dynamic_cast*>(m_ptr.get())) { return p0->m_mf; } else { @@ -59,7 +62,7 @@ public: //! Returns a const reference to the contained object. template - MF const& get () const { + [[nodiscard]] MF const& get () const { if (auto p0 = dynamic_cast*>(m_ptr.get())) { return p0->m_mf; } else if (auto p1 = dynamic_cast*>(m_ptr.get())) { @@ -70,26 +73,27 @@ public: } template - bool is () const { return Type() == typeid(MF); } + [[nodiscard]] bool is () const { return Type() == typeid(MF); } - bool hasValue () const { return m_ptr != nullptr; } + [[nodiscard]] bool hasValue () const { return m_ptr != nullptr; } private: - struct innards_base { - virtual const std::type_info& Type () const = 0; + struct innards_base // NOLINT(cppcoreguidelines-special-member-functions) + { + [[nodiscard]] virtual const std::type_info& Type () const = 0; virtual ~innards_base () = default; }; template - struct innards : innards_base + struct innards final : innards_base // NOLINT(cppcoreguidelines-special-member-functions) { innards (MF && mf) : m_mf(std::forward(mf)) {} - virtual ~innards () = default; + ~innards () final = default; - virtual const std::type_info& Type () const override { + [[nodiscard]] const std::type_info& Type () const final { return typeid(MF); } diff --git a/Src/Base/AMReX_Arena.H b/Src/Base/AMReX_Arena.H index 47de88a64ec..5205bed6a16 100644 --- a/Src/Base/AMReX_Arena.H +++ b/Src/Base/AMReX_Arena.H @@ -86,12 +86,19 @@ class Arena public: virtual ~Arena () = default; + Arena () noexcept = default; + + Arena (const Arena& rhs) = delete; + Arena (Arena&& rhs) = delete; + Arena& operator= (const Arena& rhs) = delete; + Arena& operator= (Arena&& rhs) = delete; + /** * Allocate a dynamic memory arena * \param sz size of the memory request * \return a pointer to the allocated memory */ - virtual void* alloc (std::size_t sz) = 0; + [[nodiscard]] virtual void* alloc (std::size_t sz) = 0; /** * \brief A pure virtual function for deleting the arena pointed to by pt */ @@ -120,7 +127,7 @@ public: * const funciton because it may attempt to release memory back to the * system. */ - virtual bool hasFreeDeviceMemory (std::size_t sz); + [[nodiscard]] virtual bool hasFreeDeviceMemory (std::size_t sz); /** * \brief Add this Arena to the list of Arenas that are profiled by TinyProfiler. diff --git a/Src/Base/AMReX_AsyncOut.H b/Src/Base/AMReX_AsyncOut.H index 7d8cf4a6735..3ac01215f51 100644 --- a/Src/Base/AMReX_AsyncOut.H +++ b/Src/Base/AMReX_AsyncOut.H @@ -4,8 +4,7 @@ #include -namespace amrex { -namespace AsyncOut { +namespace amrex::AsyncOut { struct WriteInfo { int ifile; @@ -31,6 +30,6 @@ void Finish (); // If you want to wait for jobs submitted to finish void Wait (); // Wait for my turn to write file. This is not for waiting for job to finish. void Notify (); // Notify next MPI process in the same file. -}} +} #endif diff --git a/Src/Base/AMReX_BArena.H b/Src/Base/AMReX_BArena.H index 10dbde88667..9a3b4aa0f1b 100644 --- a/Src/Base/AMReX_BArena.H +++ b/Src/Base/AMReX_BArena.H @@ -21,18 +21,18 @@ public: * \brief Allocates a dynamic memory arena of size sz. * Returns a pointer to this memory. */ - virtual void* alloc (std::size_t sz) override final; + [[nodiscard]] void* alloc (std::size_t sz) final; /** * \brief Deletes the arena pointed to by pt. */ - virtual void free (void* pt) override final; + void free (void* pt) final; - virtual bool isDeviceAccessible () const override final; - virtual bool isHostAccessible () const override final; + [[nodiscard]] bool isDeviceAccessible () const final; + [[nodiscard]] bool isHostAccessible () const final; - virtual bool isManaged () const override final; - virtual bool isDevice () const override final; - virtual bool isPinned () const override final; + [[nodiscard]] bool isManaged () const final; + [[nodiscard]] bool isDevice () const final; + [[nodiscard]] bool isPinned () const final; }; } diff --git a/Src/Base/AMReX_BoxArray.cpp b/Src/Base/AMReX_BoxArray.cpp index feef9be3a42..92312cdd624 100644 --- a/Src/Base/AMReX_BoxArray.cpp +++ b/Src/Base/AMReX_BoxArray.cpp @@ -1105,7 +1105,7 @@ BoxArray::minimalBox (Long& npts_avg_box) const } auto cr = crseRatio(); minbox.coarsen(cr).convert(ixType()); - npts_tot /= AMREX_D_TERM(cr[0],*cr[1],*cr[2]); + npts_tot /= AMREX_D_TERM(Long(cr[0]),*cr[1],*cr[2]); npts_avg_box = npts_tot / N; return minbox; } diff --git a/Src/Base/AMReX_BoxDomain.H b/Src/Base/AMReX_BoxDomain.H index 1ec6cfec979..488b8a6aef9 100644 --- a/Src/Base/AMReX_BoxDomain.H +++ b/Src/Base/AMReX_BoxDomain.H @@ -80,11 +80,6 @@ public: //! Construct an empty BoxDomain of IndexType itype. explicit BoxDomain (IndexType itype); - BoxDomain (const BoxDomain& rhs) = default; - BoxDomain (BoxDomain&& rhs) = default; - BoxDomain& operator= (const BoxDomain& rhs) = default; - BoxDomain& operator= (BoxDomain&& rhs) = default; - //! Add a Box to the domain. void add (const Box& b); @@ -98,7 +93,7 @@ public: * Returns True if this BoxDomain is valid. Checks for * disjointness. Returns true if the BoxDomain is empty. */ - bool ok () const; + [[nodiscard]] bool ok () const; //! Promoted from BoxList. using BoxList::clear; @@ -137,7 +132,7 @@ public: using BoxList::shiftHalf; //! Return a const reference to the underlying BoxList of this BoxDomain. - const BoxList& boxList () const; + [[nodiscard]] const BoxList& boxList () const; //! Are the BoxDomains equal? bool operator== (const BoxDomain& rhs) const; diff --git a/Src/Base/AMReX_BoxList.H b/Src/Base/AMReX_BoxList.H index 734c9698493..f14a6ed8cd9 100644 --- a/Src/Base/AMReX_BoxList.H +++ b/Src/Base/AMReX_BoxList.H @@ -82,6 +82,7 @@ public: //! Make a BoxList consisting of nboxes Boxes chopped in dir-direction from a single Box BoxList (const Box& bx, int nboxes, Direction dir); + ~BoxList () = default; BoxList (const BoxList& rhs) = default; BoxList (BoxList&& rhs) = default; BoxList& operator= (const BoxList& rhs) = default; @@ -92,9 +93,9 @@ public: //! Append a Box to this BoxList. void push_back (const Box& bn) { BL_ASSERT(ixType() == bn.ixType()); m_lbox.push_back(bn); } - Box& front () noexcept { BL_ASSERT(!m_lbox.empty()); return m_lbox.front(); } + [[nodiscard]] Box& front () noexcept { BL_ASSERT(!m_lbox.empty()); return m_lbox.front(); } - const Box& front () const noexcept { BL_ASSERT(!m_lbox.empty()); return m_lbox.front(); } + [[nodiscard]] const Box& front () const noexcept { BL_ASSERT(!m_lbox.empty()); return m_lbox.front(); } //! Join the BoxList to ourselves. void join (const BoxList& blist); @@ -106,35 +107,35 @@ public: //! Remove all Boxes from this BoxList. void clear (); //! The number of Boxes in this BoxList. - Long size () const noexcept { return m_lbox.size(); } + [[nodiscard]] Long size () const noexcept { return m_lbox.size(); } - std::size_t capacity () const noexcept { return m_lbox.capacity(); } + [[nodiscard]] std::size_t capacity () const noexcept { return m_lbox.capacity(); } - iterator begin () noexcept { return m_lbox.begin(); } - const_iterator begin () const noexcept { return m_lbox.cbegin(); } - const_iterator cbegin () const noexcept { return m_lbox.cbegin(); } + [[nodiscard]] iterator begin () noexcept { return m_lbox.begin(); } + [[nodiscard]] const_iterator begin () const noexcept { return m_lbox.cbegin(); } + [[nodiscard]] const_iterator cbegin () const noexcept { return m_lbox.cbegin(); } - iterator end () noexcept { return m_lbox.end(); } - const_iterator end () const noexcept { return m_lbox.cend(); } - const_iterator cend () const noexcept { return m_lbox.cend(); } + [[nodiscard]] iterator end () noexcept { return m_lbox.end(); } + [[nodiscard]] const_iterator end () const noexcept { return m_lbox.cend(); } + [[nodiscard]] const_iterator cend () const noexcept { return m_lbox.cend(); } /** * \brief True if this BoxList is valid; i.e. all the Boxes are * valid and they all have the same IndexType. Also returns * true if the BoxList is empty. */ - bool ok () const noexcept; + [[nodiscard]] bool ok () const noexcept; //! Is this BoxList equal to rhs? bool operator== (const BoxList& rhs) const; //! Is this BoxList notequal to rhs? bool operator!= (const BoxList& rhs) const; //! Is this BoxList empty? - bool isEmpty () const noexcept { return m_lbox.empty(); } + [[nodiscard]] bool isEmpty () const noexcept { return m_lbox.empty(); } //! Is this BoxList not empty? - bool isNotEmpty () const noexcept { return !m_lbox.empty(); } + [[nodiscard]] bool isNotEmpty () const noexcept { return !m_lbox.empty(); } //! True if the set of intersecting Boxes is empty. - bool isDisjoint () const; + [[nodiscard]] bool isDisjoint () const; //! True if all Boxes in bl are contained in this BoxList. - bool contains (const BoxList& bl) const; + [[nodiscard]] bool contains (const BoxList& bl) const; //! Modify this BoxList to contain only its intersection with Box b. BoxList& intersect (const Box& b); //! Modify this BoxList to contain only its intersection with BoxList bl. @@ -185,9 +186,9 @@ public: //! Forces each Box in the BoxList to have dimth side of length <= chunk[dim]. BoxList& maxSize (const IntVect& chunk); //! Returns smallest Box that contains all Boxes in this BoxList. - Box minimalBox () const; + [[nodiscard]] Box minimalBox () const; //! Returns the IndexType of Boxes in this BoxList. - IndexType ixType () const noexcept { return btype; } + [[nodiscard]] IndexType ixType () const noexcept { return btype; } //! Set the type of the BoxList. It's an error if the BoxList isn't empty. void set (IndexType ixtyp) noexcept { BL_ASSERT(m_lbox.empty()); btype = ixtyp; } /** @@ -208,9 +209,9 @@ public: BoxList& convert (IndexType typ) noexcept; //! Returns a reference to the Vector. - Vector& data () noexcept { return m_lbox; } + [[nodiscard]] Vector& data () noexcept { return m_lbox; } //! Returns a constant reference to the Vector. - const Vector& data () const noexcept { return m_lbox; } + [[nodiscard]] const Vector& data () const noexcept { return m_lbox; } void swap (BoxList& rhs) { std::swap(m_lbox, rhs.m_lbox); diff --git a/Src/Base/AMReX_CArena.H b/Src/Base/AMReX_CArena.H index d50a3b90cb3..ee081d88f82 100644 --- a/Src/Base/AMReX_CArena.H +++ b/Src/Base/AMReX_CArena.H @@ -37,21 +37,23 @@ public: CArena (std::size_t hunk_size = 0, ArenaInfo info = ArenaInfo()); CArena (const CArena& rhs) = delete; + CArena (CArena&& rhs) = delete; CArena& operator= (const CArena& rhs) = delete; + CArena& operator= (CArena&& rhs) = delete; //! The destructor. - virtual ~CArena () override; + ~CArena () override; //! Allocate some memory. - virtual void* alloc (std::size_t nbytes) override final; + [[nodiscard]] void* alloc (std::size_t nbytes) final; /** * \brief Free up allocated memory. Merge neighboring free memory chunks * into largest possible chunk. */ - virtual void free (void* vp) override final; + void free (void* vp) final; - virtual std::size_t freeUnused () override final; + std::size_t freeUnused () final; /** * \brief Does the device have enough free memory for allocating this @@ -59,13 +61,13 @@ public: * const funciton because it may attempt to release memory back to the * system. */ - virtual bool hasFreeDeviceMemory (std::size_t sz) override; + [[nodiscard]] bool hasFreeDeviceMemory (std::size_t sz) final; /** * \brief Add this Arena to the list of Arenas that are profiled by TinyProfiler. * \param memory_name The name of this arena in the TinyProfiler output. */ - virtual void registerForProfiling (const std::string& memory_name) override; + void registerForProfiling (const std::string& memory_name) final; //! The current amount of heap space used by the CArena object. std::size_t heap_space_used () const noexcept; @@ -85,7 +87,7 @@ public: protected: - virtual std::size_t freeUnused_protected () override final; + std::size_t freeUnused_protected () final; //! The nodes in our free list and block list. class Node @@ -98,7 +100,7 @@ protected: //! The "less-than" operator. bool operator< (const Node& rhs) const noexcept { - return std::less()(m_block, rhs.m_block); + return std::less<>{}(m_block, rhs.m_block); } //! The equality operator. @@ -108,25 +110,25 @@ protected: } //! The block address. - void* block () const noexcept { return m_block; } + [[nodiscard]] void* block () const noexcept { return m_block; } //! Set block address. void block (void* blk) noexcept { m_block = blk; } //! The size of the memory block. - std::size_t size () const noexcept { return m_size; } + [[nodiscard]] std::size_t size () const noexcept { return m_size; } //! Set size. void size (std::size_t sz) noexcept { m_size = sz; } - void* owner () const noexcept { return m_owner; } + [[nodiscard]] void* owner () const noexcept { return m_owner; } - bool coalescable (const Node& rhs) const noexcept { + [[nodiscard]] bool coalescable (const Node& rhs) const noexcept { return m_owner == rhs.m_owner; } //! Get the MemStat object of the function where this block was allocated. - MemStat* mem_stat () const { return m_stat; } + [[nodiscard]] MemStat* mem_stat () const { return m_stat; } struct hash { std::size_t operator() (const Node& n) const noexcept { diff --git a/Src/Base/AMReX_DistributionMapping.H b/Src/Base/AMReX_DistributionMapping.H index 44fedb76c65..dc301d1819d 100644 --- a/Src/Base/AMReX_DistributionMapping.H +++ b/Src/Base/AMReX_DistributionMapping.H @@ -99,18 +99,18 @@ class DistributionMapping * ProcessorMap()[i] is an integer in the interval [0, NCPU) where * NCPU is the number of CPUs being used. */ - const Vector& ProcessorMap () const noexcept; + [[nodiscard]] const Vector& ProcessorMap () const noexcept; //! Length of the underlying processor map. - Long size () const noexcept { return m_ref->m_pmap.size(); } - Long capacity () const noexcept { return m_ref->m_pmap.capacity(); } - bool empty () const noexcept { return m_ref->m_pmap.empty(); } + [[nodiscard]] Long size () const noexcept { return Long(m_ref->m_pmap.size()); } + [[nodiscard]] Long capacity () const noexcept { return Long(m_ref->m_pmap.capacity()); } + [[nodiscard]] bool empty () const noexcept { return m_ref->m_pmap.empty(); } //! Number of references to this DistributionMapping - Long linkCount () const noexcept { return m_ref.use_count(); } + [[nodiscard]] Long linkCount () const noexcept { return m_ref.use_count(); } //! Equivalent to ProcessorMap()[index]. - int operator[] (int index) const noexcept { return m_ref->m_pmap[index]; } + [[nodiscard]] int operator[] (int index) const noexcept { return m_ref->m_pmap[index]; } std::istream& readFrom (std::istream& is); @@ -137,7 +137,7 @@ class DistributionMapping void SFCProcessorMap (const BoxArray& boxes, const std::vector& wgts, int nprocs, Real& efficiency, bool sort=true); void KnapSackProcessorMap (const std::vector& wgts, int nprocs, - Real* efficiency=0, + Real* efficiency=nullptr, bool do_full_knapsack=true, int nmax=std::numeric_limits::max(), bool sort=true); @@ -246,7 +246,7 @@ class DistributionMapping */ static std::vector > makeSFC (const BoxArray& ba, bool use_box_vol=true, - const int nprocs=ParallelContext::NProcsSub() ); + int nprocs=ParallelContext::NProcsSub() ); /** \brief Computes the average cost per MPI rank given a distribution mapping * global cost vector. @@ -295,7 +295,7 @@ private: void RoundRobinDoIt (int nboxes, int nprocs, - std::vector* LIpairV = 0, + std::vector* LIpairV = nullptr, bool sort = true); void KnapSackDoIt (const std::vector& wgts, @@ -338,7 +338,7 @@ private: friend class DistributionMapping; //! Constructors to match those in DistributionMapping .... - Ref () noexcept {} + Ref () = default; explicit Ref (int len) : m_pmap(len) {} @@ -360,20 +360,20 @@ private: public: struct RefID { - RefID () noexcept : data(nullptr) {} + constexpr RefID () noexcept {} // =default does not work due to a clang bug // NOLINT explicit RefID (Ref* data_) noexcept : data(data_) {} - bool operator< (const RefID& rhs) const noexcept { return std::less()(data,rhs.data); } + bool operator< (const RefID& rhs) const noexcept { return std::less<>{}(data,rhs.data); } bool operator== (const RefID& rhs) const noexcept { return data == rhs.data; } bool operator!= (const RefID& rhs) const noexcept { return data != rhs.data; } - const Ref *dataPtr() const noexcept { return data; } + [[nodiscard]] const Ref *dataPtr() const noexcept { return data; } void PrintPtr(std::ostream &os) const { os << data << '\n'; } friend std::ostream& operator<< (std::ostream& os, const RefID& id); private: - Ref* data; + Ref* data = nullptr; }; //! This gives a unique ID of the reference, which is different from dmID above. - RefID getRefID () const noexcept { return RefID { m_ref.get() }; } + [[nodiscard]] RefID getRefID () const noexcept { return RefID { m_ref.get() }; } }; //! Our output operator. @@ -420,8 +420,8 @@ void DistributionMapping::ComputeDistributionMappingEfficiency ( const int nprocs = ParallelDescriptor::NProcs(); Vector wgts(nprocs, T(0)); - const Long nboxes = dm.size(); - for (Long ibox = 0; ibox < nboxes; ++ibox) { + const auto nboxes = int(dm.size()); + for (int ibox = 0; ibox < nboxes; ++ibox) { wgts[dm[ibox]] += cost[ibox]; } diff --git a/Src/Base/AMReX_DistributionMapping.cpp b/Src/Base/AMReX_DistributionMapping.cpp index 51dce01cc52..4f682346302 100644 --- a/Src/Base/AMReX_DistributionMapping.cpp +++ b/Src/Base/AMReX_DistributionMapping.cpp @@ -1462,7 +1462,7 @@ DistributionMapping::SFCProcessorMap (const BoxArray& boxes, int nprocs) m_ref->clear(); m_ref->m_pmap.resize(boxes.size()); - if (boxes.size() < sfc_threshold*nprocs) + if (boxes.size() < Long(sfc_threshold)*nprocs) { KnapSackProcessorMap(boxes,nprocs); } @@ -1493,7 +1493,7 @@ DistributionMapping::SFCProcessorMap (const BoxArray& boxes, m_ref->clear(); m_ref->m_pmap.resize(wgts.size()); - if (boxes.size() < sfc_threshold*nprocs) + if (boxes.size() < Long(sfc_threshold)*nprocs) { KnapSackProcessorMap(wgts,nprocs); } @@ -1516,7 +1516,7 @@ DistributionMapping::SFCProcessorMap (const BoxArray& boxes, m_ref->clear(); m_ref->m_pmap.resize(wgts.size()); - if (boxes.size() < sfc_threshold*nprocs) + if (boxes.size() < Long(sfc_threshold)*nprocs) { KnapSackProcessorMap(wgts,nprocs,&eff); } @@ -1885,7 +1885,7 @@ DistributionMapping::makeSFC (const LayoutData& rcost_local, } std::vector > -DistributionMapping::makeSFC (const BoxArray& ba, bool use_box_vol, const int nprocs) +DistributionMapping::makeSFC (const BoxArray& ba, bool use_box_vol, int nprocs) { BL_PROFILE("makeSFC"); diff --git a/Src/Base/AMReX_FabConv.H b/Src/Base/AMReX_FabConv.H index 92b2f5ec706..78554000f25 100644 --- a/Src/Base/AMReX_FabConv.H +++ b/Src/Base/AMReX_FabConv.H @@ -49,9 +49,9 @@ public: IntDescriptor (Long nb, Ordering ordering = NormalOrder); //! Returns the ordering. - Ordering order () const; + [[nodiscard]] Ordering order () const; //! Returns the number of bytes. - int numBytes () const; + [[nodiscard]] int numBytes () const; //! The equality operator. bool operator== (const IntDescriptor& id) const; //! The inequality operator. @@ -122,23 +122,23 @@ public: */ RealDescriptor (const Long* fr_, const int* ord_, int ordl_); //! Returns the format array as a const Long* - const Long* format () const&; + [[nodiscard]] const Long* format () const&; const Long* format () && = delete; //! Returns const Vector reference to the format array. - const Vector& formatarray () const&; + [[nodiscard]] const Vector& formatarray () const&; const Vector& formatarray () && = delete; //! Returns the order array as a const int* - const int* order () const&; + [[nodiscard]] const int* order () const&; const int* order () && = delete; //! Returns const Vector reference to the order array. - const Vector& orderarray () const&; - + [[nodiscard]] const Vector& orderarray () const&; const Vector& orderarray () && = delete; + //! Returns the number of bytes in the Real. - int numBytes () const; + [[nodiscard]] int numBytes () const; //! The equality operator. bool operator== (const RealDescriptor& rd) const; @@ -157,7 +157,7 @@ public: * \brief Returns a copy of this RealDescriptor on the heap. * The user is responsible for deletion. */ - RealDescriptor* clone () const; + [[nodiscard]] RealDescriptor* clone () const; /** * \brief Returns a RealDescriptor on the heap detailing requested diff --git a/Src/Base/AMReX_GpuAsyncArray.H b/Src/Base/AMReX_GpuAsyncArray.H index 2abcf330359..2258057e079 100644 --- a/Src/Base/AMReX_GpuAsyncArray.H +++ b/Src/Base/AMReX_GpuAsyncArray.H @@ -87,8 +87,8 @@ public: #endif #elif defined(AMREX_USE_SYCL) #ifdef AMREX_USE_CODEPLAY_HOST_TASK - auto pd = d_data; - auto ph = h_data; + auto* pd = d_data; + auto* ph = h_data; auto& q = *(Gpu::gpuStream().queue); try { q.submit([&] (sycl::handler& h) { diff --git a/Src/Base/AMReX_GpuDevice.H b/Src/Base/AMReX_GpuDevice.H index 9564996cb93..2acb7fbdc12 100644 --- a/Src/Base/AMReX_GpuDevice.H +++ b/Src/Base/AMReX_GpuDevice.H @@ -18,8 +18,8 @@ #define AMREX_GPU_MAX_STREAMS 8 +#ifdef AMREX_USE_GPU namespace amrex { - #ifdef AMREX_USE_HIP using gpuDeviceProp_t = hipDeviceProp_t; #elif defined(AMREX_USE_CUDA) @@ -41,8 +41,10 @@ using gpuDeviceProp_t = cudaDeviceProp; int maxParameterSize; }; #endif +} +#endif -namespace Gpu { +namespace amrex::Gpu { class Device { @@ -68,7 +70,7 @@ public: return inSingleStreamRegion() ? 1 : max_gpu_streams; } - static void setStreamIndex (const int idx) noexcept; + static void setStreamIndex (int idx) noexcept; static void resetStreamIndex () noexcept { setStreamIndex(0); } #ifdef AMREX_USE_GPU @@ -113,8 +115,8 @@ public: #endif - static void mem_advise_set_preferred (void* p, const std::size_t sz, const int device); - static void mem_advise_set_readonly (void* p, const std::size_t sz); + static void mem_advise_set_preferred (void* p, std::size_t sz, int device); + static void mem_advise_set_readonly (void* p, std::size_t sz); #ifdef AMREX_USE_GPU static void setNumThreadsMin (int nx, int ny, int nz) noexcept; @@ -300,6 +302,6 @@ dtod_memcpy (void* p_d_dst, const void* p_d_src, const std::size_t sz) noexcept #endif -}} +} #endif diff --git a/Src/Base/AMReX_GpuDevice.cpp b/Src/Base/AMReX_GpuDevice.cpp index f84eed4bed3..d7095314402 100644 --- a/Src/Base/AMReX_GpuDevice.cpp +++ b/Src/Base/AMReX_GpuDevice.cpp @@ -616,7 +616,7 @@ Device::streamIndex (gpuStream_t s) noexcept #endif void -Device::setStreamIndex (const int idx) noexcept +Device::setStreamIndex (int idx) noexcept { amrex::ignore_unused(idx); #ifdef AMREX_USE_GPU @@ -810,7 +810,7 @@ Device::executeGraph(const cudaGraphExec_t &graphExec, bool synch) #endif void -Device::mem_advise_set_preferred (void* p, const std::size_t sz, const int device) +Device::mem_advise_set_preferred (void* p, std::size_t sz, int device) { amrex::ignore_unused(p,sz,device); #if defined(AMREX_USE_CUDA) || defined(AMREX_USE_HIP) @@ -833,7 +833,7 @@ Device::mem_advise_set_preferred (void* p, const std::size_t sz, const int devic } void -Device::mem_advise_set_readonly (void* p, const std::size_t sz) +Device::mem_advise_set_readonly (void* p, std::size_t sz) { amrex::ignore_unused(p,sz); #if defined(AMREX_USE_CUDA) || defined(AMREX_USE_HIP) diff --git a/Src/Base/AMReX_GpuUtility.H b/Src/Base/AMReX_GpuUtility.H index 29fc4915163..0df89140035 100644 --- a/Src/Base/AMReX_GpuUtility.H +++ b/Src/Base/AMReX_GpuUtility.H @@ -171,8 +171,8 @@ namespace Gpu { class StreamIter { public: - StreamIter (const int n, bool is_thread_safe=true) noexcept; - StreamIter (const int n, const StreamItInfo& info, bool is_thread_safe=true) noexcept; + StreamIter (int n, bool is_thread_safe=true) noexcept; + StreamIter (int n, const StreamItInfo& info, bool is_thread_safe=true) noexcept; ~StreamIter (); @@ -183,7 +183,7 @@ namespace Gpu { int operator() () const noexcept { return m_i; } - bool isValid () const noexcept { return m_i < m_n; } + [[nodiscard]] bool isValid () const noexcept { return m_i < m_n; } #if !defined(AMREX_USE_GPU) void operator++ () noexcept { ++m_i; } diff --git a/Src/Base/AMReX_GpuUtility.cpp b/Src/Base/AMReX_GpuUtility.cpp index 0cae969afe4..1eccbf4abd4 100644 --- a/Src/Base/AMReX_GpuUtility.cpp +++ b/Src/Base/AMReX_GpuUtility.cpp @@ -20,13 +20,13 @@ operator<< (std::ostream& os, const dim3& d) namespace Gpu { -StreamIter::StreamIter (const int n, bool is_thread_safe) noexcept +StreamIter::StreamIter (int n, bool is_thread_safe) noexcept : m_n(n), m_i(0), m_threadsafe(is_thread_safe), m_sync(true) { init(); } -StreamIter::StreamIter (const int n, const StreamItInfo& info, bool is_thread_safe) noexcept +StreamIter::StreamIter (int n, const StreamItInfo& info, bool is_thread_safe) noexcept : m_n(n), m_i(0), m_threadsafe(is_thread_safe), m_sync(info.device_sync) { init(); diff --git a/Src/Base/AMReX_IntVect.H b/Src/Base/AMReX_IntVect.H index 5762c50de5a..2b8900248a8 100644 --- a/Src/Base/AMReX_IntVect.H +++ b/Src/Base/AMReX_IntVect.H @@ -84,8 +84,7 @@ public: /** * \brief Construct an IntVect whose components are all zero. */ - AMREX_GPU_HOST_DEVICE - constexpr IntVect () noexcept : vect{AMREX_D_DECL(0,0,0)} {} + constexpr IntVect () noexcept {} // cannot use = default due to Clang bug // NOLINT /** * \brief Construct an IntVect given the specific values for its @@ -127,7 +126,7 @@ public: // dtor, copy-ctor, copy-op=, move-ctor, and move-op= are compiler generated. - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 dim3 () const noexcept { #if (AMREX_SPACEDIM == 1) return Dim3{vect[0],0,0}; @@ -153,7 +152,7 @@ public: /** Sum of all components of this IntVect. */ - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int sum () const noexcept { int retval = AMREX_D_TERM((*this)[0], + (*this)[1], +(*this)[2]); @@ -161,7 +160,7 @@ public: } //! maximum (no absolute values) value - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int max () const noexcept { #if (AMREX_SPACEDIM == 1) @@ -175,7 +174,7 @@ public: } //! minimum (no absolute values) value - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int min () const noexcept { #if (AMREX_SPACEDIM == 1) @@ -189,31 +188,31 @@ public: } //return coordinate with largest value - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int maxDir(bool a_doAbsValue) const noexcept; //! Returns a reference to the i'th coordinate of the IntVect. - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int& operator[] (int i) noexcept { BL_ASSERT(i>=0 && i < AMREX_SPACEDIM); return vect[i]; } //! Returns the i'th coordinate of the IntVect. - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int& operator[] (int i) const noexcept { BL_ASSERT(i>=0 && i < AMREX_SPACEDIM); return vect[i]; } //! Returns a pointer to the first element of the IntVect. - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int* begin () noexcept { return &vect[0]; } //! Returns a pointer to the first element of the IntVect. - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int* begin () const noexcept { return &vect[0]; } //! Returns a pointer to the (last+1) element of the IntVect. - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int* end () noexcept { return &vect[AMREX_SPACEDIM]; } //! Returns a pointer to the (last+1) element of the IntVect. - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int* end () const noexcept { return &vect[AMREX_SPACEDIM]; } //! Set i'th coordinate of IntVect to val. @@ -227,9 +226,9 @@ public: * \brief Returns a const pointer to an array of coordinates of the * IntVect. Useful for arguments to FORTRAN calls. */ - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int* getVect () const& noexcept { return vect; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int* getVect () & noexcept { return vect; } AMREX_GPU_HOST_DEVICE int* getVect () && = delete; @@ -295,7 +294,7 @@ public: * \brief Returns true if this is less than argument for all components. * NOTE: This is NOT a strict weak ordering usable by STL sorting algorithms. */ - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allLT (const IntVect& rhs) const noexcept { return AMREX_D_TERM(vect[0] < rhs[0], && vect[1] < rhs[1], && vect[2] < rhs[2]); @@ -304,7 +303,7 @@ public: * \brief Returns true if this is less than or equal to argument for all components. * NOTE: This is NOT a strict weak ordering usable by STL sorting algorithms. */ - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allLE (const IntVect& rhs) const noexcept { return AMREX_D_TERM(vect[0] <= rhs[0], && vect[1] <= rhs[1], && vect[2] <= rhs[2]); @@ -313,7 +312,7 @@ public: * \brief Returns true if this is greater than argument for all components. * NOTE: This is NOT a strict weak ordering usable by STL sorting algorithms. */ - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allGT (const IntVect& rhs) const noexcept { return AMREX_D_TERM(vect[0] > rhs[0], && vect[1] > rhs[1], && vect[2] > rhs[2]); @@ -322,14 +321,14 @@ public: * \brief Returns true if this is greater than or equal to argument for all components. * NOTE: This is NOT a strict weak ordering usable by STL sorting algorithms. */ - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allGE (const IntVect& rhs) const noexcept { return AMREX_D_TERM(vect[0] >= rhs[0], && vect[1] >= rhs[1], && vect[2] >= rhs[2]); } //! Unary plus -- for completeness. AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - const IntVect operator+ () const noexcept { return *this; } + IntVect operator+ () const noexcept { return *this; } //! Unary Minus -- negates all components. AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVect operator- () const noexcept { return IntVect(AMREX_D_DECL(-vect[0], -vect[1], -vect[2] )); } @@ -547,7 +546,7 @@ private: friend std::ostream& operator<< (std::ostream& os, const IntVect& iv); friend std::istream& operator>> (std::istream& is, IntVect& iv); - int vect[AMREX_SPACEDIM]; + int vect[AMREX_SPACEDIM] = {AMREX_D_DECL(0,0,0)}; }; AMREX_GPU_HOST_DEVICE diff --git a/Src/Base/AMReX_Machine.H b/Src/Base/AMReX_Machine.H index 6489b0f2ca0..dd49c876e28 100644 --- a/Src/Base/AMReX_Machine.H +++ b/Src/Base/AMReX_Machine.H @@ -4,8 +4,7 @@ #include -namespace amrex { -namespace machine { +namespace amrex::machine { void Initialize (); //!< called in amrex::Initialize() @@ -18,6 +17,6 @@ void Finalize (); Vector find_best_nbh (int rank_n, bool flag_local_ranks = false); #endif -}} +} #endif diff --git a/Src/Base/AMReX_Morton.H b/Src/Base/AMReX_Morton.H index 13377fc9ab0..565b46f7fa3 100644 --- a/Src/Base/AMReX_Morton.H +++ b/Src/Base/AMReX_Morton.H @@ -9,8 +9,7 @@ #include -namespace amrex { -namespace Morton { +namespace amrex::Morton { /** * \brief @@ -97,7 +96,7 @@ std::uint32_t makeSpace (std::uint32_t x) noexcept { AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::uint32_t toUInt10 (amrex::Real x, amrex::Real xmin, amrex::Real xmax) noexcept { AMREX_ASSERT(x >= xmin && x < xmax); - constexpr std::uint32_t code_offset = (1u << 10); + constexpr std::uint32_t code_offset = (1U << 10); return (std::uint32_t)(((x - xmin)/(xmax - xmin)) * code_offset); } @@ -117,7 +116,7 @@ std::uint32_t toUInt10 (amrex::Real x, amrex::Real xmin, amrex::Real xmax) noexc AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::uint32_t toUInt16 (amrex::Real x, amrex::Real xmin, amrex::Real xmax) noexcept { AMREX_ASSERT(x >= xmin && x < xmax); - constexpr std::uint32_t code_offset = (1u << 16); + constexpr std::uint32_t code_offset = (1U << 16); return (std::uint32_t)(((x - xmin)/(xmax - xmin)) * code_offset); } @@ -135,8 +134,8 @@ std::uint32_t toUInt16 (amrex::Real x, amrex::Real xmin, amrex::Real xmax) noexc AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::uint32_t toUInt32 (amrex::Real x, amrex::Real xmin, amrex::Real xmax) noexcept { AMREX_ASSERT(x >= xmin && x < xmax); - constexpr unsigned long long code_offset = (1ull << 32); - return (std::uint32_t)(((x - xmin)/(xmax - xmin)) * code_offset); + constexpr unsigned long long code_offset = (1ULL << 32); + return (std::uint32_t)(((x - xmin)/(xmax - xmin)) * Real(code_offset)); } /** @@ -192,6 +191,5 @@ std::uint32_t get32BitCode (const XDim3& p, } #endif -} } #endif diff --git a/Src/Base/AMReX_MultiFabUtil.H b/Src/Base/AMReX_MultiFabUtil.H index 1d3ea6345b4..8c499874a83 100644 --- a/Src/Base/AMReX_MultiFabUtil.H +++ b/Src/Base/AMReX_MultiFabUtil.H @@ -236,8 +236,8 @@ namespace amrex for (MFIter mfi(mf_in); mfi.isValid(); ++mfi) { const Long n = mfi.fabbox().numPts() * mf_in.nComp(); - auto pdst = mf_out[mfi].dataPtr(); - auto psrc = mf_in [mfi].dataPtr(); + auto * pdst = mf_out[mfi].dataPtr(); + auto const* psrc = mf_in [mfi].dataPtr(); AMREX_HOST_DEVICE_PARALLEL_FOR_1D ( n, i, { pdst[i] = static_cast(psrc[i]); // NOLINT(bugprone-signed-char-misuse) @@ -919,7 +919,7 @@ Vector get_cell_data (MF const& mf, IntVect const& cell using T = typename MF::value_type; const int ncomp = mf.nComp(); Gpu::DeviceVector dv(ncomp); - auto dp = dv.data(); + auto* dp = dv.data(); bool found = false; auto loc = cell.dim3(); for (MFIter mfi(mf); mfi.isValid() && !found; ++mfi) diff --git a/Src/Base/AMReX_MultiFabUtilI.H b/Src/Base/AMReX_MultiFabUtilI.H index d433c152bbb..9696a2d888a 100644 --- a/Src/Base/AMReX_MultiFabUtilI.H +++ b/Src/Base/AMReX_MultiFabUtilI.H @@ -1,10 +1,9 @@ // Used by EB_LSCore only. Might be removed in the future. So don't use. -namespace amrex { +namespace amrex::MFUtil { //! General collection of MultiFab utilities - namespace MFUtil { //! Template class defining a copy operation where source and target are //! grown by ng. Template parameter T must be either MultiFab or @@ -117,6 +116,4 @@ namespace amrex { else AsymmetricGhost::copy(mf_out, mf_in, nc, ng); } - } - } diff --git a/Src/Base/AMReX_Orientation.H b/Src/Base/AMReX_Orientation.H index 3a8631379a4..263bb84a95e 100644 --- a/Src/Base/AMReX_Orientation.H +++ b/Src/Base/AMReX_Orientation.H @@ -34,10 +34,7 @@ public: //! In each dimension a face is either low or high. enum Side { low = 0, high = 1 }; //! The default constructor. - AMREX_GPU_HOST_DEVICE - constexpr Orientation () noexcept - : - val(-1) {} + constexpr Orientation () noexcept = default; //! Set the orientation of a side. AMREX_GPU_HOST_DEVICE Orientation (int dir, Side side) noexcept @@ -77,22 +74,22 @@ public: AMREX_GPU_HOST_DEVICE constexpr operator int () const noexcept { return val; } //! Return opposite orientation. - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE Orientation flip () const noexcept { return Orientation(val < AMREX_SPACEDIM ? val+AMREX_SPACEDIM : val-AMREX_SPACEDIM); } //! Returns the coordinate direction. - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE int coordDir () const noexcept { return val%AMREX_SPACEDIM; } //! Returns the orientation of the face -- low or high. - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE Side faceDir () const noexcept { return Side(val/AMREX_SPACEDIM); } //! Returns true if Orientation is low. - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE bool isLow () const noexcept { return val < AMREX_SPACEDIM; } //! Returns true if Orientation is high. - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE bool isHigh () const noexcept { return val >= AMREX_SPACEDIM; } //! Read from an istream. friend std::istream& operator>> (std::istream& is, Orientation& o); @@ -127,7 +124,7 @@ private: Orientation (int v) noexcept : val(v) {} // //! The data. - int val; + int val = -1; }; //! Write to an ostream in ASCII format. @@ -140,10 +137,7 @@ class OrientationIter public: //! The default constructor. - AMREX_GPU_HOST_DEVICE - constexpr OrientationIter () noexcept - : - face(0) {} + constexpr OrientationIter () noexcept = default; //! Construct an iterator on the Orientation. AMREX_GPU_HOST_DEVICE OrientationIter (const Orientation& _face) noexcept @@ -157,9 +151,9 @@ public: Orientation operator() () const noexcept { BL_ASSERT(isValid()); return Orientation(face); } //! Cast to void*. Used to test if iterator is valid. AMREX_GPU_HOST_DEVICE - operator void* () noexcept { return 0 <= face && face < 2*AMREX_SPACEDIM ? this : 0; } + operator void* () noexcept { return 0 <= face && face < 2*AMREX_SPACEDIM ? this : nullptr; } //! Is the iterator valid? - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE bool isValid () const noexcept { return 0 <= face && face < 2*AMREX_SPACEDIM; } //! Pre-decrement. AMREX_GPU_HOST_DEVICE @@ -194,7 +188,7 @@ public: private: - int face; + int face = 0; //! Construct an iterator on the face. AMREX_GPU_HOST_DEVICE OrientationIter (int _face) noexcept : face(_face) {} diff --git a/Src/Base/AMReX_PArena.H b/Src/Base/AMReX_PArena.H index ba3aa925124..cc221ba7bae 100644 --- a/Src/Base/AMReX_PArena.H +++ b/Src/Base/AMReX_PArena.H @@ -23,18 +23,20 @@ class PArena public: PArena (Long release_threshold); PArena (const PArena& rhs) = delete; + PArena (PArena&& rhs) = delete; PArena& operator= (const PArena& rhs) = delete; - virtual ~PArena () override; + PArena& operator= (PArena&& rhs) = delete; + ~PArena () override; - virtual void* alloc (std::size_t nbytes) override final; - virtual void free (void* p) override final; + [[nodiscard]] void* alloc (std::size_t nbytes) final; + void free (void* p) final; - virtual bool isDeviceAccessible () const override final; - virtual bool isHostAccessible () const override final; + [[nodiscard]] bool isDeviceAccessible () const final; + [[nodiscard]] bool isHostAccessible () const final; - virtual bool isManaged () const override final; - virtual bool isDevice () const override final; - virtual bool isPinned () const override final; + [[nodiscard]] bool isManaged () const final; + [[nodiscard]] bool isDevice () const final; + [[nodiscard]] bool isPinned () const final; #ifdef AMREX_CUDA_GE_11_2 private: diff --git a/Src/Base/AMReX_ParallelContext.H b/Src/Base/AMReX_ParallelContext.H index 33d759a13bd..baaad04870e 100644 --- a/Src/Base/AMReX_ParallelContext.H +++ b/Src/Base/AMReX_ParallelContext.H @@ -9,8 +9,7 @@ #include #include -namespace amrex { -namespace ParallelContext { +namespace amrex::ParallelContext { class Frame { @@ -19,13 +18,15 @@ public: Frame (MPI_Comm c, int id, int io_rank); explicit Frame (MPI_Comm c); Frame (Frame const&) = delete; + Frame& operator= (Frame const&) = delete; + Frame& operator= (Frame &&) = delete; Frame (Frame && rhs) noexcept; ~Frame (); - int MyID () const noexcept { return m_id; } - int MyProc () const noexcept { return m_rank_me; } - int NProcs () const noexcept { return m_nranks; } - int IOProc () const noexcept { return m_io_rank; } + [[nodiscard]] int MyID () const noexcept { return m_id; } + [[nodiscard]] int MyProc () const noexcept { return m_rank_me; } + [[nodiscard]] int NProcs () const noexcept { return m_nranks; } + [[nodiscard]] int IOProc () const noexcept { return m_io_rank; } static int local_to_global_rank (int lrank); static void local_to_global_rank (int* global, const int* local, int n); static void global_to_local_rank (int* local, const int* global, int n); @@ -91,12 +92,12 @@ inline void BarrierAll () noexcept { } //! get and increment mpi tag in current frame inline int get_inc_mpi_tag () noexcept { return frames.back().get_inc_mpi_tag(); } //! translate between local rank and global rank -inline int local_to_global_rank (int rank) noexcept { return frames.back().local_to_global_rank(rank); } +inline int local_to_global_rank (int rank) noexcept { return Frame::local_to_global_rank(rank); } inline void local_to_global_rank (int* global, const int* local, int n) noexcept - { frames.back().local_to_global_rank(global, local, n); } -inline int global_to_local_rank (int rank) noexcept { return frames.back().global_to_local_rank(rank); } + { Frame::local_to_global_rank(global, local, n); } +inline int global_to_local_rank (int rank) noexcept { return Frame::global_to_local_rank(rank); } inline void global_to_local_rank (int* local, const int* global, int n) noexcept - { frames.back().global_to_local_rank(local, global, n); } + { Frame::global_to_local_rank(local, global, n); } inline void push (MPI_Comm c) { frames.emplace_back(c); } inline void push (MPI_Comm c, int id, int io_rank) { frames.emplace_back(c, id, io_rank); } @@ -106,6 +107,6 @@ inline void set_last_frame_ofs (const std::string & filename) { //! Note that it's the user's responsibility to free the MPI_Comm inline void pop () { frames.pop_back(); } -}} +} #endif // AMREX_PARALLELCONTEXT_H diff --git a/Src/Base/AMReX_Periodicity.H b/Src/Base/AMReX_Periodicity.H index a57921f0f95..959e1bb34af 100644 --- a/Src/Base/AMReX_Periodicity.H +++ b/Src/Base/AMReX_Periodicity.H @@ -19,20 +19,20 @@ public: Periodicity () noexcept : period(AMREX_D_DECL(0,0,0)) {} explicit Periodicity (const IntVect& v) noexcept : period(v) {} - bool isAnyPeriodic () const noexcept + [[nodiscard]] bool isAnyPeriodic () const noexcept { return AMREX_D_TERM(period[0]>0, || period[1]>0, || period[2]>0); } - bool isAllPeriodic () const noexcept + [[nodiscard]] bool isAllPeriodic () const noexcept { return AMREX_D_TERM(period[0]>0, && period[1]>0, && period[2]>0); } - bool isPeriodic (int dir) const noexcept + [[nodiscard]] bool isPeriodic (int dir) const noexcept { return period[dir]>0; } bool operator==(const Periodicity& rhs) const noexcept { return period == rhs.period; } //! Cell-centered domain Box "infinitely" long in non-periodic directions. - Box Domain () const noexcept; + [[nodiscard]] Box Domain () const noexcept; - std::vector shiftIntVect () const; + [[nodiscard]] std::vector shiftIntVect () const; static const Periodicity& NonPeriodic () noexcept; diff --git a/Src/Base/AMReX_PhysBCFunct.H b/Src/Base/AMReX_PhysBCFunct.H index b15cb3c5636..2c6d6e7e782 100644 --- a/Src/Base/AMReX_PhysBCFunct.H +++ b/Src/Base/AMReX_PhysBCFunct.H @@ -26,26 +26,25 @@ extern "C" } typedef void (*UserFillBox) (Box const& bx, Array4 const& dest, - const int dcomp, const int numcomp, - GeometryData const& geom, const Real time, - const BCRec* bcr, const int bcomp, - const int orig_comp); + int dcomp, int numcomp, + GeometryData const& geom, Real time, + const BCRec* bcr, int bcomp, + int orig_comp); //! This version calls function working on array class BndryFuncArray { public: - BndryFuncArray () noexcept {} BndryFuncArray (BndryFuncDefault inFunc) noexcept : m_func(inFunc) {} BndryFuncArray (BndryFunc3DDefault inFunc) noexcept : m_func3D(inFunc) {} void operator() (Box const& bx, FArrayBox& dest, - const int dcomp, const int numcomp, - Geometry const& geom, const Real time, - const Vector& bcr, const int bcomp, - const int orig_comp); + int dcomp, int numcomp, + Geometry const& geom, Real time, + const Vector& bcr, int bcomp, + int orig_comp); - bool RunOnGPU () const noexcept { return m_run_on_gpu; } + [[nodiscard]] bool RunOnGPU () const noexcept { return m_run_on_gpu; } // void setRunOnGPU (bool b) noexcept { m_run_on_gpu = b; } protected: @@ -68,23 +67,23 @@ public: GpuBndryFuncFab (F&& a_f) : m_user_f(std::move(a_f)) {} void operator() (Box const& bx, FArrayBox& dest, - const int dcomp, const int numcomp, - Geometry const& geom, const Real time, - const Vector& bcr, const int bcomp, - const int orig_comp); + int dcomp, int numcomp, + Geometry const& geom, Real time, + const Vector& bcr, int bcomp, + int orig_comp); template void ccfcdoit (Box const& bx, FArrayBox& dest, - const int dcomp, const int numcomp, - Geometry const& geom, const Real time, - const Vector& bcr, const int bcomp, - const int orig_comp, FF&& ff); + int dcomp, int numcomp, + Geometry const& geom, Real time, + const Vector& bcr, int bcomp, + int orig_comp, FF&& fillfunc); void nddoit (Box const& bx, FArrayBox& dest, - const int dcomp, const int numcomp, - Geometry const& geom, const Real time, - const Vector& bcr, const int bcomp, - const int orig_comp); + int dcomp, int numcomp, + Geometry const& geom, Real time, + const Vector& bcr, int bcomp, + int orig_comp); protected: F m_user_f; @@ -98,10 +97,10 @@ public: CpuBndryFuncFab (UserFillBox a_f) : f_user(a_f) {} void operator() (Box const& bx, FArrayBox& dest, - const int dcomp, const int numcomp, - Geometry const& geom, const Real time, - const Vector& bcr, const int bcomp, - const int orig_comp); + int dcomp, int numcomp, + Geometry const& geom, Real time, + const Vector& bcr, int bcomp, + int orig_comp); protected: UserFillBox f_user = nullptr; @@ -119,7 +118,7 @@ template class PhysBCFunct { public: - PhysBCFunct () {} + PhysBCFunct () = default; PhysBCFunct (const Geometry& geom, const Vector& bcr, F const& f) : m_geom(geom), m_bcr(bcr), m_f(f) @@ -129,8 +128,6 @@ public: : m_geom(geom), m_bcr(bcr), m_f(std::move(f)) {} - ~PhysBCFunct () {} - void define (const Geometry& geom, const Vector& bcr, F const& f) { m_geom = geom; m_bcr = bcr; m_f = f; } @@ -195,10 +192,10 @@ private: template void GpuBndryFuncFab::operator() (Box const& bx, FArrayBox& dest, - const int dcomp, const int numcomp, - Geometry const& geom, const Real time, - const Vector& bcr, const int bcomp, - const int orig_comp) + int dcomp, int numcomp, + Geometry const& geom, Real time, + const Vector& bcr, int bcomp, + int orig_comp) { #if defined(__CUDACC__) && (__CUDACC_VER_MAJOR__ == 11) && (__CUDACC_VER_MINOR__ == 6) // The compiler is allowed to always reject static_assert(false,..) even @@ -220,10 +217,10 @@ GpuBndryFuncFab::operator() (Box const& bx, FArrayBox& dest, template void GpuBndryFuncFab::nddoit (Box const& bx, FArrayBox& dest, - const int dcomp, const int numcomp, - Geometry const& geom, const Real time, - const Vector& bcr, const int bcomp, - const int orig_comp) + int dcomp, int numcomp, + Geometry const& geom, Real time, + const Vector& bcr, int bcomp, + int orig_comp) { const IntVect& len = bx.length(); @@ -344,10 +341,10 @@ template template void GpuBndryFuncFab::ccfcdoit (Box const& bx, FArrayBox& dest, - const int dcomp, const int numcomp, - Geometry const& geom, const Real time, - const Vector& bcr, const int bcomp, - const int orig_comp, FF&& fillfunc) + int dcomp, int numcomp, + Geometry const& geom, Real time, + const Vector& bcr, int bcomp, + int orig_comp, FF&& fillfunc) { const IntVect& len = bx.length(); diff --git a/Src/Base/AMReX_PhysBCFunct.cpp b/Src/Base/AMReX_PhysBCFunct.cpp index 761d23855bf..93923fd5e91 100644 --- a/Src/Base/AMReX_PhysBCFunct.cpp +++ b/Src/Base/AMReX_PhysBCFunct.cpp @@ -5,10 +5,10 @@ namespace amrex { void BndryFuncArray::operator () (Box const& /*bx*/, FArrayBox& dest, - const int dcomp, const int numcomp, - Geometry const& geom, const Real time, - const Vector& bcr, const int bcomp, // BCRec for this box - const int /*orig_comp*/) + int dcomp, int numcomp, + Geometry const& geom, Real time, + const Vector& bcr, int bcomp, // BCRec for this box + int /*orig_comp*/) { BL_ASSERT(m_func != nullptr || m_func3D != nullptr); @@ -46,10 +46,10 @@ BndryFuncArray::operator () (Box const& /*bx*/, FArrayBox& dest, void CpuBndryFuncFab::operator() (Box const& bx, FArrayBox& dest, - const int dcomp, const int numcomp, - Geometry const& geom, const Real time, - const Vector& bcr, const int bcomp, - const int orig_comp) + int dcomp, int numcomp, + Geometry const& geom, Real time, + const Vector& bcr, int bcomp, + int orig_comp) { const int* lo = dest.loVect(); const Box& domain = amrex::convert(geom.Domain(),bx.ixType()); diff --git a/Src/Base/AMReX_Print.H b/Src/Base/AMReX_Print.H index 17a24891324..1e4b83a40c8 100644 --- a/Src/Base/AMReX_Print.H +++ b/Src/Base/AMReX_Print.H @@ -81,6 +81,11 @@ namespace amrex } } + Print (Print const&) = delete; + Print (Print &&) = delete; + Print& operator= (Print const&) = delete; + Print& operator= (Print &&) = delete; + Print& SetPrecision(int p) { ss.precision(p); return *this; @@ -125,20 +130,20 @@ namespace amrex static constexpr int AllProcs = -1; - explicit PrintToFile (const std::string& file_name_) - : file_name(file_name_) + explicit PrintToFile (std::string file_name_) + : file_name(std::move(file_name_)) , rank(ParallelContext::IOProcessorNumberSub()) , comm(ParallelContext::CommunicatorSub()) { Initialize(); } - PrintToFile (const std::string& file_name_, int rank_ ) - : file_name(file_name_) + PrintToFile (std::string file_name_, int rank_ ) + : file_name(std::move(file_name_)) , rank(rank_) , comm(ParallelContext::CommunicatorSub()) { Initialize(); } - PrintToFile (const std::string& file_name_, int rank_, MPI_Comm comm_) - : file_name(file_name_) + PrintToFile (std::string file_name_, int rank_, MPI_Comm comm_) + : file_name(std::move(file_name_)) , rank(rank_) , comm(comm_) { Initialize(); } @@ -151,6 +156,11 @@ namespace amrex } } + PrintToFile (PrintToFile const&) = delete; + PrintToFile (PrintToFile &&) = delete; + PrintToFile& operator= (PrintToFile const&) = delete; + PrintToFile& operator= (PrintToFile &&) = delete; + PrintToFile& SetPrecision(int p) { ss.precision(p); return *this; @@ -200,8 +210,8 @@ namespace amrex { public: //! Example: AllPrint() << " x = " << x << std::endl; - explicit AllPrintToFile (const std::string& file_name_) - : PrintToFile(file_name_, Print::AllProcs) + explicit AllPrintToFile (std::string file_name_) + : PrintToFile(std::move(file_name_), Print::AllProcs) {} }; diff --git a/Src/Base/AMReX_RealBox.H b/Src/Base/AMReX_RealBox.H index 7601444ee9b..ddbc96b1b90 100644 --- a/Src/Base/AMReX_RealBox.H +++ b/Src/Base/AMReX_RealBox.H @@ -20,8 +20,7 @@ class RealBox { public: //! The default constructor. Builds invalid RealBox. - AMREX_GPU_HOST_DEVICE - constexpr RealBox () noexcept : xlo{AMREX_D_DECL(0.,0.,0.)}, xhi{AMREX_D_DECL(-1.,-1.,-1.)} {} + constexpr RealBox () noexcept = default; //! Construct region given diagonal points. AMREX_GPU_HOST_DEVICE @@ -42,23 +41,23 @@ public: AMREX_D_DECL(Real x1, Real y1, Real z1)) noexcept : xlo{AMREX_D_DECL(x0,y0,z0)}, xhi{AMREX_D_DECL(x1,y1,z1)} {} //! Returns lo side. - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE const Real* lo () const& noexcept { return xlo; } AMREX_GPU_HOST_DEVICE const Real* lo () && = delete; //! Returns hide side. - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE const Real* hi () const& noexcept { return xhi; } AMREX_GPU_HOST_DEVICE const Real* hi () && = delete; //! Returns length in specified direction. - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE Real lo (int dir) const noexcept { return xlo[dir]; } //! Returns hi side in specified direction. - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE Real hi (int dir) const noexcept { return xhi[dir]; } //! Returns length in specified direction. - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE Real length (int dir) const noexcept { return xhi[dir]-xlo[dir]; } //! Sets lo side. void setLo (const Real* a_lo) noexcept { AMREX_D_EXPR(xlo[0] = a_lo[0], xlo[1] = a_lo[1], xlo[2] = a_lo[2]); } @@ -77,7 +76,7 @@ public: //! Sets hi side in specified direction. void setHi (int dir, Real a_hi) noexcept { BL_ASSERT(dir >= 0 && dir < AMREX_SPACEDIM); xhi[dir] = a_hi; } //! Is the RealBox OK; i.e. does it have non-negative volume? - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE bool ok () const noexcept { return (length(0) >= 0.0) #if (AMREX_SPACEDIM > 1) @@ -91,14 +90,14 @@ public: //! Returns the volume of the RealBox. If this RealBox is invalid, //! it's volume is considered to be zero. - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE Real volume () const noexcept { if (ok()) return AMREX_D_TERM(length(0), *length(1), *length(2)); return 0.0; } //! Is the specified point contained in the RealBox? - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE bool contains (const Real* point, Real eps = 0.0) const noexcept { return AMREX_D_TERM((xlo[0]-eps < point[0]) && (point[0] < xhi[0]+eps), @@ -107,7 +106,7 @@ public: } //! Is the specified point contained in the RealBox? - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE bool contains (XDim3 point, Real eps = 0.0) const noexcept { return AMREX_D_TERM((xlo[0]-eps < point.x) && (point.x < xhi[0]+eps), && (xlo[1]-eps < point.y) && (point.y < xhi[1]+eps), @@ -115,19 +114,19 @@ public: } //! Is the specified RealVect contained in this RealBox? - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE bool contains (const RealVect& rv, Real eps=0.0) const noexcept { return contains(rv.dataPtr(), eps); } //! Is the specified RealBox contained in this RealBox? - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE bool contains (const RealBox& rb, Real eps = 0.0) const noexcept { return contains(rb.xlo, eps) && contains(rb.xhi, eps); } //! Does the specified RealBox intersect with this RealBox? - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE bool intersects (const RealBox& bx) const noexcept { return ! (AMREX_D_TERM((xlo[0] > bx.xhi[0]) || (xhi[0] < bx.xlo[0]), || (xlo[1] > bx.xhi[1]) || (xhi[1] < bx.xlo[1]), @@ -138,8 +137,8 @@ private: // // The data. // - Real xlo[AMREX_SPACEDIM]; - Real xhi[AMREX_SPACEDIM]; + Real xlo[AMREX_SPACEDIM] = {AMREX_D_DECL(Real(0.),Real(0.),Real(0.))}; + Real xhi[AMREX_SPACEDIM] = {AMREX_D_DECL(Real(-1.),Real(-1.),Real(-1.))}; }; // diff --git a/Src/Base/AMReX_RealVect.H b/Src/Base/AMReX_RealVect.H index 3593e431a41..83cc747b030 100644 --- a/Src/Base/AMReX_RealVect.H +++ b/Src/Base/AMReX_RealVect.H @@ -42,8 +42,7 @@ public: /** Construct a RealVect whose components are zero. */ - AMREX_GPU_HOST_DEVICE - constexpr RealVect () noexcept : vect{AMREX_D_DECL(0.,0.,0.)} {} + constexpr RealVect () noexcept {} // NOLINT explicit RealVect (const std::vector& vr) noexcept : vect{AMREX_D_DECL(vr[0],vr[1],vr[2])} { BL_ASSERT(vr.size() == AMREX_SPACEDIM); @@ -116,7 +115,7 @@ public: /** Return pointer to the first component. */ - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real* begin () noexcept { return vect; } @@ -124,7 +123,7 @@ public: /** Return pointer to the first component. */ - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline const Real* begin () const noexcept { return vect; } @@ -132,7 +131,7 @@ public: /** Return pointer to the one past last component */ - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real* end () noexcept { return vect + AMREX_SPACEDIM; } @@ -140,7 +139,7 @@ public: /** Return pointer to the one past last component */ - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline const Real* end () const noexcept { return vect + AMREX_SPACEDIM; } @@ -279,7 +278,7 @@ public: /** Returns the result of the scalar product with another RealVect */ - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real dotProduct(const RealVect& a_rhs) const noexcept; #if (AMREX_SPACEDIM == 3) @@ -287,7 +286,7 @@ public: /** Returns the result of the cross product with another RealVect */ - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline RealVect crossProduct(const RealVect& a_rhs) const noexcept; #endif @@ -352,7 +351,7 @@ public: Returns an IntVect whose components are the std::floor of the RealVect components. */ - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline IntVect floor () const noexcept; /// @@ -360,7 +359,7 @@ public: Returns an IntVect whose components are the std::floor of the RealVect components. */ - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline IntVect ceil () const noexcept; /// @@ -368,7 +367,7 @@ public: Returns an IntVect whose components are the std::floor of the RealVect components. */ - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline IntVect round () const noexcept; /*@}*/ @@ -435,28 +434,28 @@ public: /** Sum of all components of this RealVect. */ - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real sum () const noexcept; /// /** sqrt(sum squares) */ - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real vectorLength() const noexcept; /// /** sum squares--no square root */ - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real radSquared() const noexcept; /// /** Product of all components of this RealVect. */ - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real product () const noexcept; /// @@ -464,7 +463,7 @@ public: Component with the minimum value of this RealVect (returns 0 if they are all the same). a_doAbs : if true then take the absolute value before comparing */ - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline int minDir(const bool& a_doAbs) const noexcept; /// @@ -472,7 +471,7 @@ public: Component with the maximum value of this RealVect (returns 0 if they are all the same). a_doAbs : if true then take the absolute value before comparing */ - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline int maxDir(const bool& a_doAbs) const noexcept; /*@}*/ @@ -486,7 +485,7 @@ public: /** Only for sending stuff to Fortran */ - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE const Real* dataPtr() const noexcept { return vect; } /// @@ -641,7 +640,7 @@ protected: /** The individual components of this RealVect. */ - Real vect[SpaceDim]; + Real vect[SpaceDim] = {AMREX_D_DECL(Real(0.),Real(0.),Real(0.))}; }; @@ -751,13 +750,9 @@ inline Real RealVect::radSquared() const noexcept { - Real len = 0; - for (int idir = 0; idir < SpaceDim; idir++) - { - len = len + vect[idir]*vect[idir]; - } - - return len; + return AMREX_D_TERM(vect[0]*vect[0], + + vect[1]*vect[1], + + vect[2]*vect[2]); } AMREX_GPU_HOST_DEVICE diff --git a/Src/Base/AMReX_TagParallelFor.H b/Src/Base/AMReX_TagParallelFor.H index 0a49ac127ab..ae832f3b2af 100644 --- a/Src/Base/AMReX_TagParallelFor.H +++ b/Src/Base/AMReX_TagParallelFor.H @@ -17,7 +17,7 @@ struct Array4PairTag { Array4 sfab; Box dbox; - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Box const& box () const noexcept { return dbox; } }; @@ -28,7 +28,7 @@ struct Array4CopyTag { Box dbox; Dim3 offset; // sbox.smallEnd() - dbox.smallEnd() - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Box const& box () const noexcept { return dbox; } }; @@ -40,7 +40,7 @@ struct Array4MaskCopyTag { Box dbox; Dim3 offset; // sbox.smallEnd() - dbox.smallEnd() - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Box const& box () const noexcept { return dbox; } }; @@ -48,7 +48,7 @@ template struct Array4Tag { Array4 dfab; - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Box box () const noexcept { return Box(dfab); } }; @@ -57,7 +57,7 @@ struct Array4BoxTag { Array4 dfab; Box dbox; - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Box const& box () const noexcept { return dbox; } }; @@ -67,7 +67,7 @@ struct Array4BoxValTag { Box dbox; T val; - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Box const& box () const noexcept { return dbox; } }; @@ -76,7 +76,7 @@ struct VectorTag { T* p; int m_size; - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int size () const noexcept { return m_size; } }; diff --git a/Src/Base/AMReX_TypeTraits.H b/Src/Base/AMReX_TypeTraits.H index 3c5642e7780..222576f05f5 100644 --- a/Src/Base/AMReX_TypeTraits.H +++ b/Src/Base/AMReX_TypeTraits.H @@ -137,7 +137,9 @@ namespace amrex Nonesuch() = delete; ~Nonesuch() = delete; Nonesuch(Nonesuch const&) = delete; + Nonesuch(Nonesuch &&) = delete; void operator=(Nonesuch const&) = delete; + void operator=(Nonesuch &&) = delete; }; template class Op, diff --git a/Src/Base/AMReX_Utility.H b/Src/Base/AMReX_Utility.H index d2c80cf53b1..32676dc8bc9 100644 --- a/Src/Base/AMReX_Utility.H +++ b/Src/Base/AMReX_Utility.H @@ -192,7 +192,7 @@ namespace amrex explicit expect (std::string str_); explicit expect (const char* istr_); explicit expect (char c); - const std::string& the_string( ) const; + [[nodiscard]] const std::string& the_string( ) const; private: std::string istr; }; @@ -200,11 +200,8 @@ namespace amrex class StreamRetry { public: - StreamRetry(std::ostream &os, std::string suffix, - const int maxtries); - StreamRetry(std::string filename, - const bool abortonretryfailure, - const int maxtries); + StreamRetry(std::ostream &os, std::string suffix, int maxtries); + StreamRetry(std::string filename, bool abortonretryfailure, int maxtries); bool TryOutput(); bool TryFileOutput(); static int NStreamErrors() { return nStreamErrors; } diff --git a/Src/Base/AMReX_Utility.cpp b/Src/Base/AMReX_Utility.cpp index f79d37c99af..b54fbe8fbb7 100644 --- a/Src/Base/AMReX_Utility.cpp +++ b/Src/Base/AMReX_Utility.cpp @@ -588,14 +588,13 @@ amrex::expect::the_string () const int amrex::StreamRetry::nStreamErrors = 0; amrex::StreamRetry::StreamRetry(std::ostream &a_os, std::string a_suffix, - const int a_maxtries) + int a_maxtries) : tries(0), maxTries(a_maxtries), sros(a_os), spos(a_os.tellp()), suffix(std::move(a_suffix)) { } -amrex::StreamRetry::StreamRetry (std::string filename, - const bool abortonretryfailure, - const int maxtries) +amrex::StreamRetry::StreamRetry (std::string filename, bool abortonretryfailure, + int maxtries) : tries(0), maxTries(maxtries), abortOnRetryFailure(abortonretryfailure), fileName(std::move(filename)), diff --git a/Src/Boundary/AMReX_BoundCond.H b/Src/Boundary/AMReX_BoundCond.H index 79f4ac76bab..834f790f6b5 100644 --- a/Src/Boundary/AMReX_BoundCond.H +++ b/Src/Boundary/AMReX_BoundCond.H @@ -22,7 +22,7 @@ class BoundCond public: // //! Initializes boundary condition type to default. - BoundCond () noexcept : bctype(-1) {} + BoundCond () noexcept = default; // //! Initializes boundary condition type to specified value. // Many codes rely on implicit conversion. So no explicit here. @@ -45,7 +45,7 @@ public: private: // //! Index of boundary condition type. - int bctype; + int bctype = -1; }; } diff --git a/Src/Boundary/AMReX_FabSet.H b/Src/Boundary/AMReX_FabSet.H index ebaa27a2cf9..f4ae8b7d247 100644 --- a/Src/Boundary/AMReX_FabSet.H +++ b/Src/Boundary/AMReX_FabSet.H @@ -85,19 +85,19 @@ public: MultiArray4 arrays () noexcept { return m_mf.arrays(); } MultiArray4 const_arrays () const noexcept { return m_mf.const_arrays(); } - Box fabbox (int K) const noexcept { return m_mf.fabbox(K); } + [[nodiscard]] Box fabbox (int K) const noexcept { return m_mf.fabbox(K); } - int size () const noexcept { return m_mf.size(); } + [[nodiscard]] int size () const noexcept { return m_mf.size(); } - const BoxArray& boxArray () const noexcept { return m_mf.boxArray(); } + [[nodiscard]] const BoxArray& boxArray () const noexcept { return m_mf.boxArray(); } - const DistributionMapping& DistributionMap () const noexcept + [[nodiscard]] const DistributionMapping& DistributionMap () const noexcept { return m_mf.DistributionMap(); } - MF & multiFab () noexcept { return m_mf; } - MF const& multiFab () const noexcept { return m_mf; } + [[nodiscard]] MF & multiFab () noexcept { return m_mf; } + [[nodiscard]] MF const& multiFab () const noexcept { return m_mf; } - int nComp () const noexcept { return m_mf.nComp(); } + [[nodiscard]] int nComp () const noexcept { return m_mf.nComp(); } void clear () { m_mf.clear(); } @@ -326,7 +326,7 @@ FabSetT::linComb (value_type a, const MF& mfa, int a_comp, MF bdrya(boxArray(),DistributionMap(),ncomp,0,MFInfo()); MF bdryb(boxArray(),DistributionMap(),ncomp,0,MFInfo()); - const value_type huge = static_cast(sizeof(value_type) == 8 ? 1.e200 : 1.e30); + const auto huge = static_cast(sizeof(value_type) == 8 ? 1.e200 : 1.e30); #ifdef AMREX_USE_OMP #pragma omp parallel if (Gpu::notInLaunchRegion()) diff --git a/Src/EB/AMReX_EB2_IF_AllRegular.H b/Src/EB/AMReX_EB2_IF_AllRegular.H index 10d04939cb6..ac690670b1e 100644 --- a/Src/EB/AMReX_EB2_IF_AllRegular.H +++ b/Src/EB/AMReX_EB2_IF_AllRegular.H @@ -15,7 +15,6 @@ class AllRegularIF public: constexpr Real operator() (const RealArray&) const noexcept { return -1.0; } - AMREX_GPU_HOST_DEVICE constexpr Real operator() (AMREX_D_DECL(Real, Real, Real)) const noexcept { return -1.0; } }; diff --git a/Src/EB/AMReX_EB2_IF_Box.H b/Src/EB/AMReX_EB2_IF_Box.H index 52ca56a6e10..1af2113143d 100644 --- a/Src/EB/AMReX_EB2_IF_Box.H +++ b/Src/EB/AMReX_EB2_IF_Box.H @@ -24,7 +24,7 @@ public: m_sign( a_inside ? 1.0 : -1.0 ) {} - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { Real r = std::numeric_limits::lowest(); @@ -34,7 +34,7 @@ public: return r*m_sign; } - inline Real operator() (const RealArray& p) const noexcept + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { return this->operator() (AMREX_D_DECL(p[0], p[1], p[2])); } diff --git a/Src/EB/AMReX_EB2_IF_Complement.H b/Src/EB/AMReX_EB2_IF_Complement.H index d8b3853d14d..611497dd3e7 100644 --- a/Src/EB/AMReX_EB2_IF_Complement.H +++ b/Src/EB/AMReX_EB2_IF_Complement.H @@ -18,13 +18,13 @@ public: ComplementIF (F a_f) : m_f(std::move(a_f)) {} - inline Real operator() (const RealArray& p) const noexcept + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { return -m_f(p); } template::value,int>::type = 0> - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { return -m_f(AMREX_D_DECL(x,y,z)); diff --git a/Src/EB/AMReX_EB2_IF_Cylinder.H b/Src/EB/AMReX_EB2_IF_Cylinder.H index f4dd1f2a00f..11eb146f54f 100644 --- a/Src/EB/AMReX_EB2_IF_Cylinder.H +++ b/Src/EB/AMReX_EB2_IF_Cylinder.H @@ -37,7 +37,7 @@ public: AMREX_ASSERT(m_direction < AMREX_SPACEDIM); } - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { #if (AMREX_SPACEDIM == 3) @@ -92,7 +92,7 @@ public: } } - inline Real operator() (const RealArray& p) const noexcept + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { return this->operator() (AMREX_D_DECL(p[0], p[1], p[2])); } diff --git a/Src/EB/AMReX_EB2_IF_DevicePtr.H b/Src/EB/AMReX_EB2_IF_DevicePtr.H index 78ebd74ef97..a4c817e5829 100644 --- a/Src/EB/AMReX_EB2_IF_DevicePtr.H +++ b/Src/EB/AMReX_EB2_IF_DevicePtr.H @@ -11,13 +11,13 @@ public: DevicePtrIF(T* a_p) : p(a_p) {} - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { return (*p)(AMREX_D_DECL(x,y,z)); } - Real operator() (const RealArray& a) const noexcept + [[nodiscard]] Real operator() (const RealArray& a) const noexcept { return this->operator() (AMREX_D_DECL(a[0], a[1], a[2])); } diff --git a/Src/EB/AMReX_EB2_IF_Difference.H b/Src/EB/AMReX_EB2_IF_Difference.H index 30330d4077b..74d775677a0 100644 --- a/Src/EB/AMReX_EB2_IF_Difference.H +++ b/Src/EB/AMReX_EB2_IF_Difference.H @@ -23,7 +23,7 @@ public: m_g(std::move(a_g)) {} - inline Real operator() (const RealArray& p) const noexcept + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { Real r1 = m_f(p); Real r2 = m_g(p); @@ -33,7 +33,7 @@ public: template ::value && IsGPUable::value, int>::type = 0> - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { Real r1 = m_f(AMREX_D_DECL(x,y,z)); diff --git a/Src/EB/AMReX_EB2_IF_Ellipsoid.H b/Src/EB/AMReX_EB2_IF_Ellipsoid.H index f92584d08b1..d32ffd8fd23 100644 --- a/Src/EB/AMReX_EB2_IF_Ellipsoid.H +++ b/Src/EB/AMReX_EB2_IF_Ellipsoid.H @@ -21,7 +21,7 @@ public: m_sign( a_inside ? 1.0_rt : -1.0_rt ) {} - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { Real d2 = AMREX_D_TERM( (x-m_center.x)*(x-m_center.x) / (m_radii.x*m_radii.x), + (y-m_center.y)*(y-m_center.y) / (m_radii.y*m_radii.y), @@ -29,7 +29,7 @@ public: return m_sign*(d2-1.0_rt); } - inline Real operator() (const RealArray& p) const noexcept { + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { return this->operator()(AMREX_D_DECL(p[0],p[1],p[2])); } diff --git a/Src/EB/AMReX_EB2_IF_Extrusion.H b/Src/EB/AMReX_EB2_IF_Extrusion.H index f8ba6ae7daa..218ffdb74d4 100644 --- a/Src/EB/AMReX_EB2_IF_Extrusion.H +++ b/Src/EB/AMReX_EB2_IF_Extrusion.H @@ -21,7 +21,7 @@ public: m_direction(direction) {} - inline Real operator() (const RealArray& p) const + [[nodiscard]] inline Real operator() (const RealArray& p) const { RealArray x = p; x[m_direction] = 0.0; @@ -29,7 +29,7 @@ public: } template ::value,int>::type = 0> - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { switch (m_direction) diff --git a/Src/EB/AMReX_EB2_IF_Intersection.H b/Src/EB/AMReX_EB2_IF_Intersection.H index 065a19fb860..4da055ba7ef 100644 --- a/Src/EB/AMReX_EB2_IF_Intersection.H +++ b/Src/EB/AMReX_EB2_IF_Intersection.H @@ -17,26 +17,26 @@ namespace amrex::EB2 { namespace IIF_detail { template - inline Real do_min (const RealArray& p, F&& f) noexcept + [[nodiscard]] inline Real do_min (const RealArray& p, F&& f) noexcept { return f(p); } template - inline Real do_min (const RealArray& p, F&& f, Fs&... fs) noexcept + [[nodiscard]] inline Real do_min (const RealArray& p, F&& f, Fs&... fs) noexcept { return amrex::min(f(p), do_min(p, std::forward(fs)...)); } template - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real do_min (AMREX_D_DECL(Real x, Real y, Real z), F&& f) noexcept { return f(AMREX_D_DECL(x,y,z)); } template - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real do_min (AMREX_D_DECL(Real x, Real y, Real z), F&& f, Fs&... fs) { return amrex::min(f(AMREX_D_DECL(x,y,z)), do_min(AMREX_D_DECL(x,y,z), std::forward(fs)...)); @@ -50,13 +50,13 @@ class IntersectionIF public: using GpuTuple::GpuTuple; - inline Real operator() (const RealArray& p) const noexcept + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { return op_impl(p, std::make_index_sequence()); } template , typename std::enable_if::value,int>::type = 0> - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { return op_impl(AMREX_D_DECL(x,y,z), std::make_index_sequence()); @@ -65,13 +65,13 @@ public: protected: template - inline Real op_impl (const RealArray& p, std::index_sequence) const noexcept + [[nodiscard]] inline Real op_impl (const RealArray& p, std::index_sequence) const noexcept { return IIF_detail::do_min(p, amrex::get(*this)...); } template - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real op_impl (AMREX_D_DECL(Real x, Real y, Real z), std::index_sequence) const noexcept { return IIF_detail::do_min(AMREX_D_DECL(x,y,z), amrex::get(*this)...); diff --git a/Src/EB/AMReX_EB2_IF_Lathe.H b/Src/EB/AMReX_EB2_IF_Lathe.H index 06e051991d5..c5914034f42 100644 --- a/Src/EB/AMReX_EB2_IF_Lathe.H +++ b/Src/EB/AMReX_EB2_IF_Lathe.H @@ -19,7 +19,7 @@ public: LatheIF (F a_f) : m_f(std::move(a_f)) {} - inline Real operator() (const RealArray& p) const noexcept + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { Real r = std::hypot(p[0],p[1]); #if (AMREX_SPACEDIM == 2) @@ -30,7 +30,7 @@ public: } template ::value,int>::type = 0> - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { Real r = std::hypot(x,y); diff --git a/Src/EB/AMReX_EB2_IF_Parser.H b/Src/EB/AMReX_EB2_IF_Parser.H index 73c176a7ba0..e4cd3b8187c 100644 --- a/Src/EB/AMReX_EB2_IF_Parser.H +++ b/Src/EB/AMReX_EB2_IF_Parser.H @@ -17,7 +17,7 @@ public: : m_parser(a_parser) {} - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline amrex::Real operator() (AMREX_D_DECL(amrex::Real x, amrex::Real y, amrex::Real z)) const noexcept { #if (AMREX_SPACEDIM == 2) @@ -27,7 +27,7 @@ public: #endif } - inline amrex::Real operator() (const amrex::RealArray& p) const noexcept { + [[nodiscard]] inline amrex::Real operator() (const amrex::RealArray& p) const noexcept { return this->operator()(AMREX_D_DECL(p[0],p[1],p[2])); } diff --git a/Src/EB/AMReX_EB2_IF_Plane.H b/Src/EB/AMReX_EB2_IF_Plane.H index 36e5ae68f17..c52bffbadc7 100644 --- a/Src/EB/AMReX_EB2_IF_Plane.H +++ b/Src/EB/AMReX_EB2_IF_Plane.H @@ -20,7 +20,7 @@ public: m_sign( a_inside ? 1.0 : -1.0 ) {} - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { return AMREX_D_TERM( (x-m_point.x)*m_normal.x*m_sign, @@ -28,7 +28,7 @@ public: +(z-m_point.z)*m_normal.z*m_sign ); } - inline Real operator() (const RealArray& p) const noexcept + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { return this->operator()(AMREX_D_DECL(p[0],p[1],p[2])); } diff --git a/Src/EB/AMReX_EB2_IF_Polynomial.H b/Src/EB/AMReX_EB2_IF_Polynomial.H index 67ba37e3dd7..e6ff747b420 100644 --- a/Src/EB/AMReX_EB2_IF_Polynomial.H +++ b/Src/EB/AMReX_EB2_IF_Polynomial.H @@ -72,15 +72,16 @@ public: : m_polynomial(a_polynomial), m_inside(a_inside), m_sign( a_inside ? 1.0_rt : -1.0_rt ), - m_size(m_polynomial.size()) + m_size(int(m_polynomial.size())) {} + ~PolynomialIF () = default; PolynomialIF (const PolynomialIF& rhs) = default; PolynomialIF (PolynomialIF&& rhs) = default; PolynomialIF& operator= (const PolynomialIF& rhs) = delete; PolynomialIF& operator= (PolynomialIF&& rhs) = delete; - inline + [[nodiscard]] inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { Real retval = 0.0_rt; @@ -92,7 +93,7 @@ public: return m_sign*retval; } - inline Real operator() (const RealArray& p) const noexcept { + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { return this->operator()(AMREX_D_DECL(p[0],p[1],p[2])); } diff --git a/Src/EB/AMReX_EB2_IF_Rotation.H b/Src/EB/AMReX_EB2_IF_Rotation.H index 538e2429fe5..9a676a347ea 100644 --- a/Src/EB/AMReX_EB2_IF_Rotation.H +++ b/Src/EB/AMReX_EB2_IF_Rotation.H @@ -25,7 +25,7 @@ public: // Note that angle is measured in radians #if (AMREX_SPACEDIM==2) - inline Real operator() (const RealArray& p) const noexcept + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { Real x = p[0]*m_cos_angle + p[1]*m_sin_angle; Real y = -p[0]*m_sin_angle + p[1]*m_cos_angle; @@ -33,7 +33,7 @@ public: } template ::value,int>::type = 0> - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (Real x, Real y) const noexcept { return m_f( x*m_cos_angle + y*m_sin_angle, @@ -42,7 +42,7 @@ public: #endif #if (AMREX_SPACEDIM==3) - inline Real operator() (const RealArray& p) const noexcept + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { switch(m_dir) { case(0): @@ -67,7 +67,7 @@ public: } template ::value,int>::type = 0> - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (Real x, Real y, Real z) const noexcept { switch(m_dir) { diff --git a/Src/EB/AMReX_EB2_IF_Scale.H b/Src/EB/AMReX_EB2_IF_Scale.H index 33fb39a8fe1..832b8c51197 100644 --- a/Src/EB/AMReX_EB2_IF_Scale.H +++ b/Src/EB/AMReX_EB2_IF_Scale.H @@ -26,7 +26,7 @@ public: {} template ::value,int>::type = 0> - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { return m_f(AMREX_D_DECL(x*m_sfinv.x, @@ -34,7 +34,7 @@ public: z*m_sfinv.z)); } - inline Real operator() (const RealArray& p) const noexcept + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { return m_f({AMREX_D_DECL(p[0]*m_sfinv.x, p[1]*m_sfinv.y, diff --git a/Src/EB/AMReX_EB2_IF_Sphere.H b/Src/EB/AMReX_EB2_IF_Sphere.H index 00987ae121c..458e38d0a2a 100644 --- a/Src/EB/AMReX_EB2_IF_Sphere.H +++ b/Src/EB/AMReX_EB2_IF_Sphere.H @@ -21,7 +21,7 @@ public: m_sign( a_inside ? 1.0 : -1.0 ) {} - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { Real d2 = AMREX_D_TERM( (x-m_center.x)*(x-m_center.x), + (y-m_center.y)*(y-m_center.y), @@ -29,7 +29,7 @@ public: return m_sign*(d2-m_radius*m_radius); } - inline Real operator() (const RealArray& p) const noexcept { + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { return this->operator()(AMREX_D_DECL(p[0],p[1],p[2])); } diff --git a/Src/EB/AMReX_EB2_IF_Spline.H b/Src/EB/AMReX_EB2_IF_Spline.H index b3bd1c690cc..c0269a85865 100644 --- a/Src/EB/AMReX_EB2_IF_Spline.H +++ b/Src/EB/AMReX_EB2_IF_Spline.H @@ -19,19 +19,19 @@ class SplineIF { public: void addSplineElement(std::vector pts) { - SplineDistFcnElement2d * theSpline = new SplineDistFcnElement2d(); - theSpline->set_control_points(pts); + auto* theSpline = new SplineDistFcnElement2d(); + theSpline->set_control_points(std::move(pts)); theSpline->calc_D(); geomElements.push_back(theSpline); } void addLineElement(std::vector pts) { - LineDistFcnElement2d * theLine = new LineDistFcnElement2d(); - theLine->set_control_points(pts); + auto* theLine = new LineDistFcnElement2d(); + theLine->set_control_points(std::move(pts)); geomElements.push_back(theLine); } - amrex::Real operator() (const amrex::RealArray& p) const { + [[nodiscard]] amrex::Real operator() (const amrex::RealArray& p) const { amrex::RealVect cp; distFcnElement2d * closesetGeomElement = nullptr; amrex::Real dist; diff --git a/Src/EB/AMReX_EB2_IF_Torus.H b/Src/EB/AMReX_EB2_IF_Torus.H index c8392302d35..be264efade7 100644 --- a/Src/EB/AMReX_EB2_IF_Torus.H +++ b/Src/EB/AMReX_EB2_IF_Torus.H @@ -23,7 +23,7 @@ public: m_sign( a_inside ? 1.0 : -1.0 ) {} - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { Real d = std::hypot(x-m_center.x, y-m_center.y); #if (AMREX_SPACEDIM == 2) @@ -36,7 +36,7 @@ public: #endif } - inline Real operator() (const RealArray& p) const noexcept { + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { return this->operator()(AMREX_D_DECL(p[0],p[1],p[2])); } diff --git a/Src/EB/AMReX_EB2_IF_Translation.H b/Src/EB/AMReX_EB2_IF_Translation.H index a58f4e37985..cdf5ea9983b 100644 --- a/Src/EB/AMReX_EB2_IF_Translation.H +++ b/Src/EB/AMReX_EB2_IF_Translation.H @@ -21,7 +21,7 @@ public: m_offset(makeXDim3(a_offset)) {} - inline Real operator() (const RealArray& p) const noexcept + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { return m_f({AMREX_D_DECL(p[0]-m_offset.x, p[1]-m_offset.y, @@ -29,7 +29,7 @@ public: } template ::value,int>::type = 0> - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { return m_f(AMREX_D_DECL(x-m_offset.x, diff --git a/Src/EB/AMReX_EB2_IF_Union.H b/Src/EB/AMReX_EB2_IF_Union.H index 1a9d5de0da3..0c8b38cb80d 100644 --- a/Src/EB/AMReX_EB2_IF_Union.H +++ b/Src/EB/AMReX_EB2_IF_Union.H @@ -17,26 +17,26 @@ namespace amrex::EB2 { namespace UIF_detail { template - inline Real do_max (const RealArray& p, F&& f) noexcept + [[nodiscard]] inline Real do_max (const RealArray& p, F&& f) noexcept { return f(p); } template - inline Real do_max (const RealArray& p, F&& f, Fs&... fs) noexcept + [[nodiscard]] inline Real do_max (const RealArray& p, F&& f, Fs&... fs) noexcept { return amrex::max(f(p), do_max(p, std::forward(fs)...)); } template - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real do_max (AMREX_D_DECL(Real x, Real y, Real z), F&& f) noexcept { return f(AMREX_D_DECL(x,y,z)); } template - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real do_max (AMREX_D_DECL(Real x, Real y, Real z), F&& f, Fs&... fs) noexcept { return amrex::max(f(AMREX_D_DECL(x,y,z)), do_max(AMREX_D_DECL(x,y,z), std::forward(fs)...)); @@ -50,13 +50,13 @@ class UnionIF public: using GpuTuple::GpuTuple; - inline Real operator() (const RealArray& p) const noexcept + [[nodiscard]] inline Real operator() (const RealArray& p) const noexcept { return op_impl(p, std::make_index_sequence()); } template , typename std::enable_if::value,int>::type = 0> - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { return op_impl(AMREX_D_DECL(x,y,z), std::make_index_sequence()); @@ -65,13 +65,13 @@ public: protected: template - inline Real op_impl (const RealArray& p, std::index_sequence) const noexcept + [[nodiscard]] inline Real op_impl (const RealArray& p, std::index_sequence) const noexcept { return UIF_detail::do_max(p, amrex::get(*this)...); } template - AMREX_GPU_HOST_DEVICE inline + [[nodiscard]] AMREX_GPU_HOST_DEVICE inline Real op_impl (AMREX_D_DECL(Real x, Real y, Real z), std::index_sequence) const noexcept { return UIF_detail::do_max(AMREX_D_DECL(x,y,z), amrex::get(*this)...); diff --git a/Src/EB/AMReX_EB2_IndexSpace_chkpt_file.H b/Src/EB/AMReX_EB2_IndexSpace_chkpt_file.H index 323b2f921e0..2605118d3b2 100644 --- a/Src/EB/AMReX_EB2_IndexSpace_chkpt_file.H +++ b/Src/EB/AMReX_EB2_IndexSpace_chkpt_file.H @@ -25,14 +25,14 @@ public: void operator= (IndexSpaceChkptFile const&) = delete; void operator= (IndexSpaceChkptFile &&) = delete; - virtual ~IndexSpaceChkptFile () {} + ~IndexSpaceChkptFile () override = default; - virtual const Level& getLevel (const Geometry& geom) const final; - virtual const Geometry& getGeometry (const Box& dom) const final; - virtual const Box& coarsestDomain () const final { + [[nodiscard]] const Level& getLevel (const Geometry& geom) const final; + [[nodiscard]] const Geometry& getGeometry (const Box& dom) const final; + [[nodiscard]] const Box& coarsestDomain () const final { return m_geom.back().Domain(); } - virtual void addFineLevels (int num_new_fine_levels) final; + void addFineLevels (int num_new_fine_levels) final; private: diff --git a/Src/EB/AMReX_EBDataCollection.H b/Src/EB/AMReX_EBDataCollection.H index 19f568b3caa..13edcdb7243 100644 --- a/Src/EB/AMReX_EBDataCollection.H +++ b/Src/EB/AMReX_EBDataCollection.H @@ -29,16 +29,16 @@ public: EBDataCollection& operator= (const EBDataCollection&) = delete; EBDataCollection& operator= (EBDataCollection&&) = delete; - const FabArray& getMultiEBCellFlagFab () const; - const MultiFab& getLevelSet () const; - const MultiFab& getVolFrac () const; - const MultiCutFab& getCentroid () const; - const MultiCutFab& getBndryCent () const; - const MultiCutFab& getBndryArea () const; - const MultiCutFab& getBndryNormal () const; - Array getAreaFrac () const; - Array getFaceCent () const; - Array getEdgeCent () const; + [[nodiscard]] const FabArray& getMultiEBCellFlagFab () const; + [[nodiscard]] const MultiFab& getLevelSet () const; + [[nodiscard]] const MultiFab& getVolFrac () const; + [[nodiscard]] const MultiCutFab& getCentroid () const; + [[nodiscard]] const MultiCutFab& getBndryCent () const; + [[nodiscard]] const MultiCutFab& getBndryArea () const; + [[nodiscard]] const MultiCutFab& getBndryNormal () const; + [[nodiscard]] Array getAreaFrac () const; + [[nodiscard]] Array getFaceCent () const; + [[nodiscard]] Array getEdgeCent () const; private: diff --git a/Src/EB/AMReX_EB_STL_utils.H b/Src/EB/AMReX_EB_STL_utils.H index ddef3e87ec6..eb277202cde 100644 --- a/Src/EB/AMReX_EB_STL_utils.H +++ b/Src/EB/AMReX_EB_STL_utils.H @@ -39,20 +39,19 @@ private: void read_binary_stl_file (std::string const& fname, Real scale, Array const& center, int reverse_normal); -public: // for cuda - void prepare (); - public: + void prepare (); // public for cuda + void read_stl_file (std::string const& fname, Real scale, Array const& center, int reverse_normal); void fill (MultiFab& mf, IntVect const& nghost, Geometry const& geom, Real outside_value = -1._rt, Real inside_value = 1._rt) const; - int getBoxType (Box const& box, Geometry const& geom, RunOn) const; + [[nodiscard]] int getBoxType (Box const& box, Geometry const& geom, RunOn) const; - bool isGPUable () const noexcept { return true; } + static constexpr bool isGPUable () noexcept { return true; } void fillFab (BaseFab& levelset, const Geometry& geom, RunOn, Box const& bounding_box) const; diff --git a/Src/EB/AMReX_EB_chkpt_file.H b/Src/EB/AMReX_EB_chkpt_file.H index b38ce808f73..bb51c79a127 100644 --- a/Src/EB/AMReX_EB_chkpt_file.H +++ b/Src/EB/AMReX_EB_chkpt_file.H @@ -8,7 +8,7 @@ namespace amrex::EB2 { class ChkptFile { private: - std::string m_restart_file = ""; + std::string m_restart_file; const std::string m_volfrac_name = "volfrac"; const std::string m_centroid_name = "centroid"; diff --git a/Src/EB/AMReX_EB_utils.H b/Src/EB/AMReX_EB_utils.H index 0d88a5793e2..9bb07b562a3 100644 --- a/Src/EB/AMReX_EB_utils.H +++ b/Src/EB/AMReX_EB_utils.H @@ -21,8 +21,8 @@ namespace amrex { Array4 const& div, Array4 const& divc, Array4 const& wt, - const int icomp, - const int ncomp, + int icomp, + int ncomp, Array4 const& flags, Array4 const& vfrac, const Geometry & geom); diff --git a/Src/EB/AMReX_EB_utils.cpp b/Src/EB/AMReX_EB_utils.cpp index 39139bf1410..317a7792bf3 100644 --- a/Src/EB/AMReX_EB_utils.cpp +++ b/Src/EB/AMReX_EB_utils.cpp @@ -17,8 +17,8 @@ namespace amrex { MultiFab& divc_mf, const MultiFab& weights, MFIter* mfi, - const int icomp, - const int ncomp, + int icomp, + int ncomp, const EBCellFlagFab& flags_fab, const MultiFab* volfrac, Box& /*domain*/, @@ -58,8 +58,8 @@ namespace amrex { Array4 const& div, Array4 const& divc, Array4 const& wt, - const int icomp, - const int ncomp, + int icomp, + int ncomp, Array4 const& flags, Array4 const& vfrac, const Geometry & geom) diff --git a/Src/EB/AMReX_algoim_K.H b/Src/EB/AMReX_algoim_K.H index 9c192028663..257b7821bb8 100644 --- a/Src/EB/AMReX_algoim_K.H +++ b/Src/EB/AMReX_algoim_K.H @@ -39,20 +39,20 @@ struct EBPlane : cent{cx,cy,cz}, norm{nx,ny,nz} {} - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real operator() (Real x, Real y, Real z) const noexcept { return (x-cent[0])*norm[0] + (y-cent[1])*norm[1] + (z-cent[2])*norm[2]; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real operator() (GpuArray const& p) const noexcept { return (p[0]-cent[0])*norm[0] + (p[1]-cent[1])*norm[1] + (p[2]-cent[2])*norm[2]; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real grad (int d) const noexcept { return norm[d]; @@ -69,7 +69,7 @@ struct QuadratureRule GpuArray nodes; template - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real operator() (const F& f) const noexcept { @@ -81,7 +81,7 @@ struct QuadratureRule } template - AMREX_GPU_HOST AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST AMREX_FORCE_INLINE Real eval (const F& f) const noexcept { @@ -171,7 +171,7 @@ struct PsiCode unsigned char bits = 0; AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr - PsiCode () noexcept {} + PsiCode () noexcept = default; AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE PsiCode (const GpuArray& sides, int sign) noexcept @@ -210,13 +210,13 @@ struct PsiCode } } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int side (int dim) const noexcept { return bits & (1 << dim); } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int sign () const noexcept { return (bits & (1 << N)) ? 0 : ((bits & (1 << (N+1))) ? 1 : -1); diff --git a/Src/EB/AMReX_distFcnElement.H b/Src/EB/AMReX_distFcnElement.H index 8bd1ebe8755..1d7c2ef0597 100644 --- a/Src/EB/AMReX_distFcnElement.H +++ b/Src/EB/AMReX_distFcnElement.H @@ -8,16 +8,16 @@ namespace amrex { -class distFcnElement2d { +class distFcnElement2d { // NOLINT(cppcoreguidelines-special-member-functions) public: //! Constructor - distFcnElement2d() {} - virtual ~distFcnElement2d() {} + distFcnElement2d() = default; + virtual ~distFcnElement2d() = default; - virtual distFcnElement2d* newDistFcnElement2d() const = 0; + [[nodiscard]] virtual distFcnElement2d* newDistFcnElement2d() const = 0; - virtual amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect& cp) const = 0; - virtual amrex::Real cpside(amrex::RealVect pt, amrex::RealVect& cp) const = 0; + [[nodiscard]] virtual amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect& cp) const = 0; + [[nodiscard]] virtual amrex::Real cpside(amrex::RealVect pt, amrex::RealVect& cp) const = 0; static int solve_thomas(const std::vector &a, std::vector b, const std::vector &c, @@ -26,17 +26,17 @@ class distFcnElement2d { }; -class LineDistFcnElement2d: public distFcnElement2d { +class LineDistFcnElement2d: public distFcnElement2d { // NOLINT(cppcoreguidelines-special-member-functions) public: - LineDistFcnElement2d() {} - virtual ~LineDistFcnElement2d() {} + LineDistFcnElement2d() = default; + ~LineDistFcnElement2d() override = default; - virtual distFcnElement2d* newDistFcnElement2d() const override; + [[nodiscard]] distFcnElement2d* newDistFcnElement2d() const override; void set_control_points(std::vector pts); - virtual amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect& cp) const override; - virtual amrex::Real cpside(amrex::RealVect pt, amrex::RealVect& cp) const override; + [[nodiscard]] amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect& cp) const override; + [[nodiscard]] amrex::Real cpside(amrex::RealVect pt, amrex::RealVect& cp) const override; void print_control_points(); @@ -55,12 +55,12 @@ class LineDistFcnElement2d: public distFcnElement2d { }; -class SplineDistFcnElement2d: public distFcnElement2d { +class SplineDistFcnElement2d: public distFcnElement2d { // NOLINT(cppcoreguidelines-special-member-functions) public: - SplineDistFcnElement2d() {} - virtual ~SplineDistFcnElement2d() {} + SplineDistFcnElement2d() = default; + ~SplineDistFcnElement2d() override = default; - virtual distFcnElement2d* newDistFcnElement2d() const override; + [[nodiscard]] distFcnElement2d* newDistFcnElement2d() const override; void set_control_points(std::vector pts); @@ -71,8 +71,8 @@ class SplineDistFcnElement2d: public distFcnElement2d { void calc_D(bool clamped_bc = false); - virtual amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect& cp) const override; - virtual amrex::Real cpside(amrex::RealVect pt, amrex::RealVect& cp) const override; + [[nodiscard]] amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect& cp) const override; + [[nodiscard]] amrex::Real cpside(amrex::RealVect pt, amrex::RealVect& cp) const override; protected: static amrex::Real eval(amrex::Real t, amrex::Real y0, amrex::Real y1, diff --git a/Src/Extern/HYPRE/AMReX_HypreSolver.H b/Src/Extern/HYPRE/AMReX_HypreSolver.H index c74fc4539f2..48badc08f21 100644 --- a/Src/Extern/HYPRE/AMReX_HypreSolver.H +++ b/Src/Extern/HYPRE/AMReX_HypreSolver.H @@ -24,11 +24,11 @@ public: IntVect const& a_nghost, Geometry const& a_geom, BoxArray const& a_grids, - DistributionMapping const& a_dmap, + DistributionMapping const& a_dmap, // NOLINT(modernize-pass-by-value) Marker && a_marker, Filler && a_filler, int a_verbose = 0, - std::string const& a_options_namespace = "hypre"); + std::string a_options_namespace = "hypre"); template ::value && std::is_same_vb(); } HYPRE_IJVector getx () const { return m_hypre_ij->x(); } -public: // for cuda +// public: // for cuda template #ifdef AMREX_USE_CUDA @@ -119,23 +119,23 @@ HypreSolver::HypreSolver (Vector const& a_index_type, IntVect const& a_nghost, Geometry const& a_geom, BoxArray const& a_grids, - DistributionMapping const& a_dmap, + DistributionMapping const& a_dmap, // NOLINT(modernize-pass-by-value) Marker && a_marker, Filler && a_filler, int a_verbose, - std::string const& a_options_namespace) - : m_nvars (a_index_type.size()), + std::string a_options_namespace) + : m_nvars (int(a_index_type.size())), m_index_type (a_index_type), m_nghost (a_nghost), m_geom (a_geom), m_dmap (a_dmap), m_verbose (a_verbose), - m_options_namespace(a_options_namespace) + m_options_namespace(std::move(a_options_namespace)) { BL_PROFILE("HypreSolver()"); #ifdef AMREX_USE_MPI - m_comm = ParallelContext::CommunicatorSub(); + m_comm = ParallelContext::CommunicatorSub(); // NOLINT(cppcoreguidelines-prefer-member-initializer) #endif m_grids.resize(m_nvars); @@ -494,7 +494,7 @@ HypreSolver::fill_matrix (Filler const& filler) detail::pack_matrix_gpu(cols_tmp, mat_tmp, cols_vec, mat_vec); } #else - auto pgid = gid_v.data(); + auto* pgid = gid_v.data(); for (int ivar = 0; ivar < m_nvars; ++ivar) { if (m_nrows_grid[ivar][mfi] > 0) { auto const& lid = m_local_id[ivar].const_array(mfi); @@ -574,8 +574,8 @@ HypreSolver::load_vectors (Vector const& a_soln, xvec.resize(nrows); bvec.clear(); bvec.resize(nrows); - auto xp = xvec.data(); - auto bp = bvec.data(); + auto* xp = xvec.data(); + auto* bp = bvec.data(); HYPRE_Int const* rows = m_global_id_vec[mfi].data(); @@ -627,7 +627,7 @@ HypreSolver::get_solution (Vector const& a_soln) { xvec.clear(); xvec.resize(nrows); - auto xp = xvec.data(); + auto* xp = xvec.data(); HYPRE_Int const* rows = m_global_id_vec[mfi].data(); diff --git a/Src/Extern/PETSc/AMReX_PETSc.cpp b/Src/Extern/PETSc/AMReX_PETSc.cpp index 722b2143abf..5b6f82cec85 100644 --- a/Src/Extern/PETSc/AMReX_PETSc.cpp +++ b/Src/Extern/PETSc/AMReX_PETSc.cpp @@ -237,7 +237,7 @@ PETScABecLap::prepareSolver () Gpu::DeviceVector dv_is_covered(hv_is_covered.size()); Gpu::copyAsync(Gpu::hostToDevice, hv_is_covered.begin(), hv_is_covered.end(), dv_is_covered.begin()); - auto pc = dv_is_covered.data(); + auto const* pc = dv_is_covered.data(); auto const& cell_id_ma = cell_id.arrays(); ParallelFor(cell_id, IntVect(1), [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept @@ -361,7 +361,7 @@ PETScABecLap::prepareSolver () #ifdef AMREX_USE_GPU if (Gpu::inLaunchRegion() && cell_id.isFusingCandidate()) { Gpu::Buffer offset_buf(offset.data(), offset.local_size()); - auto poffset = offset_buf.data(); + auto const* poffset = offset_buf.data(); auto const& cell_id_ma = cell_id.arrays(); auto const& cell_id_vec_ma = cell_id_vec.arrays(); ParallelFor(cell_id, diff --git a/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H b/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H index 7fc56f49b23..5384f534107 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H @@ -21,13 +21,13 @@ public: using BCType = LinOpBCType; using Location = typename MLLinOpT::Location; - MLABecLaplacianT () {} + MLABecLaplacianT () = default; MLABecLaplacianT (const Vector& a_geom, const Vector& a_grids, const Vector& a_dmap, const LPInfo& a_info = LPInfo(), const Vector const*>& a_factory = {}, - const int a_ncomp = 1); + int a_ncomp = 1); MLABecLaplacianT (const Vector& a_geom, const Vector& a_grids, @@ -35,9 +35,9 @@ public: const Vector& a_overset_mask, // 1: unknown, 0: known const LPInfo& a_info = LPInfo(), const Vector const*>& a_factory = {}, - const int a_ncomp = 1); + int a_ncomp = 1); - virtual ~MLABecLaplacianT (); + ~MLABecLaplacianT () override; MLABecLaplacianT (const MLABecLaplacianT&) = delete; MLABecLaplacianT (MLABecLaplacianT&&) = delete; @@ -49,7 +49,7 @@ public: const Vector& a_dmap, const LPInfo& a_info = LPInfo(), const Vector const*>& a_factory = {}, - const int a_ncomp = 1); + int a_ncomp = 1); void define (const Vector& a_geom, const Vector& a_grids, @@ -57,7 +57,7 @@ public: const Vector& a_overset_mask, const LPInfo& a_info = LPInfo(), const Vector const*>& a_factory = {}, - const int a_ncomp = 1); + int a_ncomp = 1); /** * Set scalar constants A and B in the equation: @@ -144,37 +144,37 @@ public: int> = 0> void setBCoeffs (int amrlev, Vector const& beta); - virtual int getNComp () const override { return m_ncomp; } + [[nodiscard]] int getNComp () const override { return m_ncomp; } - virtual bool needsUpdate () const override { + [[nodiscard]] bool needsUpdate () const override { return (m_needs_update || MLCellABecLapT::needsUpdate()); } - virtual void update () override; - - virtual void prepareForSolve () override; - virtual bool isSingular (int amrlev) const override { return m_is_singular[amrlev]; } - virtual bool isBottomSingular () const override { return m_is_singular[0]; } - virtual void Fapply (int amrlev, int mglev, MF& out, const MF& in) const final override; - virtual void Fsmooth (int amrlev, int mglev, MF& sol, const MF& rhs, int redblack) const final override; - virtual void FFlux (int amrlev, const MFIter& mfi, - const Array& flux, - const FAB& sol, Location /* loc */, - const int face_only=0) const final override; - - virtual void normalize (int amrlev, int mglev, MF& mf) const final override; - - virtual RT getAScalar () const final override { return m_a_scalar; } - virtual RT getBScalar () const final override { return m_b_scalar; } - virtual MF const* getACoeffs (int amrlev, int mglev) const final override + void update () override; + + void prepareForSolve () override; + [[nodiscard]] bool isSingular (int amrlev) const override { return m_is_singular[amrlev]; } + [[nodiscard]] bool isBottomSingular () const override { return m_is_singular[0]; } + void Fapply (int amrlev, int mglev, MF& out, const MF& in) const final; + void Fsmooth (int amrlev, int mglev, MF& sol, const MF& rhs, int redblack) const final; + void FFlux (int amrlev, const MFIter& mfi, + const Array& flux, + const FAB& sol, Location /* loc */, + int face_only=0) const final; + + void normalize (int amrlev, int mglev, MF& mf) const final; + + [[nodiscard]] RT getAScalar () const final { return m_a_scalar; } + [[nodiscard]] RT getBScalar () const final { return m_b_scalar; } + [[nodiscard]] MF const* getACoeffs (int amrlev, int mglev) const final { return &(m_a_coeffs[amrlev][mglev]); } - virtual Array getBCoeffs (int amrlev, int mglev) const final override + [[nodiscard]] Array getBCoeffs (int amrlev, int mglev) const final { return amrex::GetArrOfConstPtrs(m_b_coeffs[amrlev][mglev]); } - virtual std::unique_ptr> makeNLinOp (int /*grid_size*/) const final override; + [[nodiscard]] std::unique_ptr> makeNLinOp (int /*grid_size*/) const final; - virtual bool supportNSolve () const final override; + [[nodiscard]] bool supportNSolve () const final; - virtual void copyNSolveSolution (MF& dst, MF const& src) const final override; + void copyNSolveSolution (MF& dst, MF const& src) const final; void averageDownCoeffsSameAmrLevel (int amrlev, Vector& a, Vector >& b); @@ -201,7 +201,7 @@ protected: Vector m_is_singular; - virtual bool supportRobinBC () const noexcept override { return true; } + [[nodiscard]] bool supportRobinBC () const noexcept override { return true; } private: @@ -218,7 +218,7 @@ MLABecLaplacianT::MLABecLaplacianT (const Vector& a_geom, const Vector& a_dmap, const LPInfo& a_info, const Vector const*>& a_factory, - const int a_ncomp) + int a_ncomp) { define(a_geom, a_grids, a_dmap, a_info, a_factory, a_ncomp); } @@ -230,12 +230,12 @@ MLABecLaplacianT::MLABecLaplacianT (const Vector& a_geom, const Vector& a_overset_mask, const LPInfo& a_info, const Vector const*>& a_factory, - const int a_ncomp) + int a_ncomp) { define(a_geom, a_grids, a_dmap, a_overset_mask, a_info, a_factory, a_ncomp); } -template MLABecLaplacianT::~MLABecLaplacianT () {} +template MLABecLaplacianT::~MLABecLaplacianT () = default; template void @@ -244,7 +244,7 @@ MLABecLaplacianT::define (const Vector& a_geom, const Vector& a_dmap, const LPInfo& a_info, const Vector const*>& a_factory, - const int a_ncomp) + int a_ncomp) { BL_PROFILE("MLABecLaplacian::define()"); this->m_ncomp = a_ncomp; @@ -260,7 +260,7 @@ MLABecLaplacianT::define (const Vector& a_geom, const Vector& a_overset_mask, const LPInfo& a_info, const Vector const*>& a_factory, - const int a_ncomp) + int a_ncomp) { BL_PROFILE("MLABecLaplacian::define(overset)"); this->m_ncomp = a_ncomp; @@ -1001,7 +1001,7 @@ template void MLABecLaplacianT::FFlux (int amrlev, const MFIter& mfi, const Array& flux, - const FAB& sol, Location, const int face_only) const + const FAB& sol, Location, int face_only) const { BL_PROFILE("MLABecLaplacian::FFlux()"); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLALaplacian.H b/Src/LinearSolvers/MLMG/AMReX_MLALaplacian.H index a27e9ed91ef..dc1dfb53e38 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLALaplacian.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLALaplacian.H @@ -20,14 +20,14 @@ public: using BCType = LinOpBCType; using Location = typename MLLinOpT::Location; - MLALaplacianT () {} + MLALaplacianT () = default; MLALaplacianT (const Vector& a_geom, const Vector& a_grids, const Vector& a_dmap, const LPInfo& a_info = LPInfo(), const Vector const*>& a_factory = {}, - const int a_ncomp = 1); - virtual ~MLALaplacianT (); + int a_ncomp = 1); + ~MLALaplacianT () override; MLALaplacianT (const MLALaplacianT&) = delete; MLALaplacianT (MLALaplacianT&&) = delete; @@ -43,33 +43,33 @@ public: void setScalars (RT a, RT b) noexcept; void setACoeffs (int amrlev, const MF& alpha); - virtual int getNComp () const override { return m_ncomp; } + [[nodiscard]] int getNComp () const override { return m_ncomp; } - virtual bool needsUpdate () const override { + [[nodiscard]] bool needsUpdate () const override { return (m_needs_update || MLCellABecLapT::needsUpdate()); } - virtual void update () override; - - virtual void prepareForSolve () final override; - virtual bool isSingular (int amrlev) const final override { return m_is_singular[amrlev]; } - virtual bool isBottomSingular () const final override { return m_is_singular[0]; } - virtual void Fapply (int amrlev, int mglev, MF& out, const MF& in) const final override; - virtual void Fsmooth (int amrlev, int mglev, MF& sol, const MF& rsh, int redblack) const final override; - virtual void FFlux (int amrlev, const MFIter& mfi, - const Array& flux, - const FAB& sol, Location /* loc */, - const int face_only=0) const final override; - - virtual void normalize (int marlve, int mglev, MF& mf) const final override; - - virtual RT getAScalar () const final override { return m_a_scalar; } - virtual RT getBScalar () const final override { return m_b_scalar; } - virtual MF const* getACoeffs (int amrlev, int mglev) const final override + void update () override; + + void prepareForSolve () final; + [[nodiscard]] bool isSingular (int amrlev) const final { return m_is_singular[amrlev]; } + [[nodiscard]] bool isBottomSingular () const final { return m_is_singular[0]; } + void Fapply (int amrlev, int mglev, MF& out, const MF& in) const final; + void Fsmooth (int amrlev, int mglev, MF& sol, const MF& rhs, int redblack) const final; + void FFlux (int amrlev, const MFIter& mfi, + const Array& flux, + const FAB& sol, Location /* loc */, + int face_only=0) const final; + + void normalize (int amrlev, int mglev, MF& mf) const final; + + [[nodiscard]] RT getAScalar () const final { return m_a_scalar; } + [[nodiscard]] RT getBScalar () const final { return m_b_scalar; } + [[nodiscard]] MF const* getACoeffs (int amrlev, int mglev) const final { return &(m_a_coeffs[amrlev][mglev]); } - virtual Array getBCoeffs (int /*amrlev*/, int /*mglev*/) const final override + [[nodiscard]] Array getBCoeffs (int /*amrlev*/, int /*mglev*/) const final { return {{ AMREX_D_DECL(nullptr,nullptr,nullptr)}}; } - virtual std::unique_ptr> makeNLinOp (int /*grid_size*/) const final override { + [[nodiscard]] std::unique_ptr> makeNLinOp (int /*grid_size*/) const final { amrex::Abort("MLALaplacian::makeNLinOp: Not implemented"); return std::unique_ptr>{}; } @@ -99,7 +99,7 @@ MLALaplacianT::MLALaplacianT (const Vector& a_geom, const Vector& a_dmap, const LPInfo& a_info, const Vector const*>& a_factory, - const int a_ncomp) + int a_ncomp) : m_ncomp(a_ncomp) { define(a_geom, a_grids, a_dmap, a_info, a_factory); @@ -132,8 +132,7 @@ MLALaplacianT::define (const Vector& a_geom, } template -MLALaplacianT::~MLALaplacianT () -{} +MLALaplacianT::~MLALaplacianT () = default; template void @@ -587,7 +586,7 @@ template void MLALaplacianT::FFlux (int amrlev, const MFIter& mfi, const Array& flux, - const FAB& sol, Location, const int face_only) const + const FAB& sol, Location, int face_only) const { AMREX_ASSERT(!this->hasHiddenDimension()); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLCGSolver.H b/Src/LinearSolvers/MLMG/AMReX_MLCGSolver.H index 69605d61d57..0b54c0309fd 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLCGSolver.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLCGSolver.H @@ -21,7 +21,9 @@ public: ~MLCGSolverT (); MLCGSolverT (const MLCGSolverT& rhs) = delete; + MLCGSolverT (MLCGSolverT&& rhs) = delete; MLCGSolverT& operator= (const MLCGSolverT& rhs) = delete; + MLCGSolverT& operator= (MLCGSolverT&& rhs) = delete; void setSolver (Type _typ) noexcept { solver_type = _typ; } @@ -35,26 +37,26 @@ public: int solve (MF& solnL, const MF& rhsL, RT eps_rel, RT eps_abs); void setVerbose (int _verbose) { verbose = _verbose; } - int getVerbose () const { return verbose; } + [[nodiscard]] int getVerbose () const { return verbose; } void setMaxIter (int _maxiter) { maxiter = _maxiter; } - int getMaxIter () const { return maxiter; } + [[nodiscard]] int getMaxIter () const { return maxiter; } void setNGhost(int _nghost) {nghost = IntVect(_nghost);} - int getNGhost() {return nghost[0];} + [[nodiscard]] int getNGhost() {return nghost[0];} - RT dotxy (const MF& r, const MF& z, bool local = false); - RT norm_inf (const MF& res, bool local = false); + [[nodiscard]] RT dotxy (const MF& r, const MF& z, bool local = false); + [[nodiscard]] RT norm_inf (const MF& res, bool local = false); int solve_bicgstab (MF& solnL, const MF& rhsL, RT eps_rel, RT eps_abs); int solve_cg (MF& solnL, const MF& rhsL, RT eps_rel, RT eps_abs); - int getNumIters () const noexcept { return iter; } + [[nodiscard]] int getNumIters () const noexcept { return iter; } private: MLLinOpT& Lp; Type solver_type; - const int amrlev; + const int amrlev = 0; const int mglev; int verbose = 0; int maxiter = 100; @@ -64,10 +66,10 @@ private: template MLCGSolverT::MLCGSolverT (MLLinOpT& _lp, Type _typ) - : Lp(_lp), solver_type(_typ), amrlev(0), mglev(_lp.NMGLevels(0)-1) + : Lp(_lp), solver_type(_typ), mglev(_lp.NMGLevels(0)-1) {} -template MLCGSolverT::~MLCGSolverT () {} +template MLCGSolverT::~MLCGSolverT () = default; template int diff --git a/Src/LinearSolvers/MLMG/AMReX_MLCellABecLap.H b/Src/LinearSolvers/MLMG/AMReX_MLCellABecLap.H index b034128877c..f58137ca9b6 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLCellABecLap.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLCellABecLap.H @@ -647,7 +647,6 @@ MLCellABecLapT::makeHypre (Hypre::Interface hypre_interface) const { if constexpr (!std::is_same()) { amrex::Abort("MLCellABecLap Hypre interface only supports MultiFab"); - return nullptr; } else { const BoxArray& ba = this->m_grids[0].back(); const DistributionMapping& dm = this->m_dmap[0].back(); @@ -695,6 +694,7 @@ MLCellABecLapT::makeHypre (Hypre::Interface hypre_interface) const return hypre_solver; } + return nullptr; } #endif @@ -705,7 +705,6 @@ MLCellABecLapT::makePETSc () const { if constexpr (!std::is_same()) { amrex::Abort("MLCellABecLap PETSc interface only supports MultiFab"); - return nullptr; } else { const BoxArray& ba = this->m_grids[0].back(); const DistributionMapping& dm = this->m_dmap[0].back(); @@ -748,6 +747,7 @@ MLCellABecLapT::makePETSc () const } return petsc_solver; } + return nullptr; } #endif diff --git a/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H b/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H index 85eeac7344c..9fa69d8de12 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H @@ -110,7 +110,7 @@ public: RT xdoty (int amrlev, int mglev, const MF& x, const MF& y, bool local) const final; virtual void Fapply (int amrlev, int mglev, MF& out, const MF& in) const = 0; - virtual void Fsmooth (int amrlev, int mglev, MF& sol, const MF& rsh, int redblack) const = 0; + virtual void Fsmooth (int amrlev, int mglev, MF& sol, const MF& rhs, int redblack) const = 0; virtual void FFlux (int amrlev, const MFIter& mfi, const Array& flux, const FAB& sol, Location loc, int face_only=0) const = 0; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.H b/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.H index 99283acc5dd..0c4937d2de5 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.H @@ -41,7 +41,7 @@ public: const Vector& a_dmap, const LPInfo& a_info); - virtual ~MLEBNodeFDLaplacian () = default; + ~MLEBNodeFDLaplacian () override = default; MLEBNodeFDLaplacian (const MLEBNodeFDLaplacian&) = delete; MLEBNodeFDLaplacian (MLEBNodeFDLaplacian&&) = delete; @@ -69,9 +69,9 @@ public: const LPInfo& a_info, const Vector& a_factory); - virtual std::unique_ptr > makeFactory (int amrlev, int mglev) const final override; + [[nodiscard]] std::unique_ptr > makeFactory (int amrlev, int mglev) const final; - virtual void scaleRHS (int amrlev, MultiFab& rhs) const final; + void scaleRHS (int amrlev, MultiFab& rhs) const final; #endif @@ -80,45 +80,45 @@ public: const Vector& a_dmap, const LPInfo& a_info); - virtual std::string name () const override { return std::string("MLEBNodeFDLaplacian"); } + [[nodiscard]] std::string name () const override { return std::string("MLEBNodeFDLaplacian"); } - virtual void restriction (int amrlev, int cmglev, MultiFab& crse, MultiFab& fine) const final override; - virtual void interpolation (int amrlev, int fmglev, MultiFab& fine, const MultiFab& crse) const final override; - virtual void averageDownSolutionRHS (int camrlev, MultiFab& crse_sol, MultiFab& crse_rhs, - const MultiFab& fine_sol, const MultiFab& fine_rhs) final override; + void restriction (int amrlev, int cmglev, MultiFab& crse, MultiFab& fine) const final; + void interpolation (int amrlev, int fmglev, MultiFab& fine, const MultiFab& crse) const final; + void averageDownSolutionRHS (int camrlev, MultiFab& crse_sol, MultiFab& crse_rhs, + const MultiFab& fine_sol, const MultiFab& fine_rhs) final; - virtual void reflux (int crse_amrlev, - MultiFab& res, const MultiFab& crse_sol, const MultiFab& crse_rhs, - MultiFab& fine_res, MultiFab& fine_sol, const MultiFab& fine_rhs) const final override; + void reflux (int crse_amrlev, + MultiFab& res, const MultiFab& crse_sol, const MultiFab& crse_rhs, + MultiFab& fine_res, MultiFab& fine_sol, const MultiFab& fine_rhs) const final; - virtual void prepareForSolve () final override; - virtual void Fapply (int amrlev, int mglev, MultiFab& out, const MultiFab& in) const final override; - virtual void Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs) const final override; - virtual void normalize (int amrlev, int mglev, MultiFab& mf) const final override; + void prepareForSolve () final; + void Fapply (int amrlev, int mglev, MultiFab& out, const MultiFab& in) const final; + void Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs) const final; + void normalize (int amrlev, int mglev, MultiFab& mf) const final; - virtual void fixUpResidualMask (int amrlev, iMultiFab& resmsk) final override; + void fixUpResidualMask (int amrlev, iMultiFab& resmsk) final; - virtual bool isSingular (int) const final override { return false; } - virtual bool isBottomSingular () const final override { return false; } + [[nodiscard]] bool isSingular (int) const final { return false; } + [[nodiscard]] bool isBottomSingular () const final { return false; } - virtual void compGrad (int amrlev, const Array& grad, - MultiFab& sol, Location /*loc*/) const override; + void compGrad (int amrlev, const Array& grad, + MultiFab& sol, Location /*loc*/) const override; #if defined(AMREX_USE_HYPRE) && (AMREX_SPACEDIM > 1) - virtual void fillIJMatrix (MFIter const& mfi, - Array4 const& gid, - Array4 const& lid, - HypreNodeLap::Int* const ncols, - HypreNodeLap::Int* const cols, - Real* const mat) const override; - - virtual void fillRHS (MFIter const& mfi, - Array4 const& lid, - Real* const rhs, - Array4 const& bfab) const override; + void fillIJMatrix (MFIter const& mfi, + Array4 const& gid, + Array4 const& lid, + HypreNodeLap::Int* ncols, + HypreNodeLap::Int* cols, + Real* mat) const override; + + void fillRHS (MFIter const& mfi, + Array4 const& lid, + Real* rhs, + Array4 const& bfab) const override; #endif - virtual void postSolve (Vector& sol) const override; + void postSolve (Vector& sol) const override; private: GpuArray m_sigma{{AMREX_D_DECL(1_rt,1_rt,1_rt)}}; @@ -136,7 +136,7 @@ MLEBNodeFDLaplacian::setEBDirichlet (F&& f) { m_phi_eb.resize(m_num_amr_levels); for (int amrlev = 0; amrlev < m_num_amr_levels; ++amrlev) { - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + auto const* factory = dynamic_cast(m_factory[amrlev][0].get()); if (factory) { Geometry const& geom = m_geom[amrlev][0]; auto const problo = geom.ProbLoArray(); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp b/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp index 58e4fbb4515..523ed4cb44d 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp @@ -639,16 +639,16 @@ void MLEBNodeFDLaplacian::fillIJMatrix (MFIter const& /*mfi*/, Array4 const& /*gid*/, Array4 const& /*lid*/, - HypreNodeLap::Int* const /*ncols*/, - HypreNodeLap::Int* const /*cols*/, - Real* const /*mat*/) const + HypreNodeLap::Int* /*ncols*/, + HypreNodeLap::Int* /*cols*/, + Real* /*mat*/) const { amrex::Abort("MLEBNodeFDLaplacian::fillIJMatrix: todo"); } void MLEBNodeFDLaplacian::fillRHS (MFIter const& /*mfi*/, Array4 const& /*lid*/, - Real* const /*rhs*/, Array4 const& /*bfab*/) const + Real* /*rhs*/, Array4 const& /*bfab*/) const { amrex::Abort("MLEBNodeFDLaplacian::fillRHS: todo"); } diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.H b/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.H index 86173801555..aa420b5635a 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.H @@ -35,7 +35,7 @@ public: const LPInfo& a_info, const Vector& a_factory); - virtual ~MLEBTensorOp (); + ~MLEBTensorOp () override; MLEBTensorOp (const MLEBTensorOp&) = delete; MLEBTensorOp (MLEBTensorOp&&) = delete; @@ -62,30 +62,35 @@ public: void setEBBulkViscosity (int amrlev, MultiFab const& kappa); void setEBBulkViscosity (int amrlev, Real kappa); - virtual int getNComp () const final override { return AMREX_SPACEDIM; } + [[nodiscard]] int getNComp () const final { return AMREX_SPACEDIM; } - virtual bool isCrossStencil () const final override { return false; } - virtual bool isTensorOp () const final override { return true; } + [[nodiscard]] bool isCrossStencil () const final { return false; } + [[nodiscard]] bool isTensorOp () const final { return true; } - virtual bool needsUpdate () const final override { + [[nodiscard]] bool needsUpdate () const final { return (m_needs_update || MLEBABecLap::needsUpdate()); } - virtual void update () final override { + void update () final { amrex::Abort("MLEBTensorOp: update TODO"); } - virtual void prepareForSolve () final override; - virtual bool isSingular (int /*armlev*/) const final override { return false; } - virtual bool isBottomSingular () const final override { return false; } + void prepareForSolve () final; + [[nodiscard]] bool isSingular (int /*armlev*/) const final { return false; } + [[nodiscard]] bool isBottomSingular () const final { return false; } - virtual void apply (int amrlev, int mglev, MultiFab& out, MultiFab& in, BCMode bc_mode, - StateMode s_mode, const MLMGBndry* bndry=nullptr) const final override; - virtual void compFlux (int amrlev, const Array& fluxes, - MultiFab& sol, Location loc) const override; + void apply (int amrlev, int mglev, MultiFab& out, MultiFab& in, BCMode bc_mode, + StateMode s_mode, const MLMGBndry* bndry=nullptr) const final; + void compFlux (int amrlev, const Array& fluxes, + MultiFab& sol, Location loc) const override; void compVelGrad (int amrlev, const Array& grads, MultiFab& sol, Location loc) const; + void setBCoeffs (int amrlev, const Array& beta, + Location a_beta_loc) = delete; + void setEBDirichlet (int amrlev, const MultiFab& phi, const MultiFab& beta) = delete; + void setEBHomogDirichlet (int amrlev, const MultiFab& beta) = delete; + protected: bool m_needs_update = true; @@ -96,11 +101,6 @@ protected: Vector > m_eb_kappa; mutable Vector > > m_tauflux; - void setBCoeffs (int amrlev, const Array& beta, - Location a_beta_loc) = delete; - void setEBDirichlet (int amrlev, const MultiFab& phi, const MultiFab& beta) = delete; - void setEBHomogDirichlet (int amrlev, const MultiFab& beta) = delete; - public: // for cuda void applyBCTensor (int amrlev, int mglev, MultiFab& vel, diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBTensor_K.H b/Src/LinearSolvers/MLMG/AMReX_MLEBTensor_K.H index 241f4ab0af6..27e50d3d988 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBTensor_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBTensor_K.H @@ -8,7 +8,7 @@ namespace amrex { AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlebtensor_weight (int d) { - return (d==2) ? 0.5 : ((d==1) ? 1.0 : 0.0); + return (d==2) ? Real(0.5) : ((d==1) ? Real(1.0) : Real(0.0)); } AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE diff --git a/Src/LinearSolvers/MLMG/AMReX_MLNodeLap_2D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLNodeLap_2D_K.H index 39015d4256b..d34290c0162 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLNodeLap_2D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLNodeLap_2D_K.H @@ -2362,7 +2362,8 @@ template void mlndlap_fillijmat_sten_cpu (Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, Real* const mat, // NOLINT(readability-non-const-parameter) + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Array4 const& sten) noexcept { constexpr auto gidmax = std::numeric_limits::max(); @@ -2433,7 +2434,8 @@ template void mlndlap_fillijmat_aa_cpu (Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, Real* const mat, // NOLINT(readability-non-const-parameter) + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Array4 const& sig, GpuArray const& dxinv, Box const& ccdom, bool is_rz) noexcept @@ -2580,7 +2582,8 @@ template void mlndlap_fillijmat_ha_cpu (Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, Real* const mat, // NOLINT(readability-non-const-parameter) + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Array4 const& sx, Array4 const& sy, GpuArray const& dxinv, @@ -2733,8 +2736,9 @@ template void mlndlap_fillijmat_cs_cpu (Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, Real* const mat, // NOLINT(readability-non-const-parameter) - Real const sig, + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) + Real sig, GpuArray const& dxinv, Box const& ccdom, bool is_rz) noexcept { @@ -2884,7 +2888,8 @@ void mlndlap_fillijmat_sten_gpu (const int ps, const int i, const int j, const i const int offset, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, Real* const mat, + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Array4 const& sten) noexcept { if (lid(i,j,k) >= 0) @@ -2993,7 +2998,8 @@ void mlndlap_fillijmat_aa_gpu (const int ps, const int i, const int j, const int const int offset, Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, Real* const mat, + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Array4 const& sig, GpuArray const& dxinv, Box const& ccdom, bool is_rz) noexcept @@ -3177,7 +3183,8 @@ void mlndlap_fillijmat_ha_gpu (const int ps, const int i, const int j, const int const int offset, Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, Real* const mat, + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Array4 const& sx, Array4 const& sy, GpuArray const& dxinv, @@ -3367,7 +3374,8 @@ void mlndlap_fillijmat_cs_gpu (const int ps, const int i, const int j, const int const int offset, Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, Real* const mat, + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Real sig, GpuArray const& dxinv, Box const& ccdom, bool is_rz) noexcept { diff --git a/Src/LinearSolvers/MLMG/AMReX_MLNodeLap_3D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLNodeLap_3D_K.H index fb9d6052fef..53ea8d9ae10 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLNodeLap_3D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLNodeLap_3D_K.H @@ -7060,8 +7060,8 @@ template void mlndlap_fillijmat_sten_cpu (Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, - Real* const mat, // NOLINT(readability-non-const-parameter) + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Array4 const& sten) noexcept { constexpr int ist_000 = 1-1; @@ -7249,8 +7249,8 @@ template void mlndlap_fillijmat_aa_cpu (Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, - Real* const mat, // NOLINT(readability-non-const-parameter) + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Array4 const& sig, GpuArray const& dxinv, Box const& ccdom) noexcept @@ -7693,8 +7693,8 @@ template void mlndlap_fillijmat_ha_cpu (Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, - Real* const mat, // NOLINT(readability-non-const-parameter) + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Array4 const& sx, Array4 const& sy, Array4 const& sz, @@ -8245,9 +8245,9 @@ template void mlndlap_fillijmat_cs_cpu (Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, - Real* const mat, // NOLINT(readability-non-const-parameter) - Real const sigma, + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) + Real sigma, GpuArray const& dxinv, Box const& ccdom) noexcept { @@ -8693,7 +8693,8 @@ void mlndlap_fillijmat_sten_gpu (const int ps, const int i, const int j, const i const int offset, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, Real* const mat, + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Array4 const& sten) noexcept { if (lid(i,j,k) >= 0) @@ -9009,7 +9010,8 @@ void mlndlap_fillijmat_aa_gpu (const int ps, const int i, const int j, const int const int offset, Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, Real* const mat, + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Array4 const& sig, GpuArray const& dxinv, Box const& ccdom) noexcept @@ -9580,7 +9582,8 @@ void mlndlap_fillijmat_ha_gpu (const int ps, const int i, const int j, const int const int offset, Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, Real* const mat, + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Array4 const& sx, Array4 const& sy, Array4 const& sz, @@ -10259,7 +10262,8 @@ void mlndlap_fillijmat_cs_gpu (const int ps, const int i, const int j, const int const int offset, Box const& ndbx, Array4 const& gid, Array4 const& lid, - HypreInt* const ncols, HypreInt* const cols, Real* const mat, + HypreInt* ncols, HypreInt* cols, + Real* mat, // NOLINT(readability-non-const-parameter) Real sigma, GpuArray const& dxinv, Box const& ccdom) noexcept { diff --git a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.H b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.H index 81f5ba9f1a2..d284eff33ee 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.H @@ -29,7 +29,7 @@ public : const Vector& a_factory, Real a_const_sigma = Real(0.0)); #endif - virtual ~MLNodeLaplacian () = default; + ~MLNodeLaplacian () override = default; MLNodeLaplacian (const MLNodeLaplacian&) = delete; MLNodeLaplacian (MLNodeLaplacian&&) = delete; @@ -52,7 +52,7 @@ public : Real a_const_sigma = Real(0.0)); #endif - virtual std::string name () const override { return std::string("MLNodeLaplacian"); } + std::string name () const override { return std::string("MLNodeLaplacian"); } void setRZCorrection (bool rz) noexcept { m_is_rz = rz; } @@ -88,42 +88,42 @@ public : m_smooth_num_sweeps = nsweeps; } - virtual BottomSolver getDefaultBottomSolver () const final override { + BottomSolver getDefaultBottomSolver () const final { return (m_coarsening_strategy == CoarseningStrategy::RAP) ? BottomSolver::bicgcg : BottomSolver::bicgstab; } - virtual void restriction (int amrlev, int cmglev, MultiFab& crse, MultiFab& fine) const final override; - virtual void interpolation (int amrlev, int fmglev, MultiFab& fine, const MultiFab& crse) const final override; - virtual void averageDownSolutionRHS (int camrlev, MultiFab& crse_sol, MultiFab& crse_rhs, - const MultiFab& fine_sol, const MultiFab& fine_rhs) final override; + void restriction (int amrlev, int cmglev, MultiFab& crse, MultiFab& fine) const final; + void interpolation (int amrlev, int fmglev, MultiFab& fine, const MultiFab& crse) const final; + void averageDownSolutionRHS (int camrlev, MultiFab& crse_sol, MultiFab& crse_rhs, + const MultiFab& fine_sol, const MultiFab& fine_rhs) final; - virtual void reflux (int crse_amrlev, + void reflux (int crse_amrlev, MultiFab& res, const MultiFab& crse_sol, const MultiFab& crse_rhs, - MultiFab& fine_res, MultiFab& fine_sol, const MultiFab& fine_rhs) const final override; + MultiFab& fine_res, MultiFab& fine_sol, const MultiFab& fine_rhs) const final; - virtual void prepareForSolve () final override; - virtual void Fapply (int amrlev, int mglev, MultiFab& out, const MultiFab& in) const final override; - virtual void Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs) const final override; - virtual void normalize (int amrlev, int mglev, MultiFab& mf) const final override; + void prepareForSolve () final; + void Fapply (int amrlev, int mglev, MultiFab& out, const MultiFab& in) const final; + void Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs) const final; + void normalize (int amrlev, int mglev, MultiFab& mf) const final; - virtual void fixUpResidualMask (int amrlev, iMultiFab& resmsk) final override; + void fixUpResidualMask (int amrlev, iMultiFab& resmsk) final; - virtual void getFluxes (const Vector >& /*a_flux*/, + void getFluxes (const Vector >& /*a_flux*/, const Vector& /*a_sol*/, - Location /*a_loc*/) const final override { + Location /*a_loc*/) const final { amrex::Abort("MLNodeLaplacian::getFluxes: How did we get here?"); } - virtual void getFluxes (const Vector& a_flux, - const Vector& a_sol) const final override; - virtual void unimposeNeumannBC (int amrlev, MultiFab& rhs) const final override; - virtual Vector getSolvabilityOffset (int amrlev, int mglev, - MultiFab const& rhs) const override; - virtual void fixSolvabilityByOffset (int amrlev, int mglev, MultiFab& rhs, - Vector const& offset) const override; - - virtual void compGrad (int /*amrlev*/, const Array& /*grad*/, - MultiFab& /*sol*/, Location /*loc*/) const final override { + void getFluxes (const Vector& a_flux, + const Vector& a_sol) const final; + void unimposeNeumannBC (int amrlev, MultiFab& rhs) const final; + Vector getSolvabilityOffset (int amrlev, int mglev, + MultiFab const& rhs) const override; + void fixSolvabilityByOffset (int amrlev, int mglev, MultiFab& rhs, + Vector const& offset) const override; + + void compGrad (int /*amrlev*/, const Array& /*grad*/, + MultiFab& /*sol*/, Location /*loc*/) const final { amrex::Abort("MLNodeLaplacian::compGrad: How did we get here?"); } void compGrad (int amrlev, MultiFab& grad, MultiFab& sol) const; @@ -148,36 +148,36 @@ public : #endif #if defined(AMREX_USE_HYPRE) && (AMREX_SPACEDIM > 1) - virtual void fillIJMatrix (MFIter const& mfi, + void fillIJMatrix (MFIter const& mfi, Array4 const& gid, Array4 const& lid, - HypreNodeLap::Int* const ncols, - HypreNodeLap::Int* const cols, - Real* const mat) const override; + HypreNodeLap::Int* ncols, + HypreNodeLap::Int* cols, + Real* mat) const override; #ifdef AMREX_USE_GPU void fillIJMatrix_gpu (MFIter const& mfi, Array4 const& gid, Array4 const& lid, - HypreNodeLap::Int* const ncols, - HypreNodeLap::Int* const cols, - Real* const mat) const; + HypreNodeLap::Int* ncols, + HypreNodeLap::Int* cols, + Real* mat) const; #endif void fillIJMatrix_cpu (MFIter const& mfi, Array4 const& gid, Array4 const& lid, - HypreNodeLap::Int* const ncols, - HypreNodeLap::Int* const cols, - Real* const mat) const; + HypreNodeLap::Int* ncols, + HypreNodeLap::Int* cols, + Real* mat) const; - virtual void fillRHS (MFIter const& mfi, Array4 const& lid, - Real* const rhs, Array4 const& bfab) const override; + void fillRHS (MFIter const& mfi, Array4 const& lid, + Real* rhs, Array4 const& bfab) const override; #endif protected: - virtual void resizeMultiGrid (int new_size) override final; + void resizeMultiGrid (int new_size) final; private: @@ -206,7 +206,7 @@ private: bool m_use_harmonic_average = false; bool m_use_mapped = false; - virtual void checkPoint (std::string const& file_name) const final; + void checkPoint (std::string const& file_name) const final; }; } diff --git a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_hypre.cpp b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_hypre.cpp index 48763a008b2..f8ec20ccc7d 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_hypre.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_hypre.cpp @@ -11,9 +11,9 @@ void MLNodeLaplacian::fillIJMatrix (MFIter const& mfi, Array4 const& gid, Array4 const& lid, - HypreNodeLap::Int* const ncols, - HypreNodeLap::Int* const cols, - Real* const mat) const + HypreNodeLap::Int* ncols, + HypreNodeLap::Int* cols, + Real* mat) const { #ifdef AMREX_USE_GPU if (Gpu::inLaunchRegion()) { @@ -31,9 +31,9 @@ void MLNodeLaplacian::fillIJMatrix_gpu (MFIter const& mfi, Array4 const& gid, Array4 const& lid, - HypreNodeLap::Int* const ncols, - HypreNodeLap::Int* const cols, - Real* const mat) const + HypreNodeLap::Int* ncols, + HypreNodeLap::Int* cols, + Real* mat) const { const int amrlev = 0; const int mglev = m_num_mg_levels[amrlev]-1; @@ -171,9 +171,9 @@ void MLNodeLaplacian::fillIJMatrix_cpu (MFIter const& mfi, Array4 const& gid, Array4 const& lid, - HypreNodeLap::Int* const ncols, - HypreNodeLap::Int* const cols, - Real* const mat) const + HypreNodeLap::Int* ncols, + HypreNodeLap::Int* cols, + Real* mat) const { const int amrlev = 0; const int mglev = m_num_mg_levels[amrlev]-1; @@ -230,7 +230,7 @@ MLNodeLaplacian::fillIJMatrix_cpu (MFIter const& mfi, void MLNodeLaplacian::fillRHS (MFIter const& mfi, Array4 const& lid, - Real* const rhs, Array4 const& bfab) const + Real* rhs, Array4 const& bfab) const { const int amrlev = 0; const int mglev = m_num_mg_levels[amrlev]-1; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLNodeLinOp.H b/Src/LinearSolvers/MLMG/AMReX_MLNodeLinOp.H index a0f6e31efb1..3c36989f79a 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLNodeLinOp.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLNodeLinOp.H @@ -76,7 +76,7 @@ public: bool skip_fillboundary=false) const; virtual void Fapply (int amrlev, int mglev, MultiFab& out, const MultiFab& in) const = 0; - virtual void Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rsh) const = 0; + virtual void Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs) const = 0; void nodalSync (int amrlev, int mglev, MultiFab& mf) const; @@ -115,16 +115,16 @@ public: virtual void fillIJMatrix (MFIter const& /*mfi*/, Array4 const& /*gid*/, Array4 const& /*lid*/, - HypreNodeLap::Int* const /*ncols*/, - HypreNodeLap::Int* const /*cols*/, - Real* const /*mat*/) const + HypreNodeLap::Int* /*ncols*/, + HypreNodeLap::Int* /*cols*/, + Real* /*mat*/) const { amrex::Abort("MLNodeLinOp::fillIJMatrix: how did we get here?"); } virtual void fillRHS (MFIter const& /*mfi*/, Array4 const& /*lid*/, - Real* const /*rhs*/, + Real* /*rhs*/, Array4 const& /*bfab*/) const { amrex::Abort("MLNodeLinOp:fillRHS: how did we get here?"); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLNodeTensorLaplacian.H b/Src/LinearSolvers/MLMG/AMReX_MLNodeTensorLaplacian.H index fce30185f96..03a73cae86d 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLNodeTensorLaplacian.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLNodeTensorLaplacian.H @@ -22,12 +22,12 @@ public: static constexpr int nelems = 6; #endif - MLNodeTensorLaplacian () noexcept {} + MLNodeTensorLaplacian () = default; MLNodeTensorLaplacian (const Vector& a_geom, const Vector& a_grids, const Vector& a_dmap, const LPInfo& a_info = LPInfo()); - virtual ~MLNodeTensorLaplacian () = default; + ~MLNodeTensorLaplacian () override = default; MLNodeTensorLaplacian (const MLNodeTensorLaplacian&) = delete; MLNodeTensorLaplacian (MLNodeTensorLaplacian&&) = delete; @@ -46,39 +46,39 @@ public: const Vector& a_dmap, const LPInfo& a_info = LPInfo()); - virtual std::string name () const override { return std::string("MLNodeTensorLaplacian"); } + [[nodiscard]] std::string name () const override { return std::string("MLNodeTensorLaplacian"); } - virtual void restriction (int amrlev, int cmglev, MultiFab& crse, MultiFab& fine) const final override; - virtual void interpolation (int amrlev, int fmglev, MultiFab& fine, const MultiFab& crse) const final override; - virtual void averageDownSolutionRHS (int camrlev, MultiFab& crse_sol, MultiFab& crse_rhs, - const MultiFab& fine_sol, const MultiFab& fine_rhs) final override; + void restriction (int amrlev, int cmglev, MultiFab& crse, MultiFab& fine) const final; + void interpolation (int amrlev, int fmglev, MultiFab& fine, const MultiFab& crse) const final; + void averageDownSolutionRHS (int camrlev, MultiFab& crse_sol, MultiFab& crse_rhs, + const MultiFab& fine_sol, const MultiFab& fine_rhs) final; - virtual void reflux (int crse_amrlev, - MultiFab& res, const MultiFab& crse_sol, const MultiFab& crse_rhs, - MultiFab& fine_res, MultiFab& fine_sol, const MultiFab& fine_rhs) const final override; + void reflux (int crse_amrlev, + MultiFab& res, const MultiFab& crse_sol, const MultiFab& crse_rhs, + MultiFab& fine_res, MultiFab& fine_sol, const MultiFab& fine_rhs) const final; - virtual void smooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs, - bool skip_fillboundary=false) const final override; + void smooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs, + bool skip_fillboundary=false) const final; - virtual void prepareForSolve () final override; - virtual void Fapply (int amrlev, int mglev, MultiFab& out, const MultiFab& in) const final override; - virtual void Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs) const final override; - virtual void normalize (int amrlev, int mglev, MultiFab& mf) const final override; + void prepareForSolve () final; + void Fapply (int amrlev, int mglev, MultiFab& out, const MultiFab& in) const final; + void Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs) const final; + void normalize (int amrlev, int mglev, MultiFab& mf) const final; - virtual void fixUpResidualMask (int amrlev, iMultiFab& resmsk) final override; + void fixUpResidualMask (int amrlev, iMultiFab& resmsk) final; #if defined(AMREX_USE_HYPRE) && (AMREX_SPACEDIM > 1) - virtual void fillIJMatrix (MFIter const& mfi, - Array4 const& gid, - Array4 const& lid, - HypreNodeLap::Int* const ncols, - HypreNodeLap::Int* const cols, - Real* const mat) const override; - - virtual void fillRHS (MFIter const& mfi, - Array4 const& lid, - Real* const rhs, - Array4 const& bfab) const override; + void fillIJMatrix (MFIter const& mfi, + Array4 const& gid, + Array4 const& lid, + HypreNodeLap::Int* ncols, + HypreNodeLap::Int* cols, + Real* mat) const override; + + void fillRHS (MFIter const& mfi, + Array4 const& lid, + Real* rhs, + Array4 const& bfab) const override; #endif private: diff --git a/Src/LinearSolvers/MLMG/AMReX_MLNodeTensorLaplacian.cpp b/Src/LinearSolvers/MLMG/AMReX_MLNodeTensorLaplacian.cpp index e31a540a296..e0a1e383722 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLNodeTensorLaplacian.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLNodeTensorLaplacian.cpp @@ -282,9 +282,9 @@ void MLNodeTensorLaplacian::fillIJMatrix (MFIter const& mfi, Array4 const& gid, Array4 const& lid, - HypreNodeLap::Int* const ncols, - HypreNodeLap::Int* const cols, - Real* const mat) const + HypreNodeLap::Int* ncols, + HypreNodeLap::Int* cols, + Real* mat) const { const int amrlev = 0; const int mglev = NMGLevels(amrlev)-1; @@ -327,7 +327,7 @@ MLNodeTensorLaplacian::fillIJMatrix (MFIter const& mfi, void MLNodeTensorLaplacian::fillRHS (MFIter const& mfi, Array4 const& lid, - Real* const rhs, Array4 const& bfab) const + Real* rhs, Array4 const& bfab) const { const Box& bx = mfi.validbox(); AMREX_HOST_DEVICE_PARALLEL_FOR_3D(bx, i, j, k, diff --git a/Src/LinearSolvers/MLMG/AMReX_MLPoisson_2D_K.H b/Src/LinearSolvers/MLMG/AMReX_MLPoisson_2D_K.H index a1ca2c4553d..9604de38feb 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLPoisson_2D_K.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLPoisson_2D_K.H @@ -2,10 +2,10 @@ #define AMREX_MLPOISSON_2D_K_H_ #include +#if (AMREX_SPACEDIM == 2) namespace amrex { - -#if (AMREX_SPACEDIM != 2) -namespace TwoD { +#else +namespace amrex::TwoD { #endif template @@ -316,10 +316,6 @@ void mlpoisson_normalize (int i, int j, int, Array4 const& x, x(i,j,0) /= (-dhx*(rel+rer) - dhy*rc*T(2.0)); } -#if (AMREX_SPACEDIM != 2) -} -#endif - } #endif diff --git a/Src/LinearSolvers/MLMG/AMReX_MLTensorOp.H b/Src/LinearSolvers/MLMG/AMReX_MLTensorOp.H index 3224296fa72..15e6ba0d7dd 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLTensorOp.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLTensorOp.H @@ -39,7 +39,7 @@ public: const Vector& a_overset_mask, // 1: unknown, 0: known const LPInfo& a_info = LPInfo(), const Vector const*>& a_factory = {}); - virtual ~MLTensorOp () = default; + ~MLTensorOp () override = default; MLTensorOp (const MLTensorOp&) = delete; MLTensorOp (MLTensorOp&&) = delete; @@ -64,31 +64,33 @@ public: void setBulkViscosity (int amrlev, const Array& kappa); void setBulkViscosity (int amrlev, Real kappa); - virtual int getNComp () const final override { return AMREX_SPACEDIM; } + [[nodiscard]] int getNComp () const final { return AMREX_SPACEDIM; } - virtual bool isCrossStencil () const final override { return false; } - virtual bool isTensorOp () const final override { return true; } + [[nodiscard]] bool isCrossStencil () const final { return false; } + [[nodiscard]] bool isTensorOp () const final { return true; } - virtual bool needsUpdate () const final override { + [[nodiscard]] bool needsUpdate () const final { return (m_needs_update || MLABecLaplacian::needsUpdate()); } - virtual void update () final override { + void update () final { amrex::Abort("MLTensorOp: update TODO"); } - virtual void prepareForSolve () final override; - virtual bool isSingular (int /*armlev*/) const final override { return false; } - virtual bool isBottomSingular () const final override { return false; } + void prepareForSolve () final; + [[nodiscard]] bool isSingular (int /*armlev*/) const final { return false; } + [[nodiscard]] bool isBottomSingular () const final { return false; } - virtual void apply (int amrlev, int mglev, MultiFab& out, MultiFab& in, BCMode bc_mode, - StateMode s_mode, const MLMGBndry* bndry=nullptr) const final override; + void apply (int amrlev, int mglev, MultiFab& out, MultiFab& in, BCMode bc_mode, + StateMode s_mode, const MLMGBndry* bndry=nullptr) const final; - virtual void compFlux (int amrlev, const Array& fluxes, - MultiFab& sol, Location loc) const override; + void compFlux (int amrlev, const Array& fluxes, + MultiFab& sol, Location loc) const override; void compVelGrad (int amrlev, const Array& fluxes, MultiFab& sol, Location loc) const; + void setBCoeffs (int amrlev, const Array& beta) = delete; + protected: bool m_needs_update = true; @@ -96,8 +98,6 @@ protected: bool m_has_kappa = false; Vector > > m_kappa; - void setBCoeffs (int amrlev, const Array& beta) = delete; - public: // for cuda void applyBCTensor (int amrlev, int mglev, MultiFab& vel, diff --git a/Src/Particle/AMReX_DenseBins.H b/Src/Particle/AMReX_DenseBins.H index e6c7678acac..a4fdc14e038 100644 --- a/Src/Particle/AMReX_DenseBins.H +++ b/Src/Particle/AMReX_DenseBins.H @@ -44,7 +44,7 @@ struct DenseBinIteratorFactory m_items(items) {} - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE BinIterator getBinIterator(const int bin_number) const noexcept { return BinIterator(bin_number, m_offsets_ptr, m_permutation_ptr, m_items); @@ -344,7 +344,7 @@ public: int nchunks = OpenMP::get_max_threads(); int chunksize = nitems / nchunks; - auto counts = (index_type*)(The_Arena()->alloc(nchunks*nbins*sizeof(index_type))); + auto* counts = (index_type*)(The_Arena()->alloc(nchunks*nbins*sizeof(index_type))); for (int i = 0; i < nbins*nchunks; ++i) { counts[i] = 0;} m_counts.resize(0); @@ -502,34 +502,32 @@ public: } } -public: - //! \brief the number of items in the container - Long numItems () const noexcept { return m_perm.size(); } + [[nodiscard]] Long numItems () const noexcept { return m_perm.size(); } //! \brief the number of bins in the container - Long numBins () const noexcept { return m_offsets.size()-1; } + [[nodiscard]] Long numBins () const noexcept { return m_offsets.size()-1; } //! \brief returns the pointer to the permutation array - index_type* permutationPtr () noexcept { return m_perm.dataPtr(); } + [[nodiscard]] index_type* permutationPtr () noexcept { return m_perm.dataPtr(); } //! \brief returns the pointer to the offsets array - index_type* offsetsPtr () noexcept { return m_offsets.dataPtr(); } + [[nodiscard]] index_type* offsetsPtr () noexcept { return m_offsets.dataPtr(); } //! \brief returns the pointer to the bins array - index_type* binsPtr () noexcept { return m_bins.dataPtr(); } + [[nodiscard]] index_type* binsPtr () noexcept { return m_bins.dataPtr(); } //! \brief returns const pointer to the permutation array - const index_type* permutationPtr () const noexcept { return m_perm.dataPtr(); } + [[nodiscard]] const index_type* permutationPtr () const noexcept { return m_perm.dataPtr(); } //! \brief returns const pointer to the offsets array - const index_type* offsetsPtr () const noexcept { return m_offsets.dataPtr(); } + [[nodiscard]] const index_type* offsetsPtr () const noexcept { return m_offsets.dataPtr(); } //! \brief returns the const pointer to the bins array - const index_type* binsPtr () const noexcept { return m_bins.dataPtr(); } + [[nodiscard]] const index_type* binsPtr () const noexcept { return m_bins.dataPtr(); } //! \brief returns a GPU-capable object that can create iterators over the items in a bin. - DenseBinIteratorFactory getBinIteratorFactory() const noexcept + [[nodiscard]] DenseBinIteratorFactory getBinIteratorFactory() const noexcept { return DenseBinIteratorFactory(m_offsets, m_perm, m_items); } diff --git a/Src/Particle/AMReX_NeighborList.H b/Src/Particle/AMReX_NeighborList.H index 88d9eabcc2e..28afc3bce9d 100644 --- a/Src/Particle/AMReX_NeighborList.H +++ b/Src/Particle/AMReX_NeighborList.H @@ -114,10 +114,10 @@ struct Neighbors AMREX_GPU_HOST_DEVICE bool operator!= (iterator const& /*rhs*/) const { return m_index < m_stop; } - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE ParticleType& operator* () const { return m_pstruct[m_nbor_list_ptr[m_index]]; } - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE unsigned int index () const { return m_nbor_list_ptr[m_index]; } private: @@ -140,10 +140,10 @@ struct Neighbors AMREX_GPU_HOST_DEVICE bool operator!= (const_iterator const& /*rhs*/) const { return m_index < m_stop; } - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE const ParticleType& operator* () const { return m_pstruct[m_nbor_list_ptr[m_index]]; } - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE unsigned int index () const { return m_nbor_list_ptr[m_index]; } private: @@ -153,37 +153,37 @@ struct Neighbors const ParticleType* m_pstruct; }; - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE iterator begin () noexcept { return iterator(m_nbor_offsets_ptr[m_i], m_nbor_offsets_ptr[m_i+1], m_nbor_list_ptr, m_pstruct); } - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE iterator end () noexcept { return iterator(m_nbor_offsets_ptr[m_i+1], m_nbor_offsets_ptr[m_i+1], m_nbor_list_ptr, m_pstruct); } - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE const_iterator begin () const noexcept { return const_iterator(m_nbor_offsets_ptr[m_i], m_nbor_offsets_ptr[m_i+1], m_nbor_list_ptr, m_pstruct); } - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE const_iterator end () const noexcept { return const_iterator(m_nbor_offsets_ptr[m_i+1], m_nbor_offsets_ptr[m_i+1], m_nbor_list_ptr, m_pstruct); } - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE const_iterator cbegin () const noexcept { return const_iterator(m_nbor_offsets_ptr[m_i], m_nbor_offsets_ptr[m_i+1], m_nbor_list_ptr, m_pstruct); } - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE const_iterator cend () const noexcept { return const_iterator(m_nbor_offsets_ptr[m_i+1], m_nbor_offsets_ptr[m_i+1], m_nbor_list_ptr, m_pstruct); @@ -217,7 +217,7 @@ struct NeighborData m_pstruct(pstruct) {} - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE amrex::Neighbors getNeighbors (int i) const { return Neighbors(i, m_nbor_offsets_ptr, m_nbor_list_ptr, m_pstruct); } @@ -258,7 +258,7 @@ public: Gpu::DeviceVector> dxi_v; Gpu::DeviceVector> plo_v; off_bins_v.push_back(0); - off_bins_v.push_back(bx.numPts()); + off_bins_v.push_back(int(bx.numPts())); lo_v.push_back(lbound(bx)); hi_v.push_back(ubound(bx)); dxi_v.push_back(geom.InvCellSizeArray()); @@ -308,16 +308,16 @@ public: const auto dst_ptile_data = target_tile.getConstParticleTileData(); m_pstruct = aos().dataPtr(); - const auto pstruct_ptr = aos().dataPtr(); + auto* const pstruct_ptr = aos().dataPtr(); const size_t np_total = aos.size(); const size_t np_real = src_tile.numRealParticles(); - auto off_bins_p = off_bins_v.data(); - auto dxi_p = dxi_v.data(); - auto plo_p = plo_v.data(); - auto lo_p = lo_v.data(); - auto hi_p = hi_v.data(); + auto const* off_bins_p = off_bins_v.data(); + auto const* dxi_p = dxi_v.data(); + auto const* plo_p = plo_v.data(); + auto const* lo_p = lo_v.data(); + auto const* hi_p = hi_v.data(); BinMapper bm(off_bins_p, dxi_p, plo_p, lo_p, hi_p, bin_type_array); // Get tot bin count on host @@ -337,14 +337,14 @@ public: m_nbor_counts.resize( np_size+1, 0); m_nbor_offsets.resize(np_size+1); - auto pnbor_counts = m_nbor_counts.dataPtr(); - auto pnbor_offset = m_nbor_offsets.dataPtr(); + auto* pnbor_counts = m_nbor_counts.dataPtr(); + auto* pnbor_offset = m_nbor_offsets.dataPtr(); auto pperm = m_bins.permutationPtr(); auto poffset = m_bins.offsetsPtr(); const auto src_ptile_data = src_tile.getConstParticleTileData(); - const auto src_pstruct_ptr = src_tile.GetArrayOfStructs()().dataPtr(); + const auto* src_pstruct_ptr = src_tile.GetArrayOfStructs()().dataPtr(); AMREX_FOR_1D ( np_size, i, { @@ -404,7 +404,7 @@ public: #endif m_nbor_list.resize(total_nbors); - auto pm_nbor_list = m_nbor_list.dataPtr(); + auto* pm_nbor_list = m_nbor_list.dataPtr(); AMREX_FOR_1D ( np_size, i, { @@ -456,16 +456,16 @@ public: return NeighborData(m_nbor_offsets, m_nbor_list, m_pstruct); } - int numParticles () { return m_nbor_offsets.size() - 1; } + [[nodiscard]] int numParticles () const { return m_nbor_offsets.size() - 1; } - Gpu::DeviceVector& GetOffsets () { return m_nbor_offsets; } - const Gpu::DeviceVector& GetOffsets () const { return m_nbor_offsets; } + [[nodiscard]] Gpu::DeviceVector& GetOffsets () { return m_nbor_offsets; } + [[nodiscard]] const Gpu::DeviceVector& GetOffsets () const { return m_nbor_offsets; } - Gpu::DeviceVector& GetCounts () { return m_nbor_counts; } - const Gpu::DeviceVector& GetCounts () const { return m_nbor_counts; } + [[nodiscard]] Gpu::DeviceVector& GetCounts () { return m_nbor_counts; } + [[nodiscard]] const Gpu::DeviceVector& GetCounts () const { return m_nbor_counts; } - Gpu::DeviceVector& GetList () { return m_nbor_list; } - const Gpu::DeviceVector& GetList () const { return m_nbor_list; } + [[nodiscard]] Gpu::DeviceVector& GetList () { return m_nbor_list; } + [[nodiscard]] const Gpu::DeviceVector& GetList () const { return m_nbor_list; } void print () { diff --git a/Src/Particle/AMReX_NeighborParticlesGPUImpl.H b/Src/Particle/AMReX_NeighborParticlesGPUImpl.H index 864a2b467ca..6338d9d55f8 100644 --- a/Src/Particle/AMReX_NeighborParticlesGPUImpl.H +++ b/Src/Particle/AMReX_NeighborParticlesGPUImpl.H @@ -71,9 +71,9 @@ buildNeighborMask () int grid = mfi.index(); std::set neighbor_grids; - for (auto pit=pshifts.cbegin(); pit!=pshifts.cend(); ++pit) + for (auto pshift : pshifts) { - const Box box = ba[mfi] + *pit; + const Box box = ba[mfi] + pshift; const bool first_only = false; auto isecs = ba.intersections(box, first_only, m_num_neighbor_cells); @@ -81,9 +81,9 @@ buildNeighborMask () for (auto& isec : isecs) { int nbor_grid = isec.first; - const Box isec_box = isec.second - *pit; - if ( (grid == nbor_grid) && (*pit == IntVect(AMREX_D_DECL(0, 0, 0)))) continue; - neighbor_grids.insert(NeighborTask(nbor_grid, isec_box, *pit)); + const Box isec_box = isec.second - pshift; + if ( (grid == nbor_grid) && (pshift == 0)) continue; + neighbor_grids.insert(NeighborTask(nbor_grid, isec_box, pshift)); const int global_rank = dmap[nbor_grid]; neighbor_procs.push_back(ParallelContext::global_to_local_rank(global_rank)); } diff --git a/Src/Particle/AMReX_NeighborParticlesI.H b/Src/Particle/AMReX_NeighborParticlesI.H index cacf041b439..56ce4ff27d8 100644 --- a/Src/Particle/AMReX_NeighborParticlesI.H +++ b/Src/Particle/AMReX_NeighborParticlesI.H @@ -241,7 +241,7 @@ IntVect NeighborParticleContainer ::computeRefFac (int src_lev, int lev) { - IntVect ref_fac = IntVect(AMREX_D_DECL(1,1,1)); + IntVect ref_fac(1); if (src_lev < lev) { for (int l = src_lev; l < lev; ++l) { ref_fac *= this->GetParGDB()->refRatio(l); @@ -279,9 +279,9 @@ NeighborParticleContainer const std::vector& pshifts = periodicity.shiftIntVect(); const BoxArray& ba = this->ParticleBoxArray(lev); - for (auto pit=pshifts.cbegin(); pit!=pshifts.cend(); ++pit) + for (auto const& pshift : pshifts) { - const Box& pbox = box + (*pit); + const Box& pbox = box + pshift; bool first_only = false; ba.intersections(pbox, isects, first_only, 0); for (const auto& isec : isects) { @@ -601,9 +601,9 @@ getNeighborTags (Vector& tags, const ParticleType& p, const std::vector& pshifts = periodicity.shiftIntVect(); const BoxArray& ba = this->ParticleBoxArray(lev); const IntVect& iv = this->Index(p, lev); - for (auto pit=pshifts.cbegin(); pit!=pshifts.cend(); ++pit) + for (auto const& pshift : pshifts) { - Box pbox = amrex::grow(Box(iv, iv), ref_fac*nGrow) + (*pit); + Box pbox = amrex::grow(Box(iv, iv), ref_fac*nGrow) + pshift; bool first_only = false; ba.intersections(pbox, isects, first_only, 0); for (const auto& isec : isects) @@ -614,7 +614,7 @@ getNeighborTags (Vector& tags, const ParticleType& p, int tile = getTileIndex(cell, grid_box, this->do_tiling, this->tile_size, tbx); auto nbor = NeighborCopyTag(lev, isec.first, tile); - nbor.periodic_shift = -1*(*pit); + nbor.periodic_shift = -pshift; if (src_tag != nbor) tags.push_back(nbor); } } @@ -737,7 +737,7 @@ buildNeighborList (CheckPair&& check_pair, bool /*sort*/) Gpu::DeviceVector> plo_v; off_bins_v.push_back(0); - off_bins_v.push_back(bx.numPts()); + off_bins_v.push_back(int(bx.numPts())); lo_v.push_back(lbound(bx)); hi_v.push_back(ubound(bx)); dxi_v.push_back(geom.InvCellSizeArray()); @@ -822,7 +822,7 @@ buildNeighborList (CheckPair&& check_pair, OtherPCType& other, Gpu::DeviceVector> plo_v; off_bins_v.push_back(0); - off_bins_v.push_back(bx.numPts()); + off_bins_v.push_back(int(bx.numPts())); lo_v.push_back(lbound(bx)); hi_v.push_back(ubound(bx)); dxi_v.push_back(geom.InvCellSizeArray()); @@ -921,7 +921,7 @@ buildNeighborList (CheckPair&& check_pair, int type_ind, int* ref_ratio, lbx.grow(NGhost); // Store for memcpy - int nbins = lbx.numPts(); + auto nbins = int(lbx.numPts()); Dim3 lo = lbound( lbx ); Dim3 hi = ubound( lbx ); @@ -1064,7 +1064,7 @@ selectActualNeighbors (CheckPair&& check_pair, int num_cells) if (call_check_pair(check_pair, ptile_data, ptile_data, i, pperm[p])) { IntVect cell_ijk = getParticleCell(pstruct[pperm[p]], plo, dxi, domain); if (!box.contains(cell_ijk)) { - unsigned int loc = Gpu::Atomic::Add(p_np_boundary, 1u); + unsigned int loc = Gpu::Atomic::Add(p_np_boundary, 1U); p_boundary_particle_ids[loc] = i; isActualNeighbor = true; break; diff --git a/Src/Particle/AMReX_ParticleCommunication.H b/Src/Particle/AMReX_ParticleCommunication.H index 14ecdfe02b7..9054948ad01 100644 --- a/Src/Particle/AMReX_ParticleCommunication.H +++ b/Src/Particle/AMReX_ParticleCommunication.H @@ -60,18 +60,18 @@ struct ParticleCopyOp void clear (); - void setNumLevels (const int num_levels); + void setNumLevels (int num_levels); - void resize (const int gid, const int lev, const int size); + void resize (int gid, int lev, int size); - int numCopies (const int gid, const int lev) const + [[nodiscard]] int numCopies (int gid, int lev) const { if (m_boxes.size() <= lev) return 0; auto mit = m_boxes[lev].find(gid); - return mit == m_boxes[lev].end() ? 0 : mit->second.size(); + return mit == m_boxes[lev].end() ? 0 : int(mit->second.size()); } - int numLevels () const { return m_boxes.size(); } + [[nodiscard]] int numLevels () const { return int(m_boxes.size()); } }; struct ParticleCopyPlan @@ -150,7 +150,7 @@ struct ParticleCopyPlan m_box_counts_d.resize(0); m_box_counts_d.resize(num_buckets+1, 0); m_box_offsets.resize(num_buckets+1); - auto p_dst_box_counts = m_box_counts_d.dataPtr(); + auto* p_dst_box_counts = m_box_counts_d.dataPtr(); auto getBucket = pc.BufferMap().getBucketFunctor(); m_dst_indices.resize(num_levels); @@ -163,9 +163,9 @@ struct ParticleCopyPlan if (num_copies == 0) continue; m_dst_indices[lev][gid].resize(num_copies); - auto p_boxes = op.m_boxes[lev].at(gid).dataPtr(); - auto p_levs = op.m_levels[lev].at(gid).dataPtr(); - auto p_dst_indices = m_dst_indices[lev][gid].dataPtr(); + const auto* p_boxes = op.m_boxes[lev].at(gid).dataPtr(); + const auto* p_levs = op.m_levels[lev].at(gid).dataPtr(); + auto* p_dst_indices = m_dst_indices[lev][gid].dataPtr(); AMREX_FOR_1D ( num_copies, i, { @@ -174,7 +174,7 @@ struct ParticleCopyPlan { int dst_lev = p_levs[i]; int index = static_cast(Gpu::Atomic::Add( - &p_dst_box_counts[getBucket(dst_lev, dst_box)], 1u)); + &p_dst_box_counts[getBucket(dst_lev, dst_box)], 1U)); p_dst_indices[i] = index; } }); @@ -279,8 +279,8 @@ struct GetSendBufferOffset Long operator() (int dst_box, int dst_lev, std::size_t psize, int i) const { int dst_pid = m_get_pid(dst_lev, dst_box); - Long dst_offset = psize*(m_box_offsets[m_get_bucket(dst_lev, dst_box)] + i); - dst_offset += m_pad_correction[dst_pid]; + Long dst_offset = Long(psize)*(m_box_offsets[m_get_bucket(dst_lev, dst_box)] + i); + dst_offset += Long(m_pad_correction[dst_pid]); return dst_offset; } }; @@ -317,8 +317,8 @@ void packBuffer (const PC& pc, const ParticleCopyOp& op, const ParticleCopyPlan& } snd_buffer.resize(total_buffer_size); - auto p_comm_real = plan.d_real_comp_mask.dataPtr(); - auto p_comm_int = plan.d_int_comp_mask.dataPtr(); + const auto* p_comm_real = plan.d_real_comp_mask.dataPtr(); + const auto* p_comm_int = plan.d_int_comp_mask.dataPtr(); const auto plo = pc.Geom(0).ProbLoArray(); const auto phi = pc.Geom(0).ProbHiArray(); @@ -338,12 +338,12 @@ void packBuffer (const PC& pc, const ParticleCopyOp& op, const ParticleCopyPlan& int num_copies = op.numCopies(gid, lev); if (num_copies == 0) continue; - auto p_boxes = op.m_boxes[lev].at(gid).dataPtr(); - auto p_levels = op.m_levels[lev].at(gid).dataPtr(); - auto p_src_indices = op.m_src_indices[lev].at(gid).dataPtr(); - auto p_periodic_shift = op.m_periodic_shift[lev].at(gid).dataPtr(); - auto p_dst_indices = plan.m_dst_indices[lev].at(gid).dataPtr(); - auto p_snd_buffer = snd_buffer.dataPtr(); + const auto* p_boxes = op.m_boxes[lev].at(gid).dataPtr(); + const auto* p_levels = op.m_levels[lev].at(gid).dataPtr(); + const auto* p_src_indices = op.m_src_indices[lev].at(gid).dataPtr(); + const auto* p_periodic_shift = op.m_periodic_shift[lev].at(gid).dataPtr(); + const auto* p_dst_indices = plan.m_dst_indices[lev].at(gid).dataPtr(); + auto* p_snd_buffer = snd_buffer.dataPtr(); GetSendBufferOffset get_offset(plan, pc.BufferMap()); AMREX_FOR_1D ( num_copies, i, @@ -415,8 +415,8 @@ void unpackBuffer (PC& pc, const ParticleCopyPlan& plan, const Buffer& snd_buffe std::vector offsets; policy.resizeTiles(tiles, sizes, offsets); - auto p_comm_real = plan.d_real_comp_mask.dataPtr(); - auto p_comm_int = plan.d_int_comp_mask.dataPtr(); + const auto* p_comm_real = plan.d_real_comp_mask.dataPtr(); + const auto* p_comm_int = plan.d_int_comp_mask.dataPtr(); // local unpack int uindex = 0; @@ -475,8 +475,8 @@ void communicateParticlesStart (const PC& pc, ParticleCopyPlan& plan, const SndB rOffset.push_back(TotRcvBytes); Long nbytes = plan.m_rcv_num_particles[i]*psize; std::size_t acd = ParallelDescriptor::alignof_comm_data(nbytes); - TotRcvBytes = amrex::aligned_size(acd, TotRcvBytes); - TotRcvBytes += amrex::aligned_size(acd, nbytes); + TotRcvBytes = Long(amrex::aligned_size(acd, TotRcvBytes)); + TotRcvBytes += Long(amrex::aligned_size(acd, nbytes)); plan.m_rcv_pad_correction_h.push_back(plan.m_rcv_pad_correction_h.back() + nbytes); } } @@ -492,7 +492,7 @@ void communicateParticlesStart (const PC& pc, ParticleCopyPlan& plan, const SndB rcv_buffer.resize(TotRcvBytes); - plan.m_nrcvs = RcvProc.size(); + plan.m_nrcvs = int(RcvProc.size()); plan.m_particle_stats.resize(0); plan.m_particle_stats.resize(plan.m_nrcvs); @@ -561,13 +561,13 @@ void unpackRemotes (PC& pc, const ParticleCopyPlan& plan, Buffer& rcv_buffer, Un if (plan.m_nrcvs > 0) { - auto p_comm_real = plan.d_real_comp_mask.dataPtr(); - auto p_comm_int = plan.d_int_comp_mask.dataPtr(); - auto p_rcv_buffer = rcv_buffer.dataPtr(); + const auto* p_comm_real = plan.d_real_comp_mask.dataPtr(); + const auto* p_comm_int = plan.d_int_comp_mask.dataPtr(); + auto* p_rcv_buffer = rcv_buffer.dataPtr(); std::vector sizes; std::vector tiles; - for (int i = 0, N = plan.m_rcv_box_counts.size(); i < N; ++i) + for (int i = 0, N = int(plan.m_rcv_box_counts.size()); i < N; ++i) { int copy_size = plan.m_rcv_box_counts[i]; int lev = plan.m_rcv_box_levs[i]; @@ -583,7 +583,7 @@ void unpackRemotes (PC& pc, const ParticleCopyPlan& plan, Buffer& rcv_buffer, Un Gpu::streamSynchronize(); int uindex = 0; int procindex = 0, rproc = plan.m_rcv_box_pids[0]; - for (int i = 0, N = plan.m_rcv_box_counts.size(); i < N; ++i) + for (int i = 0, N = int(plan.m_rcv_box_counts.size()); i < N; ++i) { int lev = plan.m_rcv_box_levs[i]; int gid = plan.m_rcv_box_ids[i]; @@ -603,7 +603,7 @@ void unpackRemotes (PC& pc, const ParticleCopyPlan& plan, Buffer& rcv_buffer, Un ++uindex; Long psize = plan.superParticleSize(); - auto p_pad_adjust = plan.m_rcv_pad_correction_d.dataPtr(); + const auto* p_pad_adjust = plan.m_rcv_pad_correction_d.dataPtr(); AMREX_FOR_1D ( size, ip, { Long src_offset = psize*(offset + ip) + p_pad_adjust[procindex]; diff --git a/Src/Particle/AMReX_ParticleCommunication.cpp b/Src/Particle/AMReX_ParticleCommunication.cpp index 908db2a0e39..8952451ff2e 100644 --- a/Src/Particle/AMReX_ParticleCommunication.cpp +++ b/Src/Particle/AMReX_ParticleCommunication.cpp @@ -11,7 +11,7 @@ void ParticleCopyOp::clear () m_periodic_shift.resize(0); } -void ParticleCopyOp::setNumLevels (const int num_levels) +void ParticleCopyOp::setNumLevels (int num_levels) { m_boxes.resize(num_levels); m_levels.resize(num_levels); @@ -19,7 +19,7 @@ void ParticleCopyOp::setNumLevels (const int num_levels) m_periodic_shift.resize(num_levels); } -void ParticleCopyOp::resize (const int gid, const int lev, const int size) +void ParticleCopyOp::resize (int gid, int lev, int size) { if (lev >= m_boxes.size()) { diff --git a/Src/Particle/AMReX_ParticleIO.H b/Src/Particle/AMReX_ParticleIO.H index cfc55dfd550..d6f8d47ccc9 100644 --- a/Src/Particle/AMReX_ParticleIO.H +++ b/Src/Particle/AMReX_ParticleIO.H @@ -434,7 +434,7 @@ ParticleContainer_impl ParallelDescriptor::ReduceLongMax(maxnextid, IOProcNumber); nparticlesPrePost = nparticles; - maxnextidPrePost = maxnextid; + maxnextidPrePost = int(maxnextid); nParticlesAtLevelPrePost.clear(); nParticlesAtLevelPrePost.resize(finestLevel() + 1, 0); @@ -491,7 +491,7 @@ ParticleContainer_impl cnt[whichPrePost[lev][i]] += countPrePost[lev][i]; } - for(int i(0), N = cnt.size(); i < N; ++i) { + for(int i(0), N = int(cnt.size()); i < N; ++i) { if(cnt[i] == 0) { std::string FullFileName = NFilesIter::FileName(i, filePrefixPrePost[lev]); FileSystem::Remove(FullFileName); @@ -712,7 +712,8 @@ ParticleContainer_impl for (int lev = 0; lev <= finest_level_in_file; lev++) { std::string phdr_name = fullname; - phdr_name = amrex::Concatenate(phdr_name + "/Level_", lev, 1); + phdr_name += "/Level_"; + phdr_name = amrex::Concatenate(phdr_name, lev, 1); phdr_name += "/Particle_H"; if (amrex::FileExists(phdr_name)) { @@ -728,7 +729,8 @@ ParticleContainer_impl old_dms[lev] = ParticleDistributionMap(lev); old_bas[lev] = ParticleBoxArray(lev); std::string phdr_name = fullname; - phdr_name = amrex::Concatenate(phdr_name + "/Level_", lev, 1); + phdr_name += "/Level_"; + phdr_name = amrex::Concatenate(phdr_name, lev, 1); phdr_name += "/Particle_H"; if (! amrex::FileExists(phdr_name)) continue; @@ -907,12 +909,12 @@ ParticleContainer_impl // the m_lev and m_grid data on disk. We can easily recreate // that given the structure of the checkpoint file. const int iChunkSize = 2 + NStructInt + NumIntComps(); - Vector istuff(cnt*iChunkSize); + Vector istuff(std::size_t(cnt)*iChunkSize); readIntData(istuff.dataPtr(), istuff.size(), ifs, FPC::NativeIntDescriptor()); // Then the real data in binary. const int rChunkSize = AMREX_SPACEDIM + NStructReal + NumRealComps(); - Vector rstuff(cnt*rChunkSize); + Vector rstuff(std::size_t(cnt)*rChunkSize); ReadParticleRealData(rstuff.dataPtr(), rstuff.size(), ifs); // Now reassemble the particles. @@ -1024,42 +1026,42 @@ ParticleContainer_impl for (int host_lev = 0; host_lev < static_cast(host_particles.size()); ++host_lev) { for (auto& kv : host_particles[host_lev]) { - auto grid = kv.first.first; - auto tile = kv.first.second; - const auto& src_tile = kv.second; - - auto& dst_tile = DefineAndReturnParticleTile(host_lev, grid, tile); - auto old_size = dst_tile.size(); - auto new_size = old_size; - if constexpr(!ParticleType::is_soa_particle) - { - new_size += src_tile.size(); - } else { - new_size += host_real_attribs[host_lev][std::make_pair(grid,tile)][0].size(); - } - dst_tile.resize(new_size); - - if constexpr(!ParticleType::is_soa_particle) - { - Gpu::copyAsync(Gpu::hostToDevice, src_tile.begin(), src_tile.end(), - dst_tile.GetArrayOfStructs().begin() + old_size); - } - - for (int i = 0; i < NumRealComps(); ++i) { - Gpu::copyAsync(Gpu::hostToDevice, - host_real_attribs[host_lev][std::make_pair(grid,tile)][i].begin(), - host_real_attribs[host_lev][std::make_pair(grid,tile)][i].end(), - dst_tile.GetStructOfArrays().GetRealData(i).begin() + old_size); - } - - for (int i = 0; i < NumIntComps(); ++i) { - Gpu::copyAsync(Gpu::hostToDevice, - host_int_attribs[host_lev][std::make_pair(grid,tile)][i].begin(), - host_int_attribs[host_lev][std::make_pair(grid,tile)][i].end(), - dst_tile.GetStructOfArrays().GetIntData(i).begin() + old_size); - } + auto grid = kv.first.first; + auto tile = kv.first.second; + const auto& src_tile = kv.second; + + auto& dst_tile = DefineAndReturnParticleTile(host_lev, grid, tile); + auto old_size = dst_tile.size(); + auto new_size = old_size; + if constexpr(!ParticleType::is_soa_particle) + { + new_size += src_tile.size(); + } else { + new_size += host_real_attribs[host_lev][std::make_pair(grid,tile)][0].size(); + } + dst_tile.resize(new_size); + + if constexpr(!ParticleType::is_soa_particle) + { + Gpu::copyAsync(Gpu::hostToDevice, src_tile.begin(), src_tile.end(), + dst_tile.GetArrayOfStructs().begin() + old_size); + } + + for (int i = 0; i < NumRealComps(); ++i) { // NOLINT(readability-misleading-indentation) + Gpu::copyAsync(Gpu::hostToDevice, + host_real_attribs[host_lev][std::make_pair(grid,tile)][i].begin(), + host_real_attribs[host_lev][std::make_pair(grid,tile)][i].end(), + dst_tile.GetStructOfArrays().GetRealData(i).begin() + old_size); + } + + for (int i = 0; i < NumIntComps(); ++i) { + Gpu::copyAsync(Gpu::hostToDevice, + host_int_attribs[host_lev][std::make_pair(grid,tile)][i].begin(), + host_int_attribs[host_lev][std::make_pair(grid,tile)][i].end(), + dst_tile.GetStructOfArrays().GetIntData(i).begin() + old_size); + } } - } + } Gpu::streamSynchronize(); } @@ -1153,46 +1155,46 @@ ParticleContainer_impl amrex::FileOpenFailed(filename); for (int lev = 0; lev < m_particles.size(); lev++) { - auto& pmap = m_particles[lev]; - for (const auto& kv : pmap) { - ParticleTile pinned_ptile; - pinned_ptile.define(NumRuntimeRealComps(), NumRuntimeIntComps()); - pinned_ptile.resize(kv.second.numParticles()); - amrex::copyParticles(pinned_ptile, kv.second); - const auto& host_aos = pinned_ptile.GetArrayOfStructs(); - const auto& host_soa = pinned_ptile.GetStructOfArrays(); - - auto np = host_aos.numParticles(); - for (int index = 0; index < np; ++index) { - const ParticleType* it = &host_aos[index]; - if (it->id() > 0) { - - // write out the particle struct first... - AMREX_D_TERM(File << it->pos(0) << ' ', - << it->pos(1) << ' ', - << it->pos(2) << ' '); - - for (int i = 0; i < NStructReal; i++) - File << it->rdata(i) << ' '; - - File << it->id() << ' '; - File << it->cpu() << ' '; - - for (int i = 0; i < NStructInt; i++) - File << it->idata(i) << ' '; - - // then the particle attributes. - for (int i = 0; i < NumRealComps(); i++) - File << host_soa.GetRealData(i)[index] << ' '; - - for (int i = 0; i < NumIntComps(); i++) - File << host_soa.GetIntData(i)[index] << ' '; - - File << '\n'; + auto& pmap = m_particles[lev]; + for (const auto& kv : pmap) { + ParticleTile pinned_ptile; + pinned_ptile.define(NumRuntimeRealComps(), NumRuntimeIntComps()); + pinned_ptile.resize(kv.second.numParticles()); + amrex::copyParticles(pinned_ptile, kv.second); + const auto& host_aos = pinned_ptile.GetArrayOfStructs(); + const auto& host_soa = pinned_ptile.GetStructOfArrays(); + + auto np = host_aos.numParticles(); + for (int index = 0; index < np; ++index) { + const ParticleType* it = &host_aos[index]; + if (it->id() > 0) { + + // write out the particle struct first... + AMREX_D_TERM(File << it->pos(0) << ' ', + << it->pos(1) << ' ', + << it->pos(2) << ' '); + + for (int i = 0; i < NStructReal; i++) + File << it->rdata(i) << ' '; + + File << it->id() << ' '; + File << it->cpu() << ' '; + + for (int i = 0; i < NStructInt; i++) + File << it->idata(i) << ' '; + + // then the particle attributes. + for (int i = 0; i < NumRealComps(); i++) + File << host_soa.GetRealData(i)[index] << ' '; + + for (int i = 0; i < NumIntComps(); i++) + File << host_soa.GetIntData(i)[index] << ' '; + + File << '\n'; + } } } - } } File.flush(); diff --git a/Src/Particle/AMReX_ParticleInit.H b/Src/Particle/AMReX_ParticleInit.H index 28427de32fb..04e8b75fbc3 100644 --- a/Src/Particle/AMReX_ParticleInit.H +++ b/Src/Particle/AMReX_ParticleInit.H @@ -213,7 +213,7 @@ ParticleContainer_impl // Shift the position. for (int d=0; d(p.pos(d) + (rep[d]-1)*DomSize[d]); + p_rep.pos(d) = static_cast(p.pos(d) + Real(rep[d]-1)*DomSize[d]); } // Copy the extra data @@ -558,7 +558,7 @@ InitFromBinaryFile (const std::string& file, { do { - int n = int(amrex::Random() * (NProcs-1)); + auto n = int(amrex::Random() * Real(NProcs-1)); AMREX_ASSERT(n >= 0); AMREX_ASSERT(n < NProcs); @@ -571,7 +571,7 @@ InitFromBinaryFile (const std::string& file, int i = 0; - for (std::set::const_iterator it = readers.begin(), End = readers.end(); + for (auto it = readers.cbegin(), End = readers.cend(); it != End; ++it, ++i) { @@ -645,7 +645,7 @@ InitFromBinaryFile (const std::string& file, // const std::streamoff ENDPOS = ifs.tellg(); - RealSizeInFile = (ENDPOS - CURPOS) / (NP*(DM+NX)); + RealSizeInFile = int((ENDPOS - CURPOS) / (NP*(DM+NX))); AMREX_ASSERT(RealSizeInFile == sizeof(float) || RealSizeInFile == sizeof(double)); // @@ -763,14 +763,14 @@ InitFromBinaryFile (const std::string& file, { if (RealSizeInFile == sizeof(float)) { - ifs.read((char*)&fxtra[0], extradata*sizeof(float)); + ifs.read((char*)&fxtra[0], std::streamsize(extradata*sizeof(float))); for (int ii = 0; ii < extradata; ii++) p.rdata(ii) = static_cast(fxtra[ii]); } else if (RealSizeInFile == sizeof(double)) { - ifs.read((char*)&dxtra[0], extradata*sizeof(double)); + ifs.read((char*)&dxtra[0], std::streamsize(extradata*sizeof(double))); for (int ii = 0; ii < extradata; ii++) p.rdata(ii) = static_cast(dxtra[ii]); @@ -783,11 +783,11 @@ InitFromBinaryFile (const std::string& file, { if (RealSizeInFile == sizeof(float)) { - ifs.read((char*)&fignore[0], (NX-extradata)*sizeof(float)); + ifs.read((char*)&fignore[0], std::streamsize((NX-extradata)*sizeof(float))); } else if (RealSizeInFile == sizeof(double)) { - ifs.read((char*)&dignore[0], (NX-extradata)*sizeof(double)); + ifs.read((char*)&dignore[0], std::streamsize((NX-extradata)*sizeof(double))); } } @@ -957,7 +957,7 @@ InitRandom (Long icount, AMREX_ASSERT(iseed > 0); AMREX_ASSERT(icount > 0); - AMREX_ASSERT(m_gdb != 0); + AMREX_ASSERT(m_gdb != nullptr); const int MyProc = ParallelDescriptor::MyProc(); const int NProcs = ParallelDescriptor::NProcs(); @@ -1141,7 +1141,7 @@ InitRandom (Long icount, dst_tile.GetArrayOfStructs().begin() + old_size); } - for (int i = 0; i < NArrayReal; ++i) { + for (int i = 0; i < NArrayReal; ++i) { // NOLINT(readability-misleading-indentation) Gpu::copyAsync(Gpu::hostToDevice, host_real_attribs[host_lev][std::make_pair(grid,tile)][i].begin(), host_real_attribs[host_lev][std::make_pair(grid,tile)][i].end(), @@ -1284,7 +1284,7 @@ InitRandom (Long icount, dst_tile.GetArrayOfStructs().begin() + old_size); } - for (int i = 0; i < NArrayReal; ++i) { + for (int i = 0; i < NArrayReal; ++i) { // NOLINT(readability-misleading-indentation) Gpu::copyAsync(Gpu::hostToDevice, host_real_attribs[host_lev][std::make_pair(grid,tile)][i].begin(), host_real_attribs[host_lev][std::make_pair(grid,tile)][i].end(), @@ -1329,7 +1329,7 @@ ParticleContainer_impl AMREX_ASSERT(iseed > 0); AMREX_ASSERT(icount_per_box > 0); - AMREX_ASSERT(m_gdb != 0); + AMREX_ASSERT(m_gdb != nullptr); const int IOProc = ParallelDescriptor::IOProcessorNumber(); const auto strttime = amrex::second(); @@ -1362,9 +1362,9 @@ ParticleContainer_impl for (Long jcnt = 0; jcnt < icount_per_box; jcnt++) { for (Long kcnt = 0; kcnt < icount_per_box; kcnt++) { - p.pos(0) = static_cast(grid_box.lo(0) + (dist(mt) + icnt) / icount_per_box * grid_box.length(0)); - p.pos(1) = static_cast(grid_box.lo(1) + (dist(mt) + jcnt) / icount_per_box * grid_box.length(1)); - p.pos(2) = static_cast(grid_box.lo(2) + (dist(mt) + kcnt) / icount_per_box * grid_box.length(2)); + p.pos(0) = static_cast(grid_box.lo(0) + (dist(mt) + double(icnt)) / double(icount_per_box) * grid_box.length(0)); + p.pos(1) = static_cast(grid_box.lo(1) + (dist(mt) + double(jcnt)) / double(icount_per_box) * grid_box.length(1)); + p.pos(2) = static_cast(grid_box.lo(2) + (dist(mt) + double(kcnt)) / double(icount_per_box) * grid_box.length(2)); for (int i = 0; i < AMREX_SPACEDIM; i++) AMREX_ASSERT(p.pos(i) < grid_box.hi(i)); @@ -1425,7 +1425,7 @@ InitOnePerCell (Real x_off, Real y_off, Real z_off, const ParticleInitData& pdat BL_PROFILE("ParticleContainer::InitOnePerCell()"); - AMREX_ASSERT(m_gdb != 0); + AMREX_ASSERT(m_gdb != nullptr); // Note that x_off, y_off and z_off are the offsets from the lower left corner // in each cell as measured in units of dx, so they must be in [0,1] @@ -1507,7 +1507,7 @@ InitNRandomPerCell (int n_per_cell, const ParticleInitData& pdata) { BL_PROFILE("ParticleContainer::InitNRandomPerCell()"); - AMREX_ASSERT(m_gdb != 0); + AMREX_ASSERT(m_gdb != nullptr); const int IOProc = ParallelDescriptor::IOProcessorNumber(); const auto strttime = amrex::second(); @@ -1554,7 +1554,7 @@ InitNRandomPerCell (int n_per_cell, const ParticleInitData& pdata) int iter = 0; while (iter < max_iter) { r = amrex::Random(); - p.pos(i) = static_cast(grid_box.lo(i) + (r + cell[i]-beg[i])*dx[i]); + p.pos(i) = static_cast(grid_box.lo(i) + (r + Real(cell[i]-beg[i]))*dx[i]); if (p.pos(i) < grid_box.hi(i)) break; iter++; } diff --git a/Src/Particle/AMReX_ParticleTile.H b/Src/Particle/AMReX_ParticleTile.H index 3b5ee15fdb0..de01c31fc06 100644 --- a/Src/Particle/AMReX_ParticleTile.H +++ b/Src/Particle/AMReX_ParticleTile.H @@ -51,7 +51,7 @@ struct ParticleTileData ParticleReal* AMREX_RESTRICT * AMREX_RESTRICT m_runtime_rdata; int* AMREX_RESTRICT * AMREX_RESTRICT m_runtime_idata; - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE ParticleReal& pos (const int dir, const int index) const & { if constexpr(!ParticleType::is_soa_particle) { @@ -61,7 +61,7 @@ struct ParticleTileData } } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE decltype(auto) id (const int index) const & { if constexpr(!ParticleType::is_soa_particle) { @@ -71,7 +71,7 @@ struct ParticleTileData } } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE decltype(auto) cpu (const int index) const & { if constexpr(!ParticleType::is_soa_particle) { @@ -81,13 +81,13 @@ struct ParticleTileData } } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE ParticleReal * rdata (const int attribute_index) const { return this->m_rdata[attribute_index]; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int * idata (const int attribute_index) const { return this->m_idata[attribute_index]; @@ -108,7 +108,7 @@ struct ParticleTileData const int* comm_real, const int * comm_int) const noexcept { AMREX_ASSERT(src_index < m_size); - auto dst = buffer + dst_offset; + auto* dst = buffer + dst_offset; if constexpr (!ParticleType::is_soa_particle) { memcpy(dst, m_aos + src_index, sizeof(ParticleType)); dst += sizeof(ParticleType); @@ -156,7 +156,7 @@ struct ParticleTileData const int* comm_real, const int* comm_int) const noexcept { AMREX_ASSERT(dst_index < m_size); - auto src = buffer + src_offset; + const auto* src = buffer + src_offset; if constexpr (!ParticleType::is_soa_particle) { memcpy(m_aos + dst_index, src, sizeof(ParticleType)); src += sizeof(ParticleType); @@ -200,7 +200,7 @@ struct ParticleTileData } template ::type = 0> - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE SuperParticleType getSuperParticle (int index) const noexcept { AMREX_ASSERT(index < m_size); @@ -221,7 +221,7 @@ struct ParticleTileData } template ::type = 0> - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE SuperParticleType getSuperParticle (int index) const noexcept { AMREX_ASSERT(index < m_size); @@ -279,8 +279,8 @@ struct ConstSoAParticle : SoAParticleBase using RealType = ParticleReal; AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - ConstSoAParticle(ConstPTD const& ptd, long i) : - m_constparticle_tile_data(ptd), m_index(i) + ConstSoAParticle (ConstPTD const& ptd, long i) : // Note: should this be int instead? + m_constparticle_tile_data(ptd), m_index(int(i)) { } @@ -288,18 +288,18 @@ struct ConstSoAParticle : SoAParticleBase //functions to get id and cpu in the SOA data - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int cpu () const { return this->m_constparticle_tile_data.m_idata[1][m_index]; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int id () const { return this->m_constparticle_tile_data.m_idata[0][m_index]; } //functions to get positions of the particle in the SOA data - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE RealVect pos () const & {return RealVect(AMREX_D_DECL(this->m_constparticle_tile_data.m_rdata[0][m_index], this->m_constparticle_tile_data.m_rdata[1][m_index], this->m_constparticle_tile_data.m_rdata[2][m_index]));} - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const RealType& pos (int position_index) const & { AMREX_ASSERT(position_index < AMREX_SPACEDIM); @@ -342,8 +342,8 @@ struct SoAParticle : SoAParticleBase using RealType = ParticleReal; AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - SoAParticle(PTD const& ptd, long i) : - m_particle_tile_data(ptd), m_index(i) + SoAParticle (PTD const& ptd, long i) : // Note: should this be int instead? + m_particle_tile_data(ptd), m_index(int(i)) { } @@ -351,32 +351,32 @@ struct SoAParticle : SoAParticleBase //functions to get id and cpu in the SOA data - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int& cpu () & { return this->m_particle_tile_data.m_idata[1][m_index]; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int& id () & { return this->m_particle_tile_data.m_idata[0][m_index]; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int& cpu () const & { return this->m_particle_tile_data.m_idata[1][m_index]; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int& id () const & { return this->m_particle_tile_data.m_idata[0][m_index]; } //functions to get positions of the particle in the SOA data - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE RealVect pos () const & {return RealVect(AMREX_D_DECL(this->m_particle_tile_data.m_rdata[0][m_index], this->m_particle_tile_data.m_rdata[1][m_index], this->m_particle_tile_data.m_rdata[2][m_index]));} - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE RealType& pos (int position_index) & { AMREX_ASSERT(position_index < AMREX_SPACEDIM); return this->m_particle_tile_data.m_rdata[position_index][m_index]; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - RealType pos (int position_index) const & + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + RealType pos (int position_index) const & { AMREX_ASSERT(position_index < AMREX_SPACEDIM); return this->m_particle_tile_data.m_rdata[position_index][m_index]; @@ -464,7 +464,7 @@ struct ConstParticleTileData GpuArray m_rdata; GpuArray m_idata; - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const ParticleReal& pos (const int dir, const int index) const & { if constexpr(!ParticleType::is_soa_particle) { @@ -474,7 +474,7 @@ struct ConstParticleTileData } } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE decltype(auto) id (const int index) const & { if constexpr(!ParticleType::is_soa_particle) { @@ -484,7 +484,7 @@ struct ConstParticleTileData } } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE decltype(auto) cpu (const int index) const & { if constexpr(!ParticleType::is_soa_particle) { @@ -494,19 +494,19 @@ struct ConstParticleTileData } } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const ParticleReal * rdata (const int attribute_index) const { return this->m_rdata[attribute_index]; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int * idata (const int attribute_index) const { return this->m_idata[attribute_index]; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE decltype(auto) operator[] (const int index) const { if constexpr (!ParticleType::is_soa_particle) { @@ -526,7 +526,7 @@ struct ConstParticleTileData const int* comm_real, const int * comm_int) const noexcept { AMREX_ASSERT(src_index < m_size); - auto dst = buffer + dst_offset; + auto* dst = buffer + dst_offset; if constexpr (!ParticleType::is_soa_particle) { memcpy(dst, m_aos + src_index, sizeof(ParticleType)); dst += sizeof(ParticleType); @@ -570,7 +570,7 @@ struct ConstParticleTileData } template ::type = 0> - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE SuperParticleType getSuperParticle (int index) const noexcept { AMREX_ASSERT(index < m_size); @@ -593,7 +593,7 @@ struct ConstParticleTileData } template ::type = 0> - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE SuperParticleType getSuperParticle (int index) const noexcept { AMREX_ASSERT(index < m_size); @@ -637,9 +637,7 @@ struct ParticleTile using ParticleTileDataType = ParticleTileData; using ConstParticleTileDataType = ConstParticleTileData; - ParticleTile () - : m_defined(false) - {} + ParticleTile () = default; void define (int a_num_runtime_real, int a_num_runtime_int) { @@ -1142,7 +1140,7 @@ private: AoS m_aos_tile; SoA m_soa_tile; - bool m_defined; + bool m_defined = false; amrex::PODVector > m_runtime_r_ptrs; amrex::PODVector > m_runtime_i_ptrs; diff --git a/Src/Particle/AMReX_ParticleTransformation.H b/Src/Particle/AMReX_ParticleTransformation.H index af932788734..95d555594ab 100644 --- a/Src/Particle/AMReX_ParticleTransformation.H +++ b/Src/Particle/AMReX_ParticleTransformation.H @@ -330,7 +330,7 @@ Index filterParticles (DstTile& dst, const SrcTile& src, const Index* mask, Gpu::copyAsync(Gpu::deviceToHost, mask+n-1, mask + n, &last_mask); Gpu::copyAsync(Gpu::deviceToHost, offsets.data()+n-1, offsets.data()+n, &last_offset); - auto p_offsets = offsets.dataPtr(); + auto* p_offsets = offsets.dataPtr(); const auto src_data = src.getConstParticleTileData(); auto dst_data = dst.getParticleTileData(); @@ -386,7 +386,7 @@ auto filterParticles (DstTile& dst, const SrcTile& src, Pred&& p, { Gpu::DeviceVector mask(n); - auto p_mask = mask.dataPtr(); + auto* p_mask = mask.dataPtr(); const auto src_data = src.getConstParticleTileData(); amrex::ParallelForRNG(n, @@ -425,7 +425,7 @@ Index filterAndTransformParticles (DstTile& dst, const SrcTile& src, Index* mask Gpu::copyAsync(Gpu::deviceToHost, mask+np-1, mask + np, &last_mask); Gpu::copyAsync(Gpu::deviceToHost, offsets.data()+np-1, offsets.data()+np, &last_offset); - auto p_offsets = offsets.dataPtr(); + auto const* p_offsets = offsets.dataPtr(); const auto src_data = src.getConstParticleTileData(); auto dst_data = dst.getParticleTileData(); @@ -513,7 +513,7 @@ Index filterAndTransformParticles (DstTile1& dst1, DstTile2& dst2, Gpu::copyAsync(Gpu::deviceToHost, mask+np-1, mask + np, &last_mask); Gpu::copyAsync(Gpu::deviceToHost, offsets.data()+np-1, offsets.data()+np, &last_offset); - auto p_offsets = offsets.dataPtr(); + auto* p_offsets = offsets.dataPtr(); const auto src_data = src.getConstParticleTileData(); auto dst_data1 = dst1.getParticleTileData(); @@ -552,7 +552,7 @@ int filterAndTransformParticles (DstTile1& dst1, DstTile2& dst2, const SrcTile& auto np = src.numParticles(); Gpu::DeviceVector mask(np); - auto p_mask = mask.dataPtr(); + auto* p_mask = mask.dataPtr(); const auto src_data = src.getConstParticleTileData(); amrex::ParallelForRNG(np, @@ -590,7 +590,7 @@ auto filterAndTransformParticles (DstTile& dst, const SrcTile& src, Pred&& p, F& auto np = src.numParticles(); Gpu::DeviceVector mask(np); - auto p_mask = mask.dataPtr(); + auto* p_mask = mask.dataPtr(); const auto src_data = src.getConstParticleTileData(); amrex::ParallelForRNG(np, diff --git a/Src/Particle/AMReX_SparseBins.H b/Src/Particle/AMReX_SparseBins.H index 6233bbbbb02..035828b1da6 100644 --- a/Src/Particle/AMReX_SparseBins.H +++ b/Src/Particle/AMReX_SparseBins.H @@ -36,7 +36,7 @@ struct SparseBinIteratorFactory m_items(items), m_num_bins(bins.size()) {} - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE index_type getIndex (const index_type bin_number) const noexcept { if (m_num_bins == 1) return 0; @@ -58,7 +58,7 @@ struct SparseBinIteratorFactory return m_not_found; } - AMREX_GPU_HOST_DEVICE + [[nodiscard]] AMREX_GPU_HOST_DEVICE BinIterator getBinIterator (const index_type bin_number) const noexcept { auto index = getIndex(bin_number); @@ -171,31 +171,31 @@ public: } //! \brief the number of items in the container - Long numItems () const noexcept { return m_perm.size(); } + [[nodiscard]] Long numItems () const noexcept { return m_perm.size(); } //! \brief the number of bins in the container - Long numBins () const noexcept { return m_offsets.size()-1; } + [[nodiscard]] Long numBins () const noexcept { return m_offsets.size()-1; } //! \brief returns the pointer to the permutation array - index_type* permutationPtr () noexcept { return m_perm.dataPtr(); } + [[nodiscard]] index_type* permutationPtr () noexcept { return m_perm.dataPtr(); } //! \brief returns the pointer to the offsets array - index_type* offsetsPtr () noexcept { return m_offsets.dataPtr(); } + [[nodiscard]] index_type* offsetsPtr () noexcept { return m_offsets.dataPtr(); } //! \brief returns the pointer to the array of non-zero bins - index_type* getNonZeroBinsPtr() noexcept { return m_bins.dataPtr(); } + [[nodiscard]] index_type* getNonZeroBinsPtr() noexcept { return m_bins.dataPtr(); } //! \brief returns const pointer to the permutation array - const index_type* permutationPtr () const noexcept { return m_perm.dataPtr(); } + [[nodiscard]] const index_type* permutationPtr () const noexcept { return m_perm.dataPtr(); } //! \brief returns const pointer to the offsets array - const index_type* offsetsPtr () const noexcept { return m_offsets.dataPtr(); } + [[nodiscard]] const index_type* offsetsPtr () const noexcept { return m_offsets.dataPtr(); } //! \brief returns the pointer to the array of non-zero bins - const index_type* getNonZeroBinsPtr() const noexcept { return m_bins.dataPtr(); } + [[nodiscard]] const index_type* getNonZeroBinsPtr() const noexcept { return m_bins.dataPtr(); } //! \brief returns a GPU-capable object that can create iterators over the items in a bin. - SparseBinIteratorFactory getBinIteratorFactory() const noexcept + [[nodiscard]] SparseBinIteratorFactory getBinIteratorFactory() const noexcept { return SparseBinIteratorFactory(m_bins, m_offsets, m_perm, m_items); } diff --git a/Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/face_velocity_2d_K.H b/Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/face_velocity_2d_K.H index 9e29024828e..16323e8afba 100644 --- a/Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/face_velocity_2d_K.H +++ b/Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/face_velocity_2d_K.H @@ -7,12 +7,12 @@ AMREX_GPU_DEVICE AMREX_FORCE_INLINE void get_face_velocity_psi(amrex::Box const& bx, - const amrex::Real time, + amrex::Real time, amrex::Array4 const& psi, - amrex::Real const dx, - amrex::Real const dy, - amrex::Real const prob_lo_x, - amrex::Real const prob_lo_y) + amrex::Real dx, + amrex::Real dy, + amrex::Real prob_lo_x, + amrex::Real prob_lo_y) { using namespace amrex; constexpr Real PI = 3.141592653589793238462643383279502884197; @@ -40,7 +40,7 @@ AMREX_FORCE_INLINE void get_face_velocity_x(int i, int j, int k, amrex::Array4 const& vx, amrex::Array4 const& psi, - const amrex::Real dy) + amrex::Real dy) { vx(i,j,k) = -( (psi(i,j+1,0)+psi(i-1,j+1,0)) - (psi(i,j-1,0)+psi(i-1,j-1,0)) ) * (0.25/dy); } @@ -50,18 +50,18 @@ AMREX_FORCE_INLINE void get_face_velocity_y(int i, int j, int k, amrex::Array4 const& vy, amrex::Array4 const& psi, - const amrex::Real dx) + amrex::Real dx) { vy(i,j,k) = ( (psi(i+1,j,0)+psi(i+1,j-1,0)) - (psi(i-1,j,0)+psi(i-1,j-1,0)) ) * (0.25/dx); } AMREX_GPU_HOST AMREX_FORCE_INLINE -void get_face_velocity(const amrex::Real time, +void get_face_velocity(amrex::Real time, amrex::FArrayBox& vx, amrex::FArrayBox& vy, - amrex::GpuArray dx, - amrex::GpuArray prob_lo) + amrex::GpuArray const& dx, + amrex::GpuArray const& prob_lo) { using namespace amrex; diff --git a/Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/face_velocity_3d_K.H b/Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/face_velocity_3d_K.H index d45111fc9cd..e073209a8ae 100644 --- a/Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/face_velocity_3d_K.H +++ b/Tests/Amr/Advection_AmrLevel/Exec/SingleVortex/face_velocity_3d_K.H @@ -7,14 +7,14 @@ AMREX_GPU_DEVICE AMREX_FORCE_INLINE void get_face_velocity_psi(amrex::Box const& bx, - const amrex::Real time, + amrex::Real time, amrex::Array4 const& psi, - amrex::Real const dx, - amrex::Real const dy, - amrex::Real const /*dz*/, - amrex::Real const prob_lo_x, - amrex::Real const prob_lo_y, - amrex::Real const /*prob_lo_z*/) + amrex::Real dx, + amrex::Real dy, + amrex::Real /*dz*/, + amrex::Real prob_lo_x, + amrex::Real prob_lo_y, + amrex::Real /*prob_lo_z*/) { using namespace amrex; constexpr Real PI = 3.141592653589793238462643383279502884197; @@ -42,7 +42,7 @@ AMREX_FORCE_INLINE void get_face_velocity_x(int i, int j, int k, amrex::Array4 const& vx, amrex::Array4 const& psi, - const amrex::Real dy) + amrex::Real dy) { vx(i,j,k) = -( (psi(i,j+1,0)+psi(i-1,j+1,0)) - (psi(i,j-1,0)+psi(i-1,j-1,0)) ) * (0.25/dy); } @@ -52,7 +52,7 @@ AMREX_FORCE_INLINE void get_face_velocity_y(int i, int j, int k, amrex::Array4 const& vy, amrex::Array4 const& psi, - const amrex::Real dx) + amrex::Real dx) { vy(i,j,k) = ( (psi(i+1,j,0)+psi(i+1,j-1,0)) - (psi(i-1,j,0)+psi(i-1,j-1,0)) ) * (0.25/dx); } @@ -67,12 +67,12 @@ void get_face_velocity_z(int i, int j, int k, AMREX_GPU_HOST AMREX_FORCE_INLINE -void get_face_velocity(const amrex::Real time, +void get_face_velocity(amrex::Real time, amrex::FArrayBox& vx, amrex::FArrayBox& vy, amrex::FArrayBox& vz, - amrex::GpuArray dx, - amrex::GpuArray prob_lo) + amrex::GpuArray const& dx, + amrex::GpuArray const& prob_lo) { using namespace amrex; diff --git a/Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/face_velocity_2d_K.H b/Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/face_velocity_2d_K.H index f9043f23422..eb1075a47d2 100644 --- a/Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/face_velocity_2d_K.H +++ b/Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/face_velocity_2d_K.H @@ -9,11 +9,11 @@ AMREX_GPU_HOST AMREX_FORCE_INLINE -void get_face_velocity(const amrex::Real /*time*/, +void get_face_velocity(amrex::Real /*time*/, amrex::FArrayBox& vx, amrex::FArrayBox& vy, - amrex::GpuArray /*dx*/, - amrex::GpuArray /*prob_lo*/) + amrex::GpuArray const& /*dx*/, + amrex::GpuArray const& /*prob_lo*/) { using namespace amrex; diff --git a/Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/face_velocity_3d_K.H b/Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/face_velocity_3d_K.H index 960c1aa5091..cdae691a765 100644 --- a/Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/face_velocity_3d_K.H +++ b/Tests/Amr/Advection_AmrLevel/Exec/UniformVelocity/face_velocity_3d_K.H @@ -9,12 +9,12 @@ AMREX_GPU_HOST AMREX_FORCE_INLINE -void get_face_velocity(const amrex::Real /*time*/, +void get_face_velocity(amrex::Real /*time*/, amrex::FArrayBox& vx, amrex::FArrayBox& vy, amrex::FArrayBox& vz, - amrex::GpuArray /*dx*/, - amrex::GpuArray /*prob_lo*/) + amrex::GpuArray const& /*dx*/, + amrex::GpuArray const& /*prob_lo*/) { using namespace amrex; diff --git a/Tests/Amr/Advection_AmrLevel/Source/Adv.cpp b/Tests/Amr/Advection_AmrLevel/Source/Adv.cpp index 1cc3660fd36..3a5ab003ae2 100644 --- a/Tests/Amr/Advection_AmrLevel/Source/Adv.cpp +++ b/Tests/Amr/Advection_AmrLevel/Source/Adv.cpp @@ -6,7 +6,7 @@ AMREX_GPU_HOST void -AmrLevelAdv::advect (const amrex::Real /*time*/, +AmrLevelAdv::advect (amrex::Real /*time*/, const amrex::Box& bx, amrex::GpuArray nbx, const amrex::FArrayBox& statein, @@ -17,8 +17,8 @@ AmrLevelAdv::advect (const amrex::Real /*time*/, AMREX_D_DECL(amrex::FArrayBox& fx, amrex::FArrayBox& fy, amrex::FArrayBox& fz), - amrex::GpuArray dx, - const amrex::Real dt) + amrex::GpuArray const& dx, + amrex::Real dt) { using namespace amrex; diff --git a/Tests/Amr/Advection_AmrLevel/Source/AmrLevelAdv.H b/Tests/Amr/Advection_AmrLevel/Source/AmrLevelAdv.H index ea6292e6f90..769a6ce65ea 100644 --- a/Tests/Amr/Advection_AmrLevel/Source/AmrLevelAdv.H +++ b/Tests/Amr/Advection_AmrLevel/Source/AmrLevelAdv.H @@ -1,5 +1,5 @@ -#ifndef _AmrLevelAdv_H_ -#define _AmrLevelAdv_H_ +#ifndef AmrLevelAdv_H_ +#define AmrLevelAdv_H_ #include #include @@ -208,7 +208,7 @@ protected: * See Adv.cpp for implementation. */ AMREX_GPU_HOST - static void advect (const amrex::Real /*time*/, + static void advect (amrex::Real /*time*/, const amrex::Box& bx, amrex::GpuArray nbx, const amrex::FArrayBox& statein, @@ -219,8 +219,8 @@ protected: AMREX_D_DECL(amrex::FArrayBox& fx, amrex::FArrayBox& fy, amrex::FArrayBox& fz), - amrex::GpuArray dx, - const amrex::Real dt); + amrex::GpuArray const& dx, + amrex::Real dt); // inline functions implemented below AmrLevelAdv& getLevel (int lev); @@ -258,22 +258,10 @@ protected: * See bc_nullfill.cpp for implementation. */ void nullfill (amrex::Box const& bx, amrex::FArrayBox& data, - const int dcomp, const int numcomp, - amrex::Geometry const& geom, const amrex::Real time, - const amrex::Vector& bcr, const int bcomp, - const int scomp); - -/** - * Problem-dependent function that computes Godunov velocities for each face. - * See face_velocity_?D_K.H under Exec directory for implementation. - */ -AMREX_GPU_HOST -AMREX_FORCE_INLINE -void get_face_velocity(const amrex::Real time, - amrex::FArrayBox& vx, - amrex::FArrayBox& vy, - amrex::GpuArray dx, - amrex::GpuArray prob_lo); + int dcomp, int numcomp, + amrex::Geometry const& geom, amrex::Real time, + const amrex::Vector& bcr, int bcomp, + int scomp); /* * Inlines. diff --git a/Tests/Amr/Advection_AmrLevel/Source/bc_nullfill.cpp b/Tests/Amr/Advection_AmrLevel/Source/bc_nullfill.cpp index ee67111ba7a..9b3f73bbe5f 100644 --- a/Tests/Amr/Advection_AmrLevel/Source/bc_nullfill.cpp +++ b/Tests/Amr/Advection_AmrLevel/Source/bc_nullfill.cpp @@ -8,20 +8,20 @@ struct NullFill { AMREX_GPU_DEVICE void operator() (const IntVect& /*iv*/, Array4 const& /*dest*/, - const int /*dcomp*/, const int /*numcomp*/, - GeometryData const& /*geom*/, const Real /*time*/, - const BCRec* /*bcr*/, const int /*bcomp*/, - const int /*orig_comp*/) const + int /*dcomp*/, int /*numcomp*/, + GeometryData const& /*geom*/, Real /*time*/, + const BCRec* /*bcr*/, int /*bcomp*/, + int /*orig_comp*/) const { // no physical boundaries to fill because it is all periodic } }; void nullfill (Box const& bx, FArrayBox& data, - const int dcomp, const int numcomp, - Geometry const& geom, const Real time, - const Vector& bcr, const int bcomp, - const int scomp) + int dcomp, int numcomp, + Geometry const& geom, Real time, + const Vector& bcr, int bcomp, + int scomp) { GpuBndryFuncFab gpu_bndry_func(NullFill{}); gpu_bndry_func(bx,data,dcomp,numcomp,geom,time,bcr,bcomp,scomp); diff --git a/Tests/LinearSolvers/ABecLap_SP/MyTest.H b/Tests/LinearSolvers/ABecLap_SP/MyTest.H index 75ab3eb8d69..633c934a403 100644 --- a/Tests/LinearSolvers/ABecLap_SP/MyTest.H +++ b/Tests/LinearSolvers/ABecLap_SP/MyTest.H @@ -15,7 +15,7 @@ public: void solve (); void writePlotfile () const; -public: // make these public for cuda +// public: for cuda void initProbPoisson (); void initProbABecLaplacian (); @@ -88,7 +88,7 @@ MyTest::solvePoisson () T(1.e-10) : T(1.e-4); const Real tol_abs = 0.0; - const int nlevels = geom.size(); + const auto nlevels = int(geom.size()); if (composite_solve) { @@ -197,7 +197,7 @@ MyTest::solveABecLaplacian () T(1.e-10) : T(1.e-4); const T tol_abs = T(0.0); - const int nlevels = geom.size(); + const auto nlevels = int(geom.size()); if (composite_solve) { diff --git a/Tests/LinearSolvers/ABecLaplacian_C/MyTest.H b/Tests/LinearSolvers/ABecLaplacian_C/MyTest.H index baa438cd1fa..afe97c9bea6 100644 --- a/Tests/LinearSolvers/ABecLaplacian_C/MyTest.H +++ b/Tests/LinearSolvers/ABecLaplacian_C/MyTest.H @@ -16,7 +16,7 @@ public: void solve (); void writePlotfile () const; -public: // make these public for cuda +// make these public for cuda void initProbPoisson (); void initProbABecLaplacian (); void initProbABecLaplacianInhomNeumann (); diff --git a/Tests/LinearSolvers/NodalPoisson/MyTest.H b/Tests/LinearSolvers/NodalPoisson/MyTest.H index 0752f25cd27..29d87cfd18c 100644 --- a/Tests/LinearSolvers/NodalPoisson/MyTest.H +++ b/Tests/LinearSolvers/NodalPoisson/MyTest.H @@ -20,8 +20,8 @@ public: void initData (); - int getNumTrials() { return num_trials; } - int getDoPlots() { return do_plots; } + [[nodiscard]] int getNumTrials () const { return num_trials; } + [[nodiscard]] int getDoPlots () const { return do_plots; } private: