Skip to content

Commit

Permalink
missing initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarruscag committed Jan 1, 2025
1 parent e599fa1 commit cf4f609
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 51 deletions.
12 changes: 6 additions & 6 deletions SU2_CFD/include/output/COutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,19 +260,18 @@ class COutput {
/*! \brief The name of the field, i.e. the name that is printed in the file header.*/
string fieldName;
/*! \brief This value identifies the position of the values of this field at each node in the ::Local_Data array. */
short offset;
short offset = -1;
/*! \brief This offset is used for the compact formulation. */
short offsetCompact;
short offsetCompact = -1;
/*! \brief The group this field belongs to. */
string outputGroup;
/*! \brief String containing the description of the field. */
string description;
/*! \brief Default constructor. */
VolumeOutputField() = default;
/*! \brief Constructor to initialize all members. */
VolumeOutputField(string fieldName_, int offset_, string volumeOutputGroup_, string description_):
VolumeOutputField(string fieldName_, string volumeOutputGroup_, string description_):
fieldName(std::move(fieldName_)),
offset(offset_),
outputGroup(std::move(volumeOutputGroup_)),
description(std::move(description_)) {}
};
Expand Down Expand Up @@ -746,8 +745,9 @@ class COutput {
* \param[in] groupname - The name of the group this field belongs to.
* \param[in] description - Description of the volume field.
*/
inline void AddVolumeOutput(string name, string field_name, string groupname, string description){
volumeOutput_Map[name] = VolumeOutputField(field_name, -1, groupname, description);
inline void AddVolumeOutput(const string& name, const string& field_name,
const string& group_name, const string& description) {
volumeOutput_Map[name] = VolumeOutputField(field_name, group_name, description);
volumeOutput_List.push_back(name);
}

Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/src/output/CAdjFlowCompOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ CAdjFlowCompOutput::CAdjFlowCompOutput(CConfig *config, unsigned short nDim) : C

if (find(requestedVolumeFields.begin(), requestedVolumeFields.end(), string("SENSITIVITY")) == requestedVolumeFields.end()) {
requestedVolumeFields.emplace_back("SENSITIVITY");
nRequestedVolumeFields ++;
nRequestedVolumeFields++;
}

stringstream ss;
Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/src/output/CAdjFlowIncOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ CAdjFlowIncOutput::CAdjFlowIncOutput(CConfig *config, unsigned short nDim) : CAd

if (find(requestedVolumeFields.begin(), requestedVolumeFields.end(), string("SENSITIVITY")) == requestedVolumeFields.end()) {
requestedVolumeFields.emplace_back("SENSITIVITY");
nRequestedVolumeFields ++;
nRequestedVolumeFields++;
}

stringstream ss;
Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/src/output/CAdjHeatOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ CAdjHeatOutput::CAdjHeatOutput(CConfig *config, unsigned short nDim) : COutput(c

if (find(requestedVolumeFields.begin(), requestedVolumeFields.end(), string("SENSITIVITY")) == requestedVolumeFields.end()) {
requestedVolumeFields.emplace_back("SENSITIVITY");
nRequestedVolumeFields ++;
nRequestedVolumeFields++;
}

stringstream ss;
Expand Down
20 changes: 10 additions & 10 deletions SU2_CFD/src/output/CFlowCompOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ CFlowCompOutput::CFlowCompOutput(const CConfig *config, unsigned short nDim) : C
auto notFound = requestedVolumeFields.end();
if (find(requestedVolumeFields.begin(), notFound, string("GRID_VELOCITY")) == notFound) {
requestedVolumeFields.emplace_back("GRID_VELOCITY");
nRequestedVolumeFields ++;
nRequestedVolumeFields++;
}
}

Expand Down Expand Up @@ -219,7 +219,7 @@ void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){
AddVolumeOutput("DENSITY", "Density", "SOLUTION", "Density");
AddVolumeOutput("MOMENTUM-X", "Momentum_x", "SOLUTION", "x-component of the momentum vector");
AddVolumeOutput("MOMENTUM-Y", "Momentum_y", "SOLUTION", "y-component of the momentum vector");

if (nDim == 3)
AddVolumeOutput("MOMENTUM-Z", "Momentum_z", "SOLUTION", "z-component of the momentum vector");
AddVolumeOutput("ENERGY", "Energy", "SOLUTION", "Energy");
Expand All @@ -241,7 +241,7 @@ void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){
AddVolumeOutput("PRESSURE_COEFF", "Pressure_Coefficient", "PRIMITIVE", "Pressure coefficient");
AddVolumeOutput("VELOCITY-X", "Velocity_x", "PRIMITIVE", "x-component of the velocity vector");
AddVolumeOutput("VELOCITY-Y", "Velocity_y", "PRIMITIVE", "y-component of the velocity vector");

if (nDim == 3)
AddVolumeOutput("VELOCITY-Z", "Velocity_z", "PRIMITIVE", "z-component of the velocity vector");

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

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

TurboInOut<<" BLADE ROW INDEX "<<iZone <<"";
TurboInOut.PrintFooter();
Expand Down Expand Up @@ -772,7 +772,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr<CTurboOutput
file.width(30); file << BladePerf->GetInletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref();
}
file.width(30); file << BladePerf->GetInletState().GetVelocityValue()*config[ZONE_0]->GetVelocity_Ref();
// This captures NaNs
// This captures NaNs
if(isnan(BladePerf->GetInletState().GetAbsFlowAngle())){
file.width(30); file << "0.0000";
}
Expand All @@ -792,11 +792,11 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr<CTurboOutput

/*--- Writing Span wise outflow thermodynamic quantities. ---*/
spanwise_performance_filename = "TURBOMACHINERY/outflow_spanwise_kinematic_values";
if (nZone > 1) {
spanwise_performance_filename.append("_" + std::to_string(val_iZone) + ".dat");
} else {
spanwise_performance_filename.append(".dat");
}
if (nZone > 1) {
spanwise_performance_filename.append("_" + std::to_string(val_iZone) + ".dat");
} else {
spanwise_performance_filename.append(".dat");
}
file.open (spanwise_performance_filename.data(), ios::out | ios::trunc);
file.setf(ios::scientific);
file.precision(12);
Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/src/output/CFlowIncOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ CFlowIncOutput::CFlowIncOutput(CConfig *config, unsigned short nDim) : CFlowOutp
auto notFound = requestedVolumeFields.end();
if (find(requestedVolumeFields.begin(), notFound, string("GRID_VELOCITY")) == notFound) {
requestedVolumeFields.emplace_back("GRID_VELOCITY");
nRequestedVolumeFields ++;
nRequestedVolumeFields++;
}
}

Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/src/output/CNEMOCompOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ CNEMOCompOutput::CNEMOCompOutput(const CConfig *config, unsigned short nDim) : C
auto notFound = requestedVolumeFields.end();
if (find(requestedVolumeFields.begin(), notFound, string("GRID_VELOCITY")) == notFound) {
requestedVolumeFields.emplace_back("GRID_VELOCITY");
nRequestedVolumeFields ++;
nRequestedVolumeFields++;
}
}

