diff --git a/.clang-tidy b/.clang-tidy index 4c826cda869..e77b342bf95 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,7 @@ Checks: > '-*, bugprone-*, + -bugprone-easily-swappable-parameters, -bugprone-exception-escape, clang-analyzer-*, -clang-analyzer-optin.mpi.MPI-Checker, @@ -24,9 +25,11 @@ Checks: > performance-*, readability-*, -readability-braces-around-statements, + -readability-container-data-pointer, -readability-else-after-return, -readability-function-cognitive-complexity, -readability-function-size, + -readability-identifier-length, -readability-implicit-bool-conversion, -readability-isolate-declaration, -readability-magic-numbers, diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index afd37544c12..b9702290c49 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -47,14 +47,14 @@ jobs: ctest --output-on-failure tests_clang: - name: Clang@7.0 C++17 SP Particles DP Mesh Debug [tests] - runs-on: ubuntu-20.04 + name: Clang@14.0 C++17 SP Particles DP Mesh Debug [tests] + runs-on: ubuntu-22.04 env: {CXXFLAGS: "-fno-operator-names -Werror -Wall -Wextra -Wpedantic -Wnull-dereference -Wfloat-conversion -Wshadow -Woverloaded-virtual -Wextra-semi -Wunreachable-code -O1 -Wnon-virtual-dtor"} # It's too slow with -O0 steps: - uses: actions/checkout@v3 - name: Dependencies - run: .github/workflows/dependencies/dependencies_clang7.sh + run: .github/workflows/dependencies/dependencies_clang.sh 14 - name: Build & Install run: | mkdir build @@ -69,9 +69,10 @@ jobs: -DAMReX_PARTICLES=ON \ -DAMReX_PRECISION=DOUBLE \ -DAMReX_PARTICLES_PRECISION=SINGLE \ - -DCMAKE_C_COMPILER=$(which clang) \ - -DCMAKE_CXX_COMPILER=$(which clang++) \ - -DCMAKE_Fortran_COMPILER=$(which gfortran) + -DCMAKE_C_COMPILER=$(which clang-14) \ + -DCMAKE_CXX_COMPILER=$(which clang++-14) \ + -DCMAKE_Fortran_COMPILER=$(which gfortran) \ + -DAMReX_CLANG_TIDY=ON make -j 2 ctest --output-on-failure -E GhostsAndVirtuals diff --git a/.github/workflows/dependencies/dependencies_clang.sh b/.github/workflows/dependencies/dependencies_clang.sh new file mode 100755 index 00000000000..ba55c482991 --- /dev/null +++ b/.github/workflows/dependencies/dependencies_clang.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +# Copyright 2020-2022 The AMReX Community +# +# License: BSD-3-Clause-LBNL +# Authors: Axel Huebl + +set -eu -o pipefail + +sudo apt-get update + +sudo apt-get install -y --no-install-recommends \ + build-essential \ + gfortran \ + clang-$1 \ + clang-tidy-$1 \ + libomp-$1-dev diff --git a/Src/Amr/AMReX_AmrLevel.cpp b/Src/Amr/AMReX_AmrLevel.cpp index bf98fe01184..ed2188dc11a 100644 --- a/Src/Amr/AMReX_AmrLevel.cpp +++ b/Src/Amr/AMReX_AmrLevel.cpp @@ -347,7 +347,7 @@ AmrLevel::writePlotFile (const std::string& dir, #ifdef AMREX_USE_EB if (EB2::TopIndexSpaceIfPresent()) { plotMF.setVal(0.0, cnt, 1, nGrow); - auto factory = static_cast(m_factory.get()); + auto *factory = static_cast(m_factory.get()); MultiFab::Copy(plotMF,factory->getVolFrac(),0,cnt,1,nGrow); } #endif diff --git a/Src/Base/AMReX_FabArray.H b/Src/Base/AMReX_FabArray.H index f9a787a4dc8..959252b07fc 100644 --- a/Src/Base/AMReX_FabArray.H +++ b/Src/Base/AMReX_FabArray.H @@ -427,7 +427,7 @@ public: bool hasEBFabFactory () const noexcept { #ifdef AMREX_USE_EB - const auto f = dynamic_cast(m_factory.get()); + const auto *const f = dynamic_cast(m_factory.get()); return (f != nullptr); #else return false; @@ -436,7 +436,7 @@ public: bool isAllRegular () const noexcept { #ifdef AMREX_USE_EB - const auto f = dynamic_cast(m_factory.get()); + const auto *const f = dynamic_cast(m_factory.get()); if (f) { return f->isAllRegular(); } else { diff --git a/Src/Base/AMReX_PlotFileUtil.cpp b/Src/Base/AMReX_PlotFileUtil.cpp index 8aa0e86a145..cee9ee9b735 100644 --- a/Src/Base/AMReX_PlotFileUtil.cpp +++ b/Src/Base/AMReX_PlotFileUtil.cpp @@ -405,7 +405,8 @@ EB_WriteMultiLevelPlotfile (const std::string& plotfilename, int nlevels, PreBuildDirectorHierarchy(plotfilename, levelPrefix, nlevels, callBarrier); if (!extra_dirs.empty()) { for (const auto& d : extra_dirs) { - const std::string ed = plotfilename+"/"+d; + std::string ed = plotfilename; + ed.append("/").append(d); amrex::PreBuildDirectorHierarchy(ed, levelPrefix, nlevels, callBarrier); } } diff --git a/Src/EB/AMReX_EB2.H b/Src/EB/AMReX_EB2.H index def8d2de9e0..be23e5f82e7 100644 --- a/Src/EB/AMReX_EB2.H +++ b/Src/EB/AMReX_EB2.H @@ -25,7 +25,13 @@ void Finalize (); class IndexSpace { public: - virtual ~IndexSpace() {} + virtual ~IndexSpace() = default; + + IndexSpace () noexcept = default; + IndexSpace (IndexSpace const&) = delete; + IndexSpace (IndexSpace &&) = delete; + IndexSpace& operator= (IndexSpace const&) = delete; + IndexSpace& operator= (IndexSpace &&) = delete; // This function will take the ownership of the IndexSpace // pointer, and put it on the top of the stack (i.e., back of the @@ -44,11 +50,11 @@ public: return *(m_instance.back()); } static bool empty () noexcept { return m_instance.empty(); } - static int size () noexcept { return m_instance.size(); } + static int size () noexcept { return static_cast(m_instance.size()); } - virtual const Level& getLevel (const Geometry & geom) const = 0; - virtual const Geometry& getGeometry (const Box& domain) const = 0; - virtual const Box& coarsestDomain () const = 0; + [[nodiscard]] virtual const Level& getLevel (const Geometry & geom) const = 0; + [[nodiscard]] virtual const Geometry& getGeometry (const Box& domain) const = 0; + [[nodiscard]] virtual const Box& coarsestDomain () const = 0; virtual void addFineLevels (int num_new_fine_levels) = 0; protected: @@ -74,14 +80,14 @@ public: void operator= (IndexSpaceImp const&) = delete; void operator= (IndexSpaceImp &&) = delete; - virtual ~IndexSpaceImp () {} + ~IndexSpaceImp () 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; using F = typename G::FunctionType; diff --git a/Src/EB/AMReX_EB2.cpp b/Src/EB/AMReX_EB2.cpp index fc2d75e0a01..2f122789319 100644 --- a/Src/EB/AMReX_EB2.cpp +++ b/Src/EB/AMReX_EB2.cpp @@ -16,7 +16,7 @@ #include #include -namespace amrex { namespace EB2 { +namespace amrex::EB2 { AMREX_EXPORT Vector > IndexSpace::m_instance; @@ -234,7 +234,7 @@ Build (const Geometry& geom, int required_coarsening_level, void addFineLevels (int num_new_fine_levels) { BL_PROFILE("EB2::addFineLevels()"); - auto p = const_cast(TopIndexSpace()); + auto *p = const_cast(TopIndexSpace()); if (p) { p->addFineLevels(num_new_fine_levels); } @@ -255,7 +255,7 @@ BuildFromChkptFile (std::string const& fname, } namespace { -static int comp_max_crse_level (Box cdomain, const Box& domain) +int comp_max_crse_level (Box cdomain, const Box& domain) { int ilev; for (ilev = 0; ilev < 30; ++ilev) { @@ -283,4 +283,4 @@ maxCoarseningLevel (IndexSpace const* ebis, const Geometry& geom) return comp_max_crse_level(cdomain,domain); } -}} +} diff --git a/Src/EB/AMReX_EB2_3D_C.cpp b/Src/EB/AMReX_EB2_3D_C.cpp index f979c890874..85cdfb6e14f 100644 --- a/Src/EB/AMReX_EB2_3D_C.cpp +++ b/Src/EB/AMReX_EB2_3D_C.cpp @@ -1,6 +1,6 @@ #include -namespace amrex { namespace EB2 { +namespace amrex::EB2 { namespace { @@ -728,44 +728,31 @@ int build_faces (Box const& bx, Array4 const& cell, AMREX_HOST_DEVICE_FOR_3D(nbxg1, i, j, k, { if (levset(i,j,k) < Real(0.0)) { - bool zero_levset = false; - if (xbx.contains(i ,j-1,k-1) - && fx(i ,j-1,k-1) == Type::covered) { - zero_levset = true; - } else if (xbx.contains(i ,j ,k-1) - && fx(i ,j ,k-1) == Type::covered) { - zero_levset = true; - } else if (xbx.contains(i ,j-1,k ) - && fx(i ,j-1,k ) == Type::covered) { - zero_levset = true; - } else if (xbx.contains(i ,j ,k ) - && fx(i ,j ,k ) == Type::covered) { - zero_levset = true; - } else if (ybx.contains(i-1,j ,k-1) - && fy(i-1,j ,k-1) == Type::covered) { - zero_levset = true; - } else if (ybx.contains(i ,j ,k-1) - && fy(i ,j ,k-1) == Type::covered) { - zero_levset = true; - } else if (ybx.contains(i-1,j ,k ) - && fy(i-1,j ,k ) == Type::covered) { - zero_levset = true; - } else if (ybx.contains(i ,j ,k ) - && fy(i ,j ,k ) == Type::covered) { - zero_levset = true; - } else if (zbx.contains(i-1,j-1,k ) - && fz(i-1,j-1,k ) == Type::covered) { - zero_levset = true; - } else if (zbx.contains(i ,j-1,k ) - && fz(i ,j-1,k ) == Type::covered) { - zero_levset = true; - } else if (zbx.contains(i-1,j ,k ) - && fz(i-1,j ,k ) == Type::covered) { - zero_levset = true; - } else if (zbx.contains(i ,j ,k ) - && fz(i ,j ,k ) == Type::covered) { - zero_levset = true; - } + bool zero_levset = + (xbx.contains(i ,j-1,k-1) + && fx(i ,j-1,k-1) == Type::covered) || + (xbx.contains(i ,j ,k-1) + && fx(i ,j ,k-1) == Type::covered) || + (xbx.contains(i ,j-1,k ) + && fx(i ,j-1,k ) == Type::covered) || + (xbx.contains(i ,j ,k ) + && fx(i ,j ,k ) == Type::covered) || + (ybx.contains(i-1,j ,k-1) + && fy(i-1,j ,k-1) == Type::covered) || + (ybx.contains(i ,j ,k-1) + && fy(i ,j ,k-1) == Type::covered) || + (ybx.contains(i-1,j ,k ) + && fy(i-1,j ,k ) == Type::covered) || + (ybx.contains(i ,j ,k ) + && fy(i ,j ,k ) == Type::covered) || + (zbx.contains(i-1,j-1,k ) + && fz(i-1,j-1,k ) == Type::covered) || + (zbx.contains(i ,j-1,k ) + && fz(i ,j-1,k ) == Type::covered) || + (zbx.contains(i-1,j ,k ) + && fz(i-1,j ,k ) == Type::covered) || + (zbx.contains(i ,j ,k ) + && fz(i ,j ,k ) == Type::covered); if (zero_levset) { levset(i,j,k) = Real(0.0); } @@ -886,68 +873,47 @@ void build_cells (Box const& bx, Array4 const& cell, AMREX_HOST_DEVICE_FOR_3D(nbxg1, i, j, k, { if (levset(i,j,k) < Real(0.0)) { - bool zero_levset = false; - if (bxg1.contains(i-1,j-1,k-1) - && cell(i-1,j-1,k-1).isCovered()) { - zero_levset = true; - } else if (bxg1.contains(i ,j-1,k-1) - && cell(i ,j-1,k-1).isCovered()) { - zero_levset = true; - } else if (bxg1.contains(i-1,j ,k-1) - && cell(i-1,j ,k-1).isCovered()) { - zero_levset = true; - } else if (bxg1.contains(i ,j ,k-1) - && cell(i ,j ,k-1).isCovered()) { - zero_levset = true; - } else if (bxg1.contains(i-1,j-1,k ) - && cell(i-1,j-1,k ).isCovered()) { - zero_levset = true; - } else if (bxg1.contains(i ,j-1,k ) - && cell(i ,j-1,k ).isCovered()) { - zero_levset = true; - } else if (bxg1.contains(i-1,j ,k ) - && cell(i-1,j ,k ).isCovered()) { - zero_levset = true; - } else if (bxg1.contains(i ,j ,k ) - && cell(i ,j ,k ).isCovered()) { - zero_levset = true; - } else if (bxg1x.contains(i ,j-1,k-1) - && fx(i ,j-1,k-1) == Type::covered) { - zero_levset = true; - } else if (bxg1x.contains(i ,j ,k-1) - && fx(i ,j ,k-1) == Type::covered) { - zero_levset = true; - } else if (bxg1x.contains(i ,j-1,k ) - && fx(i ,j-1,k ) == Type::covered) { - zero_levset = true; - } else if (bxg1x.contains(i ,j ,k ) - && fx(i ,j ,k ) == Type::covered) { - zero_levset = true; - } else if (bxg1y.contains(i-1,j ,k-1) - && fy(i-1,j ,k-1) == Type::covered) { - zero_levset = true; - } else if (bxg1y.contains(i ,j ,k-1) - && fy(i ,j ,k-1) == Type::covered) { - zero_levset = true; - } else if (bxg1y.contains(i-1,j ,k ) - && fy(i-1,j ,k ) == Type::covered) { - zero_levset = true; - } else if (bxg1y.contains(i ,j ,k ) - && fy(i ,j ,k ) == Type::covered) { - zero_levset = true; - } else if (bxg1z.contains(i-1,j-1,k ) - && fz(i-1,j-1,k ) == Type::covered) { - zero_levset = true; - } else if (bxg1z.contains(i ,j-1,k ) - && fz(i ,j-1,k ) == Type::covered) { - zero_levset = true; - } else if (bxg1z.contains(i-1,j ,k ) - && fz(i-1,j ,k ) == Type::covered) { - zero_levset = true; - } else if (bxg1z.contains(i ,j ,k ) - && fz(i ,j ,k ) == Type::covered) { - zero_levset = true; - } + bool zero_levset = + (bxg1.contains(i-1,j-1,k-1) + && cell(i-1,j-1,k-1).isCovered()) || + (bxg1.contains(i ,j-1,k-1) + && cell(i ,j-1,k-1).isCovered()) || + (bxg1.contains(i-1,j ,k-1) + && cell(i-1,j ,k-1).isCovered()) || + (bxg1.contains(i ,j ,k-1) + && cell(i ,j ,k-1).isCovered()) || + (bxg1.contains(i-1,j-1,k ) + && cell(i-1,j-1,k ).isCovered()) || + (bxg1.contains(i ,j-1,k ) + && cell(i ,j-1,k ).isCovered()) || + (bxg1.contains(i-1,j ,k ) + && cell(i-1,j ,k ).isCovered()) || + (bxg1.contains(i ,j ,k ) + && cell(i ,j ,k ).isCovered()) || + (bxg1x.contains(i ,j-1,k-1) + && fx(i ,j-1,k-1) == Type::covered) || + (bxg1x.contains(i ,j ,k-1) + && fx(i ,j ,k-1) == Type::covered) || + (bxg1x.contains(i ,j-1,k ) + && fx(i ,j-1,k ) == Type::covered) || + (bxg1x.contains(i ,j ,k ) + && fx(i ,j ,k ) == Type::covered) || + (bxg1y.contains(i-1,j ,k-1) + && fy(i-1,j ,k-1) == Type::covered) || + (bxg1y.contains(i ,j ,k-1) + && fy(i ,j ,k-1) == Type::covered) || + (bxg1y.contains(i-1,j ,k ) + && fy(i-1,j ,k ) == Type::covered) || + (bxg1y.contains(i ,j ,k ) + && fy(i ,j ,k ) == Type::covered) || + (bxg1z.contains(i-1,j-1,k ) + && fz(i-1,j-1,k ) == Type::covered) || + (bxg1z.contains(i ,j-1,k ) + && fz(i ,j-1,k ) == Type::covered) || + (bxg1z.contains(i-1,j ,k ) + && fz(i-1,j ,k ) == Type::covered) || + (bxg1z.contains(i ,j ,k ) + && fz(i ,j ,k ) == Type::covered); if (zero_levset) { levset(i,j,k) = Real(0.0); } @@ -1152,4 +1118,4 @@ void set_connection_flags (Box const& bx, }); } -}} +} diff --git a/Src/EB/AMReX_EB2_GeometryShop.H b/Src/EB/AMReX_EB2_GeometryShop.H index 9063942f11f..d64735b2f55 100644 --- a/Src/EB/AMReX_EB2_GeometryShop.H +++ b/Src/EB/AMReX_EB2_GeometryShop.H @@ -11,6 +11,7 @@ #include #include #include +#include namespace amrex { namespace EB2 { @@ -195,31 +196,18 @@ public: : m_f(std::move(f)), m_resource() {} - GeometryShop (F const& f, R const& r) - : m_f(f), m_resource(r) + GeometryShop (F const& f, R r) + : m_f(f), m_resource(std::move(r)) {} - GeometryShop (F && f, R && r) + GeometryShop (F && f, R r) : m_f(std::move(f)), m_resource(std::move(r)) {} - ~GeometryShop() {} - - GeometryShop (GeometryShop const& rhs) - : m_f(rhs.m_f), m_resource(rhs.m_resource) - {} - - GeometryShop (GeometryShop && rhs) - : m_f(std::move(rhs.m_f)), m_resource(std::move(rhs.m_resource)) - {} - - GeometryShop& operator= (GeometryShop const& rhs) = delete; - GeometryShop& operator= (GeometryShop && rhs) = delete; - - F const& GetImpFunc () const& { return m_f; } + [[nodiscard]] F const& GetImpFunc () const& { return m_f; } F&& GetImpFunc () && { return std::move(m_f); } - int getBoxType_Cpu (const Box& bx, Geometry const& geom) const noexcept + [[nodiscard]] int getBoxType_Cpu (const Box& bx, Geometry const& geom) const noexcept { const Real* problo = geom.ProbLo(); const Real* dx = geom.CellSize(); @@ -256,7 +244,7 @@ public: } template ::value>::type* FOO = nullptr > - int getBoxType (const Box& bx, const Geometry& geom, RunOn run_on) const noexcept + [[nodiscard]] int getBoxType (const Box& bx, const Geometry& geom, RunOn run_on) const noexcept { if (run_on == RunOn::Gpu && Gpu::inLaunchRegion()) { @@ -303,7 +291,7 @@ public: } template ::value>::type* BAR = nullptr > - int getBoxType (const Box& bx, const Geometry& geom, RunOn) const noexcept + [[nodiscard]] int getBoxType (const Box& bx, const Geometry& geom, RunOn) const noexcept { return getBoxType_Cpu(bx, geom); } diff --git a/Src/EB/AMReX_EB2_Graph.H b/Src/EB/AMReX_EB2_Graph.H index 8f734b8db8f..6ab2b4f53ba 100644 --- a/Src/EB/AMReX_EB2_Graph.H +++ b/Src/EB/AMReX_EB2_Graph.H @@ -50,12 +50,12 @@ struct Neighbor void setZLo (Type_t t) { flag &= zero_zlo_mask; flag |= (t << 8); } void setZHi (Type_t t) { flag &= zero_zhi_mask; flag |= (t << 10); } - Type_t getXLo () const { return (flag & one_xlo_mask); } - Type_t getXHi () const { return (flag & one_xhi_mask) >> 2; } - Type_t getYLo () const { return (flag & one_ylo_mask) >> 4; } - Type_t getYHi () const { return (flag & one_yhi_mask) >> 6; } - Type_t getZLo () const { return (flag & one_zlo_mask) >> 8; } - Type_t getZHi () const { return (flag & one_zhi_mask) >> 10; } + [[nodiscard]] Type_t getXLo () const { return (flag & one_xlo_mask); } + [[nodiscard]] Type_t getXHi () const { return (flag & one_xhi_mask) >> 2; } + [[nodiscard]] Type_t getYLo () const { return (flag & one_ylo_mask) >> 4; } + [[nodiscard]] Type_t getYHi () const { return (flag & one_yhi_mask) >> 6; } + [[nodiscard]] Type_t getZLo () const { return (flag & one_zlo_mask) >> 8; } + [[nodiscard]] Type_t getZHi () const { return (flag & one_zhi_mask) >> 10; } private: diff --git a/Src/EB/AMReX_EB2_IF_Box.H b/Src/EB/AMReX_EB2_IF_Box.H index 1cae5315a69..cb19e631649 100644 --- a/Src/EB/AMReX_EB2_IF_Box.H +++ b/Src/EB/AMReX_EB2_IF_Box.H @@ -24,11 +24,6 @@ public: m_sign( a_inside ? 1.0 : -1.0 ) {} - BoxIF (const BoxIF& rhs) noexcept = default; - BoxIF (BoxIF&& rhs) noexcept = default; - BoxIF& operator= (const BoxIF& rhs) = delete; - BoxIF& operator= (BoxIF&& rhs) = delete; - AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { diff --git a/Src/EB/AMReX_EB2_IF_Cylinder.H b/Src/EB/AMReX_EB2_IF_Cylinder.H index f9cf4088312..d2e0f76b9cd 100644 --- a/Src/EB/AMReX_EB2_IF_Cylinder.H +++ b/Src/EB/AMReX_EB2_IF_Cylinder.H @@ -37,11 +37,6 @@ public: AMREX_ASSERT(m_direction < AMREX_SPACEDIM); } - CylinderIF (const CylinderIF& rhs) noexcept = default; - CylinderIF (CylinderIF&& rhs) noexcept = default; - CylinderIF& operator= (const CylinderIF& rhs) = delete; - CylinderIF& operator= (CylinderIF&& rhs) = delete; - AMREX_GPU_HOST_DEVICE inline Real operator() (AMREX_D_DECL(Real x, Real y, Real z)) const noexcept { diff --git a/Src/EB/AMReX_EB2_IF_Ellipsoid.H b/Src/EB/AMReX_EB2_IF_Ellipsoid.H index fa102004981..3b39c82793c 100644 --- a/Src/EB/AMReX_EB2_IF_Ellipsoid.H +++ b/Src/EB/AMReX_EB2_IF_Ellipsoid.H @@ -21,12 +21,6 @@ public: m_sign( a_inside ? 1.0_rt : -1.0_rt ) {} - EllipsoidIF (const EllipsoidIF& rhs) noexcept = default; - EllipsoidIF (EllipsoidIF&& rhs) noexcept = default; - EllipsoidIF& operator= (const EllipsoidIF& rhs) = delete; - EllipsoidIF& operator= (EllipsoidIF&& rhs) = delete; - - 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), diff --git a/Src/EB/AMReX_EB2_IF_Parser.H b/Src/EB/AMReX_EB2_IF_Parser.H index 36748060f5e..77769469ec8 100644 --- a/Src/EB/AMReX_EB2_IF_Parser.H +++ b/Src/EB/AMReX_EB2_IF_Parser.H @@ -17,11 +17,6 @@ public: : m_parser(a_parser) {} - ParserIF (const ParserIF& rhs) noexcept = default; - ParserIF (ParserIF&& rhs) noexcept = default; - ParserIF& operator= (const ParserIF& rhs) = delete; - ParserIF& operator= (ParserIF&& rhs) = delete; - AMREX_GPU_HOST_DEVICE inline amrex::Real operator() (AMREX_D_DECL(amrex::Real x, amrex::Real y, amrex::Real z)) const noexcept { diff --git a/Src/EB/AMReX_EB2_IF_Sphere.H b/Src/EB/AMReX_EB2_IF_Sphere.H index d28fdbd4241..d6ff3f2dcc5 100644 --- a/Src/EB/AMReX_EB2_IF_Sphere.H +++ b/Src/EB/AMReX_EB2_IF_Sphere.H @@ -21,11 +21,6 @@ public: m_sign( a_inside ? 1.0 : -1.0 ) {} - SphereIF (const SphereIF& rhs) noexcept = default; - SphereIF (SphereIF&& rhs) noexcept = default; - SphereIF& operator= (const SphereIF& rhs) = delete; - SphereIF& operator= (SphereIF&& rhs) = delete; - 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), diff --git a/Src/EB/AMReX_EB2_IF_Torus.H b/Src/EB/AMReX_EB2_IF_Torus.H index ad8fc80e012..ee6dc1af2d9 100644 --- a/Src/EB/AMReX_EB2_IF_Torus.H +++ b/Src/EB/AMReX_EB2_IF_Torus.H @@ -23,11 +23,6 @@ public: m_sign( a_inside ? 1.0 : -1.0 ) {} - TorusIF (const TorusIF& rhs) noexcept = default; - TorusIF (TorusIF&& rhs) noexcept = default; - TorusIF& operator= (const TorusIF& rhs) = delete; - TorusIF& operator= (TorusIF&& rhs) = delete; - 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); @@ -50,8 +45,6 @@ protected: Real m_large_radius; Real m_small_radius; XDim3 m_center; - // - Real m_small_radius2; // precomputed radius squared Real m_sign; }; diff --git a/Src/EB/AMReX_EB2_IndexSpace_STL.H b/Src/EB/AMReX_EB2_IndexSpace_STL.H index a5e13ba0591..955b9103b15 100644 --- a/Src/EB/AMReX_EB2_IndexSpace_STL.H +++ b/Src/EB/AMReX_EB2_IndexSpace_STL.H @@ -26,14 +26,14 @@ public: void operator= (IndexSpaceSTL const&) = delete; void operator= (IndexSpaceSTL &&) = delete; - virtual ~IndexSpaceSTL () {} + ~IndexSpaceSTL () 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_EB2_IndexSpace_STL.cpp b/Src/EB/AMReX_EB2_IndexSpace_STL.cpp index 1a81cfe72e9..335b490ce48 100644 --- a/Src/EB/AMReX_EB2_IndexSpace_STL.cpp +++ b/Src/EB/AMReX_EB2_IndexSpace_STL.cpp @@ -1,6 +1,6 @@ #include -namespace amrex { namespace EB2 { +namespace amrex::EB2 { IndexSpaceSTL::IndexSpaceSTL (const std::string& stl_file, Real stl_scale, Array const& stl_center, int stl_reverse_normal, @@ -70,7 +70,7 @@ const Level& IndexSpaceSTL::getLevel (const Geometry& geom) const { auto it = std::find(std::begin(m_domain), std::end(m_domain), geom.Domain()); - int i = std::distance(m_domain.begin(), it); + auto i = std::distance(m_domain.begin(), it); return m_stllevel[i]; } @@ -78,7 +78,7 @@ const Geometry& IndexSpaceSTL::getGeometry (const Box& dom) const { auto it = std::find(std::begin(m_domain), std::end(m_domain), dom); - int i = std::distance(m_domain.begin(), it); + auto i = std::distance(m_domain.begin(), it); return m_geom[i]; } @@ -88,4 +88,4 @@ IndexSpaceSTL::addFineLevels (int /*num_new_fine_levels*/) amrex::Abort("IndexSpaceSTL::addFineLevels: todo"); } -}} +} diff --git a/Src/EB/AMReX_EB2_IndexSpace_chkpt_file.H b/Src/EB/AMReX_EB2_IndexSpace_chkpt_file.H index 3285978744a..b1bca7c66b8 100644 --- a/Src/EB/AMReX_EB2_IndexSpace_chkpt_file.H +++ b/Src/EB/AMReX_EB2_IndexSpace_chkpt_file.H @@ -14,7 +14,7 @@ class IndexSpaceChkptFile { public: - IndexSpaceChkptFile (const ChkptFile& chkptfile, + IndexSpaceChkptFile (const ChkptFile& chkpt_file, const Geometry& geom, int required_coarsening_level, int max_coarsening_level, int ngrow, bool build_coarse_level_by_coarsening, diff --git a/Src/EB/AMReX_EB2_IndexSpace_chkpt_file.cpp b/Src/EB/AMReX_EB2_IndexSpace_chkpt_file.cpp index b0318dd402c..68688c5aab8 100644 --- a/Src/EB/AMReX_EB2_IndexSpace_chkpt_file.cpp +++ b/Src/EB/AMReX_EB2_IndexSpace_chkpt_file.cpp @@ -1,6 +1,6 @@ #include -namespace amrex { namespace EB2 { +namespace amrex::EB2 { IndexSpaceChkptFile::IndexSpaceChkptFile (const ChkptFile& chkpt_file, const Geometry& geom, int required_coarsening_level, @@ -65,7 +65,7 @@ const Level& IndexSpaceChkptFile::getLevel (const Geometry& geom) const { auto it = std::find(std::begin(m_domain), std::end(m_domain), geom.Domain()); - int i = std::distance(m_domain.begin(), it); + auto i = std::distance(m_domain.begin(), it); return m_chkpt_file_level[i]; } @@ -73,7 +73,7 @@ const Geometry& IndexSpaceChkptFile::getGeometry (const Box& dom) const { auto it = std::find(std::begin(m_domain), std::end(m_domain), dom); - int i = std::distance(m_domain.begin(), it); + auto i = std::distance(m_domain.begin(), it); return m_geom[i]; } @@ -83,4 +83,4 @@ IndexSpaceChkptFile::addFineLevels (int /*num_new_fine_levels*/) amrex::Abort("IndexSpaceChkptFile::addFineLevels: not supported"); } -}} +} diff --git a/Src/EB/AMReX_EB2_Level.H b/Src/EB/AMReX_EB2_Level.H index 29e3521d97a..5cbecc772e1 100644 --- a/Src/EB/AMReX_EB2_Level.H +++ b/Src/EB/AMReX_EB2_Level.H @@ -62,13 +62,11 @@ public: void write_to_chkpt_file (const std::string& fname, bool extend_domain_face, int max_grid_size) const; -protected: - - Level (Level && rhs) = default; +// public: // for cuda + int coarsenFromFine (Level& fineLevel, bool fill_boundary); + void buildCellFlag (); - Level (Level const& rhs) = delete; - Level& operator=(Level const& rhs) = delete; - Level& operator=(Level && rhs) = delete; +protected: Geometry m_geom; IntVect m_ngrow; @@ -89,10 +87,6 @@ protected: bool m_allregular = false; bool m_ok = false; IndexSpace const* m_parent; - -public: // for cuda - int coarsenFromFine (Level& fineLevel, bool fill_boundary); - void buildCellFlag (); }; template diff --git a/Src/EB/AMReX_EB2_Level.cpp b/Src/EB/AMReX_EB2_Level.cpp index 09b6db4a54c..112bf9db044 100644 --- a/Src/EB/AMReX_EB2_Level.cpp +++ b/Src/EB/AMReX_EB2_Level.cpp @@ -4,7 +4,7 @@ #include #include -namespace amrex { namespace EB2 { +namespace amrex::EB2 { void Level::prepareForCoarsening (const Level& rhs, int max_grid_size, IntVect ngrow) @@ -927,4 +927,4 @@ Level::write_to_chkpt_file (const std::string& fname, bool extend_domain_face, i m_geom, m_ngrow, extend_domain_face, max_grid_size); } -}} +} diff --git a/Src/EB/AMReX_EB2_Level_STL.cpp b/Src/EB/AMReX_EB2_Level_STL.cpp index 53243cd754a..c2df4f08661 100644 --- a/Src/EB/AMReX_EB2_Level_STL.cpp +++ b/Src/EB/AMReX_EB2_Level_STL.cpp @@ -1,6 +1,6 @@ #include -namespace amrex { namespace EB2 { +namespace amrex::EB2 { STLLevel::STLLevel (IndexSpace const* is, STLtools const& stl_tools, const Geometry& geom, int max_grid_size, int ngrow, bool extend_domain_face, int num_crse_opt) @@ -16,4 +16,4 @@ STLLevel::STLLevel (IndexSpace const* is, int ilev, int max_grid_size, int ngrow : GShopLevel(is, ilev, max_grid_size, ngrow, geom, fineLevel) {} -}} +} diff --git a/Src/EB/AMReX_EB2_Level_chkpt_file.cpp b/Src/EB/AMReX_EB2_Level_chkpt_file.cpp index 0b2d88e828f..ca646d0b094 100644 --- a/Src/EB/AMReX_EB2_Level_chkpt_file.cpp +++ b/Src/EB/AMReX_EB2_Level_chkpt_file.cpp @@ -3,7 +3,7 @@ #include -namespace amrex { namespace EB2 { +namespace amrex::EB2 { ChkptFileLevel::ChkptFileLevel (IndexSpace const* is, ChkptFile const& chkpt_file, Geometry const& geom, int max_grid_size, int ngrow, bool extend_domain_face) @@ -132,7 +132,7 @@ ChkptFileLevel::finalize_cell_flags () } }); - #if (AMREX_SPACEDIM == 3) +#if (AMREX_SPACEDIM == 3) const Box& zbx = amrex::grow(amrex::surroundingNodes(vbx,2),1); AMREX_HOST_DEVICE_FOR_3D ( zbx, i, j, k, { @@ -142,10 +142,10 @@ ChkptFileLevel::finalize_cell_flags () fz(i,j,k) = Type::regular; } }); - #endif +#endif - #if (AMREX_SPACEDIM == 2) +#if (AMREX_SPACEDIM == 2) ignore_unused(ctmp); AMREX_HOST_DEVICE_FOR_3D ( bxg1, i, j, k, { @@ -166,7 +166,7 @@ ChkptFileLevel::finalize_cell_flags () set_connection_flags(bxg1, cell, fx, fy); - #else +#else AMREX_HOST_DEVICE_FOR_3D ( bxg1, i, j, k, { if (cell(i,j,k).isSingleValued()) { @@ -187,7 +187,7 @@ ChkptFileLevel::finalize_cell_flags () set_connection_flags(vbx, bxg1, cell, ctmp, fx, fy, fz); - #endif +#endif } @@ -200,4 +200,4 @@ ChkptFileLevel::ChkptFileLevel (IndexSpace const* is, int ilev, int max_grid_siz : GShopLevel(is, ilev, max_grid_size, ngrow, geom, fineLevel) {} -}} +} diff --git a/Src/EB/AMReX_EB2_MultiGFab.cpp b/Src/EB/AMReX_EB2_MultiGFab.cpp index 8d71877164c..8d09ca7c069 100644 --- a/Src/EB/AMReX_EB2_MultiGFab.cpp +++ b/Src/EB/AMReX_EB2_MultiGFab.cpp @@ -3,7 +3,7 @@ #include #include -namespace amrex { namespace EB2 { +namespace amrex::EB2 { void GFab::buildTypes (EBCellFlagFab& celltype) @@ -52,4 +52,4 @@ MultiGFab::getLevelSet () return r; } -}} +} diff --git a/Src/EB/AMReX_EB2_ND_C.cpp b/Src/EB/AMReX_EB2_ND_C.cpp index e512f00a4a6..a465c36cef1 100644 --- a/Src/EB/AMReX_EB2_ND_C.cpp +++ b/Src/EB/AMReX_EB2_ND_C.cpp @@ -1,6 +1,6 @@ #include -namespace amrex { namespace EB2 { +namespace amrex::EB2 { void intercept_to_edge_centroid (AMREX_D_DECL(Array4 const& excent, Array4 const& eycent, @@ -64,4 +64,4 @@ void intercept_to_edge_centroid (AMREX_D_DECL(Array4 const& excent, ); } -}} +} diff --git a/Src/EB/AMReX_EBCellFlag.H b/Src/EB/AMReX_EBCellFlag.H index 362b9583faf..0a15cba704b 100644 --- a/Src/EB/AMReX_EBCellFlag.H +++ b/Src/EB/AMReX_EBCellFlag.H @@ -17,18 +17,16 @@ class EBCellFlag { public: - AMREX_GPU_HOST_DEVICE - EBCellFlag () noexcept {} - - EBCellFlag (const EBCellFlag& rhs) noexcept = default; + constexpr EBCellFlag () noexcept = default; + ~EBCellFlag () noexcept = default; + constexpr EBCellFlag (const EBCellFlag& rhs) noexcept = default; + constexpr EBCellFlag (EBCellFlag&& rhs) noexcept = default; + constexpr EBCellFlag& operator= (const EBCellFlag& rhs) noexcept = default; + constexpr EBCellFlag& operator= (EBCellFlag&& rhs) noexcept = default; - AMREX_GPU_HOST_DEVICE explicit constexpr EBCellFlag (uint32_t i) noexcept : flag(i) {} - EBCellFlag& operator= (const EBCellFlag& rhs) noexcept = default; - - AMREX_GPU_HOST_DEVICE - EBCellFlag& operator= (uint32_t i) noexcept { flag = i; return *this; } + constexpr EBCellFlag& operator= (uint32_t i) noexcept { flag = i; return *this; } AMREX_GPU_HOST_DEVICE EBCellFlag& operator+= (const EBCellFlag& /* rhs */) { @@ -63,45 +61,45 @@ public: flag |= static_cast(n) << pos_numvofs; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator==(const EBCellFlag& a_input) const noexcept { return (flag == (a_input.flag)); } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator!=(const EBCellFlag& a_input) const noexcept { return (flag != (a_input.flag)); } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int getNumVoFs () const noexcept { - return (flag & one_numvofs_mask) >> pos_numvofs; + return static_cast((flag & one_numvofs_mask) >> pos_numvofs); } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isRegular () const noexcept { return (flag & one_type_mask) == regular_bits; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isSingleValued () const noexcept { return (flag & one_type_mask) == single_valued_bits; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isMultiValued () const noexcept { return (flag & one_type_mask) == multi_valued_bits; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isCovered () const noexcept { return (flag & one_type_mask) == covered_bits; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isConnected (const IntVect& iv) const noexcept { int i=0, j=0, k=0; AMREX_D_TERM(i=iv[0];, j=iv[1];, k=iv[2]); @@ -109,13 +107,13 @@ public: return flag & (1 << n); } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isConnected (int i, int j, int k) const noexcept { const int n = w_lower_mask + 13 + i + 3*j + k*9; // pos_ngbr[k+1,j+1,i+1] return flag & (1 << n); } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isDisconnected (const IntVect& iv) const noexcept { int i=0, j=0, k=0; AMREX_D_TERM(i=iv[0];, j=iv[1];, k=iv[2]); @@ -123,7 +121,7 @@ public: return !(flag & (1 << n)); } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool isDisconnected (int i, int j, int k) const noexcept { const int n = w_lower_mask + 13 + i + 3*j + k*9; // pos_ngbr[k+1,j+1,i+1] return !(flag & (1 << n)); @@ -167,7 +165,7 @@ public: flag |= 1 << n; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int numNeighbors () const noexcept { int n = 1; n += isConnected(-1,-1, 0); @@ -208,19 +206,19 @@ public: return n; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE uint32_t getValue() const noexcept { return flag; } - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static constexpr EBCellFlag TheDefaultCell () { return EBCellFlag{default_value}; } // DO NOT test covered cells using cell == TheCoveredCell() // Use cell.isCovered() instead. // Each covered cell is covered in its own way. - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE + [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static constexpr EBCellFlag TheCoveredCell () { return EBCellFlag{covered_value}; } private: @@ -303,7 +301,7 @@ public: EBCellFlagFab () = default; EBCellFlagFab (EBCellFlagFab&& rhs) = default; - virtual ~EBCellFlagFab () override = default; + ~EBCellFlagFab () override = default; EBCellFlagFab (const EBCellFlagFab&) = delete; EBCellFlagFab& operator= (const EBCellFlagFab&) = delete; diff --git a/Src/EB/AMReX_EBCellFlag.cpp b/Src/EB/AMReX_EBCellFlag.cpp index 88a24a64afc..7ae412b2abc 100644 --- a/Src/EB/AMReX_EBCellFlag.cpp +++ b/Src/EB/AMReX_EBCellFlag.cpp @@ -176,11 +176,8 @@ EBCellFlagFab::getNumCutCells (const Box& bx_in) const noexcept const Box& bx = amrex::enclosedCells(bx_in); - if (thistype == FabType::regular) - { - return 0; - } - else if (thistype == FabType::covered) + if (thistype == FabType::regular || + thistype == FabType::covered) { return 0; } diff --git a/Src/EB/AMReX_EBFArrayBox.H b/Src/EB/AMReX_EBFArrayBox.H index efc24329606..4c52ce29872 100644 --- a/Src/EB/AMReX_EBFArrayBox.H +++ b/Src/EB/AMReX_EBFArrayBox.H @@ -15,7 +15,7 @@ class EBFArrayBox public: EBFArrayBox (); explicit EBFArrayBox (Arena* ar); - EBFArrayBox (const EBCellFlagFab& ebcellflag, const Box& box, int ncomps, Arena* ar, + EBFArrayBox (const EBCellFlagFab& ebflag, const Box& bx, int ncomps, Arena* ar, const EBFArrayBoxFactory* factory=nullptr, int box_index=-1); EBFArrayBox (EBFArrayBox const& rhs, MakeType make_type, int scomp, int ncomp); @@ -24,46 +24,46 @@ public: EBFArrayBox& operator= (const EBFArrayBox&) = delete; EBFArrayBox& operator= (EBFArrayBox&&) = delete; - ~EBFArrayBox (); + ~EBFArrayBox () override; //! Get EBCellFlag Fab - const EBCellFlagFab& getEBCellFlagFab () const { return *m_ebcellflag; } + [[nodiscard]] const EBCellFlagFab& getEBCellFlagFab () const { return *m_ebcellflag; } //! Get a pointer to levelset data if available. The return value could //! be nullptr if not available. - const FArrayBox* getLevelSetData () const; + [[nodiscard]] const FArrayBox* getLevelSetData () const; //! Get a pointer to volume fraction data if available. The return //! value could be nullptr if not available. - const FArrayBox* getVolFracData () const; + [[nodiscard]] const FArrayBox* getVolFracData () const; //! Get a pointer to volume centroid data if available. The return //! value could be nullptr if not available. - const FArrayBox* getCentroidData () const; + [[nodiscard]] const FArrayBox* getCentroidData () const; //! Get a pointer to boundary centroid data if available. The return //! value could be nullptr if not available. - const FArrayBox* getBndryCentData () const; + [[nodiscard]] const FArrayBox* getBndryCentData () const; //! Get a pointer to boundary normal data if available. The return //! value could be nullptr if not available. - const FArrayBox* getBndryNormalData () const; + [[nodiscard]] const FArrayBox* getBndryNormalData () const; //! Get a pointer to boundary area data if available. The return //! value could be nullptr if not available. - const FArrayBox* getBndryAreaData () const; + [[nodiscard]] const FArrayBox* getBndryAreaData () const; //! Get pointers to area fraction data if available. The return value //! could be nullptr if not available. - Array getAreaFracData () const; + [[nodiscard]] Array getAreaFracData () const; //! Get pointers to face centroid data if available. The return value //! could be nullptr if not available. - Array getFaceCentData () const; + [[nodiscard]] Array getFaceCentData () const; //! Get pointers to edge centroid data if available. The return value //! could be nullptr if not available. - Array getEdgeCentData () const; + [[nodiscard]] Array getEdgeCentData () const; private: const EBCellFlagFab* m_ebcellflag = nullptr; diff --git a/Src/EB/AMReX_EBFArrayBox.cpp b/Src/EB/AMReX_EBFArrayBox.cpp index 073e286c807..781112ed2c1 100644 --- a/Src/EB/AMReX_EBFArrayBox.cpp +++ b/Src/EB/AMReX_EBFArrayBox.cpp @@ -7,9 +7,7 @@ namespace amrex { -EBFArrayBox::EBFArrayBox () -{ -} +EBFArrayBox::EBFArrayBox () = default; EBFArrayBox::EBFArrayBox (Arena* ar) : FArrayBox(ar) @@ -37,10 +35,7 @@ EBFArrayBox::EBFArrayBox (EBFArrayBox const& rhs, MakeType make_type, int scomp, m_type = rhs.m_type; } -EBFArrayBox::~EBFArrayBox () -{ - -} +EBFArrayBox::~EBFArrayBox () = default; const FArrayBox* EBFArrayBox::getLevelSetData () const @@ -178,7 +173,7 @@ EBFArrayBox::getEdgeCentData () const const EBCellFlagFab& getEBCellFlagFab (const FArrayBox& fab) { - const EBFArrayBox* ebfab = static_cast(&fab); + const auto* ebfab = static_cast(&fab); BL_ASSERT(ebfab); return ebfab->getEBCellFlagFab(); } diff --git a/Src/EB/AMReX_EBFabFactory.H b/Src/EB/AMReX_EBFabFactory.H index dbe31d4b683..aa8a3ece2d2 100644 --- a/Src/EB/AMReX_EBFabFactory.H +++ b/Src/EB/AMReX_EBFabFactory.H @@ -25,7 +25,7 @@ public: EBFArrayBoxFactory (const EB2::Level& a_level, const Geometry& a_geom, const BoxArray& a_ba, const DistributionMapping& a_dm, const Vector& a_ngrow, EBSupport a_support); - virtual ~EBFArrayBoxFactory () = default; + ~EBFArrayBoxFactory () override = default; EBFArrayBoxFactory (const EBFArrayBoxFactory&) = default; EBFArrayBoxFactory (EBFArrayBoxFactory&&) noexcept = default; @@ -35,53 +35,53 @@ public: EBFArrayBoxFactory& operator= (EBFArrayBoxFactory&&) = delete; AMREX_NODISCARD - virtual FArrayBox* create (const Box& box, int ncomps, const FabInfo& info, int box_index) const final; + FArrayBox* create (const Box& box, int ncomps, const FabInfo& info, int box_index) const final; AMREX_NODISCARD - virtual FArrayBox* create_alias (FArrayBox const& rhs, int scomp, int ncomp) const final; + FArrayBox* create_alias (FArrayBox const& rhs, int scomp, int ncomp) const final; - virtual void destroy (FArrayBox* fab) const final; + void destroy (FArrayBox* fab) const final; AMREX_NODISCARD - virtual EBFArrayBoxFactory* clone () const final; + EBFArrayBoxFactory* clone () const final; - const FabArray& getMultiEBCellFlagFab () const noexcept + [[nodiscard]] const FabArray& getMultiEBCellFlagFab () const noexcept { return m_ebdc->getMultiEBCellFlagFab(); } - const MultiFab& getLevelSet () const noexcept { return m_ebdc->getLevelSet(); } + [[nodiscard]] const MultiFab& getLevelSet () const noexcept { return m_ebdc->getLevelSet(); } - const MultiFab& getVolFrac () const noexcept { return m_ebdc->getVolFrac(); } + [[nodiscard]] const MultiFab& getVolFrac () const noexcept { return m_ebdc->getVolFrac(); } - const MultiCutFab& getCentroid () const noexcept { return m_ebdc->getCentroid(); } + [[nodiscard]] const MultiCutFab& getCentroid () const noexcept { return m_ebdc->getCentroid(); } - const MultiCutFab& getBndryCent () const noexcept { return m_ebdc->getBndryCent(); } + [[nodiscard]] const MultiCutFab& getBndryCent () const noexcept { return m_ebdc->getBndryCent(); } - const MultiCutFab& getBndryNormal () const noexcept { return m_ebdc->getBndryNormal(); } + [[nodiscard]] const MultiCutFab& getBndryNormal () const noexcept { return m_ebdc->getBndryNormal(); } - const MultiCutFab& getBndryArea () const noexcept { return m_ebdc->getBndryArea(); } + [[nodiscard]] const MultiCutFab& getBndryArea () const noexcept { return m_ebdc->getBndryArea(); } - Array getAreaFrac () const noexcept { + [[nodiscard]] Array getAreaFrac () const noexcept { return m_ebdc->getAreaFrac(); } // For y-face-centroid, the two components are for x and then z-directions, respectively. - Array getFaceCent () const noexcept { + [[nodiscard]] Array getFaceCent () const noexcept { return m_ebdc->getFaceCent(); } - Array getEdgeCent () const noexcept { + [[nodiscard]] Array getEdgeCent () const noexcept { return m_ebdc->getEdgeCent(); } - bool isAllRegular () const noexcept; + [[nodiscard]] bool isAllRegular () const noexcept; - EB2::Level const* getEBLevel () const noexcept { return m_parent; } - EB2::IndexSpace const* getEBIndexSpace () const noexcept; - int maxCoarseningLevel () const noexcept; + [[nodiscard]] EB2::Level const* getEBLevel () const noexcept { return m_parent; } + [[nodiscard]] EB2::IndexSpace const* getEBIndexSpace () const noexcept; + [[nodiscard]] int maxCoarseningLevel () const noexcept; - const DistributionMapping& DistributionMap () const noexcept; - const BoxArray& boxArray () const noexcept; - const Geometry& Geom () const noexcept { return m_geom; } + [[nodiscard]] const DistributionMapping& DistributionMap () const noexcept; + [[nodiscard]] const BoxArray& boxArray () const noexcept; + [[nodiscard]] const Geometry& Geom () const noexcept { return m_geom; } private: diff --git a/Src/EB/AMReX_EBFabFactory.cpp b/Src/EB/AMReX_EBFabFactory.cpp index 87ac8eeff67..1fd928b3c0b 100644 --- a/Src/EB/AMReX_EBFabFactory.cpp +++ b/Src/EB/AMReX_EBFabFactory.cpp @@ -48,7 +48,7 @@ EBFArrayBoxFactory::create_alias (FArrayBox const& rhs, int scomp, int ncomp) co } else { - EBFArrayBox const& ebrhs = static_cast(rhs); + auto const& ebrhs = static_cast(rhs); return new EBFArrayBox(ebrhs, amrex::make_alias, scomp, ncomp); } } @@ -62,7 +62,7 @@ EBFArrayBoxFactory::destroy (FArrayBox* fab) const } else { - EBFArrayBox* p = static_cast(fab); + auto* p = static_cast(fab); delete p; } } diff --git a/Src/EB/AMReX_EBFluxRegister.H b/Src/EB/AMReX_EBFluxRegister.H index 0ea4c115e82..c53f0a894a6 100644 --- a/Src/EB/AMReX_EBFluxRegister.H +++ b/Src/EB/AMReX_EBFluxRegister.H @@ -77,7 +77,7 @@ public: const Real* dx, Real dt, const FArrayBox& volfrac, const std::array& areafrac, - RunOn gpu_or_cpu); + RunOn runon); using YAFluxRegister::FineAdd; void FineAdd (const MFIter& mfi, @@ -86,7 +86,7 @@ public: const FArrayBox& volfrac, const std::array& areafrac, const FArrayBox& dm, - RunOn gpu_or_cpu); + RunOn runon); void Reflux (MultiFab& crse_state, const amrex::MultiFab& crse_vfrac, MultiFab& fine_state, const amrex::MultiFab& fine_vfrac); diff --git a/Src/EB/AMReX_EBInterpolater.H b/Src/EB/AMReX_EBInterpolater.H index 27ff42085dc..e0299c1c326 100644 --- a/Src/EB/AMReX_EBInterpolater.H +++ b/Src/EB/AMReX_EBInterpolater.H @@ -13,9 +13,7 @@ public: using CellConservativeLinear::CellConservativeLinear; - virtual ~EBCellConservativeLinear () = default; - - virtual void interp (const FArrayBox& crse, + void interp (const FArrayBox& crse, int crse_comp, FArrayBox& fine, int fine_comp, @@ -27,7 +25,7 @@ public: Vector const& bcr, int actual_comp, int actual_state, - RunOn gpu_or_cpu) override; + RunOn runon) override; }; extern AMREX_EXPORT EBCellConservativeLinear eb_lincc_interp; diff --git a/Src/EB/AMReX_EBInterpolater.cpp b/Src/EB/AMReX_EBInterpolater.cpp index 823f7739ff6..cc020637aca 100644 --- a/Src/EB/AMReX_EBInterpolater.cpp +++ b/Src/EB/AMReX_EBInterpolater.cpp @@ -7,7 +7,7 @@ namespace amrex { EBCellConservativeLinear eb_lincc_interp; -EBCellConservativeLinear eb_cell_cons_interp(0); +EBCellConservativeLinear eb_cell_cons_interp(false); void EBCellConservativeLinear::interp (const FArrayBox& crse, @@ -35,8 +35,8 @@ EBCellConservativeLinear::interp (const FArrayBox& crse, } else { - const EBFArrayBox& crse_eb = static_cast(crse); - EBFArrayBox& fine_eb = static_cast(fine); + const auto& crse_eb = static_cast(crse); + auto& fine_eb = static_cast(fine); const EBCellFlagFab& crse_flag = crse_eb.getEBCellFlagFab(); const EBCellFlagFab& fine_flag = fine_eb.getEBCellFlagFab(); diff --git a/Src/EB/AMReX_EBMFInterpolater.H b/Src/EB/AMReX_EBMFInterpolater.H index f71a35d6117..55d74fc0d75 100644 --- a/Src/EB/AMReX_EBMFInterpolater.H +++ b/Src/EB/AMReX_EBMFInterpolater.H @@ -12,12 +12,10 @@ class EBMFCellConsLinInterp final public: using MFCellConsLinInterp::MFCellConsLinInterp; - virtual ~EBMFCellConsLinInterp () = default; - - virtual void interp (MultiFab const& crsemf, int ccomp, MultiFab& finemf, int fcomp, int ncomp, + void interp (MultiFab const& crsemf, int ccomp, MultiFab& finemf, int fcomp, int ncomp, IntVect const& ng, Geometry const& cgeom, Geometry const& fgeom, Box const& dest_domain, IntVect const& ratio, - Vector const& bcs, int bcscomp); + Vector const& bcs, int bcomp) override; }; extern AMREX_EXPORT EBMFCellConsLinInterp eb_mf_cell_cons_interp; diff --git a/Src/EB/AMReX_EBMFInterpolater.cpp b/Src/EB/AMReX_EBMFInterpolater.cpp index 6be06110b32..608d5a4dacb 100644 --- a/Src/EB/AMReX_EBMFInterpolater.cpp +++ b/Src/EB/AMReX_EBMFInterpolater.cpp @@ -16,8 +16,8 @@ EBMFCellConsLinInterp::interp (MultiFab const& crsemf, int ccomp, MultiFab& fine MFCellConsLinInterp::interp(crsemf, ccomp, finemf, fcomp, nc, ng, cgeom, fgeom, dest_domain, ratio, bcs, bcomp); - auto const ffact = dynamic_cast(&finemf.Factory()); - auto const cfact = dynamic_cast(&crsemf.Factory()); + const auto *const ffact = dynamic_cast(&finemf.Factory()); + const auto *const cfact = dynamic_cast(&crsemf.Factory()); if (!ffact || !cfact || ffact->isAllRegular()) { return; } diff --git a/Src/EB/AMReX_EBMultiFabUtil.H b/Src/EB/AMReX_EBMultiFabUtil.H index 702b15161c9..da03ef5be37 100644 --- a/Src/EB/AMReX_EBMultiFabUtil.H +++ b/Src/EB/AMReX_EBMultiFabUtil.H @@ -15,7 +15,7 @@ namespace amrex void EB_set_covered (MultiFab& mf, int icomp, int ncomp, int ngrow, const Vector& vals); void EB_set_covered_faces (const Array& umac, Real val); - void EB_set_covered_faces (const Array& umac, const int scomp, const int ncomp, const Vector& vals); + void EB_set_covered_faces (const Array& umac, int scomp, int ncomp, const Vector& vals); void EB_average_down (const MultiFab& S_fine, MultiFab& S_crse, const MultiFab& vol_fine, const MultiFab& vfrac_fine, int scomp, int ncomp, const IntVect& ratio); @@ -54,13 +54,13 @@ namespace amrex const Array& fmf); // Cell centers to cell centroids - void EB_interp_CC_to_Centroid (MultiFab& cntrd, const MultiFab& cc, int scomp, int dcomp, int ncomp, const Geometry& geom); + void EB_interp_CC_to_Centroid (MultiFab& cent, const MultiFab& cc, int scomp, int dcomp, int ncomp, const Geometry& geom); // Cell centers to face centroids void EB_interp_CC_to_FaceCentroid (const MultiFab& cc, - AMREX_D_DECL( MultiFab& fcx, - MultiFab& fcy, - MultiFab& fcz), + AMREX_D_DECL( MultiFab& fc_x, + MultiFab& fc_y, + MultiFab& fc_z), int scomp, int dcomp, int nc, const Geometry& geom, const amrex::Vector& a_bcs); diff --git a/Src/EB/AMReX_EBMultiFabUtil.cpp b/Src/EB/AMReX_EBMultiFabUtil.cpp index f215c2a1ae0..57d36a536b6 100644 --- a/Src/EB/AMReX_EBMultiFabUtil.cpp +++ b/Src/EB/AMReX_EBMultiFabUtil.cpp @@ -26,7 +26,7 @@ EB_set_covered (MultiFab& mf, Real val) void EB_set_covered (MultiFab& mf, int icomp, int ncomp, int ngrow, Real val) { - const auto factory = dynamic_cast(&(mf.Factory())); + const auto *const factory = dynamic_cast(&(mf.Factory())); if (factory == nullptr) return; const auto& flags = factory->getMultiEBCellFlagFab(); @@ -68,7 +68,7 @@ EB_set_covered (MultiFab& mf, int icomp, int ncomp, const Vector& vals) void EB_set_covered (MultiFab& mf, int icomp, int ncomp, int ngrow, const Vector& a_vals) { - const auto factory = dynamic_cast(&(mf.Factory())); + const auto *const factory = dynamic_cast(&(mf.Factory())); if (factory == nullptr) return; const auto& flags = factory->getMultiEBCellFlagFab(); @@ -108,7 +108,7 @@ EB_set_covered (MultiFab& mf, int icomp, int ncomp, int ngrow, const Vector& umac, Real val) { - const auto factory = dynamic_cast(&(umac[0]->Factory())); + const auto *const factory = dynamic_cast(&(umac[0]->Factory())); if (factory == nullptr) return; const auto& area = factory->getAreaFrac(); @@ -219,7 +219,7 @@ EB_set_covered_faces (const Array& umac, Real val) void EB_set_covered_faces (const Array& umac, const int scomp, const int ncomp, const Vector& a_vals ) { - const auto factory = dynamic_cast(&(umac[0]->Factory())); + const auto *const factory = dynamic_cast(&(umac[0]->Factory())); if (factory == nullptr) return; const auto& area = factory->getAreaFrac(); diff --git a/Src/EB/AMReX_EBToPVD.H b/Src/EB/AMReX_EBToPVD.H index 17692f0edf4..b1320c13a06 100644 --- a/Src/EB/AMReX_EBToPVD.H +++ b/Src/EB/AMReX_EBToPVD.H @@ -14,17 +14,17 @@ namespace amrex { class EBToPVD { public: - EBToPVD(): m_grid(0) {} + EBToPVD() = default; void EBToPolygon(const Real* problo, const Real* dx, const Box & bx, Array4 const& flag, Array4 const& bcent, Array4 const& apx, Array4 const& apy, Array4 const& apz); - void WriteEBVTP(const int myID) const; - void WritePVTP(const int nProcs) const; + void WriteEBVTP(int myID) const; + static void WritePVTP(int nProcs) ; - void EBGridCoverage(const int myID, const Real* problo, const Real* dx, + void EBGridCoverage(int myID, const Real* problo, const Real* dx, const Box &bx, Array4 const& flag); private: @@ -32,18 +32,18 @@ private: const std::array& lnormal); // Calculates the Hesse Normal FOrm corresponding to normal and centroid - void calc_hesse(Real& distance, std::array& n0, Real& p, - const std::array& normal, const std::array& centroid) const; + static void calc_hesse(Real& distance, std::array& n0, Real& p, + const std::array& normal, const std::array& centroid) ; // Fills the alpha vector - void calc_alpha(std::array& alpha, + static void calc_alpha(std::array& alpha, const std::array& n0, Real p, const std::array,8>& vertex, - const Real* dx) const; + const Real* dx) ; // Fills count and flags selecting the alphas which are in (0,1) - void calc_intersects(int& int_count, std::array& intersects_flags, - const std::array& alpha) const; + static void calc_intersects(int& int_count, std::array& intersects_flags, + const std::array& alpha) ; void print_points(std::ofstream& myfile) const; void print_connectivity(std::ofstream& myfile) const; @@ -51,7 +51,7 @@ private: std::vector> m_points; std::vector> m_connectivity; - int m_grid; + int m_grid{0}; }; diff --git a/Src/EB/AMReX_EBToPVD.cpp b/Src/EB/AMReX_EBToPVD.cpp index fd5e4cfad68..332cea1abfb 100644 --- a/Src/EB/AMReX_EBToPVD.cpp +++ b/Src/EB/AMReX_EBToPVD.cpp @@ -172,7 +172,7 @@ void EBToPVD::EBToPolygon(const Real* problo, const Real* dx, m_points.push_back(apoints[lc1]); int lc2 = m_connectivity.back()[0]+1; m_connectivity.back()[0] = lc2; - m_connectivity.back()[lc2] = m_points.size()-1; + m_connectivity.back()[lc2] = static_cast(m_points.size()-1); } } @@ -196,8 +196,8 @@ void EBToPVD::WriteEBVTP(const int myID) const myfile << "\n"; myfile << "\n"; myfile << "\n"; - myfile << "\n"; print_points(myfile); print_connectivity(myfile); @@ -211,7 +211,7 @@ void EBToPVD::WriteEBVTP(const int myID) const } } -void EBToPVD::WritePVTP(const int nProcs) const +void EBToPVD::WritePVTP(const int nProcs) { std::ofstream myfile("eb.pvtp"); @@ -315,7 +315,7 @@ void EBToPVD::reorder_polygon(const std::vector>& lpoints, } void EBToPVD::calc_hesse(Real& distance, std::array& n0, Real& p, - const std::array& normal, const std::array& centroid) const + const std::array& normal, const std::array& centroid) { Real sign_of_dist; @@ -337,7 +337,7 @@ void EBToPVD::calc_hesse(Real& distance, std::array& n0, Real& p, void EBToPVD::calc_alpha(std::array& alpha, const std::array& n0, Real p, const std::array,8>& vertex, - const Real* dx) const + const Real* dx) { // default (large) value std::fill(alpha.begin(), alpha.end(), 10.0); @@ -368,7 +368,7 @@ void EBToPVD::calc_alpha(std::array& alpha, } void EBToPVD::calc_intersects(int& int_count, std::array& intersects_flags, - const std::array& alpha) const + const std::array& alpha) { int_count = 0; std::fill(intersects_flags.begin(), intersects_flags.end(), false); @@ -386,9 +386,9 @@ void EBToPVD::print_points(std::ofstream& myfile) const myfile << "\n"; myfile << "\n"; - for(size_t lc1 = 0; lc1 < m_points.size(); ++lc1) { + for(const auto & m_point : m_points) { myfile << std::fixed << std::scientific - << m_points[lc1][0] << " " << m_points[lc1][1] << " " << m_points[lc1][2] << "\n"; + << m_point[0] << " " << m_point[1] << " " << m_point[2] << "\n"; } myfile << "\n"; @@ -399,9 +399,9 @@ void EBToPVD::print_connectivity(std::ofstream& myfile) const { myfile << "\n"; myfile << "\n"; - for(size_t lc1 = 0; lc1 < m_connectivity.size(); ++lc1) { - for(int lc2 = 1; lc2 <= m_connectivity[lc1][0]; ++lc2) { - myfile << " " << m_connectivity[lc1][lc2]; + for(const auto & lc1 : m_connectivity) { + for(int lc2 = 1; lc2 <= lc1[0]; ++lc2) { + myfile << " " << lc1[lc2]; } myfile << "\n"; } @@ -409,8 +409,8 @@ void EBToPVD::print_connectivity(std::ofstream& myfile) const myfile << "\n"; int lc2 = 0; - for(size_t lc1 = 0; lc1 < m_connectivity.size(); ++lc1) { - lc2 = lc2 + m_connectivity[lc1][0]; + for(const auto & lc1 : m_connectivity) { + lc2 = lc2 + lc1[0]; myfile << " " << lc2; } myfile << "\n"; @@ -471,12 +471,12 @@ void EBToPVD::EBGridCoverage(const int myID, const Real* problo, const Real* dx, lines[llc] = grid_start + llc*dx[idim]; } - myfile << "\n"; - for(size_t llc = 0; llc < lines.size(); ++llc) { - myfile << " " << lines[llc]; + for(auto line : lines) { + myfile << " " << line; } myfile << "\n"; diff --git a/Src/EB/AMReX_EB_STL_utils.H b/Src/EB/AMReX_EB_STL_utils.H index ff476a4e611..ddef3e87ec6 100644 --- a/Src/EB/AMReX_EB_STL_utils.H +++ b/Src/EB/AMReX_EB_STL_utils.H @@ -62,9 +62,9 @@ public: Array4 const& lst, Geometry const& geom, RunOn, Box const& bounding_box) const; - void updateIntercept (Array,AMREX_SPACEDIM> const& inter_arr, + static void updateIntercept (Array,AMREX_SPACEDIM> const& inter_arr, Array,AMREX_SPACEDIM> const& type_arr, - Array4 const& lst, Geometry const& geom) const; + Array4 const& lst, Geometry const& geom) ; }; diff --git a/Src/EB/AMReX_EB_STL_utils.cpp b/Src/EB/AMReX_EB_STL_utils.cpp index 6ef6c2ec6d2..89576639b46 100644 --- a/Src/EB/AMReX_EB_STL_utils.cpp +++ b/Src/EB/AMReX_EB_STL_utils.cpp @@ -18,7 +18,7 @@ namespace { amrex::max(a[2],b[2]) < amrex::min(tri.v1.z,tri.v2.z,tri.v3.z) || amrex::min(a[2],b[2]) > amrex::max(tri.v1.z,tri.v2.z,tri.v3.z)) { - return 0; + return false; } else { @@ -51,7 +51,7 @@ namespace { Real dlevset) { if ((dlevset > 0._rt && norm.x > 0._rt) || (dlevset < 0._rt && norm.x < 0._rt)) - { // This triangle has the wrong direction + { // This triangle has the wrong direction // NOLINT(bugprone-branch-clone) return std::make_pair(false,0.0_rt); } else if (x1 > amrex::max(v1.x,v2.x,v3.x) || @@ -679,7 +679,7 @@ STLtools::getIntercept (Array,AMREX_SPACEDIM> const& inter_arr, void STLtools::updateIntercept (Array,AMREX_SPACEDIM> const& inter_arr, Array,AMREX_SPACEDIM> const& type_arr, - Array4 const& lst, Geometry const& geom) const + Array4 const& lst, Geometry const& geom) { auto const& dx = geom.CellSizeArray(); auto const& problo = geom.ProbLoArray(); diff --git a/Src/EB/AMReX_EB_chkpt_file.H b/Src/EB/AMReX_EB_chkpt_file.H index 781db55a1d8..49c55139532 100644 --- a/Src/EB/AMReX_EB_chkpt_file.H +++ b/Src/EB/AMReX_EB_chkpt_file.H @@ -31,7 +31,7 @@ private: public: - ChkptFile (const std::string &fname); + ChkptFile (std::string fname); void read_from_chkpt_file (BoxArray& cut_grids, BoxArray& covered_grids, DistributionMapping& dmap, diff --git a/Src/EB/AMReX_EB_chkpt_file.cpp b/Src/EB/AMReX_EB_chkpt_file.cpp index d3caff7e05a..214304f73c9 100644 --- a/Src/EB/AMReX_EB_chkpt_file.cpp +++ b/Src/EB/AMReX_EB_chkpt_file.cpp @@ -4,6 +4,7 @@ #include #include // amrex::VisMF::Write(MultiFab) #include // amrex::[read,write]IntData(array_of_ints) +#include namespace { @@ -17,7 +18,7 @@ void gotoNextLine (std::istream& is) } -namespace amrex { namespace EB2 { +namespace amrex::EB2 { // Header information includes the cut and covered boxes (if any) // Checkpoint file contains data for cut boxes @@ -91,8 +92,8 @@ ChkptFile::writeToFile (const MultiFab& mf, const std::string& mf_name) const } -ChkptFile::ChkptFile (const std::string &fname) - : m_restart_file(fname) +ChkptFile::ChkptFile (std::string fname) + : m_restart_file(std::move(fname)) {} void @@ -107,8 +108,12 @@ ChkptFile::read_from_chkpt_file (BoxArray& cut_grids, BoxArray& covered_grids, const IntVect& ngrow_finest, bool extend_domain_face, int max_grid_size) const { - Real prob_lo[AMREX_SPACEDIM]; - Real prob_hi[AMREX_SPACEDIM]; + Real prob_lo[] = {AMREX_D_DECL(std::numeric_limits::max(), + std::numeric_limits::max(), + std::numeric_limits::max())}; + Real prob_hi[] = {AMREX_D_DECL(std::numeric_limits::lowest(), + std::numeric_limits::lowest(), + std::numeric_limits::lowest())}; std::string File(m_restart_file + "/Header"); @@ -321,4 +326,4 @@ ChkptFile::write_to_chkpt_file (const BoxArray& cut_grids, } } -}} +} diff --git a/Src/EB/AMReX_EB_triGeomOps_K.H b/Src/EB/AMReX_EB_triGeomOps_K.H index 8ffca711c83..242093d2acf 100644 --- a/Src/EB/AMReX_EB_triGeomOps_K.H +++ b/Src/EB/AMReX_EB_triGeomOps_K.H @@ -9,20 +9,20 @@ namespace amrex namespace tri_geom_ops { //================================================================================ - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real Distance2(Real P1[3],Real P2[3]) + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real Distance2(const Real P1[3],const Real P2[3]) { return( (P1[0]-P2[0])*(P1[0]-P2[0]) + (P1[1]-P2[1])*(P1[1]-P2[1]) + (P1[2]-P2[2])*(P1[2]-P2[2]) ); } //================================================================================ - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real DotProd(Real v1[3],Real v2[3]) + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real DotProd(const Real v1[3],const Real v2[3]) { return(v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]); } //================================================================================ // If this is zero, the two lines either intersect or are parallel. - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real side_op(Real L1[6],Real L2[6]) + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real side_op(const Real L1[6],const Real L2[6]) { return( L1[0]*L2[4] + L1[1]*L2[5] @@ -32,14 +32,14 @@ namespace amrex + L1[5]*L2[1] ); } //================================================================================ - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void getvec(Real P1[3],Real P2[3],Real v[3]) + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void getvec(const Real P1[3],const Real P2[3],Real v[3]) { v[0]=P2[0]-P1[0]; v[1]=P2[1]-P1[1]; v[2]=P2[2]-P1[2]; } //================================================================================ - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void getunitvec(Real v[3],Real vu[3]) + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void getunitvec(const Real v[3],Real vu[3]) { Real vmag; vmag=std::sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); @@ -48,14 +48,14 @@ namespace amrex vu[2]=v[2]/vmag; } //================================================================================ - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void CrossProd(Real v1[3],Real v2[3],Real v[3]) + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void CrossProd(const Real v1[3],const Real v2[3],Real v[3]) { v[0]=v1[1]*v2[2]-v1[2]*v2[1]; v[1]=v1[2]*v2[0]-v1[0]*v2[2]; v[2]=v1[0]*v2[1]-v1[1]*v2[0]; } //================================================================================ - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void get_plucker_coords(Real v1[3],Real v2[3],Real L[6]) + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void get_plucker_coords(const Real v1[3],const Real v2[3],Real L[6]) { L[0] = v1[0]*v2[1] - v1[1]*v2[0]; L[1] = v1[0]*v2[2] - v1[2]*v2[0]; @@ -122,7 +122,7 @@ namespace amrex } //================================================================================ //this is only useful when v1-v2 segment intersects the triangle - AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool find_intersection_point(Real v1[3],Real v2[3], + AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool find_intersection_point(const Real v1[3],const Real v2[3], Real t1[3], Real t2[3], Real t3[3],Real ip[3],int bisect_iters=20,Real tol=1e-6) { Real plane_eq_mid,plane_eq1,plane_eq2; diff --git a/Src/EB/AMReX_EB_utils.cpp b/Src/EB/AMReX_EB_utils.cpp index 935b937cac3..d7f51ce2c4c 100644 --- a/Src/EB/AMReX_EB_utils.cpp +++ b/Src/EB/AMReX_EB_utils.cpp @@ -246,7 +246,7 @@ namespace amrex { const Box& bx = mfi.tilebox (); // this is to check efficiently if this tile contains any eb stuff - const EBFArrayBox& div_fab = static_cast(div_out[mfi]); + const auto& div_fab = static_cast(div_out[mfi]); const EBCellFlagFab& flags = div_fab.getEBCellFlagFab(); if ( !(flags.getType(amrex::grow(bx, 0)) == FabType::covered) && @@ -277,7 +277,7 @@ namespace amrex { void FillSignedDistance (MultiFab& mf, bool fluid_has_positive_sign) { - auto factory = dynamic_cast(&(mf.Factory())); + const auto *factory = dynamic_cast(&(mf.Factory())); if (factory) { FillSignedDistance(mf, *(factory->getEBLevel()), *factory, 1, fluid_has_positive_sign); } else { @@ -498,7 +498,7 @@ void FillSignedDistance (MultiFab& mf, EB2::Level const& ls_lev, Box eb_search = mfi.validbox(); eb_search.coarsen(refratio).enclosedCells().grow(eb_pad); - const int nallcells = eb_search.numPts(); + const auto nallcells = static_cast(eb_search.numPts()); Gpu::DeviceVector is_cut(nallcells); int* p_is_cut = is_cut.data(); @@ -523,14 +523,14 @@ void FillSignedDistance (MultiFab& mf, EB2::Level const& ls_lev, if (ncutcells > 0) { Gpu::DeviceVector > facets(ncutcells); - auto p_facets = facets.data(); + auto *p_facets = facets.data(); Array4 const& bcent = bndrycent.const_array(mfi); AMREX_D_TERM(Array4 const& apx = areafrac[0]->const_array(mfi);, Array4 const& apy = areafrac[1]->const_array(mfi);, Array4 const& apz = areafrac[2]->const_array(mfi)); amrex::ParallelFor(eb_search, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept { - int icell = eb_search.index(IntVect(AMREX_D_DECL(i,j,k))); + auto icell = eb_search.index(IntVect(AMREX_D_DECL(i,j,k))); if (p_is_cut[icell]) { GpuArray& fac = p_facets[p_cutcell_offset[icell]]; AMREX_D_TERM(fac[0] = (bcent(i,j,k,0)+Real(i)+0.5_rt) * dx_eb[0];, diff --git a/Src/EB/AMReX_MultiCutFab.H b/Src/EB/AMReX_MultiCutFab.H index 5d30f114a48..0e48a0b80dc 100644 --- a/Src/EB/AMReX_MultiCutFab.H +++ b/Src/EB/AMReX_MultiCutFab.H @@ -13,7 +13,7 @@ class CutFab final { public: - CutFab () {} + CutFab () = default; explicit CutFab (Arena* ar) : FArrayBox(ar) {} @@ -27,7 +27,7 @@ public: CutFab (CutFab const& rhs, MakeType make_type, int scomp, int ncomp) : FArrayBox(rhs, make_type, scomp, ncomp) {} - virtual ~CutFab () noexcept override = default; + ~CutFab () noexcept override = default; CutFab (CutFab&& rhs) noexcept = default; diff --git a/Src/EB/AMReX_MultiCutFab.cpp b/Src/EB/AMReX_MultiCutFab.cpp index 665a19ec463..1c4fcece2c1 100644 --- a/Src/EB/AMReX_MultiCutFab.cpp +++ b/Src/EB/AMReX_MultiCutFab.cpp @@ -8,8 +8,7 @@ namespace amrex { -MultiCutFab::MultiCutFab () -{} +MultiCutFab::MultiCutFab () = default; MultiCutFab::MultiCutFab (const BoxArray& ba, const DistributionMapping& dm, int ncomp, int ngrow, const FabArray& cellflags) @@ -20,7 +19,7 @@ MultiCutFab::MultiCutFab (const BoxArray& ba, const DistributionMapping& dm, } MultiCutFab::~MultiCutFab () -{} += default; void MultiCutFab::define (const BoxArray& ba, const DistributionMapping& dm, diff --git a/Src/EB/AMReX_WriteEBSurface.cpp b/Src/EB/AMReX_WriteEBSurface.cpp index c6cf071621c..52b50d6c182 100644 --- a/Src/EB/AMReX_WriteEBSurface.cpp +++ b/Src/EB/AMReX_WriteEBSurface.cpp @@ -50,8 +50,9 @@ void WriteEBSurface (const BoxArray & ba, const DistributionMapping & dmap, cons eb_to_pvd.WriteEBVTP(cpu); - if(ParallelDescriptor::IOProcessor()) - eb_to_pvd.WritePVTP(nProcs); + if(ParallelDescriptor::IOProcessor()) { + EBToPVD::WritePVTP(nProcs); + } for (MFIter mfi(mf_ba); mfi.isValid(); ++mfi) { @@ -68,4 +69,3 @@ void WriteEBSurface (const BoxArray & ba, const DistributionMapping & dmap, cons } } - diff --git a/Src/EB/AMReX_algoim.cpp b/Src/EB/AMReX_algoim.cpp index 5fc34d51ff2..08a4e2f5d54 100644 --- a/Src/EB/AMReX_algoim.cpp +++ b/Src/EB/AMReX_algoim.cpp @@ -3,7 +3,7 @@ #include #include -namespace amrex { namespace algoim { +namespace amrex::algoim { void compute_integrals (MultiFab& intg, int nghost) @@ -383,4 +383,4 @@ compute_surface_integrals (MultiFab& sintgmf, IntVect nghost) #endif } -}} +} diff --git a/Src/EB/AMReX_distFcnElement.H b/Src/EB/AMReX_distFcnElement.H index 2a9c7a0c2f4..8bd1ebe8755 100644 --- a/Src/EB/AMReX_distFcnElement.H +++ b/Src/EB/AMReX_distFcnElement.H @@ -18,10 +18,10 @@ class distFcnElement2d { virtual amrex::Real cpdist(amrex::RealVect pt, amrex::RealVect& cp) const = 0; virtual amrex::Real cpside(amrex::RealVect pt, amrex::RealVect& cp) const = 0; - int solve_thomas(const std::vector &diagminus, - std::vector diag, - const std::vector &diagplus, - std::vector rhs, + static int solve_thomas(const std::vector &a, + std::vector b, + const std::vector &c, + std::vector d, std::vector &X); }; @@ -41,11 +41,11 @@ class LineDistFcnElement2d: public distFcnElement2d { void print_control_points(); protected: - void single_seg_cpdist(amrex::RealVect pt, + static void single_seg_cpdist(amrex::RealVect pt, amrex::Real x0, amrex::Real x1, amrex::Real y0, amrex::Real y1, amrex::RealVect& cp, - amrex::Real& dist) const; + amrex::Real& dist); private: std::vector control_points_x; @@ -75,27 +75,27 @@ class SplineDistFcnElement2d: public distFcnElement2d { virtual amrex::Real cpside(amrex::RealVect pt, amrex::RealVect& cp) const override; protected: - amrex::Real eval(amrex::Real t, amrex::Real y0, amrex::Real y1, - amrex::Real D0, amrex::Real D1) const; - void dxbydt(amrex::Real t, amrex::Real y0, amrex::Real y1, + static amrex::Real eval(amrex::Real t, amrex::Real y0, amrex::Real y1, + amrex::Real D0, amrex::Real D1); + static void dxbydt(amrex::Real t, amrex::Real y0, amrex::Real y1, amrex::Real D0, amrex::Real D1, amrex::Real& dyf, - amrex::Real& d2yf) const; + amrex::Real& d2yf); - void single_spline_cpdist(amrex::RealVect pt, + static void single_spline_cpdist(amrex::RealVect pt, amrex::Real x0, amrex::Real x1, amrex::Real Dx0, amrex::Real Dx1, amrex::Real y0, amrex::Real y1, amrex::Real Dy0, amrex::Real Dy1, amrex::Real& t, amrex::RealVect& cp, - amrex::Real& dist) const; + amrex::Real& dist); - amrex::Real dist(amrex::RealVect pt, + static amrex::Real dist(amrex::RealVect pt, amrex::Real x0, amrex::Real x1, amrex::Real Dx0, amrex::Real Dx1, amrex::Real y0, amrex::Real y1, amrex::Real Dy0, amrex::Real Dy1, amrex::Real& t, - amrex::RealVect& spt) const; + amrex::RealVect& spt); private: std::vector control_points_x; diff --git a/Src/EB/AMReX_distFcnElement.cpp b/Src/EB/AMReX_distFcnElement.cpp index b4d88d4da1d..720510c9043 100644 --- a/Src/EB/AMReX_distFcnElement.cpp +++ b/Src/EB/AMReX_distFcnElement.cpp @@ -10,13 +10,13 @@ int distFcnElement2d::solve_thomas(const std::vector &a, std::vector b, const std::vector &c, std::vector d, - std::vector &x) { - unsigned n; - n = d.size(); + std::vector &x) +{ + int n = static_cast(d.size()); x.resize(n); amrex::Real m; - for (unsigned i=1; i < n; ++i) { + for (int i=1; i < n; ++i) { m = a[i-1]/b[i-1]; b[i] -= m*c[i-1]; d[i] -= m*d[i-1]; @@ -41,7 +41,7 @@ int distFcnElement2d::solve_thomas(const std::vector &a, namespace amrex { distFcnElement2d* SplineDistFcnElement2d::newDistFcnElement2d() const { - SplineDistFcnElement2d* newSpline = new SplineDistFcnElement2d(); + auto* newSpline = new SplineDistFcnElement2d(); newSpline->control_points_x = control_points_x; newSpline->control_points_y = control_points_y; newSpline->bc_pt_start = bc_pt_start; @@ -53,7 +53,7 @@ distFcnElement2d* SplineDistFcnElement2d::newDistFcnElement2d() const { amrex::Real SplineDistFcnElement2d::eval(amrex::Real t, amrex::Real y0, amrex::Real y1, - amrex::Real D0, amrex::Real D1) const { + amrex::Real D0, amrex::Real D1) { amrex::Real c, d; c = 3.0_rt*(y1 - y0) - 2.0_rt*D0 - D1; @@ -67,7 +67,8 @@ amrex::Real SplineDistFcnElement2d::dist(amrex::RealVect pt, amrex::Real y0, amrex::Real y1, amrex::Real Dy0, amrex::Real Dy1, amrex::Real& t, - amrex::RealVect& spt) const { + amrex::RealVect& spt) +{ amrex::RealVect delta; spt[0] = eval(t, x0, x1, Dx0, Dx1); spt[1] = eval(t, y0, y1, Dy0, Dy1); @@ -87,7 +88,7 @@ amrex::Real SplineDistFcnElement2d::cpdist(amrex::RealVect pt, amrex::Real t; amrex::RealVect cp; amrex::Real dist; - int nsplines = Dx.size() - 1; + int nsplines = static_cast(Dx.size() - 1); for (int i=0; i(Dx.size() - 1); for (int i=0; i(control_points_x.size()); icontrol_points_x = control_points_x; newLine->control_points_y = control_points_y; return static_cast(newLine); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H b/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H index 0365a01c683..3400b9f795f 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H @@ -1002,7 +1002,7 @@ MLCellLinOpT::interpAssign (int amrlev, int fmglev, MF& fine, MF& crse) cons ignore_unused(isEB); #ifdef AMREX_USE_EB - auto factory = dynamic_cast(&(fine.Factory())); + const auto *factory = dynamic_cast(&(fine.Factory())); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; #endif @@ -1072,7 +1072,7 @@ MLCellLinOpT::interpolationAmr (int famrlev, MF& fine, const MF& crse, const int refratio = this->AMRRefRatio(famrlev-1); #ifdef AMREX_USE_EB - auto factory = dynamic_cast(this->Factory(famrlev)); + const auto *factory = dynamic_cast(this->Factory(famrlev)); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; #endif @@ -1529,7 +1529,7 @@ MLCellLinOpT::getSolvabilityOffset (int amrlev, int mglev, MF const& rhs) co Vector offset(ncomp); #ifdef AMREX_USE_EB - auto factory = dynamic_cast(this->Factory(amrlev,mglev)); + const auto *factory = dynamic_cast(this->Factory(amrlev,mglev)); if (factory && !factory->isAllRegular()) { if constexpr (std::is_same()) { @@ -1599,7 +1599,7 @@ MLCellLinOpT::prepareForSolve () MF foo(this->m_grids[amrlev][mglev], this->m_dmap[amrlev][mglev], ncomp, 0, MFInfo().SetAlloc(false)); #ifdef AMREX_USE_EB - auto factory = dynamic_cast(this->m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(this->m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; auto area = (factory) ? factory->getAreaFrac() @@ -1917,7 +1917,7 @@ MLCellLinOpT::computeVolInv () const auto f = [&] (int amrlev, int mglev) { #ifdef AMREX_USE_EB - auto factory = dynamic_cast(this->Factory(amrlev,mglev)); + const auto *factory = dynamic_cast(this->Factory(amrlev,mglev)); if (factory && !factory->isAllRegular()) { if constexpr (std::is_same()) { @@ -1943,7 +1943,7 @@ MLCellLinOpT::computeVolInv () const #ifdef AMREX_USE_EB RT temp1, temp2; - auto factory = dynamic_cast(this->Factory(0,0)); + const auto *factory = dynamic_cast(this->Factory(0,0)); if (factory && !factory->isAllRegular()) { ParallelAllReduce::Sum({m_volinv[0][0], m_volinv[0][mgbottom]}, @@ -1973,7 +1973,7 @@ MLCellLinOpT::normInf (int amrlev, MF const& mf, bool local) const -> RT if constexpr (!std::is_same()) { amrex::Abort("MLCellLinOpT with EB only works with MultiFab"); } else { - auto factory = dynamic_cast(this->Factory(amrlev)); + const auto *factory = dynamic_cast(this->Factory(amrlev)); const MultiFab& vfrac = factory->getVolFrac(); if (amrlev == finest_level) { #ifdef AMREX_USE_GPU diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.H b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.H index 918de61f590..b4e64b84d69 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.H @@ -16,15 +16,15 @@ class MLEBABecLap { public: - MLEBABecLap () {} + MLEBABecLap () = default; MLEBABecLap (const Vector& a_geom, const Vector& a_grids, const Vector& a_dmap, const LPInfo& a_info, const Vector& a_factory, - const int a_ncomp = 1); + int a_ncomp = 1); - virtual ~MLEBABecLap (); + ~MLEBABecLap () override; MLEBABecLap (const MLEBABecLap&) = delete; MLEBABecLap (MLEBABecLap&&) = delete; @@ -35,7 +35,8 @@ public: const Vector& a_grids, const Vector& a_dmap, const LPInfo& a_info, - const Vector& a_factory); + const Vector& a_factory, + int a_ncomp = 1); void setPhiOnCentroid (); @@ -61,56 +62,56 @@ public: void setEBHomogDirichlet (int amrlev, Real beta); void setEBHomogDirichlet (int amrlev, Vector const& beta); - virtual int getNComp () const override { return m_ncomp; } + int getNComp () const override { return m_ncomp; } - virtual bool needsUpdate () const override { + bool needsUpdate () const override { return (m_needs_update || MLCellABecLap::needsUpdate()); } - virtual void update () override; + void update () override; - virtual std::unique_ptr > makeFactory (int amrlev, int mglev) const final override; + std::unique_ptr > makeFactory (int amrlev, int mglev) const final; - virtual bool isCrossStencil () const override { return false; } + bool isCrossStencil () const override { return false; } - virtual void applyBC (int amrlev, int mglev, MultiFab& in, BCMode bc_mode, StateMode s_mode, - const MLMGBndry* bndry=nullptr, bool skip_fillboundary=false) const final override; - virtual void apply (int amrlev, int mglev, MultiFab& out, MultiFab& in, BCMode bc_mode, + void applyBC (int amrlev, int mglev, MultiFab& in, BCMode bc_mode, StateMode s_mode, + const MLMGBndry* bndry=nullptr, bool skip_fillboundary=false) const final; + void apply (int amrlev, int mglev, MultiFab& out, MultiFab& in, BCMode bc_mode, StateMode s_mode, const MLMGBndry* bndry=nullptr) const override; - virtual void compGrad (int amrlev, const Array& grad, - MultiFab& sol, Location loc) const final 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, MultiFab& out, const MultiFab& in) const final override; - virtual void Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs, int redblack) const final override; - virtual void FFlux (int amrlev, const MFIter& mfi, + void compGrad (int amrlev, const Array& grad, + MultiFab& sol, Location loc) const final; + + void prepareForSolve () override; + bool isSingular (int amrlev) const override { return m_is_singular[amrlev]; } + bool isBottomSingular () const override { return m_is_singular[0]; } + void Fapply (int amrlev, int mglev, MultiFab& out, const MultiFab& in) const final; + void Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs, int redblack) const final; + void FFlux (int amrlev, const MFIter& mfi, const Array& flux, const FArrayBox& sol, Location loc, - const int face_only=0) const final override; + int face_only=0) const final; - virtual void normalize (int amrlev, int mglev, MultiFab& mf) const final override; + void normalize (int amrlev, int mglev, MultiFab& mf) const final; - virtual Real getAScalar () const final override { return m_a_scalar; } - virtual Real getBScalar () const final override { return m_b_scalar; } - virtual MultiFab const* getACoeffs (int amrlev, int mglev) const final override + Real getAScalar () const final { return m_a_scalar; } + Real getBScalar () const final { return m_b_scalar; } + MultiFab const* getACoeffs (int amrlev, int mglev) const final { return &(m_a_coeffs[amrlev][mglev]); } - virtual Array getBCoeffs (int amrlev, int mglev) const final override + 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 { + std::unique_ptr makeNLinOp (int /*grid_size*/) const final { amrex::Abort("MLABecLaplacian::makeNLinOp: Not implemented"); return std::unique_ptr{}; } - virtual void restriction (int, int, MultiFab& crse, MultiFab& fine) const final override; + void restriction (int, int, MultiFab& crse, MultiFab& fine) const final; - virtual void interpolation (int amrlev, int fmglev, MultiFab& fine, const MultiFab& crse) const final override; + void interpolation (int amrlev, int fmglev, MultiFab& fine, const MultiFab& crse) const final; - virtual void averageDownSolutionRHS (int camrlev, MultiFab& crse_sol, MultiFab& crse_rhs, - const MultiFab& fine_sol, const MultiFab& fine_rhs) final override; + void averageDownSolutionRHS (int camrlev, MultiFab& crse_sol, MultiFab& crse_rhs, + const MultiFab& fine_sol, const MultiFab& fine_rhs) final; - virtual void getEBFluxes (const Vector& a_flux, + void getEBFluxes (const Vector& a_flux, const Vector& a_sol) const override; #if defined(AMREX_USE_HYPRE) && (AMREX_SPACEDIM > 1) diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.cpp b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.cpp index dcb06ab9563..e7c09e4a7a2 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.cpp @@ -26,9 +26,8 @@ MLEBABecLap::MLEBABecLap (const Vector& a_geom, const LPInfo& a_info, const Vector& a_factory, const int a_ncomp) - : m_ncomp(a_ncomp) { - define(a_geom, a_grids, a_dmap, a_info, a_factory); + define(a_geom, a_grids, a_dmap, a_info, a_factory, a_ncomp); } std::unique_ptr > @@ -46,19 +45,20 @@ MLEBABecLap::define (const Vector& a_geom, const Vector& a_grids, const Vector& a_dmap, const LPInfo& a_info, - const Vector& a_factory) + const Vector& a_factory, + int a_ncomp) { BL_PROFILE("MLEBABecLap::define()"); + this->m_ncomp = a_ncomp; + Vector const*> _factory; - for (auto x : a_factory) { + for (const auto *x : a_factory) { _factory.push_back(static_cast const*>(x)); } MLCellABecLap::define(a_geom, a_grids, a_dmap, a_info, _factory); - const int ncomp = getNComp(); - m_a_coeffs.resize(m_num_amr_levels); m_b_coeffs.resize(m_num_amr_levels); m_cc_mask.resize(m_num_amr_levels); @@ -82,7 +82,7 @@ MLEBABecLap::define (const Vector& a_geom, const int ng = 1; m_b_coeffs[amrlev][mglev][idim].define(ba, m_dmap[amrlev][mglev], - ncomp, ng, MFInfo(), *m_factory[amrlev][mglev]); + m_ncomp, ng, MFInfo(), *m_factory[amrlev][mglev]); m_b_coeffs[amrlev][mglev][idim].setVal(0.0); } @@ -97,8 +97,7 @@ MLEBABecLap::define (const Vector& a_geom, m_phi_loc = Location::CellCenter; } -MLEBABecLap::~MLEBABecLap () -{} +MLEBABecLap::~MLEBABecLap () = default; void MLEBABecLap::setPhiOnCentroid () @@ -208,7 +207,7 @@ MLEBABecLap::setEBDirichlet (int amrlev, const MultiFab& phi, const MultiFab& be } } - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; MFItInfo mfi_info; @@ -284,7 +283,7 @@ MLEBABecLap::setEBDirichlet (int amrlev, const MultiFab& phi, Real beta) } } - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; MFItInfo mfi_info; @@ -346,7 +345,7 @@ MLEBABecLap::setEBDirichlet (int amrlev, const MultiFab& phi, Vector const } } - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; Gpu::DeviceVector dv_beta(hv_beta.size()); @@ -414,7 +413,7 @@ MLEBABecLap::setEBHomogDirichlet (int amrlev, const MultiFab& beta) } } - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; MFItInfo mfi_info; @@ -488,7 +487,7 @@ MLEBABecLap::setEBHomogDirichlet (int amrlev, Real beta) } } - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; MFItInfo mfi_info; @@ -550,7 +549,7 @@ MLEBABecLap::setEBHomogDirichlet (int amrlev, Vector const& hv_beta) } } - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; Gpu::DeviceVector dv_beta(hv_beta.size()); @@ -624,7 +623,7 @@ MLEBABecLap::averageDownCoeffsSameAmrLevel (int amrlev, Vector& a, Vector >& b, const Vector& b_eb) { - int nmglevs = a.size(); + auto nmglevs = static_cast(a.size()); for (int mglev = 1; mglev < nmglevs; ++mglev) { IntVect ratio = (amrlev > 0) ? IntVect(mg_coarsen_ratio) : mg_coarsen_ratio_vec[mglev-1]; @@ -691,8 +690,8 @@ MLEBABecLap::prepareForSolve () m_is_singular.clear(); m_is_singular.resize(m_num_amr_levels, false); - auto itlo = std::find(m_lobc[0].begin(), m_lobc[0].end(), BCType::Dirichlet); - auto ithi = std::find(m_hibc[0].begin(), m_hibc[0].end(), BCType::Dirichlet); + auto itlo = std::find(m_lobc[0].begin(), m_lobc[0].end(), BCType::Dirichlet); // NOLINT + auto ithi = std::find(m_hibc[0].begin(), m_hibc[0].end(), BCType::Dirichlet); // NOLINT if (itlo == m_lobc[0].end() && ithi == m_hibc[0].end() && !isEBDirichlet()) { // No Dirichlet for (int alev = 0; alev < m_num_amr_levels; ++alev) @@ -733,7 +732,7 @@ MLEBABecLap::compGrad (int amrlev, const Array& grad, const Real dzi = m_geom[amrlev][mglev].InvCellSize(2);); const iMultiFab& ccmask = m_cc_mask[amrlev][mglev]; - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; auto area = (factory) ? factory->getAreaFrac() : Array{AMREX_D_DECL(nullptr, nullptr, nullptr)}; @@ -857,7 +856,7 @@ MLEBABecLap::normalize (int amrlev, int mglev, MultiFab& mf) const const auto dxarray = m_geom[amrlev][mglev].CellSizeArray(); const Real dh = m_b_scalar*AMREX_D_TERM(dxinvarray[0], *dxinvarray[1], *dxinvarray[2]); #endif - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const MultiFab* vfrac = (factory) ? &(factory->getVolFrac()) : nullptr; auto area = (factory) ? factory->getAreaFrac() @@ -946,7 +945,7 @@ MLEBABecLap::interpolation (int amrlev, int fmglev, MultiFab& fine, const MultiF { BL_PROFILE("MLEBABecLap::interpolation()"); - auto factory = dynamic_cast(m_factory[amrlev][fmglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][fmglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const int ncomp = getNComp(); @@ -1029,7 +1028,7 @@ MLEBABecLap::applyBC (int amrlev, int mglev, MultiFab& in, BCMode bc_mode, State const auto& ccmask = m_cc_mask[amrlev][mglev]; - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; auto area = (factory) ? factory->getAreaFrac() : Array{AMREX_D_DECL(nullptr,nullptr,nullptr)}; @@ -1180,8 +1179,8 @@ MLEBABecLap::update () m_is_singular.clear(); m_is_singular.resize(m_num_amr_levels, false); - auto itlo = std::find(m_lobc[0].begin(), m_lobc[0].end(), BCType::Dirichlet); - auto ithi = std::find(m_hibc[0].begin(), m_hibc[0].end(), BCType::Dirichlet); + auto itlo = std::find(m_lobc[0].begin(), m_lobc[0].end(), BCType::Dirichlet); // NOLINT + auto ithi = std::find(m_hibc[0].begin(), m_hibc[0].end(), BCType::Dirichlet); // NOLINT if (itlo == m_lobc[0].end() && ithi == m_hibc[0].end() && !isEBDirichlet()) { // No Dirichlet for (int alev = 0; alev < m_num_amr_levels; ++alev) @@ -1223,7 +1222,7 @@ MLEBABecLap::getEBFluxes (const Vector& a_flux, const Vector(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const MultiFab* vfrac = (factory) ? &(factory->getVolFrac()) : nullptr; auto area = (factory) ? factory->getAreaFrac() diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_F.cpp b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_F.cpp index 90edc4a6974..68f94cc0915 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_F.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBABecLap_F.cpp @@ -21,7 +21,7 @@ MLEBABecLap::Fapply (int amrlev, int mglev, MultiFab& out, const MultiFab& in) c const auto dxinvarr = m_geom[amrlev][mglev].InvCellSizeArray(); - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const MultiFab* vfrac = (factory) ? &(factory->getVolFrac()) : nullptr; auto area = (factory) ? factory->getAreaFrac() @@ -30,7 +30,7 @@ MLEBABecLap::Fapply (int amrlev, int mglev, MultiFab& out, const MultiFab& in) c : Array{AMREX_D_DECL(nullptr,nullptr,nullptr)}; const MultiCutFab* barea = (factory) ? &(factory->getBndryArea()) : nullptr; const MultiCutFab* bcent = (factory) ? &(factory->getBndryCent()) : nullptr; - const auto ccent = (factory) ? &(factory->getCentroid()) : nullptr; + const auto *const ccent = (factory) ? &(factory->getCentroid()) : nullptr; const bool is_eb_dirichlet = isEBDirichlet(); const bool is_eb_inhomog = m_is_eb_inhomog; @@ -201,7 +201,7 @@ MLEBABecLap::Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiFab& rhs, #endif const Real alpha = m_a_scalar; - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const MultiFab* vfrac = (factory) ? &(factory->getVolFrac()) : nullptr; auto area = (factory) ? factory->getAreaFrac() @@ -328,7 +328,7 @@ MLEBABecLap::FFlux (int amrlev, const MFIter& mfi, const Array(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const Real* dxinv = m_geom[amrlev][mglev].InvCellSize(); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp b/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp index 04f926f0209..860950f990e 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp @@ -85,7 +85,7 @@ MLEBNodeFDLaplacian::define (const Vector& a_geom, } Vector const*> _factory; - for (auto x : a_factory) { + for (const auto *x : a_factory) { _factory.push_back(static_cast const*>(x)); } @@ -254,7 +254,7 @@ MLEBNodeFDLaplacian::prepareForSolve () // compGrad relies on the negative value to detect EB. for (int amrlev = 0; amrlev < m_num_amr_levels; ++amrlev) { for (int mglev = 0; mglev < m_num_mg_levels[amrlev]; ++mglev) { - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); auto const& levset_mf = factory->getLevelSet(); auto const& levset_ar = levset_mf.const_arrays(); auto& dmask_mf = *m_dirichlet_mask[amrlev][mglev]; @@ -319,7 +319,7 @@ void MLEBNodeFDLaplacian::scaleRHS (int amrlev, MultiFab& rhs) const { auto const& dmask = *m_dirichlet_mask[amrlev][0]; - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); auto const& edgecent = factory->getEdgeCent(); #ifdef AMREX_USE_OMP @@ -366,7 +366,7 @@ MLEBNodeFDLaplacian::Fapply (int amrlev, int mglev, MultiFab& out, const MultiFa #ifdef AMREX_USE_EB const auto phieb = (m_in_solution_mode) ? m_s_phi_eb : Real(0.0); - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); auto const& edgecent = factory->getEdgeCent(); #endif @@ -468,7 +468,7 @@ MLEBNodeFDLaplacian::Fsmooth (int amrlev, int mglev, MultiFab& sol, const MultiF } #ifdef AMREX_USE_EB - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); auto const& edgecent = factory->getEdgeCent(); #endif @@ -558,7 +558,7 @@ MLEBNodeFDLaplacian::compGrad (int amrlev, const Array #ifdef AMREX_USE_EB auto const& dmask = *m_dirichlet_mask[amrlev][mglev]; const auto phieb = m_s_phi_eb; - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); AMREX_ASSERT(factory); auto const& edgecent = factory->getEdgeCent(); #endif @@ -658,7 +658,7 @@ MLEBNodeFDLaplacian::postSolve (Vector& sol) const #ifdef AMREX_USE_EB for (int amrlev = 0; amrlev < m_num_amr_levels; ++amrlev) { const auto phieb = m_s_phi_eb; - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); auto const& levset_mf = factory->getLevelSet(); auto const& levset_ar = levset_mf.const_arrays(); MultiFab& mf = sol[amrlev]; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.H b/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.H index 1ed29a84801..86173801555 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.H @@ -60,7 +60,7 @@ public: void setEBShearViscosityWithInflow (int amrlev, MultiFab const& eta, MultiFab const& eb_vel); void setEBBulkViscosity (int amrlev, MultiFab const& kappa); - void setEBBulkViscosity (int amrlev, Real eta); + void setEBBulkViscosity (int amrlev, Real kappa); virtual int getNComp () const final override { return AMREX_SPACEDIM; } @@ -83,7 +83,7 @@ public: virtual void compFlux (int amrlev, const Array& fluxes, MultiFab& sol, Location loc) const override; - void compVelGrad (int amrlev, const Array& fluxes, + void compVelGrad (int amrlev, const Array& grads, MultiFab& sol, Location loc) const; protected: diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.cpp b/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.cpp index 87c9892dc57..0538421683b 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp.cpp @@ -26,8 +26,7 @@ MLEBTensorOp::MLEBTensorOp (const Vector& a_geom, define(a_geom, a_grids, a_dmap, a_info, a_factory); } -MLEBTensorOp::~MLEBTensorOp () -{} +MLEBTensorOp::~MLEBTensorOp () = default; void MLEBTensorOp::define (const Vector& a_geom, @@ -38,7 +37,7 @@ MLEBTensorOp::define (const Vector& a_geom, { BL_PROFILE("MLEBTensorOp::define()"); - MLEBABecLap::define(a_geom, a_grids, a_dmap, a_info, a_factory); + MLEBABecLap::define(a_geom, a_grids, a_dmap, a_info, a_factory, AMREX_SPACEDIM); m_kappa.clear(); m_kappa.resize(NAMRLevels()); @@ -208,7 +207,7 @@ MLEBTensorOp::apply (int amrlev, int mglev, MultiFab& out, MultiFab& in, BCMode applyBCTensor(amrlev, mglev, in, bc_mode, s_mode, bndry); - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const MultiFab* vfrac = (factory) ? &(factory->getVolFrac()) : nullptr; auto area = (factory) ? factory->getAreaFrac() @@ -292,7 +291,7 @@ void MLEBTensorOp::compCrossTerms(int amrlev, int mglev, MultiFab const& mf, const MLMGBndry* bndry) const { - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; auto area = (factory) ? factory->getAreaFrac() : Array{AMREX_D_DECL(nullptr,nullptr,nullptr)}; @@ -516,7 +515,7 @@ MLEBTensorOp::compFlux (int amrlev, const Array& fluxe applyBCTensor(amrlev, mglev, sol, BCMode::Inhomogeneous, StateMode::Solution, m_bndry_sol[amrlev].get()); - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; auto area = (factory) ? factory->getAreaFrac() : Array{AMREX_D_DECL(nullptr,nullptr,nullptr)}; @@ -636,7 +635,7 @@ MLEBTensorOp::compVelGrad (int amrlev, const auto dlo = amrex::lbound(domain); const auto dhi = amrex::ubound(domain); - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; auto area = (factory) ? factory->getAreaFrac() : Array{AMREX_D_DECL(nullptr,nullptr,nullptr)}; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp_bc.cpp b/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp_bc.cpp index cea62d58217..77050040091 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp_bc.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLEBTensorOp_bc.cpp @@ -20,7 +20,7 @@ MLEBTensorOp::applyBCTensor (int amrlev, int mglev, MultiFab& vel, const auto dlo = amrex::lbound(domain); const auto dhi = amrex::ubound(domain); - auto factory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][mglev].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; MFItInfo mfi_info; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLLinOp.H b/Src/LinearSolvers/MLMG/AMReX_MLLinOp.H index dae2e8cbae0..58ab519c556 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLLinOp.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLLinOp.H @@ -716,7 +716,7 @@ MLLinOpT::define (const Vector& a_geom, #ifdef AMREX_USE_EB if (!a_factory.empty() && eb_limit_coarsening) { - auto f = dynamic_cast(a_factory[0]); + const auto *f = dynamic_cast(a_factory[0]); if (f) { info.max_coarsening_level = std::min(info.max_coarsening_level, f->maxCoarseningLevel()); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLMG.H b/Src/LinearSolvers/MLMG/AMReX_MLMG.H index 81edd7fde4f..3d60b2603fd 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLMG.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLMG.H @@ -980,7 +980,7 @@ MLMGT::prepareForSolve (Vector const& a_sol, Vector const& linop.scaleRHS(alev, rhs[alev]); #ifdef AMREX_USE_EB - auto factory = dynamic_cast(linop.Factory(alev)); + const auto *factory = dynamic_cast(linop.Factory(alev)); if (factory && !factory->isAllRegular()) { if constexpr (std::is_same()) { EB_set_covered(rhs[alev], 0, ncomp, 0, RT(0.0)); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.cpp b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.cpp index 764a4692798..e33bdfdb21d 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian.cpp @@ -88,15 +88,10 @@ MLNodeLaplacian::define (const Vector& a_geom, m_eb_vel_dot_n.resize(m_num_amr_levels); for (int amrlev = 0; amrlev < m_num_amr_levels; ++amrlev) { -#ifdef AMREX_USE_EB m_integral[amrlev] = std::make_unique(m_grids[amrlev][0], m_dmap[amrlev][0], ncomp_i, 1, MFInfo(), *m_factory[amrlev][0]); -#else - m_integral[amrlev] = std::make_unique(m_grids[amrlev][0], - m_dmap[amrlev][0], ncomp_i, 1)); -#endif } #endif @@ -115,7 +110,7 @@ MLNodeLaplacian::define (const Vector& a_geom, Real a_const_sigma) { Vector const*> _factory; - for (auto x : a_factory) { + for (const auto *x : a_factory) { _factory.push_back(static_cast const*>(x)); } define(a_geom, a_grids, a_dmap, a_info, _factory, a_const_sigma); @@ -177,7 +172,7 @@ MLNodeLaplacian::getSolvabilityOffset (int amrlev, int mglev, MultiFab const& rh if (m_coarsening_strategy == CoarseningStrategy::RAP) { #ifdef AMREX_USE_EB - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); if (mglev == 0 && factory && !factory->isAllRegular()) { const MultiFab& vfrac = factory->getVolFrac(); const auto& vfrac_ma = vfrac.const_arrays(); @@ -291,7 +286,7 @@ MLNodeLaplacian::fixSolvabilityByOffset (int amrlev, int mglev, MultiFab& rhs, if (m_coarsening_strategy == CoarseningStrategy::RAP) { #ifdef AMREX_USE_EB - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); if (mglev == 0 && factory && !factory->isAllRegular()) { const MultiFab& vfrac = factory->getVolFrac(); const auto& vfrac_ma = vfrac.const_arrays(); @@ -1033,7 +1028,7 @@ MLNodeLaplacian::setEBInflowVelocity (int amrlev, const MultiFab& eb_vel) m_eb_vel_dot_n[amrlev]->setVal(0.0); - auto ebfactory = dynamic_cast(m_factory[amrlev][mglev].get()); + const auto *ebfactory = dynamic_cast(m_factory[amrlev][mglev].get()); MFItInfo mfi_info; if (Gpu::notInLaunchRegion()) mfi_info.EnableTiling().SetDynamic(true); diff --git a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_misc.cpp b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_misc.cpp index 339ca98e072..227e7fec0c4 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_misc.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_misc.cpp @@ -638,7 +638,7 @@ MLNodeLaplacian::updateVelocity (const Vector& vel, const Vector(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const MultiFab* vfrac = (factory) ? &(factory->getVolFrac()) : nullptr; const MultiFab* intg = m_integral[amrlev].get(); @@ -723,7 +723,7 @@ MLNodeLaplacian::compGrad (int amrlev, MultiFab& grad, MultiFab& sol) const const auto dxinv = m_geom[amrlev][0].InvCellSizeArray(); #ifdef AMREX_USE_EB - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const MultiFab* vfrac = (factory) ? &(factory->getVolFrac()) : nullptr; const MultiFab* intg = m_integral[amrlev].get(); @@ -800,7 +800,7 @@ MLNodeLaplacian::getFluxes (const Vector & a_flux, const Vector(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const MultiFab* vfrac = (factory) ? &(factory->getVolFrac()) : nullptr; const MultiFab* intg = m_integral[amrlev].get(); @@ -988,7 +988,7 @@ MLNodeLaplacian::compRHS (const Vector& rhs, const Vector& const iMultiFab& dmsk = *m_dirichlet_mask[ilev][0]; #ifdef AMREX_USE_EB - auto factory = dynamic_cast(m_factory[ilev][0].get()); + const auto *factory = dynamic_cast(m_factory[ilev][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const MultiFab* vfrac = (factory) ? &(factory->getVolFrac()) : nullptr; const MultiCutFab* barea = (factory) ? &(factory->getBndryArea()) : nullptr; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_sten.cpp b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_sten.cpp index e3caf4ecced..8a71c6cf760 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_sten.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_sten.cpp @@ -57,7 +57,7 @@ MLNodeLaplacian::buildStencil () const auto dxinvarr = geom.InvCellSizeArray(); #ifdef AMREX_USE_EB - auto factory = dynamic_cast(m_factory[amrlev][0].get()); + const auto *factory = dynamic_cast(m_factory[amrlev][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const MultiFab* intg = m_integral[amrlev].get(); const MultiFab* vfrac = (factory) ? &(factory->getVolFrac()) : nullptr; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_sync.cpp b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_sync.cpp index 2c6aa3f0a90..d562100d5a3 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_sync.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_sync.cpp @@ -80,7 +80,7 @@ MLNodeLaplacian::compSyncResidualCoarse (MultiFab& sync_resid, const MultiFab& a const iMultiFab& dmsk = *m_dirichlet_mask[0][0]; #ifdef AMREX_USE_EB - auto factory = dynamic_cast(m_factory[0][0].get()); + const auto *factory = dynamic_cast(m_factory[0][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const MultiFab* intg = m_integral[0].get(); const MultiFab* vfrac = (factory) ? &(factory->getVolFrac()) : nullptr; @@ -344,7 +344,7 @@ MLNodeLaplacian::compSyncResidualFine (MultiFab& sync_resid, const MultiFab& phi const auto hibc = HiBC(); #ifdef AMREX_USE_EB - auto factory = dynamic_cast(m_factory[0][0].get()); + const auto *factory = dynamic_cast(m_factory[0][0].get()); const FabArray* flags = (factory) ? &(factory->getMultiEBCellFlagFab()) : nullptr; const MultiFab* intg = m_integral[0].get(); const MultiFab* vfrac = (factory) ? &(factory->getVolFrac()) : nullptr; diff --git a/Src/LinearSolvers/MLMG/AMReX_MLTensorOp.cpp b/Src/LinearSolvers/MLMG/AMReX_MLTensorOp.cpp index 5db32158b4f..215220ca418 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLTensorOp.cpp +++ b/Src/LinearSolvers/MLMG/AMReX_MLTensorOp.cpp @@ -44,7 +44,8 @@ MLTensorOp::define (const Vector& a_geom, { BL_PROFILE("MLTensorOp::define()"); - MLABecLaplacian::define(a_geom, a_grids, a_dmap, a_info, a_factory); + MLABecLaplacian::define(a_geom, a_grids, a_dmap, a_info, a_factory, + AMREX_SPACEDIM); m_kappa.clear(); m_kappa.resize(NAMRLevels()); @@ -72,7 +73,8 @@ MLTensorOp::define (const Vector& a_geom, { BL_PROFILE("MLTensorOp::define(oveset)"); - MLABecLaplacian::define(a_geom, a_grids, a_dmap, a_overset_mask, a_info, a_factory); + MLABecLaplacian::define(a_geom, a_grids, a_dmap, a_overset_mask, a_info, + a_factory, AMREX_SPACEDIM); m_kappa.clear(); m_kappa.resize(NAMRLevels());