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)
- "approxiations" → "approximations" in 5 C++ solver files
- "generilize" → "generalize" in
CEulerSolver.cpp(4 occurrences)
Python Code Style (PEP8)
- Replace
type(x) == listwithisinstance(x, list)ingradients.pyandfunctions.py
C++ Safety Improvements
-
Add zero-distance guard in
CHeatSolver.cpp(lines 640, 671)- Changed
/distto/fmax(dist, EPS)to prevent potential division by zero
- Changed
-
Remove redundant
1.0*multiplication inCRadP1Solver.cpp(lines 323, 397)
C++ Bug Fixes (Common)
-
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
- Changed
-
Remove redundant
1.0*inwall_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