Expand Down
42 changes: 12 additions & 30 deletions SU2_CFD/src/output/COutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,6 @@ void COutput::PreprocessVolumeOutput(CConfig *config){
}
}

string RequiredField;
std::vector<bool> FoundField(nRequestedVolumeFields, false);
vector<string> FieldsToRemove;

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

unsigned short nVolumeFieldsCompact = 0;
unsigned short nVolumeFields = 0, nVolumeFieldsCompact = 0;

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

const string &fieldReference = volumeOutput_List[iField_Output];
if (volumeOutput_Map.count(fieldReference) > 0) {
VolumeOutputField &Field = volumeOutput_Map.at(fieldReference);

/*--- Loop through all fields specified in the config ---*/

for (size_t iReqField = 0; iReqField < restartVolumeFields.size(); iReqField++) {
const auto it = volumeOutput_Map.find(fieldReference);
if (it != volumeOutput_Map.end()) {
VolumeOutputField &Field = it->second;

// minimum required fields for restarts
RequiredField = restartVolumeFields[iReqField];
/*--- Loop through the minimum required fields for restarts. ---*/

if (((RequiredField == Field.outputGroup) || (RequiredField == fieldReference)) && (Field.offset == -1)) {
Field.offsetCompact = nVolumeFieldsCompact;
for (const auto& RequiredField : restartVolumeFields) {
if ((RequiredField == Field.outputGroup || RequiredField == fieldReference) && Field.offsetCompact == -1) {
Field.offsetCompact = nVolumeFieldsCompact++;
requiredVolumeFieldNames.push_back(Field.fieldName);
nVolumeFieldsCompact++;
}
}
}
}

unsigned short nVolumeFields = 0;

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

const string &fieldReference = volumeOutput_List[iField_Output];
if (volumeOutput_Map.count(fieldReference) > 0){
VolumeOutputField &Field = volumeOutput_Map.at(fieldReference);

/*--- Loop through all fields specified in the config ---*/
/*--- Loop through all fields specified in the config. ---*/

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

const string &RequestedField = requestedVolumeFields[iReqField];

if (((RequestedField == Field.outputGroup) || (RequestedField == fieldReference)) && (Field.offset == -1)) {

Field.offset = nVolumeFields;
if ((RequestedField == Field.outputGroup || RequestedField == fieldReference) && Field.offset == -1) {
Field.offset = nVolumeFields++;
volumeFieldNames.push_back(Field.fieldName);
nVolumeFields++;
FoundField[iReqField] = true;
}
}
Expand Down

0 comments on commit cf4f609

Please sign in to comment.