Skip to content

Commit 56e0a92

Browse files
author
Joshua Kelly
committed
Merge branch 'feature_turbo_ramps' of https://github.com/su2code/SU2 into feature_turbo_ramps
2 parents 3f8e1c1 + 87e5530 commit 56e0a92

File tree

351 files changed

+1868
-1804
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

351 files changed

+1868
-1804
lines changed

Common/include/CConfig.hpp

Lines changed: 132 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
#include "option_structure.hpp"
4747
#include "containers/container_decorators.hpp"
48+
#include "toolboxes/printing_toolbox.hpp"
4849

4950
#ifdef HAVE_CGNS
5051
#include "cgnslib.h"
@@ -358,7 +359,6 @@ class CConfig {
358359
su2double BEM_blade_angle; /*!< \brief Propeller blade angle.*/
359360
string BEM_prop_filename; /*!< \brief Propeller filename.*/
360361
unsigned short ActDiskBem_Frequency; /*!< \brief Frequency of updating actuator disk with BEM. */
361-
bool History_File_Append_Flag; /*!< \brief Flag to append history file.*/
362362
su2double *ActDisk_DeltaPress; /*!< \brief Specified pressure delta for actuator disk. */
363363
su2double *ActDisk_DeltaTemp; /*!< \brief Specified temperature delta for actuator disk. */
364364
su2double *ActDisk_TotalPressRatio; /*!< \brief Specified tot. pres. ratio for actuator disk. */
@@ -2283,7 +2283,22 @@ class CConfig {
22832283
* \brief Get the name of the file with the element properties for structural problems.
22842284
* \return Name of the file with the element properties of the structural problem.
22852285
*/
2286-
string GetFEA_FileName(void) const { return FEA_FileName; }
2286+
string GetFEA_FileName(void) const {
2287+
string FEAFilename = FEA_FileName;
2288+
2289+
/*--- strip the extension if it is present, only if it is .dat ---*/
2290+
PrintingToolbox::TrimExtension(".dat", FEAFilename);
2291+
2292+
/*--- If multizone, append zone name ---*/
2293+
if (Multizone_Problem)
2294+
FEAFilename = GetMultizone_FileName(FEAFilename, GetiZone(), "");
2295+
2296+
/*--- Add the extension again ---*/
2297+
FEAFilename += ".dat";
2298+
2299+
/*--- return the stripped filename base, without extension. ---*/
2300+
return FEAFilename;
2301+
}
22872302

22882303
/*!
22892304
* \brief Determine if advanced features are used from the element-based FEA analysis (experimental feature).
@@ -5028,12 +5043,6 @@ class CConfig {
50285043
*/
50295044
bool GetInlet_Profile_From_File(void) const { return Inlet_From_File; }
50305045

5031-
/*!
5032-
* \brief Get name of the input file for the specified inlet profile.
5033-
* \return Name of the input file for the specified inlet profile.
5034-
*/
5035-
string GetInlet_FileName(void) const { return Inlet_Filename; }
5036-
50375046
/*!
50385047
* \brief Get name of the input file for the specified actuator disk.
50395048
* \return Name of the input file for the specified actuator disk.
@@ -5557,20 +5566,70 @@ class CConfig {
55575566
* \brief Get name of the input grid.
55585567
* \return File name of the input grid.
55595568
*/
5560-
string GetMesh_FileName(void) const { return Mesh_FileName; }
5569+
string GetMesh_FileName(void) const {
5570+
5571+
/*--- we keep the original Mesh_FileName ---*/
5572+
string meshFilename = Mesh_FileName;
5573+
5574+
/*--- strip the extension, only if it is .su2 or .cgns ---*/
5575+
auto extIndex = meshFilename.rfind(".su2");
5576+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5577+
extIndex = meshFilename.rfind(".cgns");
5578+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5579+
5580+
switch (GetMesh_FileFormat()) {
5581+
case SU2:
5582+
case RECTANGLE:
5583+
case BOX:
5584+
meshFilename += ".su2";
5585+
break;
5586+
case CGNS_GRID:
5587+
meshFilename += ".cgns";
5588+
break;
5589+
default:
5590+
SU2_MPI::Error("Unrecognized mesh format specified!", CURRENT_FUNCTION);
5591+
break;
5592+
}
5593+
5594+
return meshFilename;
5595+
}
55615596

55625597
/*!
55635598
* \brief Get name of the output grid, this parameter is important for grid
55645599
* adaptation and deformation.
55655600
* \return File name of the output grid.
55665601
*/
5567-
string GetMesh_Out_FileName(void) const { return Mesh_Out_FileName; }
5602+
string GetMesh_Out_FileName(void) const {
5603+
5604+
/*--- we keep the original Mesh_Out_FileName ---*/
5605+
string meshFilename = Mesh_Out_FileName;
5606+
5607+
/*--- strip the extension, only if it is .su2 or .cgns ---*/
5608+
auto extIndex = meshFilename.rfind(".su2");
5609+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5610+
extIndex = meshFilename.rfind(".cgns");
5611+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5612+
5613+
return meshFilename;
5614+
}
55685615

55695616
/*!
55705617
* \brief Get the name of the file with the solution of the flow problem.
55715618
* \return Name of the file with the solution of the flow problem.
55725619
*/
5573-
string GetSolution_FileName(void) const { return Solution_FileName; }
5620+
string GetSolution_FileName(void) const {
5621+
/*--- we keep the original Solution_FileName ---*/
5622+
string solutionFilename = Solution_FileName;
5623+
5624+
/*--- strip the extension, only if it is .dat or .csv ---*/
5625+
auto extIndex = solutionFilename.rfind(".dat");
5626+
if (extIndex != std::string::npos) solutionFilename.resize(extIndex);
5627+
extIndex = solutionFilename.rfind(".csv");
5628+
if (extIndex != std::string::npos) solutionFilename.resize(extIndex);
5629+
5630+
/*--- return the stripped filename base, without extension. ---*/
5631+
return solutionFilename;
5632+
}
55745633

55755634
/*!
55765635
* \brief Get the name of the file with the solution of the adjoint flow problem
@@ -5608,7 +5667,68 @@ class CConfig {
56085667
* \brief Get the name of the file with the convergence history of the problem.
56095668
* \return Name of the file with convergence history of the problem.
56105669
*/
5611-
string GetConv_FileName(void) const { return Conv_FileName; }
5670+
string GetHistory_FileName(void) const {
5671+
5672+
/*--- we keep the original Conv_FileName ---*/
5673+
string historyFilename = Conv_FileName;
5674+
5675+
/*--- strip the extension, only if it is .dat or .csv ---*/
5676+
auto extIndex = historyFilename.rfind(".dat");
5677+
if (extIndex != std::string::npos) historyFilename.resize(extIndex);
5678+
extIndex = historyFilename.rfind(".csv");
5679+
if (extIndex != std::string::npos) historyFilename.resize(extIndex);
5680+
5681+
/*--- Multizone problems require the number of the zone to be appended. ---*/
5682+
if (GetMultizone_Problem())
5683+
historyFilename = GetMultizone_FileName(historyFilename, GetiZone(), "");
5684+
5685+
/*--- Append the restart iteration ---*/
5686+
if (GetTime_Domain() && GetRestart()) {
5687+
historyFilename = GetUnsteady_FileName(historyFilename, GetRestart_Iter(), "");
5688+
}
5689+
5690+
/*--- Add the correct file extension depending on the file format ---*/
5691+
string hist_ext = ".csv";
5692+
if (GetTabular_FileFormat() == TAB_OUTPUT::TAB_TECPLOT) hist_ext = ".dat";
5693+
5694+
/*--- Append the extension ---*/
5695+
historyFilename += hist_ext;
5696+
5697+
return historyFilename;
5698+
}
5699+
5700+
/*!
5701+
* \brief Get name of the input file for the specified inlet profile.
5702+
* \return Name of the input file for the specified inlet profile.
5703+
*/
5704+
string GetInlet_FileName(void) const {
5705+
5706+
/*--- we keep the original inlet profile filename ---*/
5707+
string inletProfileFilename = Inlet_Filename;
5708+
5709+
/*--- strip the extension, only if it is .dat or .csv ---*/
5710+
auto extIndex = inletProfileFilename.rfind(".dat");
5711+
if (extIndex != std::string::npos) inletProfileFilename.resize(extIndex);
5712+
extIndex = inletProfileFilename.rfind(".csv");
5713+
if (extIndex != std::string::npos) inletProfileFilename.resize(extIndex);
5714+
5715+
/*--- Multizone problems require the number of the zone to be appended. ---*/
5716+
if (GetMultizone_Problem())
5717+
inletProfileFilename = GetMultizone_FileName(inletProfileFilename, GetiZone(), "");
5718+
5719+
/*--- Modify file name for an unsteady restart ---*/
5720+
if (GetTime_Domain() && GetRestart()) {
5721+
inletProfileFilename = GetUnsteady_FileName(inletProfileFilename, GetRestart_Iter(), "");
5722+
}
5723+
/*--- Add the correct file extension depending on the file format ---*/
5724+
string ext = ".dat";
5725+
5726+
inletProfileFilename += ext;
5727+
5728+
5729+
return inletProfileFilename;
5730+
}
5731+
56125732

56135733
/*!
56145734
* \brief Get the Starting Iteration for the windowing approach
@@ -5659,15 +5779,6 @@ class CConfig {
56595779
*/
56605780
string GetMultizone_FileName(string val_filename, int val_iZone, const string& ext) const;
56615781

5662-
/*!
5663-
* \brief Append the zone index to the restart or the solution files.
5664-
* \param[in] val_filename - the base filename.
5665-
* \param[in] val_iZone - the zone ID.
5666-
* \param[in] ext - the filename extension.
5667-
* \return Name of the restart file for the flow variables.
5668-
*/
5669-
string GetMultizone_HistoryFileName(string val_filename, int val_iZone, const string& ext) const;
5670-
56715782
/*!
56725783
* \brief Append the instance index to the restart or the solution files.
56735784
* \param[in] val_filename - the base filename.

Common/include/toolboxes/printing_toolbox.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
2626
*/
2727

28+
#pragma once
29+
2830
#include <iostream>
2931
#include <iomanip>
3032
#include <cstdint>
@@ -287,4 +289,16 @@ inline std::string StringToUpperCase(const std::string& str) {
287289
return upp_str;
288290
}
289291

292+
/*!
293+
* \brief Trim an extension from a name.
294+
* \param[in] - extension we want to remove.
295+
* \param[in,out] - string we want to trim.
296+
*/
297+
inline void TrimExtension(const std::string& ext, std::string& name) {
298+
const auto extIndex = name.rfind(ext);
299+
if (extIndex != std::string::npos && extIndex + ext.size() == name.size()) {
300+
name.resize(extIndex);
301+
}
302+
}
303+
290304
} // namespace PrintingToolbox

0 commit comments

Comments
 (0)