Skip to content

Godunov_2D_eb.cpp:212 grow() args transposed — final y-flux box lacks its transverse x ring #92

Closed

Description

@WeiqunZhang

Severity: high/medium · Category: correctness · Fix order: 4 of 25 — fix this 4th.

Filenames are numbered in reverse fix order: 001 = fix last, 025 = fix first. This file is 022.

Location: Source/Hydro/Godunov/Godunov_2D_eb.cpp:212

Based on commit 8f87fa8 (line numbers refer to that tree).

The seven findings below were reported independently but are the same one-line defect at Godunov_2D_eb.cpp:212; one patch resolves all of them.

The defect

What is wrong — The final Y-Riemann box uses grow(bx_to_fill, 1, 1-cdir) which with cdir==1 is grow(dir=1, ncells=0), a no-op; the intended transverse growth grow(bx_to_fill, 1-cdir, 1) (grow x by 1) is never applied, so final y-fluxes/q2 are missing on the two outermost x-columns. Reported independently at this same line by F005, F007, F012, F013, F022, F045; each reviewer's own wording and evidence is under Verification evidence below.

Why it matters

2D USE_EB Godunov run (default do_mol=0, redistribution_type=FluxRedist) with a cut y-face in the outer x-column of grow(tilebox,2): eb_compute_div's tangential interpolation reads flux_tmp1 holding only the artificial-viscosity contribution (the hyperbolic flux is never written there), corrupting divc there; FluxRedist's divnc average over grow(bx,2) redistributes the error into valid cells, giving tile-layout-dependent wrong answers near the EB.

