Skip to content

Fix issue #233: remove the unreachable EB body-state machinery - #265

Merged
asalmgren merged 2 commits into
AMReX-Fluids:developmentfrom
asalmgren:fix-233
Oct 12, 2026
Merged

asalmgren merged 2 commits into
AMReX-Fluids:developmentfrom
asalmgren:fix-233

Conversation

@asalmgren

Copy link
Copy Markdown
Contributor

Fixes #233.

NavierStokesBase::init_eb has no caller anywhere in Source/, Exec/ or Tutorials/, and it is the only caller of initialize_eb2_structs, which is in turn the only writer of ebmask and the only place that clears no_eb_in_domain. With no_eb_in_domain stuck at its default of true, define_body_state and set_body_state return on their first line, and the two set_body_state(S_new) calls in NavierStokes.cpp were commented out anyway.

Besides being dead, the code was a hazard if revived: the singlevalued branch of initialize_eb2_structs and the point search in define_body_state walk an EBCellFlagFab and a BaseFab<int> with a BoxIterator on the host, which is invalid for the device-resident data of a GPU build (the bug class fixed in 92f0e72 / #147), and the rank search would Bcast with body_rank == -1, guarded only by an AMREX_ASSERT, if no rank found an uncovered cell.

Removed init_eb, initialize_eb2_structs, define_body_state, set_body_state, ebInitialized, and the ebmask, body_state, body_state_set, no_eb_in_domain and eb_initialized members. Source/NSB_K.H held only set_body_state_k, so the header is deleted along with its four #includes. facecent goes too — initialize_eb2_structs held its only assignment and nothing reads it. volfrac and areafrac stay: they are set on the live path in NavierStokesBase.cpp:774-775 and used by the reflux and diffusion code.

The NavierStokes.cpp comments that pointed at set_body_state are updated. initData's EB_set_covered(S_new, COVERED_VAL) is unchanged and remains how covered cells get their values.

Verification

  • Exec/run2d, Exec/run3d, Exec/eb_run2d and Exec/eb_run3d all build clean.
  • EB regtest regtest.2d.flow_past_cylinder-x (2 MPI ranks, 10 steps) agrees bit-for-bit with the pre-change build on all fields including vfrac (fcompare: PLOTFILE AGREE).

🤖 Generated with Claude Code

asalmgren and others added 2 commits October 12, 2026 14:36
…inery

NavierStokesBase::init_eb has no caller anywhere in Source/, Exec/ or
Tutorials/, and it is the only caller of initialize_eb2_structs, which
is in turn the only writer of ebmask and the only place that clears
no_eb_in_domain. With no_eb_in_domain stuck at its default of true,
define_body_state and set_body_state return on their first line, and
the two set_body_state(S_new) calls in NavierStokes.cpp were commented
out anyway.

Besides being dead, the code was a hazard if revived: the singlevalued
branch of initialize_eb2_structs and the point search in
define_body_state walk an EBCellFlagFab and a BaseFab<int> with a
BoxIterator on the host, which is invalid for the device-resident data
of a GPU build (the bug class fixed in 92f0e72 / AMReX-Fluids#147), and the rank
search would Bcast with body_rank == -1, guarded only by an
AMREX_ASSERT, if no rank found an uncovered cell.

Removed: init_eb, initialize_eb2_structs, define_body_state,
set_body_state, ebInitialized, and the ebmask, body_state,
body_state_set, no_eb_in_domain and eb_initialized members. Source/NSB_K.H
held only set_body_state_k, so the header is deleted along with its
four #includes. facecent goes too -- initialize_eb2_structs held its
only assignment and nothing reads it. volfrac and areafrac stay: they
are set on the live path in NavierStokesBase::define_workspace and used
by the reflux and diffusion code.

The comments in NavierStokes.cpp that pointed at set_body_state are
updated; initData's EB_set_covered(S_new, COVERED_VAL) is unchanged and
remains how covered cells get their values.

2D, 3D, EB-2D and EB-3D all build. The EB regtest
flow_past_cylinder-x (2 MPI ranks, 10 steps) agrees bit-for-bit with
the previous code.

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

Labels

None yet

Projects

None yet

1 participant