Skip to content

Commit 239bd59

Browse files
committed
move dealing with extensions up to the getfile functions
1 parent 36cecee commit 239bd59

25 files changed

+207
-102
lines changed

Common/include/CConfig.hpp

Lines changed: 107 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4932,11 +4932,7 @@ class CConfig {
49324932
*/
49334933
bool GetInlet_Profile_From_File(void) const { return Inlet_From_File; }
49344934

4935-
/*!
4936-
* \brief Get name of the input file for the specified inlet profile.
4937-
* \return Name of the input file for the specified inlet profile.
4938-
*/
4939-
string GetInlet_FileName(void) const { return Inlet_Filename; }
4935+
49404936

49414937
/*!
49424938
* \brief Get name of the input file for the specified actuator disk.
@@ -5382,19 +5378,19 @@ class CConfig {
53825378
bool GetWrt_Volume_Overwrite(void) const { return Wrt_Volume_Overwrite; }
53835379

53845380
/*!
5385-
* \brief Provides the number of varaibles.
5381+
* \brief Provides the number of variables.
53865382
* \return Number of variables.
53875383
*/
53885384
unsigned short GetnVar(void);
53895385

53905386
/*!
5391-
* \brief Provides the number of varaibles.
5387+
* \brief Provides the number of variables.
53925388
* \return Number of variables.
53935389
*/
53945390
unsigned short GetnZone(void) const { return nZone; }
53955391

53965392
/*!
5397-
* \brief Provides the number of varaibles.
5393+
* \brief Provides the number of variables.
53985394
* \return Number of variables.
53995395
*/
54005396
unsigned short GetiZone(void) const { return iZone; }
@@ -5454,20 +5450,83 @@ class CConfig {
54545450
* \brief Get name of the input grid.
54555451
* \return File name of the input grid.
54565452
*/
5457-
string GetMesh_FileName(void) const { return Mesh_FileName; }
5453+
string GetMesh_FileName(void) const {
5454+
5455+
/*--- we keep the original Mesh_FileName ---*/
5456+
string meshFilename = Mesh_FileName;
5457+
5458+
/*--- strip the extension, only if it is .su2 or .cgns ---*/
5459+
auto extIndex = meshFilename.rfind(".su2");
5460+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5461+
extIndex = meshFilename.rfind(".cgns");
5462+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5463+
5464+
cout << "mesh file format = " << GetMesh_FileFormat() << " , file = " << meshFilename<< endl;
5465+
5466+
switch (GetMesh_FileFormat()) {
5467+
case SU2:
5468+
case RECTANGLE:
5469+
case BOX:
5470+
meshFilename += ".su2";
5471+
break;
5472+
case CGNS_GRID:
5473+
meshFilename += ".cgns";
5474+
break;
5475+
default:
5476+
SU2_MPI::Error("Unrecognized mesh format specified!", CURRENT_FUNCTION);
5477+
break;
5478+
}
5479+
5480+
return meshFilename;
5481+
}
54585482

54595483
/*!
54605484
* \brief Get name of the output grid, this parameter is important for grid
54615485
* adaptation and deformation.
54625486
* \return File name of the output grid.
54635487
*/
5464-
string GetMesh_Out_FileName(void) const { return Mesh_Out_FileName; }
5488+
string GetMesh_Out_FileName(void) const {
5489+
5490+
/*--- we keep the original Mesh_Out_FileName ---*/
5491+
string meshFilename = Mesh_Out_FileName;
5492+
5493+
/*--- strip the extension, only if it is .su2 or .cgns ---*/
5494+
auto extIndex = meshFilename.rfind(".su2");
5495+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5496+
extIndex = meshFilename.rfind(".cgns");
5497+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5498+
5499+
// switch (Mesh_FileFormat) {
5500+
// case SU2:
5501+
// meshFilename += ".su2";
5502+
// case CGNS_GRID:
5503+
// meshFilename += ".cgns";
5504+
// default:
5505+
// SU2_MPI::Error("Unrecognized mesh format specified!", CURRENT_FUNCTION);
5506+
// break;
5507+
// }
5508+
5509+
return meshFilename;
5510+
}
54655511

54665512
/*!
54675513
* \brief Get the name of the file with the solution of the flow problem.
54685514
* \return Name of the file with the solution of the flow problem.
54695515
*/
5470-
string GetSolution_FileName(void) const { return Solution_FileName; }
5516+
string GetSolution_FileName(void) const {
5517+
5518+
/*--- we keep the original Solution_FileName ---*/
5519+
string solutionFilename = Solution_FileName;
5520+
5521+
/*--- strip the extension, only if it is .dat or .csv ---*/
5522+
auto extIndex = solutionFilename.rfind(".dat");
5523+
if (extIndex != std::string::npos) solutionFilename.resize(extIndex);
5524+
extIndex = solutionFilename.rfind(".csv");
5525+
if (extIndex != std::string::npos) solutionFilename.resize(extIndex);
5526+
5527+
/*--- return the stripped filename base, without extension. ---*/
5528+
return solutionFilename;
5529+
}
54715530

54725531
/*!
54735532
* \brief Get the name of the file with the solution of the adjoint flow problem
@@ -5505,7 +5564,7 @@ class CConfig {
55055564
* \brief Get the name of the file with the convergence history of the problem.
55065565
* \return Name of the file with convergence history of the problem.
55075566
*/
5508-
string GetConv_FileName(void) const {
5567+
string GetHistory_FileName(void) const {
55095568

55105569
/*--- we keep the original Conv_FileName ---*/
55115570
string historyFilename = Conv_FileName;
@@ -5516,8 +5575,9 @@ class CConfig {
55165575
extIndex = historyFilename.rfind(".csv");
55175576
if (extIndex != std::string::npos) historyFilename.resize(extIndex);
55185577

5519-
/*--- Append the zone ID ---*/
5520-
historyFilename = GetMultizone_FileName(historyFilename, GetiZone(), "");
5578+
/*--- Multizone problems require the number of the zone to be appended. ---*/
5579+
if (GetMultizone_Problem())
5580+
historyFilename = GetMultizone_FileName(historyFilename, GetiZone(), "");
55215581

55225582
/*--- Append the restart iteration ---*/
55235583
if (GetTime_Domain() && GetRestart()) {
@@ -5534,6 +5594,39 @@ class CConfig {
55345594
return historyFilename;
55355595
}
55365596

5597+
/*!
5598+
* \brief Get name of the input file for the specified inlet profile.
5599+
* \return Name of the input file for the specified inlet profile.
5600+
*/
5601+
string GetInlet_FileName(void) const {
5602+
5603+
/*--- we keep the original inlet profile filename ---*/
5604+
string inletProfileFilename = Inlet_Filename;
5605+
5606+
/*--- strip the extension, only if it is .dat or .csv ---*/
5607+
auto extIndex = inletProfileFilename.rfind(".dat");
5608+
if (extIndex != std::string::npos) inletProfileFilename.resize(extIndex);
5609+
extIndex = inletProfileFilename.rfind(".csv");
5610+
if (extIndex != std::string::npos) inletProfileFilename.resize(extIndex);
5611+
5612+
/*--- Multizone problems require the number of the zone to be appended. ---*/
5613+
if (GetMultizone_Problem())
5614+
inletProfileFilename = GetMultizone_FileName(inletProfileFilename, GetiZone(), "");
5615+
5616+
/*--- Modify file name for an unsteady restart ---*/
5617+
if (GetTime_Domain() && GetRestart()) {
5618+
inletProfileFilename = GetUnsteady_FileName(inletProfileFilename, GetRestart_Iter(), "");
5619+
}
5620+
/*--- Add the correct file extension depending on the file format ---*/
5621+
string ext = ".dat";
5622+
5623+
inletProfileFilename += ext;
5624+
5625+
5626+
return inletProfileFilename;
5627+
}
5628+
5629+
55375630
/*!
55385631
* \brief Get the Starting Iteration for the windowing approach
55395632
* in Sensitivity Analysis for period-averaged outputs, which oscillate.

Common/src/CConfig.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ CConfig::CConfig(CConfig* config, char case_filename[MAX_STRING_SIZE], SU2_COMPO
170170

171171
/*--- Get the dimension --- */
172172

173-
val_nDim = GetnDim(Mesh_FileName, Mesh_FileFormat);
173+
val_nDim = GetnDim(GetMesh_FileName(), Mesh_FileFormat);
174174

175175
/*--- Configuration file postprocessing ---*/
176176

@@ -2127,7 +2127,7 @@ void CConfig::SetConfig_Options() {
21272127
/*!\brief MESH_FORMAT \n DESCRIPTION: Mesh input file format \n OPTIONS: see \link Input_Map \endlink \n DEFAULT: SU2 \ingroup Config*/
21282128
addEnumOption("MESH_FORMAT", Mesh_FileFormat, Input_Map, SU2);
21292129
/* DESCRIPTION: Mesh input file */
2130-
addStringOption("MESH_FILENAME", Mesh_FileName, string("mesh.su2"));
2130+
addStringOption("MESH_FILENAME", Mesh_FileName, string("mesh"));
21312131
/*!\brief MESH_OUT_FILENAME \n DESCRIPTION: Mesh output file name. Used when converting, scaling, or deforming a mesh. \n DEFAULT: mesh_out \ingroup Config*/
21322132
addStringOption("MESH_OUT_FILENAME", Mesh_Out_FileName, string("mesh_out"));
21332133

@@ -3341,7 +3341,7 @@ void CConfig::SetnZone(){
33413341

33423342
/*--- Get the number of zones from the mesh file --- */
33433343

3344-
nZone = GetnZone(Mesh_FileName, Mesh_FileFormat);
3344+
nZone = GetnZone(GetMesh_FileName(), Mesh_FileFormat);
33453345

33463346
/*--- If config list is set, make sure number matches number of zones in mesh file --- */
33473347

@@ -6588,7 +6588,7 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
65886588
}
65896589
}
65906590

6591-
cout << "Input mesh file name: " << Mesh_FileName << endl;
6591+
cout << "Input mesh file name: " << GetMesh_FileName() << endl;
65926592

65936593
if (val_software == SU2_COMPONENT::SU2_DOT) {
65946594
if (DiscreteAdjoint) {
@@ -8362,29 +8362,24 @@ CConfig::~CConfig() {
83628362
delete [] FreeStreamTurboNormal;
83638363
}
83648364

8365+
/*--- Input is the filename base, output is the completed filename. ---*/
83658366
string CConfig::GetFilename(string filename, const string& ext, int timeIter) const {
83668367

8367-
8368-
83698368
/*--- Append the zone number if multizone problems ---*/
8370-
if (Multizone_Problem)
8371-
//filename = GetMultizone_FileName(filename, GetiZone(), ext);
8369+
if (GetMultizone_Problem())
83728370
filename = GetMultizone_FileName(filename, GetiZone(), "");
83738371

83748372
/*--- Append the zone number if multiple instance problems ---*/
83758373
if (GetnTimeInstances() > 1)
8376-
//filename = GetMultiInstance_FileName(filename, GetiInst(), ext);
83778374
filename = GetMultiInstance_FileName(filename, GetiInst(), "");
83788375

83798376
/*--- Append the iteration number for unsteady problems ---*/
83808377
if (GetTime_Domain())
8381-
//filename = GetUnsteady_FileName(filename, timeIter, ext);
83828378
filename = GetUnsteady_FileName(filename, timeIter, "");
83838379

8384-
83858380
/*--- Add the extension --- */
8386-
filename = filename + string(ext);
83878381

8382+
filename = filename + string(ext);
83888383

83898384
return filename;
83908385
}

Common/src/grid_movement/CSurfaceMovement.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4060,7 +4060,7 @@ void CSurfaceMovement::ReadFFDInfo(CGeometry* geometry, CConfig* config, CFreeFo
40604060

40614061
mesh_file.open(val_mesh_filename);
40624062
if (mesh_file.fail()) {
4063-
SU2_MPI::Error("There is no geometry file (ReadFFDInfo)!!", CURRENT_FUNCTION);
4063+
SU2_MPI::Error("ReadFFDInfo:: There is no geometry file called " + val_mesh_filename, CURRENT_FUNCTION);
40644064
}
40654065

40664066
while (getline(mesh_file, text_line)) {
@@ -4919,7 +4919,7 @@ void CSurfaceMovement::WriteFFDInfo(CSurfaceMovement** surface_movement, CGeomet
49194919

49204920
auto str = config[ZONE_0]->GetMesh_Out_FileName();
49214921
// unsigned short lastindex = str.find_last_of('.');
4922-
str += ".su2";
4922+
//str += ".su2";
49234923

49244924
output_file.precision(15);
49254925
output_file.open(str, ios::out | ios::app);

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ void CFVMFlowSolverBase<V, R>::LoadRestart_impl(CGeometry **geometry, CSolver **
824824
unsigned short nVar_Restart) {
825825
/*--- Restart the solution from file information ---*/
826826

827-
const string restart_filename = config->GetFilename(config->GetSolution_FileName(), "", iter);
827+
string restart_filename = config->GetSolution_FileName();
828828
const bool static_fsi = ((config->GetTime_Marching() == TIME_MARCHING::STEADY) && config->GetFSI_Simulation());
829829

830830
/*--- To make this routine safe to call in parallel most of it can only be executed by one thread. ---*/
@@ -837,10 +837,12 @@ void CFVMFlowSolverBase<V, R>::LoadRestart_impl(CGeometry **geometry, CSolver **
837837
unsigned short skipVars = nDim;
838838

839839
/*--- Read the restart data from either an ASCII or binary SU2 file. ---*/
840-
840+
cout << "nijso:cfvmflowsolverbase.inl" << endl;
841841
if (config->GetRead_Binary_Restart()) {
842+
restart_filename = config->GetFilename(restart_filename, ".dat", iter);
842843
Read_SU2_Restart_Binary(geometry[MESH_0], config, restart_filename);
843844
} else {
845+
restart_filename = config->GetFilename(restart_filename, ".csv", iter);
844846
Read_SU2_Restart_ASCII(geometry[MESH_0], config, restart_filename);
845847
}
846848

SU2_CFD/src/output/CMeshOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ CMeshOutput::CMeshOutput(CConfig *config, unsigned short nDim) : COutput(config,
3838

3939
/*--- Set the volume filename --- */
4040

41-
volumeFilename = config->GetMesh_Out_FileName() + ".su2";
41+
volumeFilename = config->GetMesh_Out_FileName();
4242

4343
/*--- Set the surface filename ---*/
4444

SU2_CFD/src/output/COutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ COutput::COutput(const CConfig *config, unsigned short ndim, bool fem_output):
8484

8585
/*--- Retrieve the history filename, including extension ---*/
8686

87-
historyFilename = config->GetConv_FileName();
87+
historyFilename = config->GetHistory_FileName();
8888

8989
historySep = ",";
9090

SU2_CFD/src/output/filewriter/CSU2MeshFileWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void CSU2MeshFileWriter::WriteData(string val_filename) {
3939
ofstream output_file;
4040

4141
/*--- strip the extension from the original filename and add the .su2 extension ---*/
42-
unsigned short lastindex = val_filename.find_last_of('.');
43-
val_filename = val_filename.substr(0, lastindex);
42+
//unsigned short lastindex = val_filename.find_last_of('.');
43+
//val_filename = val_filename.substr(0, lastindex);
4444

4545
/*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/
4646
val_filename.append(fileExt);

SU2_CFD/src/solvers/CAdjEulerSolver.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3814,7 +3814,9 @@ void CAdjEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf
38143814

38153815
filename = config->GetSolution_AdjFileName();
38163816
restart_filename = config->GetObjFunc_Extension(filename);
3817-
restart_filename = config->GetFilename(restart_filename, "", val_iter);
3817+
3818+
cout << "adj-euler: restart filename = " << restart_filename << endl;
3819+
38183820

38193821
Coord = new su2double [nDim];
38203822
for (iDim = 0; iDim < nDim; iDim++)
@@ -3827,8 +3829,10 @@ void CAdjEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf
38273829
/*--- Read the restart data from either an ASCII or binary SU2 file. ---*/
38283830

38293831
if (config->GetRead_Binary_Restart()) {
3832+
restart_filename = config->GetFilename(restart_filename, ".dat", val_iter);
38303833
Read_SU2_Restart_Binary(geometry[MESH_0], config, restart_filename);
38313834
} else {
3835+
restart_filename = config->GetFilename(restart_filename, ".csv", val_iter);
38323836
Read_SU2_Restart_ASCII(geometry[MESH_0], config, restart_filename);
38333837
}
38343838

0 commit comments

Comments
 (0)