Fix: Prevent zero-division in Cp calculation for zero free-stream velocity by ayush4874 · Pull Request #2666 · su2code/SU2
Problem
The Pressure Coefficient (Cp) calculation currently divides by ReferenceDynamicPressure without checking if it is zero.
This causes NaN values or crashes when:
- The reference velocity is set to 0.0 (e.g., in moving reference frame simulations).
- The user inadvertently sets zero free-stream values.
Solution
Added a safety check for GetReferenceDynamicPressure() in:
CFlowCompOutput.cpp(Compressible)CFlowIncOutput.cpp(Incompressible)CNEMOCompOutput.cpp(NEMO / Hypersonic)
If the dynamic pressure is effectively zero (abs < 1e-10), the Cp output defaults to 0.0 instead of performing the division.