How to reach it

  • Build Exec/SodPlusSphere (DIM=2, USE_EB=TRUE); run its inputs with CAMR.do_mol=0 (source default; deck's do_mol=1 removed). Append CAMR.redistribution_type=FluxRedist too -- the deck sets FluxRedist then StateRedist (inputs:30-31) and the last occurrence wins, so the shipped run is StateRedist, not the FluxRedist path this scenario needs. ppm_type default 0 reaches Godunov_umeth_eb; no abort blocks 2D EB Godunov.
  • Exec/SodPlusSphere (GNUmakefile: DIM=2, USE_EB=TRUE), run inputs with CAMR.do_mol=0 (the default; deck's do_mol=1 overridden). Defaults ppm_type=0, FluxRedist pass all validation (CAMR.cpp:186-197); sphere EB cuts grid-box x-edges.
  • Build Exec/SodPlusSphere (DIM=2, USE_EB=TRUE); run shipped inputs with CAMR.do_mol=0 (the default; decks override to 1). ppm_type default 0 passes the CAMR.cpp:189 EBGodunov gate; default FluxRedist propagates the error.
  • Exec/DoubleRamp (DIM=2, USE_EB=TRUE) run with CAMR.do_mol=0 (default; deck line overridable), default ppm_type=0 passes the EBGodunov abort; CAMR.redistribution_type=FluxRedist or StateRedist consumes the corrupted layer.
  • Build Exec/SodPlusSphere (DIM=2, USE_EB=TRUE); run its inputs with CAMR.do_mol=0 (code default; deck's do_mol=1 line removed). Defaults ppm_type=0, FluxRedist pass all asserts; sphere EB with amr.max_grid_size=16 puts cut cells in patch ghost columns.
  • Exec/SodPlusSphere (or DoubleRamp/ReReTest): DIM=2, USE_EB=TRUE build; set CAMR.do_mol=0 (the default; shipped decks override to 1) with default ppm_type=0 and FluxRedist; sphere-cut cells at grid x-edges trigger it.

Suggested fix

AMReX's free function is grow(box, idir, n_cell) (AMReX_Box.H), so the transverse direction belongs in the second slot: grow(bx_to_fill, 1-cdir, 1). Write line 185 the same way — it is only accidentally right at cdir==0, and PR #45 (cc39829) created this bug by copying that line into the y pass without swapping. The corrected box is the 2D analogue of Godunov_3D_eb.cpp's yfbx.grow(0,1) and MOL_umeth_eb.cpp:117's ybx.grow(IntVect(1,0,1)). No reallocation is needed: hydro_transd already fills qm/qp over bxg1, and flux_tmp[1]/qec[1] extend one and two cells beyond bx_to_fill.

Apply together: qec is resized but never zeroed (Hydro_umdrv_eb.cpp:72-76) and hydro_cmpflx skips ap==0 faces, so eb_pdivu can still interpolate uninitialized q2. MOL_umeth_eb zeroes its Godunov states in the else branch; do likewise, or setVal the qec fabs. Please check this against open issue #70.

For Source/Hydro/Godunov/Godunov_2D_eb.cpp:212 (F004):

--- a/Source/Hydro/Godunov/Godunov_2D_eb.cpp
+++ b/Source/Hydro/Godunov/Godunov_2D_eb.cpp
@@ -209,7 +209,7 @@
 
   // This box must be grown by one in transverse direction so we can
   // do tangential interpolation when taking divergence later
-  const Box& yfxbx = surroundingNodes( grow(bx_to_fill, 1, 1-cdir), cdir);
+  const Box& yfxbx = surroundingNodes( grow(bx_to_fill, 1-cdir, 1), cdir);
 
   // Final Riemann problem Y
   ParallelFor(yfxbx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept

Swaps the arguments to amrex::grow(Box, idir, n_cell) (AMReX_Box.H) so the transverse direction 1-cdir (=x) is grown by 1 cell instead of growing dir 1 by 0 (no-op). Matches Godunov_3D_eb.cpp's yfbx.grow(0,1) and MOL_umeth_eb.cpp:117. Line 185's xfxbx uses the same wrong argument order but evaluates correctly for cdir=0; left unchanged as it is functionally correct, though the maintainer may want to rewrite it identically for clarity.

Diff(s) are against 8f87fa8, written from the current source and verified only with git apply --check — never compiled, never run, never applied to the tree. Treat them as precise intent, not tested patches.

Verification evidence

F004 — confirmed (two independent verifier lenses)

Lens 1 (refutation attempt): Line 212: const Box& yfxbx = surroundingNodes( grow(bx_to_fill, 1, 1-cdir), cdir); with cdir=1 -> grow(dir=1,n=0), a no-op; AMReX signature is grow(Box,idir,n_cell) (AMReX_Box.H:1363). eb_compute_div reads v(ii=i±1) at cut y-faces (Hydro_utils_eb_K.H:373-385) over bxg_i=grow(bx,2); flux_tmp[1] setVal(0) at the missing ring; divnc in amrex_flux_redistribute reads divc over grow(bx,2) into bx. Only nuance: adjust_fluxes_eb adds artif-visc there, hyperbolic flux still missing. May relate to open issue #70.

Lens 2 (reachability/intent): Godunov_2D_eb.cpp:212: grow(bx_to_fill,1,1-cdir) with cdir=1 grows dir 1 by 0 (amrex grow(Box,idir,n_cell)), violating the comment above it; 3D and MOL analogs (Godunov_3D_eb.cpp:527 yfbx.grow(0,1); MOL_umeth_eb.cpp:117) do the intended x-growth. flux_tmp[1] stays setVal-0 (Hydro_umdrv_eb.cpp:108) on the outer x-columns; eb_compute_div (Hydro_utils_eb_K.H:373-385) reads v(i±1,j) there over bxg_i=grow(tilebox,2), corrupting divc; amrex FluxRedist divnc (grow(bx,1) cut cells reading grow(bx,2) divc) redistributes it into valid cells. Introduced by copy-paste in commit cc39829.

F005 — confirmed (two independent verifier lenses)

Reported as: grow() arguments are in the wrong order: grow(bx_to_fill, 1, 1-cdir) with cdir==1 grows direction 1 by 0 cells, so the final Y-flux/face-state box gets no transverse (x) halo, unlike the intent stated in the comment and unlike the 3D sibling (Godunov_3D_eb.cpp:527) which grows both transverse directions.

Failure scenario: 2D EB Godunov (do_mol=0, default FluxRedist): eb_compute_div/eb_pdivu over bxg_i tangentially interpolate flux_tmp[1] and qec[1] at x+/-1 for cut y-faces; on the outer x-ring those faces hold setVal(0) flux and stale/uninitialized qec values, corrupting divc/pdivu that redistribution smears into valid cells; wrong UEINT and box-layout-dependent results near the EB.

Lens 1 (refutation attempt): Same no-op grow at line 212; 3D sibling Godunov_3D_eb.cpp:527 does yfbx.grow(0,1); yfbx.grow(2,1). qec fabs are resized without setVal (Hydro_umdrv_eb.cpp:72-76), so q2 on the ±1-x ring holds first-pass pre-transverse values (uninitialized where apy==0); eb_pdivu reads q2(ii=i±1,GDV) and subtracts from divc(UEINT) over bxg_i. Failure chain verified through ApplyMLRedistribution/FluxRedist.

Lens 2 (reachability/intent): AMReX_Box.H:1363 declares grow(b, idir, n_cell). Godunov_2D_eb.cpp:212 with cdir==1 yields grow(bx,1,0), a no-op, contradicting its own comment (lines 210-211) and siblings Godunov_3D_eb.cpp:527 (yfbx.grow(0,1)) and MOL_umeth_eb.cpp:117 (ybx.grow(IntVect(1,0,1))). flux_tmp[1] stays setVal(0) on the outer x-ring (Hydro_umdrv_eb.cpp:107-108); eb_compute_div blends it via fracx (Hydro_utils_eb_K.H:371-389); amrex_flux_redistribute's 3x3 divnc over grow(bx,1) smears the corrupt grow(bx,2) ring into valid cells.

F007 — confirmed (two independent verifier lenses)

Reported as: yfxbx = surroundingNodes(grow(bx_to_fill, 1, 1-cdir), cdir) with cdir==1 calls grow(box, idir=1, n_cell=0), a no-op, so the final y-fluxes and q2 face states are never computed on the +-1-x ring that the comment says is required for tangential interpolation; the 3D file does this correctly (yfbx.grow(0,1); yfbx.grow(2,1)) and MOL_umeth_eb also grows transversally.

Failure scenario: 2D EB Godunov run (AMREX_SPACEDIM=2, USE_EB=TRUE, do_mol=0): for a cut cell with 0<apy<1 on the x-boundary of bxg_i, eb_compute_div blends fy from an unfilled face (0.0 from setVal) and eb_pdivu reads uninitialized qec memory (q2 has no setVal), corrupting divc; FluxRedist's divnc averaging over grow(bx,2) neighborhoods mixes the corrupted values into valid-cell dUdt, giving box-decomposition-dependent wrong answers or NaNs.

Lens 1 (refutation attempt): Confirmed grow(box,1,0) no-op at line 212; MOL_umeth_eb.cpp:117 does ybx.grow(IntVect(1,0,1)) (grows x), matching claimed convention. flux_tmp[1].setVal(0.) at Hydro_umdrv_eb.cpp:108; qec has no setVal. Path reachable: Exec/DoubleRamp is DIM=2/USE_EB=TRUE, defaults do_mol=0, redistribution_type=FluxRedist (CAMR_defaults.H). Introduced by cc39829 (PR #45), never fixed.

Lens 2 (reachability/intent): Godunov_2D_eb.cpp:212: grow(bx_to_fill,1,1-cdir) with cdir=1 is grow(box,idir=1,n=0), a no-op; commit cc39829 added it with comment "must be grown by one in transverse direction", and 3D (yfbx.grow(0,1)) plus 2D MOL (ybx.grow(IntVect(1,0,1))) do it right. flx2's only writer is this final pass (prelim pass writes local temp fy, line 155), so eb_compute_div (Hydro_utils_eb_K.H:373-385) blends fracx*0.0 into cut-cell fym/fyp at bxg_i's x-edges; FluxRedist divnc spreads it into valid dUdt. Caveat: q2 IS pre-written on the ring (line 160), so eb_pdivu reads stale, not uninitialized, values.

F012 — confirmed (two independent verifier lenses)

Reported as: grow() arguments are transposed: grow(bx_to_fill, 1, 1-cdir) with cdir=1 grows direction 1 by 0 cells, so the final y-flux/Godunov-state box is never grown by one in the transverse (x) direction, unlike the x pass (line 185) and unlike all three final flux boxes in Godunov_3D_eb.cpp.

Failure scenario: 2D USE_EB Godunov run (do_mol=0, any redistribution_type): eb_compute_div/eb_pdivu tangentially interpolate the y-flux/q2 at i±1 for cut cells with partial y-faces on the outer x-layers of bxg_i; flux_tmp[1] there is still its setVal 0.0, giving wrong divc that redistribution propagates into valid cells, so results near the EB depend on box/tile layout.

Lens 1 (refutation attempt): Same transposed grow args at 212; x pass at 185 (cdir=0) coincidentally correct, masking the bug. Core defect and default-config (FluxRedist) failure chain verified. One overreach: with NoRedist the corrupted grow(bx,2) ghost columns would not reach valid cells, so 'any redistribution_type' is too strong — defect stands regardless.

Lens 2 (reachability/intent): Godunov_2D_eb.cpp:212: grow(bx_to_fill,1,1-cdir) with cdir=1 is grow(dir=1,n=0), a no-op, contradicting the comment ("must be grown by one in transverse direction") added by commit cc39829 as a bounds fix; 3D (yfbx.grow(0,1)) and MOL (ybx.grow(IntVect(1,0,1))) grow x. eb_compute_div (Hydro_utils_eb_K.H:371-385) over bxg_i blends v(i±1,j,k)=setVal-0.0 flux_tmp[1] on bxg_i's outer x-layer; AMReX StateRedist reads divc on grow(bx,3), FluxRedist divnc on grow(bx,2), propagating into valid cells, layout-dependently.

F013 — confirmed (two independent verifier lenses)

Reported as: grow() arguments are swapped: grow(bx_to_fill, 1, 1-cdir) with cdir=1 grows direction 1 by ZERO cells, so yfxbx is never grown transversally in x, though the comment and the 3D twin (Godunov_3D_eb.cpp yfbx.grow(0,1)) require it for tangential flux interpolation.

Failure scenario: 2D + EB Godunov (do_mol=0, default): final y-fluxes/q2 are unfilled for x outside bx_to_fill. eb_compute_div/eb_pdivu at cut y-faces in the outer x-columns of bxg_i interpolate flux at (i±1,j) reading setVal-zero (or artif-visc-only) fluxes and stale q2, corrupting divc that redistribution propagates into valid cells; results depend on grid layout.

Lens 1 (refutation attempt): yfxbx = surroundingNodes(bx_to_fill,1) effectively (grow is no-op), so final y-fluxes/q2 unfilled for x outside bx_to_fill=bxg_i. eb_compute_div fym/fyp interpolation (Hydro_utils_eb_K.H:371-389) reads those faces for outer-x-column cut cells; adjust_fluxes_eb leaves only artif-visc there; divnc over grow(bx,1) neighborhoods propagates into bx. Grid-layout dependence follows since bxg_i is per-tile.

Lens 2 (reachability/intent): AMReX grow(b,idir,n_cell) (AMReX_Box.H:678): line 212 with cdir=1 gives grow(dir1,0)=no-op, contradicting its own comment (added in cc39829 "fix bounds for 2D EBGodunov") and the 3D twin yfbx.grow(0,1) (Godunov_3D_eb.cpp:527). flux_tmp[1] is setVal(0) on surroundingNodes(grow(bxg_i,1),1) (Hydro_umdrv_eb.cpp:105-108); eb_compute_div over bxg_i interpolates v(i±1,j) at cut y-faces (Hydro_utils_eb_K.H:375,385), reading artif-visc-only zeros in the outer x-columns; corrupted divc feeds ApplyMLRedistribution into valid cells. Still at HEAD 8f87fa8.

F022 — confirmed (two independent verifier lenses)

Reported as: grow() arguments are transposed: grow(bx_to_fill, 1, 1-cdir) grows direction 1 by (1-cdir) cells, so for the final Y Riemann pass (cdir=1) the y-face box gets zero transverse (x) growth, unlike the comment's intent and the 3D sibling (Godunov_3D_eb.cpp yfbx.grow(0,1)).

Failure scenario: 2D + EB + Godunov (defaults): y-faces at x = bxg_i lo-1/hi+1 never get final fluxes or GD states; flux_tmp[1] stays 0 and q2 keeps stale first-pass values there. eb_compute_div/eb_pdivu centroid interpolation (ii=i±1) at cut cells on the outer ring reads them, corrupting divc that redistribution (divnc, 2-cell reach) propagates into valid cells: silent, max_grid_size-dependent wrong answers near box x-edges.

Lens 1 (refutation attempt): Confirmed: coded yfxbx has zero x-growth; y-faces at bxg_i lo-1/hi+1 keep flux_tmp[1]=0 (setVal, Hydro_umdrv_eb.cpp:108) plus artif-visc only, and q2 keeps stale first-Riemann values (filled over surroundingNodes(grow(bxg_i,1),1) at line 76 of Godunov_2D_eb.cpp, never overwritten by final pass there). amrex_flux_redistribute divnc loop over grow(bx,1) reads divc at i±1,j±1 (AMReX_EB_FluxRedistribute.cpp:97-159), reaching grow(bx,2) and redistributing into bx: max_grid_size-dependent.

Lens 2 (reachability/intent): Godunov_2D_eb.cpp:212: grow(bx_to_fill,1,1-cdir) with cdir=1 grows dir 1 by 0; comment demands transverse growth, 3D sibling does yfbx.grow(0,1). flux_tmp[1] setVal(0) (Hydro_umdrv_eb.cpp:108) is never overwritten at bxg_i x-extent+/-1; eb_compute_div cut cells blend fracx*v(i+/-1,j,k,n)=0 into divc (Hydro_utils_eb_K.H:371-393) over all of bxg_i; FluxRedist ngrow=2 pulls that ring into valid dsdt. No abort blocks EB+Godunov (CAMR.cpp:188 names EBGodunov as supported).

F045 — confirmed (one verifier lens)

Reported as: grow(bx_to_fill, 1, 1-cdir) with cdir=1 grows direction 1 by ZERO cells (argument order swapped), so the final y-flux/q2 are not computed on the x-extended ring the comment and the 3D code (yfbx.grow(0,1)) require for tangential interpolation.

Failure scenario: 2D EB Godunov, cut cells near a box's x-edge: eb_compute_div/eb_pdivu at cells on the x-edge of bxg_i interpolate y-fluxes/q2 at ii=i+-1 (Hydro_utils_eb_K.H:373-385), reading faces never filled by the final Riemann — artificial-viscosity-only fluxes or the stale pre-transverse q2 (uninitialized where apy=0) — corrupting divc that feeds redistribution into bx.

Lens 1 (refutation attempt): Most precise statement of the same defect: cited interpolation lines Hydro_utils_eb_K.H:373-385 match exactly; faces on the missing ring hold artificial-viscosity-only fluxes (adjust_fluxes_eb loops over full Box(fy_arr)) and q2 is stale pre-transverse / uninitialized where apy==0 (qec never setVal'd). Same silent, layout-dependent divc corruption feeding redistribution into bx as the high findings — severity belongs at high, not medium.


Based on commit 8f87fa8, which is also the tree the audit verified against. From an automated audit of Source/, Tutorials/ and Util/. Audit finding ids: F004, F005, F007, F012, F013, F022, F045. Reviewer unit(s): Godunov-2D+shared, Godunov-3D, Hydro-drivers, theme:2d-3d-parity, theme:box-bounds-args, theme:eb-smallcell, theme:ghost-fillpatch, theme:state-comp-indexing. Nothing here was compiled or run — the failure scenarios are code reasoning, so the reaching configuration above is the cheapest way to confirm or refute it.

Activity

  1. added a commit that references this issue on Nov 17, 2026
    c3a3c56
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