Skip to content

Refactor of the NEMO solvers: shared helpers and removal of unreachable code - #2973

Open
rois1995 wants to merge 9 commits into
su2code:developfrom
rois1995:refactor_NEMO
Open

rois1995 wants to merge 9 commits into
su2code:developfrom
rois1995:refactor_NEMO

Conversation

@rois1995

Copy link
Copy Markdown
Contributor

Proposed Changes

A clean-up of the two NEMO solver classes (CNEMOEulerSolver, CNEMONSSolver). It changes no result and adds no feature.

  • Removes code that could never run. BC_Inlet and BC_HeatFluxCatalytic_Wall start with a "not operational" error, so the rest of their bodies was dead. Commented-out blocks are removed too.
  • Replaces copied blocks with six small helpers, for the data passed to the numerics, the viscous flux at a boundary, and the velocity and energy treatment of the walls.
  • Uses fixed-size local arrays where boundary conditions allocated memory at every call.
  • Shares the reference values with CEulerSolver through one function in CFVMFlowSolverBase. This is the only change outside NEMO; it is one commit (222b7b64d4) and can be split off if you prefer.

The two NEMO solver files go from 3,404 to 2,728 lines.

Why it helps. The copies had drifted apart over time, and a correction made in one was missing in the others. With one helper per task, a fix is made once.

Why not build NEMO on CScalarSolver. I looked at this first. The scalar solver runs after the flow solver, as a separate system. In NEMO the pressure depends on the composition and the chemistry is stiff, so species, energy and flow are solved together on purpose. Splitting them would be a rewrite that changes every NEMO result, so I kept the coupled solver.

Checks, against develop built on the same machine: identical values for the 14 NEMO regression cases, for three extra NEMO cases (heat-flux wall, slip wall, viscous supersonic inlet) and for six standard compressible cases covering all REF_DIMENSIONALIZATION options. The NEMO unit tests pass. No warnings with --warnlevel=3 in the changed files, also in the AD configuration. Not checked: runs with Mutation++, OpenMP or AD.

Related Work

This is only the refactoring. While reading the code I collected a list of bugs and possible improvements in NEMO. None is addressed here on purpose: they will come in separate pull requests, grouped by area of the code, so that a change of results is never mixed with a change of structure. Where the old code had a defect, this pull request keeps the old behavior.

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L7oxzVir4zENrpy3K3W6Fm

rois1995 and others added 9 commits October 12, 2026 11:33
Delete the disabled viscous blocks in BC_Inlet and BC_Outlet, the disabled
chemistry source block and the leftover species loop in the heat-flux wall,
and the unused turbulent kinetic energy lines. No functional change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7oxzVir4zENrpy3K3W6Fm
The block that passes dPdU, dTdU, dTvedU, Eve, Cvve and Gamma of two points
to a numerics object was repeated in the centered, upwind, viscous and
boundary loops. Replace the nine copies by one helper in CNEMOEulerSolver.

The helper always sets Gamma. BC_Supersonic_Inlet did not set it before, so
the AUSM+-up2 and AUSM+M schemes read the value of a previous call there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7oxzVir4zENrpy3K3W6Fm
Add SetWallVelocity_Strong and SetWallEnergyFlux_Weak to CNEMONSSolver and
use them in the heat-flux, isothermal and Smoluchowski-Maxwell walls, which
repeated the same statements.

Reduce BC_HeatFluxCatalytic_Wall to its error message. The code after the
error could not run and had no catalytic contribution. Remove the unused
GradY array of the catalytic isothermal wall. No functional change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7oxzVir4zENrpy3K3W6Fm
Keep the behavior of the code before the helper was added: only the call
sites that passed Gamma to the numerics before still do it, with their own
SetGamma call. The helper passes dPdU, dTdU, dTvedU, Eve and Cvve.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7oxzVir4zENrpy3K3W6Fm
Add SetNumericsTransportState and AddViscousBoundaryResidual to
CNEMOEulerSolver. BC_Far_Field and BC_Supersonic_Inlet had the same viscous
block, and Viscous_Residual repeated the transport property calls.

Reduce BC_Inlet to its error message. The code after the error could not
run. No functional change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7oxzVir4zENrpy3K3W6Fm
BC_Outlet and the isothermal walls allocated and freed their work arrays
with new and delete at every call. Use static arrays of size MAXNVAR and
MAXNDIM. The Jacobian and the unit normal of the isothermal wall are now
local to each vertex of the loop. No functional change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7oxzVir4zENrpy3K3W6Fm
CEulerSolver and CNEMOEulerSolver computed the reference values and the
non-dimensional free-stream values with the same statements in their
SetNondimensionalization. Move them to SetCompressibleNonDimValues in
CFVMFlowSolverBase. Each solver keeps the values that are specific to it
(vib.-el. temperature for NEMO; conductivity, specific heat, ReThetaT and
mass diffusivity for the ideal gas solver). No functional change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7oxzVir4zENrpy3K3W6Fm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7oxzVir4zENrpy3K3W6Fm
Use GeometryToolbox::Norm for the non-dimensional velocity magnitude, wrap
two lines longer than 120 characters, shorten three comments, and drop the
val_ prefix from the arguments of the two wall helpers so that all the new
helpers use the same naming. No functional change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L7oxzVir4zENrpy3K3W6Fm

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant