fix NaN assertions that never fired due to IEEE 754 NaN comparison#1875
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request replaces incorrect != NAN comparisons with std::isfinite() checks in testParticleSink.cpp and radiation_system.hpp to properly handle NaN values. A review comment suggests using AMREX_ALWAYS_ASSERT_WITH_MESSAGE for input validation in testParticleSink.cpp to ensure the check remains active in release builds.
BenWibking
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix debug assertions that silently passed even when variables held NaN values, due to incorrect use of relational operators with
NAN.In IEEE 754,
NaN != NaNalways evaluates totrue, soAMREX_ASSERT(x != NAN)andAMREX_ASSERT_WITH_MESSAGE(x != NAN, ...)are no-ops — they never fire regardless of whetherxis NaN. Two sites were affected:RadSystem::ComputeRadPressureinsrc/radiation/radiation_system.hpp: four assertions onFn,Tnx,Tny,Tnzthat guard against uninitialized flux/pressure-tensor components.problem_maininsrc/problems/ParticleSink/testParticleSink.cpp: one assertion thatboost_vel_xwas actually read from the input file.Both sites are replaced with
std::isfinite(value), which correctly returnsfalsefor NaN and infinity.Related issues
Fixes #1857.
Checklist
Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an
xinside the square brackets[ ]in the Markdown source below:/azp run.