Skip to content

Conversation

@guptapratykshh
Copy link

Proposed Changes

Adds field-based lookup for restart files, allowing SU2 to restart when required fields are missing (e.g., enabling the energy equation or turbulence model after an initial run without them). Missing fields are initialized from config defaults (e.g., temperature from INC_TEMPERATURE_INIT), with warnings. Maintains backward compatibility with standard restart files.
Key Implementation:

  • Added FindFieldIndex() helper function to CSolver base class for field-based lookup
  • Refactored CFVMFlowSolverBase::LoadRestart() to use field-based lookup instead of fixed offsets
  • Updated CTurbSolver::LoadRestart() to handle missing turbulence variables
  • Supports both incompressible and compressible flows, as well as turbulence models

Related Work

Resolves #2483

Issue Description:

SU2 crashed when restarting a simulation with restart files that did not contain all necessary fields. For example, running an incompressible flow simulation without the energy equation, then enabling the energy equation, or enabling a turbulence model after an initial run without it.

  • Modified 4 core solver files to implement field-based restart loading
  • Added error handling and user warnings
  • Maintains full backward compatibility with existing restart files

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.

@pcarruscag pcarruscag changed the base branch from master to develop January 3, 2026 18:35
Comment on lines 922 to 931
/*--- Load Pressure (index 0) ---*/
if (fieldIdx_Pressure >= 0) {
solutionBuffer[0] = Restart_Data[baseIndex + fieldIdx_Pressure];
} else {
/*--- Use default from config ---*/
solutionBuffer[0] = config->GetPressure_FreeStreamND();
if (rank == MASTER_NODE && counter == 0) {
cout << "WARNING: Pressure field not found in restart file, using config default." << endl;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the solver already have the default initialization when we load the restart?
If so, can we use the solution that is already in the solver nodes instead of repeating the logic for initialization?

If there is physics-specific logic required (incompressible, compressible, NEMO) it should be implemented in the respective solvers using e.g. a virtual function or static polymorphism based on the ENUM_REGIME template parameter of this class, instead of these long if/else blocks.

The names of the variables need to be in sync with those used for output. Therefore, they should be defined as constants and used in both places (output class and here).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. I have updated implementation:

  • Defaults: Verified that nodes are pre-initialized. I removed the redundant default initialization logic, missing fields now simply preserve the existing values in the solver nodes.
  • Polymorphism: Refactored LoadRestartSolutionFields to use if constexpr on the ENUM_REGIME template parameter, ensuring clean static separation of physics logic.
  • Constants: Introduced a RestartFieldNames namespace to ensure field names are consistent and defined in one place.

@guptapratykshh guptapratykshh force-pushed the feature/restart-missing-fields-2483 branch from 8488024 to 6f1f9ab Compare January 4, 2026 08:16
@bigfooted
Copy link
Contributor

Nice! Can you add a testcase to the regressions (Testcases/parallel_regression.py + new config file), for instance one of the flat plate SA testcases or some testcase that already uses a restart file, and restart with SST instead?

@guptapratykshh
Copy link
Author

Added the requested regression test (turb_SST_flatplate_restart) to parallel_regression.py , which restarts an SA solution using the SST model. This verifies that missing turbulence fields are correctly initialized from defaults.

Comment on lines 2714 to 2814
SurfaceViscCoeff.CEff[iMarker_Monitoring] = SurfaceViscCoeff.CL[iMarker_Monitoring] / (SurfaceViscCoeff.CD[iMarker_Monitoring] + EPS);
SurfaceViscCoeff.CEff[iMarker_Monitoring] =
SurfaceViscCoeff.CL[iMarker_Monitoring] / (SurfaceViscCoeff.CD[iMarker_Monitoring] + EPS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert all formatting changes to this file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

turb_SST_flatplate_restart.cfg_dir = "rans/flatplate"
turb_SST_flatplate_restart.cfg_file = "turb_SST_flatplate_restart.cfg"
turb_SST_flatplate_restart.test_iter = 10
turb_SST_flatplate_restart.test_vals = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot possibly test correctness if it doesn't have values

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Keep only functional changes for field-based restart loading.
No formatting changes - file now has clean diff against upstream.
Remove multiple spaces before assignment operators to comply with PEP8.
Comment on lines +1 to +2
SOLVER= RANS
KIND_TURB_MODEL= SA
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How was the restart file made? Which missing variables are tested here?

Copy link
Author

@guptapratykshh guptapratykshh Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The restart file is generated by euler_NACA0012_precursor.cfg (EULER solver) which outputs restart_flow_euler.dat containing only flow fields (Density, Momentum, Energy) but no turbulence variables.

The test then restarts using turb_SA_restart_test.cfg (RANS/SA solver) which loads this Euler restart file via SOLUTION_FILENAME= restart_flow_euler.dat.

Missing variable tested: Nu_Tilde (SA turbulence working variable) - which is absent in the Euler restart file.

The fix initializes the missing Nu_Tilde from freestream defaults (Solution_Inf), allowing successful Euler→RANS restart.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restart with missing fields

3 participants