@@ -118,21 +118,31 @@ void CTurbSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfig*
118118 Read_SU2_Restart_ASCII (geometry[MESH_0], config, restart_filename);
119119 }
120120
121- /* --- Skip flow variables ---*/
121+ /* --- Identify turbulence variable names based on the model ---*/
122+ vector<string> varNames (nVar);
122123
123- unsigned short skipVars = nDim + solver[MESH_0][FLOW_SOL]->GetnVar ();
124-
125- /* --- Adjust the number of solution variables in the incompressible
126- restart. We always carry a space in nVar for the energy equation in the
127- mean flow solver, but we only write it to the restart if it is active.
128- Therefore, we must reduce skipVars here if energy is inactive so that
129- the turbulent variables are read correctly. ---*/
124+ const auto kind_turb_model = config->GetKind_Turb_Model ();
125+ if (kind_turb_model == TURB_MODEL::SA) {
126+ if (nVar > 0 ) varNames[0 ] = " Nu_Tilde" ;
127+ }
128+ else if (kind_turb_model == TURB_MODEL::SST) {
129+ if (nVar > 0 ) varNames[0 ] = " Turb_Kin_Energy" ;
130+ if (nVar > 1 ) varNames[1 ] = " Omega" ;
131+ }
132+ /* --- Add other turbulence models as needed ---*/
130133
131- const bool incompressible = (config->GetKind_Regime () == ENUM_REGIME::INCOMPRESSIBLE);
132- const bool energy = config->GetEnergy_Equation ();
133- const bool weakly_coupled_heat = config->GetWeakly_Coupled_Heat ();
134+ /* --- Find indices for all turbulence variables at once ---*/
135+ vector<int > field_indices = FindFieldIndices (varNames);
134136
135- if (incompressible && ((!energy) && (!weakly_coupled_heat))) skipVars--;
137+ /* --- Warn if any fields are missing (Master node only) ---*/
138+ if (rank == MASTER_NODE) {
139+ for (unsigned short iVar = 0 ; iVar < nVar; ++iVar) {
140+ if (field_indices[iVar] == -1 && !varNames[iVar].empty ()) {
141+ cout << " WARNING: " << varNames[iVar] << " field not found in restart file. "
142+ << " Using initialized default.\n " ;
143+ }
144+ }
145+ }
136146
137147 /* --- Load data from the restart into correct containers. ---*/
138148
@@ -147,8 +157,12 @@ void CTurbSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfig*
147157 /* --- We need to store this point's data, so jump to the correct
148158 offset in the buffer of data from the restart file and load it. ---*/
149159
150- const auto index = counter * Restart_Vars[1 ] + skipVars;
151- for (auto iVar = 0u ; iVar < nVar; iVar++) nodes->SetSolution (iPoint_Local, iVar, Restart_Data[index + iVar]);
160+ const auto baseIndex = counter * Restart_Vars[1 ];
161+ for (auto iVar = 0u ; iVar < nVar; iVar++) {
162+ if (field_indices[iVar] != -1 ) {
163+ nodes->SetSolution (iPoint_Local, iVar, Restart_Data[baseIndex + field_indices[iVar]]);
164+ }
165+ }
152166
153167 /* --- Increment the overall counter for how many points have been loaded. ---*/
154168 counter++;
@@ -166,6 +180,7 @@ void CTurbSolver::LoadRestart(CGeometry** geometry, CSolver*** solver, CConfig*
166180 } // end safe global access, pre and postprocessing are thread-safe.
167181 END_SU2_OMP_SAFE_GLOBAL_ACCESS
168182
183+
169184 /* --- MPI solution and compute the eddy viscosity ---*/
170185
171186 solver[MESH_0][TURB_SOL]->InitiateComms (geometry[MESH_0], config, MPI_QUANTITIES::SOLUTION);
0 commit comments