Conversation
Contributor
There was a problem hiding this comment.
CodeQL found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
pcarruscag
reviewed
Apr 14, 2023
…to new_turbo_outputs
…to new_turbo_outputs
pcarruscag
reviewed
Nov 1, 2023
Member
pcarruscag
left a comment
There was a problem hiding this comment.
Code looks good, just trying to trim down the interface if possible
6 tasks
pcarruscag
reviewed
Jan 16, 2024
Comment on lines
623
to
868
| void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr<CTurboOutput> TurboPerf, CGeometry *geometry, CConfig **config, unsigned short val_iZone) { | ||
|
|
||
| string inMarker_Tag, outMarker_Tag, inMarkerTag_Mix; | ||
| unsigned short nZone = config[val_iZone]->GetnZone(); | ||
|
|
||
| unsigned short iDim, iSpan; | ||
|
|
||
| unsigned long iExtIter = config[val_iZone]->GetOuterIter(); | ||
| const su2double* SpanWiseValuesIn, *SpanWiseValuesOut; | ||
| ofstream file; | ||
| string spanwise_performance_filename; | ||
|
|
||
| if (rank != MASTER_NODE){ | ||
| return; | ||
| } | ||
|
|
||
| auto BladePerformance = TurboPerf->GetBladesPerformances(); | ||
|
|
||
| /*--- Start of write file turboperformance spanwise ---*/ | ||
| SpanWiseValuesIn = geometry->GetSpanWiseValue(INFLOW); | ||
| SpanWiseValuesOut = geometry->GetSpanWiseValue(OUTFLOW); | ||
|
|
||
| /*--- Writing Span wise inflow thermodynamic quantities. ---*/ | ||
| spanwise_performance_filename = "TURBOMACHINERY/inflow_spanwise_thermodynamic_values.dat"; | ||
| char buffer[50]; | ||
| if (nZone > 1){ | ||
| unsigned short lastindex = spanwise_performance_filename.find_last_of("."); | ||
| spanwise_performance_filename = spanwise_performance_filename.substr(0, lastindex); | ||
| SPRINTF (buffer, "_%d.dat", SU2_TYPE::Int(val_iZone)); | ||
| spanwise_performance_filename.append(string(buffer)); | ||
| } | ||
|
|
||
|
|
||
| file.open (spanwise_performance_filename.data(), ios::out | ios::trunc); | ||
| file.setf(ios::scientific); | ||
| file.precision(12); | ||
|
|
||
| file << "TITLE = \"Inflow Spanwise Thermodynamic Values. iOuterIter = " << iExtIter << " \"" << endl; | ||
| file << "VARIABLES =" << endl; | ||
|
|
||
| file.width(30); file << "\"SpanWise Value[m]\""; | ||
| file.width(15); file << "\"iSpan\""; | ||
| file.width(30); file << "\"Pressure[Pa]\""; | ||
| file.width(30); file << "\"TotalPressure[Pa]\""; | ||
| file.width(30); file << "\"Temperature[K]\""; | ||
| file.width(30); file << "\"TotalTemperature[K]\""; | ||
| file.width(30); file << "\"Enthalpy[J]\""; | ||
| file.width(30); file << "\"TotalEnthalpy[J]\""; | ||
| file.width(30); file << "\"Density[kg/m3]\""; | ||
| file.width(30); file << "\"Entropy[J/K]\""; | ||
| file << endl; | ||
|
|
||
| for(iSpan = 0; iSpan < config[val_iZone]->GetnSpanWiseSections(); iSpan++){ | ||
| const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan); | ||
|
|
||
| file.width(30); file << SpanWiseValuesIn[iSpan]; | ||
| file.width(15); file << iSpan; | ||
| file.width(30); file << BladePerf->GetInletState().GetPressure()*config[ZONE_0]->GetPressure_Ref(); | ||
| file.width(30); file << BladePerf->GetInletState().GetTotalPressure()*config[ZONE_0]->GetPressure_Ref(); | ||
| file.width(30); file << BladePerf->GetInletState().GetTemperature()*config[ZONE_0]->GetTemperature_Ref(); | ||
| file.width(30); file << BladePerf->GetInletState().GetTotalTemperature()*config[ZONE_0]->GetTemperature_Ref(); | ||
| file.width(30); file << BladePerf->GetInletState().GetEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); | ||
| file.width(30); file << BladePerf->GetInletState().GetTotalEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); | ||
| file.width(30); file << BladePerf->GetInletState().GetDensity()*config[ZONE_0]->GetDensity_Ref(); | ||
| file.width(30); file << BladePerf->GetInletState().GetEntropy()*config[ZONE_0]->GetEnergy_Ref()/config[ZONE_0]->GetTemperature_Ref(); | ||
| } | ||
|
|
||
| file.close(); | ||
|
|
||
| /*--- Writing Span wise outflow thermodynamic quantities. ---*/ | ||
| spanwise_performance_filename = "TURBOMACHINERY/outflow_spanwise_thermodynamic_values.dat"; | ||
| if (nZone > 1){ | ||
| unsigned short lastindex = spanwise_performance_filename.find_last_of("."); | ||
| spanwise_performance_filename = spanwise_performance_filename.substr(0, lastindex); | ||
| SPRINTF (buffer, "_%d.dat", SU2_TYPE::Int(val_iZone)); | ||
| spanwise_performance_filename.append(string(buffer)); | ||
| } | ||
|
|
||
| file.open (spanwise_performance_filename.data(), ios::out | ios::trunc); | ||
| file.setf(ios::scientific); | ||
| file.precision(12); | ||
|
|
||
| file << "TITLE = \"Outflow Span-wise Thermodynamic Values. iOuterIter = " << iExtIter << " \"" << endl; | ||
| file << "VARIABLES =" << endl; | ||
|
|
||
| file.width(30); file << "\"SpanWise Value[m]\""; | ||
| file.width(15); file << "\"iSpan\""; | ||
| file.width(30); file << "\"Pressure[Pa]\""; | ||
| file.width(30); file << "\"TotalPressure[Pa]\""; | ||
| file.width(30); file << "\"Temperature[K]\""; | ||
| file.width(30); file << "\"TotalTemperature[K]\""; | ||
| file.width(30); file << "\"Enthalpy[J]\""; | ||
| file.width(30); file << "\"TotalEnthalpy[J]\""; | ||
| file.width(30); file << "\"Density[kg/m3]\""; | ||
| file.width(30); file << "\"Entropy[J/K]\""; | ||
| file << endl; | ||
|
|
||
|
|
||
| for(iSpan = 0; iSpan < config[val_iZone]->GetnSpanWiseSections(); iSpan++){ | ||
| const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan); | ||
|
|
||
| file.width(30); file << SpanWiseValuesOut[iSpan]; | ||
| file.width(15); file << iSpan; | ||
| file.width(30); file << BladePerf->GetOutletState().GetPressure()*config[ZONE_0]->GetPressure_Ref(); | ||
| file.width(30); file << BladePerf->GetOutletState().GetTotalPressure()*config[ZONE_0]->GetPressure_Ref(); | ||
| file.width(30); file << BladePerf->GetOutletState().GetTemperature()*config[ZONE_0]->GetTemperature_Ref(); | ||
| file.width(30); file << BladePerf->GetOutletState().GetTotalTemperature()*config[ZONE_0]->GetTemperature_Ref(); | ||
| file.width(30); file << BladePerf->GetOutletState().GetEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); | ||
| file.width(30); file << BladePerf->GetOutletState().GetTotalEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); | ||
| file.width(30); file << BladePerf->GetOutletState().GetDensity()*config[ZONE_0]->GetDensity_Ref(); | ||
| file.width(30); file << BladePerf->GetOutletState().GetEntropy()*config[ZONE_0]->GetEnergy_Ref()/config[ZONE_0]->GetTemperature_Ref(); | ||
| } | ||
|
|
||
| file.close(); | ||
|
|
||
| /*--- Writing Span wise inflow kinematic quantities. ---*/ | ||
| spanwise_performance_filename = "TURBOMACHINERY/inflow_spanwise_kinematic_values.dat"; | ||
| if (nZone > 1){ | ||
| unsigned short lastindex = spanwise_performance_filename.find_last_of("."); | ||
| spanwise_performance_filename = spanwise_performance_filename.substr(0, lastindex); | ||
| SPRINTF (buffer, "_%d.dat", SU2_TYPE::Int(val_iZone)); | ||
| spanwise_performance_filename.append(string(buffer)); | ||
| } | ||
|
|
||
| file.open (spanwise_performance_filename.data(), ios::out | ios::trunc); | ||
| file.setf(ios::scientific); | ||
| file.precision(12); | ||
|
|
||
| file << "TITLE = \"Inflow Span-wise Kinematic Values. iOuterIter = " << iExtIter << " \"" << endl; | ||
| file << "VARIABLES =" << endl; | ||
|
|
||
| file.width(30); file << "\"SpanWise Value[m]\""; | ||
| file.width(15); file << "\"iSpan\""; | ||
| file.width(30); file << "\"Normal Mach[-]\""; | ||
| file.width(30); file << "\"Tangential Mach[-]\""; | ||
| if (geometry->GetnDim() == 3) { | ||
| file.width(30); file << "\"3rd Component Mach[-]\""; | ||
| }; | ||
| file.width(30); file << "\"Mach Module[-]\""; | ||
| file.width(30); file << "\"Normal Velocity[m/s]\""; | ||
| file.width(30); file << "\"Tangential Velocity[m/s]\""; | ||
| if (geometry->GetnDim() == 3) { | ||
| file.width(30); file << "\"3rd Component Velocity[m/s]\""; | ||
| }; | ||
| file.width(30); file << "\"Velocity Module[m/s]\""; | ||
| file.width(30); file << "\"Absolute Flow Angle[deg]\""; | ||
| file.width(30); file << "\"Relative Flow Angle[deg]\""; | ||
| file << endl; | ||
|
|
||
|
|
||
| for(iSpan = 0; iSpan < config[val_iZone]->GetnSpanWiseSections(); iSpan++){ | ||
| const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan); | ||
|
|
||
| file.width(30); file << SpanWiseValuesIn[iSpan]; | ||
| file.width(15); file << iSpan; | ||
| for (iDim = 0; iDim < geometry->GetnDim(); iDim++){ | ||
| file.width(30); file << BladePerf->GetInletState().GetMach()[iDim]; | ||
| } | ||
| file.width(30); file << BladePerf->GetInletState().GetMachValue(); | ||
| for (iDim = 0; iDim < geometry->GetnDim(); iDim++){ | ||
| 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 | ||
| if(isnan(BladePerf->GetInletState().GetAbsFlowAngle())){ | ||
| file.width(30); file << "0.0000"; | ||
| } | ||
| else { | ||
| file.width(30); file << BladePerf->GetInletState().GetAbsFlowAngle()*180.0/PI_NUMBER; | ||
| } | ||
| if(isnan(BladePerf->GetInletState().GetFlowAngle())){ | ||
| file.width(30); file << "0.0000"; | ||
| } | ||
| else{ | ||
| file.width(30); file << BladePerf->GetInletState().GetFlowAngle()*180.0/PI_NUMBER; | ||
| } | ||
| file << endl; | ||
| } | ||
|
|
||
| file.close(); | ||
|
|
||
| /*--- Writing Span wise outflow thermodynamic quantities. ---*/ | ||
| spanwise_performance_filename = "TURBOMACHINERY/outflow_spanwise_kinematic_values.dat"; | ||
| if (nZone > 1){ | ||
| unsigned short lastindex = spanwise_performance_filename.find_last_of("."); | ||
| spanwise_performance_filename = spanwise_performance_filename.substr(0, lastindex); | ||
| SPRINTF (buffer, "_%d.dat", SU2_TYPE::Int(val_iZone)); | ||
| spanwise_performance_filename.append(string(buffer)); | ||
| } | ||
|
|
||
| file.open (spanwise_performance_filename.data(), ios::out | ios::trunc); | ||
| file.setf(ios::scientific); | ||
| file.precision(12); | ||
|
|
||
| file << "TITLE = \"Outflow Span-wise Kinematic Values. iOuterIter = " << iExtIter << " \"" << endl; | ||
| file << "VARIABLES =" << endl; | ||
|
|
||
| file.width(30); file << "\"SpanWise Value[m]\""; | ||
| file.width(15); file << "\"iSpan\""; | ||
| file.width(30); file << "\"Normal Mach[-]\""; | ||
| file.width(30); file << "\"Tangential Mach[-]\""; | ||
| if (geometry->GetnDim() == 3) { | ||
| file.width(30); file << "\"3rd Component Mach[-]\""; | ||
| }; | ||
| file.width(30); file << "\"Mach Module[-]\""; | ||
| file.width(30); file << "\"Normal Velocity[m/s]\""; | ||
| file.width(30); file << "\"Tangential Velocity[m/s]\""; | ||
| if (geometry->GetnDim() == 3) { | ||
| file.width(30); file << "\"3rd Component Velocity[m/s]\""; | ||
| }; | ||
| file.width(30); file << "\"Velocity Module[m/s]\""; | ||
| file.width(30); file << "\"Absolute Flow Angle[deg]\""; | ||
| file.width(30); file << "\"Relative Flow Angle[deg]\""; | ||
| file << endl; | ||
|
|
||
|
|
||
| for(iSpan = 0; iSpan < config[val_iZone]->GetnSpanWiseSections(); iSpan++){ | ||
| const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan); | ||
|
|
||
| file.width(30); file << SpanWiseValuesOut[iSpan]; | ||
| file.width(15); file << iSpan; | ||
| for (iDim = 0; iDim < geometry->GetnDim(); iDim++){ | ||
| file.width(30); file << BladePerf->GetOutletState().GetMach()[iDim]; | ||
| } | ||
| file.width(30); file << BladePerf->GetInletState().GetMachValue(); | ||
| for (iDim = 0; iDim < geometry->GetnDim(); iDim++){ | ||
| file.width(30); file << BladePerf->GetOutletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref(); | ||
| } | ||
| file.width(30); file << BladePerf->GetInletState().GetVelocityValue()*config[ZONE_0]->GetVelocity_Ref(); | ||
| if(isnan(BladePerf->GetInletState().GetAbsFlowAngle())){ | ||
| file.width(30); file << "0.0000"; | ||
| } | ||
| else { | ||
| file.width(30); file << BladePerf->GetOutletState().GetAbsFlowAngle()*180.0/PI_NUMBER; | ||
| } | ||
| if(isnan(BladePerf->GetInletState().GetAbsFlowAngle())){ | ||
| file.width(30); file << "0.0000"; | ||
| } | ||
| else{ | ||
| file.width(30); file << BladePerf->GetOutletState().GetFlowAngle()*180.0/PI_NUMBER; | ||
| } | ||
| file << endl; | ||
| } | ||
|
|
||
| file.close(); | ||
| } No newline at end of file |
Check notice
Code scanning / CodeQL
Block with too many statements
…to new_turbo_outputs
pcarruscag
approved these changes
Feb 5, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Implemented updated turboperformance methods and adds improved history ouput of turboperformance variables to match screen output
Related Work
Follows on from removal of legacy output - #2003
Implements improved turboperformance calculations used in feature_turbomachinery_restruct_singlezone - #1316
PR Checklist
pre-commit run --allto format old commits.