Fix NEMO history MAX_/BGS_ residual groups: species-first indexing and finite maximum residuals - #2882
Open
bellonarts wants to merge 2 commits into
Open
Conversation
…d finite maximum residuals The NEMO solution vector is species-first, but CNEMOCompOutput wrote the MAX_RES and BGS_RES history groups with calorically-perfect indexing: max[RhoV] read Res_Max(2), which is the residual of species 2, and the momentum, energy, and vibrational-electronic maxima were never written at all. Register and load both groups with the same species-first layout as RMS_RES (max[Rho_0..n], max[RhoU], max[RhoV], max[RhoW], max[RhoE], max[RhoEve]; likewise bgs[*]). Res_Max and Res_Max_BGS also had no floor, unlike the EPS^2 floor applied to the RMS reductions in CSolver::SetResidual_RMS, so an exactly-zero residual, for example an inert trace species at a cold start, printed a literal "-inf" into history.csv and the screen table, breaking numeric consumers of the history file. Floor both maxima at EPS^2, matching the RMS convention (log10 floor of -32). Verified on a cold-start AIR-5 NEMO case: the pre-fix max[Rho], max[RhoU], and max[RhoE] values reappear bit-identically as max[Rho_0], max[Rho_1], and max[Rho_4]; the inert-species -inf cell prints -32; the newly written momentum and energy maxima satisfy max >= rms; every previously existing non-max column is bit-identical. The compressible QuickStart history is byte-identical before and after the fix. GetRes_Max has no in-tree consumer besides the log10 output sites. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Exercise species-first MAX/BGS output in 2D and 3D, the zero-MAX finite log floor, and the real multizone BGS load path. Remove the unused Residual_Max_BGS floor: BGS output reads Residual_BGS, which is already floored. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Proposed Changes
Two coupled defects in the NEMO history output, fixed in
SU2_CFD/src/output/CNEMOCompOutput.cppandSU2_CFD/src/solvers/CSolver.cpp. Please note the breaking change first: for NEMO solvers the history fieldsMAX_DENSITYandBGS_DENSITYare renamed to per-species fieldsMAX_DENSITY_0..._{nSpecies-1}/BGS_DENSITY_0..._{nSpecies-1}(screen and CSV headersmax[Rho_i]/bgs[Rho_i]), and the previously missingMAX_ENERGY_VE/BGS_ENERGY_VEfields are added. NEMO configs that nameMAX_DENSITYorBGS_DENSITYinCONV_FIELDorHISTORY_OUTPUTneed updating. The old names reported wrong data for NEMO, so keeping them compatible would preserve the defect. The compressible (non-NEMO) output classes and their field names are untouched.Defect 1: the MAX_RES and BGS_RES groups index the wrong variables. The NEMO solution vector is species-first (
rho_0..rho_{n-1}, rhoU, rhoV, [rhoW,] rhoE, rhoEve) and the RMS_RES group indexes it that way, but the MAX_RES and BGS_RES groups inCNEMOCompOutputused the calorically-perfect layout (GetRes_Max(0)as density,GetRes_Max(1)as x-momentum, and so on). For AIR-5 the column labeledmax[RhoV]is therefore the maximum residual of species 2, and the momentum, energy, and vibrational-electronic maxima are never written at all. This was verified bit-level on a cold-start AIR-5 case, where the pre-fixmax[Rho],max[RhoU], andmax[RhoE]values reappear identically as the post-fixmax[Rho_0],max[Rho_1], andmax[Rho_4]:max[Rho]max[Rho_0]max[RhoU]max[Rho_1]max[RhoV]max[Rho_2]max[RhoW]max[Rho_3]max[RhoE]max[Rho_4]max[RhoU]max[RhoV]max[RhoW]max[RhoE]max[RhoEve]Each newly written maximum satisfies
max[.] >= rms[.]for its variable, as it must for two reductions of the same residual vector. Fix: register and load MAX_RES and BGS_RES with the same species-first layout as RMS_RES.Defect 2: an exactly-zero maximum residual prints a literal
-inf.CSolver::SetResidual_RMSfloors the RMS reduction atEPS*EPS, but did not floorResidual_Max. A bitwise-zero residual, which is routine for an inert trace species at a cold start (zero freestream mass fraction, chemistry frozen at the cold freestream temperature), therefore reached the output aslog10(0)and SU2 wrote the token-infintohistory.csvand the screen table. That token breaks numeric consumers of the history file (CSV-to-float parsers, JSON pipelines withallow_nan=false, plotting tools). Fix: floorResidual_MaxatEPS*EPSimmediately after its global reduction, matching the RMS convention. BGS history readsResidual_BGS, which is already floored bySetResidual_BGS; the distinctResidual_Max_BGSstorage is not consumed by this output path and is intentionally unchanged.Neither change touches solver arithmetic. Verification:
GAS_COMPOSITIONwith three zero trace species), serial release build, 3 iterations. Pre-fix reproduces the defect exactly (max[RhoV]=-infpaired withrms[Rho_2]=-32). Post-fix: full 10-column max group, no nonfinite tokens, bit-level column mapping as tabled above, and all 32 non-max[*]columns (rms, forces, heat, CFL, linear solver, nonphysical points) bit-identical pre/post across all rows.inv_NACA0012.cfg, 160 iterations to convergence):history.csvbyte-identical pre/post.UnitTests/SU2_CFD/output/CNEMOCompOutput_tests.cpp: 183 assertions exercise 2-D and 3-D field registration and loading, every species-first MAX/BGS offset, a zero maximum through the realSetResidual_RMSreduction (finite-32), and the multizoneSetResidual_BGSpath throughLoadHistoryData.Related Work
No open issue or PR was found for either defect. The defect is present at v8.5.0 and on the develop tip. This PR is independent of the mass-fraction tolerance fix in #2880 and the interrupt-exit reporting fix in #2881; it changes NEMO history output only.
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.
pre-commit run --allto format old commits.