-
Notifications
You must be signed in to change notification settings - Fork 913
Fix #2483: Add field-based restart loading with missing field initialization #2675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Fix #2483: Add field-based restart loading with missing field initialization #2675
Conversation
| /*--- 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; | ||
| } | ||
| } |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
LoadRestartSolutionFieldsto use if constexpr on the ENUM_REGIME template parameter, ensuring clean static separation of physics logic. - Constants: Introduced a
RestartFieldNamesnamespace to ensure field names are consistent and defined in one place.
8488024 to
6f1f9ab
Compare
|
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? |
|
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. |
| 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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
TestCases/parallel_regression.py
Outdated
| 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 = [] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
| SOLVER= RANS | ||
| KIND_TURB_MODEL= SA |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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:
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.
PR Checklist
pre-commit run --allto format old commits.