Skip to content

Commit 34890f3

Browse files
committed
the fixes
1 parent f47e22b commit 34890f3

7 files changed

Lines changed: 72 additions & 71 deletions

File tree

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/CFlowOutput.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class CFlowOutput : public CFVMOutput{
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

SU2_CFD/include/output/COutput.hpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,9 @@ class COutput {
532532
* \param[in] value - The new value of this field.
533533
*/
534534
inline void SetHistoryOutputValue(string name, su2double value){
535-
if (historyOutput_Map.count(name) > 0){
536-
historyOutput_Map[name].value = value;
535+
auto it = historyOutput_Map.find(name);
536+
if (it != historyOutput_Map.end()){
537+
it->second.value = value;
537538
} else {
538539
SU2_MPI::Error(string("Cannot find output field with name ") + name, CURRENT_FUNCTION);
539540
}
@@ -549,13 +550,16 @@ class COutput {
549550
* \param[in] field_type - The type of the field (::HistoryFieldType).
550551
*/
551552
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){
553+
string groupname, const vector<string>& marker_names,
554+
HistoryFieldType field_type = HistoryFieldType::DEFAULT) {
555+
if (!marker_names.empty()) {
555556
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, ""));
557+
vector<HistoryOutputField> fields;
558+
fields.reserve(marker_names.size());
559+
for (const auto& marker : marker_names) {
560+
fields.push_back(HistoryOutputField(field_name+"("+marker+")", format, groupname, field_type, ""));
558561
}
562+
historyOutputPerSurface_Map[name] = std::move(fields);
559563
}
560564
}
561565

@@ -565,9 +569,10 @@ class COutput {
565569
* \param[in] value - The new value of this field.
566570
* \param[in] iMarker - The index of the marker.
567571
*/
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;
572+
inline void SetHistoryOutputPerSurfaceValue(string name, su2double value, unsigned short iMarker) {
573+
auto it = historyOutputPerSurface_Map.find(name);
574+
if (it != historyOutputPerSurface_Map.end()) {
575+
it->second[iMarker].value = value;
571576
} else {
572577
SU2_MPI::Error(string("Cannot find output field with name ") + name, CURRENT_FUNCTION);
573578
}

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/CFlowOutput.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ CFlowOutput::CFlowOutput(CConfig *config, unsigned short nDim, bool fem_output)
3535
lastInnerIter = curInnerIter;
3636
}
3737

38-
void CFlowOutput::AddAnalyzeSurfaceOutput(CConfig *config){
39-
38+
void CFlowOutput::AddAnalyzeSurfaceOutput(const CConfig *config){
4039

4140
/// DESCRIPTION: Average mass flow
4241
AddHistoryOutput("SURFACE_MASSFLOW", "Avg_Massflow", ScreenOutputFormat::SCIENTIFIC, "FLOW_COEFF", "Total average mass flow on all markers set in MARKER_ANALYZE", HistoryFieldType::COEFFICIENT);

SU2_CFD/src/output/COutput.cpp

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,6 @@ void COutput::SetHistoryFile_Output(const CConfig *config) {
10291029
unsigned short iField_Output = 0,
10301030
iReqField = 0,
10311031
iMarker = 0;
1032-
stringstream out;
10331032

10341033
for (iField_Output = 0; iField_Output < historyOutput_List.size(); iField_Output++){
10351034
const string &fieldIdentifier = historyOutput_List[iField_Output];
@@ -1069,44 +1068,48 @@ void COutput::SetScreen_Header(const CConfig *config) {
10691068

10701069
void COutput::SetScreen_Output(const CConfig *config) {
10711070

1072-
string RequestedField;
1073-
1074-
for (unsigned short iReqField = 0; iReqField < nRequestedScreenFields; iReqField++){
1075-
stringstream out;
1076-
RequestedField = requestedScreenFields[iReqField];
1077-
if (historyOutput_Map.count(RequestedField) > 0){
1078-
switch (historyOutput_Map.at(RequestedField).screenFormat) {
1071+
for (const auto& RequestedField : requestedScreenFields) {
1072+
const auto it1 = historyOutput_Map.find(RequestedField);
1073+
if (it1 != historyOutput_Map.end()) {
1074+
const auto& field = it1->second;
1075+
stringstream out;
1076+
switch (field.screenFormat) {
10791077
case ScreenOutputFormat::INTEGER:
1080-
PrintingToolbox::PrintScreenInteger(out, SU2_TYPE::Int(historyOutput_Map.at(RequestedField).value), fieldWidth);
1078+
PrintingToolbox::PrintScreenInteger(out, SU2_TYPE::Int(field.value), fieldWidth);
10811079
break;
10821080
case ScreenOutputFormat::FIXED:
1083-
PrintingToolbox::PrintScreenFixed(out, historyOutput_Map.at(RequestedField).value, fieldWidth);
1081+
PrintingToolbox::PrintScreenFixed(out, field.value, fieldWidth);
10841082
break;
10851083
case ScreenOutputFormat::SCIENTIFIC:
1086-
PrintingToolbox::PrintScreenScientific(out, historyOutput_Map.at(RequestedField).value, fieldWidth);
1084+
PrintingToolbox::PrintScreenScientific(out, field.value, fieldWidth);
10871085
break;
10881086
case ScreenOutputFormat::PERCENT:
1089-
PrintingToolbox::PrintScreenPercent(out, historyOutput_Map[RequestedField].value, fieldWidth);
1087+
PrintingToolbox::PrintScreenPercent(out, field.value, fieldWidth);
10901088
break;
10911089
}
1092-
}
1093-
if (historyOutputPerSurface_Map.count(RequestedField) > 0){
1094-
switch (historyOutputPerSurface_Map.at(RequestedField)[0].screenFormat) {
1095-
case ScreenOutputFormat::INTEGER:
1096-
PrintingToolbox::PrintScreenInteger(out, SU2_TYPE::Int(historyOutputPerSurface_Map.at(RequestedField)[0].value), fieldWidth);
1097-
break;
1098-
case ScreenOutputFormat::FIXED:
1099-
PrintingToolbox::PrintScreenFixed(out, historyOutputPerSurface_Map.at(RequestedField)[0].value, fieldWidth);
1100-
break;
1101-
case ScreenOutputFormat::SCIENTIFIC:
1102-
PrintingToolbox::PrintScreenScientific(out, historyOutputPerSurface_Map.at(RequestedField)[0].value, fieldWidth);
1103-
break;
1104-
case ScreenOutputFormat::PERCENT:
1105-
PrintingToolbox::PrintScreenPercent(out, historyOutputPerSurface_Map[RequestedField][0].value, fieldWidth);
1106-
break;
1090+
(*convergenceTable) << out.str();
1091+
}
1092+
const auto it2 = historyOutputPerSurface_Map.find(RequestedField);
1093+
if (it2 != historyOutputPerSurface_Map.end()) {
1094+
for (const auto& field : it2->second) {
1095+
stringstream out;
1096+
switch (field.screenFormat) {
1097+
case ScreenOutputFormat::INTEGER:
1098+
PrintingToolbox::PrintScreenInteger(out, SU2_TYPE::Int(field.value), fieldWidth);
1099+
break;
1100+
case ScreenOutputFormat::FIXED:
1101+
PrintingToolbox::PrintScreenFixed(out, field.value, fieldWidth);
1102+
break;
1103+
case ScreenOutputFormat::SCIENTIFIC:
1104+
PrintingToolbox::PrintScreenScientific(out, field.value, fieldWidth);
1105+
break;
1106+
case ScreenOutputFormat::PERCENT:
1107+
PrintingToolbox::PrintScreenPercent(out, field.value, fieldWidth);
1108+
break;
1109+
}
1110+
(*convergenceTable) << out.str();
11071111
}
11081112
}
1109-
(*convergenceTable) << out.str();
11101113
}
11111114
SetAdditionalScreenOutput(config);
11121115
}
@@ -1209,7 +1212,7 @@ void COutput::PrepareHistoryFile(CConfig *config){
12091212

12101213
/*--- Open the history file ---*/
12111214

1212-
histFile.open(historyFilename.c_str(), ios::out);
1215+
histFile.open(historyFilename, ios::out);
12131216

12141217
/*--- Create and format the history file table ---*/
12151218

@@ -1225,23 +1228,26 @@ void COutput::PrepareHistoryFile(CConfig *config){
12251228

12261229
}
12271230

1228-
void COutput::CheckHistoryOutput(){
1229-
1231+
void COutput::CheckHistoryOutput() {
12301232

12311233
/*--- Set screen convergence output header and remove unavailable fields ---*/
12321234

1233-
string requestedField;
12341235
vector<string> FieldsToRemove;
12351236
vector<bool> FoundField(nRequestedHistoryFields, false);
12361237

1237-
for (unsigned short iReqField = 0; iReqField < nRequestedScreenFields; iReqField++){
1238-
requestedField = requestedScreenFields[iReqField];
1239-
if (historyOutput_Map.count(requestedField) > 0){
1240-
convergenceTable->AddColumn(historyOutput_Map.at(requestedField).fieldName, fieldWidth);
1238+
for (unsigned short iReqField = 0; iReqField < nRequestedScreenFields; iReqField++) {
1239+
const auto& requestedField = requestedScreenFields[iReqField];
1240+
const auto it1 = historyOutput_Map.find(requestedField);
1241+
if (it1 != historyOutput_Map.end()) {
1242+
convergenceTable->AddColumn(it1->second.fieldName, fieldWidth);
1243+
}
1244+
const auto it2 = historyOutputPerSurface_Map.find(requestedField);
1245+
if (it2 != historyOutputPerSurface_Map.end()) {
1246+
for (const auto& field : it2->second) {
1247+
convergenceTable->AddColumn(field.fieldName, fieldWidth);
1248+
}
12411249
}
1242-
else if (historyOutputPerSurface_Map.count(requestedField) > 0){
1243-
convergenceTable->AddColumn(historyOutputPerSurface_Map.at(requestedField)[0].fieldName, fieldWidth);
1244-
}else {
1250+
if (it1 == historyOutput_Map.end() && it2 == historyOutputPerSurface_Map.end()) {
12451251
FieldsToRemove.push_back(requestedField);
12461252
}
12471253
}
@@ -1253,8 +1259,9 @@ void COutput::CheckHistoryOutput(){
12531259
if (iReqField == 0){
12541260
cout << " Info: Ignoring the following screen output fields:" << endl;
12551261
cout << " ";
1256-
} cout << FieldsToRemove[iReqField];
1257-
if (iReqField != FieldsToRemove.size()-1){
1262+
}
1263+
cout << FieldsToRemove[iReqField];
1264+
if (iReqField != FieldsToRemove.size()-1) {
12581265
cout << ", ";
12591266
} else {
12601267
cout << endl;
@@ -1269,7 +1276,6 @@ void COutput::CheckHistoryOutput(){
12691276
if (rank == MASTER_NODE){
12701277
cout <<"Screen output fields: ";
12711278
for (unsigned short iReqField = 0; iReqField < nRequestedScreenFields; iReqField++){
1272-
requestedField = requestedScreenFields[iReqField];
12731279
cout << requestedScreenFields[iReqField];
12741280
if (iReqField != nRequestedScreenFields - 1) cout << ", ";
12751281
}
@@ -1286,7 +1292,7 @@ void COutput::CheckHistoryOutput(){
12861292
if (historyOutput_Map.count(fieldReference) > 0){
12871293
const HistoryOutputField &field = historyOutput_Map.at(fieldReference);
12881294
for (unsigned short iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++){
1289-
requestedField = requestedHistoryFields[iReqField];
1295+
const auto& requestedField = requestedHistoryFields[iReqField];
12901296
if (requestedField == field.outputGroup){
12911297
FoundField[iReqField] = true;
12921298
}
@@ -1296,11 +1302,10 @@ void COutput::CheckHistoryOutput(){
12961302

12971303
for (unsigned short iField_Output = 0; iField_Output < historyOutputPerSurface_List.size(); iField_Output++){
12981304
const string &fieldReference = historyOutputPerSurface_List[iField_Output];
1299-
if (historyOutputPerSurface_Map.count(fieldReference) > 0){
1300-
for (unsigned short iMarker = 0; iMarker < historyOutputPerSurface_Map.at(fieldReference).size(); iMarker++){
1301-
const HistoryOutputField &Field = historyOutputPerSurface_Map.at(fieldReference)[iMarker];
1305+
if (historyOutputPerSurface_Map.count(fieldReference) > 0) {
1306+
for (const auto &Field : historyOutputPerSurface_Map.at(fieldReference)) {
13021307
for (unsigned short iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++){
1303-
requestedField = requestedHistoryFields[iReqField];
1308+
const auto& requestedField = requestedHistoryFields[iReqField];
13041309
if (requestedField == Field.outputGroup){
13051310
FoundField[iReqField] = true;
13061311
}
@@ -1322,7 +1327,8 @@ void COutput::CheckHistoryOutput(){
13221327
if (iReqField == 0){
13231328
cout << " Info: Ignoring the following history output groups:" << endl;
13241329
cout << " ";
1325-
} cout << FieldsToRemove[iReqField];
1330+
}
1331+
cout << FieldsToRemove[iReqField];
13261332
if (iReqField != FieldsToRemove.size()-1){
13271333
cout << ", ";
13281334
} else {
@@ -1338,7 +1344,6 @@ void COutput::CheckHistoryOutput(){
13381344
if (rank == MASTER_NODE){
13391345
cout <<"History output group(s): ";
13401346
for (unsigned short iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++){
1341-
requestedField = requestedHistoryFields[iReqField];
13421347
cout << requestedHistoryFields[iReqField];
13431348
if (iReqField != nRequestedHistoryFields - 1) cout << ", ";
13441349
}

0 commit comments

Comments
 (0)