Skip to content

fix: five critical and moderate bugs in wall model, radiation solver, file parsing, and security#2636

Merged
pcarruscag merged 13 commits intosu2code:developfrom
shbhmexe:fix/solver-stability-security
Dec 23, 2025
Merged

fix: five critical and moderate bugs in wall model, radiation solver, file parsing, and security#2636
pcarruscag merged 13 commits intosu2code:developfrom
shbhmexe:fix/solver-stability-security

Conversation

@shbhmexe
Copy link

@shbhmexe shbhmexe commented Dec 4, 2025

Summary

This PR improves numerical robustness in the wall-model heat-flux/shear-stress calculations by avoiding divide-by-(near)-zero behavior in convergence checks and guarding an exponential evaluation. No algorithmic/model changes beyond defensive numerical safeguards.

Changes / Bugs fixed

1) Wall model convergence robustness (Common/src/wall_model.cpp)

  • Issue: Ratio-based convergence checks (1 - tauWall/tauWall_prev, 1 - qWall/qWall_prev) can produce NaN/Inf or unstable behavior when previous values are zero/near-zero.
  • Fix: Switch to an absolute/relative convergence check with an EPS floor:
    • abs(tauWall - tauWall_prev) < max(tol*abs(tauWall), EPS)
    • abs(qWall - qWall_prev) < max(tol*abs(qWall), EPS)
  • Impact: More stable convergence detection; avoids division by zero on early iterations.

2) Wall model Gamma safeguard (Common/src/wall_model.cpp)

  • Issue: exp(1.0/Gamma) can overflow / produce NaN/Inf when Gamma approaches 0.
  • Fix: Guard the denominator using exp(1.0 / fmin(Gamma, -EPS)) (Gamma is expected to be negative).
  • Impact: Prevents numerical blow-ups in heat-flux evaluation.

Non-functional changes

  • SU2_CFD/src/solvers/CRadP1Solver.cpp: comment indentation only (no behavior change).
  • SU2_CFD/src/solvers/CSolver.cpp: whitespace-only change around an existing TODO comment (no behavior change).

Testing

  • Not run locally (small, defensive numerical changes). CI/regression should cover.

Checklist

  • Minimal, targeted changes
  • No new dependencies
  • Backward compatible behavior (only improved numerical safeguards)

@shbhmexe
Copy link
Author

shbhmexe commented Dec 4, 2025

/label bug

pcarruscag and others added 2 commits December 4, 2025 16:13
…clauses

fix: Replace bare except clauses with specific exception types in Python utilities
Signed-off-by: shbhmexe <[email protected]>
Fixed three critical division by zero bugs, two moderate bugs, and
resolved code formatting issues:

1. Wall model convergence - zero-check before division
2. Wall model Gamma - epsilon check for exp(1/Gamma)
3. Radiation emissivity - clamp to [0,1] range
4. Restart metadata - correct ITER= offset 95
5. Filename buffer - replace strcpy with strncpy

Formatting Fixes:
- CSolver.cpp: Removed space before parentheses
- CRadP1Solver.cpp: Converted single-line ifs to block style
- wall_model.cpp & CPhysicalGeometry.cpp: Verified indentation

Improves solver stability, correctness, security, and code style.

Signed-off-by: shbhmexe <[email protected]>
Wall model (wall_model.cpp):
- Use fmax(x, 1e-16) in denominator for convergence check
- Use fmin(Gamma, -1e-16) in exp denominator (Gamma is always negative)

Reverted changes per reviewer request:
- CPhysicalGeometry.cpp: Revert to original strcpy (don't complicate)
- CSolver.cpp: Revert ITER offset to 9 (original author had reason)
- CRadP1Solver.cpp: Remove emissivity validation (should be in CConfig)

Signed-off-by: shbhmexe <[email protected]>
shbhmexe added 2 commits December 17, 2025 18:04
Common: use EPS when clamping Gamma in wall model

Signed-off-by: shbhmexe <[email protected]>
@pcarruscag
Copy link
Member

Update the PR description please.

@shbhmexe
Copy link
Author

Update the PR description please.

Sure, I’ll update the PR description right now to reflect all the changes made so far and ensure it matches the current final state.

@pcarruscag pcarruscag merged commit fc3538b into su2code:develop Dec 23, 2025
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants