@@ -718,139 +718,119 @@ void CFVMFlowSolverBase<V, R>::SetUniformInlet(const CConfig* config, unsigned s
718718}
719719
720720template <class V , ENUM_REGIME R>
721- void CFVMFlowSolverBase<V, R>::LoadRestart_impl(CGeometry **geometry, CSolver ***solver, CConfig *config,
722- int iter, bool update_geo, su2double* SolutionRestart,
721+ void CFVMFlowSolverBase<V, R>::LoadRestart_impl(CGeometry **geometry, CSolver ***solver, CConfig *config, int iter,
722+ bool update_geo, su2double* SolutionRestart,
723723 unsigned short nVar_Restart) {
724-
725724 /* --- Restart the solution from file information ---*/
726725
727- unsigned short iDim, iVar, iMesh;
728- unsigned long iPoint, index, iChildren, Point_Fine;
729- TURB_MODEL turb_model = config->GetKind_Turb_Model ();
730- su2double Area_Children, Area_Parent;
731- const su2double* Solution_Fine = nullptr ;
732- const passivedouble* Coord = nullptr ;
733- bool dual_time = ((config->GetTime_Marching () == TIME_MARCHING::DT_STEPPING_1ST) ||
734- (config->GetTime_Marching () == TIME_MARCHING::DT_STEPPING_2ND));
735- bool static_fsi = ((config->GetTime_Marching () == TIME_MARCHING::STEADY) && config->GetFSI_Simulation ());
736- bool steady_restart = config->GetSteadyRestart ();
737- bool turbulent = (config->GetKind_Turb_Model () != TURB_MODEL::NONE);
738-
739- string restart_filename = config->GetFilename (config->GetSolution_FileName (), " " , iter);
726+ const string restart_filename = config->GetFilename (config->GetSolution_FileName (), " " , iter);
727+ const bool static_fsi = ((config->GetTime_Marching () == TIME_MARCHING::STEADY) && config->GetFSI_Simulation ());
740728
741729 /* --- To make this routine safe to call in parallel most of it can only be executed by one thread. ---*/
742730 SU2_OMP_MASTER {
743731
744- if (nVar_Restart == 0 ) nVar_Restart = nVar;
732+ if (nVar_Restart == 0 ) nVar_Restart = nVar;
745733
746- /* --- Skip coordinates ---*/
734+ /* --- Skip coordinates ---*/
747735
748- unsigned short skipVars = geometry[MESH_0]-> GetnDim () ;
736+ unsigned short skipVars = nDim ;
749737
750- /* --- Store the number of variables for the turbulence model
751- (that could appear in the restart file before the grid velocities). ---*/
752- unsigned short turbVars = 0 ;
753- if (turbulent){
754- if ((turb_model == TURB_MODEL::SST) || (turb_model == TURB_MODEL::SST_SUST)) turbVars = 2 ;
755- else turbVars = 1 ;
756- }
738+ /* --- Read the restart data from either an ASCII or binary SU2 file. ---*/
757739
758- /* --- Read the restart data from either an ASCII or binary SU2 file. ---*/
759-
760- if (config->GetRead_Binary_Restart ()) {
761- Read_SU2_Restart_Binary (geometry[MESH_0], config, restart_filename);
762- } else {
763- Read_SU2_Restart_ASCII (geometry[MESH_0], config, restart_filename);
764- }
740+ if (config->GetRead_Binary_Restart ()) {
741+ Read_SU2_Restart_Binary (geometry[MESH_0], config, restart_filename);
742+ } else {
743+ Read_SU2_Restart_ASCII (geometry[MESH_0], config, restart_filename);
744+ }
765745
766- if (update_geo && dynamic_grid) {
767- auto notFound = fields.end ();
768- if (find (fields.begin (), notFound, string (" \" Grid_Velocity_x\" " )) == notFound) {
769- if (rank == MASTER_NODE)
770- cout << " \n WARNING: The restart file does not contain grid velocities, these will be set to zero.\n " << endl;
771- steady_restart = true ;
746+ bool steady_restart = config->GetSteadyRestart ();
747+ if (update_geo && dynamic_grid) {
748+ auto notFound = fields.end ();
749+ if (find (fields.begin (), notFound, string (" \" Grid_Velocity_x\" " )) == notFound) {
750+ if (rank == MASTER_NODE)
751+ cout << " \n WARNING: The restart file does not contain grid velocities, these will be set to zero.\n " << endl;
752+ steady_restart = true ;
753+ }
772754 }
773- }
774755
775- /* --- Load data from the restart into correct containers. ---*/
756+ /* --- Load data from the restart into correct containers. ---*/
776757
777- unsigned long counter = 0 , iPoint_Global = 0 ;
778- for (; iPoint_Global < geometry[MESH_0]->GetGlobal_nPointDomain (); iPoint_Global++) {
758+ unsigned long counter = 0 ;
759+ for (auto iPoint_Global = 0ul ; iPoint_Global < geometry[MESH_0]->GetGlobal_nPointDomain (); iPoint_Global++) {
779760
780- /* --- Retrieve local index. If this node from the restart file lives
781- on the current processor, we will load and instantiate the vars. ---*/
761+ /* --- Retrieve local index. If this node from the restart file lives
762+ on the current processor, we will load and instantiate the vars. ---*/
782763
783- auto iPoint_Local = geometry[MESH_0]->GetGlobal_to_Local_Point (iPoint_Global);
764+ const auto iPoint_Local = geometry[MESH_0]->GetGlobal_to_Local_Point (iPoint_Global);
784765
785- if (iPoint_Local > -1 ) {
766+ if (iPoint_Local > -1 ) {
786767
787- /* --- We need to store this point's data, so jump to the correct
788- offset in the buffer of data from the restart file and load it. ---*/
768+ /* --- We need to store this point's data, so jump to the correct
769+ offset in the buffer of data from the restart file and load it. ---*/
789770
790- index = counter* Restart_Vars[1 ] + skipVars;
771+ auto index = counter * Restart_Vars[1 ] + skipVars;
791772
792- if (SolutionRestart == nullptr ) {
793- for (iVar = 0 ; iVar < nVar_Restart; iVar++)
794- nodes->SetSolution (iPoint_Local, iVar, Restart_Data[index+iVar]);
795- }
796- else {
797- /* --- Used as buffer, allows defaults for nVar > nVar_Restart. ---*/
798- for (iVar = 0 ; iVar < nVar_Restart; iVar++)
799- SolutionRestart[iVar] = Restart_Data[index+ iVar];
800- nodes->SetSolution (iPoint_Local, SolutionRestart);
801- }
773+ if (SolutionRestart == nullptr ) {
774+ for (auto iVar = 0u ; iVar < nVar_Restart; iVar++)
775+ nodes->SetSolution (iPoint_Local, iVar, Restart_Data[index+iVar]);
776+ }
777+ else {
778+ /* --- Used as buffer, allows defaults for nVar > nVar_Restart. ---*/
779+ for (auto iVar = 0u ; iVar < nVar_Restart; iVar++)
780+ SolutionRestart[iVar] = Restart_Data[index + iVar];
781+ nodes->SetSolution (iPoint_Local, SolutionRestart);
782+ }
802783
803- /* --- For dynamic meshes, read in and store the
804- grid coordinates and grid velocities for each node. ---*/
784+ /* --- For dynamic meshes, read in and store the
785+ grid coordinates and grid velocities for each node. ---*/
805786
806- if (dynamic_grid && update_geo) {
787+ if (dynamic_grid && update_geo) {
807788
808- /* --- Read in the next 2 or 3 variables which are the grid velocities ---*/
809- /* --- If we are restarting the solution from a previously computed static calculation (no grid movement) ---*/
810- /* --- the grid velocities are set to 0. This is useful for FSI computations ---*/
789+ /* --- Read in the next 2 or 3 variables which are the grid velocities ---*/
790+ /* --- If we are restarting the solution from a previously computed static calculation (no grid movement) ---*/
791+ /* --- the grid velocities are set to 0. This is useful for FSI computations ---*/
811792
812- /* --- Rewind the index to retrieve the Coords. ---*/
813- index = counter*Restart_Vars[1 ];
814- Coord = &Restart_Data[index];
815-
816- su2double GridVel[MAXNDIM] = {0.0 };
817- if (!steady_restart) {
818- /* --- Move the index forward to get the grid velocities. ---*/
819- index += skipVars + nVar_Restart + turbVars;
820- for (iDim = 0 ; iDim < nDim; iDim++) { GridVel[iDim] = Restart_Data[index+iDim]; }
821- }
793+ /* --- Rewind the index to retrieve the Coords. ---*/
794+ index = counter * Restart_Vars[1 ];
795+ const auto * Coord = &Restart_Data[index];
822796
823- for (iDim = 0 ; iDim < nDim; iDim++) {
824- geometry[MESH_0]->nodes ->SetCoord (iPoint_Local, iDim, Coord[iDim]);
825- geometry[MESH_0]->nodes ->SetGridVel (iPoint_Local, iDim, GridVel[iDim]);
797+ su2double GridVel[MAXNDIM] = {0.0 };
798+ if (!steady_restart) {
799+ /* --- Move the index forward to get the grid velocities. ---*/
800+ index += skipVars + nVar_Restart + config->GetnTurbVar ();
801+ for (auto iDim = 0u ; iDim < nDim; iDim++) { GridVel[iDim] = Restart_Data[index+iDim]; }
802+ }
803+
804+ for (auto iDim = 0u ; iDim < nDim; iDim++) {
805+ geometry[MESH_0]->nodes ->SetCoord (iPoint_Local, iDim, Coord[iDim]);
806+ geometry[MESH_0]->nodes ->SetGridVel (iPoint_Local, iDim, GridVel[iDim]);
807+ }
826808 }
827- }
828809
829- /* --- For static FSI problems, grid_movement is 0 but we need to read in and store the
830- grid coordinates for each node (but not the grid velocities, as there are none). ---*/
810+ /* --- For static FSI problems, grid_movement is 0 but we need to read in and store the
811+ grid coordinates for each node (but not the grid velocities, as there are none). ---*/
831812
832- if (static_fsi && update_geo) {
833- /* --- Rewind the index to retrieve the Coords. ---*/
834- index = counter*Restart_Vars[1 ];
835- Coord = &Restart_Data[index];
813+ if (static_fsi && update_geo) {
814+ /* --- Rewind the index to retrieve the Coords. ---*/
815+ index = counter*Restart_Vars[1 ];
816+ const auto * Coord = &Restart_Data[index];
836817
837- for (iDim = 0 ; iDim < nDim; iDim++) {
838- geometry[MESH_0]->nodes ->SetCoord (iPoint_Local, iDim, Coord[iDim]);
818+ for (auto iDim = 0u ; iDim < nDim; iDim++) {
819+ geometry[MESH_0]->nodes ->SetCoord (iPoint_Local, iDim, Coord[iDim]);
820+ }
839821 }
840- }
841822
842- /* --- Increment the overall counter for how many points have been loaded. ---*/
843- counter++;
823+ /* --- Increment the overall counter for how many points have been loaded. ---*/
824+ counter++;
825+ }
844826 }
845827
846- }
847-
848- /* --- Detect a wrong solution file ---*/
828+ /* --- Detect a wrong solution file ---*/
849829
850- if (counter != nPointDomain) {
851- SU2_MPI::Error (string (" The solution file " ) + restart_filename + string (" doesn't match with the mesh file! \n " ) +
852- string (" It could be empty lines at the end of the file." ), CURRENT_FUNCTION);
853- }
830+ if (counter != nPointDomain) {
831+ SU2_MPI::Error (string (" The solution file " ) + restart_filename + string (" does not match with the mesh file. \n " ) +
832+ string (" This can be caused by empty lines at the end of the file." ), CURRENT_FUNCTION);
833+ }
854834 }
855835 END_SU2_OMP_MASTER
856836 SU2_OMP_BARRIER
@@ -862,10 +842,10 @@ void CFVMFlowSolverBase<V, R>::LoadRestart_impl(CGeometry **geometry, CSolver **
862842 CGeometry::UpdateGeometry (geometry, config);
863843
864844 if (dynamic_grid) {
865- for (iMesh = 0 ; iMesh <= config->GetnMGLevels (); iMesh++) {
845+ for (auto iMesh = 0u ; iMesh <= config->GetnMGLevels (); iMesh++) {
866846
867847 /* --- Compute the grid velocities on the coarser levels. ---*/
868- if (iMesh) geometry[iMesh]->SetRestricted_GridVelocity (geometry[iMesh- 1 ]);
848+ if (iMesh) geometry[iMesh]->SetRestricted_GridVelocity (geometry[iMesh - 1 ]);
869849 else {
870850 geometry[MESH_0]->InitiateComms (geometry[MESH_0], config, GRID_VELOCITY);
871851 geometry[MESH_0]->CompleteComms (geometry[MESH_0], config, GRID_VELOCITY);
@@ -884,23 +864,26 @@ void CFVMFlowSolverBase<V, R>::LoadRestart_impl(CGeometry **geometry, CSolver **
884864
885865 /* --- For turbulent simulations the flow preprocessing is done by the turbulence solver
886866 * after it loads its variables (they are needed to compute flow primitives). ---*/
887- if (!turbulent ) {
867+ if (config-> GetKind_Turb_Model () == TURB_MODEL::NONE ) {
888868 solver[MESH_0][FLOW_SOL]->Preprocessing (geometry[MESH_0], solver[MESH_0], config, MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS, false );
889869 }
890870
891871 /* --- Interpolate the solution down to the coarse multigrid levels ---*/
892872
893- for (iMesh = 1 ; iMesh <= config->GetnMGLevels (); iMesh++) {
873+ for (auto iMesh = 1u ; iMesh <= config->GetnMGLevels (); iMesh++) {
874+
894875 SU2_OMP_FOR_STAT (omp_chunk_size)
895- for (iPoint = 0 ; iPoint < geometry[iMesh]->GetnPoint (); iPoint++) {
896- Area_Parent = geometry[iMesh]->nodes ->GetVolume (iPoint);
876+ for (auto iPoint = 0ul ; iPoint < geometry[iMesh]->GetnPoint (); iPoint++) {
877+ const su2double Area_Parent = geometry[iMesh]->nodes ->GetVolume (iPoint);
897878 su2double Solution_Coarse[MAXNVAR] = {0.0 };
898- for (iChildren = 0 ; iChildren < geometry[iMesh]->nodes ->GetnChildren_CV (iPoint); iChildren++) {
899- Point_Fine = geometry[iMesh]->nodes ->GetChildren_CV (iPoint, iChildren);
900- Area_Children = geometry[iMesh-1 ]->nodes ->GetVolume (Point_Fine);
901- Solution_Fine = solver[iMesh-1 ][FLOW_SOL]->GetNodes ()->GetSolution (Point_Fine);
902- for (iVar = 0 ; iVar < nVar; iVar++) {
903- Solution_Coarse[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent;
879+
880+ for (auto iChildren = 0ul ; iChildren < geometry[iMesh]->nodes ->GetnChildren_CV (iPoint); iChildren++) {
881+ const auto Point_Fine = geometry[iMesh]->nodes ->GetChildren_CV (iPoint, iChildren);
882+ const su2double Area_Children = geometry[iMesh - 1 ]->nodes ->GetVolume (Point_Fine);
883+ const su2double* Solution_Fine = solver[iMesh - 1 ][FLOW_SOL]->GetNodes ()->GetSolution (Point_Fine);
884+
885+ for (auto iVar = 0u ; iVar < nVar; iVar++) {
886+ Solution_Coarse[iVar] += Solution_Fine[iVar] * Area_Children / Area_Parent;
904887 }
905888 }
906889 solver[iMesh][FLOW_SOL]->GetNodes ()->SetSolution (iPoint,Solution_Coarse);
@@ -910,12 +893,14 @@ void CFVMFlowSolverBase<V, R>::LoadRestart_impl(CGeometry **geometry, CSolver **
910893 solver[iMesh][FLOW_SOL]->InitiateComms (geometry[iMesh], config, SOLUTION);
911894 solver[iMesh][FLOW_SOL]->CompleteComms (geometry[iMesh], config, SOLUTION);
912895
913- if (!turbulent ) {
896+ if (config-> GetKind_Turb_Model () == TURB_MODEL::NONE ) {
914897 solver[iMesh][FLOW_SOL]->Preprocessing (geometry[iMesh], solver[iMesh], config, iMesh, NO_RK_ITER, RUNTIME_FLOW_SYS, false );
915898 }
916899 }
917900
918901 /* --- Update the old geometry (coordinates n and n-1) in dual time-stepping strategy. ---*/
902+ const bool dual_time = ((config->GetTime_Marching () == TIME_MARCHING::DT_STEPPING_1ST) ||
903+ (config->GetTime_Marching () == TIME_MARCHING::DT_STEPPING_2ND));
919904 if (dual_time && config->GetGrid_Movement () && !config->GetDeform_Mesh () &&
920905 (config->GetKind_GridMovement () != RIGID_MOTION)) {
921906 Restart_OldGeometry (geometry[MESH_0], config);
@@ -926,13 +911,13 @@ void CFVMFlowSolverBase<V, R>::LoadRestart_impl(CGeometry **geometry, CSolver **
926911 {
927912 /* --- Delete the class memory that is used to load the restart. ---*/
928913
929- delete [] Restart_Vars; Restart_Vars = nullptr ;
930- delete [] Restart_Data; Restart_Data = nullptr ;
931-
914+ delete [] Restart_Vars;
915+ Restart_Vars = nullptr ;
916+ delete [] Restart_Data;
917+ Restart_Data = nullptr ;
932918 }
933919 END_SU2_OMP_MASTER
934920 SU2_OMP_BARRIER
935-
936921}
937922
938923template <class V , ENUM_REGIME R>
0 commit comments