Skip to content

Commit cf4f609

Browse files
committed
missing initialization
1 parent e599fa1 commit cf4f609

File tree

8 files changed

+33
-51
lines changed

8 files changed

+33
-51
lines changed

SU2_CFD/include/output/COutput.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,19 +260,18 @@ class COutput {
260260
/*! \brief The name of the field, i.e. the name that is printed in the file header.*/
261261
string fieldName;
262262
/*! \brief This value identifies the position of the values of this field at each node in the ::Local_Data array. */
263-
short offset;
263+
short offset = -1;
264264
/*! \brief This offset is used for the compact formulation. */
265-
short offsetCompact;
265+
short offsetCompact = -1;
266266
/*! \brief The group this field belongs to. */
267267
string outputGroup;
268268
/*! \brief String containing the description of the field. */
269269
string description;
270270
/*! \brief Default constructor. */
271271
VolumeOutputField() = default;
272272
/*! \brief Constructor to initialize all members. */
273-
VolumeOutputField(string fieldName_, int offset_, string volumeOutputGroup_, string description_):
273+
VolumeOutputField(string fieldName_, string volumeOutputGroup_, string description_):
274274
fieldName(std::move(fieldName_)),
275-
offset(offset_),
276275
outputGroup(std::move(volumeOutputGroup_)),
277276
description(std::move(description_)) {}
278277
};
@@ -746,8 +745,9 @@ class COutput {
746745
* \param[in] groupname - The name of the group this field belongs to.
747746
* \param[in] description - Description of the volume field.
748747
*/
749-
inline void AddVolumeOutput(string name, string field_name, string groupname, string description){
750-
volumeOutput_Map[name] = VolumeOutputField(field_name, -1, groupname, description);
748+
inline void AddVolumeOutput(const string& name, const string& field_name,
749+
const string& group_name, const string& description) {
750+
volumeOutput_Map[name] = VolumeOutputField(field_name, group_name, description);
751751
volumeOutput_List.push_back(name);
752752
}
753753

SU2_CFD/src/output/CAdjFlowCompOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ CAdjFlowCompOutput::CAdjFlowCompOutput(CConfig *config, unsigned short nDim) : C
6161

6262
if (find(requestedVolumeFields.begin(), requestedVolumeFields.end(), string("SENSITIVITY")) == requestedVolumeFields.end()) {
6363
requestedVolumeFields.emplace_back("SENSITIVITY");
64-
nRequestedVolumeFields ++;
64+
nRequestedVolumeFields++;
6565
}
6666

6767
stringstream ss;

SU2_CFD/src/output/CAdjFlowIncOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ CAdjFlowIncOutput::CAdjFlowIncOutput(CConfig *config, unsigned short nDim) : CAd
6767

6868
if (find(requestedVolumeFields.begin(), requestedVolumeFields.end(), string("SENSITIVITY")) == requestedVolumeFields.end()) {
6969
requestedVolumeFields.emplace_back("SENSITIVITY");
70-
nRequestedVolumeFields ++;
70+
nRequestedVolumeFields++;
7171
}
7272

7373
stringstream ss;

SU2_CFD/src/output/CAdjHeatOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ CAdjHeatOutput::CAdjHeatOutput(CConfig *config, unsigned short nDim) : COutput(c
5858

5959
if (find(requestedVolumeFields.begin(), requestedVolumeFields.end(), string("SENSITIVITY")) == requestedVolumeFields.end()) {
6060
requestedVolumeFields.emplace_back("SENSITIVITY");
61-
nRequestedVolumeFields ++;
61+
nRequestedVolumeFields++;
6262
}
6363

6464
stringstream ss;

SU2_CFD/src/output/CFlowCompOutput.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ CFlowCompOutput::CFlowCompOutput(const CConfig *config, unsigned short nDim) : C
6161
auto notFound = requestedVolumeFields.end();
6262
if (find(requestedVolumeFields.begin(), notFound, string("GRID_VELOCITY")) == notFound) {
6363
requestedVolumeFields.emplace_back("GRID_VELOCITY");
64-
nRequestedVolumeFields ++;
64+
nRequestedVolumeFields++;
6565
}
6666
}
6767

@@ -219,7 +219,7 @@ void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){
219219
AddVolumeOutput("DENSITY", "Density", "SOLUTION", "Density");
220220
AddVolumeOutput("MOMENTUM-X", "Momentum_x", "SOLUTION", "x-component of the momentum vector");
221221
AddVolumeOutput("MOMENTUM-Y", "Momentum_y", "SOLUTION", "y-component of the momentum vector");
222-
222+
223223
if (nDim == 3)
224224
AddVolumeOutput("MOMENTUM-Z", "Momentum_z", "SOLUTION", "z-component of the momentum vector");
225225
AddVolumeOutput("ENERGY", "Energy", "SOLUTION", "Energy");
@@ -241,7 +241,7 @@ void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){
241241
AddVolumeOutput("PRESSURE_COEFF", "Pressure_Coefficient", "PRIMITIVE", "Pressure coefficient");
242242
AddVolumeOutput("VELOCITY-X", "Velocity_x", "PRIMITIVE", "x-component of the velocity vector");
243243
AddVolumeOutput("VELOCITY-Y", "Velocity_y", "PRIMITIVE", "y-component of the velocity vector");
244-
244+
245245
if (nDim == 3)
246246
AddVolumeOutput("VELOCITY-Z", "Velocity_z", "PRIMITIVE", "z-component of the velocity vector");
247247

@@ -525,7 +525,7 @@ void CFlowCompOutput::SetTurboPerformance_Output(std::shared_ptr<CTurboOutput> T
525525

526526
for (unsigned short iZone = 0; iZone <= config->GetnZone()-1; iZone++) {
527527
auto nSpan = config->GetnSpan_iZones(iZone);
528-
const auto& BladePerf = BladePerformance.at(iZone).at(nSpan);
528+
const auto& BladePerf = BladePerformance.at(iZone).at(nSpan);
529529

530530
TurboInOut<<" BLADE ROW INDEX "<<iZone <<"";
531531
TurboInOut.PrintFooter();
@@ -772,7 +772,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr<CTurboOutput
772772
file.width(30); file << BladePerf->GetInletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref();
773773
}
774774
file.width(30); file << BladePerf->GetInletState().GetVelocityValue()*config[ZONE_0]->GetVelocity_Ref();
775-
// This captures NaNs
775+
// This captures NaNs
776776
if(isnan(BladePerf->GetInletState().GetAbsFlowAngle())){
777777
file.width(30); file << "0.0000";
778778
}
@@ -792,11 +792,11 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr<CTurboOutput
792792

793793
/*--- Writing Span wise outflow thermodynamic quantities. ---*/
794794
spanwise_performance_filename = "TURBOMACHINERY/outflow_spanwise_kinematic_values";
795-
if (nZone > 1) {
796-
spanwise_performance_filename.append("_" + std::to_string(val_iZone) + ".dat");
797-
} else {
798-
spanwise_performance_filename.append(".dat");
799-
}
795+
if (nZone > 1) {
796+
spanwise_performance_filename.append("_" + std::to_string(val_iZone) + ".dat");
797+
} else {
798+
spanwise_performance_filename.append(".dat");
799+
}
800800
file.open (spanwise_performance_filename.data(), ios::out | ios::trunc);
801801
file.setf(ios::scientific);
802802
file.precision(12);

SU2_CFD/src/output/CFlowIncOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ CFlowIncOutput::CFlowIncOutput(CConfig *config, unsigned short nDim) : CFlowOutp
7070
auto notFound = requestedVolumeFields.end();
7171
if (find(requestedVolumeFields.begin(), notFound, string("GRID_VELOCITY")) == notFound) {
7272
requestedVolumeFields.emplace_back("GRID_VELOCITY");
73-
nRequestedVolumeFields ++;
73+
nRequestedVolumeFields++;
7474
}
7575
}
7676

SU2_CFD/src/output/CNEMOCompOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ CNEMOCompOutput::CNEMOCompOutput(const CConfig *config, unsigned short nDim) : C
6565
auto notFound = requestedVolumeFields.end();
6666
if (find(requestedVolumeFields.begin(), notFound, string("GRID_VELOCITY")) == notFound) {
6767
requestedVolumeFields.emplace_back("GRID_VELOCITY");
68-
nRequestedVolumeFields ++;
68+
nRequestedVolumeFields++;
6969
}
7070
}
7171

SU2_CFD/src/output/COutput.cpp

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,6 @@ void COutput::PreprocessVolumeOutput(CConfig *config){
15421542
}
15431543
}
15441544

