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]);
}
Location:
Source/MacProj.cpp:1191-1194,Source/MacProj.cpp:459-461Severity: Low — wrong sync correction only with
amr.ref_ratio = 4and three or more levels; the same gap inDiffusion::diffuse_scalarwas fixed in #205 but this twin was missedCategory: AMR-sync
Based on commit
bb697bf5(line numbers refer to that tree).Problem
mac_sync_solvehandsmlmg_mac_solvea null coarse solution (nullptrat line 459),and
mlmg_mac_solveonly tells the projector about the coarse/fine boundary when thatpointer is non-null:
For
level > 0the level grids do not cover the domain, soMLCellLinOp::setLevelBCstill builds a homogeneous Dirichlet coarse/fine boundary, but with
m_coarse_data_crse_rationever set it falls back toIntVect(2)(AMReX
AMReX_MLCellLinOp.H:843). Withamr.ref_ratio = 4the ghost-valueinterpolation 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 henceUcorr,is wrong in every cell adjacent to the level-(l-1)/l interface.
Diffusion::diffuse_scalarhad exactly this gap and #205 addedsetCoarseFineBC(nullptr, cratio[0])there (Source/Diffusion.cpp:403,529); theMAC 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 forlevel >= 1, i.e. runs with at least three AMRlevels. Every shipped deck uses
amr.ref_ratio = 2, for which the default happens to beright, so the defect is latent. Any three-level run with
amr.ref_ratio = 4gets amis-positioned homogeneous Dirichlet condition in the level-1 MAC sync, which feeds
Vsync/Ssyncand the level-1 state throughmac_sync_compute.Suggested fix
Always register the coarse/fine ratio on a level above 0; a null coarse MultiFab is
accepted by
MLLinOp::setCoarseFineBCand gives the homogeneous condition.