AMReX-Astro / AMReX-Astro/Microphysics
util/hybrj: NaN/Inf handling in enorm can cause false convergence
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 43
- Forks
- 46
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
Summary
enorm() returns 0.0 when any input component is NaN or Inf. In hybrj, fnorm == 0.0 is treated as successful convergence (info = 1). This can incorrectly classify invalid numerical states as converged solves.
Affected code
util/hybrj/hybrj_enorm.H: early return0.0_rtforisnan/isinfutil/hybrj/hybrj.H: convergence check usesfnorm == 0.0_rt
Why this is a problem
A true zero norm and an invalid norm are semantically different. Folding both into 0.0 hides instability and can produce misleading solver status.
Expected behavior
Invalid numerical values should lead to a non-converged / invalid-state path, not a successful-convergence code path.
Suggested fix
- Return
NaNfromenorm()for invalid inputs, or - Add an explicit validity flag / status propagation, and
- Guard convergence checks against NaN/Inf before accepting
fnorm == 0.
Acceptance criteria
- Invalid residual entries no longer produce
info = 1. - Solver reports a deterministic failure/invalid status for NaN/Inf paths.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the early invalid-value return in util/hybrj/hybrj_enorm.H and the fnorm convergence check in util/hybrj/hybrj.H. Trace how NaN/Inf residuals reach info = 1, then ensure invalid values take a deterministic non-converged or invalid path while true zero norms still converge.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100