From 290f482822ab34dcce05c4ea304dd8a0af930045 Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sat, 24 Sep 2022 17:23:17 -0700 Subject: [PATCH 1/5] make tagging routines EB_aware --- Src/AmrCore/AMReX_ErrorList.cpp | 122 +++++++++++++++++++++++++++----- 1 file changed, 104 insertions(+), 18 deletions(-) diff --git a/Src/AmrCore/AMReX_ErrorList.cpp b/Src/AmrCore/AMReX_ErrorList.cpp index 7f37324123a..dfc4b2c6cbb 100644 --- a/Src/AmrCore/AMReX_ErrorList.cpp +++ b/Src/AmrCore/AMReX_ErrorList.cpp @@ -290,6 +290,12 @@ AMRErrorTag::operator() (TagBoxArray& tba, else { auto const& datma = mf->const_arrays(); + +#ifdef AMREX_USE_EB + auto const& ebfact = + dynamic_cast(mf->Factory()); + auto const& flags = ebfact.getMultiEBCellFlagFab().arrays(); +#endif auto threshold = m_value[level]; auto const volume_weighting = m_info.m_volume_weighting; auto geomdata = geom.data(); @@ -302,22 +308,52 @@ AMRErrorTag::operator() (TagBoxArray& tba, { ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept { - auto const& dat = datma[bi]; - auto ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); + auto const& dat = datma[bi]; + auto const& tag = tagma[bi]; + + Real ax = 0.; Real ay = 0.; Real az = 0.; +#ifdef AMREX_USE_EB + auto const& flag = flags[bi]; + if (flag(i,j,k).isConnected(1,0,0)) { + ax = amrex::max(ax,amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k))); + } + if (flag(i,j,k).isConnected(-1,0,0)) { + ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); + } + if (flag(i,j,k).isConnected(0,1,0)) { + ay = amrex::max(ay,amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k))); + } + if (flag(i,j,k).isConnected(0,-1,0)) { + ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); + } +#if AMREX_SPACEDIM > 2 + if (flag(i,j,k).isConnected(0,0,1)) { + az = amrex::max(az,amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k))); + } + if (flag(i,j,k).isConnected(0,0,-1)) { + az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); + } +#endif + if (amrex::max(AMREX_D_DECL(ax,ay,az)) >= threshold) { + tag(i,j,k) = tag_update; + } +#else // no EB + ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); #if AMREX_SPACEDIM == 1 if (ax >= threshold) { tagma[bi](i,j,k) = tag_update;} #else - auto ay = amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k)); + ay = amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k)); ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); #if AMREX_SPACEDIM > 2 - auto az = amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k)); + az = amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k)); az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); -#endif +#endif // DIM > 2 if (amrex::max(AMREX_D_DECL(ax,ay,az)) >= threshold) { - tagma[bi](i,j,k) = tag_update; + tag(i,j,k) = tag_update; } -#endif +#endif // DIM > 1 +#endif // not EB }); } else if (m_test == RELGRAD) @@ -325,22 +361,51 @@ AMRErrorTag::operator() (TagBoxArray& tba, ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept { auto const& dat = datma[bi]; - auto ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); + Real ax = 0.; Real ay = 0.; Real az = 0.; +#ifdef AMREX_USE_EB + auto const& flag = flags[bi]; + if (flag(i,j,k).isConnected(1,0,0)) { + ax = amrex::max(ax,amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k))); + } + if (flag(i,j,k).isConnected(-1,0,0)) { + ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); + } + if (flag(i,j,k).isConnected(0,1,0)) { + ay = amrex::max(ay,amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k))); + } + if (flag(i,j,k).isConnected(0,-1,0)) { + ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); + } +#if AMREX_SPACEDIM > 2 + if (flag(i,j,k).isConnected(0,0,1)) { + az = amrex::max(az,amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k))); + } + if (flag(i,j,k).isConnected(0,0,-1)) { + az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); + } + if (amrex::max(AMREX_D_DECL(ax,ay,az)) + >= threshold * amrex::Math::abs(dat(i,j,k))) { + tagma[bi](i,j,k) = tag_update; + } +#endif // DIM > 2 +#else // no EB + ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); #if AMREX_SPACEDIM == 1 if (ax >= threshold * amrex::Math::abs(dat(i,j,k))) { tagma[bi](i,j,k) = tag_update;} #else - auto ay = amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k)); + ay = amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k)); ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); #if AMREX_SPACEDIM > 2 - auto az = amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k)); + az = amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k)); az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); -#endif +#endif // DIM > 2 if (amrex::max(AMREX_D_DECL(ax,ay,az)) >= threshold * amrex::Math::abs(dat(i,j,k))) { tagma[bi](i,j,k) = tag_update; } -#endif +#endif // DIM > 1 +#endif // not EB }); } else if (m_test == LESS) @@ -348,9 +413,16 @@ AMRErrorTag::operator() (TagBoxArray& tba, ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept { Real vol = volume_weighting ? Geometry::Volume(IntVect{AMREX_D_DECL(i,j,k)}, geomdata) : 1.0_rt; - if (datma[bi](i,j,k) * vol <= threshold) { - tagma[bi](i,j,k) = tag_update; +#ifdef AMREX_USE_EB + auto const& flag = flags[bi]; + if (!flag(i,j,k).isCovered()) { +#endif + if (datma[bi](i,j,k) * vol <= threshold) { + tagma[bi](i,j,k) = tag_update; + } +#ifdef AMREX_USE_EB } +#endif }); } else if (m_test == GREATER) @@ -358,9 +430,16 @@ AMRErrorTag::operator() (TagBoxArray& tba, ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept { Real vol = volume_weighting ? Geometry::Volume(IntVect{AMREX_D_DECL(i,j,k)}, geomdata) : 1.0_rt; - if (datma[bi](i,j,k) * vol >= threshold) { - tagma[bi](i,j,k) = tag_update; +#ifdef AMREX_USE_EB + auto const& flag = flags[bi]; + if (!flag(i,j,k).isCovered()) { +#endif + if (datma[bi](i,j,k) * vol >= threshold) { + tagma[bi](i,j,k) = tag_update; + } +#ifdef AMREX_USE_EB } +#endif }); } else if (m_test == VORT) @@ -368,9 +447,16 @@ AMRErrorTag::operator() (TagBoxArray& tba, const Real fac = threshold * Real(std::pow(2,level)); ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept { - if (datma[bi](i,j,k) >= fac) { - tagma[bi](i,j,k) = tag_update; +#ifdef AMREX_USE_EB + auto const& flag = flags[bi]; + if (!flag(i,j,k).isCovered()) { +#endif + if (datma[bi](i,j,k) >= fac) { + tagma[bi](i,j,k) = tag_update; + } +#ifdef AMREX_USE_EB } +#endif }); } else From 1b55cafe465486d2dde0fa8f87a9007b87125a7c Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sat, 24 Sep 2022 17:56:45 -0700 Subject: [PATCH 2/5] make this work if AMREX_USE_EB defined but the MultiFab not build with an EB Factory --- Src/AmrCore/AMReX_ErrorList.cpp | 284 +++++++++++++++++++------------- 1 file changed, 171 insertions(+), 113 deletions(-) diff --git a/Src/AmrCore/AMReX_ErrorList.cpp b/Src/AmrCore/AMReX_ErrorList.cpp index dfc4b2c6cbb..d40461ae66f 100644 --- a/Src/AmrCore/AMReX_ErrorList.cpp +++ b/Src/AmrCore/AMReX_ErrorList.cpp @@ -290,12 +290,6 @@ AMRErrorTag::operator() (TagBoxArray& tba, else { auto const& datma = mf->const_arrays(); - -#ifdef AMREX_USE_EB - auto const& ebfact = - dynamic_cast(mf->Factory()); - auto const& flags = ebfact.getMultiEBCellFlagFab().arrays(); -#endif auto threshold = m_value[level]; auto const volume_weighting = m_info.m_volume_weighting; auto geomdata = geom.data(); @@ -306,158 +300,222 @@ AMRErrorTag::operator() (TagBoxArray& tba, if (m_test == GRAD) { - ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept - { - auto const& dat = datma[bi]; - auto const& tag = tagma[bi]; - - Real ax = 0.; Real ay = 0.; Real az = 0.; #ifdef AMREX_USE_EB - auto const& flag = flags[bi]; - if (flag(i,j,k).isConnected(1,0,0)) { - ax = amrex::max(ax,amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k))); - } - if (flag(i,j,k).isConnected(-1,0,0)) { - ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); - } - if (flag(i,j,k).isConnected(0,1,0)) { - ay = amrex::max(ay,amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k))); - } - if (flag(i,j,k).isConnected(0,-1,0)) { - ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); - } + if (mf->hasEBFabFactory()) { + auto const& ebfact = + dynamic_cast(mf->Factory()); + auto const& flags = ebfact.getMultiEBCellFlagFab().arrays(); + ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept + { + auto const& dat = datma[bi]; + auto const& tag = tagma[bi]; + auto const& flag = flags[bi]; + + Real ax = 0.; Real ay = 0.; + + if (flag(i,j,k).isConnected(1,0,0)) { + ax = amrex::max(ax,amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k))); + } + if (flag(i,j,k).isConnected(-1,0,0)) { + ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); + } + if (flag(i,j,k).isConnected(0,1,0)) { + ay = amrex::max(ay,amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k))); + } + if (flag(i,j,k).isConnected(0,-1,0)) { + ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); + } #if AMREX_SPACEDIM > 2 - if (flag(i,j,k).isConnected(0,0,1)) { - az = amrex::max(az,amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k))); - } - if (flag(i,j,k).isConnected(0,0,-1)) { - az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); - } + Real az = 0.; + if (flag(i,j,k).isConnected(0,0,1)) { + az = amrex::max(az,amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k))); + } + if (flag(i,j,k).isConnected(0,0,-1)) { + az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); + } #endif - if (amrex::max(AMREX_D_DECL(ax,ay,az)) >= threshold) { - tag(i,j,k) = tag_update; - } -#else // no EB - ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); - ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); + if (amrex::max(AMREX_D_DECL(ax,ay,az)) >= threshold) { + tag(i,j,k) = tag_update; + } + }); + } else +#endif + { + ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept + { + auto const& dat = datma[bi]; + auto const& tag = tagma[bi]; + + Real ax = 0.; Real ay = 0.; Real az = 0.; + ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); + ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); #if AMREX_SPACEDIM == 1 - if (ax >= threshold) { tagma[bi](i,j,k) = tag_update;} + if (ax >= threshold) { tagma[bi](i,j,k) = tag_update;} #else - ay = amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k)); - ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); + ay = amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k)); + ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); #if AMREX_SPACEDIM > 2 - az = amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k)); - az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); + az = amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k)); + az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); #endif // DIM > 2 - if (amrex::max(AMREX_D_DECL(ax,ay,az)) >= threshold) { - tag(i,j,k) = tag_update; - } + if (amrex::max(AMREX_D_DECL(ax,ay,az)) >= threshold) { + tag(i,j,k) = tag_update; + } #endif // DIM > 1 -#endif // not EB - }); + }); + } } else if (m_test == RELGRAD) { - ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept - { - auto const& dat = datma[bi]; - Real ax = 0.; Real ay = 0.; Real az = 0.; #ifdef AMREX_USE_EB - auto const& flag = flags[bi]; - if (flag(i,j,k).isConnected(1,0,0)) { - ax = amrex::max(ax,amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k))); - } - if (flag(i,j,k).isConnected(-1,0,0)) { - ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); - } - if (flag(i,j,k).isConnected(0,1,0)) { - ay = amrex::max(ay,amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k))); - } - if (flag(i,j,k).isConnected(0,-1,0)) { - ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); - } + if (mf->hasEBFabFactory()) { + auto const& ebfact = + dynamic_cast(mf->Factory()); + auto const& flags = ebfact.getMultiEBCellFlagFab().arrays(); + ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept + { + auto const& dat = datma[bi]; + auto const& tag = tagma[bi]; + auto const& flag = flags[bi]; + + Real ax = 0.; Real ay = 0.; + + if (flag(i,j,k).isConnected(1,0,0)) { + ax = amrex::max(ax,amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k))); + } + if (flag(i,j,k).isConnected(-1,0,0)) { + ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); + } + if (flag(i,j,k).isConnected(0,1,0)) { + ay = amrex::max(ay,amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k))); + } + if (flag(i,j,k).isConnected(0,-1,0)) { + ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); + } #if AMREX_SPACEDIM > 2 - if (flag(i,j,k).isConnected(0,0,1)) { - az = amrex::max(az,amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k))); - } - if (flag(i,j,k).isConnected(0,0,-1)) { - az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); - } - if (amrex::max(AMREX_D_DECL(ax,ay,az)) - >= threshold * amrex::Math::abs(dat(i,j,k))) { - tagma[bi](i,j,k) = tag_update; - } + Real az = 0.; + if (flag(i,j,k).isConnected(0,0,1)) { + az = amrex::max(az,amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k))); + } + if (flag(i,j,k).isConnected(0,0,-1)) { + az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); + } + if (amrex::max(AMREX_D_DECL(ax,ay,az)) + >= threshold * amrex::Math::abs(dat(i,j,k))) { + tagma[bi](i,j,k) = tag_update; + } + }); #endif // DIM > 2 -#else // no EB - ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); - ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); + } else +#endif + { + ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept + { + auto const& dat = datma[bi]; + auto const& tag = tagma[bi]; + + Real ax = 0.; Real ay = 0.; Real az = 0.; + ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); + ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); #if AMREX_SPACEDIM == 1 - if (ax >= threshold * amrex::Math::abs(dat(i,j,k))) { tagma[bi](i,j,k) = tag_update;} + if (ax >= threshold * amrex::Math::abs(dat(i,j,k))) { tagma[bi](i,j,k) = tag_update;} #else - ay = amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k)); - ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); + ay = amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k)); + ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); #if AMREX_SPACEDIM > 2 - az = amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k)); - az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); + az = amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k)); + az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); #endif // DIM > 2 - if (amrex::max(AMREX_D_DECL(ax,ay,az)) - >= threshold * amrex::Math::abs(dat(i,j,k))) { - tagma[bi](i,j,k) = tag_update; - } + if (amrex::max(AMREX_D_DECL(ax,ay,az)) + >= threshold * amrex::Math::abs(dat(i,j,k))) { + tagma[bi](i,j,k) = tag_update; + } #endif // DIM > 1 -#endif // not EB - }); + }); + } } else if (m_test == LESS) { - ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept - { - Real vol = volume_weighting ? Geometry::Volume(IntVect{AMREX_D_DECL(i,j,k)}, geomdata) : 1.0_rt; #ifdef AMREX_USE_EB - auto const& flag = flags[bi]; - if (!flag(i,j,k).isCovered()) { -#endif - if (datma[bi](i,j,k) * vol <= threshold) { - tagma[bi](i,j,k) = tag_update; + if (mf->hasEBFabFactory()) { + auto const& ebfact = + dynamic_cast(mf->Factory()); + auto const& flags = ebfact.getMultiEBCellFlagFab().arrays(); + ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept + { + Real vol = volume_weighting ? Geometry::Volume(IntVect{AMREX_D_DECL(i,j,k)}, geomdata) : 1.0_rt; + auto const& flag = flags[bi]; + if (!flag(i,j,k).isCovered()) { + if (datma[bi](i,j,k) * vol <= threshold) { + tagma[bi](i,j,k) = tag_update; + } } -#ifdef AMREX_USE_EB - } + }); + } else #endif + { + ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept { + Real vol = volume_weighting ? Geometry::Volume(IntVect{AMREX_D_DECL(i,j,k)}, geomdata) : 1.0_rt; + if (datma[bi](i,j,k) * vol <= threshold) { + tagma[bi](i,j,k) = tag_update; + } }); + } } else if (m_test == GREATER) { +#ifdef AMREX_USE_EB + if (mf->hasEBFabFactory()) { + auto const& ebfact = + dynamic_cast(mf->Factory()); + auto const& flags = ebfact.getMultiEBCellFlagFab().arrays(); + ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept + { + Real vol = volume_weighting ? Geometry::Volume(IntVect{AMREX_D_DECL(i,j,k)}, geomdata) : 1.0_rt; + auto const& flag = flags[bi]; + if (!flag(i,j,k).isCovered()) { + if (datma[bi](i,j,k) * vol >= threshold) { + tagma[bi](i,j,k) = tag_update; + } + } + }); + } else +#endif ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept { Real vol = volume_weighting ? Geometry::Volume(IntVect{AMREX_D_DECL(i,j,k)}, geomdata) : 1.0_rt; -#ifdef AMREX_USE_EB - auto const& flag = flags[bi]; - if (!flag(i,j,k).isCovered()) { -#endif if (datma[bi](i,j,k) * vol >= threshold) { tagma[bi](i,j,k) = tag_update; } -#ifdef AMREX_USE_EB - } -#endif }); } else if (m_test == VORT) { const Real fac = threshold * Real(std::pow(2,level)); - ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept - { #ifdef AMREX_USE_EB - auto const& flag = flags[bi]; - if (!flag(i,j,k).isCovered()) { + if (mf->hasEBFabFactory()) { + auto const& ebfact = + dynamic_cast(mf->Factory()); + auto const& flags = ebfact.getMultiEBCellFlagFab().arrays(); + ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept + { + auto const& flag = flags[bi]; + if (!flag(i,j,k).isCovered()) { + if (datma[bi](i,j,k) >= fac) { + tagma[bi](i,j,k) = tag_update; + } + } + }); + } else #endif + { + ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept + { if (datma[bi](i,j,k) >= fac) { tagma[bi](i,j,k) = tag_update; } -#ifdef AMREX_USE_EB - } -#endif - }); + }); + } } else { From 9aedeeb51ceaacc6a29648d2f93eced98df257af Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sat, 24 Sep 2022 19:29:53 -0700 Subject: [PATCH 3/5] fix compiler errors --- Src/AmrCore/AMReX_ErrorList.cpp | 10 +++------- Src/Base/AMReX_VisMF.H | 2 -- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Src/AmrCore/AMReX_ErrorList.cpp b/Src/AmrCore/AMReX_ErrorList.cpp index d40461ae66f..ff2db5871e7 100644 --- a/Src/AmrCore/AMReX_ErrorList.cpp +++ b/Src/AmrCore/AMReX_ErrorList.cpp @@ -308,7 +308,6 @@ AMRErrorTag::operator() (TagBoxArray& tba, ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept { auto const& dat = datma[bi]; - auto const& tag = tagma[bi]; auto const& flag = flags[bi]; Real ax = 0.; Real ay = 0.; @@ -335,7 +334,7 @@ AMRErrorTag::operator() (TagBoxArray& tba, } #endif if (amrex::max(AMREX_D_DECL(ax,ay,az)) >= threshold) { - tag(i,j,k) = tag_update; + tagma[bi](i,j,k) = tag_update; } }); } else @@ -344,7 +343,6 @@ AMRErrorTag::operator() (TagBoxArray& tba, ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept { auto const& dat = datma[bi]; - auto const& tag = tagma[bi]; Real ax = 0.; Real ay = 0.; Real az = 0.; ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); @@ -359,7 +357,7 @@ AMRErrorTag::operator() (TagBoxArray& tba, az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); #endif // DIM > 2 if (amrex::max(AMREX_D_DECL(ax,ay,az)) >= threshold) { - tag(i,j,k) = tag_update; + tagma[bi](i,j,k) = tag_update; } #endif // DIM > 1 }); @@ -375,7 +373,6 @@ AMRErrorTag::operator() (TagBoxArray& tba, ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept { auto const& dat = datma[bi]; - auto const& tag = tagma[bi]; auto const& flag = flags[bi]; Real ax = 0.; Real ay = 0.; @@ -400,19 +397,18 @@ AMRErrorTag::operator() (TagBoxArray& tba, if (flag(i,j,k).isConnected(0,0,-1)) { az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); } +#endif // DIM > 2 if (amrex::max(AMREX_D_DECL(ax,ay,az)) >= threshold * amrex::Math::abs(dat(i,j,k))) { tagma[bi](i,j,k) = tag_update; } }); -#endif // DIM > 2 } else #endif { ParallelFor(tba, [=] AMREX_GPU_DEVICE (int bi, int i, int j, int k) noexcept { auto const& dat = datma[bi]; - auto const& tag = tagma[bi]; Real ax = 0.; Real ay = 0.; Real az = 0.; ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); diff --git a/Src/Base/AMReX_VisMF.H b/Src/Base/AMReX_VisMF.H index 12777a08307..bfab54abf8d 100644 --- a/Src/Base/AMReX_VisMF.H +++ b/Src/Base/AMReX_VisMF.H @@ -638,7 +638,6 @@ Read (FabArray& fa, const std::string& name) } int totalioreqs = nboxes; - int messtotal = 0; int reqspending = 0; int iopfileindex; std::deque iopreads; @@ -669,7 +668,6 @@ Read (FabArray& fa, const std::string& name) } } else { ParallelDescriptor::Send(vreads, tryproc, readtag); - ++messtotal; ++reqspending; } availablefiles.erase(afilesiter); From 9dc3d1d3e1eeef016bff97bc1d549d3993c8995b Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sat, 24 Sep 2022 19:37:03 -0700 Subject: [PATCH 4/5] fix compiler complaints --- Src/AmrCore/AMReX_ErrorList.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Src/AmrCore/AMReX_ErrorList.cpp b/Src/AmrCore/AMReX_ErrorList.cpp index ff2db5871e7..6dcb5565227 100644 --- a/Src/AmrCore/AMReX_ErrorList.cpp +++ b/Src/AmrCore/AMReX_ErrorList.cpp @@ -311,7 +311,6 @@ AMRErrorTag::operator() (TagBoxArray& tba, auto const& flag = flags[bi]; Real ax = 0.; Real ay = 0.; - if (flag(i,j,k).isConnected(1,0,0)) { ax = amrex::max(ax,amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k))); } @@ -344,15 +343,17 @@ AMRErrorTag::operator() (TagBoxArray& tba, { auto const& dat = datma[bi]; - Real ax = 0.; Real ay = 0.; Real az = 0.; + Real ax = 0.; ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); #if AMREX_SPACEDIM == 1 if (ax >= threshold) { tagma[bi](i,j,k) = tag_update;} #else + Real ay = 0.; ay = amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k)); ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); #if AMREX_SPACEDIM > 2 + Real az = 0.; az = amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k)); az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); #endif // DIM > 2 @@ -410,16 +411,15 @@ AMRErrorTag::operator() (TagBoxArray& tba, { auto const& dat = datma[bi]; - Real ax = 0.; Real ay = 0.; Real az = 0.; - ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); + Real ax = amrex::Math::abs(dat(i+1,j,k) - dat(i,j,k)); ax = amrex::max(ax,amrex::Math::abs(dat(i,j,k) - dat(i-1,j,k))); #if AMREX_SPACEDIM == 1 if (ax >= threshold * amrex::Math::abs(dat(i,j,k))) { tagma[bi](i,j,k) = tag_update;} #else - ay = amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k)); + Real ay = amrex::Math::abs(dat(i,j+1,k) - dat(i,j,k)); ay = amrex::max(ay,amrex::Math::abs(dat(i,j,k) - dat(i,j-1,k))); #if AMREX_SPACEDIM > 2 - az = amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k)); + Real az = amrex::Math::abs(dat(i,j,k+1) - dat(i,j,k)); az = amrex::max(az,amrex::Math::abs(dat(i,j,k) - dat(i,j,k-1))); #endif // DIM > 2 if (amrex::max(AMREX_D_DECL(ax,ay,az)) From 23ea81cee0402de1e9691cded955527d5cf0267a Mon Sep 17 00:00:00 2001 From: Ann Almgren Date: Sun, 25 Sep 2022 07:53:36 -0700 Subject: [PATCH 5/5] remove unused variable --- Src/Particle/AMReX_ParticleInit.H | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Src/Particle/AMReX_ParticleInit.H b/Src/Particle/AMReX_ParticleInit.H index ee8afc778e2..03320383ada 100644 --- a/Src/Particle/AMReX_ParticleInit.H +++ b/Src/Particle/AMReX_ParticleInit.H @@ -1022,8 +1022,6 @@ InitRandom (Long icount, ParticleLocData pld; - int cnt = 0; - Vector, Gpu::HostVector > > host_particles; host_particles.reserve(15); host_particles.resize(finestLevel()+1); @@ -1079,8 +1077,6 @@ InitRandom (Long icount, for (int i = 0; i < NArrayInt; i++) { host_int_attribs[pld.m_lev][ind][i].push_back(pdata.int_array_data[i]); } - - cnt++; } }