1545-
string RequiredField;
15461545
std::vector<bool> FoundField(nRequestedVolumeFields, false);
15471546
vector<string> FieldsToRemove;
15481547

@@ -1551,49 +1550,32 @@ void COutput::PreprocessVolumeOutput(CConfig *config){
15511550
* object gets an offset so that we know where to find the data in the Local_Data() array.
15521551
* Note that the default offset is -1. An index !=-1 defines this field as part of the output. ---*/
15531552

1554-
unsigned short nVolumeFieldsCompact = 0;
1553+
unsigned short nVolumeFields = 0, nVolumeFieldsCompact = 0;
15551554

15561555
for (size_t iField_Output = 0; iField_Output < volumeOutput_List.size(); iField_Output++) {
15571556

15581557
const string &fieldReference = volumeOutput_List[iField_Output];
1559-
if (volumeOutput_Map.count(fieldReference) > 0) {
1560-
VolumeOutputField &Field = volumeOutput_Map.at(fieldReference);
1561-
1562-
/*--- Loop through all fields specified in the config ---*/
1563-
1564-
for (size_t iReqField = 0; iReqField < restartVolumeFields.size(); iReqField++) {
1558+
const auto it = volumeOutput_Map.find(fieldReference);
1559+
if (it != volumeOutput_Map.end()) {
1560+
VolumeOutputField &Field = it->second;
15651561

1566-
// minimum required fields for restarts
1567-
RequiredField = restartVolumeFields[iReqField];
1562+
/*--- Loop through the minimum required fields for restarts. ---*/
15681563

1569-
if (((RequiredField == Field.outputGroup) || (RequiredField == fieldReference)) && (Field.offset == -1)) {
1570-
Field.offsetCompact = nVolumeFieldsCompact;
1564+
for (const auto& RequiredField : restartVolumeFields) {
1565+
if ((RequiredField == Field.outputGroup || RequiredField == fieldReference) && Field.offsetCompact == -1) {
1566+
Field.offsetCompact = nVolumeFieldsCompact++;
15711567
requiredVolumeFieldNames.push_back(Field.fieldName);
1572-
nVolumeFieldsCompact++;
15731568
}
15741569
}
1575-
}
1576-
}
1577-
1578-
unsigned short nVolumeFields = 0;
15791570

1580-
for (size_t iField_Output = 0; iField_Output < volumeOutput_List.size(); iField_Output++) {
1581-
1582-
const string &fieldReference = volumeOutput_List[iField_Output];
1583-
if (volumeOutput_Map.count(fieldReference) > 0){
1584-
VolumeOutputField &Field = volumeOutput_Map.at(fieldReference);
1585-
1586-
/*--- Loop through all fields specified in the config ---*/
1571+
/*--- Loop through all fields specified in the config. ---*/
15871572

15881573
for (size_t iReqField = 0; iReqField < nRequestedVolumeFields; iReqField++) {
1574+
const auto &RequestedField = requestedVolumeFields[iReqField];
15891575

1590-
const string &RequestedField = requestedVolumeFields[iReqField];
1591-
1592-
if (((RequestedField == Field.outputGroup) || (RequestedField == fieldReference)) && (Field.offset == -1)) {
1593-
1594-
Field.offset = nVolumeFields;
1576+
if ((RequestedField == Field.outputGroup || RequestedField == fieldReference) && Field.offset == -1) {
1577+
Field.offset = nVolumeFields++;
15951578
volumeFieldNames.push_back(Field.fieldName);
1596-
nVolumeFields++;
15971579
FoundField[iReqField] = true;
15981580
}
15991581
}

0 commit comments

Comments
 (0)