Skip to content

Commit deece11

Browse files
bigfootednijso beishuizengithub-advanced-security[bot]pcarruscag
authored
Fix volume names (#2079)
* fix volume names Co-authored-by: nijso beishuizen <[email protected]> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Pedro Gomes <[email protected]> Co-authored-by: Pedro Gomes <[email protected]>
1 parent a928ecb commit deece11

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. */
@@ -2276,7 +2276,22 @@ class CConfig {
22762276
* \brief Get the name of the file with the element properties for structural problems.
22772277
* \return Name of the file with the element properties of the structural problem.
22782278
*/
2279-
string GetFEA_FileName(void) const { return FEA_FileName; }
2279+
string GetFEA_FileName(void) const {
2280+
string FEAFilename = FEA_FileName;
2281+
2282+
/*--- strip the extension if it is present, only if it is .dat ---*/
2283+
PrintingToolbox::TrimExtension(".dat", FEAFilename);
2284+
2285+
/*--- If multizone, append zone name ---*/
2286+
if (Multizone_Problem)
2287+
FEAFilename = GetMultizone_FileName(FEAFilename, GetiZone(), "");
2288+
2289+
/*--- Add the extension again ---*/
2290+
FEAFilename += ".dat";
2291+
2292+
/*--- return the stripped filename base, without extension. ---*/
2293+
return FEAFilename;
2294+
}
22802295

22812296
/*!
22822297
* \brief Determine if advanced features are used from the element-based FEA analysis (experimental feature).
@@ -5021,12 +5036,6 @@ class CConfig {
50215036
*/
50225037
bool GetInlet_Profile_From_File(void) const { return Inlet_From_File; }
50235038

5024-
/*!
5025-
* \brief Get name of the input file for the specified inlet profile.
5026-
* \return Name of the input file for the specified inlet profile.
5027-
*/
5028-
string GetInlet_FileName(void) const { return Inlet_Filename; }
5029-
50305039
/*!
50315040
* \brief Get name of the input file for the specified actuator disk.
50325041
* \return Name of the input file for the specified actuator disk.
@@ -5549,20 +5558,70 @@ class CConfig {
55495558
* \brief Get name of the input grid.
55505559
* \return File name of the input grid.
55515560
*/
5552-
string GetMesh_FileName(void) const { return Mesh_FileName; }
5561+
string GetMesh_FileName(void) const {
5562+
5563+
/*--- we keep the original Mesh_FileName ---*/
5564+
string meshFilename = Mesh_FileName;
5565+
5566+
/*--- strip the extension, only if it is .su2 or .cgns ---*/
5567+
auto extIndex = meshFilename.rfind(".su2");
5568+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5569+
extIndex = meshFilename.rfind(".cgns");
5570+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5571+
5572+
switch (GetMesh_FileFormat()) {
5573+
case SU2:
5574+
case RECTANGLE:
5575+
case BOX:
5576+
meshFilename += ".su2";
5577+
break;
5578+
case CGNS_GRID:
5579+
meshFilename += ".cgns";
5580+
break;
5581+
default:
5582+
SU2_MPI::Error("Unrecognized mesh format specified!", CURRENT_FUNCTION);
5583+
break;
5584+
}
5585+
5586+
return meshFilename;
5587+
}
55535588

55545589
/*!
55555590
* \brief Get name of the output grid, this parameter is important for grid
55565591
* adaptation and deformation.
55575592
* \return File name of the output grid.
55585593
*/
5559-
string GetMesh_Out_FileName(void) const { return Mesh_Out_FileName; }
5594+
string GetMesh_Out_FileName(void) const {
5595+
5596+
/*--- we keep the original Mesh_Out_FileName ---*/
5597+
string meshFilename = Mesh_Out_FileName;
5598+
5599+
/*--- strip the extension, only if it is .su2 or .cgns ---*/
5600+
auto extIndex = meshFilename.rfind(".su2");
5601+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5602+
extIndex = meshFilename.rfind(".cgns");
5603+
if (extIndex != std::string::npos) meshFilename.resize(extIndex);
5604+
5605+
return meshFilename;
5606+
}
55605607

55615608
/*!
55625609
* \brief Get the name of the file with the solution of the flow problem.
55635610
* \return Name of the file with the solution of the flow problem.
55645611
*/
5565-
string GetSolution_FileName(void) const { return Solution_FileName; }
5612+
string GetSolution_FileName(void) const {
5613+
/*--- we keep the original Solution_FileName ---*/
5614+
string solutionFilename = Solution_FileName;
5615+
5616+
/*--- strip the extension, only if it is .dat or .csv ---*/
5617+
auto extIndex = solutionFilename.rfind(".dat");
5618+
if (extIndex != std::string::npos) solutionFilename.resize(extIndex);
5619+
extIndex = solutionFilename.rfind(".csv");
5620+
if (extIndex != std::string::npos) solutionFilename.resize(extIndex);
5621+
5622+
/*--- return the stripped filename base, without extension. ---*/
5623+
return solutionFilename;
5624+
}
55665625

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

56055725
/*!
56065726
* \brief Get the Starting Iteration for the windowing approach
@@ -5651,15 +5771,6 @@ class CConfig {
56515771
*/
56525772
string GetMultizone_FileName(string val_filename, int val_iZone, const string& ext) const;
56535773

5654-
/*!
5655-
* \brief Append the zone index to the restart or the solution files.
5656-
* \param[in] val_filename - the base filename.
5657-
* \param[in] val_iZone - the zone ID.
5658-
* \param[in] ext - the filename extension.
5659-
* \return Name of the restart file for the flow variables.
5660-
*/
5661-
string GetMultizone_HistoryFileName(string val_filename, int val_iZone, const string& ext) const;
5662-
56635774
/*!
56645775
* \brief Append the instance index to the restart or the solution files.
56655776
* \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)