diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index d4f94008ddc..c6ffc82eff9 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5672,7 +5672,7 @@ class CConfig { * \param[in] val_iInst - the current instance. * \return Name of the restart file for the flow variables. */ - string GetMultiInstance_HistoryFileName(string val_filename, int val_iInst) const; + string GetMultiInstance_HistoryFileName(string val_filename, int val_iInst, const string& ext) const; /*! * \brief Get the name of the restart file for the flow variables. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index bf2122f01a7..ab55fa20df5 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -2158,13 +2158,13 @@ void CConfig::SetConfig_Options() { /*!\brief BREAKDOWN_FILENAME \n DESCRIPTION: Output file forces breakdown \ingroup Config*/ addStringOption("BREAKDOWN_FILENAME", Breakdown_FileName, string("forces_breakdown.dat")); /*!\brief SOLUTION_FLOW_FILENAME \n DESCRIPTION: Restart flow input file (the file output under the filename set by RESTART_FLOW_FILENAME) \n DEFAULT: solution_flow.dat \ingroup Config */ - addStringOption("SOLUTION_FILENAME", Solution_FileName, string("solution.dat")); + addStringOption("SOLUTION_FILENAME", Solution_FileName, string("solution")); /*!\brief SOLUTION_ADJ_FILENAME\n DESCRIPTION: Restart adjoint input file. Objective function abbreviation is expected. \ingroup Config*/ - addStringOption("SOLUTION_ADJ_FILENAME", Solution_AdjFileName, string("solution_adj.dat")); + addStringOption("SOLUTION_ADJ_FILENAME", Solution_AdjFileName, string("solution_adj")); /*!\brief RESTART_FLOW_FILENAME \n DESCRIPTION: Output file restart flow \ingroup Config*/ - addStringOption("RESTART_FILENAME", Restart_FileName, string("restart.dat")); + addStringOption("RESTART_FILENAME", Restart_FileName, string("restart")); /*!\brief RESTART_ADJ_FILENAME \n DESCRIPTION: Output file restart adjoint. Objective function abbreviation will be appended. \ingroup Config*/ - addStringOption("RESTART_ADJ_FILENAME", Restart_AdjFileName, string("restart_adj.dat")); + addStringOption("RESTART_ADJ_FILENAME", Restart_AdjFileName, string("restart_adj")); /*!\brief VOLUME_FLOW_FILENAME \n DESCRIPTION: Output file flow (w/o extension) variables \ingroup Config */ addStringOption("VOLUME_FILENAME", Volume_FileName, string("vol_solution")); /*!\brief VOLUME_ADJ_FILENAME @@ -8249,11 +8249,6 @@ CConfig::~CConfig() { string CConfig::GetFilename(string filename, const string& ext, int timeIter) const { - /*--- Remove any extension --- */ - - unsigned short lastindex = filename.find_last_of('.'); - filename = filename.substr(0, lastindex); - /*--- Add the extension --- */ filename = filename + string(ext); @@ -8267,9 +8262,8 @@ string CConfig::GetFilename(string filename, const string& ext, int timeIter) co filename = GetMultiInstance_FileName(filename, GetiInst(), ext); /*--- Append the iteration number for unsteady problems ---*/ - if (GetTime_Domain()){ + if (GetTime_Domain()) filename = GetUnsteady_FileName(filename, timeIter, ext); - } return filename; } @@ -8286,15 +8280,17 @@ string CConfig::GetUnsteady_FileName(string val_filename, int val_iter, const st string UnstExt, UnstFilename = std::move(val_filename); char buffer[50]; + /*--- Note that we always call this routine wit the extension already attached, so + we remove it. ---*/ + unsigned short lastindex = UnstFilename.find_last_of('.'); + UnstFilename = UnstFilename.substr(0, lastindex); + /*--- Check that a positive value iteration is requested (for now). ---*/ if (val_iter < 0) { SU2_MPI::Error("Requesting a negative iteration number for the restart file!!", CURRENT_FUNCTION); } - unsigned short lastindex = UnstFilename.find_last_of('.'); - UnstFilename = UnstFilename.substr(0, lastindex); - /*--- Append iteration number for unsteady cases ---*/ if (Time_Domain) { @@ -8317,6 +8313,8 @@ string CConfig::GetMultizone_FileName(string val_filename, int val_iZone, const string multizone_filename = std::move(val_filename); char buffer[50]; + /*--- Note that we always call this routine wit the extension already attached, so + we remove it. ---*/ unsigned short lastindex = multizone_filename.find_last_of('.'); multizone_filename = multizone_filename.substr(0, lastindex); @@ -8331,16 +8329,20 @@ string CConfig::GetMultizone_FileName(string val_filename, int val_iZone, const string CConfig::GetMultizone_HistoryFileName(string val_filename, int val_iZone, const string& ext) const { - string multizone_filename = std::move(val_filename); - char buffer[50]; - unsigned short lastindex = multizone_filename.find_last_of('.'); - multizone_filename = multizone_filename.substr(0, lastindex); - if (Multizone_Problem) { - SPRINTF (buffer, "_%d", SU2_TYPE::Int(val_iZone)); - multizone_filename.append(string(buffer)); - } - multizone_filename += ext; - return multizone_filename; + string multizone_filename = std::move(val_filename); + char buffer[50]; + + /*--- Note that we always call this routine wit the extension already attached, so + we remove it. ---*/ + unsigned short lastindex = multizone_filename.find_last_of('.'); + multizone_filename = multizone_filename.substr(0, lastindex); + + if (Multizone_Problem) { + SPRINTF (buffer, "_%d", SU2_TYPE::Int(val_iZone)); + multizone_filename.append(string(buffer)); + } + multizone_filename += ext; + return multizone_filename; } string CConfig::GetMultiInstance_FileName(string val_filename, int val_iInst, const string& ext) const { @@ -8348,24 +8350,30 @@ string CConfig::GetMultiInstance_FileName(string val_filename, int val_iInst, co string multizone_filename = std::move(val_filename); char buffer[50]; + /*--- Note that we always call this routine wit the extension already attached, so + we remove it. ---*/ unsigned short lastindex = multizone_filename.find_last_of('.'); multizone_filename = multizone_filename.substr(0, lastindex); + SPRINTF (buffer, "_%d", SU2_TYPE::Int(val_iInst)); multizone_filename.append(string(buffer)); multizone_filename += ext; return multizone_filename; } -string CConfig::GetMultiInstance_HistoryFileName(string val_filename, int val_iInst) const { +string CConfig::GetMultiInstance_HistoryFileName(string val_filename, int val_iInst, const string& ext) const { string multizone_filename = std::move(val_filename); char buffer[50]; + /*--- Note that we always call this routine wit the extension already attached, so + we remove it. ---*/ unsigned short lastindex = multizone_filename.find_last_of('.'); multizone_filename = multizone_filename.substr(0, lastindex); + SPRINTF (buffer, "_%d", SU2_TYPE::Int(val_iInst)); multizone_filename.append(string(buffer)); - + multizone_filename += ext; return multizone_filename; } @@ -8375,11 +8383,6 @@ string CConfig::GetObjFunc_Extension(string val_filename) const { if (ContinuousAdjoint || DiscreteAdjoint) { - /*--- Remove filename extension (.dat) ---*/ - - unsigned short lastindex = Filename.find_last_of('.'); - Filename = Filename.substr(0, lastindex); - if (nObj==1) { switch (Kind_ObjFunc[0]) { case DRAG_COEFFICIENT: AdjExt = "_cd"; break; diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index a069424c666..c89e5b68a3d 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -5676,8 +5676,6 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone char buffer[50]; if (GetnZone() > 1) { - unsigned short lastindex = multizone_filename.find_last_of('.'); - multizone_filename = multizone_filename.substr(0, lastindex); SPRINTF(buffer, "_%d.dat", SU2_TYPE::Int(val_iZone)); multizone_filename.append(string(buffer)); } diff --git a/Common/src/grid_movement/CSurfaceMovement.cpp b/Common/src/grid_movement/CSurfaceMovement.cpp index 5c29534fb39..6a2c0e392de 100644 --- a/Common/src/grid_movement/CSurfaceMovement.cpp +++ b/Common/src/grid_movement/CSurfaceMovement.cpp @@ -3514,8 +3514,6 @@ void CSurfaceMovement::SetExternal_Deformation(CGeometry* geometry, CConfig* con physical time, so perform mesh motion in reverse. ---*/ unsigned long nFlowIter = config->GetnTime_Iter() - 1; flowIter = nFlowIter - iter; - unsigned short lastindex = DV_Filename.find_last_of('.'); - DV_Filename = DV_Filename.substr(0, lastindex); if ((SU2_TYPE::Int(flowIter) >= 0) && (SU2_TYPE::Int(flowIter) < 10)) SPRINTF(buffer, "_0000%d.dat", SU2_TYPE::Int(flowIter)); if ((SU2_TYPE::Int(flowIter) >= 10) && (SU2_TYPE::Int(flowIter) < 100)) @@ -3530,8 +3528,6 @@ void CSurfaceMovement::SetExternal_Deformation(CGeometry* geometry, CConfig* con } else { /*--- Forward time for the direct problem ---*/ flowIter = iter; - unsigned short lastindex = DV_Filename.find_last_of('.'); - DV_Filename = DV_Filename.substr(0, lastindex); if ((SU2_TYPE::Int(flowIter) >= 0) && (SU2_TYPE::Int(flowIter) < 10)) SPRINTF(buffer, "_0000%d.dat", SU2_TYPE::Int(flowIter)); if ((SU2_TYPE::Int(flowIter) >= 10) && (SU2_TYPE::Int(flowIter) < 100)) @@ -4922,8 +4918,7 @@ void CSurfaceMovement::WriteFFDInfo(CSurfaceMovement** surface_movement, CGeomet /*--- Read the name of the output file ---*/ auto str = config[ZONE_0]->GetMesh_Out_FileName(); - unsigned short lastindex = str.find_last_of('.'); - str = str.substr(0, lastindex) + ".su2"; + str = ".su2"; output_file.precision(15); output_file.open(str, ios::out | ios::app); diff --git a/QuickStart/inv_NACA0012.cfg b/QuickStart/inv_NACA0012.cfg index 27047c9f60a..393469ed3f5 100644 --- a/QuickStart/inv_NACA0012.cfg +++ b/QuickStart/inv_NACA0012.cfg @@ -250,10 +250,10 @@ MESH_FORMAT= SU2 MESH_OUT_FILENAME= mesh_out.su2 % % Restart flow input file -SOLUTION_FILENAME= solution_flow.dat +SOLUTION_FILENAME= solution_flow % % Restart adjoint input file -SOLUTION_ADJ_FILENAME= solution_adj.dat +SOLUTION_ADJ_FILENAME= solution_adj % % Output file format (TECPLOT, CSV) TABULAR_FORMAT= CSV @@ -262,10 +262,10 @@ TABULAR_FORMAT= CSV CONV_FILENAME= history % % Output file restart flow -RESTART_FILENAME= restart_flow.dat +RESTART_FILENAME= restart_flow % % Output file restart adjoint -RESTART_ADJ_FILENAME= restart_adj.dat +RESTART_ADJ_FILENAME= restart_adj % % Output file flow (w/o extension) variables VOLUME_FILENAME= flow diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index d8aa5c16af9..887cee9688a 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -70,15 +70,17 @@ COutput::COutput(const CConfig *config, unsigned short ndim, bool fem_output): volumeFilename = "volume"; restartFilename = "restart"; - /*--- Retrieve the history filename ---*/ - historyFilename = config->GetConv_FileName(); /*--- Add the correct file extension depending on the file format ---*/ string hist_ext = ".csv"; if (config->GetTabular_FileFormat() == TAB_OUTPUT::TAB_TECPLOT) hist_ext = ".dat"; + /*--- Retrieve the history filename ---*/ + + historyFilename = config->GetConv_FileName() + string(hist_ext); + /*--- Append the zone ID ---*/ historyFilename = config->GetMultizone_HistoryFileName(historyFilename, config->GetiZone(), hist_ext); @@ -169,7 +171,7 @@ COutput::COutput(const CConfig *config, unsigned short ndim, bool fem_output): volumeDataSorter = nullptr; surfaceDataSorter = nullptr; - headerNeeded = false; + headerNeeded = false; } COutput::~COutput() { @@ -233,7 +235,7 @@ void COutput::SetHistoryOutput(CGeometry ****geometry, CSolver *****solver, CCon if (config[ZONE_0]->GetMultizone_Problem()) Iter = OuterIter; - + /*--- Turbomachinery Performance Screen summary output---*/ if (Iter%100 == 0 && rank == MASTER_NODE) { SetTurboPerformance_Output(TurboPerf, config[val_iZone], TimeIter, OuterIter, InnerIter); @@ -360,15 +362,11 @@ void COutput::LoadData(CGeometry *geometry, CConfig *config, CSolver** solver_co } -void COutput::WriteToFile(CConfig *config, CGeometry *geometry, OUTPUT_TYPE format, string fileName){ +void COutput::WriteToFile(CConfig *config, CGeometry *geometry, OUTPUT_TYPE format, string fileName) { /*--- File writer that will later be used to write the file to disk. Created below in the "switch" ---*/ CFileWriter *fileWriter = nullptr; - /*--- If it is still present, strip the extension (suffix) from the filename ---*/ - const auto lastindex = fileName.find_last_of('.'); - fileName = fileName.substr(0, lastindex); - /*--- If the filename with appended iteration is set (depending on the WRT_*_OVERWRITE options) * two files are writen, the normal one and a copy to avoid overwriting previous outputs. ---*/ string filename_iter, extension; diff --git a/SU2_CFD/src/solvers/CBaselineSolver.cpp b/SU2_CFD/src/solvers/CBaselineSolver.cpp index 411cce58397..6effc2e57cf 100644 --- a/SU2_CFD/src/solvers/CBaselineSolver.cpp +++ b/SU2_CFD/src/solvers/CBaselineSolver.cpp @@ -91,8 +91,8 @@ void CBaselineSolver::SetOutputVariables(CGeometry *geometry, CConfig *config) { } else { filename = config->GetSolution_FileName(); } - - + //nijso + cout << "filename = "<GetRead_Binary_Restart()) { @@ -100,6 +100,7 @@ void CBaselineSolver::SetOutputVariables(CGeometry *geometry, CConfig *config) { /*--- Multizone problems require the number of the zone to be appended. ---*/ filename = config->GetFilename(filename, ".dat", config->GetTimeIter()); + cout << "filename = "<