Skip to content

Commit 716c3b2

Browse files
Merge branch 'develop' into feature_conductivity
2 parents c784eb3 + deece11 commit 716c3b2

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. */
@@ -2304,7 +2304,22 @@ class CConfig {
23042304
* \brief Get the name of the file with the element properties for structural problems.
23052305
* \return Name of the file with the element properties of the structural problem.
23062306
*/
2307-
string GetFEA_FileName(void) const { return FEA_FileName; }
2307+
string GetFEA_FileName(void) const {
2308+
string FEAFilename = FEA_FileName;
2309+
2310+
/*--- strip the extension if it is present, only if it is .dat ---*/
2311+
PrintingToolbox::TrimExtension(".dat", FEAFilename);
2312+
2313+
/*--- If multizone, append zone name ---*/
2314+
if (Multizone_Problem)
2315+
FEAFilename = GetMultizone_FileName(FEAFilename, GetiZone(), "");
2316+
2317+
/*--- Add the extension again ---*/
2318+
FEAFilename += ".dat";
2319+
2320+
/*--- return the stripped filename base, without extension. ---*/
2321+
return FEAFilename;
2322+
}
23082323

23092324
/*!
23102325
* \brief Determine if advanced features are used from the element-based FEA analysis (experimental feature).
@@ -5073,12 +5088,6 @@ class CConfig {
50735088
*/
50745089
bool GetInlet_Profile_From_File(void) const { return Inlet_From_File; }
50755090

5076-
/*!
5077-
* \brief Get name of the input file for the specified inlet profile.
5078-
* \return Name of the input file for the specified inlet profile.
5079-
*/
5080-
string GetInlet_FileName(void) const { return Inlet_Filename; }
5081-
50825091
/*!
50835092
* \brief Get name of the input file for the specified actuator disk.
50845093
* \return Name of the input file for the specified actuator disk.
@@ -5601,20 +5610,70 @@ class CConfig {
56015610
* \brief Get name of the input grid.
56025611
* \return File name of the input grid.
56035612
*/
5604-
string GetMesh_FileName(void) const { return Mesh_FileName; }
5613+
string GetMesh_FileName(void) const {
5614+
5615+
/*--- we keep the original Mesh_FileName ---*/
5616+
string meshFilename = Mesh_FileName;
5617+
5618+
/*--- strip the extension, only if it is .su2 or .cgns ---*/
5619+
auto extIndex = meshFilename.rfind(".su2");
5620+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5621+
extIndex = meshFilename.rfind(".cgns");
5622+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5623+
5624+
switch (GetMesh_FileFormat()) {
5625+
case SU2:
5626+
case RECTANGLE:
5627+
case BOX:
5628+
meshFilename += ".su2";
5629+
break;
5630+
case CGNS_GRID:
5631+
meshFilename += ".cgns";
5632+
break;
5633+
default:
5634+
SU2_MPI::Error("Unrecognized mesh format specified!", CURRENT_FUNCTION);
5635+
break;
5636+
}
5637+
5638+
return meshFilename;
5639+
}
56055640

56065641
/*!
56075642
* \brief Get name of the output grid, this parameter is important for grid
56085643
* adaptation and deformation.
56095644
* \return File name of the output grid.
56105645
*/
5611-
string GetMesh_Out_FileName(void) const { return Mesh_Out_FileName; }
5646+
string GetMesh_Out_FileName(void) const {
5647+
5648+
/*--- we keep the original Mesh_Out_FileName ---*/
5649+
string meshFilename = Mesh_Out_FileName;
5650+
5651+
/*--- strip the extension, only if it is .su2 or .cgns ---*/
5652+
auto extIndex = meshFilename.rfind(".su2");
5653+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5654+
extIndex = meshFilename.rfind(".cgns");
5655+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5656+
5657+
return meshFilename;
5658+
}
56125659

56135660
/*!
56145661
* \brief Get the name of the file with the solution of the flow problem.
56155662
* \return Name of the file with the solution of the flow problem.
56165663
*/
5617-
string GetSolution_FileName(void) const { return Solution_FileName; }
5664+
string GetSolution_FileName(void) const {
5665+
/*--- we keep the original Solution_FileName ---*/
5666+
string solutionFilename = Solution_FileName;
5667+
5668+
/*--- strip the extension, only if it is .dat or .csv ---*/
5669+
auto extIndex = solutionFilename.rfind(".dat");
5670+
if (extIndex != std::string::npos) solutionFilename.resize(extIndex);
5671+
extIndex = solutionFilename.rfind(".csv");
5672+
if (extIndex != std::string::npos) solutionFilename.resize(extIndex);
5673+
5674+
/*--- return the stripped filename base, without extension. ---*/
5675+
return solutionFilename;
5676+
}
56185677

56195678
/*!
56205679
* \brief Get the name of the file with the solution of the adjoint flow problem
@@ -5652,7 +5711,68 @@ class CConfig {
56525711
* \brief Get the name of the file with the convergence history of the problem.
56535712
* \return Name of the file with convergence history of the problem.
56545713
*/
5655-
string GetConv_FileName(void) const { return Conv_FileName; }
5714+
string GetHistory_FileName(void) const {
5715+
5716+
/*--- we keep the original Conv_FileName ---*/
5717+
string historyFilename = Conv_FileName;
5718+
5719+
/*--- strip the extension, only if it is .dat or .csv ---*/
5720+
auto extIndex = historyFilename.rfind(".dat");
5721+
if (extIndex != std::string::npos) historyFilename.resize(extIndex);
5722+
extIndex = historyFilename.rfind(".csv");
5723+
if (extIndex != std::string::npos) historyFilename.resize(extIndex);
5724+
5725+
/*--- Multizone problems require the number of the zone to be appended. ---*/
5726+
if (GetMultizone_Problem())
5727+
historyFilename = GetMultizone_FileName(historyFilename, GetiZone(), "");
5728+
5729+
/*--- Append the restart iteration ---*/
5730+
if (GetTime_Domain() && GetRestart()) {
5731+
historyFilename = GetUnsteady_FileName(historyFilename, GetRestart_Iter(), "");
5732+
}
5733+
5734+
/*--- Add the correct file extension depending on the file format ---*/
5735+
string hist_ext = ".csv";
5736+
if (GetTabular_FileFormat() == TAB_OUTPUT::TAB_TECPLOT) hist_ext = ".dat";
5737+
5738+
/*--- Append the extension ---*/
5739+
historyFilename += hist_ext;
5740+
5741+
return historyFilename;
5742+
}
5743+
5744+
/*!
5745+
* \brief Get name of the input file for the specified inlet profile.
5746+
* \return Name of the input file for the specified inlet profile.
5747+
*/
5748+
string GetInlet_FileName(void) const {
5749+
5750+
/*--- we keep the original inlet profile filename ---*/
5751+
string inletProfileFilename = Inlet_Filename;
5752+
5753+
/*--- strip the extension, only if it is .dat or .csv ---*/
5754+
auto extIndex = inletProfileFilename.rfind(".dat");
5755+
if (extIndex != std::string::npos) inletProfileFilename.resize(extIndex);
5756+
extIndex = inletProfileFilename.rfind(".csv");
5757+
if (extIndex != std::string::npos) inletProfileFilename.resize(extIndex);
5758+
5759+
/*--- Multizone problems require the number of the zone to be appended. ---*/
5760+
if (GetMultizone_Problem())
5761+
inletProfileFilename = GetMultizone_FileName(inletProfileFilename, GetiZone(), "");
5762+
5763+
/*--- Modify file name for an unsteady restart ---*/
5764+
if (GetTime_Domain() && GetRestart()) {
5765+
inletProfileFilename = GetUnsteady_FileName(inletProfileFilename, GetRestart_Iter(), "");
5766+
}
5767+
/*--- Add the correct file extension depending on the file format ---*/
5768+
string ext = ".dat";
5769+
5770+
inletProfileFilename += ext;
5771+
5772+
5773+
return inletProfileFilename;
5774+
}
5775+
56565776

56575777
/*!
56585778
* \brief Get the Starting Iteration for the windowing approach
@@ -5703,15 +5823,6 @@ class CConfig {
57035823
*/
57045824
string GetMultizone_FileName(string val_filename, int val_iZone, const string& ext) const;
57055825

5706-
/*!
5707-
* \brief Append the zone index to the restart or the solution files.
5708-
* \param[in] val_filename - the base filename.
5709-
* \param[in] val_iZone - the zone ID.
5710-
* \param[in] ext - the filename extension.
5711-
* \return Name of the restart file for the flow variables.
5712-
*/
5713-
string GetMultizone_HistoryFileName(string val_filename, int val_iZone, const string& ext) const;
5714-
57155826
/*!
57165827
* \brief Append the instance index to the restart or the solution files.
57175828
* \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)