Skip to content

mlmg_mac_solve: the MAC sync solve on a level above 0 never calls setCoarseFineBC, so MLMG assumes a coarse/fine ratio of 2 #237

Description

@WeiqunZhang

Location: Source/MacProj.cpp:1191-1194, Source/MacProj.cpp:459-461
Severity: Low — wrong sync correction only with amr.ref_ratio = 4 and three or more levels; the same gap in Diffusion::diffuse_scalar was fixed in #205 but this twin was missed
Category: AMR-sync
Based on commit bb697bf5 (line numbers refer to that tree).

Problem

mac_sync_solve hands mlmg_mac_solve a null coarse solution (nullptr at line 459),
and mlmg_mac_solve only tells the projector about the coarse/fine boundary when that
pointer is non-null:

// Source/MacProj.cpp:1191-1194
    if (level > 0 && cphi)
    {
        macproj.setCoarseFineBC(cphi, a_parent->refRatio(level-1)[0]);
    }

For level > 0 the level grids do not cover the domain, so MLCellLinOp::setLevelBC
still builds a homogeneous Dirichlet coarse/fine boundary, but with
m_coarse_data_crse_ratio never set it falls back to IntVect(2)
(AMReX AMReX_MLCellLinOp.H:843). With amr.ref_ratio = 4 the ghost-value
interpolation then places the coarse cell centre 1.5 fine cells outside the
interface instead of 2.5, so the sync potential mac_sync_phi, and hence Ucorr,
is wrong in every cell adjacent to the level-(l-1)/l interface.

Diffusion::diffuse_scalar had exactly this gap and #205 added
setCoarseFineBC(nullptr, cratio[0]) there (Source/Diffusion.cpp:403,529); the
MAC sync solve was left as is.

Impact

Only the sync solve reaches this path (the level advance always passes
mac_phi_crse[level-1]), and only for level >= 1, i.e. runs with at least three AMR
levels. Every shipped deck uses amr.ref_ratio = 2, for which the default happens to be
right, so the defect is latent. Any three-level run with amr.ref_ratio = 4 gets a
mis-positioned homogeneous Dirichlet condition in the level-1 MAC sync, which feeds
Vsync/Ssync and the level-1 state through mac_sync_compute.

Suggested fix

Always register the coarse/fine ratio on a level above 0; a null coarse MultiFab is
accepted by MLLinOp::setCoarseFineBC and gives the homogeneous condition.

--- a/Source/MacProj.cpp
+++ b/Source/MacProj.cpp
@@ -1188,7 +1188,10 @@ MacProj::mlmg_mac_solve (Amr* a_parent, const MultiFab* cphi, const BCRec& a_phys_bc,
     set_mac_solve_bc(mlmg_lobc, mlmg_hibc, a_phys_bc, geom);
 
     macproj.setDomainBC(mlmg_lobc, mlmg_hibc);
-    if (level > 0 && cphi)
+    // cphi is null for the sync solve. MLMG then uses a homogeneous
+    // Dirichlet coarse/fine BC, but it still needs the true refinement
+    // ratio; otherwise it assumes 2.
+    if (level > 0)
     {
         macproj.setCoarseFineBC(cphi, a_parent->refRatio(level-1)[0]);
     }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions