@@ -218,15 +218,15 @@ void CHeatSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container,
218218
219219void CHeatSolver::Postprocessing (CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { }
220220
221- void CHeatSolver::LoadRestart (CGeometry **geometry, CSolver ***solver, CConfig *config, int val_iter, bool val_update_geo) {
222-
221+ void CHeatSolver::LoadRestart (CGeometry **geometry, CSolver ***solver, CConfig *config, int val_iter,
222+ bool val_update_geo) {
223223 /* --- Restart the solution from file information ---*/
224224
225- string restart_filename = config->GetFilename (config->GetSolution_FileName (), " " , val_iter);
225+ const string restart_filename = config->GetFilename (config->GetSolution_FileName (), " " , val_iter);
226226
227227 /* --- Skip coordinates ---*/
228228
229- unsigned short skipVars = geometry[MESH_0]-> GetnDim () ;
229+ unsigned short skipVars = nDim ;
230230
231231 if (flow) {
232232 // P, vx, vy (,vz)
@@ -243,38 +243,31 @@ void CHeatSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *
243243 }
244244
245245 /* --- Load data from the restart into correct containers. ---*/
246- long iPoint_Local = 0 ;
247- unsigned long iPoint_Global_Local = 0 ;
248246 unsigned long counter = 0 ;
249- su2double Solution[MAXNVAR];
250247 for (auto iPoint_Global = 0ul ; iPoint_Global < geometry[MESH_0]->GetGlobal_nPointDomain (); iPoint_Global++ ) {
251248
252249 /* --- Retrieve local index. If this node from the restart file lives
253250 on the current processor, we will load and instantiate the vars. ---*/
254251
255- iPoint_Local = geometry[MESH_0]->GetGlobal_to_Local_Point (iPoint_Global);
252+ const auto iPoint_Local = geometry[MESH_0]->GetGlobal_to_Local_Point (iPoint_Global);
256253
257254 if (iPoint_Local > -1 ) {
258-
259255 /* --- We need to store this point's data, so jump to the correct
260256 offset in the buffer of data from the restart file and load it. ---*/
261257
262- auto index = counter*Restart_Vars[1 ] + skipVars;
263- for (auto iVar = 0u ; iVar < nVar; iVar++) Solution[iVar] = Restart_Data[index+iVar];
264- nodes->SetSolution (iPoint_Local,Solution);
265- iPoint_Global_Local++;
258+ const auto index = counter*Restart_Vars[1 ] + skipVars;
259+ for (auto iVar = 0u ; iVar < nVar; iVar++) nodes->SetSolution (iPoint_Local, iVar, Restart_Data[index + iVar]);
266260
267261 /* --- Increment the overall counter for how many points have been loaded. ---*/
268262 counter++;
269263 }
270-
271264 }
272265
273266 /* --- Detect a wrong solution file ---*/
274267
275- if (iPoint_Global_Local != nPointDomain) {
276- SU2_MPI::Error (string (" The solution file " ) + restart_filename + string (" doesn't match with the mesh file!\n " ) +
277- string (" It could be empty lines at the end of the file." ), CURRENT_FUNCTION);
268+ if (counter != nPointDomain) {
269+ SU2_MPI::Error (string (" The solution file " ) + restart_filename + string (" does not match with the mesh file!\n " ) +
270+ string (" This can be caused by empty lines at the end of the file." ), CURRENT_FUNCTION);
278271 }
279272
280273 /* --- Communicate the loaded solution on the fine grid before we transfer
@@ -288,31 +281,37 @@ void CHeatSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *
288281 solver[MESH_0][HEAT_SOL]->Preprocessing (geometry[MESH_0], solver[MESH_0], config, MESH_0, NO_RK_ITER, RUNTIME_HEAT_SYS, false );
289282
290283 /* --- Interpolate the solution down to the coarse multigrid levels ---*/
284+
291285 for (auto iMesh = 1u ; iMesh <= config->GetnMGLevels (); iMesh++) {
286+
292287 for (auto iPoint = 0ul ; iPoint < geometry[iMesh]->GetnPoint (); iPoint++) {
293- const auto Area_Parent = geometry[iMesh]->nodes ->GetVolume (iPoint);
294- for (auto iVar = 0u ; iVar < nVar; iVar++) Solution[iVar] = 0.0 ;
288+ const su2double Area_Parent = geometry[iMesh]->nodes ->GetVolume (iPoint);
289+ su2double Solution_Coarse[MAXNVAR] = {0.0 };
290+
295291 for (auto iChildren = 0ul ; iChildren < geometry[iMesh]->nodes ->GetnChildren_CV (iPoint); iChildren++) {
296292 const auto Point_Fine = geometry[iMesh]->nodes ->GetChildren_CV (iPoint, iChildren);
297- const auto Area_Children = geometry[iMesh-1 ]->nodes ->GetVolume (Point_Fine);
298- const auto Solution_Fine = solver[iMesh-1 ][HEAT_SOL]->GetNodes ()->GetSolution (Point_Fine);
293+ const su2double Area_Children = geometry[iMesh - 1 ]->nodes ->GetVolume (Point_Fine);
294+ const su2double* Solution_Fine = solver[iMesh - 1 ][HEAT_SOL]->GetNodes ()->GetSolution (Point_Fine);
295+
299296 for (auto iVar = 0u ; iVar < nVar; iVar++) {
300- Solution [iVar] += Solution_Fine[iVar]* Area_Children/ Area_Parent;
297+ Solution_Coarse [iVar] += Solution_Fine[iVar] * Area_Children / Area_Parent;
301298 }
302299 }
303- solver[iMesh][HEAT_SOL]->GetNodes ()->SetSolution (iPoint,Solution );
300+ solver[iMesh][HEAT_SOL]->GetNodes ()->SetSolution (iPoint,Solution_Coarse );
304301 }
302+
305303 solver[iMesh][HEAT_SOL]->InitiateComms (geometry[iMesh], config, SOLUTION);
306304 solver[iMesh][HEAT_SOL]->CompleteComms (geometry[iMesh], config, SOLUTION);
305+
307306 solver[iMesh][HEAT_SOL]->Preprocessing (geometry[iMesh], solver[iMesh], config, iMesh, NO_RK_ITER, RUNTIME_HEAT_SYS, false );
308307 }
309308
310309 /* --- Delete the class memory that is used to load the restart. ---*/
311310
312- delete [] Restart_Vars;
313- delete [] Restart_Data ;
314- Restart_Vars = nullptr ; Restart_Data = nullptr ;
315-
311+ delete[] Restart_Vars;
312+ Restart_Vars = nullptr ;
313+ delete[] Restart_Data;
314+ Restart_Data = nullptr ;
316315}
317316
318317void CHeatSolver::Centered_Residual (CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container,
0 commit comments