Skip to content

Commit becab27

Browse files
authored
Merge pull request #1341 from su2code/fix_per_surf_output
Fix "per-surface" outputs
2 parents f47e22b + 9577cba commit becab27

21 files changed

Lines changed: 1401 additions & 1806 deletions

Common/include/toolboxes/printing_toolbox.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ namespace PrintingToolbox {
7171
class CTablePrinter{
7272
public:
7373
CTablePrinter(std::ostream * output, const std::string & separator = "|");
74-
~CTablePrinter();
7574

7675
enum alignment {
7776
CENTER,

Common/src/toolboxes/printing_toolbox.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ PrintingToolbox::CTablePrinter::CTablePrinter(std::ostream * output, const std::
4343
precision_ = 6;
4444
}
4545

46-
PrintingToolbox::CTablePrinter::~CTablePrinter(){
47-
48-
}
49-
5046
int PrintingToolbox::CTablePrinter::GetNumColumns() const {
5147
return (int)column_headers_.size();
5248
}
@@ -102,8 +98,6 @@ void PrintingToolbox::CTablePrinter::PrintHorizontalLine() {
10298

10399
void PrintingToolbox::CTablePrinter::PrintHeader(){
104100

105-
106-
107101
if (print_header_top_line_) PrintHorizontalLine();
108102
*out_stream_ << separator_;
109103
int indent = 0;
@@ -140,4 +134,3 @@ void PrintingToolbox::CTablePrinter::PrintHeader(){
140134
void PrintingToolbox::CTablePrinter::PrintFooter(){
141135
PrintHorizontalLine();
142136
}
143-

SU2_CFD/include/output/CFVMOutput.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ class CFVMOutput : public COutput{
3434
/*!
3535
* \brief Constructor of the class
3636
*/
37-
CFVMOutput(CConfig *config, unsigned short nDim, bool femOutput);
38-
39-
/*!
40-
* \brief Destructor of the class.
41-
*/
42-
~CFVMOutput(void) = default;
37+
CFVMOutput(const CConfig *config, unsigned short nDim, bool femOutput);
4338

4439
/*!
4540
* \brief Add Coordinates to output.

SU2_CFD/include/output/CFlowCompOutput.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CFlowCompOutput final: public CFlowOutput {
4747
* \brief Constructor of the class
4848
* \param[in] config - Definition of the particular problem.
4949
*/
50-
CFlowCompOutput(CConfig *config, unsigned short nDim);
50+
CFlowCompOutput(const CConfig *config, unsigned short nDim);
5151

5252
/*!
5353
* \brief Load the history output field values

SU2_CFD/include/output/CFlowOutput.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ class CFlowOutput : public CFVMOutput{
3838
* \brief Constructor of the class
3939
* \param[in] config - Definition of the particular problem.
4040
*/
41-
CFlowOutput(CConfig *config, unsigned short nDim, bool femOutput);
41+
CFlowOutput(const CConfig *config, unsigned short nDim, bool femOutput);
4242

4343
/*!
4444
* \brief Add flow surface output fields
4545
* \param[in] config - Definition of the particular problem.
4646
*/
47-
void AddAnalyzeSurfaceOutput(CConfig *config);
47+
void AddAnalyzeSurfaceOutput(const CConfig *config);
4848

4949
/*!
5050
* \brief Set flow surface output field values
5151
* \param[in] solver - The container holding all solution data.
5252
* \param[in] geometry - Geometrical definition of the problem.
53-
* \param[in] config - Definition of the particular problem.
53+
* \param[in,out] config - Definition of the particular problem.
5454
* \param[in] output - Boolean indicating whether information should be written to screen
5555
*/
56-
void SetAnalyzeSurface(CSolver *solver, CGeometry *geometry, CConfig *config, bool output);
56+
void SetAnalyzeSurface(const CSolver *solver, const CGeometry *geometry, CConfig *config, bool output);
5757

5858
/*!
5959
* \brief Add aerodynamic coefficients as output fields
@@ -152,10 +152,9 @@ class CFlowOutput : public CFVMOutput{
152152
/*!
153153
* \brief Write the forces breakdown file
154154
* \param[in] config - Definition of the particular problem per zone.
155-
* \param[in] geometry - Geometrical definition of the problem.
156-
* \param[in] solver_container - The container holding all solution data.
155+
* \param[in] flow_solver - The container holding all solution data.
157156
*/
158-
void WriteForcesBreakdown(CConfig *config, CGeometry *geometry, CSolver **solver_container);
157+
void WriteForcesBreakdown(const CConfig *config, const CSolver *flow_solver) const;
159158

160159
/*!
161160
* \brief Set the time averaged output fields.

SU2_CFD/include/output/CMultizoneOutput.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ class CMultizoneOutput final: public COutput {
6161
/*!
6262
* \brief Constructor of the class.
6363
*/
64-
CMultizoneOutput(CConfig *driver_config, CConfig** config, unsigned short nDim);
65-
66-
/*!
67-
* \brief Destructor of the class.
68-
*/
69-
~CMultizoneOutput(void) override;
64+
CMultizoneOutput(const CConfig *driver_config, const CConfig* const* config, unsigned short nDim);
7065

7166
/*!
7267
* \brief Load the multizone history output field values

SU2_CFD/include/output/COutput.hpp

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,21 @@ class COutput {
5757

5858
/*----------------------------- General ----------------------------*/
5959

60-
int rank, /*!< \brief MPI Rank. */
61-
size; /*!< \brief MPI Size. */
60+
const int rank; /*!< \brief MPI Rank. */
61+
const int size; /*!< \brief MPI Size. */
6262

63-
unsigned short nDim; /*!< \brief Physical Dimension */
63+
const unsigned short nDim; /*!< \brief Physical Dimension */
6464

65-
bool multiZone, /*!< \brief Boolean to store whether we are running a multizone problem */
66-
gridMovement, /*!< \brief Boolean to store whether we have grid movement enabled */
67-
femOutput; /*!< \brief Boolean to store whether we should use the FEM routines */
65+
const bool multiZone; /*!< \brief Boolean to store whether we are running a multizone problem */
66+
const bool gridMovement; /*!< \brief Boolean to store whether we have grid movement enabled */
67+
const bool femOutput; /*!< \brief Boolean to store whether we should use the FEM routines */
68+
const bool si_units;
69+
const bool us_units;
6870

6971
/*----------------------------- Screen and history output ----------------------------*/
7072

73+
const unsigned short fieldWidth = 12; /*!< \brief Width of each column for the screen output (hardcoded for now) */
7174
string historySep; /*!< \brief Character which separates values in the history file */
72-
unsigned short fieldWidth; /*!< \brief Width of each column for the screen output (hardcoded for now) */
7375
bool noWriting; /*!< \brief Boolean indicating whether a screen/history output should be written */
7476
unsigned long curTimeIter, /*!< \brief Current value of the time iteration index */
7577
curAbsTimeIter, /*!< \brief Current value of the time iteration index */
@@ -250,7 +252,7 @@ class COutput {
250252
/*!
251253
* \brief Constructor of the class.
252254
*/
253-
COutput(CConfig *config, unsigned short nDim, bool femOutput);
255+
COutput(const CConfig *config, unsigned short nDim, bool femOutput);
254256

255257
/*!
256258
* \brief Preprocess the volume output by setting the requested volume output fields.
@@ -532,8 +534,9 @@ class COutput {
532534
* \param[in] value - The new value of this field.
533535
*/
534536
inline void SetHistoryOutputValue(string name, su2double value){
535-
if (historyOutput_Map.count(name) > 0){
536-
historyOutput_Map[name].value = value;
537+
auto it = historyOutput_Map.find(name);
538+
if (it != historyOutput_Map.end()){
539+
it->second.value = value;
537540
} else {
538541
SU2_MPI::Error(string("Cannot find output field with name ") + name, CURRENT_FUNCTION);
539542
}
@@ -549,13 +552,16 @@ class COutput {
549552
* \param[in] field_type - The type of the field (::HistoryFieldType).
550553
*/
551554
inline void AddHistoryOutputPerSurface(string name, string field_name, ScreenOutputFormat format,
552-
string groupname, vector<string> marker_names,
553-
HistoryFieldType field_type = HistoryFieldType::DEFAULT){
554-
if (marker_names.size() != 0){
555+
string groupname, const vector<string>& marker_names,
556+
HistoryFieldType field_type = HistoryFieldType::DEFAULT) {
557+
if (!marker_names.empty()) {
555558
historyOutputPerSurface_List.push_back(name);
556-
for (unsigned short i = 0; i < marker_names.size(); i++){
557-
historyOutputPerSurface_Map[name].push_back(HistoryOutputField(field_name+"("+marker_names[i]+")", format, groupname, field_type, ""));
559+
vector<HistoryOutputField> fields;
560+
fields.reserve(marker_names.size());
561+
for (const auto& marker : marker_names) {
562+
fields.push_back(HistoryOutputField(field_name+"("+marker+")", format, groupname, field_type, ""));
558563
}
564+
historyOutputPerSurface_Map[name] = std::move(fields);
559565
}
560566
}
561567

@@ -565,9 +571,10 @@ class COutput {
565571
* \param[in] value - The new value of this field.
566572
* \param[in] iMarker - The index of the marker.
567573
*/
568-
inline void SetHistoryOutputPerSurfaceValue(string name, su2double value, unsigned short iMarker){
569-
if (historyOutputPerSurface_Map.count(name) > 0){
570-
historyOutputPerSurface_Map[name][iMarker].value = value;
574+
inline void SetHistoryOutputPerSurfaceValue(string name, su2double value, unsigned short iMarker) {
575+
auto it = historyOutputPerSurface_Map.find(name);
576+
if (it != historyOutputPerSurface_Map.end()) {
577+
it->second[iMarker].value = value;
571578
} else {
572579
SU2_MPI::Error(string("Cannot find output field with name ") + name, CURRENT_FUNCTION);
573580
}

SU2_CFD/include/variables/CNEMOEulerVariable.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include "CVariable.hpp"
3131
#include "../fluid/CNEMOGas.hpp"
32-
#include "../../Common/include/toolboxes/geometry_toolbox.hpp"
32+
#include "../../../Common/include/toolboxes/geometry_toolbox.hpp"
3333

3434
/*!
3535
* \class CNEMOEulerVariable

SU2_CFD/src/output/CFVMOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "../../../Common/include/geometry/CGeometry.hpp"
3030

3131

32-
CFVMOutput::CFVMOutput(CConfig *config, unsigned short nDim, bool fem_output) : COutput (config, nDim, fem_output){ }
32+
CFVMOutput::CFVMOutput(const CConfig *config, unsigned short nDim, bool fem_output) : COutput (config, nDim, fem_output){ }
3333

3434
void CFVMOutput::AddCoordinates() {
3535

SU2_CFD/src/output/CFlowCompFEMOutput.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ CFlowCompFEMOutput::CFlowCompFEMOutput(CConfig *config, unsigned short nDim) : C
3535

3636
turb_model = config->GetKind_Turb_Model();
3737

38-
gridMovement = config->GetGrid_Movement();
39-
4038
/*--- Set the default history fields if nothing is set in the config file ---*/
4139

4240
if (nRequestedHistoryFields == 0){

0 commit comments

Comments
 (0)