fix(SU2_CFD,SU2_PY,Common): Fix typos, code style, and safety guards by shbhmexe · Pull Request #2660 · su2code/SU2

Proposed Changes

This PR addresses code quality issues across the SU2 codebase:

Typo Fixes (Comment-only)

  1. "approxiations" → "approximations" in 5 C++ solver files
  2. "generilize" → "generalize" in CEulerSolver.cpp (4 occurrences)

Python Code Style (PEP8)

  1. Replace type(x) == list with isinstance(x, list) in gradients.py and functions.py

C++ Safety Improvements

  1. Add zero-distance guard in CHeatSolver.cpp (lines 640, 671)

    • Changed /dist to /fmax(dist, EPS) to prevent potential division by zero
  2. Remove redundant 1.0* multiplication in CRadP1Solver.cpp (lines 323, 397)

C++ Bug Fixes (Common)

  1. Fix float literal in CSysMatrix.cpp (line 160)

    • Changed (nPointDomain + 1.0) to (nPointDomain + 1) for GPU array allocation
    • Using float for array sizing is incorrect type usage
  2. Remove redundant 1.0* in wall_model.cpp (line 374)

Related Work

No related issues. This is a cleanup PR to improve code quality and robustness.

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings.
  • My contribution is commented and consistent with SU2 style.
  • I used the pre-commit hook to prevent dirty commits.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation, if necessary.

Impact

  • Typo fixes: No functional changes (comment-only)
  • Python style: Functionally equivalent, follows PEP8
  • CHeatSolver.cpp: Adds safety for edge cases
  • CSysMatrix.cpp: Fixes type correctness for GPU memory allocation
  • CRadP1Solver.cpp & wall_model.cpp: Code cleanup