fix(su2): CRLF crashes, FFD/NPERIODIC warning spam, and point column trim - #1552
Open
AhmedMoustafaa wants to merge 1 commit into
Open
fix(su2): CRLF crashes, FFD/NPERIODIC warning spam, and point column trim#1552AhmedMoustafaa wants to merge 1 commit into
AhmedMoustafaa wants to merge 1 commit into
Conversation
AhmedMoustafaa
marked this pull request as draft
March 22, 2026 15:52
CRLF line endings caused np.fromfile to stop reading early, crashing 4 meshes with a reshape error. FFD box sections and NPERIODIC blocks contain bare data lines with no "=" sign, generating up to 60,000 spurious warnings per mesh. UnboundLocalError when NPOIN section is absent was also fixed. Replace np.fromfile with line-by-line reading to handle CRLF, skip data lines under FFD_CORNER_POINTS, FFD_CONTROL_POINTS, FFD_SURFACE_POINTS, and NPERIODIC sections, and initialize points to an empty array as a safe default. Tested on all 50 SU2 v8 tutorial meshes: - Failures: 4 -> 0 - Total warnings: 134,634 -> 454
AhmedMoustafaa
force-pushed
the
fix-su2-crlf-periodic
branch
from
March 22, 2026 16:02
4c6fe6f to
97619f5
Compare
AhmedMoustafaa
marked this pull request as ready for review
March 22, 2026 16:03
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.
Fix SU2 reader: CRLF line endings, double-trim bug, NPERIODIC and FFD sections
Summary
This PR fixes four bugs in the SU2 mesh reader that together caused 4 crashes and
134,634 spurious warnings when reading SU2 v7/v8 tutorial meshes. After the patch,
all 50 tutorial meshes load successfully with only 454 expected warnings (string tag
substitutions).
Fixes
1. CRLF line endings crash the point coordinate reader
Affected files: any SU2 mesh generated on Windows or by certain solvers (e.g.
CIRA, commercial CFD exporters).
np.fromfile(..., sep=' ')uses C-level I/O and bypasses Python's text-mode\r\n → \ntranslation. On CRLF files, the\rcharacters are treated asnon-numeric tokens and stop the read early, producing a reshape error:
This crashed 4 meshes in the tutorial suite:
All four have 100% CRLF line endings. The fix replaces
np.fromfilewith explicitline-by-line reading, which is handled correctly by Python's text mode:
2. Double-trimming of extra point columns
This bug was introduced alongside the CRLF fix. After switching to line-by-line
reading with
[:dim]slicing,pointsalready has exactlydimcolumns.The subsequent
points[:, :-extra_columns]then incorrectly trims real coordinatedata. Fix: remove the redundant column trim from
points; keep it only onfirst_linewhich is still built from the full-width raw line:3. NPERIODIC section causes spurious warnings
SU2 turbomachinery meshes (e.g. propeller, compressor cases) append a
NPERIODICblock after the boundary markers. Its data lines contain no
=sign, so the mainparser loop emitted a warning for each one:
Fix: explicitly skip the data lines following
NPERIODICandPERIODIC_INDEX:4. FFD box sections cause massive warning spam
SU2 shape optimisation meshes embed Free-Form Deformation (FFD) box definitions
between the mesh header and the element data. Three sub-sections —
FFD_CORNER_POINTS,FFD_CONTROL_POINTS, andFFD_SURFACE_POINTS— each havea count followed by bare data lines with no
=sign. The parser emitted a warningfor every single line, producing tens of thousands of spurious warnings per mesh:
Fix: skip the N data lines following each of the three keywords:
Note: other
FFD_*keywords (FFD_TAG,FFD_DEGREE_I/J/K,FFD_LEVEL,FFD_PARENTS,FFD_CHILDREN) have their value on the keyword line itself and arealready silently handled by the generic
split("=")fallthrough — no change neededfor those.
Per-file impact
compressible_flow/Inviscid_ONERAM6/mesh_ONERAM6_inv_ffd.su2design/Inviscid_3D_Constrained_ONERAM6/mesh_ONERAM6_inv_FFD.su2design/Inc_Turbulent_Bend_Wallfunctions/sudo_coarse_FFD.su2multiphysics/steady_cht/mesh_cht_3cyl_ffd.su2design/Unsteady_Shape_Opt_NACA0012/unsteady_naca0012_FFD.su2incompressible_flow/Inc_Streamwise_Periodic/fluid_FFD.su2design/Multi_Objective_Shape_Design/mesh_wedge_inv_FFD.su2incompressible_flow/Inc_Species_Transport/1__FFD-box-writing/mesh_out.su2incompressible_flow/Inc_Species_Transport/2__mesh-deform-test/primitiveVenturi.su2incompressible_flow/Inc_Species_Transport/3__gradient-validation/primitiveVenturi.su2incompressible_flow/Inc_Species_Transport/4__optimization/primitiveVenturi.su2compressible_flow/Turbulent_ONERAM6/mesh_ONERAM6_turb_hexa_43008.su2compressible_flow/Turbulent_ONERAM6/mesh_ONERAM6_100k.su2structural_mechanics/cantilever/mesh_cantilever.su2multiphysics/unsteady_fsi_python/airfoil.su2compressible_flow/ActuatorDisk_VariableLoad/propeller_variable_load.su2compressible_flow/Transitional_Flat_Plate/Langtry_and_Menter/T3A/grid.su2compressible_flow/Transitional_Flat_Plate/grid.su2Remaining warnings (454 total)
All remaining warnings are expected and pre-existing — meshio does not support
string boundary tags and substitutes integers:
These are a separate issue unrelated to this PR.
Test setup
Tested against all 50
.su2mesh files from theSU2 v8.0 tutorial repository covering
compressible flow, incompressible flow, multiphysics, structural mechanics, and
shape design cases.