Skip to content

Fix issues #241, #240: remove unused Diffusion members; scale only the delta_rhs source by rho_half - #262

Merged
asalmgren merged 1 commit into
AMReX-Fluids:developmentfrom
asalmgren:fix-241-240
Oct 12, 2026
Merged

asalmgren merged 1 commit into
AMReX-Fluids:developmentfrom
asalmgren:fix-241-240

Conversation

@asalmgren

Copy link
Copy Markdown
Contributor

Closes #241. Closes #240.

#241 — remove Diffusion members that are never exercised

None of these has a caller anywhere in Source/, Exec/, Tutorials/ or Util/:

  • diffuse_Ssync (~170 lines). This is a second, independent copy of the scalar sync solve, with its own density logic (computeAlpha on current-time S, an explicit rho_flag==2 rescaling, rho_half scaling of the RHS) that was never checked against the live path. The live sync diffusion is diffuse_scalar with add_old_time_divFlux=false, called from NavierStokes::mac_sync. Its last call site was already commented out before c55efb16 (2019).
  • FillBoundary(BndryRegister&, ...) — left over from the pre-MLMG boundary-register solvers.
  • viscFluxReg(), maxOrder(), tensorMaxOrder() — the flux register is reached through NavierStokesBase::getViscFluxReg(), and the max_order / tensor_max_order statics are used directly. The member variables and the diffuse.max_order / diffuse.tensor_max_order ParmParse knobs are unchanged.

The comment in diffuse_tensor_velocity that cited diffuse_Ssync as the reference for RHS scaling now cites only diffuse_scalar.

computeAlpha keeps its alpha_in branch: once diffuse_Ssync is gone the remaining forwarder is diffuse_scalar, which also consumes alpha_in in its own source loop, so it is live API surface rather than dead code. Its assert now checks alpha_in->nComp() instead of the freshly defined one-component destination, which only ever admitted alpha_in_comp == 0 and never validated the source at all.

#240 — scale only the delta_rhs source by rho_half

For rho_flag==1 the source block multiplied the whole RHS by rho_half, including the old-time diffusion term that mgn.apply had already deposited there when add_old_time_divFlux is set. Only the source should be scaled. Latent today: no caller passes both delta_rhs and add_old_time_divFlux=true.

Verification

  • Exec/run2d and Exec/eb_run3d build clean with USE_ASSERTION=TRUE WARN_ALL=TRUE WARN_ERROR=TRUE and the CI's EXTRACXXFLAGS.
  • grep for all five removed symbols across Source/ Exec/ Tutorials/ Util/ Docs/ returns nothing.
  • regtest.2d.hotspot (3 levels, temperature conduction + scal_diff_coefs, mac_sync active every step), 10 steps, compared against a binary built from development: fcompare reports PLOTFILE AGREE — exact zeros on every variable at all three levels. Expected, since nothing removed was reachable and the Diffusion::diffuse_scalar: with rho_flag==1 and delta_rhs, the old-time diffusion term is also multiplied by rho_half #240 path is latent.

🤖 Generated with Claude Code

…n members; scale only the delta_rhs source by rho_half

Issue AMReX-Fluids#241: none of these Diffusion members has a caller anywhere in
Source/, Exec/, Tutorials/ or Util/, so delete them:

  - diffuse_Ssync: a second, independent copy of the scalar sync solve,
    with its own density handling.  The live sync path is diffuse_scalar
    with add_old_time_divFlux=false, called from NavierStokes::mac_sync.
    The last call site was already commented out before c55efb1 (2019).
  - FillBoundary(BndryRegister&, ...): left over from the pre-MLMG
    boundary-register solvers.
  - viscFluxReg(), maxOrder(), tensorMaxOrder(): the flux register is
    reached through NavierStokesBase::getViscFluxReg() instead, and the
    max_order / tensor_max_order statics are used directly.  The member
    variables and the diffuse.max_order / diffuse.tensor_max_order
    ParmParse knobs are unchanged.

The comment in diffuse_tensor_velocity that cited diffuse_Ssync as the
reference for RHS scaling now cites only diffuse_scalar.

computeAlpha keeps its alpha_in branch, since diffuse_scalar both
forwards alpha_in here and consumes it in its own source loop, but its
assert now checks alpha_in->nComp() instead of the freshly defined
one-component destination, which only ever admitted alpha_in_comp == 0.

Issue AMReX-Fluids#240: for rho_flag==1, the delta_rhs block multiplied the whole
RHS by rho_half, including the old-time diffusion term that mgn.apply
had already deposited there when add_old_time_divFlux is set.  Scale
only the source.  No current caller passes both delta_rhs and
add_old_time_divFlux=true, so this is latent.

Verified: Exec/run2d and Exec/eb_run3d build clean with USE_ASSERTION,
WARN_ALL and WARN_ERROR; regtest.2d.hotspot (3 levels, scalar diffusion
and mac_sync active) run for 10 steps is bit-identical to development
(fcompare: PLOTFILE AGREE).

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

Labels

None yet

Projects

None yet

2 participants