From dc4b76efc5d54bb52bc0371ff7a90e1049af5ee1 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Tue, 17 Sep 2024 14:10:29 -0500 Subject: [PATCH 1/3] Fix EB documentation (#4155) Remove incorrect information. Note that we have an item for face centroids later. --- Docs/sphinx_documentation/source/EB.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Docs/sphinx_documentation/source/EB.rst b/Docs/sphinx_documentation/source/EB.rst index 2c78856f93..15065a841d 100644 --- a/Docs/sphinx_documentation/source/EB.rst +++ b/Docs/sphinx_documentation/source/EB.rst @@ -308,10 +308,6 @@ following data: z)^2 + (n_y \Delta x \Delta z)^2 + (n_z \Delta x \Delta y)^2}`, where :math:`n` is the boundary normal vector. -- **Face centroid** is in a :cpp:`MultiCutFab` with ``AMREX_SPACEDIM`` components. - Each component of the data is in the range of :math:`[-0.5,0.5]`, based on - each cell's local coordinates with respect to the embedded boundary. - - **Area fractions** are returned in an :cpp:`Array` of :cpp:`MultiCutFab` pointers. For each direction, area fraction is for the face of that direction. Data are in the range of :math:`[0,1]` with zero representing a covered face From eecb9ea70f2ce235222d0cc2db582fe39fe8cdff Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Tue, 17 Sep 2024 14:11:09 -0500 Subject: [PATCH 2/3] Add a new InterFromCoarseLevel for ERF (#4150) --- Src/AmrCore/AMReX_FillPatchUtil.H | 34 +++++++++++++++++++++++++ Src/AmrCore/AMReX_FillPatchUtil_I.H | 39 +++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/Src/AmrCore/AMReX_FillPatchUtil.H b/Src/AmrCore/AMReX_FillPatchUtil.H index e740ccce0d..11a8eb560e 100644 --- a/Src/AmrCore/AMReX_FillPatchUtil.H +++ b/Src/AmrCore/AMReX_FillPatchUtil.H @@ -694,6 +694,40 @@ namespace amrex const PreInterpHook& pre_interp = {}, const PostInterpHook& post_interp = {}); + /** + * \brief Fill with interpolation of coarse level data + * + * It's the CALLER's responsibility to make sure all ghost cells of the + * coarse MF needed for interpolation are filled already before calling + * this function. It's assumed that the fine level MultiFab mf's + * BoxArray is coarsenable by the refinement ratio. There is no support + * for EB. + * + * \tparam MF the MultiFab/FabArray type + * \tparam Interp spatial interpolater + * + * \param mf destination MF on the fine level + * \param nghost number of ghost cells of mf inside domain needed to be filled + * \param nghost_outside_domain number of ghost cells of mf outside domain needed to be filled + * \param cmf source MF on the coarse level + * \param scomp starting component of the source MF + * \param dcomp starting component of the destination MF + * \param ncomp number of components + * \param cgeom Geometry for the coarse level + * \param fgeom Geometry for the fine level + * \param ratio refinement ratio + * \param mapper spatial interpolater + * \param bcs boundar types for each component + */ + template + std::enable_if_t::value> + InterpFromCoarseLevel (MF& mf, IntVect const& nghost, + IntVect const& nghost_outside_domain, + const MF& cmf, int scomp, int dcomp, int ncomp, + const Geometry& cgeom, const Geometry& fgeom, + const IntVect& ratio, Interp* mapper, + const Vector& bcs); + #ifndef BL_NO_FORT enum InterpEM_t { InterpE, InterpB}; diff --git a/Src/AmrCore/AMReX_FillPatchUtil_I.H b/Src/AmrCore/AMReX_FillPatchUtil_I.H index 190566a7fa..fa26cc5ea9 100644 --- a/Src/AmrCore/AMReX_FillPatchUtil_I.H +++ b/Src/AmrCore/AMReX_FillPatchUtil_I.H @@ -1210,6 +1210,45 @@ InterpFromCoarseLevel (Array const& mf, IntVect const& ngho } } +template +std::enable_if_t::value> +InterpFromCoarseLevel (MF& mf, IntVect const& nghost, + IntVect const& nghost_outside_domain, + const MF& cmf, int scomp, int dcomp, int ncomp, + const Geometry& cgeom, const Geometry& fgeom, + const IntVect& ratio, Interp* mapper, + const Vector& bcs) +{ + const BoxArray& ba = mf.boxArray(); + const DistributionMapping& dm = mf.DistributionMap(); + + const IndexType& typ = ba.ixType(); + BL_ASSERT(typ == cmf.boxArray().ixType()); + + const InterpolaterBoxCoarsener& coarsener = mapper->BoxCoarsener(ratio); + Box tmp(-nghost, IntVect(32), typ); + Box tmp2 = coarsener.doit(tmp); + IntVect src_ghost = -tmp2.smallEnd(); + + tmp = Box(-nghost_outside_domain, IntVect(32), typ); + tmp2 = coarsener.doit(tmp); + IntVect src_ghost_outside_domain = -tmp2.smallEnd(); + + IntVect cghost = cmf.nGrowVect(); + cghost.min(src_ghost); + + AMREX_ALWAYS_ASSERT(cghost.allGE(src_ghost_outside_domain)); + + MF mf_crse_patch(amrex::coarsen(ba,ratio), dm, ncomp, src_ghost); + mf_crse_patch.ParallelCopy(cmf, scomp, 0, ncomp, cghost, src_ghost, + cgeom.periodicity()); + + Box fdomain_g = amrex::convert(fgeom.Domain(),typ); + fdomain_g.grow(nghost_outside_domain); + FillPatchInterp(mf, dcomp, mf_crse_patch, 0, ncomp, nghost, cgeom, fgeom, + fdomain_g, ratio, mapper, bcs, 0); +} + template std::enable_if_t::value> FillPatchNLevels (MF& mf, int level, const IntVect& nghost, Real time, From 73716d921e378554f618d913080ea5786e8f9b81 Mon Sep 17 00:00:00 2001 From: Andy Nonaka Date: Tue, 17 Sep 2024 12:17:47 -0700 Subject: [PATCH 3/3] Fix roundoff issue in SUNDIALS evolve() (#4148) Fix a roundoff issue in the SUNDIALS evolve() function that caused the integrator to run a second time with a very tiny dt in a given time step. --- Src/Base/AMReX_RKIntegrator.H | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Src/Base/AMReX_RKIntegrator.H b/Src/Base/AMReX_RKIntegrator.H index a6efd02853..a4769dc915 100644 --- a/Src/Base/AMReX_RKIntegrator.H +++ b/Src/Base/AMReX_RKIntegrator.H @@ -251,7 +251,8 @@ public: for (int step_number = 0; step_number < BaseT::max_steps && !stop; ++step_number) { // Adjust step size to reach output time - if (time_out - time_current < dt) { + // protect against roundoff + if ((time_out-time_current) < dt || almostEqual(time_out-time_current,dt,10)) { dt = time_out - time_current; stop = true; }