From d3141693601906450d3554bd168c3c7c8a7f4c93 Mon Sep 17 00:00:00 2001 From: Johannes Blaschke Date: Tue, 1 Jan 2019 14:19:09 +0100 Subject: [PATCH] add utility function automating levelset__eb_pad --- Src/EB/AMReX_EB_levelset.H | 24 +++++++++++++++++++++++- Src/EB/AMReX_EB_levelset.cpp | 1 - 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Src/EB/AMReX_EB_levelset.H b/Src/EB/AMReX_EB_levelset.H index 18285119fde..2c8548aac06 100644 --- a/Src/EB/AMReX_EB_levelset.H +++ b/Src/EB/AMReX_EB_levelset.H @@ -286,7 +286,7 @@ class LSUtility { //! `geom`, and CellSize matching the LSFactory `level_set` EB resolution. //! This is particularly useful for building EBFArrayBoxFactory objects //! whose Geometry is what's expected by the LSFactory's filling routines. - static Geometry make_eb_geometry(const LSFactory & level_set, const Geometry& geom){ + static Geometry make_eb_geometry(const LSFactory & level_set, const Geometry & geom){ // Set up refined geometry Box dom_eb = geom.Domain(); dom_eb.refine(level_set.get_eb_ref()); @@ -296,6 +296,28 @@ class LSUtility { } + + //! Returns the minimum eb_pad (EB ghost cells) to ensure that the level-set + //! is able to resolve a length scale of at least `min_resolution`. + + static int min_eb_pad (Real min_resolution, const Geometry & geom_eb) { + + RealVect dx_eb(AMREX_D_DECL(geom_eb.CellSize()[0], + geom_eb.CellSize()[1], + geom_eb.CellSize()[2])); + +#if (AMREX_SPACEDIM == 1) + const Real min_dx = dx_eb[0]; +#elif (AMREX_SPACEDIM == 2) + const Real min_dx = std::min(dx_eb[0], dx_eb[1]); +#elif (AMREX_SPACEDIM == 3) + const Real min_dx = std::min(dx_eb[0], std::min(dx_eb[1], dx_eb[2])); +#endif + + return min_resolution/min_dx; + } + + //! Debug utility to help interrogate runtime flag types. static void PrintFlagType(const Box & tile_box, const EBCellFlagFab & flag){ diff --git a/Src/EB/AMReX_EB_levelset.cpp b/Src/EB/AMReX_EB_levelset.cpp index f0a26ca5888..db0fbb9f12f 100644 --- a/Src/EB/AMReX_EB_levelset.cpp +++ b/Src/EB/AMReX_EB_levelset.cpp @@ -592,7 +592,6 @@ void LSFactory::fill_data (MultiFab & data, iMultiFab & valid, geom_eb.CellSize()[2])); // Don't use the ls_grid_pad for the eb_padding (goes wrong!) - //const int eb_pad = data.nGrow() + 1; const int ls_pad = data.nGrow(); // Doesn't work with iMultiFabs