Skip to content

Fix issue #259: EB body near a pressure outflow face - #266

Merged
asalmgren merged 3 commits into
AMReX-Fluids:developmentfrom
asalmgren:fix-259
Oct 13, 2026
Merged

asalmgren merged 3 commits into
AMReX-Fluids:developmentfrom
asalmgren:fix-259

Conversation

@asalmgren

Copy link
Copy Markdown
Contributor

Fixes #259.

The reported configuration turned out to hit two separate problems. Both are fixed here.

1. Covered-cell values poisoning the nodal rhs

The nodal solver's rhs is EB-aware level by level, but the contribution of a fine level to the rhs of the level below is not: for cells on the boundary of a fine grid, MLNodeLaplacian::compRHS recomputes the divergence from the raw fine velocity (mlndlap_divu_fine_contrib → mlndlap_sum_Df) with no volume-fraction weighting. IAMR holds COVERED_VAL (1e40) in covered cells, so that landed in the coarse rhs — max(abs(rhs)) on level 0 was 2e41 instead of 781 — which is where the 1e39 velocities and the 1e-42 dt in the issue came from.

doMLMGNodalProjection now zeroes the velocity in covered cells before the solve. Nothing reads velocity there: estTimeStep ignores covered cells (norm0(..., ignore_covered=true)) and the plotfile code sets them itself.

2. Refinement slicing through the body at the outflow

do_derefine_outflow (on by default) clears refinement tags within Nbuf_outflow cells of an outflow face. For a body near that face this cuts the tagged region through the middle of the body — IAMR's own grid log, with the body spanning fine cells 168–184:

default:                       1: ((144,0) (183,63))   <- c/f boundary at 184, inside the body
ns.do_derefine_outflow=0:      1: ((144,0) (191,63))   <- body fully covered

and a two-level nodal solve diverges when the coarse/fine boundary crosses a body. That is an AMReX problem, not an IAMR one: it reproduces in ~150 lines calling MLNodeLaplacian/MLMG directly, with no IAMR, with Neumann instead of Dirichlet on the face, and with a mid-domain body. Reported upstream as AMReX-Codes/amrex#6069, which has the reproducer and the sweep table.

manual_tags_placement now keeps the tags on cells a body cuts when that body carries on past the inward edge of the cleared region, so refinement reaches the outflow face instead of stopping inside the body. A body lying wholly inside the cleared region is not refined today and is not refined now either, so no configuration that currently runs changes its grids.

Result

regtest.2d.flow_past_cylinder-x with the cylinder moved toward the outflow, 2 MPI ranks, 10 steps:

eb2.sphere_center x gap to the face before after
0.40 / 0.45 / 0.48 ≥ 5.6 cells runs runs
0.50 (the issue's reproducer) 4.0 cells MLMG abort runs, with the shipped ns.gravity = -9.8
0.54 / 0.58 ≤ 0.8 cells, or cuts the face MLMG abort runs with ns.gravity=0; with gravity, stops on the existing explicit Projection::set_outflow_bcs: level 1 only partially covers an outflow face guard

Verification

  • All eight EB regression tests agree bit-for-bit with the previous code (fcompare: PLOTFILE AGREE): 2D bubble, double_shear_layer, flow_past_cylinder-x, flow_past_cylinder-y, hotspot; 3D double_shear_layer, flow_past_cylinder-x, hotspot.
  • Exec/run2d, Exec/run3d, Exec/eb_run2d, Exec/eb_run3d all build clean; NavierStokesBase.cpp is also clean under -Wall -Wextra with asserts enabled. Both changes are inside #ifdef AMREX_USE_EB, so non-EB builds are untouched.
  • Unrelated pre-existing failure noticed while running the suite: regtest.2d.shock_past_cylinder aborts in MLMG on unmodified development as well.

🤖 Generated with Claude Code

asalmgren and others added 3 commits October 12, 2026 17:31
Two separate problems made a run abort when an EB body sat within a few
cells of a pressure outflow face.

1. Covered-cell values poisoning the nodal rhs.

   The nodal solver's rhs is EB-aware level by level, but the
   contribution of a fine level to the rhs of the level below is not:
   for cells on the boundary of a fine grid, MLNodeLaplacian::compRHS
   recomputes the divergence from the raw fine velocity
   (mlndlap_divu_fine_contrib -> mlndlap_sum_Df) with no volume-fraction
   weighting. IAMR holds COVERED_VAL (1e40) in covered cells, so that
   landed in the coarse rhs: in the reproducer, max(abs(rhs)) on level 0
   was 2e41 instead of 781, which gave velocities of order 1e39, dt of
   order 1e-42 and an MLMG abort during the initial iterations.

   doMLMGNodalProjection now zeroes the velocity in covered cells before
   the solve. Nothing reads velocity there -- estTimeStep ignores covered
   cells and the plotfile code sets them itself -- so this only affects
   paths that should not have been looking at them.

2. Refinement sliced through the body at the outflow.

   do_derefine_outflow (on by default) clears refinement tags within
   Nbuf_outflow cells of an outflow face. For a body near that face this
   cuts the tagged region through the middle of the body, and a two-level
   nodal solve diverges when the coarse/fine boundary crosses a body:
   with the body spanning fine cells 174-190, a fine grid ending at 173
   or covering through 191 converges, while every boundary in between
   diverges. That is an AMReX MLNodeLaplacian problem, not an IAMR one --
   it reproduces with no IAMR, no outflow BC (Neumann does it too) and a
   mid-domain body -- and it is reported upstream.

   manual_tags_placement now keeps the tags on cells a body cuts when
   that body carries on past the inward edge of the cleared region, so
   refinement reaches the outflow face instead of stopping inside the
   body. A body lying wholly inside the cleared region is not refined
   today and is not refined now either, so no configuration that
   currently runs changes its grids.

With both fixes, flow_past_cylinder-x with the cylinder moved to
eb2.sphere_center = 0.50 0.0 0.0 -- the reproducer in the issue, a 4-cell
gap -- runs its 10 steps. At 0.54 and 0.58 the body is within one cell of
the face, or cuts it; those run with gravity off, and with gravity they
stop on the existing, explicit "level 1 only partially covers an outflow
face" abort from set_outflow_bcs rather than on a solver failure.

All eight EB regression tests (2D bubble, double_shear_layer,
flow_past_cylinder-x, flow_past_cylinder-y, hotspot; 3D
double_shear_layer, flow_past_cylinder-x, hotspot) agree bit-for-bit with
the previous code. regtest.2d.shock_past_cylinder aborts in MLMG both
before and after this commit; that is a pre-existing failure.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The ParallelFor kernel added in the previous commit uses i,j,k, which
shadowed the outflow-face loop index i. Rename that loop index to iface,
which also matches how it is used (outFaces[iface]).

Caught by the GCC EB 2D CI job, which builds with WARN_ALL=TRUE
WARN_ERROR=TRUE.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@asalmgren
asalmgren merged commit 6716520 into AMReX-Fluids:development Oct 13, 2026
12 checks passed
@asalmgren
asalmgren deleted the fix-259 branch October 13, 2026 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EB body within ~4 cells of a pressure outflow face: velocity reaches COVERED_VAL (1e40), dt collapses to ~1e-42 and MLMG aborts

1 participant