From 8e9b705b96a7cc7d6e9a2ca69e1b0fa71a9008b0 Mon Sep 17 00:00:00 2001 From: joshkellyjak Date: Thu, 6 Apr 2023 16:21:04 +0100 Subject: [PATCH 01/99] Reimplemented turboperformance calculations --- SU2_CFD/include/output/COutput.hpp | 85 +++++ SU2_CFD/src/drivers/CMultizoneDriver.cpp | 1 + SU2_CFD/src/output/CFlowCompOutput.cpp | 70 +++- SU2_CFD/src/output/COutput.cpp | 434 +++++++++++++++++++++++ 4 files changed, 589 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 70788bf4997..ab7c173d921 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -320,6 +320,62 @@ class COutput { su2double WndCauchy_Value; /*!< \brief Summed value of the convergence indicator. */ bool TimeConvergence; /*!< \brief To indicate, if the windowed time average of the time loop has converged*/ + /*--- Turbomachinery Performance Variable ---*/ + su2double Sum_Total_RadialDistortion, Sum_Total_CircumferentialDistortion; // Add all the distortion to compute a run average. + bool turbo; + unsigned short nSpanWiseSections, nMarkerTurboPerf; + + su2double **TotalStaticEfficiency, + **TotalTotalEfficiency, + **KineticEnergyLoss, + **TRadius, + **TotalPressureLoss, + **MassFlowIn, + **MassFlowOut, + **FlowAngleIn, + **FlowAngleIn_BC, + **FlowAngleOut, + **EulerianWork, + **TotalEnthalpyIn, + **TotalEnthalpyIn_BC, + **EntropyIn, + **EntropyOut, + **EntropyIn_BC, + **PressureRatio, + **TotalTemperatureIn, + **EnthalpyOut, + ***MachIn, + ***MachOut, + **VelocityOutIs, + **DensityIn, + **PressureIn, + ***TurboVelocityIn, + **DensityOut, + **PressureOut, + ***TurboVelocityOut, + **EnthalpyOutIs, + **EntropyGen, + **AbsFlowAngleIn, + **TotalEnthalpyOut, + **RothalpyIn, + **RothalpyOut, + **TotalEnthalpyOutIs, + **AbsFlowAngleOut, + **PressureOut_BC, + **TemperatureIn, + **TemperatureOut, + **TotalPressureIn, + **TotalPressureOut, + **TotalTemperatureOut, + **EnthalpyIn, + **TurbIntensityIn, + **Turb2LamViscRatioIn, + **TurbIntensityOut, + **Turb2LamViscRatioOut, + **NuFactorIn, + **NuFactorOut; + + /*--- End of turbomachinery performance ---*/ public: /*----------------------------- Public member functions ----------------------------*/ @@ -586,6 +642,35 @@ class COutput { */ void WriteToFile(CConfig *config, CGeometry *geometry, OUTPUT_TYPE format, string fileName = ""); + /* + * \brief Initialize turboperformance variables + * \param[in] config - Definition of the particular problem + */ + void InitTurboPerformance(const CConfig *config); + + /*! + * \brief Compute turboperformance variables + * \param[in] config - Definition of the particular problem. + * \param[in] geometry - Geometrical definition of the problem + * \param[in] solver - The container holding all solution data + */ + void ComputeTurboPerformance(CConfig *config, CGeometry *geometry, CSolver *solver); + + /*! + * \brief Collects Turbomachinery Performance data from the solvers and prints the data in tabular format on screen. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] config - Definition of the particular problem. + * \param[in] TimeIter - Value of the time iteration index + * \param[in] OuterIter - Value of outer iteration index + * \param[in] InnerIter - Value of the inner iteration index + */ + void SetTurboPerformance_Output(CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iZone); + + void SetTurboMultiZonePerformance_Output(CConfig *config); + + void WriteTurboPerfConvHistory(CConfig *config); + protected: /*----------------------------- Protected member functions ----------------------------*/ diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index b29da9b2161..0e2d02a0c65 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -636,6 +636,7 @@ void CMultizoneDriver::SetTurboPerformance() { solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL], donorZone); } + output_container[ZONE_0]->ComputeTurboPerformance(config_container[ZONE_0], geometry_container[ZONE_0][INST_0][MESH_0], solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]); } bool CMultizoneDriver::Monitor(unsigned long TimeIter){ diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 0e8e6b78613..af424a39f7e 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -96,6 +96,11 @@ CFlowCompOutput::CFlowCompOutput(const CConfig *config, unsigned short nDim) : C cauchySerie.resize(convFields.size(), vector(nCauchy_Elems, 0.0)); } } + + if (config->GetBoolTurbomachinery()) { + /*--- Initialise turboperformance variables ---*/ + InitTurboPerformance(config); + } } void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ @@ -207,6 +212,45 @@ void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ AddNearfieldInverseDesignOutput(); + /// BEGIN_GROUP: TURBO_PERF, DESCRIPTION: Turboperformance variables + if (config->GetBoolTurbomachinery()) { + unsigned short iMarker_Monitoring; + for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_TurboPerformance(); iMarker_Monitoring++) { + stringstream tag; + tag << iMarker_Monitoring + 1; + /// DESCRIPTION: Total pressure loss + AddHistoryOutput("TotalPressureLoss_" + tag.str(), "TotPressureLoss_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total pressure loss " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Kinetic energy loss + AddHistoryOutput("KineticEnergyLoss_" + tag.str(), "KineticEnergyLoss_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Kinetic energy loss " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Entropy generation + AddHistoryOutput("EntropyGeneration_" + tag.str(), "EntropyGen_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Entropy generation " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Eulerian work + AddHistoryOutput("EulerianWork_" + tag.str(), "EulerianWork_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Eulerian work " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Pressure ratio + AddHistoryOutput("PressureRatio_" + tag.str(), "PressureRatio_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: FLow angle in + AddHistoryOutput("FlowAngleIn_" + tag.str(), "FlowAngleIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Flow angle out + AddHistoryOutput("FlowAngleOut_" + tag.str(), "FlowAngleOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle out " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Absolute flow angle in + AddHistoryOutput("AbsFlowAngleIn_" + tag.str(), "AbsFlowAngleIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Absolute flow angle out + AddHistoryOutput("AbsFlowAngleOut_" + tag.str(), "AbsFlowAngleOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Mass flow in + AddHistoryOutput("MassFlowIn_" + tag.str(), "MassFlowIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow in " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Mass flow out + AddHistoryOutput("MassFlowOut_" + tag.str(), "MassFlowOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow out " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Mach in + AddHistoryOutput("MachIn_" + tag.str(), "MachIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach in " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Mach out + AddHistoryOutput("MachOut_" + tag.str(), "MachOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach out " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Total efficiency + AddHistoryOutput("TotalEfficiency_" + tag.str(), "TotalEfficiency_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total efficiency " + tag.str(), HistoryFieldType::DEFAULT); + /// DESCRIPTION: Total-to-static efficiency + AddHistoryOutput("TotalStaticEfficiency_" + tag.str(), "TotalStaticEfficiency_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); + } + } + } void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){ @@ -441,12 +485,36 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol if (config->GetEquivArea()) SetNearfieldInverseDesign(flow_solver, geometry, config); + if (config->GetBoolTurbomachinery()){ + + unsigned short iMarker_Monitoring; + for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_TurboPerformance(); iMarker_Monitoring++) { + stringstream tag; + tag << iMarker_Monitoring + 1; + SetHistoryOutputValue("TotalPressureLoss_" + tag.str(), TotalPressureLoss[iMarker_Monitoring][nSpanWiseSections]); + SetHistoryOutputValue("KineticEnergyLoss_" + tag.str(), KineticEnergyLoss[iMarker_Monitoring][nSpanWiseSections]); + SetHistoryOutputValue("EntropyGeneration_" + tag.str(), EntropyGen[iMarker_Monitoring][nSpanWiseSections]); + SetHistoryOutputValue("EulerianWork_" + tag.str(), EulerianWork[iMarker_Monitoring][nSpanWiseSections]); + SetHistoryOutputValue("PressureRatio_" + tag.str(), PressureRatio[iMarker_Monitoring][nSpanWiseSections]); + SetHistoryOutputValue("FlowAngleIn_" + tag.str(), 180/PI_NUMBER*FlowAngleIn[iMarker_Monitoring][nSpanWiseSections]); + SetHistoryOutputValue("FlowAngleOut_" + tag.str(), 180/PI_NUMBER*FlowAngleOut[iMarker_Monitoring][nSpanWiseSections]); + SetHistoryOutputValue("AbsFlowAngleIn_" + tag.str(), 180/PI_NUMBER*AbsFlowAngleIn[iMarker_Monitoring][nSpanWiseSections]); + SetHistoryOutputValue("AbsFlowAngleOut_" + tag.str(), 180/PI_NUMBER*AbsFlowAngleOut[iMarker_Monitoring][nSpanWiseSections]); + SetHistoryOutputValue("MassFlowIn_" + tag.str(), MassFlowIn[iMarker_Monitoring][nSpanWiseSections]); + SetHistoryOutputValue("MassFlowOut_" + tag.str(), MassFlowOut[iMarker_Monitoring][nSpanWiseSections]); + SetHistoryOutputValue("MachIn_" + tag.str(), sqrt(MachIn[iMarker_Monitoring][nSpanWiseSections][1]*MachIn[iMarker_Monitoring][nSpanWiseSections][1] + MachIn[iMarker_Monitoring][nSpanWiseSections][0]*MachIn[iMarker_Monitoring][nSpanWiseSections][0])); + SetHistoryOutputValue("MachOut_" + tag.str(), sqrt(MachOut[iMarker_Monitoring][nSpanWiseSections][1]*MachOut[iMarker_Monitoring][nSpanWiseSections][1] + MachOut[iMarker_Monitoring][nSpanWiseSections][0]*MachOut[iMarker_Monitoring][nSpanWiseSections][0])); + SetHistoryOutputValue("TotalEfficiency_" + tag.str(), TotalTotalEfficiency[iMarker_Monitoring][nSpanWiseSections]); + SetHistoryOutputValue("TotalStaticEfficiency_" + tag.str(), TotalStaticEfficiency[iMarker_Monitoring][nSpanWiseSections]); + } + } + /*--- Keep this as last, since it uses the history values that were set. ---*/ SetCustomOutputs(solver, geometry, config); SetCustomAndComboObjectives(FLOW_SOL, config, solver); - + } bool CFlowCompOutput::SetInitResiduals(const CConfig *config){ diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 646cc521c93..b95b4ad6018 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -2476,3 +2476,437 @@ void COutput::PrintVolumeFields(){ VolumeFieldTable.PrintFooter(); } } + +void COutput::InitTurboPerformance(const CConfig *config){ + unsigned short iDim, iSpan, iMarker; + + /*--- Initializate quantities for turboperformace ---*/ + nSpanWiseSections = config->GetnSpanMaxAllZones(); + nMarkerTurboPerf = config->GetnMarker_TurboPerformance(); + + + TotalStaticEfficiency = new su2double*[nMarkerTurboPerf]; + TotalTotalEfficiency = new su2double*[nMarkerTurboPerf]; + KineticEnergyLoss = new su2double*[nMarkerTurboPerf]; + TRadius = new su2double*[nMarkerTurboPerf]; + TotalPressureLoss = new su2double*[nMarkerTurboPerf]; + MassFlowIn = new su2double*[nMarkerTurboPerf]; + MassFlowOut = new su2double*[nMarkerTurboPerf]; + FlowAngleIn = new su2double*[nMarkerTurboPerf]; + FlowAngleIn_BC = new su2double*[nMarkerTurboPerf]; + FlowAngleOut = new su2double*[nMarkerTurboPerf]; + EulerianWork = new su2double*[nMarkerTurboPerf]; + TotalEnthalpyIn = new su2double*[nMarkerTurboPerf]; + TotalEnthalpyIn_BC = new su2double*[nMarkerTurboPerf]; + EntropyIn = new su2double*[nMarkerTurboPerf]; + EntropyOut = new su2double*[nMarkerTurboPerf]; + EntropyIn_BC = new su2double*[nMarkerTurboPerf]; + PressureRatio = new su2double*[nMarkerTurboPerf]; + TotalTemperatureIn = new su2double*[nMarkerTurboPerf]; + EnthalpyOut = new su2double*[nMarkerTurboPerf]; + MachIn = new su2double**[nMarkerTurboPerf]; + MachOut = new su2double**[nMarkerTurboPerf]; + VelocityOutIs = new su2double*[nMarkerTurboPerf]; + DensityIn = new su2double*[nMarkerTurboPerf]; + PressureIn = new su2double*[nMarkerTurboPerf]; + TurboVelocityIn = new su2double**[nMarkerTurboPerf]; + DensityOut = new su2double*[nMarkerTurboPerf]; + PressureOut = new su2double*[nMarkerTurboPerf]; + TurboVelocityOut = new su2double**[nMarkerTurboPerf]; + EnthalpyOutIs = new su2double*[nMarkerTurboPerf]; + EntropyGen = new su2double*[nMarkerTurboPerf]; + AbsFlowAngleIn = new su2double*[nMarkerTurboPerf]; + TotalEnthalpyOut = new su2double*[nMarkerTurboPerf]; + TotalEnthalpyOutIs = new su2double*[nMarkerTurboPerf]; + RothalpyIn = new su2double*[nMarkerTurboPerf]; + RothalpyOut = new su2double*[nMarkerTurboPerf]; + AbsFlowAngleOut = new su2double*[nMarkerTurboPerf]; + PressureOut_BC = new su2double*[nMarkerTurboPerf]; + TemperatureIn = new su2double*[nMarkerTurboPerf]; + TemperatureOut = new su2double*[nMarkerTurboPerf]; + TotalPressureIn = new su2double*[nMarkerTurboPerf]; + TotalPressureOut = new su2double*[nMarkerTurboPerf]; + TotalTemperatureOut = new su2double*[nMarkerTurboPerf]; + EnthalpyIn = new su2double*[nMarkerTurboPerf]; + TurbIntensityIn = new su2double*[nMarkerTurboPerf]; + Turb2LamViscRatioIn = new su2double*[nMarkerTurboPerf]; + TurbIntensityOut = new su2double*[nMarkerTurboPerf]; + Turb2LamViscRatioOut = new su2double*[nMarkerTurboPerf]; + NuFactorIn = new su2double*[nMarkerTurboPerf]; + NuFactorOut = new su2double*[nMarkerTurboPerf]; + + for (iMarker = 0; iMarker < nMarkerTurboPerf; iMarker++){ + TotalStaticEfficiency [iMarker] = new su2double [nSpanWiseSections + 1]; + TotalTotalEfficiency [iMarker] = new su2double [nSpanWiseSections + 1]; + KineticEnergyLoss [iMarker] = new su2double [nSpanWiseSections + 1]; + TRadius [iMarker] = new su2double [nSpanWiseSections + 1]; + TotalPressureLoss [iMarker] = new su2double [nSpanWiseSections + 1]; + MassFlowIn [iMarker] = new su2double [nSpanWiseSections + 1]; + MassFlowOut [iMarker] = new su2double [nSpanWiseSections + 1]; + FlowAngleIn [iMarker] = new su2double [nSpanWiseSections + 1]; + FlowAngleIn_BC [iMarker] = new su2double [nSpanWiseSections + 1]; + FlowAngleOut [iMarker] = new su2double [nSpanWiseSections + 1]; + EulerianWork [iMarker] = new su2double [nSpanWiseSections + 1]; + TotalEnthalpyIn [iMarker] = new su2double [nSpanWiseSections + 1]; + TotalEnthalpyIn_BC [iMarker] = new su2double [nSpanWiseSections + 1]; + EntropyIn [iMarker] = new su2double [nSpanWiseSections + 1]; + EntropyOut [iMarker] = new su2double [nSpanWiseSections + 1]; + EntropyIn_BC [iMarker] = new su2double [nSpanWiseSections + 1]; + PressureRatio [iMarker] = new su2double [nSpanWiseSections + 1]; + TotalTemperatureIn [iMarker] = new su2double [nSpanWiseSections + 1]; + EnthalpyOut [iMarker] = new su2double [nSpanWiseSections + 1]; + MachIn [iMarker] = new su2double*[nSpanWiseSections + 1]; + MachOut [iMarker] = new su2double*[nSpanWiseSections + 1]; + VelocityOutIs [iMarker] = new su2double [nSpanWiseSections + 1]; + DensityIn [iMarker] = new su2double [nSpanWiseSections + 1]; + PressureIn [iMarker] = new su2double [nSpanWiseSections + 1]; + TurboVelocityIn [iMarker] = new su2double*[nSpanWiseSections + 1]; + DensityOut [iMarker] = new su2double [nSpanWiseSections + 1]; + PressureOut [iMarker] = new su2double [nSpanWiseSections + 1]; + TurboVelocityOut [iMarker] = new su2double*[nSpanWiseSections + 1]; + EnthalpyOutIs [iMarker] = new su2double [nSpanWiseSections + 1]; + EntropyGen [iMarker] = new su2double [nSpanWiseSections + 1]; + AbsFlowAngleIn [iMarker] = new su2double [nSpanWiseSections + 1]; + TotalEnthalpyOut [iMarker] = new su2double [nSpanWiseSections + 1]; + TotalEnthalpyOutIs [iMarker] = new su2double [nSpanWiseSections + 1]; + RothalpyIn [iMarker] = new su2double [nSpanWiseSections + 1]; + RothalpyOut [iMarker] = new su2double [nSpanWiseSections + 1]; + AbsFlowAngleOut [iMarker] = new su2double [nSpanWiseSections + 1]; + PressureOut_BC [iMarker] = new su2double [nSpanWiseSections + 1]; + TemperatureIn [iMarker] = new su2double [nSpanWiseSections + 1]; + TemperatureOut [iMarker] = new su2double [nSpanWiseSections + 1]; + TotalPressureIn [iMarker] = new su2double [nSpanWiseSections + 1]; + TotalPressureOut [iMarker] = new su2double [nSpanWiseSections + 1]; + TotalTemperatureOut [iMarker] = new su2double [nSpanWiseSections + 1]; + EnthalpyIn [iMarker] = new su2double [nSpanWiseSections + 1]; + TurbIntensityIn [iMarker] = new su2double [nSpanWiseSections + 1]; + Turb2LamViscRatioIn [iMarker] = new su2double [nSpanWiseSections + 1]; + TurbIntensityOut [iMarker] = new su2double [nSpanWiseSections + 1]; + Turb2LamViscRatioOut [iMarker] = new su2double [nSpanWiseSections + 1]; + NuFactorIn [iMarker] = new su2double [nSpanWiseSections + 1]; + NuFactorOut [iMarker] = new su2double [nSpanWiseSections + 1]; + + + for (iSpan = 0; iSpan < nSpanWiseSections + 1; iSpan++){ + TotalStaticEfficiency [iMarker][iSpan] = 0.0; + TotalTotalEfficiency [iMarker][iSpan] = 0.0; + KineticEnergyLoss [iMarker][iSpan] = 0.0; + TRadius [iMarker][iSpan] = 0.0; + TotalPressureLoss [iMarker][iSpan] = 0.0; + MassFlowIn [iMarker][iSpan] = 0.0; + MassFlowOut [iMarker][iSpan] = 0.0; + FlowAngleIn [iMarker][iSpan] = 0.0; + FlowAngleIn_BC [iMarker][iSpan] = config->GetFlowAngleIn_BC(); + FlowAngleOut [iMarker][iSpan] = 0.0; + EulerianWork [iMarker][iSpan] = 0.0; + TotalEnthalpyIn [iMarker][iSpan] = 0.0; + TotalEnthalpyIn_BC [iMarker][iSpan] = 0.0; + EntropyIn [iMarker][iSpan] = 0.0; + EntropyOut [iMarker][iSpan] = 0.0; + EntropyIn_BC [iMarker][iSpan] = 0.0; + PressureRatio [iMarker][iSpan] = 0.0; + TotalTemperatureIn [iMarker][iSpan] = 0.0; + EnthalpyOut [iMarker][iSpan] = 0.0; + + + VelocityOutIs [iMarker][iSpan] = 0.0; + DensityIn [iMarker][iSpan] = 0.0; + PressureIn [iMarker][iSpan] = 0.0; + + DensityOut [iMarker][iSpan] = 0.0; + PressureOut [iMarker][iSpan] = 0.0; + + EnthalpyOutIs [iMarker][iSpan] = 0.0; + EntropyGen [iMarker][iSpan] = 0.0; + AbsFlowAngleIn [iMarker][iSpan] = 0.0; + TotalEnthalpyOut [iMarker][iSpan] = 0.0; + TotalEnthalpyOutIs [iMarker][iSpan] = 0.0; + RothalpyIn [iMarker][iSpan] = 0.0; + RothalpyOut [iMarker][iSpan] = 0.0; + AbsFlowAngleOut [iMarker][iSpan] = 0.0; + PressureOut_BC [iMarker][iSpan] = config->GetPressureOut_BC(); + + TemperatureIn [iMarker][iSpan] = 0.0; + TemperatureOut [iMarker][iSpan] = 0.0; + TotalPressureIn [iMarker][iSpan] = 0.0; + TotalPressureOut [iMarker][iSpan] = 0.0; + TotalTemperatureOut [iMarker][iSpan] = 0.0; + EnthalpyIn [iMarker][iSpan] = 0.0; + TurbIntensityIn [iMarker][iSpan] = 0.0; + Turb2LamViscRatioIn [iMarker][iSpan] = 0.0; + TurbIntensityOut [iMarker][iSpan] = 0.0; + Turb2LamViscRatioOut [iMarker][iSpan] = 0.0; + NuFactorIn [iMarker][iSpan] = 0.0; + NuFactorOut [iMarker][iSpan] = 0.0; + MachIn [iMarker][iSpan] = new su2double[4]; + MachOut [iMarker][iSpan] = new su2double[4]; + TurboVelocityIn [iMarker][iSpan] = new su2double[4]; + TurboVelocityOut [iMarker][iSpan] = new su2double[4]; + + for (iDim = 0; iDim < 4; iDim++){ + MachIn [iMarker][iSpan][iDim] = 0.0; + MachOut [iMarker][iSpan][iDim] = 0.0; + TurboVelocityIn [iMarker][iSpan][iDim] = 0.0; + TurboVelocityOut [iMarker][iSpan][iDim] = 0.0; + } + } + } +} + +void COutput::ComputeTurboPerformance(CConfig *config, CGeometry *geometry, CSolver *solver){ + CFluidModel *FluidModel; + unsigned short nDim = geometry->GetnDim(); + unsigned short iMarkerTP, iSpan, iDim, iStage, iBlade; + unsigned short nMarkerTP = config->GetnMarker_Turbomachinery(); + FluidModel = solver->GetFluidModel(); + su2double area, absVel2, soundSpeed, mach, tangVel, tangVel2, *relVel, relVel2; + su2double relPressureIn, relPressureOut, enthalpyOutIs, relVelOutIs2; + relVel = new su2double[nDim]; + su2double muLam, kine, omega, nu; + bool turbulent = ((config->GetKind_Solver() == MAIN_SOLVER::RANS) || (config->GetKind_Solver() == MAIN_SOLVER::DISC_ADJ_RANS)); + bool menter_sst = (config->GetKind_Turb_Model() == TURB_MODEL::SST); + + unsigned short nBladesRow, nStages; + + nBladesRow = config->GetnMarker_Turbomachinery(); + nStages = SU2_TYPE::Int(nBladesRow/2); + + + /*--- Compute BC imposed value for convergence monitoring ---*/ + for(iMarkerTP = 0; iMarkerTP < nMarkerTP; iMarkerTP++ ){ + for(iSpan = 0; iSpan < config->GetnSpan_iZones(iMarkerTP) + 1; iSpan++){ + if(config->GetRampOutletPressure() && config->GetInnerIter() > 0){ + PressureOut_BC[iMarkerTP][iSpan] = config->GetMonitorOutletPressure()/config->GetPressure_Ref(); + } + FluidModel->SetTDState_PT(config->GetTotalPressureIn_BC(), config->GetTotalTemperatureIn_BC()); + TotalEnthalpyIn_BC[iMarkerTP][iSpan] = FluidModel->GetStaticEnergy()+ FluidModel->GetPressure()/FluidModel->GetDensity(); + EntropyIn_BC[iMarkerTP][iSpan] = FluidModel->GetEntropy(); + } + } + + /*--- Compute performance for each blade ---*/ + for(iMarkerTP = 0; iMarkerTP < nMarkerTP; iMarkerTP++ ){ + for(iSpan = 0; iSpan < config->GetnSpan_iZones(iMarkerTP) + 1; iSpan++){ + + + /*--- INFLOW ---*/ + /*--- Retrieve Inflow primitive quantities ---*/ + DensityIn[iMarkerTP][iSpan] = solver->GetDensityIn(iMarkerTP, iSpan); + PressureIn[iMarkerTP][iSpan] = solver->GetPressureIn(iMarkerTP, iSpan); + + absVel2 = 0.0; + + for (iDim = 0; iDim < nDim; iDim++){ + TurboVelocityIn[iMarkerTP][iSpan][iDim] = solver->GetTurboVelocityIn(iMarkerTP, iSpan)[iDim]; + absVel2 += TurboVelocityIn[iMarkerTP][iSpan][iDim]*TurboVelocityIn[iMarkerTP][iSpan][iDim]; + } + TurboVelocityIn[iMarkerTP][iSpan][nDim] = sqrt(absVel2); + + TRadius[iMarkerTP][iSpan] = geometry->GetTurboRadiusIn(iMarkerTP, iSpan); + area = geometry->GetSpanAreaIn(iMarkerTP, iSpan); + + /*--- Compute static Inflow quantities ---*/ + FluidModel->SetTDState_Prho(PressureIn[iMarkerTP][iSpan], DensityIn[iMarkerTP][iSpan]); + EntropyIn[iMarkerTP][iSpan] = FluidModel->GetEntropy(); + MassFlowIn[iMarkerTP][iSpan] = config->GetnBlades(iMarkerTP)*DensityIn[iMarkerTP][iSpan]*TurboVelocityIn[iMarkerTP][iSpan][0]*area; + AbsFlowAngleIn[iMarkerTP][iSpan] = atan(TurboVelocityIn[iMarkerTP][iSpan][1]/TurboVelocityIn[iMarkerTP][iSpan][0]); + EnthalpyIn[iMarkerTP][iSpan] = FluidModel->GetStaticEnergy() + PressureIn[iMarkerTP][iSpan]/DensityIn[iMarkerTP][iSpan]; + soundSpeed = FluidModel->GetSoundSpeed(); + + + /*--- Compute Total Inflow quantities ---*/ + TotalEnthalpyIn[iMarkerTP][iSpan] = EnthalpyIn[iMarkerTP][iSpan] + 0.5*absVel2; + FluidModel->SetTDState_hs(TotalEnthalpyIn[iMarkerTP][iSpan], EntropyIn[iMarkerTP][iSpan]); + TotalPressureIn[iMarkerTP][iSpan] = FluidModel->GetPressure(); + TotalTemperatureIn[iMarkerTP][iSpan] = FluidModel->GetTemperature(); + + /*--- Retrieve Inflow relative quantities ---*/ + tangVel = geometry->GetTangGridVelIn(iMarkerTP, iSpan); + tangVel2 = tangVel*tangVel; + + for (iDim = 0; iDim < nDim; iDim++){ + relVel[iDim] = TurboVelocityIn[iMarkerTP][iSpan][iDim]; + } + relVel[1] -= tangVel; + + relVel2 = 0.0; + for (iDim = 0; iDim < nDim; iDim++){ + relVel2 += relVel[iDim]*relVel[iDim]; + } + + /*--- Compute Total relative Inflow quantities ---*/ + RothalpyIn[iMarkerTP][iSpan] = EnthalpyIn[iMarkerTP][iSpan] + 0.5*relVel2 - 0.5*tangVel2; + FluidModel->SetTDState_hs(RothalpyIn[iMarkerTP][iSpan], EntropyIn[iMarkerTP][iSpan]); + relPressureIn = FluidModel->GetPressure(); + + /*--- Compute kinematic relative Inflow quantities ---*/ + FlowAngleIn[iMarkerTP][iSpan] = atan(relVel[1]/relVel[0]); + mach = 0.0; + for (iDim = 0; iDim < nDim; iDim++){ + MachIn[iMarkerTP][iSpan][iDim] = relVel[iDim]/soundSpeed; + mach = MachIn[iMarkerTP][iSpan][iDim]*MachIn[iMarkerTP][iSpan][iDim]; + } + MachIn[iMarkerTP][iSpan][nDim] = sqrt(mach); + + /*--- Compute Turbulent Inflow quantities ---*/ + if(turbulent){ + FluidModel->SetTDState_Prho(PressureIn[iMarkerTP][iSpan], DensityIn[iMarkerTP][iSpan]); + muLam = FluidModel->GetLaminarViscosity(); + if(menter_sst){ + kine = solver->GetKineIn(iMarkerTP, iSpan); + omega = solver->GetOmegaIn(iMarkerTP, iSpan); + TurbIntensityIn[iMarkerTP][iSpan] = sqrt(2.0/3.0*kine/absVel2); + Turb2LamViscRatioIn[iMarkerTP][iSpan] = DensityIn[iMarkerTP][iSpan]*kine/(muLam*omega); +// TurbIntensityIn[iMarkerTP][iSpan] = kine; +// Turb2LamViscRatioIn[iMarkerTP][iSpan] = omega; + } + else{ + nu = solver->GetNuIn(iMarkerTP, iSpan); + NuFactorIn[iMarkerTP][iSpan] = nu*DensityIn[iMarkerTP][iSpan]/muLam; + } + } + + /*--- OUTFLOW ---*/ + /*--- Retrieve Outflow primitive quantities ---*/ + DensityOut[iMarkerTP][iSpan] = solver->GetDensityOut(iMarkerTP, iSpan); + PressureOut[iMarkerTP][iSpan] = solver->GetPressureOut(iMarkerTP, iSpan); + absVel2 = 0.0; + + for (iDim = 0; iDim < nDim; iDim++){ + TurboVelocityOut[iMarkerTP][iSpan][iDim] = solver->GetTurboVelocityOut(iMarkerTP, iSpan)[iDim]; + absVel2 += TurboVelocityOut[iMarkerTP][iSpan][iDim]*TurboVelocityOut[iMarkerTP][iSpan][iDim]; + } + TurboVelocityOut[iMarkerTP][iSpan][nDim] = sqrt(absVel2); + + + for (iDim = 0; iDim < 3; iDim++){ + } + area = geometry->GetSpanAreaOut(iMarkerTP, iSpan); + + + /*--- Compute all the Outflow quantities ---*/ + FluidModel->SetTDState_Prho(PressureOut[iMarkerTP][iSpan], DensityOut[iMarkerTP][iSpan]); + EntropyOut[iMarkerTP][iSpan] = FluidModel->GetEntropy(); + MassFlowOut[iMarkerTP][iSpan] = config->GetnBlades(iMarkerTP)*DensityOut[iMarkerTP][iSpan]*TurboVelocityOut[iMarkerTP][iSpan][0]*area; + AbsFlowAngleOut[iMarkerTP][iSpan] = atan(TurboVelocityOut[iMarkerTP][iSpan][1]/TurboVelocityOut[iMarkerTP][iSpan][0]); + EnthalpyOut[iMarkerTP][iSpan] = FluidModel->GetStaticEnergy() + PressureOut[iMarkerTP][iSpan]/DensityOut[iMarkerTP][iSpan]; + soundSpeed = FluidModel->GetSoundSpeed(); + + /*--- Compute Total Outflow quantities ---*/ + TotalEnthalpyOut[iMarkerTP][iSpan] = EnthalpyOut[iMarkerTP][iSpan] + 0.5*absVel2; + FluidModel->SetTDState_hs(TotalEnthalpyOut[iMarkerTP][iSpan], EntropyOut[iMarkerTP][iSpan]); + TotalPressureOut[iMarkerTP][iSpan] = FluidModel->GetPressure(); + TotalTemperatureOut[iMarkerTP][iSpan] = FluidModel->GetTemperature(); + + /*--- Retrieve relative Outflow quantities ---*/ + tangVel = geometry->GetTangGridVelOut(iMarkerTP, iSpan); + tangVel2 = tangVel*tangVel; + + for (iDim = 0; iDim < nDim; iDim++){ + relVel[iDim] = TurboVelocityOut[iMarkerTP][iSpan][iDim]; + } + relVel[1] -= tangVel; + + relVel2 = 0.0; + for (iDim = 0; iDim < nDim; iDim++){ + relVel2 += relVel[iDim]*relVel[iDim]; + } + + /*--- Compute Total relative Outflow quantities ---*/ + RothalpyOut[iMarkerTP][iSpan] = EnthalpyOut[iMarkerTP][iSpan] + 0.5*relVel2 - 0.5*tangVel2; + FluidModel->SetTDState_hs(RothalpyOut[iMarkerTP][iSpan], EntropyOut[iMarkerTP][iSpan]); + relPressureOut = FluidModel->GetPressure(); + + /*--- Compute isentropic Outflow quantities ---*/ + FluidModel->SetTDState_Ps(PressureOut[iMarkerTP][iSpan], EntropyIn[iMarkerTP][iSpan]); + enthalpyOutIs = FluidModel->GetStaticEnergy() + PressureOut[iMarkerTP][iSpan]/FluidModel->GetDensity(); + relVelOutIs2 = 2*(RothalpyOut[iMarkerTP][iSpan] - enthalpyOutIs) + tangVel2; + + + /*--- Compute kinematic relative Outflow quantities ---*/ + FlowAngleOut[iMarkerTP][iSpan] = atan(relVel[1]/relVel[0]); + mach = 0.0; + for (iDim = 0; iDim < nDim; iDim++){ + MachOut[iMarkerTP][iSpan][iDim] = relVel[iDim]/soundSpeed; + mach = MachOut[iMarkerTP][iSpan][iDim]*MachOut[iMarkerTP][iSpan][iDim]; + } + MachOut[iMarkerTP][iSpan][nDim] = sqrt(mach); + + /*--- Compute Turbulent Outflow quantities ---*/ + if(turbulent){ + FluidModel->SetTDState_Prho(PressureOut[iMarkerTP][iSpan], DensityOut[iMarkerTP][iSpan]); + muLam = FluidModel->GetLaminarViscosity(); + if(menter_sst){ + kine = solver->GetKineOut(iMarkerTP, iSpan); + omega = solver->GetOmegaOut(iMarkerTP, iSpan); + TurbIntensityOut[iMarkerTP][iSpan] = sqrt(2.0/3.0*kine/absVel2); + Turb2LamViscRatioOut[iMarkerTP][iSpan] = DensityOut[iMarkerTP][iSpan]*kine/(muLam*omega); +// TurbIntensityOut[iMarkerTP][iSpan] = kine; +// Turb2LamViscRatioOut[iMarkerTP][iSpan] = omega; + } + else{ + nu = solver->GetNuOut(iMarkerTP, iSpan); + NuFactorOut[iMarkerTP][iSpan] = nu*DensityOut[iMarkerTP][iSpan]/muLam; + } + } + + /*--- TURBO-PERFORMANCE---*/ + EntropyGen[iMarkerTP][iSpan] = (EntropyOut[iMarkerTP][iSpan] - EntropyIn[iMarkerTP][iSpan])/abs(EntropyIn_BC[iMarkerTP][iSpan] + 1); + EulerianWork[iMarkerTP][iSpan] = TotalEnthalpyIn[iMarkerTP][iSpan] - TotalEnthalpyOut[iMarkerTP][iSpan]; + TotalPressureLoss[iMarkerTP][iSpan] = (relPressureIn - relPressureOut)/(relPressureIn - PressureOut[iMarkerTP][iSpan]); + KineticEnergyLoss[iMarkerTP][iSpan] = 2*(EnthalpyOut[iMarkerTP][iSpan] - enthalpyOutIs)/relVelOutIs2; + PressureRatio[iMarkerTP][iSpan] = TotalPressureOut[iMarkerTP][iSpan]/TotalPressureIn[iMarkerTP][iSpan]; + EnthalpyOutIs[iMarkerTP][iSpan] = (pow(TotalPressureOut[iMarkerTP][iSpan]/TotalPressureIn[iMarkerTP][iSpan], 0.4/1.4) - 1.0)/(TotalTemperatureOut[iMarkerTP][iSpan]/TotalTemperatureIn[iMarkerTP][iSpan] -1.0); + } + } + + if(nBladesRow > 1){ + /*--- Compute performance for each stage ---*/ + + EulerianWork[nBladesRow + nStages][nSpanWiseSections] = 0.0; + /*---Comnpute performance for each stage---*/ + for(iStage = 0; iStage < nStages; iStage++ ){ + FluidModel->SetTDState_Ps(PressureOut[iStage*2 +1][config->GetnSpan_iZones(iStage*2 +1)], EntropyIn[iStage*2][config->GetnSpan_iZones(iStage*2)]); + EnthalpyOutIs[nBladesRow + iStage][nSpanWiseSections] = FluidModel->GetStaticEnergy() + PressureOut[iStage*2 +1][config->GetnSpan_iZones(iStage*2 +1)]/FluidModel->GetDensity(); + FluidModel->SetTDState_Prho(PressureOut[iStage*2 +1][config->GetnSpan_iZones(iStage*2 +1)], DensityOut[iStage*2 +1][config->GetnSpan_iZones(iStage*2 +1)]); + absVel2 = 0.0; + for (iDim = 0; iDimGetnSpan_iZones(iStage*2 +1)][iDim]*TurboVelocityOut[iStage*2 +1][config->GetnSpan_iZones(iStage*2 +1)][iDim]; + TotalEnthalpyOutIs[nBladesRow + iStage][nSpanWiseSections] = EnthalpyOutIs[nBladesRow + iStage][nSpanWiseSections] + 0.5*absVel2; + + TotalTotalEfficiency[nBladesRow + iStage][nSpanWiseSections] = (TotalEnthalpyIn[iStage*2][config->GetnSpan_iZones(iStage*2)] - TotalEnthalpyOut[iStage*2 + 1][config->GetnSpan_iZones(iStage*2 +1)]); + TotalTotalEfficiency[nBladesRow + iStage][nSpanWiseSections] /= (TotalEnthalpyIn[iStage*2][config->GetnSpan_iZones(iStage*2)] - TotalEnthalpyOutIs[nBladesRow + iStage][nSpanWiseSections]); + TotalStaticEfficiency[nBladesRow + iStage][nSpanWiseSections] = (TotalEnthalpyIn[iStage*2][config->GetnSpan_iZones(iStage*2)] - TotalEnthalpyOut[iStage*2 + 1][config->GetnSpan_iZones(iStage*2+1)]); + TotalStaticEfficiency[nBladesRow + iStage][nSpanWiseSections] /= (TotalEnthalpyIn[iStage*2][config->GetnSpan_iZones(iStage*2)] - EnthalpyOutIs[nBladesRow + iStage][nSpanWiseSections]); + PressureRatio[nBladesRow + iStage][nSpanWiseSections] = (PressureRatio[iStage*2][config->GetnSpan_iZones(iStage*2)]*PressureOut[iStage*2][config->GetnSpan_iZones(iStage*2)]/PressureOut[iStage*2 + 1][config->GetnSpan_iZones(iStage*2+1)]); + MassFlowIn[nBladesRow + iStage][nSpanWiseSections] = MassFlowIn[iStage*2][config->GetnSpan_iZones(iStage*2)]; + MassFlowOut[nBladesRow + iStage][nSpanWiseSections] = MassFlowOut[iStage*2 + 1][config->GetnSpan_iZones(iStage*2+1)]; + EntropyGen[nBladesRow + iStage][nSpanWiseSections] = EntropyGen[iStage*2 + 1][config->GetnSpan_iZones(iStage*2 +1)] + EntropyGen[iStage*2][config->GetnSpan_iZones(iStage*2)]; + + } + + /*---Compute turbo performance for full machine---*/ + FluidModel->SetTDState_Ps(PressureOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)], EntropyIn[0][config->GetnSpan_iZones(0)]); + EnthalpyOutIs[nBladesRow + nStages][nSpanWiseSections] = FluidModel->GetStaticEnergy() + PressureOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)]/FluidModel->GetDensity(); + FluidModel->SetTDState_Prho(PressureOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)], DensityOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)]); + absVel2 = 0.0; + for (iDim = 0; iDimGetnSpan_iZones(nBladesRow-1)][iDim]*TurboVelocityOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)][iDim]; + TotalEnthalpyOutIs[nBladesRow + nStages][nSpanWiseSections] = EnthalpyOutIs[nBladesRow + nStages][nSpanWiseSections] + 0.5*absVel2; + + TotalTotalEfficiency[nBladesRow + nStages][nSpanWiseSections] = (TotalEnthalpyIn[0][config->GetnSpan_iZones(0)] - TotalEnthalpyOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)]); + TotalTotalEfficiency[nBladesRow + nStages][nSpanWiseSections] /= (TotalEnthalpyIn[0][config->GetnSpan_iZones(0)] - TotalEnthalpyOutIs[nBladesRow + nStages][nSpanWiseSections]); + TotalStaticEfficiency[nBladesRow +nStages][nSpanWiseSections] = (TotalEnthalpyIn[0][config->GetnSpan_iZones(0)] - TotalEnthalpyOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)]); + TotalStaticEfficiency[nBladesRow +nStages][nSpanWiseSections] /= (TotalEnthalpyIn[0][config->GetnSpan_iZones(0)] - EnthalpyOutIs[nBladesRow + nStages][nSpanWiseSections]); + PressureRatio[nBladesRow + nStages][nSpanWiseSections] = PressureRatio[0][config->GetnSpan_iZones(0)]*PressureOut[0][config->GetnSpan_iZones(0)]/PressureOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)]; + MassFlowIn[nBladesRow + nStages][nSpanWiseSections] = MassFlowIn[0][config->GetnSpan_iZones(0)]; + MassFlowOut[nBladesRow + nStages][nSpanWiseSections] = MassFlowOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)]; + + EntropyGen[nBladesRow + nStages][nSpanWiseSections] = 0.0; + for(iBlade = 0; iBlade < nBladesRow; iBlade++ ){ + EntropyGen[nBladesRow + nStages][nSpanWiseSections] += EntropyGen[iBlade][config->GetnSpan_iZones(iBlade)]; + } + } + + delete [] relVel; + +} \ No newline at end of file From 4744927ed2deaf0721a92e463f3655a1a86d1505 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 14 Apr 2023 18:01:24 +0100 Subject: [PATCH 02/99] Updated turboperformance methods & history output --- Common/include/CConfig.hpp | 10 +- Common/include/option_structure.hpp | 24 +- Common/src/CConfig.cpp | 19 +- SU2_CFD/include/SU2_CFD.hpp | 2 +- SU2_CFD/include/drivers/CMultizoneDriver.hpp | 4 - SU2_CFD/include/iteration/CFluidIteration.hpp | 9 + SU2_CFD/include/iteration/CIteration.hpp | 19 + SU2_CFD/include/iteration/CTurboIteration.hpp | 5 + SU2_CFD/include/output/COutput.hpp | 79 +-- SU2_CFD/include/output/CTurboOutput.hpp | 262 +++++++++ SU2_CFD/include/solvers/CEulerSolver.hpp | 41 +- SU2_CFD/include/solvers/CSolver.hpp | 18 + SU2_CFD/src/drivers/CDriver.cpp | 50 +- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 57 +- SU2_CFD/src/integration/CIntegration.cpp | 7 + .../src/integration/CMultiGridIntegration.cpp | 23 + SU2_CFD/src/iteration/CFluidIteration.cpp | 133 +++++ SU2_CFD/src/iteration/CTurboIteration.cpp | 10 + SU2_CFD/src/meson.build | 1 + SU2_CFD/src/output/CFlowCompOutput.cpp | 90 +-- SU2_CFD/src/output/COutput.cpp | 554 ++++-------------- SU2_CFD/src/output/CTurboOutput.cpp | 304 ++++++++++ SU2_CFD/src/solvers/CEulerSolver.cpp | 5 + config_template.cfg | 4 + 24 files changed, 1100 insertions(+), 630 deletions(-) create mode 100644 SU2_CFD/include/output/CTurboOutput.hpp create mode 100644 SU2_CFD/src/output/CTurboOutput.cpp diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index f10273fbfc8..d4b8e93aa37 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -71,7 +71,6 @@ class CConfig { unsigned short Kind_PerformanceAverageProcess; /*!< \brief Kind of mixing process.*/ unsigned short Kind_MixingPlaneInterface; /*!< \brief Kind of mixing process.*/ unsigned short Kind_SpanWise; /*!< \brief Kind of span-wise section computation.*/ - unsigned short *Kind_TurboMachinery; /*!< \brief Kind of turbomachynery architecture.*/ unsigned short iZone, nZone; /*!< \brief Number of zones in the mesh. */ unsigned short nZoneSpecified; /*!< \brief Number of zones that are specified in config file. */ su2double Highlite_Area; /*!< \brief Highlite area. */ @@ -434,6 +433,9 @@ class CConfig { Max_DeltaTime, /*!< \brief Max delta time. */ Unst_CFL; /*!< \brief Unsteady CFL number. */ + TURBO_PERF_KIND *Kind_TurboPerf; /*!< \brief Kind of turbomachynery architecture.*/ + TURBOMACHINERY_TYPE *Kind_TurboMachinery; + /* Gradient smoothing options */ su2double SmoothingEps1; /*!< \brief Parameter for the identity part in gradient smoothing. */ su2double SmoothingEps2; /*!< \brief Parameter for the Laplace part in gradient smoothing. */ @@ -5036,7 +5038,7 @@ class CConfig { * \brief Get the kind of turbomachinery architecture. * \return Kind of turbomachinery architecture. */ - unsigned short GetKind_TurboMachinery(unsigned short val_iZone) const { return Kind_TurboMachinery[val_iZone]; } + TURBOMACHINERY_TYPE GetKind_TurboMachinery(unsigned short val_iZone) const { return Kind_TurboMachinery[val_iZone]; } /*! * \brief Get the kind of turbomachinery architecture. @@ -5151,7 +5153,7 @@ class CConfig { void SetnSpanWiseSections(unsigned short nSpan) { nSpanWiseSections = nSpan;} /*! - * \brief set number span-wise sections to compute 3D BC and performance for turbomachinery. + * \brief get number span-wise sections to compute 3D BC and performance for turbomachinery. */ unsigned short GetnSpan_iZones(unsigned short iZone) const { return nSpan_iZones[iZone];} @@ -5176,7 +5178,7 @@ class CConfig { * \brief get marker kind for Turbomachinery performance calculation. * \return kind index. */ - unsigned short GetKind_TurboPerf(unsigned short index); + TURBO_PERF_KIND GetKind_TurboPerf(unsigned short val_iZone) const { return Kind_TurboPerf[val_iZone]; }; /*! * \brief get outlet bounds name for Turbomachinery performance calculation. diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 9ce8808b038..f53b426dade 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1738,11 +1738,25 @@ enum TURBOMACHINERY_TYPE { AXIAL_CENTRIFUGAL = 5 /*!< \brief mixed flow turbine. */ }; static const MapType TurboMachinery_Map = { - MakePair("AXIAL", AXIAL) - MakePair("CENTRIFUGAL", CENTRIFUGAL) - MakePair("CENTRIPETAL", CENTRIPETAL) - MakePair("CENTRIPETAL_AXIAL", CENTRIPETAL_AXIAL) - MakePair("AXIAL_CENTRIFUGAL", AXIAL_CENTRIFUGAL) + MakePair("AXIAL", TURBOMACHINERY_TYPE::AXIAL) + MakePair("CENTRIFUGAL", TURBOMACHINERY_TYPE::CENTRIFUGAL) + MakePair("CENTRIPETAL", TURBOMACHINERY_TYPE::CENTRIPETAL) + MakePair("CENTRIPETAL_AXIAL", TURBOMACHINERY_TYPE::CENTRIPETAL_AXIAL) + MakePair("AXIAL_CENTRIFUGAL", TURBOMACHINERY_TYPE::AXIAL_CENTRIFUGAL) +}; + +/*! + * \brief Types of Turbomachinery performance Type. + */ +enum class TURBO_PERF_KIND{ + TURBINE, /*!< \brief Turbine Performance. */ + COMPRESSOR, /*!< \brief Compressor Performance. */ + PROPELLOR /*!< \brief Propellor Performance. */ +}; +static const MapType TurboPerfKind_Map = { + MakePair("TURBINE", TURBO_PERF_KIND::TURBINE) + MakePair("COMPRESSOR", TURBO_PERF_KIND::COMPRESSOR) + MakePair("PROPELLOR", TURBO_PERF_KIND::PROPELLOR) }; /*! diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 5f3a9d7535a..f2f8bbceffd 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1587,6 +1587,9 @@ void CConfig::SetConfig_Options() { /*!\brief TURBOMACHINERY_KIND \n DESCRIPTION: types of turbomachynery architecture. \n OPTIONS: see \link TurboMachinery_Map \endlink \n Default: AXIAL */ addEnumListOption("TURBOMACHINERY_KIND",nTurboMachineryKind, Kind_TurboMachinery, TurboMachinery_Map); + /*!\brief TURBOMACHINERY_KIND \n DESCRIPTION: types of turbomachynery Performance Calculations. + \n OPTIONS: see \link TurboPerfKind_Map \endlink \n Default: TURBINE */ + addEnumListOption("TURBO_PERF_KIND", nTurboMachineryKind, Kind_TurboPerf, TurboPerfKind_Map); /*!\brief MARKER_SHROUD \n DESCRIPTION: markers in which velocity is forced to 0.0 . * \n Format: (shroud1, shroud2, ...)*/ addStringListOption("MARKER_SHROUD", nMarker_Shroud, Marker_Shroud); @@ -6787,16 +6790,16 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { default: break; + } } - } - else { - if (Time_Domain) { - cout << "Dynamic structural analysis."<< endl; - cout << "Time step provided by the user for the dynamic analysis(s): "<< Delta_DynTime << "." << endl; - } else { - cout << "Static structural analysis." << endl; + else { + if (Time_Domain) { + cout << "Dynamic structural analysis."<< endl; + cout << "Time step provided by the user for the dynamic analysis(s): "<< Delta_DynTime << "." << endl; + } else { + cout << "Static structural analysis." << endl; + } } - } if ((Kind_Solver == MAIN_SOLVER::EULER) || (Kind_Solver == MAIN_SOLVER::NAVIER_STOKES) || (Kind_Solver == MAIN_SOLVER::RANS) || (Kind_Solver == MAIN_SOLVER::INC_EULER) || (Kind_Solver == MAIN_SOLVER::INC_NAVIER_STOKES) || (Kind_Solver == MAIN_SOLVER::INC_RANS) || diff --git a/SU2_CFD/include/SU2_CFD.hpp b/SU2_CFD/include/SU2_CFD.hpp index c23920bb9e4..044cfd7ae58 100644 --- a/SU2_CFD/include/SU2_CFD.hpp +++ b/SU2_CFD/include/SU2_CFD.hpp @@ -29,7 +29,7 @@ #include "../../Common/include/parallelization/mpi_structure.hpp" #include "../../Common/include/parallelization/omp_structure.hpp" -#include "CLI11.hpp" +#include "../../externals/CLI11/CLI11.hpp" #include "drivers/CDriver.hpp" #include "drivers/CSinglezoneDriver.hpp" diff --git a/SU2_CFD/include/drivers/CMultizoneDriver.hpp b/SU2_CFD/include/drivers/CMultizoneDriver.hpp index afff04b8eac..48d4f9d740e 100644 --- a/SU2_CFD/include/drivers/CMultizoneDriver.hpp +++ b/SU2_CFD/include/drivers/CMultizoneDriver.hpp @@ -83,10 +83,6 @@ class CMultizoneDriver : public CDriver { */ bool TransferData(unsigned short donorZone, unsigned short targetZone); - /*! - * \brief Set Mixing Plane interface within multiple zones. - */ - void SetMixingPlane(unsigned short donorZone); /*! * \brief Transfer the local turboperfomance quantities (for each blade row) from all the donorZones to the diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index 6346c716929..4b24fec9f80 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -106,6 +106,15 @@ class CFluidIteration : public CIteration { CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) override; + /*! + * \brief Monitors turbo computation (pressure and turbo ramps). + */ + void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) override; + + /*! + * \brief Monitors turbo computation (pressure and turbo ramps). + */ + void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) override; /*! * \brief Postprocesses the fluid system before heading to another physics system or the next iteration. diff --git a/SU2_CFD/include/iteration/CIteration.hpp b/SU2_CFD/include/iteration/CIteration.hpp index eed41a39a15..9938e174c5e 100644 --- a/SU2_CFD/include/iteration/CIteration.hpp +++ b/SU2_CFD/include/iteration/CIteration.hpp @@ -35,6 +35,7 @@ #include "../../../Common/include/grid_movement/CFreeFormDefBox.hpp" #include "../../../Common/include/parallelization/mpi_structure.hpp" #include "../integration/CIntegration.hpp" +#include "../output/CTurboOutput.hpp" using namespace std; @@ -59,6 +60,9 @@ class CIteration { su2double StartTime{0.0}, /*!< \brief Tracking wall time. */ StopTime{0.0}, UsedTime{0.0}; + std::shared_ptr TurbomachineryPerformance; /*!< \brief turbo performance calculator. */ + CTurbomachineryStagePerformance* TurbomachineryStagePerformance; /*!< \brief turbo stage performance calculator. */ + public: /*! * \brief Constructor of the class. @@ -247,6 +251,21 @@ class CIteration { unsigned short val_iInst) { return false; } + + /*! + * \brief Monitors turbo computation (pressure and turbo ramps). + */ + virtual void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) {}; + + /*! + * \brief Monitors turbo computation (pressure and turbo ramps). + */ + virtual void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) {}; + + /*! + * \brief Monitors turbo computation (pressure and turbo ramps). + */ + virtual void InitTurboPerformance(CGeometry *geometry, CConfig *config, CFluidModel *fluid) {} /*! * \brief A virtual member. diff --git a/SU2_CFD/include/iteration/CTurboIteration.hpp b/SU2_CFD/include/iteration/CTurboIteration.hpp index ad52aaa04b4..144fa758986 100644 --- a/SU2_CFD/include/iteration/CTurboIteration.hpp +++ b/SU2_CFD/include/iteration/CTurboIteration.hpp @@ -63,4 +63,9 @@ class CTurboIteration : public CFluidIteration { CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) override; + + /*! + * \brief Monitors turbo computation (pressure and turbo ramps). + */ + void InitTurboPerformance(CGeometry *geometry, CConfig *config, CFluidModel *fluid) override; }; diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index ab7c173d921..e620da7f2e9 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -38,6 +38,7 @@ #include "../../../Common/include/toolboxes/printing_toolbox.hpp" #include "tools/CWindowingTools.hpp" #include "../../../Common/include/option_structure.hpp" +#include "CTurboOutput.hpp" /*--- AD workaround for a cmath function not defined in CoDi. ---*/ namespace mel { @@ -47,7 +48,7 @@ inline su2double hypot(const su2double& a, const su2double& b) { } } } -#include "mel.hpp" +#include "../../../externals/mel/mel.hpp" class CGeometry; class CSolver; @@ -320,64 +321,7 @@ class COutput { su2double WndCauchy_Value; /*!< \brief Summed value of the convergence indicator. */ bool TimeConvergence; /*!< \brief To indicate, if the windowed time average of the time loop has converged*/ - /*--- Turbomachinery Performance Variable ---*/ - su2double Sum_Total_RadialDistortion, Sum_Total_CircumferentialDistortion; // Add all the distortion to compute a run average. - bool turbo; - unsigned short nSpanWiseSections, nMarkerTurboPerf; - - su2double **TotalStaticEfficiency, - **TotalTotalEfficiency, - **KineticEnergyLoss, - **TRadius, - **TotalPressureLoss, - **MassFlowIn, - **MassFlowOut, - **FlowAngleIn, - **FlowAngleIn_BC, - **FlowAngleOut, - **EulerianWork, - **TotalEnthalpyIn, - **TotalEnthalpyIn_BC, - **EntropyIn, - **EntropyOut, - **EntropyIn_BC, - **PressureRatio, - **TotalTemperatureIn, - **EnthalpyOut, - ***MachIn, - ***MachOut, - **VelocityOutIs, - **DensityIn, - **PressureIn, - ***TurboVelocityIn, - **DensityOut, - **PressureOut, - ***TurboVelocityOut, - **EnthalpyOutIs, - **EntropyGen, - **AbsFlowAngleIn, - **TotalEnthalpyOut, - **RothalpyIn, - **RothalpyOut, - **TotalEnthalpyOutIs, - **AbsFlowAngleOut, - **PressureOut_BC, - **TemperatureIn, - **TemperatureOut, - **TotalPressureIn, - **TotalPressureOut, - **TotalTemperatureOut, - **EnthalpyIn, - **TurbIntensityIn, - **Turb2LamViscRatioIn, - **TurbIntensityOut, - **Turb2LamViscRatioOut, - **NuFactorIn, - **NuFactorOut; - - /*--- End of turbomachinery performance ---*/ public: - /*----------------------------- Public member functions ----------------------------*/ /*! @@ -427,7 +371,26 @@ class COutput { */ void SetHistoryOutput(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter); + /*! + * \brief Collects Turbomachinery Performance data from the solvers and prints the data in tabular format on screen. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] config - Definition of the particular problem. + * \param[in] TimeIter - Value of the time iteration index + * \param[in] OuterIter - Value of outer iteration index + * \param[in] InnerIter - Value of the inner iteration index + */ + void SetTurboPerformance_Output(std::shared_ptr TurboPerf, CConfig *config, + unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iZone); + + void SetTurboMultiZonePerformance_Output(CTurbomachineryStagePerformance* TurboStagePerf, + std::shared_ptr TurboPerf, + CConfig *config); + void LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, + std::shared_ptr TurboPerf, + CConfig *config, + unsigned short iZone); /*! * \brief Collects history data from the solvers and monitors the convergence. Does not write to screen or file. * \param[in] geometry - Geometrical definition of the problem. diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp new file mode 100644 index 00000000000..ef9d5ff1f6a --- /dev/null +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -0,0 +1,262 @@ +/*! + * \file CTurboOutput.hpp + * \brief Headers of the Turbomachinery Performance class. + * \author S. Vitale, N. Anand + * \version 7.1.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + + +#pragma once + +#include +#include +#include +#include +#include +#include "../../../Common/include/geometry/CGeometry.hpp" +#include "../../../Common/include/CConfig.hpp" +#include "../fluid/CFluidModel.hpp" + + +class CTurbomachineryPrimitiveState { + private: + su2double Density, Pressure, TangVelocity; + vector Velocity; + public: + CTurbomachineryPrimitiveState(); + + CTurbomachineryPrimitiveState(vector TurboPrimitives, + unsigned short nDim, + su2double tangVel); + + su2double GetDensity() const & { return Density; } + + su2double GetPressure() const & { return Pressure; } + + su2double GetTangVelocity() const & { return TangVelocity; } + + vector GetVelocity() const & { return Velocity; } + +}; + +class CTurbomachineryCombinedPrimitiveStates { + private: + CTurbomachineryPrimitiveState InletPrimitiveState; + CTurbomachineryPrimitiveState OutletPrimitiveState; + public: + + CTurbomachineryCombinedPrimitiveStates(const CTurbomachineryPrimitiveState &inletPrimitiveState, + const CTurbomachineryPrimitiveState &outletPrimitiveState); + + CTurbomachineryPrimitiveState GetInletPrimitiveState() const & { return InletPrimitiveState; } + + CTurbomachineryPrimitiveState GetOutletPrimitiveState() const & { return OutletPrimitiveState; } +}; + +class CTurbomachineryState { + private: + su2double Density, Pressure, Entropy, Enthalpy, Temperature, TotalTemperature, TotalPressure, TotalEnthalpy; + su2double AbsFlowAngle, FlowAngle, MassFlow, Rothalpy, TotalRelPressure; + vector Velocity, RelVelocity, Mach, RelMach; + su2double Area, Radius; + + + public: + CTurbomachineryState(); + + CTurbomachineryState(unsigned short nDim, su2double area, su2double radius); + + void ComputeState(CFluidModel& fluidModel, const CTurbomachineryPrimitiveState &primitiveState); + + su2double GetDensity() const { return Density; } + + su2double GetPressure() const { return Pressure; } + + su2double GetEntropy() const { return Entropy; } + + su2double GetEnthalpy() const { return Enthalpy; } + + su2double GetTemperature() const { return Temperature; } + + su2double GetTotalTemperature() const { return TotalTemperature; } + + su2double GetTotalPressure() const { return TotalPressure; } + + su2double GetTotalRelPressure() const { return TotalRelPressure; } + + su2double GetTotalEnthalpy() const { return TotalEnthalpy; } + + su2double GetAbsFlowAngle() const { return AbsFlowAngle; } + + su2double GetFlowAngle() const { return FlowAngle; } + + su2double GetMassFlow() const { return MassFlow; } + + su2double GetRothalpy() const { return Rothalpy; } + + vector GetVelocity() const { return Velocity; } + + vector GetMach() const { return Mach; } + + su2double GetVelocityValue() const { + return Norm(Velocity); + } + + su2double GetMachValue() const { + return Norm(Mach); + } + + su2double GetRelVelocityValue() const { + return Norm(RelVelocity); + } + + su2double GetRelMachValue() const { + return Norm(RelMach); + } + + su2double Norm(vector const& u) const { + su2double accum = 0.; + for (int i = 0; i < u.size(); ++i) { + accum += u[i] * u[i]; + } + return sqrt(accum); + } +}; + + +class CTurbomachineryBladePerformance { + protected: + CTurbomachineryState InletState; + CTurbomachineryState OutletState; + su2double KineticEnergyLoss, TotalPressureLoss, EntropyGen, PressureRatio, EulerianWork; + CFluidModel &FluidModel; + + public: + CTurbomachineryBladePerformance(CFluidModel& fluidModel, + unsigned short nDim, + su2double areaIn, + su2double radiusIn, + su2double areaOut, + su2double radiusOut); + + virtual void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) {}; + + const CTurbomachineryState& GetInletState() { return InletState; } + + const CTurbomachineryState& GetOutletState() { return OutletState; } + + su2double GetKineticEnergyLoss() const { return KineticEnergyLoss; } + + su2double GetTotalPressureLoss() const { return TotalPressureLoss; } + + su2double GetEntropyGen() const { return EntropyGen; } + + su2double GetPressureRatio() const { return PressureRatio; } + + su2double GetEulerianWork() const { return EulerianWork; } + +}; + +class CTurbineBladePerformance : public CTurbomachineryBladePerformance { + + public: + CTurbineBladePerformance(CFluidModel& fluidModel, + unsigned short nDim, + su2double areaIn, + su2double radiusIn, + su2double areaOut, + su2double radiusOut); + + void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) override; + +}; + +class CCompressorBladePerformance : public CTurbomachineryBladePerformance { + + public: + CCompressorBladePerformance(CFluidModel& fluidModel, + unsigned short nDim, + su2double areaIn, + su2double radiusIn, + su2double areaOut, + su2double radiusOut); + + void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) override; + +}; + +class CPropellorBladePerformance : public CTurbomachineryBladePerformance { + + public: + CPropellorBladePerformance(CFluidModel& fluidModel, + unsigned short nDim, + su2double areaIn, + su2double radiusIn, + su2double areaOut, + su2double radiusOut); + + void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) override; + +}; + +class CTurbomachineryStagePerformance { + protected: + su2double TotalStaticEfficiency, TotalTotalEfficiency, NormEntropyGen, TotalStaticPressureRatio, TotalTotalPressureRatio, EulerianWork; + CFluidModel &fluidModel; + public: + CTurbomachineryStagePerformance(CFluidModel& fluid); + virtual ~CTurbomachineryStagePerformance() = default; + virtual void ComputePerformanceStage(CTurbomachineryState InState, CTurbomachineryState OutState, const CConfig* config); + virtual void ComputeTurbineStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState); + virtual void ComputeCompressorStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState); + su2double GetTotalStaticEfficiency() const { return TotalStaticEfficiency; } + su2double GetTotalTotalEfficiency() const { return TotalTotalEfficiency; } + su2double GetEulerianWork() const { return EulerianWork; } + su2double GetNormEntropyGen() const { return NormEntropyGen; } + su2double GetTotalStaticPressureRatio() const { return TotalStaticPressureRatio; } + su2double GetTotalTotalPressureRatio() const { return TotalTotalPressureRatio; } +}; + +class CTurboOutput { + private: + vector >> + BladesPerformances; + + static void ComputePerBlade(vector > const bladePerformances, + vector const bladePrimitives); + + static void ComputePerSpan(shared_ptr const spanPerformances, + const CTurbomachineryCombinedPrimitiveStates &spanPrimitives); + // vector> StagePerformances; + // shared_ptr MachinePerformances; + public: + CTurboOutput(const CConfig& config, const CGeometry& geometry, CFluidModel& fluidModel); + + vector >> + + GetBladesPerformances() const { return BladesPerformances; } + + // vector> GetStagePerformances() const { return StagePerformances; } + // shared_ptr GetMachinePerformances() const { return MachinePerformances; } + void ComputeTurbomachineryPerformance(vector > const primitives); +}; \ No newline at end of file diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index eecc7a292a0..bfe94ebe976 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -29,6 +29,7 @@ #include "CFVMFlowSolverBase.hpp" #include "../variables/CEulerVariable.hpp" +#include "../../../Common/include/option_structure.hpp" /*! * \class CEulerSolver @@ -108,6 +109,8 @@ class CEulerSolver : public CFVMFlowSolverBase TurbomachineryPerformance; /*!< \brief turbo performance calculator. */ + vector FluidModel; /*!< \brief fluid model used in the solver. */ /*--- Turbomachinery Solver Variables ---*/ @@ -1026,12 +1029,40 @@ class CEulerSolver : public CFVMFlowSolverBase GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool INLET) { + TurboPrimitive.clear(); + if (INLET) { + TurboPrimitive.push_back(DensityIn[iBlade][iSpan]); TurboPrimitive.push_back(PressureIn[iBlade][iSpan]); + TurboPrimitive.push_back(TurboVelocityIn[iBlade][iSpan][0]);TurboPrimitive.push_back(TurboVelocityIn[iBlade][iSpan][1]); + if (nDim==3) + TurboPrimitive.push_back(TurboVelocityIn[iBlade][iSpan][2]); + } + else { + TurboPrimitive.push_back(DensityOut[iBlade][iSpan]); TurboPrimitive.push_back(PressureOut[iBlade][iSpan]); + TurboPrimitive.push_back(TurboVelocityOut[iBlade][iSpan][0]);TurboPrimitive.push_back(TurboVelocityOut[iBlade][iSpan][1]); + if (nDim==3) + TurboPrimitive.push_back(TurboVelocityOut[iBlade][iSpan][2]); + } + return TurboPrimitive; + } /*! * \brief Set the solution using the Freestream values. * \param[in] config - Definition of the particular problem. */ void SetFreeStream_TurboSolution(CConfig *config) final; - + /*! * \brief It computes average quantities along the span for turbomachinery analysis. * \param[in] geometry - Geometrical definition of the problem. @@ -1088,9 +1119,9 @@ class CEulerSolver : public CFVMFlowSolverBase TurboPrimitive; + int *Restart_Vars; /*!< \brief Auxiliary structure for holding the number of variables and points in a restart. */ int Restart_ExtIter; /*!< \brief Auxiliary structure for holding the external iteration offset from a restart. */ passivedouble *Restart_Data; /*!< \brief Auxiliary structure for holding the data values from a restart. */ @@ -3804,6 +3807,14 @@ class CSolver { */ inline virtual void InitTurboContainers(CGeometry *geometry, CConfig *config) { } +/*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] config - Definition of the particular problem. + */ + inline virtual void InitTurboPerformance(CGeometry *geometry, CConfig *config) { } + + /*! * \brief virtual member. * \param[in] geometry - Geometrical definition of the problem. @@ -4327,6 +4338,13 @@ class CSolver { */ inline virtual bool GetHasHybridParallel() const { return false; } + /*! + * \brief Get Primal variables for turbo performance computation + * iteration can be executed by multiple threads. + * \return returns Density, pressure and TurboVelocity (IN/OUTLET) + */ + virtual vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool INLET) {return TurboPrimitive;} + /*! * \brief Get values for streamwise periodic flow: delta P, m_dot, inlet T, integrated heat, etc. * \return Struct holding streamwise periodic values. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 4dc172499de..06854fcdce3 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2462,6 +2462,9 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet const bool fluid_donor = config[donor]->GetFluidProblem(); const bool structural_donor = config[donor]->GetStructuralProblem(); + /*--- Turbomachinery Bool for MIXING PLANE ---*/ + const bool turbo = config[donor]->GetBoolTurbomachinery(); + /*--- Initialize the appropriate transfer strategy. ---*/ if (rank == MASTER_NODE) cout << " Transferring "; @@ -2488,10 +2491,22 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet if (rank == MASTER_NODE) cout << "boundary displacements from the structural solver." << endl; } else if (fluid_donor && fluid_target) { - interface_type = SLIDING_INTERFACE; - auto nVar = solver[donor][INST_0][MESH_0][FLOW_SOL]->GetnPrimVar(); - interface[donor][target] = new CSlidingInterface(nVar, 0); - if (rank == MASTER_NODE) cout << "sliding interface." << endl; + /*--- Mixing plane for turbo machinery applications. ---*/ + if (config[donor]->GetBoolMixingPlaneInterface()) { + interface_type = MIXING_PLANE; + auto nVar = solver[donor][INST_0][MESH_0][FLOW_SOL]->GetnVar(); + interface[donor][target] = new CMixingPlaneInterface(nVar, 0); + if (rank == MASTER_NODE) { + cout << "Set mixing-plane interface from donor zone " + << donor << " to target zone " << target << "." << endl; + } + } + else{ + auto nVar = solver[donor][INST_0][MESH_0][FLOW_SOL]->GetnPrimVar(); + interface_type = SLIDING_INTERFACE; + interface[donor][target] = new CSlidingInterface(nVar, 0); + if (rank == MASTER_NODE) cout << "sliding interface." << endl; + } } else if (heat_donor || heat_target) { if (heat_donor && heat_target) @@ -2526,18 +2541,6 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet } } - /*--- Mixing plane for turbo machinery applications. ---*/ - - if (config[donor]->GetBoolMixingPlaneInterface()) { - interface_type = MIXING_PLANE; - auto nVar = solver[donor][INST_0][MESH_0][FLOW_SOL]->GetnVar(); - interface[donor][target] = new CMixingPlaneInterface(nVar, 0); - if (rank == MASTER_NODE) { - cout << "Set mixing-plane interface from donor zone " - << donor << " to target zone " << target << "." << endl; - } - } - } } @@ -2694,7 +2697,7 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, nSpanMax = config[iZone]->GetnSpanWiseSections(); } - config[ZONE_0]->SetnSpan_iZones(config[iZone]->GetnSpanWiseSections(), iZone); + config[nZone-1]->SetnSpan_iZones(config[iZone]->GetnSpanWiseSections(), iZone); geometry[iZone][INST_0][MESH_0]->SetTurboVertex(config[iZone], iZone, INFLOW, true); geometry[iZone][INST_0][MESH_0]->SetTurboVertex(config[iZone], iZone, OUTFLOW, true); @@ -2710,7 +2713,7 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, if (rank == MASTER_NODE) cout<<"Max number of span-wise sections among all zones: "<< nSpanMax<<"."<< endl; - if (rank == MASTER_NODE) cout<<"Initialize solver containers for average and performance quantities." << endl; + if (rank == MASTER_NODE) cout<<"Initialize solver containers for average quantities." << endl; for (iZone = 0; iZone < nZone; iZone++) { solver[iZone][INST_0][MESH_0][FLOW_SOL]->InitTurboContainers(geometry[iZone][INST_0][MESH_0],config[iZone]); } @@ -2728,16 +2731,17 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, if (rank == MASTER_NODE) cout << "Set span-wise sections between zones on Mixing-Plane interface." << endl; for (donorZone = 0; donorZone < nZone; donorZone++) { for (targetZone = 0; targetZone < nZone; targetZone++) { - if (targetZone != donorZone){ + if (interface_container[donorZone][targetZone] != nullptr){ interface[donorZone][targetZone]->SetSpanWiseLevels(config[donorZone], config[targetZone]); } } } } - if (rank == MASTER_NODE) cout << "Transfer average geometric quantities to zone 0." << endl; - for (iZone = 1; iZone < nZone; iZone++) { - interface[iZone][ZONE_0]->GatherAverageTurboGeoValues(geometry[iZone][INST_0][MESH_0],geometry[ZONE_0][INST_0][MESH_0], iZone); + //TODO: Fix mass flow + for (iZone = 0; iZone < nZone-1; iZone++) { + if (interface[iZone][nZone-1] != nullptr) + interface[iZone][nZone-1]->GatherAverageTurboGeoValues(geometry[iZone][INST_0][MESH_0],geometry[nZone-1][INST_0][MESH_0], iZone); } /*--- Transfer number of blade to ZONE_0 to correctly compute turbo performance---*/ @@ -2764,7 +2768,7 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, nMarkerInt = config_container[donorZone]->GetnMarker_MixingPlaneInterface()/2; for (iMarkerInt = 1; iMarkerInt <= nMarkerInt; iMarkerInt++){ for (targetZone = 0; targetZone < nZone; targetZone++) { - if (targetZone != donorZone){ + if (interface_types[donorZone][targetZone]==MIXING_PLANE){ interface[donorZone][targetZone]->PreprocessAverage(geometry[donorZone][INST_0][MESH_0], geometry[targetZone][INST_0][MESH_0], config[donorZone], config[targetZone], iMarkerInt); diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 0e2d02a0c65..ec87b210663 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -181,7 +181,6 @@ void CMultizoneDriver::StartSolver() { Preprocess(TimeIter); /*--- Run a block iteration of the multizone problem. ---*/ - switch (driver_config->GetKind_MZSolver()){ case ENUM_MULTIZONE::MZ_BLOCK_GAUSS_SEIDEL: RunGaussSeidel(); break; // Block Gauss-Seidel iteration case ENUM_MULTIZONE::MZ_BLOCK_JACOBI: RunJacobi(); break; // Block-Jacobi iteration @@ -285,21 +284,13 @@ void CMultizoneDriver::RunGaussSeidel() { for (iZone = 0; iZone < nZone; iZone++) { config_container[iZone]->SetOuterIter(0ul); - /*--- This is required for correct restarts with mixing plane interfaces and GS iterations, - * for Jacobi we always do all the transfers before iterating all zones. ---*/ - if (mixingplane) SetMixingPlane(iZone); } /*--- Loop over the number of outer iterations ---*/ - for (auto iOuter_Iter = 0ul; iOuter_Iter < driver_config->GetnOuter_Iter(); iOuter_Iter++) { - - /*--- Ramp turbo values for steady problems here, otherwise do it over time steps. ---*/ - if (!config_container[ZONE_0]->GetTime_Domain()) { - RampTurbomachineryValues(iOuter_Iter); - } + for (auto iOuter_Iter = 0ul; iOuter_Iter < driver_config->GetnOuter_Iter(); iOuter_Iter++){ /*--- Loop over the number of zones (IZONE) ---*/ - for (iZone = 0; iZone < nZone; iZone++) { + for (iZone = 0; iZone < nZone; iZone++){ /*--- In principle, the mesh does not need to be updated ---*/ UpdateMesh = 0; @@ -317,7 +308,6 @@ void CMultizoneDriver::RunGaussSeidel() { if (DeformMesh) UpdateMesh+=1; } } - /*--- If a mesh update is required due to the transfer of data ---*/ if (UpdateMesh > 0) DynamicMeshUpdate(iZone, TimeIter); @@ -326,8 +316,6 @@ void CMultizoneDriver::RunGaussSeidel() { solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0); - if (mixingplane) SetMixingPlane(iZone); - /*--- A corrector step can help preventing numerical instabilities ---*/ Corrector(iZone); @@ -351,10 +339,6 @@ void CMultizoneDriver::RunJacobi() { /*--- Loop over the number of outer iterations ---*/ for (auto iOuter_Iter = 0ul; iOuter_Iter < driver_config->GetnOuter_Iter(); iOuter_Iter++){ - /*--- Ramp turbo values for steady problems here, otherwise do it over time steps. ---*/ - if (!config_container[ZONE_0]->GetTime_Domain()) { - RampTurbomachineryValues(iOuter_Iter); - } /*--- Transfer from all zones ---*/ for (iZone = 0; iZone < nZone; iZone++){ @@ -377,7 +361,6 @@ void CMultizoneDriver::RunJacobi() { /*--- If a mesh update is required due to the transfer of data ---*/ if (UpdateMesh > 0) DynamicMeshUpdate(iZone, TimeIter); - if (mixingplane) SetMixingPlane(iZone); } /*--- Loop over the number of zones (IZONE) ---*/ @@ -600,6 +583,26 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar BroadcastData(FLOW_SOL, FEA_SOL); break; case MIXING_PLANE: + { + auto nMarkerInt = config_container[donorZone]->GetnMarker_MixingPlaneInterface()/2; + + /* --- transfer the average value from the donorZone to the targetZone*/ + for (auto iMarkerInt = 1; iMarkerInt <= nMarkerInt; iMarkerInt++) { + interface_container[donorZone][targetZone]->AllgatherAverage(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL],solver_container[targetZone][INST_0][MESH_0][FLOW_SOL], + geometry_container[donorZone][INST_0][MESH_0],geometry_container[targetZone][INST_0][MESH_0], + config_container[donorZone], config_container[targetZone], iMarkerInt ); + } + + for (donorZone = 0; donorZone < nZone-1; donorZone++) { + if (interface_types[donorZone][targetZone]==MIXING_PLANE) { + interface_container[donorZone][targetZone]->GatherAverageValues(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL],solver_container[targetZone][INST_0][MESH_0][FLOW_SOL], donorZone); + interface_container[donorZone][targetZone]->GatherAverageTurboGeoValues(geometry_container[donorZone][INST_0][MESH_0],geometry_container[targetZone][INST_0][MESH_0], donorZone); + } + } + + return UpdateMesh; + break; + } case NO_TRANSFER: case ZONES_ARE_EQUAL: case NO_COMMON_INTERFACE: @@ -614,21 +617,7 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar return UpdateMesh; } -void CMultizoneDriver::SetMixingPlane(unsigned short donorZone) { - const auto nMarkerInt = config_container[donorZone]->GetnMarker_MixingPlaneInterface() / 2; - - /*--- Transfer the average value from the donor zones to the target zones ---*/ - for (auto iMarkerInt = 1; iMarkerInt <= nMarkerInt; iMarkerInt++) { - for (auto targetZone = 0u; targetZone < nZone; targetZone++) { - if (targetZone == donorZone) continue; - interface_container[donorZone][targetZone]->AllgatherAverage( - solver_container[donorZone][INST_0][MESH_0][FLOW_SOL], solver_container[targetZone][INST_0][MESH_0][FLOW_SOL], - geometry_container[donorZone][INST_0][MESH_0], geometry_container[targetZone][INST_0][MESH_0], - config_container[donorZone], config_container[targetZone], iMarkerInt); - } - } -} void CMultizoneDriver::SetTurboPerformance() { for (auto donorZone = 1u; donorZone < nZone; donorZone++) { @@ -636,7 +625,6 @@ void CMultizoneDriver::SetTurboPerformance() { solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL], donorZone); } - output_container[ZONE_0]->ComputeTurboPerformance(config_container[ZONE_0], geometry_container[ZONE_0][INST_0][MESH_0], solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]); } bool CMultizoneDriver::Monitor(unsigned long TimeIter){ @@ -684,7 +672,6 @@ bool CMultizoneDriver::Monitor(unsigned long TimeIter){ return (FinalTimeReached || MaxIterationsReached); } - if (rank == MASTER_NODE) SetTurboPerformance(); } diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index 1da64f36a32..c99311fb3eb 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -89,6 +89,13 @@ void CIntegration::Space_Integration(CGeometry *geometry, solver_container[MainSolver]->PreprocessBC_Giles(geometry, config, conv_bound_numerics, OUTFLOW); } + if (config->GetBoolTurbomachinery()){ + /*--- Average quantities at the inflow and outflow boundaries ---*/ + + solver_container[MainSolver]->TurboAverageProcess(solver_container, geometry,config,INFLOW); + solver_container[MainSolver]->TurboAverageProcess(solver_container, geometry, config, OUTFLOW); + } + /*--- Weak boundary conditions ---*/ for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { diff --git a/SU2_CFD/src/integration/CMultiGridIntegration.cpp b/SU2_CFD/src/integration/CMultiGridIntegration.cpp index c3b8df8401b..2584b9ff402 100644 --- a/SU2_CFD/src/integration/CMultiGridIntegration.cpp +++ b/SU2_CFD/src/integration/CMultiGridIntegration.cpp @@ -668,6 +668,29 @@ void CMultiGridIntegration::NonDimensional_Parameters(CGeometry **geometry, CSol solver_container[FinestMesh][FLOW_SOL]->Momentum_Forces(geometry[FinestMesh], config); solver_container[FinestMesh][FLOW_SOL]->Friction_Forces(geometry[FinestMesh], config); + /*--- Calculate the turbo performance ---*/ + if (config->GetBoolTurbomachinery()){ + + /*--- Average quantities at the inflow and outflow boundaries ---*/ + + solver_container[FinestMesh][FLOW_SOL]->TurboAverageProcess(solver_container[FinestMesh], geometry[FinestMesh],config,INFLOW); + solver_container[FinestMesh][FLOW_SOL]->TurboAverageProcess(solver_container[FinestMesh], geometry[FinestMesh], config, OUTFLOW); + + /*--- Gather Inflow and Outflow quantities on the Master Node to compute performance ---*/ + + solver_container[FinestMesh][FLOW_SOL]->GatherInOutAverageValues(config, geometry[FinestMesh]); + + /* --- compute turboperformance for each stage and the global machine ---*/ + //TODO: for multi-zone turbo this should be move to the last zone ---*/ + // solver_container[FinestMesh][FLOW_SOL]->ComputeTurboPerformance(config, geometry[FinestMesh]); + } + + /*--- Evaluate the buffet metric if requested ---*/ + /* + if(config->GetnMarker_Monitoring() || config->GetKind_ObjFunc() == BUFFET_SENSOR){ + solver_container[FinestMesh][FLOW_SOL]->Buffet_Monitoring(geometry[FinestMesh], config); + } + */ break; case RUNTIME_ADJFLOW_SYS: diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 8a0dd350e88..5cf859b33b1 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -213,10 +213,37 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe UsedTime = StopTime - StartTime; + unsigned long Iter= config[val_iZone]->GetInnerIter(); + output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), config[val_iZone]->GetInnerIter()); + /*--- Turbomachinery Specific Montior ---*/ + if (config[ZONE_0]->GetBoolTurbomachinery()){ + + /*--- Turbomachinery Performance Computation ---*/ + if (val_iZone == config[ZONE_0]->GetnZone()-1){ + ComputeTurboPerformance(solver, geometry, config, config[val_iZone]->GetInnerIter()); + output->LoadTurboHistoryData(TurbomachineryStagePerformance, TurbomachineryPerformance, config[val_iZone], val_iZone); + } + + if (config[ZONE_0]->GetMultizone_Problem()) + Iter = config[ZONE_0]->GetOuterIter(); + + /*--- Turbomachinery Performance Screen summary output---*/ + if (val_iZone == config[ZONE_0]->GetnZone()-1 && Iter%100 == 0) { + output->SetTurboPerformance_Output(TurbomachineryPerformance, config[val_iZone], + config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), + config[val_iZone]->GetInnerIter(), val_iZone); + if (rank == MASTER_NODE) + output->SetTurboMultiZonePerformance_Output(TurbomachineryStagePerformance, TurbomachineryPerformance, config[val_iZone]); + } + + /*--- Turbomachinery Rotation and Pressure Ramps ---*/ + TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter()); + } + /*--- If convergence was reached --*/ StopCalc = output->GetConvergence(); @@ -230,6 +257,112 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe return StopCalc; } +void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) { + + su2double rot_z_ini, rot_z_final ,rot_z; + su2double outPres_ini, outPres_final, outPres; + unsigned long rampFreq, finalRamp_Iter; + unsigned short iMarker, KindBC, KindBCOption; + unsigned short iZone; + string Marker_Tag; + + bool print; + if (config_container[ZONE_0]->GetMultizone_Problem()) + ExtIter = config_container[ZONE_0]->GetOuterIter(); + + for(iZone = 0; iZone < nZone; iZone++) { + /*--- ROTATING FRAME Ramp: Compute the updated rotational velocity. ---*/ + if (config_container[iZone]->GetGrid_Movement() && config_container[iZone]->GetRampRotatingFrame()) { + rampFreq = SU2_TYPE::Int(config_container[iZone]->GetRampRotatingFrame_Coeff(1)); + finalRamp_Iter = SU2_TYPE::Int(config_container[iZone]->GetRampRotatingFrame_Coeff(2)); + rot_z_ini = config_container[iZone]->GetRampRotatingFrame_Coeff(0); + print = false; + if(ExtIter % rampFreq == 0 && ExtIter <= finalRamp_Iter){ + rot_z_final = config_container[iZone]->GetFinalRotation_Rate_Z(); + if(abs(rot_z_final) > 0.0){ + rot_z = rot_z_ini + ExtIter*( rot_z_final - rot_z_ini)/finalRamp_Iter; + config_container[iZone]->SetRotation_Rate(2, rot_z); + if(rank == MASTER_NODE && print && ExtIter > 0) { + cout << endl << " Updated rotating frame grid velocities"; + cout << " for zone " << iZone << "." << endl; + } + geometry_container[iZone][INST_0][MESH_0]->SetRotationalVelocity(config_container[iZone], print); + geometry_container[iZone][INST_0][MESH_0]->SetShroudVelocity(config_container[iZone]); + } + + for (iZone = 0; iZone < nZone; iZone++) { + geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config_container[iZone], iZone, INFLOW, false); + geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config_container[iZone],iZone, OUTFLOW, false); + geometry_container[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config_container[iZone], false); + + } + } + } + } + + + /*--- Outlet Pressure Ramp: Compute the updated rotational velocity. ---*/ + if (config_container[ZONE_0]->GetRampOutletPressure()) { + rampFreq = SU2_TYPE::Int(config_container[ZONE_0]->GetRampOutletPressure_Coeff(1)); + finalRamp_Iter = SU2_TYPE::Int(config_container[ZONE_0]->GetRampOutletPressure_Coeff(2)); + outPres_ini = config_container[ZONE_0]->GetRampOutletPressure_Coeff(0); + outPres_final = config_container[ZONE_0]->GetFinalOutletPressure(); + + if(ExtIter % rampFreq == 0 && ExtIter <= finalRamp_Iter){ + outPres = outPres_ini + ExtIter*(outPres_final - outPres_ini)/finalRamp_Iter; + if(rank == MASTER_NODE) config_container[ZONE_0]->SetMonitotOutletPressure(outPres); + + for (iZone = 0; iZone < nZone; iZone++) { + for (iMarker = 0; iMarker < config_container[iZone]->GetnMarker_All(); iMarker++) { + KindBC = config_container[iZone]->GetMarker_All_KindBC(iMarker); + switch (KindBC) { + case RIEMANN_BOUNDARY: + Marker_Tag = config_container[iZone]->GetMarker_All_TagBound(iMarker); + KindBCOption = config_container[iZone]->GetKind_Data_Riemann(Marker_Tag); + if(KindBCOption == STATIC_PRESSURE || KindBCOption == RADIAL_EQUILIBRIUM ){ + SU2_MPI::Error("Outlet pressure ramp only implemented for NRBC", CURRENT_FUNCTION); + } + break; + case GILES_BOUNDARY: + Marker_Tag = config_container[iZone]->GetMarker_All_TagBound(iMarker); + KindBCOption = config_container[iZone]->GetKind_Data_Giles(Marker_Tag); + if(KindBCOption == STATIC_PRESSURE || KindBCOption == STATIC_PRESSURE_1D || KindBCOption == RADIAL_EQUILIBRIUM ){ + config_container[iZone]->SetGiles_Var1(outPres, Marker_Tag); + } + break; + } + } + } + } + } +} + +void CFluidIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) { + unsigned short nDim = geometry_container[ZONE_0][INST_0][MESH_0]->GetnDim(); + unsigned short nBladesRow = config_container[ZONE_0]->GetnMarker_Turbomachinery(); + unsigned short iBlade=0, iSpan; + vector TurboPrimitiveIn, TurboPrimitiveOut; + std::vector> bladesPrimitives; + + if (rank == MASTER_NODE) { + for (iBlade = 0; iBlade < nBladesRow; iBlade++){ + /* Blade Primitive initialized per blade */ + std::vector bladePrimitives; + auto nSpan = config_container[iBlade]->GetnSpanWiseSections(); + for (iSpan = 0; iSpan < nSpan + 1; iSpan++) { + TurboPrimitiveIn= solver[iBlade][INST_0][MESH_0][FLOW_SOL]->GetTurboPrimitive(iBlade, iSpan, true); + TurboPrimitiveOut= solver[iBlade][INST_0][MESH_0][FLOW_SOL]->GetTurboPrimitive(iBlade, iSpan, false); + auto spanInletPrimitive = CTurbomachineryPrimitiveState(TurboPrimitiveIn, nDim, geometry_container[iBlade][INST_0][MESH_0]->GetTangGridVelIn(iBlade, iSpan)); + auto spanOutletPrimitive = CTurbomachineryPrimitiveState(TurboPrimitiveOut, nDim, geometry_container[iBlade][INST_0][MESH_0]->GetTangGridVelOut(iBlade, iSpan)); + auto spanCombinedPrimitive = CTurbomachineryCombinedPrimitiveStates(spanInletPrimitive, spanOutletPrimitive); + bladePrimitives.push_back(spanCombinedPrimitive); + } + bladesPrimitives.push_back(bladePrimitives); + } + TurbomachineryPerformance->ComputeTurbomachineryPerformance(bladesPrimitives); + } +} + void CFluidIteration::Postprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, diff --git a/SU2_CFD/src/iteration/CTurboIteration.cpp b/SU2_CFD/src/iteration/CTurboIteration.cpp index 464ae8186ea..bd73894db42 100644 --- a/SU2_CFD/src/iteration/CTurboIteration.cpp +++ b/SU2_CFD/src/iteration/CTurboIteration.cpp @@ -27,6 +27,7 @@ #include "../../include/iteration/CTurboIteration.hpp" #include "../../include/output/COutput.hpp" +#include "../../include/output/CTurboOutput.hpp" void CTurboIteration::Preprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, @@ -37,6 +38,10 @@ void CTurboIteration::Preprocess(COutput* output, CIntegration**** integration, solver[val_iZone][val_iInst][MESH_0], geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], INFLOW); solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->TurboAverageProcess( solver[val_iZone][val_iInst][MESH_0], geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], OUTFLOW); + + if (config[val_iZone]->GetBoolTurbomachinery()) { + InitTurboPerformance(geometry[val_iZone][INST_0][MESH_0], config[val_iZone], solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetFluidModel()); + } } void CTurboIteration::Postprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, @@ -53,3 +58,8 @@ void CTurboIteration::Postprocess(COutput* output, CIntegration**** integration, solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GatherInOutAverageValues(config[val_iZone], geometry[val_iZone][val_iInst][MESH_0]); } + +void CTurboIteration::InitTurboPerformance(CGeometry *geometry, CConfig *config, CFluidModel *fluid){ + TurbomachineryPerformance = std::make_shared(*config, *geometry, *fluid); + TurbomachineryStagePerformance = new CTurbomachineryStagePerformance(*fluid); +} diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 9ca0188ffc0..71d20e42842 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -30,6 +30,7 @@ su2_cfd_src += files(['output/COutputFactory.cpp', 'output/CHeatOutput.cpp', 'output/CMeshOutput.cpp', 'output/CNEMOCompOutput.cpp', + 'output/CTurboOutput.cpp' , 'output/COutput.cpp', 'output/filewriter/CParallelDataSorter.cpp', 'output/filewriter/CFVMDataSorter.cpp', diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index af424a39f7e..0f32bbb2a41 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -97,10 +97,6 @@ CFlowCompOutput::CFlowCompOutput(const CConfig *config, unsigned short nDim) : C } } - if (config->GetBoolTurbomachinery()) { - /*--- Initialise turboperformance variables ---*/ - InitTurboPerformance(config); - } } void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ @@ -214,41 +210,38 @@ void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ /// BEGIN_GROUP: TURBO_PERF, DESCRIPTION: Turboperformance variables if (config->GetBoolTurbomachinery()) { - unsigned short iMarker_Monitoring; - for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_TurboPerformance(); iMarker_Monitoring++) { + //Adds zone turboperformance history variables + for (unsigned short iZone = 0; iZone <= config->GetnZone() - 1; iZone++) { stringstream tag; - tag << iMarker_Monitoring + 1; - /// DESCRIPTION: Total pressure loss - AddHistoryOutput("TotalPressureLoss_" + tag.str(), "TotPressureLoss_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total pressure loss " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Kinetic energy loss - AddHistoryOutput("KineticEnergyLoss_" + tag.str(), "KineticEnergyLoss_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Kinetic energy loss " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Entropy generation - AddHistoryOutput("EntropyGeneration_" + tag.str(), "EntropyGen_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Entropy generation " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Eulerian work - AddHistoryOutput("EulerianWork_" + tag.str(), "EulerianWork_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Eulerian work " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Pressure ratio - AddHistoryOutput("PressureRatio_" + tag.str(), "PressureRatio_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: FLow angle in - AddHistoryOutput("FlowAngleIn_" + tag.str(), "FlowAngleIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Flow angle out - AddHistoryOutput("FlowAngleOut_" + tag.str(), "FlowAngleOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle out " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Absolute flow angle in - AddHistoryOutput("AbsFlowAngleIn_" + tag.str(), "AbsFlowAngleIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Absolute flow angle out - AddHistoryOutput("AbsFlowAngleOut_" + tag.str(), "AbsFlowAngleOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Mass flow in - AddHistoryOutput("MassFlowIn_" + tag.str(), "MassFlowIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow in " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Mass flow out - AddHistoryOutput("MassFlowOut_" + tag.str(), "MassFlowOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow out " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Mach in - AddHistoryOutput("MachIn_" + tag.str(), "MachIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach in " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Mach out - AddHistoryOutput("MachOut_" + tag.str(), "MachOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach out " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Total efficiency - AddHistoryOutput("TotalEfficiency_" + tag.str(), "TotalEfficiency_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total efficiency " + tag.str(), HistoryFieldType::DEFAULT); - /// DESCRIPTION: Total-to-static efficiency - AddHistoryOutput("TotalStaticEfficiency_" + tag.str(), "TotalStaticEfficiency_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); + tag << iZone + 1; + AddHistoryOutput("EntropyIn_" + tag.str(), "EntropyIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total pressure loss " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("EntropyOut_" + tag.str(), "EntropyOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Kinetic energy loss " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalEntahalpyIn_" + tag.str(), "TotalEntahalpyIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Entropy generation " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalEnthalpyOut_" + tag.str(), "TotalEnthalpyOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Eulerian work " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalPressureIn_" + tag.str(), "TotPressureIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalPressureOut_" + tag.str(), "TotPressureOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureIn_" + tag.str(), "PressureIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureOut_" + tag.str(), "PressureOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("DensityIn_" + tag.str(), "DensityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("DensityOut_" + tag.str(), "DensityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("NormalVelocityIn_" + tag.str(), "NormalVelocityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("NormalVelocityOut_" + tag.str(), "NormalVelocityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TangentialVelocityIn_" + tag.str(), "TangentialVelocityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TangentialVelocityOut_" + tag.str(), "TangentialVelocityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("MassFlowIn_" + tag.str(), "MassFlowIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("MassFlowOut_" + tag.str(), "MassFlowOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total efficiency " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("MachIn_" + tag.str(), "MachIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("MachOut_" + tag.str(), "MachOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("FlowAngleIn_" + tag.str(), "FlowAngleIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("FlowAngleOut_" + tag.str(), "FlowAngleOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); } + //Adds turbomachinery machine performance variables + AddHistoryOutput("EntropyGeneration", "EntropyGen", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("EulerianWork", "EulerianWork", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalStaticEfficiency", "TotStaticEff", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalTotalEfficiency", "TotTotEff", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureRatioTS", "PRTS", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureRatioTT", "PRTT", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); } } @@ -485,29 +478,6 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol if (config->GetEquivArea()) SetNearfieldInverseDesign(flow_solver, geometry, config); - if (config->GetBoolTurbomachinery()){ - - unsigned short iMarker_Monitoring; - for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_TurboPerformance(); iMarker_Monitoring++) { - stringstream tag; - tag << iMarker_Monitoring + 1; - SetHistoryOutputValue("TotalPressureLoss_" + tag.str(), TotalPressureLoss[iMarker_Monitoring][nSpanWiseSections]); - SetHistoryOutputValue("KineticEnergyLoss_" + tag.str(), KineticEnergyLoss[iMarker_Monitoring][nSpanWiseSections]); - SetHistoryOutputValue("EntropyGeneration_" + tag.str(), EntropyGen[iMarker_Monitoring][nSpanWiseSections]); - SetHistoryOutputValue("EulerianWork_" + tag.str(), EulerianWork[iMarker_Monitoring][nSpanWiseSections]); - SetHistoryOutputValue("PressureRatio_" + tag.str(), PressureRatio[iMarker_Monitoring][nSpanWiseSections]); - SetHistoryOutputValue("FlowAngleIn_" + tag.str(), 180/PI_NUMBER*FlowAngleIn[iMarker_Monitoring][nSpanWiseSections]); - SetHistoryOutputValue("FlowAngleOut_" + tag.str(), 180/PI_NUMBER*FlowAngleOut[iMarker_Monitoring][nSpanWiseSections]); - SetHistoryOutputValue("AbsFlowAngleIn_" + tag.str(), 180/PI_NUMBER*AbsFlowAngleIn[iMarker_Monitoring][nSpanWiseSections]); - SetHistoryOutputValue("AbsFlowAngleOut_" + tag.str(), 180/PI_NUMBER*AbsFlowAngleOut[iMarker_Monitoring][nSpanWiseSections]); - SetHistoryOutputValue("MassFlowIn_" + tag.str(), MassFlowIn[iMarker_Monitoring][nSpanWiseSections]); - SetHistoryOutputValue("MassFlowOut_" + tag.str(), MassFlowOut[iMarker_Monitoring][nSpanWiseSections]); - SetHistoryOutputValue("MachIn_" + tag.str(), sqrt(MachIn[iMarker_Monitoring][nSpanWiseSections][1]*MachIn[iMarker_Monitoring][nSpanWiseSections][1] + MachIn[iMarker_Monitoring][nSpanWiseSections][0]*MachIn[iMarker_Monitoring][nSpanWiseSections][0])); - SetHistoryOutputValue("MachOut_" + tag.str(), sqrt(MachOut[iMarker_Monitoring][nSpanWiseSections][1]*MachOut[iMarker_Monitoring][nSpanWiseSections][1] + MachOut[iMarker_Monitoring][nSpanWiseSections][0]*MachOut[iMarker_Monitoring][nSpanWiseSections][0])); - SetHistoryOutputValue("TotalEfficiency_" + tag.str(), TotalTotalEfficiency[iMarker_Monitoring][nSpanWiseSections]); - SetHistoryOutputValue("TotalStaticEfficiency_" + tag.str(), TotalStaticEfficiency[iMarker_Monitoring][nSpanWiseSections]); - } - } /*--- Keep this as last, since it uses the history values that were set. ---*/ diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index b95b4ad6018..cae8762b9da 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -29,6 +29,7 @@ #include "../../include/solvers/CSolver.hpp" #include "../../include/output/COutput.hpp" +#include "../../include/output/CTurboOutput.hpp" #include "../../include/output/filewriter/CFVMDataSorter.hpp" #include "../../include/output/filewriter/CFEMDataSorter.hpp" #include "../../include/output/filewriter/CCGNSFileWriter.hpp" @@ -169,7 +170,7 @@ COutput::COutput(const CConfig *config, unsigned short ndim, bool fem_output): surfaceDataSorter = nullptr; headerNeeded = false; - + } COutput::~COutput(void) { @@ -2477,436 +2478,135 @@ void COutput::PrintVolumeFields(){ } } -void COutput::InitTurboPerformance(const CConfig *config){ - unsigned short iDim, iSpan, iMarker; - - /*--- Initializate quantities for turboperformace ---*/ - nSpanWiseSections = config->GetnSpanMaxAllZones(); - nMarkerTurboPerf = config->GetnMarker_TurboPerformance(); - - - TotalStaticEfficiency = new su2double*[nMarkerTurboPerf]; - TotalTotalEfficiency = new su2double*[nMarkerTurboPerf]; - KineticEnergyLoss = new su2double*[nMarkerTurboPerf]; - TRadius = new su2double*[nMarkerTurboPerf]; - TotalPressureLoss = new su2double*[nMarkerTurboPerf]; - MassFlowIn = new su2double*[nMarkerTurboPerf]; - MassFlowOut = new su2double*[nMarkerTurboPerf]; - FlowAngleIn = new su2double*[nMarkerTurboPerf]; - FlowAngleIn_BC = new su2double*[nMarkerTurboPerf]; - FlowAngleOut = new su2double*[nMarkerTurboPerf]; - EulerianWork = new su2double*[nMarkerTurboPerf]; - TotalEnthalpyIn = new su2double*[nMarkerTurboPerf]; - TotalEnthalpyIn_BC = new su2double*[nMarkerTurboPerf]; - EntropyIn = new su2double*[nMarkerTurboPerf]; - EntropyOut = new su2double*[nMarkerTurboPerf]; - EntropyIn_BC = new su2double*[nMarkerTurboPerf]; - PressureRatio = new su2double*[nMarkerTurboPerf]; - TotalTemperatureIn = new su2double*[nMarkerTurboPerf]; - EnthalpyOut = new su2double*[nMarkerTurboPerf]; - MachIn = new su2double**[nMarkerTurboPerf]; - MachOut = new su2double**[nMarkerTurboPerf]; - VelocityOutIs = new su2double*[nMarkerTurboPerf]; - DensityIn = new su2double*[nMarkerTurboPerf]; - PressureIn = new su2double*[nMarkerTurboPerf]; - TurboVelocityIn = new su2double**[nMarkerTurboPerf]; - DensityOut = new su2double*[nMarkerTurboPerf]; - PressureOut = new su2double*[nMarkerTurboPerf]; - TurboVelocityOut = new su2double**[nMarkerTurboPerf]; - EnthalpyOutIs = new su2double*[nMarkerTurboPerf]; - EntropyGen = new su2double*[nMarkerTurboPerf]; - AbsFlowAngleIn = new su2double*[nMarkerTurboPerf]; - TotalEnthalpyOut = new su2double*[nMarkerTurboPerf]; - TotalEnthalpyOutIs = new su2double*[nMarkerTurboPerf]; - RothalpyIn = new su2double*[nMarkerTurboPerf]; - RothalpyOut = new su2double*[nMarkerTurboPerf]; - AbsFlowAngleOut = new su2double*[nMarkerTurboPerf]; - PressureOut_BC = new su2double*[nMarkerTurboPerf]; - TemperatureIn = new su2double*[nMarkerTurboPerf]; - TemperatureOut = new su2double*[nMarkerTurboPerf]; - TotalPressureIn = new su2double*[nMarkerTurboPerf]; - TotalPressureOut = new su2double*[nMarkerTurboPerf]; - TotalTemperatureOut = new su2double*[nMarkerTurboPerf]; - EnthalpyIn = new su2double*[nMarkerTurboPerf]; - TurbIntensityIn = new su2double*[nMarkerTurboPerf]; - Turb2LamViscRatioIn = new su2double*[nMarkerTurboPerf]; - TurbIntensityOut = new su2double*[nMarkerTurboPerf]; - Turb2LamViscRatioOut = new su2double*[nMarkerTurboPerf]; - NuFactorIn = new su2double*[nMarkerTurboPerf]; - NuFactorOut = new su2double*[nMarkerTurboPerf]; - - for (iMarker = 0; iMarker < nMarkerTurboPerf; iMarker++){ - TotalStaticEfficiency [iMarker] = new su2double [nSpanWiseSections + 1]; - TotalTotalEfficiency [iMarker] = new su2double [nSpanWiseSections + 1]; - KineticEnergyLoss [iMarker] = new su2double [nSpanWiseSections + 1]; - TRadius [iMarker] = new su2double [nSpanWiseSections + 1]; - TotalPressureLoss [iMarker] = new su2double [nSpanWiseSections + 1]; - MassFlowIn [iMarker] = new su2double [nSpanWiseSections + 1]; - MassFlowOut [iMarker] = new su2double [nSpanWiseSections + 1]; - FlowAngleIn [iMarker] = new su2double [nSpanWiseSections + 1]; - FlowAngleIn_BC [iMarker] = new su2double [nSpanWiseSections + 1]; - FlowAngleOut [iMarker] = new su2double [nSpanWiseSections + 1]; - EulerianWork [iMarker] = new su2double [nSpanWiseSections + 1]; - TotalEnthalpyIn [iMarker] = new su2double [nSpanWiseSections + 1]; - TotalEnthalpyIn_BC [iMarker] = new su2double [nSpanWiseSections + 1]; - EntropyIn [iMarker] = new su2double [nSpanWiseSections + 1]; - EntropyOut [iMarker] = new su2double [nSpanWiseSections + 1]; - EntropyIn_BC [iMarker] = new su2double [nSpanWiseSections + 1]; - PressureRatio [iMarker] = new su2double [nSpanWiseSections + 1]; - TotalTemperatureIn [iMarker] = new su2double [nSpanWiseSections + 1]; - EnthalpyOut [iMarker] = new su2double [nSpanWiseSections + 1]; - MachIn [iMarker] = new su2double*[nSpanWiseSections + 1]; - MachOut [iMarker] = new su2double*[nSpanWiseSections + 1]; - VelocityOutIs [iMarker] = new su2double [nSpanWiseSections + 1]; - DensityIn [iMarker] = new su2double [nSpanWiseSections + 1]; - PressureIn [iMarker] = new su2double [nSpanWiseSections + 1]; - TurboVelocityIn [iMarker] = new su2double*[nSpanWiseSections + 1]; - DensityOut [iMarker] = new su2double [nSpanWiseSections + 1]; - PressureOut [iMarker] = new su2double [nSpanWiseSections + 1]; - TurboVelocityOut [iMarker] = new su2double*[nSpanWiseSections + 1]; - EnthalpyOutIs [iMarker] = new su2double [nSpanWiseSections + 1]; - EntropyGen [iMarker] = new su2double [nSpanWiseSections + 1]; - AbsFlowAngleIn [iMarker] = new su2double [nSpanWiseSections + 1]; - TotalEnthalpyOut [iMarker] = new su2double [nSpanWiseSections + 1]; - TotalEnthalpyOutIs [iMarker] = new su2double [nSpanWiseSections + 1]; - RothalpyIn [iMarker] = new su2double [nSpanWiseSections + 1]; - RothalpyOut [iMarker] = new su2double [nSpanWiseSections + 1]; - AbsFlowAngleOut [iMarker] = new su2double [nSpanWiseSections + 1]; - PressureOut_BC [iMarker] = new su2double [nSpanWiseSections + 1]; - TemperatureIn [iMarker] = new su2double [nSpanWiseSections + 1]; - TemperatureOut [iMarker] = new su2double [nSpanWiseSections + 1]; - TotalPressureIn [iMarker] = new su2double [nSpanWiseSections + 1]; - TotalPressureOut [iMarker] = new su2double [nSpanWiseSections + 1]; - TotalTemperatureOut [iMarker] = new su2double [nSpanWiseSections + 1]; - EnthalpyIn [iMarker] = new su2double [nSpanWiseSections + 1]; - TurbIntensityIn [iMarker] = new su2double [nSpanWiseSections + 1]; - Turb2LamViscRatioIn [iMarker] = new su2double [nSpanWiseSections + 1]; - TurbIntensityOut [iMarker] = new su2double [nSpanWiseSections + 1]; - Turb2LamViscRatioOut [iMarker] = new su2double [nSpanWiseSections + 1]; - NuFactorIn [iMarker] = new su2double [nSpanWiseSections + 1]; - NuFactorOut [iMarker] = new su2double [nSpanWiseSections + 1]; - - - for (iSpan = 0; iSpan < nSpanWiseSections + 1; iSpan++){ - TotalStaticEfficiency [iMarker][iSpan] = 0.0; - TotalTotalEfficiency [iMarker][iSpan] = 0.0; - KineticEnergyLoss [iMarker][iSpan] = 0.0; - TRadius [iMarker][iSpan] = 0.0; - TotalPressureLoss [iMarker][iSpan] = 0.0; - MassFlowIn [iMarker][iSpan] = 0.0; - MassFlowOut [iMarker][iSpan] = 0.0; - FlowAngleIn [iMarker][iSpan] = 0.0; - FlowAngleIn_BC [iMarker][iSpan] = config->GetFlowAngleIn_BC(); - FlowAngleOut [iMarker][iSpan] = 0.0; - EulerianWork [iMarker][iSpan] = 0.0; - TotalEnthalpyIn [iMarker][iSpan] = 0.0; - TotalEnthalpyIn_BC [iMarker][iSpan] = 0.0; - EntropyIn [iMarker][iSpan] = 0.0; - EntropyOut [iMarker][iSpan] = 0.0; - EntropyIn_BC [iMarker][iSpan] = 0.0; - PressureRatio [iMarker][iSpan] = 0.0; - TotalTemperatureIn [iMarker][iSpan] = 0.0; - EnthalpyOut [iMarker][iSpan] = 0.0; - - - VelocityOutIs [iMarker][iSpan] = 0.0; - DensityIn [iMarker][iSpan] = 0.0; - PressureIn [iMarker][iSpan] = 0.0; - - DensityOut [iMarker][iSpan] = 0.0; - PressureOut [iMarker][iSpan] = 0.0; - - EnthalpyOutIs [iMarker][iSpan] = 0.0; - EntropyGen [iMarker][iSpan] = 0.0; - AbsFlowAngleIn [iMarker][iSpan] = 0.0; - TotalEnthalpyOut [iMarker][iSpan] = 0.0; - TotalEnthalpyOutIs [iMarker][iSpan] = 0.0; - RothalpyIn [iMarker][iSpan] = 0.0; - RothalpyOut [iMarker][iSpan] = 0.0; - AbsFlowAngleOut [iMarker][iSpan] = 0.0; - PressureOut_BC [iMarker][iSpan] = config->GetPressureOut_BC(); - - TemperatureIn [iMarker][iSpan] = 0.0; - TemperatureOut [iMarker][iSpan] = 0.0; - TotalPressureIn [iMarker][iSpan] = 0.0; - TotalPressureOut [iMarker][iSpan] = 0.0; - TotalTemperatureOut [iMarker][iSpan] = 0.0; - EnthalpyIn [iMarker][iSpan] = 0.0; - TurbIntensityIn [iMarker][iSpan] = 0.0; - Turb2LamViscRatioIn [iMarker][iSpan] = 0.0; - TurbIntensityOut [iMarker][iSpan] = 0.0; - Turb2LamViscRatioOut [iMarker][iSpan] = 0.0; - NuFactorIn [iMarker][iSpan] = 0.0; - NuFactorOut [iMarker][iSpan] = 0.0; - MachIn [iMarker][iSpan] = new su2double[4]; - MachOut [iMarker][iSpan] = new su2double[4]; - TurboVelocityIn [iMarker][iSpan] = new su2double[4]; - TurboVelocityOut [iMarker][iSpan] = new su2double[4]; - - for (iDim = 0; iDim < 4; iDim++){ - MachIn [iMarker][iSpan][iDim] = 0.0; - MachOut [iMarker][iSpan][iDim] = 0.0; - TurboVelocityIn [iMarker][iSpan][iDim] = 0.0; - TurboVelocityOut [iMarker][iSpan][iDim] = 0.0; - } - } - } -} - -void COutput::ComputeTurboPerformance(CConfig *config, CGeometry *geometry, CSolver *solver){ - CFluidModel *FluidModel; - unsigned short nDim = geometry->GetnDim(); - unsigned short iMarkerTP, iSpan, iDim, iStage, iBlade; - unsigned short nMarkerTP = config->GetnMarker_Turbomachinery(); - FluidModel = solver->GetFluidModel(); - su2double area, absVel2, soundSpeed, mach, tangVel, tangVel2, *relVel, relVel2; - su2double relPressureIn, relPressureOut, enthalpyOutIs, relVelOutIs2; - relVel = new su2double[nDim]; - su2double muLam, kine, omega, nu; - bool turbulent = ((config->GetKind_Solver() == MAIN_SOLVER::RANS) || (config->GetKind_Solver() == MAIN_SOLVER::DISC_ADJ_RANS)); - bool menter_sst = (config->GetKind_Turb_Model() == TURB_MODEL::SST); - - unsigned short nBladesRow, nStages; - - nBladesRow = config->GetnMarker_Turbomachinery(); - nStages = SU2_TYPE::Int(nBladesRow/2); - - - /*--- Compute BC imposed value for convergence monitoring ---*/ - for(iMarkerTP = 0; iMarkerTP < nMarkerTP; iMarkerTP++ ){ - for(iSpan = 0; iSpan < config->GetnSpan_iZones(iMarkerTP) + 1; iSpan++){ - if(config->GetRampOutletPressure() && config->GetInnerIter() > 0){ - PressureOut_BC[iMarkerTP][iSpan] = config->GetMonitorOutletPressure()/config->GetPressure_Ref(); - } - FluidModel->SetTDState_PT(config->GetTotalPressureIn_BC(), config->GetTotalTemperatureIn_BC()); - TotalEnthalpyIn_BC[iMarkerTP][iSpan] = FluidModel->GetStaticEnergy()+ FluidModel->GetPressure()/FluidModel->GetDensity(); - EntropyIn_BC[iMarkerTP][iSpan] = FluidModel->GetEntropy(); - } - } - - /*--- Compute performance for each blade ---*/ - for(iMarkerTP = 0; iMarkerTP < nMarkerTP; iMarkerTP++ ){ - for(iSpan = 0; iSpan < config->GetnSpan_iZones(iMarkerTP) + 1; iSpan++){ - - - /*--- INFLOW ---*/ - /*--- Retrieve Inflow primitive quantities ---*/ - DensityIn[iMarkerTP][iSpan] = solver->GetDensityIn(iMarkerTP, iSpan); - PressureIn[iMarkerTP][iSpan] = solver->GetPressureIn(iMarkerTP, iSpan); - - absVel2 = 0.0; - - for (iDim = 0; iDim < nDim; iDim++){ - TurboVelocityIn[iMarkerTP][iSpan][iDim] = solver->GetTurboVelocityIn(iMarkerTP, iSpan)[iDim]; - absVel2 += TurboVelocityIn[iMarkerTP][iSpan][iDim]*TurboVelocityIn[iMarkerTP][iSpan][iDim]; - } - TurboVelocityIn[iMarkerTP][iSpan][nDim] = sqrt(absVel2); - - TRadius[iMarkerTP][iSpan] = geometry->GetTurboRadiusIn(iMarkerTP, iSpan); - area = geometry->GetSpanAreaIn(iMarkerTP, iSpan); - - /*--- Compute static Inflow quantities ---*/ - FluidModel->SetTDState_Prho(PressureIn[iMarkerTP][iSpan], DensityIn[iMarkerTP][iSpan]); - EntropyIn[iMarkerTP][iSpan] = FluidModel->GetEntropy(); - MassFlowIn[iMarkerTP][iSpan] = config->GetnBlades(iMarkerTP)*DensityIn[iMarkerTP][iSpan]*TurboVelocityIn[iMarkerTP][iSpan][0]*area; - AbsFlowAngleIn[iMarkerTP][iSpan] = atan(TurboVelocityIn[iMarkerTP][iSpan][1]/TurboVelocityIn[iMarkerTP][iSpan][0]); - EnthalpyIn[iMarkerTP][iSpan] = FluidModel->GetStaticEnergy() + PressureIn[iMarkerTP][iSpan]/DensityIn[iMarkerTP][iSpan]; - soundSpeed = FluidModel->GetSoundSpeed(); - - - /*--- Compute Total Inflow quantities ---*/ - TotalEnthalpyIn[iMarkerTP][iSpan] = EnthalpyIn[iMarkerTP][iSpan] + 0.5*absVel2; - FluidModel->SetTDState_hs(TotalEnthalpyIn[iMarkerTP][iSpan], EntropyIn[iMarkerTP][iSpan]); - TotalPressureIn[iMarkerTP][iSpan] = FluidModel->GetPressure(); - TotalTemperatureIn[iMarkerTP][iSpan] = FluidModel->GetTemperature(); - - /*--- Retrieve Inflow relative quantities ---*/ - tangVel = geometry->GetTangGridVelIn(iMarkerTP, iSpan); - tangVel2 = tangVel*tangVel; - - for (iDim = 0; iDim < nDim; iDim++){ - relVel[iDim] = TurboVelocityIn[iMarkerTP][iSpan][iDim]; - } - relVel[1] -= tangVel; - - relVel2 = 0.0; - for (iDim = 0; iDim < nDim; iDim++){ - relVel2 += relVel[iDim]*relVel[iDim]; - } - - /*--- Compute Total relative Inflow quantities ---*/ - RothalpyIn[iMarkerTP][iSpan] = EnthalpyIn[iMarkerTP][iSpan] + 0.5*relVel2 - 0.5*tangVel2; - FluidModel->SetTDState_hs(RothalpyIn[iMarkerTP][iSpan], EntropyIn[iMarkerTP][iSpan]); - relPressureIn = FluidModel->GetPressure(); - - /*--- Compute kinematic relative Inflow quantities ---*/ - FlowAngleIn[iMarkerTP][iSpan] = atan(relVel[1]/relVel[0]); - mach = 0.0; - for (iDim = 0; iDim < nDim; iDim++){ - MachIn[iMarkerTP][iSpan][iDim] = relVel[iDim]/soundSpeed; - mach = MachIn[iMarkerTP][iSpan][iDim]*MachIn[iMarkerTP][iSpan][iDim]; - } - MachIn[iMarkerTP][iSpan][nDim] = sqrt(mach); - - /*--- Compute Turbulent Inflow quantities ---*/ - if(turbulent){ - FluidModel->SetTDState_Prho(PressureIn[iMarkerTP][iSpan], DensityIn[iMarkerTP][iSpan]); - muLam = FluidModel->GetLaminarViscosity(); - if(menter_sst){ - kine = solver->GetKineIn(iMarkerTP, iSpan); - omega = solver->GetOmegaIn(iMarkerTP, iSpan); - TurbIntensityIn[iMarkerTP][iSpan] = sqrt(2.0/3.0*kine/absVel2); - Turb2LamViscRatioIn[iMarkerTP][iSpan] = DensityIn[iMarkerTP][iSpan]*kine/(muLam*omega); -// TurbIntensityIn[iMarkerTP][iSpan] = kine; -// Turb2LamViscRatioIn[iMarkerTP][iSpan] = omega; - } - else{ - nu = solver->GetNuIn(iMarkerTP, iSpan); - NuFactorIn[iMarkerTP][iSpan] = nu*DensityIn[iMarkerTP][iSpan]/muLam; - } - } - - /*--- OUTFLOW ---*/ - /*--- Retrieve Outflow primitive quantities ---*/ - DensityOut[iMarkerTP][iSpan] = solver->GetDensityOut(iMarkerTP, iSpan); - PressureOut[iMarkerTP][iSpan] = solver->GetPressureOut(iMarkerTP, iSpan); - absVel2 = 0.0; - - for (iDim = 0; iDim < nDim; iDim++){ - TurboVelocityOut[iMarkerTP][iSpan][iDim] = solver->GetTurboVelocityOut(iMarkerTP, iSpan)[iDim]; - absVel2 += TurboVelocityOut[iMarkerTP][iSpan][iDim]*TurboVelocityOut[iMarkerTP][iSpan][iDim]; - } - TurboVelocityOut[iMarkerTP][iSpan][nDim] = sqrt(absVel2); - - - for (iDim = 0; iDim < 3; iDim++){ - } - area = geometry->GetSpanAreaOut(iMarkerTP, iSpan); - - - /*--- Compute all the Outflow quantities ---*/ - FluidModel->SetTDState_Prho(PressureOut[iMarkerTP][iSpan], DensityOut[iMarkerTP][iSpan]); - EntropyOut[iMarkerTP][iSpan] = FluidModel->GetEntropy(); - MassFlowOut[iMarkerTP][iSpan] = config->GetnBlades(iMarkerTP)*DensityOut[iMarkerTP][iSpan]*TurboVelocityOut[iMarkerTP][iSpan][0]*area; - AbsFlowAngleOut[iMarkerTP][iSpan] = atan(TurboVelocityOut[iMarkerTP][iSpan][1]/TurboVelocityOut[iMarkerTP][iSpan][0]); - EnthalpyOut[iMarkerTP][iSpan] = FluidModel->GetStaticEnergy() + PressureOut[iMarkerTP][iSpan]/DensityOut[iMarkerTP][iSpan]; - soundSpeed = FluidModel->GetSoundSpeed(); - - /*--- Compute Total Outflow quantities ---*/ - TotalEnthalpyOut[iMarkerTP][iSpan] = EnthalpyOut[iMarkerTP][iSpan] + 0.5*absVel2; - FluidModel->SetTDState_hs(TotalEnthalpyOut[iMarkerTP][iSpan], EntropyOut[iMarkerTP][iSpan]); - TotalPressureOut[iMarkerTP][iSpan] = FluidModel->GetPressure(); - TotalTemperatureOut[iMarkerTP][iSpan] = FluidModel->GetTemperature(); - - /*--- Retrieve relative Outflow quantities ---*/ - tangVel = geometry->GetTangGridVelOut(iMarkerTP, iSpan); - tangVel2 = tangVel*tangVel; - - for (iDim = 0; iDim < nDim; iDim++){ - relVel[iDim] = TurboVelocityOut[iMarkerTP][iSpan][iDim]; - } - relVel[1] -= tangVel; - - relVel2 = 0.0; - for (iDim = 0; iDim < nDim; iDim++){ - relVel2 += relVel[iDim]*relVel[iDim]; - } - - /*--- Compute Total relative Outflow quantities ---*/ - RothalpyOut[iMarkerTP][iSpan] = EnthalpyOut[iMarkerTP][iSpan] + 0.5*relVel2 - 0.5*tangVel2; - FluidModel->SetTDState_hs(RothalpyOut[iMarkerTP][iSpan], EntropyOut[iMarkerTP][iSpan]); - relPressureOut = FluidModel->GetPressure(); - - /*--- Compute isentropic Outflow quantities ---*/ - FluidModel->SetTDState_Ps(PressureOut[iMarkerTP][iSpan], EntropyIn[iMarkerTP][iSpan]); - enthalpyOutIs = FluidModel->GetStaticEnergy() + PressureOut[iMarkerTP][iSpan]/FluidModel->GetDensity(); - relVelOutIs2 = 2*(RothalpyOut[iMarkerTP][iSpan] - enthalpyOutIs) + tangVel2; - - - /*--- Compute kinematic relative Outflow quantities ---*/ - FlowAngleOut[iMarkerTP][iSpan] = atan(relVel[1]/relVel[0]); - mach = 0.0; - for (iDim = 0; iDim < nDim; iDim++){ - MachOut[iMarkerTP][iSpan][iDim] = relVel[iDim]/soundSpeed; - mach = MachOut[iMarkerTP][iSpan][iDim]*MachOut[iMarkerTP][iSpan][iDim]; - } - MachOut[iMarkerTP][iSpan][nDim] = sqrt(mach); - - /*--- Compute Turbulent Outflow quantities ---*/ - if(turbulent){ - FluidModel->SetTDState_Prho(PressureOut[iMarkerTP][iSpan], DensityOut[iMarkerTP][iSpan]); - muLam = FluidModel->GetLaminarViscosity(); - if(menter_sst){ - kine = solver->GetKineOut(iMarkerTP, iSpan); - omega = solver->GetOmegaOut(iMarkerTP, iSpan); - TurbIntensityOut[iMarkerTP][iSpan] = sqrt(2.0/3.0*kine/absVel2); - Turb2LamViscRatioOut[iMarkerTP][iSpan] = DensityOut[iMarkerTP][iSpan]*kine/(muLam*omega); -// TurbIntensityOut[iMarkerTP][iSpan] = kine; -// Turb2LamViscRatioOut[iMarkerTP][iSpan] = omega; - } - else{ - nu = solver->GetNuOut(iMarkerTP, iSpan); - NuFactorOut[iMarkerTP][iSpan] = nu*DensityOut[iMarkerTP][iSpan]/muLam; - } - } +void COutput::SetTurboPerformance_Output(std::shared_ptr TurboPerf, + CConfig *config, + unsigned long TimeIter, + unsigned long OuterIter, + unsigned long InnerIter, + unsigned short val_iZone) { - /*--- TURBO-PERFORMANCE---*/ - EntropyGen[iMarkerTP][iSpan] = (EntropyOut[iMarkerTP][iSpan] - EntropyIn[iMarkerTP][iSpan])/abs(EntropyIn_BC[iMarkerTP][iSpan] + 1); - EulerianWork[iMarkerTP][iSpan] = TotalEnthalpyIn[iMarkerTP][iSpan] - TotalEnthalpyOut[iMarkerTP][iSpan]; - TotalPressureLoss[iMarkerTP][iSpan] = (relPressureIn - relPressureOut)/(relPressureIn - PressureOut[iMarkerTP][iSpan]); - KineticEnergyLoss[iMarkerTP][iSpan] = 2*(EnthalpyOut[iMarkerTP][iSpan] - enthalpyOutIs)/relVelOutIs2; - PressureRatio[iMarkerTP][iSpan] = TotalPressureOut[iMarkerTP][iSpan]/TotalPressureIn[iMarkerTP][iSpan]; - EnthalpyOutIs[iMarkerTP][iSpan] = (pow(TotalPressureOut[iMarkerTP][iSpan]/TotalPressureIn[iMarkerTP][iSpan], 0.4/1.4) - 1.0)/(TotalTemperatureOut[iMarkerTP][iSpan]/TotalTemperatureIn[iMarkerTP][iSpan] -1.0); - } + curTimeIter = TimeIter; + curAbsTimeIter = TimeIter - config->GetRestart_Iter(); + curOuterIter = OuterIter; + curInnerIter = InnerIter; + stringstream TurboInOutTable, TurboPerfTable; + + if(rank == MASTER_NODE) { + auto BladePerformance = TurboPerf->GetBladesPerformances(); + auto nSpan = config->GetnSpan_iZones(val_iZone); + + /*-- Table for Turbomachinery Performance Values --*/ + PrintingToolbox::CTablePrinter TurboInOut(&TurboInOutTable); + + TurboInOutTable<<"-- Turbomachinery inlet and outlet property Summary:"<GetnSpan_iZones(iZone); + + TurboInOut<<" BLADE ROW INDEX "<GetInletState().GetEntropy() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetEntropy(); + TurboInOut << "Total Enthalpy " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalEnthalpy() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalEnthalpy(); + TurboInOut << "Total Pressure " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalPressure() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalPressure(); + TurboInOut << "Pressure " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetPressure() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetPressure(); + TurboInOut << "Density " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetDensity() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetDensity(); + TurboInOut << "Normal Velocity " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[0] << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[0]; + TurboInOut << "Tangential Velocity " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[1] << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[1]; + TurboInOut << "Mass Flow " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMassFlow() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMassFlow(); + TurboInOut << "Mach " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMachValue() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMachValue(); + TurboInOut << "Flow Angle " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER; + TurboInOut.PrintFooter(); + } + cout< 1){ - /*--- Compute performance for each stage ---*/ - - EulerianWork[nBladesRow + nStages][nSpanWiseSections] = 0.0; - /*---Comnpute performance for each stage---*/ - for(iStage = 0; iStage < nStages; iStage++ ){ - FluidModel->SetTDState_Ps(PressureOut[iStage*2 +1][config->GetnSpan_iZones(iStage*2 +1)], EntropyIn[iStage*2][config->GetnSpan_iZones(iStage*2)]); - EnthalpyOutIs[nBladesRow + iStage][nSpanWiseSections] = FluidModel->GetStaticEnergy() + PressureOut[iStage*2 +1][config->GetnSpan_iZones(iStage*2 +1)]/FluidModel->GetDensity(); - FluidModel->SetTDState_Prho(PressureOut[iStage*2 +1][config->GetnSpan_iZones(iStage*2 +1)], DensityOut[iStage*2 +1][config->GetnSpan_iZones(iStage*2 +1)]); - absVel2 = 0.0; - for (iDim = 0; iDimGetnSpan_iZones(iStage*2 +1)][iDim]*TurboVelocityOut[iStage*2 +1][config->GetnSpan_iZones(iStage*2 +1)][iDim]; - TotalEnthalpyOutIs[nBladesRow + iStage][nSpanWiseSections] = EnthalpyOutIs[nBladesRow + iStage][nSpanWiseSections] + 0.5*absVel2; - - TotalTotalEfficiency[nBladesRow + iStage][nSpanWiseSections] = (TotalEnthalpyIn[iStage*2][config->GetnSpan_iZones(iStage*2)] - TotalEnthalpyOut[iStage*2 + 1][config->GetnSpan_iZones(iStage*2 +1)]); - TotalTotalEfficiency[nBladesRow + iStage][nSpanWiseSections] /= (TotalEnthalpyIn[iStage*2][config->GetnSpan_iZones(iStage*2)] - TotalEnthalpyOutIs[nBladesRow + iStage][nSpanWiseSections]); - TotalStaticEfficiency[nBladesRow + iStage][nSpanWiseSections] = (TotalEnthalpyIn[iStage*2][config->GetnSpan_iZones(iStage*2)] - TotalEnthalpyOut[iStage*2 + 1][config->GetnSpan_iZones(iStage*2+1)]); - TotalStaticEfficiency[nBladesRow + iStage][nSpanWiseSections] /= (TotalEnthalpyIn[iStage*2][config->GetnSpan_iZones(iStage*2)] - EnthalpyOutIs[nBladesRow + iStage][nSpanWiseSections]); - PressureRatio[nBladesRow + iStage][nSpanWiseSections] = (PressureRatio[iStage*2][config->GetnSpan_iZones(iStage*2)]*PressureOut[iStage*2][config->GetnSpan_iZones(iStage*2)]/PressureOut[iStage*2 + 1][config->GetnSpan_iZones(iStage*2+1)]); - MassFlowIn[nBladesRow + iStage][nSpanWiseSections] = MassFlowIn[iStage*2][config->GetnSpan_iZones(iStage*2)]; - MassFlowOut[nBladesRow + iStage][nSpanWiseSections] = MassFlowOut[iStage*2 + 1][config->GetnSpan_iZones(iStage*2+1)]; - EntropyGen[nBladesRow + iStage][nSpanWiseSections] = EntropyGen[iStage*2 + 1][config->GetnSpan_iZones(iStage*2 +1)] + EntropyGen[iStage*2][config->GetnSpan_iZones(iStage*2)]; - - } - - /*---Compute turbo performance for full machine---*/ - FluidModel->SetTDState_Ps(PressureOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)], EntropyIn[0][config->GetnSpan_iZones(0)]); - EnthalpyOutIs[nBladesRow + nStages][nSpanWiseSections] = FluidModel->GetStaticEnergy() + PressureOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)]/FluidModel->GetDensity(); - FluidModel->SetTDState_Prho(PressureOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)], DensityOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)]); - absVel2 = 0.0; - for (iDim = 0; iDimGetnSpan_iZones(nBladesRow-1)][iDim]*TurboVelocityOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)][iDim]; - TotalEnthalpyOutIs[nBladesRow + nStages][nSpanWiseSections] = EnthalpyOutIs[nBladesRow + nStages][nSpanWiseSections] + 0.5*absVel2; +void COutput::SetTurboMultiZonePerformance_Output(CTurbomachineryStagePerformance* TurboStagePerf, + std::shared_ptr TurboPerf, + CConfig *config) { + + auto nZone = config->GetnZone(); + unsigned short iStage, iZone; + auto nSpan = config->GetnSpanWiseSections(); + stringstream TurboMZPerf; + + PrintingToolbox::CTablePrinter TurboInOut(&TurboMZPerf); + + /*--- Print header for the stage performance computation ---*/ + TurboMZPerf<<"-- Turbomachinery Stage Performance --"<GetBladesPerformances().at(ZONE_0).at(nSpan)->GetInletState(); + auto OutState = TurboPerf->GetBladesPerformances().at(nZone-1).at(nSpan)->GetOutletState(); + + TurboStagePerf->ComputePerformanceStage(InState, OutState, config); + + /*--- Print Machine Performance (In future also add if the performance is TURBINE or COMPRESSOR) ---*/ + TurboInOut<<"MACHINE"<GetNormEntropyGen()*100 + <GetEulerianWork() + <GetTotalStaticEfficiency()*100 + <GetTotalTotalEfficiency()*100 + <GetTotalStaticPressureRatio() + <GetTotalTotalPressureRatio(); + TurboInOut.PrintFooter(); + cout<GetnSpan_iZones(0)] - TotalEnthalpyOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)]); - TotalTotalEfficiency[nBladesRow + nStages][nSpanWiseSections] /= (TotalEnthalpyIn[0][config->GetnSpan_iZones(0)] - TotalEnthalpyOutIs[nBladesRow + nStages][nSpanWiseSections]); - TotalStaticEfficiency[nBladesRow +nStages][nSpanWiseSections] = (TotalEnthalpyIn[0][config->GetnSpan_iZones(0)] - TotalEnthalpyOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)]); - TotalStaticEfficiency[nBladesRow +nStages][nSpanWiseSections] /= (TotalEnthalpyIn[0][config->GetnSpan_iZones(0)] - EnthalpyOutIs[nBladesRow + nStages][nSpanWiseSections]); - PressureRatio[nBladesRow + nStages][nSpanWiseSections] = PressureRatio[0][config->GetnSpan_iZones(0)]*PressureOut[0][config->GetnSpan_iZones(0)]/PressureOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)]; - MassFlowIn[nBladesRow + nStages][nSpanWiseSections] = MassFlowIn[0][config->GetnSpan_iZones(0)]; - MassFlowOut[nBladesRow + nStages][nSpanWiseSections] = MassFlowOut[nBladesRow-1][config->GetnSpan_iZones(nBladesRow-1)]; +} - EntropyGen[nBladesRow + nStages][nSpanWiseSections] = 0.0; - for(iBlade = 0; iBlade < nBladesRow; iBlade++ ){ - EntropyGen[nBladesRow + nStages][nSpanWiseSections] += EntropyGen[iBlade][config->GetnSpan_iZones(iBlade)]; +void COutput::LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, + std::shared_ptr TurboPerf, + CConfig *config, unsigned short val_iZone) { + + if (rank == MASTER_NODE){ + auto BladePerformance = TurboPerf->GetBladesPerformances(); + auto nSpan = config->GetnSpan_iZones(val_iZone); + for (unsigned short iZone = 0; iZone <= val_iZone; iZone++) { + nSpan = config->GetnSpan_iZones(iZone); + stringstream tag; + tag << iZone + 1; + + SetHistoryOutputValue("EntropyIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetEntropy()); + SetHistoryOutputValue("EntropyOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetEntropy()); + SetHistoryOutputValue("TotalEntahalpyIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalEnthalpy()); + SetHistoryOutputValue("TotalEnthalpyOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalEnthalpy()); + SetHistoryOutputValue("TotalPressureIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalPressure()); + SetHistoryOutputValue("TotalPressureOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalPressure()); + SetHistoryOutputValue("PressureIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetPressure()); + SetHistoryOutputValue("PressureOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetPressure()); + SetHistoryOutputValue("DensityIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetDensity()); + SetHistoryOutputValue("DensityOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetDensity()); + SetHistoryOutputValue("NormalVelocityIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[0]); + SetHistoryOutputValue("NormalVelocityOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[0]); + SetHistoryOutputValue("TangentialVelocityIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[1]); + SetHistoryOutputValue("TangentialVelocityOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[1]); + SetHistoryOutputValue("MassFlowIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMassFlow()); + SetHistoryOutputValue("MassFlowOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMassFlow()); + SetHistoryOutputValue("MachIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMachValue()); + SetHistoryOutputValue("MachOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMachValue()); + SetHistoryOutputValue("FlowAngleIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER); + SetHistoryOutputValue("FlowAngleOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER); + } + SetHistoryOutputValue("EntropyGeneration", TurboStagePerf->GetNormEntropyGen()*100); + SetHistoryOutputValue("EulerianWork", TurboStagePerf->GetEulerianWork()); + SetHistoryOutputValue("TotalStaticEfficiency", TurboStagePerf->GetTotalStaticEfficiency()*100); + SetHistoryOutputValue("TotalTotalEfficiency", TurboStagePerf->GetTotalTotalEfficiency()*100); + SetHistoryOutputValue("PressureRatioTS", TurboStagePerf->GetTotalStaticPressureRatio()); + SetHistoryOutputValue("PressureRatioTT", TurboStagePerf->GetTotalTotalPressureRatio()); } - } - - delete [] relVel; - } \ No newline at end of file diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp new file mode 100644 index 00000000000..c5b1705f6c3 --- /dev/null +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -0,0 +1,304 @@ +/*! + * \file CTurboOutput.cpp + * \brief Source of the Turbomachinery Performance class. + * \author S. Vitale, N. Anand + * \version 7.1.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/output/CTurboOutput.hpp" + +CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState() { + Density = Pressure = TangVelocity = 0.0; +} +CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState(vector TurboPrimitive, + unsigned short nDim, + su2double tangVel) : Density(TurboPrimitive[0]), Pressure(TurboPrimitive[1]), TangVelocity(tangVel) { + // Velocity.assign(TurboPrimitive+2, TurboPrimitive + nDim+2 ); + Velocity = {TurboPrimitive.begin()+2, TurboPrimitive.end()}; +} + +CTurbomachineryCombinedPrimitiveStates::CTurbomachineryCombinedPrimitiveStates(const CTurbomachineryPrimitiveState& inletPrimitiveState, + const CTurbomachineryPrimitiveState& outletPrimitiveState) : InletPrimitiveState(inletPrimitiveState), OutletPrimitiveState(outletPrimitiveState){} + +CTurbomachineryState::CTurbomachineryState(){ + Density = Pressure = Entropy = Enthalpy = Temperature = TotalTemperature = TotalPressure = TotalEnthalpy = 0.0; + AbsFlowAngle = FlowAngle = MassFlow = Rothalpy = TotalRelPressure = 0.0; + Area = Radius = 0.0; +} + +CTurbomachineryState::CTurbomachineryState(unsigned short nDim, su2double area, su2double radius) : CTurbomachineryState() { + generate_n(back_inserter(Velocity),nDim, [] {return 0.0;}); + generate_n(back_inserter(RelVelocity),nDim, [] {return 0.0;}); + generate_n(back_inserter(Mach),nDim, [] {return 0.0;}); + generate_n(back_inserter(RelMach),nDim, [] {return 0.0;}); + Area = area; + Radius = radius; +} + +void CTurbomachineryState::ComputeState(CFluidModel& fluidModel, const CTurbomachineryPrimitiveState &primitiveState) { + + /*--- Assign new primitive values ---*/ + Density = primitiveState.GetDensity(); + Pressure = primitiveState.GetPressure(); + std::vector velocity = primitiveState.GetVelocity(); + Velocity.assign(velocity.begin(), velocity.end()); + su2double tangVel = primitiveState.GetTangVelocity(); + + /*--- Compute static TD quantities ---*/ + fluidModel.SetTDState_Prho(Pressure, Density); + Entropy = fluidModel.GetEntropy(); + Enthalpy = fluidModel.GetStaticEnergy() + Pressure / Density; + su2double soundSpeed = fluidModel.GetSoundSpeed(); + + /*--- Compute total TD quantities ---*/ + TotalEnthalpy = Enthalpy + 0.5 * GetVelocityValue() * GetVelocityValue(); + fluidModel.SetTDState_hs(TotalEnthalpy, Entropy); + TotalPressure = fluidModel.GetPressure(); + TotalTemperature = fluidModel.GetTemperature(); + + /*--- Compute absolute kinematic quantities---*/ + MassFlow = Density * Velocity[0] * Area; + AbsFlowAngle = atan(Velocity[1] / Velocity[0]); + Mach.assign(Velocity.begin(), Velocity.end()); + std::for_each(Mach.begin(), Mach.end(), [&](su2double &el) { el /= soundSpeed; }); + + /*--- Compute relative kinematic quantities ---*/ + su2double tangVel2 = tangVel * tangVel; + RelVelocity.assign(Velocity.begin(), Velocity.end()); + RelVelocity[1] -= tangVel; + su2double relVel2 = GetRelVelocityValue(); + FlowAngle = atan(RelVelocity[1] / RelVelocity[0]); + RelMach.assign(RelVelocity.begin(), RelVelocity.end()); + std::for_each(RelMach.begin(), RelMach.end(), [&](su2double &el) { el /= soundSpeed; }); + + /*--- Compute total relative TD quantities ---*/ + Rothalpy = Enthalpy + 0.5 * relVel2 - 0.5 * tangVel2; + fluidModel.SetTDState_hs(Rothalpy, Entropy); + TotalRelPressure = fluidModel.GetPressure(); + + /*--- Compute isentropic quantities ---*/ + fluidModel.SetTDState_Ps(Pressure, Entropy); + +} + +CTurbomachineryBladePerformance::CTurbomachineryBladePerformance(CFluidModel& fluidModel, + unsigned short nDim, + su2double areaIn, + su2double radiusIn, + su2double areaOut, + su2double radiusOut) : FluidModel(fluidModel) { + InletState = CTurbomachineryState(nDim, areaIn, radiusIn); + OutletState = CTurbomachineryState(nDim, areaOut,radiusOut); +} + + +CTurbineBladePerformance::CTurbineBladePerformance(CFluidModel& fluidModel, + unsigned short nDim, + su2double areaIn, + su2double radiusIn, + su2double areaOut, + su2double radiusOut) : CTurbomachineryBladePerformance(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut){} + +void CTurbineBladePerformance::ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) { + + /*--- Compute Inlet and Outlet state ---*/ + InletState.ComputeState(FluidModel, primitives.GetInletPrimitiveState()); + OutletState.ComputeState(FluidModel, primitives.GetOutletPrimitiveState()); + + /*--- Compute isentropic Outflow quantities ---*/ + FluidModel.SetTDState_Ps(OutletState.GetPressure(), InletState.GetEntropy()); + su2double enthalpyOutIs = FluidModel.GetStaticEnergy() + OutletState.GetPressure() / FluidModel.GetDensity(); + su2double tangVel = primitives.GetOutletPrimitiveState().GetTangVelocity(); + su2double relVelOutIs2 = 2 * (OutletState.GetRothalpy() - enthalpyOutIs) + tangVel * tangVel; + + /*--- Compute performance ---*/ + EntropyGen = (OutletState.GetEntropy() - InletState.GetEntropy()); // / abs(InletState.GetEntropy() + 1); + EulerianWork = InletState.GetTotalEnthalpy() - OutletState.GetTotalEnthalpy(); + TotalPressureLoss = (InletState.GetTotalRelPressure() - OutletState.GetTotalRelPressure()) / + (OutletState.GetTotalRelPressure() - OutletState.GetPressure()); + KineticEnergyLoss = 2 * (OutletState.GetEnthalpy() - enthalpyOutIs) / relVelOutIs2; +} + +CCompressorBladePerformance::CCompressorBladePerformance(CFluidModel& fluidModel, + unsigned short nDim, + su2double areaIn, + su2double radiusIn, + su2double areaOut, + su2double radiusOut) : CTurbomachineryBladePerformance(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut){} + +void CCompressorBladePerformance::ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) { + /*--- Compute Inlet and Outlet state ---*/ + InletState.ComputeState(FluidModel, primitives.GetInletPrimitiveState()); + OutletState.ComputeState(FluidModel, primitives.GetOutletPrimitiveState()); + + /*--- Compute isentropic Outflow quantities ---*/ + FluidModel.SetTDState_Ps(OutletState.GetPressure(), InletState.GetEntropy()); + su2double enthalpyOutIs = FluidModel.GetStaticEnergy() + OutletState.GetPressure() / FluidModel.GetDensity(); + su2double tangVel = primitives.GetOutletPrimitiveState().GetTangVelocity(); + su2double relVelOutIs2 = 2 * (OutletState.GetRothalpy() - enthalpyOutIs) + tangVel * tangVel; + + /*--- Compute performance ---*/ + EntropyGen = (OutletState.GetEntropy() - InletState.GetEntropy()); // / abs(InletState.GetEntropy() + 1); + EulerianWork = OutletState.GetTotalEnthalpy() - InletState.GetTotalEnthalpy(); + TotalPressureLoss = (InletState.GetTotalRelPressure() - OutletState.GetTotalRelPressure()) / + (InletState.GetTotalRelPressure() - InletState.GetPressure()); + KineticEnergyLoss = 2 * (OutletState.GetEnthalpy() - enthalpyOutIs) / relVelOutIs2; +} + +CPropellorBladePerformance::CPropellorBladePerformance(CFluidModel& fluidModel, + unsigned short nDim, + su2double areaIn, + su2double radiusIn, + su2double areaOut, + su2double radiusOut) : CTurbomachineryBladePerformance(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut){} + +void CPropellorBladePerformance::ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) { + // TODO: to be implemented +} + +CTurboOutput::CTurboOutput(const CConfig& config, + const CGeometry& geometry, + CFluidModel& fluidModel) { + unsigned short nBladesRow = config.GetnMarker_Turbomachinery(); + unsigned short nDim = geometry.GetnDim(); + unsigned short nStages = SU2_TYPE::Int(nBladesRow / 2); + + for (unsigned short iBladeRow = 0; iBladeRow < nBladesRow; iBladeRow++) { + vector > bladeSpanPerformances; + unsigned short nSpan = config.GetnSpanWiseSections(); + for (unsigned short iSpan = 0; iSpan < nSpan + 1; iSpan++) { + + su2double areaIn = geometry.GetSpanAreaIn(iBladeRow, iSpan); + su2double areaOut = geometry.GetSpanAreaOut(iBladeRow, iSpan); + su2double radiusIn = geometry.GetTurboRadiusIn(iBladeRow, iSpan); + su2double radiusOut = geometry.GetTurboRadiusOut(iBladeRow, iSpan); + // std::cout << "Area In " << areaIn << " Area Out " << areaOut << " blade row " << iBladeRow <(fluidModel, nDim, areaIn, radiusIn, areaOut, + radiusOut)); + break; + + case TURBO_PERF_KIND::COMPRESSOR: + bladeSpanPerformances.push_back(make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, + radiusOut)); + break; + + case TURBO_PERF_KIND::PROPELLOR: + bladeSpanPerformances.push_back(make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, + radiusOut)); + break; + + default: + bladeSpanPerformances.push_back(make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, + radiusOut)); + break; + } + } + } + BladesPerformances.push_back(bladeSpanPerformances); + } +} + +void CTurboOutput::ComputeTurbomachineryPerformance( + vector > const bladesPrimitives) { + for(unsigned i = 0; i < BladesPerformances.size(); ++i) { + ComputePerBlade(BladesPerformances[i], bladesPrimitives[i]); + } +} + +void CTurboOutput::ComputePerBlade( + vector > const bladePerformances, + vector const bladePrimitives) { + for(unsigned i = 0; i < bladePerformances.size(); ++i) { + ComputePerSpan(bladePerformances[i], bladePrimitives[i]); + } +} + +void CTurboOutput::ComputePerSpan(shared_ptr const spanPerformances, + const CTurbomachineryCombinedPrimitiveStates &spanPrimitives) { + spanPerformances->ComputePerformance(spanPrimitives); +} + +CTurbomachineryStagePerformance::CTurbomachineryStagePerformance(CFluidModel& fluid) : fluidModel(fluid) { + +} + +void CTurbomachineryStagePerformance::ComputePerformanceStage(CTurbomachineryState InState, CTurbomachineryState OutState, const CConfig* config) { + + switch (config->GetKind_TurboPerf(ZONE_0)) { + case TURBO_PERF_KIND::TURBINE: + ComputeTurbineStagePerformance(InState, OutState); + break; + + case TURBO_PERF_KIND::COMPRESSOR: + ComputeCompressorStagePerformance(InState, OutState); + break; + + default: + ComputeTurbineStagePerformance(InState, OutState); + break; + } +} + +void CTurbomachineryStagePerformance::ComputeTurbineStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState) { + + /*--- Compute isentropic Outflow quantities ---*/ + fluidModel.SetTDState_Ps(OutState.GetPressure(), InState.GetEntropy()); + su2double enthalpyOutIs = fluidModel.GetStaticEnergy() + OutState.GetPressure() / fluidModel.GetDensity(); + su2double totEnthalpyOutIs = enthalpyOutIs + 0.5*OutState.GetVelocityValue()*OutState.GetVelocityValue(); + + /*--- Compute turbine stage performance ---*/ + NormEntropyGen = (OutState.GetEntropy() - InState.GetEntropy())/InState.GetEntropy(); + EulerianWork = InState.GetTotalEnthalpy() - OutState.GetTotalEnthalpy(); + TotalStaticEfficiency = EulerianWork/(InState.GetTotalEnthalpy()-enthalpyOutIs); + TotalTotalEfficiency = EulerianWork/(InState.GetTotalEnthalpy()-totEnthalpyOutIs); + TotalStaticPressureRatio = InState.GetTotalPressure()/OutState.GetPressure(); + TotalTotalPressureRatio = InState.GetTotalPressure()/OutState.GetTotalPressure(); +} + +void CTurbomachineryStagePerformance::ComputeCompressorStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState) { + + /*--- Compute isentropic Outflow quantities ---*/ + fluidModel.SetTDState_Ps(OutState.GetPressure(), InState.GetEntropy()); + su2double enthalpyOutIs = fluidModel.GetStaticEnergy() + OutState.GetPressure() / fluidModel.GetDensity(); + su2double totEnthalpyOutIs = enthalpyOutIs + 0.5*OutState.GetVelocityValue()*OutState.GetVelocityValue(); + + /*--- Compute compressor stage performance ---*/ + NormEntropyGen = (OutState.GetEntropy() - InState.GetEntropy())/InState.GetEntropy(); + EulerianWork = OutState.GetTotalEnthalpy() - InState.GetTotalEnthalpy(); + TotalStaticEfficiency = (enthalpyOutIs-InState.GetTotalEnthalpy())/EulerianWork; + TotalTotalEfficiency = (totEnthalpyOutIs-InState.GetTotalEnthalpy())/EulerianWork; + TotalStaticPressureRatio = OutState.GetPressure()/InState.GetTotalPressure(); + TotalTotalPressureRatio = OutState.GetTotalPressure()/InState.GetTotalPressure(); + +} \ No newline at end of file diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 97fa79e6d15..557f91be237 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -35,6 +35,7 @@ #include "../../include/fluid/CCoolProp.hpp" #include "../../include/numerics_simd/CNumericsSIMD.hpp" #include "../../include/limiters/CLimiterDetails.hpp" +#include "../../include/output/CTurboOutput.hpp" CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, @@ -361,6 +362,10 @@ void CEulerSolver::InstantiateEdgeNumerics(const CSolver* const* solver_containe END_SU2_OMP_SAFE_GLOBAL_ACCESS } +void CEulerSolver::InitTurboPerformance(CGeometry *geometry, CConfig *config){ + TurbomachineryPerformance = std::make_shared(*config, *geometry, *GetFluidModel()); +} + void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ /*--- Initialize quantities for the average process for internal flow ---*/ diff --git a/config_template.cfg b/config_template.cfg index 7a30a6d6fc8..372abfa8040 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -628,6 +628,10 @@ SUBSONIC_ENGINE_VALUES= ( 0.4, 0.0, 0.0, 2116.216, 518.67 ) % CENTRIPETAL_AXIAL, AXIAL_CENTRIFUGAL) TURBOMACHINERY_KIND= CENTRIPETAL CENTRIPETAL_AXIAL % +% Specify the machine architecture for performance analysis (TURBINE, COMPRESSOR, PROPELLOR) +% +TURBO_PERF_KIND = TURBINE TURBINE +% % Specify kind of interpolation for the mixing-plane (LINEAR_INTERPOLATION, % NEAREST_SPAN, MATCHING) MIXINGPLANE_INTERFACE_KIND= LINEAR_INTERPOLATION From 7e6619ccc542c92d5b1e7653825f574b428e8dfd Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 17 Apr 2023 16:57:22 +0100 Subject: [PATCH 03/99] Changes to address comments --- SU2_CFD/include/SU2_CFD.hpp | 2 +- SU2_CFD/include/iteration/CFluidIteration.hpp | 5 +- SU2_CFD/include/iteration/CTurboIteration.hpp | 8 +- SU2_CFD/include/output/CFlowCompOutput.hpp | 11 + SU2_CFD/include/output/CFlowOutput.hpp | 8 +- SU2_CFD/include/output/COutput.hpp | 89 ++++----- SU2_CFD/include/output/CTurboOutput.hpp | 189 ++++++++---------- SU2_CFD/include/solvers/CEulerSolver.hpp | 4 +- SU2_CFD/include/solvers/CSolver.hpp | 8 +- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 7 +- SU2_CFD/src/iteration/CFluidIteration.cpp | 154 +++++++------- SU2_CFD/src/output/CFlowCompOutput.cpp | 159 +++++++++++---- SU2_CFD/src/output/CFlowOutput.cpp | 36 ++++ SU2_CFD/src/output/COutput.cpp | 164 +++------------ SU2_CFD/src/output/CTurboOutput.cpp | 3 +- 15 files changed, 421 insertions(+), 426 deletions(-) diff --git a/SU2_CFD/include/SU2_CFD.hpp b/SU2_CFD/include/SU2_CFD.hpp index 044cfd7ae58..c23920bb9e4 100644 --- a/SU2_CFD/include/SU2_CFD.hpp +++ b/SU2_CFD/include/SU2_CFD.hpp @@ -29,7 +29,7 @@ #include "../../Common/include/parallelization/mpi_structure.hpp" #include "../../Common/include/parallelization/omp_structure.hpp" -#include "../../externals/CLI11/CLI11.hpp" +#include "CLI11.hpp" #include "drivers/CDriver.hpp" #include "drivers/CSinglezoneDriver.hpp" diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index 4b24fec9f80..d73fac3801f 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -106,13 +106,14 @@ class CFluidIteration : public CIteration { CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) override; - /*! + + /*! * \brief Monitors turbo computation (pressure and turbo ramps). */ void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) override; /*! - * \brief Monitors turbo computation (pressure and turbo ramps). + * \brief Computes turboperformance. */ void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) override; diff --git a/SU2_CFD/include/iteration/CTurboIteration.hpp b/SU2_CFD/include/iteration/CTurboIteration.hpp index 144fa758986..9846d99ffe7 100644 --- a/SU2_CFD/include/iteration/CTurboIteration.hpp +++ b/SU2_CFD/include/iteration/CTurboIteration.hpp @@ -64,8 +64,8 @@ class CTurboIteration : public CFluidIteration { CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) override; - /*! - * \brief Monitors turbo computation (pressure and turbo ramps). - */ - void InitTurboPerformance(CGeometry *geometry, CConfig *config, CFluidModel *fluid) override; + /*! + * \brief Initialises turboperformance classes. + */ + void InitTurboPerformance(CGeometry *geometry, CConfig *config, CFluidModel *fluid) override; }; diff --git a/SU2_CFD/include/output/CFlowCompOutput.hpp b/SU2_CFD/include/output/CFlowCompOutput.hpp index fbf27d36f43..e7f38021fa7 100644 --- a/SU2_CFD/include/output/CFlowCompOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompOutput.hpp @@ -92,4 +92,15 @@ class CFlowCompOutput final: public CFlowOutput { * \param[in] config - Definition of the particular problem. */ bool WriteHistoryFileOutput(const CConfig *config) override ; + + void SetTurboPerformance_Output(std::shared_ptr TurboPerf, CConfig *config, + unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) override; + + void SetTurboMultiZonePerformance_Output(CTurbomachineryStagePerformance* TurboStagePerf, + std::shared_ptr TurboPerf, + CConfig *config) override; + + void LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, + std::shared_ptr TurboPerf, + CConfig *config) override; }; diff --git a/SU2_CFD/include/output/CFlowOutput.hpp b/SU2_CFD/include/output/CFlowOutput.hpp index a3893cfb23c..5730f8a01c1 100644 --- a/SU2_CFD/include/output/CFlowOutput.hpp +++ b/SU2_CFD/include/output/CFlowOutput.hpp @@ -30,6 +30,7 @@ #include "CFVMOutput.hpp" #include "../variables/CVariable.hpp" + /*--- Forward declare to avoid including here. ---*/ template struct CPrimitiveIndices; @@ -44,6 +45,12 @@ class CFlowOutput : public CFVMOutput{ */ CFlowOutput(const CConfig *config, unsigned short nDim, bool femOutput); + /* + * \brief Add turboperformance outputs as history field + * \param[in] nZone - Number of zones in problem + */ + void AddTurboOutput(unsigned short nZone); + /*! * \brief Set the values of the volume output fields for a surface point. * \param[in] config - Definition of the particular problem. @@ -321,5 +328,4 @@ class CFlowOutput : public CFVMOutput{ * \param[in] config - Definition of the particular problem per zone. */ void SetFixedCLScreenOutput(const CConfig *config); - }; diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index e620da7f2e9..db7bbf607b3 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -48,7 +48,7 @@ inline su2double hypot(const su2double& a, const su2double& b) { } } } -#include "../../../externals/mel/mel.hpp" +#include "mel.hpp" class CGeometry; class CSolver; @@ -372,32 +372,25 @@ class COutput { void SetHistoryOutput(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter); /*! - * \brief Collects Turbomachinery Performance data from the solvers and prints the data in tabular format on screen. + * \brief Collects history data from the solvers and monitors the convergence. Does not write to screen or file. * \param[in] geometry - Geometrical definition of the problem. * \param[in] solver_container - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. - * \param[in] TimeIter - Value of the time iteration index - * \param[in] OuterIter - Value of outer iteration index - * \param[in] InnerIter - Value of the inner iteration index */ - void SetTurboPerformance_Output(std::shared_ptr TurboPerf, CConfig *config, - unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iZone); - - void SetTurboMultiZonePerformance_Output(CTurbomachineryStagePerformance* TurboStagePerf, - std::shared_ptr TurboPerf, - CConfig *config); - - void LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, - std::shared_ptr TurboPerf, - CConfig *config, - unsigned short iZone); + void SetHistoryOutput(CGeometry *geometry, CSolver **solver_container, CConfig *config); /*! - * \brief Collects history data from the solvers and monitors the convergence. Does not write to screen or file. + * \brief Collects history data from the solvers, monitors the convergence and writes to screen and history file. * \param[in] geometry - Geometrical definition of the problem. * \param[in] solver_container - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. + * \param[in] TimeIter - Value of the time iteration index + * \param[in] OuterIter - Value of outer iteration index + * \param[in] InnerIter - Value of the inner iteration index */ - void SetHistoryOutput(CGeometry *geometry, CSolver **solver_container, CConfig *config); + void SetHistoryOutput(CGeometry *geometry, CSolver **solver_container, CConfig *config, + CTurbomachineryStagePerformance* TurboStagePerf, + std::shared_ptr TurboPerf, unsigned short val_iZone, + unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter); /*! * Collects history data from the individual output per zone, @@ -605,34 +598,6 @@ class COutput { */ void WriteToFile(CConfig *config, CGeometry *geometry, OUTPUT_TYPE format, string fileName = ""); - /* - * \brief Initialize turboperformance variables - * \param[in] config - Definition of the particular problem - */ - void InitTurboPerformance(const CConfig *config); - - /*! - * \brief Compute turboperformance variables - * \param[in] config - Definition of the particular problem. - * \param[in] geometry - Geometrical definition of the problem - * \param[in] solver - The container holding all solution data - */ - void ComputeTurboPerformance(CConfig *config, CGeometry *geometry, CSolver *solver); - - /*! - * \brief Collects Turbomachinery Performance data from the solvers and prints the data in tabular format on screen. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - * \param[in] TimeIter - Value of the time iteration index - * \param[in] OuterIter - Value of outer iteration index - * \param[in] InnerIter - Value of the inner iteration index - */ - void SetTurboPerformance_Output(CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iZone); - - void SetTurboMultiZonePerformance_Output(CConfig *config); - - void WriteTurboPerfConvHistory(CConfig *config); protected: @@ -976,6 +941,38 @@ class COutput { */ inline virtual void LoadMultizoneHistoryData(const COutput* const* output, const CConfig* const* config) {} + /*! + * \brief Writes turboperformance to screen + * \param[in] TurboPerf - Turboperformance definition + * \param[in] config - Definition of the particular problem + * \param[in] TimeIter - Value of the time iteration index + * \param[in] OuterIter - Value of outer iteration index + * \param[in] InnerIter - Value of the inner iteration index + */ + inline virtual void SetTurboPerformance_Output(std::shared_ptr TurboPerf, CConfig *config, + unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) {}; + + /*! + * \brief Writes turboperformance to history file + * \param[in] TurboStagePerf - Stage turboperformance definition + * \param[in] TurboPerf - Turboperformance definition + * \param[in] config - Definition of the particular problem + */ + inline virtual void SetTurboMultiZonePerformance_Output(CTurbomachineryStagePerformance* TurboStagePerf, + std::shared_ptr TurboPerf, + CConfig *config) {}; + + /*! + * \brief Writes turboperformance to screen + * \param[in] TurboStagePerf - Stage turboperformance definition + * \param[in] TurboPerf - Turboperformance definition + * \param[in] config - Definition of the particular problem + * \param[in] iZone - Current zone + */ + inline virtual void LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, + std::shared_ptr TurboPerf, + CConfig *config) {}; + /*! * \brief Set the available history output fields * \param[in] config - Definition of the particular problem. diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp index ef9d5ff1f6a..c31709405ff 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -2,14 +2,14 @@ * \file CTurboOutput.hpp * \brief Headers of the Turbomachinery Performance class. * \author S. Vitale, N. Anand - * \version 7.1.1 "Blackbird" + * \version 7.5.1 "Blackbird" * * SU2 Project Website: https://su2code.github.io * * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * Copyright 2012-2023, SU2 Contributors (cf. AUTHORS.md) * * SU2 is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -25,7 +25,6 @@ * License along with SU2. If not, see . */ - #pragma once #include @@ -37,56 +36,52 @@ #include "../../../Common/include/CConfig.hpp" #include "../fluid/CFluidModel.hpp" - class CTurbomachineryPrimitiveState { - private: + private: su2double Density, Pressure, TangVelocity; - vector Velocity; - public: - CTurbomachineryPrimitiveState(); + vector Velocity; - CTurbomachineryPrimitiveState(vector TurboPrimitives, - unsigned short nDim, - su2double tangVel); + public: + CTurbomachineryPrimitiveState(); - su2double GetDensity() const & { return Density; } + CTurbomachineryPrimitiveState(vector TurboPrimitives, unsigned short nDim, su2double tangVel); - su2double GetPressure() const & { return Pressure; } + su2double GetDensity() const& { return Density; } - su2double GetTangVelocity() const & { return TangVelocity; } + su2double GetPressure() const& { return Pressure; } - vector GetVelocity() const & { return Velocity; } + su2double GetTangVelocity() const& { return TangVelocity; } + const std::vector& GetVelocity() const& { return Velocity; } }; class CTurbomachineryCombinedPrimitiveStates { - private: + private: CTurbomachineryPrimitiveState InletPrimitiveState; CTurbomachineryPrimitiveState OutletPrimitiveState; - public: - CTurbomachineryCombinedPrimitiveStates(const CTurbomachineryPrimitiveState &inletPrimitiveState, - const CTurbomachineryPrimitiveState &outletPrimitiveState); + public: + CTurbomachineryCombinedPrimitiveStates(const CTurbomachineryPrimitiveState& inletPrimitiveState, + const CTurbomachineryPrimitiveState& outletPrimitiveState); - CTurbomachineryPrimitiveState GetInletPrimitiveState() const & { return InletPrimitiveState; } + CTurbomachineryPrimitiveState GetInletPrimitiveState() const& { return InletPrimitiveState; } - CTurbomachineryPrimitiveState GetOutletPrimitiveState() const & { return OutletPrimitiveState; } + CTurbomachineryPrimitiveState GetOutletPrimitiveState() const& { return OutletPrimitiveState; } }; class CTurbomachineryState { - private: + private: su2double Density, Pressure, Entropy, Enthalpy, Temperature, TotalTemperature, TotalPressure, TotalEnthalpy; su2double AbsFlowAngle, FlowAngle, MassFlow, Rothalpy, TotalRelPressure; - vector Velocity, RelVelocity, Mach, RelMach; + vector Velocity, RelVelocity, Mach, RelMach; su2double Area, Radius; - - public: + public: CTurbomachineryState(); CTurbomachineryState(unsigned short nDim, su2double area, su2double radius); - void ComputeState(CFluidModel& fluidModel, const CTurbomachineryPrimitiveState &primitiveState); + void ComputeState(CFluidModel& fluidModel, const CTurbomachineryPrimitiveState& primitiveState); su2double GetDensity() const { return Density; } @@ -114,56 +109,43 @@ class CTurbomachineryState { su2double GetRothalpy() const { return Rothalpy; } - vector GetVelocity() const { return Velocity; } + vector GetVelocity() const { return Velocity; } - vector GetMach() const { return Mach; } + vector GetMach() const { return Mach; } - su2double GetVelocityValue() const { - return Norm(Velocity); - } + su2double GetVelocityValue() const { return Norm(Velocity); } - su2double GetMachValue() const { - return Norm(Mach); - } + su2double GetMachValue() const { return Norm(Mach); } - su2double GetRelVelocityValue() const { - return Norm(RelVelocity); - } + su2double GetRelVelocityValue() const { return Norm(RelVelocity); } - su2double GetRelMachValue() const { - return Norm(RelMach); - } + su2double GetRelMachValue() const { return Norm(RelMach); } su2double Norm(vector const& u) const { su2double accum = 0.; for (int i = 0; i < u.size(); ++i) { - accum += u[i] * u[i]; + accum += u[i] * u[i]; } return sqrt(accum); } }; - class CTurbomachineryBladePerformance { - protected: + protected: CTurbomachineryState InletState; CTurbomachineryState OutletState; su2double KineticEnergyLoss, TotalPressureLoss, EntropyGen, PressureRatio, EulerianWork; - CFluidModel &FluidModel; + CFluidModel& FluidModel; - public: - CTurbomachineryBladePerformance(CFluidModel& fluidModel, - unsigned short nDim, - su2double areaIn, - su2double radiusIn, - su2double areaOut, - su2double radiusOut); + public: + CTurbomachineryBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, + su2double areaOut, su2double radiusOut); - virtual void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) {}; + virtual void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates& primitives){}; const CTurbomachineryState& GetInletState() { return InletState; } - const CTurbomachineryState& GetOutletState() { return OutletState; } + const CTurbomachineryState& GetOutletState() { return OutletState; } su2double GetKineticEnergyLoss() const { return KineticEnergyLoss; } @@ -174,89 +156,74 @@ class CTurbomachineryBladePerformance { su2double GetPressureRatio() const { return PressureRatio; } su2double GetEulerianWork() const { return EulerianWork; } - }; class CTurbineBladePerformance : public CTurbomachineryBladePerformance { + public: + CTurbineBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, + su2double areaOut, su2double radiusOut); - public: - CTurbineBladePerformance(CFluidModel& fluidModel, - unsigned short nDim, - su2double areaIn, - su2double radiusIn, - su2double areaOut, - su2double radiusOut); - - void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) override; - + void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates& primitives) override; }; class CCompressorBladePerformance : public CTurbomachineryBladePerformance { + public: + CCompressorBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, + su2double areaOut, su2double radiusOut); - public: - CCompressorBladePerformance(CFluidModel& fluidModel, - unsigned short nDim, - su2double areaIn, - su2double radiusIn, - su2double areaOut, - su2double radiusOut); - - void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) override; - + void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates& primitives) override; }; class CPropellorBladePerformance : public CTurbomachineryBladePerformance { + public: + CPropellorBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, + su2double areaOut, su2double radiusOut); - public: - CPropellorBladePerformance(CFluidModel& fluidModel, - unsigned short nDim, - su2double areaIn, - su2double radiusIn, - su2double areaOut, - su2double radiusOut); - - void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) override; - + void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates& primitives) override; }; class CTurbomachineryStagePerformance { - protected: - su2double TotalStaticEfficiency, TotalTotalEfficiency, NormEntropyGen, TotalStaticPressureRatio, TotalTotalPressureRatio, EulerianWork; - CFluidModel &fluidModel; - public: - CTurbomachineryStagePerformance(CFluidModel& fluid); - virtual ~CTurbomachineryStagePerformance() = default; - virtual void ComputePerformanceStage(CTurbomachineryState InState, CTurbomachineryState OutState, const CConfig* config); - virtual void ComputeTurbineStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState); - virtual void ComputeCompressorStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState); - su2double GetTotalStaticEfficiency() const { return TotalStaticEfficiency; } - su2double GetTotalTotalEfficiency() const { return TotalTotalEfficiency; } - su2double GetEulerianWork() const { return EulerianWork; } - su2double GetNormEntropyGen() const { return NormEntropyGen; } - su2double GetTotalStaticPressureRatio() const { return TotalStaticPressureRatio; } - su2double GetTotalTotalPressureRatio() const { return TotalTotalPressureRatio; } + protected: + su2double TotalStaticEfficiency, TotalTotalEfficiency, NormEntropyGen, TotalStaticPressureRatio, + TotalTotalPressureRatio, EulerianWork; + CFluidModel& fluidModel; + + public: + CTurbomachineryStagePerformance(CFluidModel& fluid); + virtual ~CTurbomachineryStagePerformance() = default; + virtual void ComputePerformanceStage(CTurbomachineryState InState, CTurbomachineryState OutState, + const CConfig* config); + virtual void ComputeTurbineStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState); + virtual void ComputeCompressorStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState); + su2double GetTotalStaticEfficiency() const { return TotalStaticEfficiency; } + su2double GetTotalTotalEfficiency() const { return TotalTotalEfficiency; } + su2double GetEulerianWork() const { return EulerianWork; } + su2double GetNormEntropyGen() const { return NormEntropyGen; } + su2double GetTotalStaticPressureRatio() const { return TotalStaticPressureRatio; } + su2double GetTotalTotalPressureRatio() const { return TotalTotalPressureRatio; } }; class CTurboOutput { - private: - vector >> - BladesPerformances; + private: + vector>> BladesPerformances; - static void ComputePerBlade(vector > const bladePerformances, - vector const bladePrimitives); + static void ComputePerBlade(vector> const bladePerformances, + vector const bladePrimitives); - static void ComputePerSpan(shared_ptr const spanPerformances, - const CTurbomachineryCombinedPrimitiveStates &spanPrimitives); + static void ComputePerSpan(shared_ptr const spanPerformances, + const CTurbomachineryCombinedPrimitiveStates& spanPrimitives); // vector> StagePerformances; // shared_ptr MachinePerformances; - public: + public: CTurboOutput(const CConfig& config, const CGeometry& geometry, CFluidModel& fluidModel); - vector >> + vector>> - GetBladesPerformances() const { return BladesPerformances; } + GetBladesPerformances() const { + return BladesPerformances; + } // vector> GetStagePerformances() const { return StagePerformances; } // shared_ptr GetMachinePerformances() const { return MachinePerformances; } - void ComputeTurbomachineryPerformance(vector > const primitives); -}; \ No newline at end of file + void ComputeTurbomachineryPerformance(vector> const primitives); +};s \ No newline at end of file diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index bfe94ebe976..cb3ae3eb8ca 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -29,8 +29,7 @@ #include "CFVMFlowSolverBase.hpp" #include "../variables/CEulerVariable.hpp" -#include "../../../Common/include/option_structure.hpp" - +#include "../output/CTurboOutput.hpp" /*! * \class CEulerSolver * \ingroup Euler_Equations @@ -1062,7 +1061,6 @@ class CEulerSolver : public CFVMFlowSolverBase GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool INLET) {return TurboPrimitive;} + virtual vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool Inlet) {return TurboPrimitive;} /*! * \brief Get values for streamwise periodic flow: delta P, m_dot, inlet T, integrated heat, etc. diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index ec87b210663..050ee68da88 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -584,23 +584,22 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar break; case MIXING_PLANE: { - auto nMarkerInt = config_container[donorZone]->GetnMarker_MixingPlaneInterface()/2; + const auto nMarkerInt = config_container[donorZone]->GetnMarker_MixingPlaneInterface() / 2; - /* --- transfer the average value from the donorZone to the targetZone*/ + /*--- Transfer the average value from the donorZone to the targetZone ---*/ for (auto iMarkerInt = 1; iMarkerInt <= nMarkerInt; iMarkerInt++) { interface_container[donorZone][targetZone]->AllgatherAverage(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL],solver_container[targetZone][INST_0][MESH_0][FLOW_SOL], geometry_container[donorZone][INST_0][MESH_0],geometry_container[targetZone][INST_0][MESH_0], config_container[donorZone], config_container[targetZone], iMarkerInt ); } - for (donorZone = 0; donorZone < nZone-1; donorZone++) { + for (donorZone = 0; donorZone < nZone; donorZone++) { if (interface_types[donorZone][targetZone]==MIXING_PLANE) { interface_container[donorZone][targetZone]->GatherAverageValues(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL],solver_container[targetZone][INST_0][MESH_0][FLOW_SOL], donorZone); interface_container[donorZone][targetZone]->GatherAverageTurboGeoValues(geometry_container[donorZone][INST_0][MESH_0],geometry_container[targetZone][INST_0][MESH_0], donorZone); } } - return UpdateMesh; break; } case NO_TRANSFER: diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 5cf859b33b1..6658b7854ed 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -28,6 +28,7 @@ #include "../../include/iteration/CFluidIteration.hpp" #include "../../include/output/COutput.hpp" + void CFluidIteration::Preprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, @@ -213,36 +214,23 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe UsedTime = StopTime - StartTime; - unsigned long Iter= config[val_iZone]->GetInnerIter(); - - output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], - config[val_iZone], config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), - config[val_iZone]->GetInnerIter()); /*--- Turbomachinery Specific Montior ---*/ if (config[ZONE_0]->GetBoolTurbomachinery()){ - - /*--- Turbomachinery Performance Computation ---*/ - if (val_iZone == config[ZONE_0]->GetnZone()-1){ - ComputeTurboPerformance(solver, geometry, config, config[val_iZone]->GetInnerIter()); - output->LoadTurboHistoryData(TurbomachineryStagePerformance, TurbomachineryPerformance, config[val_iZone], val_iZone); - } - - if (config[ZONE_0]->GetMultizone_Problem()) - Iter = config[ZONE_0]->GetOuterIter(); - - /*--- Turbomachinery Performance Screen summary output---*/ - if (val_iZone == config[ZONE_0]->GetnZone()-1 && Iter%100 == 0) { - output->SetTurboPerformance_Output(TurbomachineryPerformance, config[val_iZone], - config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), - config[val_iZone]->GetInnerIter(), val_iZone); - if (rank == MASTER_NODE) - output->SetTurboMultiZonePerformance_Output(TurbomachineryStagePerformance, TurbomachineryPerformance, config[val_iZone]); + if (val_iZone == config[ZONE_0]->GetnZone()-1) { + ComputeTurboPerformance(solver, geometry, config, config[val_iZone]->GetnInner_Iter()); + + output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], + config[val_iZone], TurbomachineryStagePerformance, TurbomachineryPerformance, val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), + config[val_iZone]->GetInnerIter()); } - /*--- Turbomachinery Rotation and Pressure Ramps ---*/ TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter()); } + + output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], + config[val_iZone], config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), + config[val_iZone]->GetInnerIter()); /*--- If convergence was reached --*/ StopCalc = output->GetConvergence(); @@ -257,79 +245,75 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe return StopCalc; } -void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) { +void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter) { - su2double rot_z_ini, rot_z_final ,rot_z; - su2double outPres_ini, outPres_final, outPres; - unsigned long rampFreq, finalRamp_Iter; - unsigned short iMarker, KindBC, KindBCOption; - unsigned short iZone; - string Marker_Tag; + auto* config = config_container[ZONE_0]; - bool print; if (config_container[ZONE_0]->GetMultizone_Problem()) - ExtIter = config_container[ZONE_0]->GetOuterIter(); + iter = config_container[ZONE_0]->GetOuterIter(); + - for(iZone = 0; iZone < nZone; iZone++) { /*--- ROTATING FRAME Ramp: Compute the updated rotational velocity. ---*/ - if (config_container[iZone]->GetGrid_Movement() && config_container[iZone]->GetRampRotatingFrame()) { - rampFreq = SU2_TYPE::Int(config_container[iZone]->GetRampRotatingFrame_Coeff(1)); - finalRamp_Iter = SU2_TYPE::Int(config_container[iZone]->GetRampRotatingFrame_Coeff(2)); - rot_z_ini = config_container[iZone]->GetRampRotatingFrame_Coeff(0); - print = false; - if(ExtIter % rampFreq == 0 && ExtIter <= finalRamp_Iter){ - rot_z_final = config_container[iZone]->GetFinalRotation_Rate_Z(); - if(abs(rot_z_final) > 0.0){ - rot_z = rot_z_ini + ExtIter*( rot_z_final - rot_z_ini)/finalRamp_Iter; + if (config->GetGrid_Movement() && config->GetRampRotatingFrame()) { + const unsigned long rampFreq = SU2_TYPE::Int(config->GetRampRotatingFrame_Coeff(1)); + const unsigned long finalRamp_Iter = SU2_TYPE::Int(config->GetRampRotatingFrame_Coeff(2)); + const su2double rot_z_ini = config->GetRampRotatingFrame_Coeff(0); + const bool print = false; + + if(iter % rampFreq == 0 && iter <= finalRamp_Iter){ + + for (auto iZone = 0u; iZone < nZone; iZone++) { + const su2double rot_z_final = config_container[iZone]->GetFinalRotation_Rate_Z(); + + if (fabs(rot_z_final) > 0.0) { + const su2double rot_z = rot_z_ini + iter * ( rot_z_final - rot_z_ini) / finalRamp_Iter; config_container[iZone]->SetRotation_Rate(2, rot_z); - if(rank == MASTER_NODE && print && ExtIter > 0) { - cout << endl << " Updated rotating frame grid velocities"; - cout << " for zone " << iZone << "." << endl; + if (rank == MASTER_NODE && print && iter > 0) { + cout << "\nUpdated rotating frame grid velocities for zone " << iZone << ".\n"; } geometry_container[iZone][INST_0][MESH_0]->SetRotationalVelocity(config_container[iZone], print); geometry_container[iZone][INST_0][MESH_0]->SetShroudVelocity(config_container[iZone]); } + } - for (iZone = 0; iZone < nZone; iZone++) { - geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config_container[iZone], iZone, INFLOW, false); - geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config_container[iZone],iZone, OUTFLOW, false); - geometry_container[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config_container[iZone], false); - - } + for (auto iZone = 0u; iZone < nZone; iZone++) { + geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config_container[iZone], iZone, INFLOW, false); + geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config_container[iZone],iZone, OUTFLOW, false); + geometry_container[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config_container[iZone], false); } } } - - /*--- Outlet Pressure Ramp: Compute the updated rotational velocity. ---*/ - if (config_container[ZONE_0]->GetRampOutletPressure()) { - rampFreq = SU2_TYPE::Int(config_container[ZONE_0]->GetRampOutletPressure_Coeff(1)); - finalRamp_Iter = SU2_TYPE::Int(config_container[ZONE_0]->GetRampOutletPressure_Coeff(2)); - outPres_ini = config_container[ZONE_0]->GetRampOutletPressure_Coeff(0); - outPres_final = config_container[ZONE_0]->GetFinalOutletPressure(); - - if(ExtIter % rampFreq == 0 && ExtIter <= finalRamp_Iter){ - outPres = outPres_ini + ExtIter*(outPres_final - outPres_ini)/finalRamp_Iter; - if(rank == MASTER_NODE) config_container[ZONE_0]->SetMonitotOutletPressure(outPres); - - for (iZone = 0; iZone < nZone; iZone++) { - for (iMarker = 0; iMarker < config_container[iZone]->GetnMarker_All(); iMarker++) { - KindBC = config_container[iZone]->GetMarker_All_KindBC(iMarker); + /*--- Outlet Pressure Ramp: Compute the updated pressure. ---*/ + if (config->GetRampOutletPressure()) { + const unsigned long rampFreq = SU2_TYPE::Int(config->GetRampOutletPressure_Coeff(1)); + const unsigned long finalRamp_Iter = SU2_TYPE::Int(config->GetRampOutletPressure_Coeff(2)); + const su2double outPres_ini = config->GetRampOutletPressure_Coeff(0); + const su2double outPres_final = config->GetFinalOutletPressure(); + + if (iter % rampFreq == 0 && iter <= finalRamp_Iter) { + const su2double outPres = outPres_ini + iter * (outPres_final - outPres_ini) / finalRamp_Iter; + if (rank == MASTER_NODE) config->SetMonitotOutletPressure(outPres); + + for (auto iZone = 0u; iZone < nZone; iZone++) { + for (auto iMarker = 0; iMarker < config_container[iZone]->GetnMarker_All(); iMarker++) { + const auto KindBC = config_container[iZone]->GetMarker_All_KindBC(iMarker); + const auto Marker_Tag = config_container[iZone]->GetMarker_All_TagBound(iMarker); + unsigned short KindBCOption; switch (KindBC) { - case RIEMANN_BOUNDARY: - Marker_Tag = config_container[iZone]->GetMarker_All_TagBound(iMarker); - KindBCOption = config_container[iZone]->GetKind_Data_Riemann(Marker_Tag); - if(KindBCOption == STATIC_PRESSURE || KindBCOption == RADIAL_EQUILIBRIUM ){ - SU2_MPI::Error("Outlet pressure ramp only implemented for NRBC", CURRENT_FUNCTION); - } - break; - case GILES_BOUNDARY: - Marker_Tag = config_container[iZone]->GetMarker_All_TagBound(iMarker); - KindBCOption = config_container[iZone]->GetKind_Data_Giles(Marker_Tag); - if(KindBCOption == STATIC_PRESSURE || KindBCOption == STATIC_PRESSURE_1D || KindBCOption == RADIAL_EQUILIBRIUM ){ - config_container[iZone]->SetGiles_Var1(outPres, Marker_Tag); - } - break; + case RIEMANN_BOUNDARY: + KindBCOption = config_container[iZone]->GetKind_Data_Riemann(Marker_Tag); + if (KindBCOption == STATIC_PRESSURE || KindBCOption == RADIAL_EQUILIBRIUM) { + SU2_MPI::Error("Outlet pressure ramp only implemented for NRBC", CURRENT_FUNCTION); + } + break; + case GILES_BOUNDARY: + KindBCOption = config_container[iZone]->GetKind_Data_Giles(Marker_Tag); + if (KindBCOption == STATIC_PRESSURE || KindBCOption == STATIC_PRESSURE_1D || + KindBCOption == RADIAL_EQUILIBRIUM ) { + config_container[iZone]->SetGiles_Var1(outPres, Marker_Tag); + } + break; } } } @@ -360,6 +344,16 @@ void CFluidIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** bladesPrimitives.push_back(bladePrimitives); } TurbomachineryPerformance->ComputeTurbomachineryPerformance(bladesPrimitives); + + auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); + + /*--- Machine Performance (Takes inlet of Zone 0 and Outlet of Zone N-1) ---*/ + // TODO: This still crashed or gives garbage value if there are uneven spans + auto InState = TurbomachineryPerformance->GetBladesPerformances().at(ZONE_0).at(nSpan)->GetInletState(); + nSpan = config_container[nZone-1]->GetnSpanWiseSections(); + auto OutState = TurbomachineryPerformance->GetBladesPerformances().at(nZone-1).at(nSpan)->GetOutletState(); + + TurbomachineryStagePerformance->ComputePerformanceStage(InState, OutState, config_container[nZone-1]); } } diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 0f32bbb2a41..87c2f27a6c2 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -208,41 +208,7 @@ void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ AddNearfieldInverseDesignOutput(); - /// BEGIN_GROUP: TURBO_PERF, DESCRIPTION: Turboperformance variables - if (config->GetBoolTurbomachinery()) { - //Adds zone turboperformance history variables - for (unsigned short iZone = 0; iZone <= config->GetnZone() - 1; iZone++) { - stringstream tag; - tag << iZone + 1; - AddHistoryOutput("EntropyIn_" + tag.str(), "EntropyIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total pressure loss " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("EntropyOut_" + tag.str(), "EntropyOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Kinetic energy loss " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalEntahalpyIn_" + tag.str(), "TotalEntahalpyIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Entropy generation " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalEnthalpyOut_" + tag.str(), "TotalEnthalpyOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Eulerian work " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalPressureIn_" + tag.str(), "TotPressureIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalPressureOut_" + tag.str(), "TotPressureOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("PressureIn_" + tag.str(), "PressureIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("PressureOut_" + tag.str(), "PressureOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("DensityIn_" + tag.str(), "DensityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle out " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("DensityOut_" + tag.str(), "DensityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("NormalVelocityIn_" + tag.str(), "NormalVelocityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("NormalVelocityOut_" + tag.str(), "NormalVelocityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TangentialVelocityIn_" + tag.str(), "TangentialVelocityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow out " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TangentialVelocityOut_" + tag.str(), "TangentialVelocityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("MassFlowIn_" + tag.str(), "MassFlowIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach out " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("MassFlowOut_" + tag.str(), "MassFlowOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total efficiency " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("MachIn_" + tag.str(), "MachIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("MachOut_" + tag.str(), "MachOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("FlowAngleIn_" + tag.str(), "FlowAngleIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("FlowAngleOut_" + tag.str(), "FlowAngleOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); - } - //Adds turbomachinery machine performance variables - AddHistoryOutput("EntropyGeneration", "EntropyGen", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); - AddHistoryOutput("EulerianWork", "EulerianWork", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalStaticEfficiency", "TotStaticEff", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalTotalEfficiency", "TotTotEff", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); - AddHistoryOutput("PressureRatioTS", "PRTS", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); - AddHistoryOutput("PressureRatioTT", "PRTT", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); - } + if (config->GetBoolTurbomachinery()) AddTurboOutput(config->GetnZone()); } @@ -504,3 +470,126 @@ void CFlowCompOutput::SetAdditionalScreenOutput(const CConfig *config){ bool CFlowCompOutput::WriteHistoryFileOutput(const CConfig *config) { return !config->GetFinite_Difference_Mode() && COutput::WriteHistoryFileOutput(config); } + +void CFlowCompOutput::SetTurboPerformance_Output(std::shared_ptr TurboPerf, + CConfig *config, + unsigned long TimeIter, + unsigned long OuterIter, + unsigned long InnerIter) { + + curTimeIter = TimeIter; + curAbsTimeIter = TimeIter - config->GetRestart_Iter(); + curOuterIter = OuterIter; + curInnerIter = InnerIter; + stringstream TurboInOutTable, TurboPerfTable; + + if(rank == MASTER_NODE) { + auto BladePerformance = TurboPerf->GetBladesPerformances(); + + /*-- Table for Turbomachinery Performance Values --*/ + PrintingToolbox::CTablePrinter TurboInOut(&TurboInOutTable); + + TurboInOutTable<<"-- Turbomachinery inlet and outlet property Summary:"<GetnZone()-1; iZone++) { + auto nSpan = config->GetnSpan_iZones(iZone); + + TurboInOut<<" BLADE ROW INDEX "<GetInletState().GetEntropy() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetEntropy(); + TurboInOut << "Total Enthalpy " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalEnthalpy() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalEnthalpy(); + TurboInOut << "Total Pressure " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalPressure() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalPressure(); + TurboInOut << "Pressure " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetPressure() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetPressure(); + TurboInOut << "Density " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetDensity() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetDensity(); + TurboInOut << "Normal Velocity " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[0] << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[0]; + TurboInOut << "Tangential Velocity " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[1] << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[1]; + TurboInOut << "Mass Flow " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMassFlow() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMassFlow(); + TurboInOut << "Mach " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMachValue() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMachValue(); + TurboInOut << "Flow Angle " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER; + TurboInOut.PrintFooter(); + } + cout< TurboPerf, + CConfig *config) { + + auto nZone = config->GetnZone(); + unsigned short iStage, iZone; + auto nSpan = config->GetnSpanWiseSections(); + stringstream TurboMZPerf; + + PrintingToolbox::CTablePrinter TurboInOut(&TurboMZPerf); + + /*--- Print header for the stage performance computation ---*/ + TurboMZPerf<<"-- Turbomachinery Stage Performance --"<GetNormEntropyGen()*100 + <GetEulerianWork() + <GetTotalStaticEfficiency()*100 + <GetTotalTotalEfficiency()*100 + <GetTotalStaticPressureRatio() + <GetTotalTotalPressureRatio(); + TurboInOut.PrintFooter(); + cout< TurboPerf, + CConfig *config) { + + if (rank == MASTER_NODE){ + auto BladePerformance = TurboPerf->GetBladesPerformances(); + for (unsigned short iZone = 0; iZone <= config->GetnZone()-1; iZone++) { + auto nSpan = config->GetnSpan_iZones(iZone); + stringstream tag; + tag << iZone + 1; + + SetHistoryOutputValue("EntropyIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetEntropy()); + SetHistoryOutputValue("EntropyOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetEntropy()); + SetHistoryOutputValue("TotalEntahalpyIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalEnthalpy()); + SetHistoryOutputValue("TotalEnthalpyOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalEnthalpy()); + SetHistoryOutputValue("TotalPressureIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalPressure()); + SetHistoryOutputValue("TotalPressureOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalPressure()); + SetHistoryOutputValue("PressureIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetPressure()); + SetHistoryOutputValue("PressureOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetPressure()); + SetHistoryOutputValue("DensityIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetDensity()); + SetHistoryOutputValue("DensityOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetDensity()); + SetHistoryOutputValue("NormalVelocityIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[0]); + SetHistoryOutputValue("NormalVelocityOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[0]); + SetHistoryOutputValue("TangentialVelocityIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[1]); + SetHistoryOutputValue("TangentialVelocityOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[1]); + SetHistoryOutputValue("MassFlowIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMassFlow()); + SetHistoryOutputValue("MassFlowOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMassFlow()); + SetHistoryOutputValue("MachIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMachValue()); + SetHistoryOutputValue("MachOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMachValue()); + SetHistoryOutputValue("FlowAngleIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER); + SetHistoryOutputValue("FlowAngleOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER); + } + SetHistoryOutputValue("EntropyGeneration", TurboStagePerf->GetNormEntropyGen()*100); + SetHistoryOutputValue("EulerianWork", TurboStagePerf->GetEulerianWork()); + SetHistoryOutputValue("TotalStaticEfficiency", TurboStagePerf->GetTotalStaticEfficiency()*100); + SetHistoryOutputValue("TotalTotalEfficiency", TurboStagePerf->GetTotalTotalEfficiency()*100); + SetHistoryOutputValue("PressureRatioTS", TurboStagePerf->GetTotalStaticPressureRatio()); + SetHistoryOutputValue("PressureRatioTT", TurboStagePerf->GetTotalTotalPressureRatio()); + } +} diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 5be001f5a5a..28f8716e5ca 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -36,6 +36,7 @@ #include "../../include/variables/CPrimitiveIndices.hpp" #include "../../include/fluid/CCoolProp.hpp" + CFlowOutput::CFlowOutput(const CConfig *config, unsigned short nDim, bool fem_output) : CFVMOutput(config, nDim, fem_output), lastInnerIter(curInnerIter) { @@ -3745,3 +3746,38 @@ void CFlowOutput::SetFixedCLScreenOutput(const CConfig *config){ curInnerIter = config->GetInnerIter(); } } + +void CFlowOutput::AddTurboOutput(unsigned short nZone){ +//Adds zone turboperformance history variables + for (unsigned short iZone = 0; iZone <= nZone-1; iZone++) { + stringstream tag; + tag << iZone + 1; + AddHistoryOutput("EntropyIn_" + tag.str(), "EntropyIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total pressure loss " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("EntropyOut_" + tag.str(), "EntropyOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Kinetic energy loss " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalEntahalpyIn_" + tag.str(), "TotalEntahalpyIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Entropy generation " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalEnthalpyOut_" + tag.str(), "TotalEnthalpyOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Eulerian work " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalPressureIn_" + tag.str(), "TotPressureIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalPressureOut_" + tag.str(), "TotPressureOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureIn_" + tag.str(), "PressureIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureOut_" + tag.str(), "PressureOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("DensityIn_" + tag.str(), "DensityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("DensityOut_" + tag.str(), "DensityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("NormalVelocityIn_" + tag.str(), "NormalVelocityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("NormalVelocityOut_" + tag.str(), "NormalVelocityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TangentialVelocityIn_" + tag.str(), "TangentialVelocityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TangentialVelocityOut_" + tag.str(), "TangentialVelocityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("MassFlowIn_" + tag.str(), "MassFlowIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("MassFlowOut_" + tag.str(), "MassFlowOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total efficiency " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("MachIn_" + tag.str(), "MachIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("MachOut_" + tag.str(), "MachOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("FlowAngleIn_" + tag.str(), "FlowAngleIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("FlowAngleOut_" + tag.str(), "FlowAngleOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); + } + //Adds turbomachinery machine performance variables + AddHistoryOutput("EntropyGeneration", "EntropyGen", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("EulerianWork", "EulerianWork", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalStaticEfficiency", "TotStaticEff", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalTotalEfficiency", "TotTotEff", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureRatioTS", "PRTS", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureRatioTT", "PRTT", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); +} diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index cae8762b9da..e83e4c5e283 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -228,6 +228,37 @@ void COutput::SetHistoryOutput(CGeometry *geometry, } +void COutput::SetHistoryOutput(CGeometry *geometry, + CSolver **solver, + CConfig *config, + CTurbomachineryStagePerformance* TurboStagePerf, + std::shared_ptr TurboPerf, + unsigned short val_iZone, + unsigned long TimeIter, + unsigned long OuterIter, + unsigned long InnerIter){ + + unsigned long Iter= InnerIter; + + if (config->GetMultizone_Problem()) + Iter = OuterIter; + + /*--- Turbomachinery Performance Screen summary output---*/ + if (Iter%100 == 0) { + SetTurboPerformance_Output(TurboPerf, config, TimeIter, OuterIter, InnerIter); + + if (rank == MASTER_NODE) + SetTurboMultiZonePerformance_Output(TurboStagePerf, TurboPerf, config); + } + + /*--- Update turboperformance history file*/ + LoadTurboHistoryData(TurboStagePerf, TurboPerf, config); + + SetHistoryOutput(geometry, solver, config, TimeIter, OuterIter,InnerIter); + +} + + void COutput::SetMultizoneHistoryOutput(COutput **output, CConfig **config, CConfig *driver_config, unsigned long TimeIter, unsigned long OuterIter){ curTimeIter = TimeIter; @@ -2476,137 +2507,4 @@ void COutput::PrintVolumeFields(){ VolumeFieldTable.PrintFooter(); } -} - -void COutput::SetTurboPerformance_Output(std::shared_ptr TurboPerf, - CConfig *config, - unsigned long TimeIter, - unsigned long OuterIter, - unsigned long InnerIter, - unsigned short val_iZone) { - - curTimeIter = TimeIter; - curAbsTimeIter = TimeIter - config->GetRestart_Iter(); - curOuterIter = OuterIter; - curInnerIter = InnerIter; - stringstream TurboInOutTable, TurboPerfTable; - - if(rank == MASTER_NODE) { - auto BladePerformance = TurboPerf->GetBladesPerformances(); - auto nSpan = config->GetnSpan_iZones(val_iZone); - - /*-- Table for Turbomachinery Performance Values --*/ - PrintingToolbox::CTablePrinter TurboInOut(&TurboInOutTable); - - TurboInOutTable<<"-- Turbomachinery inlet and outlet property Summary:"<GetnSpan_iZones(iZone); - - TurboInOut<<" BLADE ROW INDEX "<GetInletState().GetEntropy() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetEntropy(); - TurboInOut << "Total Enthalpy " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalEnthalpy() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalEnthalpy(); - TurboInOut << "Total Pressure " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalPressure() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalPressure(); - TurboInOut << "Pressure " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetPressure() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetPressure(); - TurboInOut << "Density " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetDensity() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetDensity(); - TurboInOut << "Normal Velocity " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[0] << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[0]; - TurboInOut << "Tangential Velocity " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[1] << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[1]; - TurboInOut << "Mass Flow " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMassFlow() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMassFlow(); - TurboInOut << "Mach " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMachValue() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMachValue(); - TurboInOut << "Flow Angle " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER; - TurboInOut.PrintFooter(); - } - cout< TurboPerf, - CConfig *config) { - - auto nZone = config->GetnZone(); - unsigned short iStage, iZone; - auto nSpan = config->GetnSpanWiseSections(); - stringstream TurboMZPerf; - - PrintingToolbox::CTablePrinter TurboInOut(&TurboMZPerf); - - /*--- Print header for the stage performance computation ---*/ - TurboMZPerf<<"-- Turbomachinery Stage Performance --"<GetBladesPerformances().at(ZONE_0).at(nSpan)->GetInletState(); - auto OutState = TurboPerf->GetBladesPerformances().at(nZone-1).at(nSpan)->GetOutletState(); - - TurboStagePerf->ComputePerformanceStage(InState, OutState, config); - - /*--- Print Machine Performance (In future also add if the performance is TURBINE or COMPRESSOR) ---*/ - TurboInOut<<"MACHINE"<GetNormEntropyGen()*100 - <GetEulerianWork() - <GetTotalStaticEfficiency()*100 - <GetTotalTotalEfficiency()*100 - <GetTotalStaticPressureRatio() - <GetTotalTotalPressureRatio(); - TurboInOut.PrintFooter(); - cout< TurboPerf, - CConfig *config, unsigned short val_iZone) { - - if (rank == MASTER_NODE){ - auto BladePerformance = TurboPerf->GetBladesPerformances(); - auto nSpan = config->GetnSpan_iZones(val_iZone); - for (unsigned short iZone = 0; iZone <= val_iZone; iZone++) { - nSpan = config->GetnSpan_iZones(iZone); - stringstream tag; - tag << iZone + 1; - - SetHistoryOutputValue("EntropyIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetEntropy()); - SetHistoryOutputValue("EntropyOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetEntropy()); - SetHistoryOutputValue("TotalEntahalpyIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalEnthalpy()); - SetHistoryOutputValue("TotalEnthalpyOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalEnthalpy()); - SetHistoryOutputValue("TotalPressureIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalPressure()); - SetHistoryOutputValue("TotalPressureOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalPressure()); - SetHistoryOutputValue("PressureIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetPressure()); - SetHistoryOutputValue("PressureOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetPressure()); - SetHistoryOutputValue("DensityIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetDensity()); - SetHistoryOutputValue("DensityOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetDensity()); - SetHistoryOutputValue("NormalVelocityIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[0]); - SetHistoryOutputValue("NormalVelocityOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[0]); - SetHistoryOutputValue("TangentialVelocityIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[1]); - SetHistoryOutputValue("TangentialVelocityOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[1]); - SetHistoryOutputValue("MassFlowIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMassFlow()); - SetHistoryOutputValue("MassFlowOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMassFlow()); - SetHistoryOutputValue("MachIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMachValue()); - SetHistoryOutputValue("MachOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMachValue()); - SetHistoryOutputValue("FlowAngleIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER); - SetHistoryOutputValue("FlowAngleOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER); - } - SetHistoryOutputValue("EntropyGeneration", TurboStagePerf->GetNormEntropyGen()*100); - SetHistoryOutputValue("EulerianWork", TurboStagePerf->GetEulerianWork()); - SetHistoryOutputValue("TotalStaticEfficiency", TurboStagePerf->GetTotalStaticEfficiency()*100); - SetHistoryOutputValue("TotalTotalEfficiency", TurboStagePerf->GetTotalTotalEfficiency()*100); - SetHistoryOutputValue("PressureRatioTS", TurboStagePerf->GetTotalStaticPressureRatio()); - SetHistoryOutputValue("PressureRatioTT", TurboStagePerf->GetTotalTotalPressureRatio()); - } } \ No newline at end of file diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index c5b1705f6c3..634adf1a145 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -1,6 +1,6 @@ /*! * \file CTurboOutput.cpp - * \brief Source of the Turbomachinery Performance class. + * \brief Source of the Turbomachinery Performance class * \author S. Vitale, N. Anand * \version 7.1.1 "Blackbird" * @@ -27,6 +27,7 @@ #include "../../include/output/CTurboOutput.hpp" + CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState() { Density = Pressure = TangVelocity = 0.0; } From 1d5c4fce575114f133652d9113127354ac0a83cc Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 17 Apr 2023 17:02:41 +0100 Subject: [PATCH 04/99] typo --- SU2_CFD/include/output/CTurboOutput.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp index c31709405ff..01652af243f 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -226,4 +226,4 @@ class CTurboOutput { // vector> GetStagePerformances() const { return StagePerformances; } // shared_ptr GetMachinePerformances() const { return MachinePerformances; } void ComputeTurbomachineryPerformance(vector> const primitives); -};s \ No newline at end of file +}; \ No newline at end of file From f60220dc3cb43fb59dadbd31712a9ffdddfdab8b Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 19 Apr 2023 16:56:08 +0100 Subject: [PATCH 05/99] Fixed mass flow rate computation --- Common/include/geometry/CGeometry.hpp | 8 ++ Common/include/geometry/CPhysicalGeometry.hpp | 8 ++ Common/src/geometry/CPhysicalGeometry.cpp | 16 ++++ SU2_CFD/include/interfaces/CInterface.hpp | 9 --- .../interfaces/cfd/CMixingPlaneInterface.hpp | 8 -- SU2_CFD/src/drivers/CDriver.cpp | 80 +------------------ SU2_CFD/src/drivers/CMultizoneDriver.cpp | 7 +- SU2_CFD/src/drivers/CSinglezoneDriver.cpp | 2 - SU2_CFD/src/interfaces/CInterface.cpp | 10 --- .../interfaces/cfd/CMixingPlaneInterface.cpp | 15 ---- SU2_CFD/src/iteration/CFluidIteration.cpp | 4 + 11 files changed, 39 insertions(+), 128 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 22280ddf04f..49b56a4347b 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -783,6 +783,14 @@ class CGeometry { */ inline virtual void GatherInOutAverageValues(CConfig* config, bool allocate) {} + /*! + * \brief Store all the turboperformance in the solver in ZONE_0. + * \param[in] donor_geometry - Solution from the donor mesh. + * \param[in] target_geometry - Solution from the target mesh. + * \param[in] donorZone - counter of the donor solution + */ + inline virtual void SetAvgTurboGeoValues(const CConfig *donor_config, CGeometry *donor_geometry, unsigned short donorZone) {}; + /*! * \brief Set max length. * \param[in] config - Definition of the particular problem. diff --git a/Common/include/geometry/CPhysicalGeometry.hpp b/Common/include/geometry/CPhysicalGeometry.hpp index 0f881daeea9..d2812857735 100644 --- a/Common/include/geometry/CPhysicalGeometry.hpp +++ b/Common/include/geometry/CPhysicalGeometry.hpp @@ -408,6 +408,14 @@ class CPhysicalGeometry final : public CGeometry { */ void GatherInOutAverageValues(CConfig* config, bool allocate) override; + /*! + * \brief Store all the turboperformance in the solver in ZONE_0. + * \param[in] donor_geometry - Solution from the donor mesh. + * \param[in] target_geometry - Solution from the target mesh. + * \param[in] donorZone - counter of the donor solution + */ + void SetAvgTurboGeoValues(const CConfig *donor_config, CGeometry *donor_geometry, unsigned short donorZone) override; + /*! * \brief Set the edge structure of the control volume. * \param[in] config - Definition of the particular problem. diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index 6ecfb42c140..4d6b9fc0de8 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -6311,6 +6311,22 @@ void CPhysicalGeometry::GatherInOutAverageValues(CConfig* config, bool allocate) delete[] turboNormal; } +void CPhysicalGeometry::SetAvgTurboGeoValues(const CConfig *donor_config, CGeometry *donor_geometry, + unsigned short donorZone) { + + unsigned short iSpan; + unsigned short nSpanMaxAllZones = donor_config->GetnSpanMaxAllZones(); + + for(iSpan = 0; iSpanGetTurboRadiusIn(donorZone, iSpan), donorZone, iSpan); + SetSpanAreaIn(donor_geometry->GetSpanAreaIn(donorZone, iSpan), donorZone, iSpan); + SetTangGridVelIn(donor_geometry->GetTangGridVelIn(donorZone, iSpan), donorZone, iSpan); + SetTurboRadiusOut(donor_geometry->GetTurboRadiusOut(donorZone, iSpan), donorZone, iSpan); + SetSpanAreaOut(donor_geometry->GetSpanAreaOut(donorZone, iSpan), donorZone, iSpan); + SetTangGridVelOut(donor_geometry->GetTangGridVelOut(donorZone, iSpan), donorZone, iSpan); + } +} + void CPhysicalGeometry::SetMaxLength(CConfig* config) { SU2_OMP_FOR_STAT(roundUpDiv(nPointDomain, omp_get_max_threads())) for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { diff --git a/SU2_CFD/include/interfaces/CInterface.hpp b/SU2_CFD/include/interfaces/CInterface.hpp index 49deb7dbe31..983028e8f0f 100644 --- a/SU2_CFD/include/interfaces/CInterface.hpp +++ b/SU2_CFD/include/interfaces/CInterface.hpp @@ -219,13 +219,4 @@ class CInterface { */ void GatherAverageValues(CSolver *donor_solution, CSolver *target_solution, unsigned short donorZone); - /*! - * \brief Exchange Average geometrical value beteween zones . - * \param[in] donor_geometry - Geometry of the donor mesh. - * \param[in] target_geometry - Geometry of the target mesh. - * \param[in] donor_config - Definition of the problem at the donor mesh. - * \param[in] target_config - Definition of the problem at the target mesh. - */ - void GatherAverageTurboGeoValues(CGeometry *donor_geometry, CGeometry *target_geometry, unsigned short donorZone); - }; diff --git a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp index de3fe45340a..59f078778d9 100644 --- a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp +++ b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp @@ -81,14 +81,6 @@ class CMixingPlaneInterface : public CInterface { */ void SetAverageValues(CSolver *donor_solution, CSolver *target_solution, unsigned short donorZone) override; - /*! - * \brief Store all the turboperformance in the solver in ZONE_0. - * \param[in] donor_geometry - Solution from the donor mesh. - * \param[in] target_geometry - Solution from the target mesh. - * \param[in] donorZone - counter of the donor solution - */ - void SetAverageTurboGeoValues(CGeometry *donor_geometry, CGeometry *target_geometry, unsigned short donorZone) override; - }; diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index a00867b5528..5c5a12091dd 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2739,9 +2739,8 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, } //TODO: Fix mass flow - for (iZone = 0; iZone < nZone-1; iZone++) { - if (interface[iZone][nZone-1] != nullptr) - interface[iZone][nZone-1]->GatherAverageTurboGeoValues(geometry[iZone][INST_0][MESH_0],geometry[nZone-1][INST_0][MESH_0], iZone); + for (iZone = 0; iZone < nZone-1; iZone++) { + geometry[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config[iZone],geometry[iZone][INST_0][MESH_0], iZone); } /*--- Transfer number of blade to ZONE_0 to correctly compute turbo performance---*/ @@ -2923,81 +2922,6 @@ void CDriver::PrintDirectResidual(RECORDING kind_recording) { } -void CDriver::RampTurbomachineryValues(unsigned long iter) { - auto* config = config_container[ZONE_0]; - - /*--- ROTATING FRAME Ramp: Compute the updated rotational velocity. ---*/ - if (config->GetGrid_Movement() && config->GetRampRotatingFrame()) { - const unsigned long rampFreq = SU2_TYPE::Int(config->GetRampRotatingFrame_Coeff(1)); - const unsigned long finalRamp_Iter = SU2_TYPE::Int(config->GetRampRotatingFrame_Coeff(2)); - const su2double rot_z_ini = config->GetRampRotatingFrame_Coeff(0); - const bool print = false; - - if(iter % rampFreq == 0 && iter <= finalRamp_Iter){ - - for (auto iZone = 0u; iZone < nZone; iZone++) { - const su2double rot_z_final = config_container[iZone]->GetFinalRotation_Rate_Z(); - - if (fabs(rot_z_final) > 0.0) { - const su2double rot_z = rot_z_ini + iter * ( rot_z_final - rot_z_ini) / finalRamp_Iter; - config_container[iZone]->SetRotation_Rate(2, rot_z); - if (rank == MASTER_NODE && print && iter > 0) { - cout << "\nUpdated rotating frame grid velocities for zone " << iZone << ".\n"; - } - geometry_container[iZone][INST_0][MESH_0]->SetRotationalVelocity(config_container[iZone], print); - geometry_container[iZone][INST_0][MESH_0]->SetShroudVelocity(config_container[iZone]); - } - } - - for (auto iZone = 0u; iZone < nZone; iZone++) { - geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config_container[iZone], iZone, INFLOW, false); - geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config_container[iZone],iZone, OUTFLOW, false); - geometry_container[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config_container[iZone], false); - } - - for (auto iZone = 1u; iZone < nZone; iZone++) { - interface_container[iZone][ZONE_0]->GatherAverageTurboGeoValues( - geometry_container[iZone][INST_0][MESH_0], geometry_container[ZONE_0][INST_0][MESH_0], iZone); - } - } - } - - /*--- Outlet Pressure Ramp: Compute the updated pressure. ---*/ - if (config->GetRampOutletPressure()) { - const unsigned long rampFreq = SU2_TYPE::Int(config->GetRampOutletPressure_Coeff(1)); - const unsigned long finalRamp_Iter = SU2_TYPE::Int(config->GetRampOutletPressure_Coeff(2)); - const su2double outPres_ini = config->GetRampOutletPressure_Coeff(0); - const su2double outPres_final = config->GetFinalOutletPressure(); - - if (iter % rampFreq == 0 && iter <= finalRamp_Iter) { - const su2double outPres = outPres_ini + iter * (outPres_final - outPres_ini) / finalRamp_Iter; - if (rank == MASTER_NODE) config->SetMonitotOutletPressure(outPres); - - for (auto iZone = 0u; iZone < nZone; iZone++) { - for (auto iMarker = 0; iMarker < config_container[iZone]->GetnMarker_All(); iMarker++) { - const auto KindBC = config_container[iZone]->GetMarker_All_KindBC(iMarker); - const auto Marker_Tag = config_container[iZone]->GetMarker_All_TagBound(iMarker); - unsigned short KindBCOption; - switch (KindBC) { - case RIEMANN_BOUNDARY: - KindBCOption = config_container[iZone]->GetKind_Data_Riemann(Marker_Tag); - if (KindBCOption == STATIC_PRESSURE || KindBCOption == RADIAL_EQUILIBRIUM) { - SU2_MPI::Error("Outlet pressure ramp only implemented for NRBC", CURRENT_FUNCTION); - } - break; - case GILES_BOUNDARY: - KindBCOption = config_container[iZone]->GetKind_Data_Giles(Marker_Tag); - if (KindBCOption == STATIC_PRESSURE || KindBCOption == STATIC_PRESSURE_1D || - KindBCOption == RADIAL_EQUILIBRIUM ) { - config_container[iZone]->SetGiles_Var1(outPres, Marker_Tag); - } - break; - } - } - } - } - } -} CFluidDriver::CFluidDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunicator) : CDriver(confFile, val_nZone, MPICommunicator, false) { Max_Iter = config_container[ZONE_0]->GetnInner_Iter(); diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 714cff62a33..4db751f3379 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -246,11 +246,6 @@ void CMultizoneDriver::Preprocess(unsigned long TimeIter) { } } - /*--- Ramp turbo values for unsteady problems here, otherwise do it over outer iterations. ---*/ - if (config_container[ZONE_0]->GetTime_Domain()) { - RampTurbomachineryValues(TimeIter); - } - SU2_MPI::Barrier(SU2_MPI::GetComm()); /*--- Run a predictor step ---*/ @@ -596,7 +591,7 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar for (donorZone = 0; donorZone < nZone; donorZone++) { if (interface_types[donorZone][targetZone]==MIXING_PLANE) { interface_container[donorZone][targetZone]->GatherAverageValues(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL],solver_container[targetZone][INST_0][MESH_0][FLOW_SOL], donorZone); - interface_container[donorZone][targetZone]->GatherAverageTurboGeoValues(geometry_container[donorZone][INST_0][MESH_0],geometry_container[targetZone][INST_0][MESH_0], donorZone); + geometry_container[targetZone][INST_0][MESH_0]->SetAvgTurboGeoValues(config_container[iZone],geometry_container[iZone][INST_0][MESH_0], iZone); } } diff --git a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp index 3a3518d33ab..32cd7d18482 100644 --- a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp @@ -123,8 +123,6 @@ void CSinglezoneDriver::Preprocess(unsigned long TimeIter) { else config_container[ZONE_0]->SetPhysicalTime(0.0); - /*--- Ramp turbo BCs for this time step. ---*/ - RampTurbomachineryValues(TimeIter); /*--- Set the initial condition for EULER/N-S/RANS ---------------------------------------------*/ if (config_container[ZONE_0]->GetFluidProblem()) { diff --git a/SU2_CFD/src/interfaces/CInterface.cpp b/SU2_CFD/src/interfaces/CInterface.cpp index dc068205324..ea4d1d0bfe3 100644 --- a/SU2_CFD/src/interfaces/CInterface.cpp +++ b/SU2_CFD/src/interfaces/CInterface.cpp @@ -645,13 +645,3 @@ void CInterface::GatherAverageValues(CSolver *donor_solution, CSolver *target_so SetAverageValues(donor_solution, target_solution, donorZone); } - -void CInterface::GatherAverageTurboGeoValues(CGeometry *donor_geometry, CGeometry *target_geometry, - unsigned short donorZone){ - - - /*--- here we made the strong assumption that the mesh zone order - * follows the same order of the turbomachinery markers ---*/ - SetAverageTurboGeoValues(donor_geometry, target_geometry, donorZone); - -} diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index ab7de26be09..d98b61dadeb 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -136,18 +136,3 @@ void CMixingPlaneInterface::SetAverageValues(CSolver *donor_solution, CSolver *t } } - -void CMixingPlaneInterface::SetAverageTurboGeoValues(CGeometry *donor_geometry, CGeometry *target_geometry, - unsigned short donorZone){ - unsigned short iSpan; - - for(iSpan = 0; iSpanSetTurboRadiusIn(donor_geometry->GetTurboRadiusIn(donorZone, iSpan), donorZone, iSpan); - target_geometry->SetSpanAreaIn(donor_geometry->GetSpanAreaIn(donorZone, iSpan), donorZone, iSpan); - target_geometry->SetTangGridVelIn(donor_geometry->GetTangGridVelIn(donorZone, iSpan), donorZone, iSpan); - target_geometry->SetTurboRadiusOut(donor_geometry->GetTurboRadiusOut(donorZone, iSpan), donorZone, iSpan); - target_geometry->SetSpanAreaOut(donor_geometry->GetSpanAreaOut(donorZone, iSpan), donorZone, iSpan); - target_geometry->SetTangGridVelOut(donor_geometry->GetTangGridVelOut(donorZone, iSpan), donorZone, iSpan); - } - -} diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index fe0d1dfd374..cfc04c7eac8 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -281,6 +281,10 @@ void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** c geometry_container[iZone][INST_0][MESH_0]->SetAvgTurboValue(config_container[iZone],iZone, OUTFLOW, false); geometry_container[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config_container[iZone], false); } + + for (auto iZone = 0u; iZone < nZone-1; iZone++) { + geometry_container[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config_container[iZone],geometry_container[iZone][INST_0][MESH_0], iZone); + } } } From 6f1e09b615e2c37ea5500811e3f9592d7fca06c2 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 20 Apr 2023 09:00:04 +0100 Subject: [PATCH 06/99] Some tidying and build warning fixes --- SU2_CFD/include/output/CTurboOutput.hpp | 4 +++- SU2_CFD/src/drivers/CDriver.cpp | 3 --- SU2_CFD/src/iteration/CFluidIteration.cpp | 2 +- SU2_CFD/src/output/CFlowCompOutput.cpp | 3 --- SU2_CFD/src/output/CTurboOutput.cpp | 2 -- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp index 01652af243f..5471524658d 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -123,7 +123,7 @@ class CTurbomachineryState { su2double Norm(vector const& u) const { su2double accum = 0.; - for (int i = 0; i < u.size(); ++i) { + for (auto i = 0u; i < u.size(); ++i) { accum += u[i] * u[i]; } return sqrt(accum); @@ -141,6 +141,8 @@ class CTurbomachineryBladePerformance { CTurbomachineryBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, su2double areaOut, su2double radiusOut); + virtual ~CTurbomachineryBladePerformance() = default; + virtual void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates& primitives){}; const CTurbomachineryState& GetInletState() { return InletState; } diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 5c5a12091dd..4ef240b2f3c 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2462,9 +2462,6 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet const bool fluid_donor = config[donor]->GetFluidProblem(); const bool structural_donor = config[donor]->GetStructuralProblem(); - /*--- Turbomachinery Bool for MIXING PLANE ---*/ - const bool turbo = config[donor]->GetBoolTurbomachinery(); - /*--- Initialize the appropriate transfer strategy. ---*/ if (rank == MASTER_NODE) cout << " Transferring "; diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index cfc04c7eac8..8175b9ec92b 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -282,7 +282,7 @@ void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** c geometry_container[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config_container[iZone], false); } - for (auto iZone = 0u; iZone < nZone-1; iZone++) { + for (auto iZone = 0; iZone < nZone-1; iZone++) { geometry_container[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config_container[iZone],geometry_container[iZone][INST_0][MESH_0], iZone); } } diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 87c2f27a6c2..1098fc07eff 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -522,9 +522,6 @@ void CFlowCompOutput::SetTurboMultiZonePerformance_Output(CTurbomachineryStagePe std::shared_ptr TurboPerf, CConfig *config) { - auto nZone = config->GetnZone(); - unsigned short iStage, iZone; - auto nSpan = config->GetnSpanWiseSections(); stringstream TurboMZPerf; PrintingToolbox::CTablePrinter TurboInOut(&TurboMZPerf); diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index 634adf1a145..68208bed37e 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -182,7 +182,6 @@ CTurboOutput::CTurboOutput(const CConfig& config, CFluidModel& fluidModel) { unsigned short nBladesRow = config.GetnMarker_Turbomachinery(); unsigned short nDim = geometry.GetnDim(); - unsigned short nStages = SU2_TYPE::Int(nBladesRow / 2); for (unsigned short iBladeRow = 0; iBladeRow < nBladesRow; iBladeRow++) { vector > bladeSpanPerformances; @@ -193,7 +192,6 @@ CTurboOutput::CTurboOutput(const CConfig& config, su2double areaOut = geometry.GetSpanAreaOut(iBladeRow, iSpan); su2double radiusIn = geometry.GetTurboRadiusIn(iBladeRow, iSpan); su2double radiusOut = geometry.GetTurboRadiusOut(iBladeRow, iSpan); - // std::cout << "Area In " << areaIn << " Area Out " << areaOut << " blade row " << iBladeRow < Date: Thu, 20 Apr 2023 10:01:51 +0100 Subject: [PATCH 07/99] format changes --- Common/include/geometry/CGeometry.hpp | 3 +- Common/include/geometry/CPhysicalGeometry.hpp | 2 +- Common/src/geometry/CPhysicalGeometry.cpp | 7 +- SU2_CFD/src/output/CTurboOutput.cpp | 223 ++++++++---------- 4 files changed, 105 insertions(+), 130 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 49b56a4347b..e066b3f6139 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -789,7 +789,8 @@ class CGeometry { * \param[in] target_geometry - Solution from the target mesh. * \param[in] donorZone - counter of the donor solution */ - inline virtual void SetAvgTurboGeoValues(const CConfig *donor_config, CGeometry *donor_geometry, unsigned short donorZone) {}; + inline virtual void SetAvgTurboGeoValues(const CConfig* donor_config, CGeometry* donor_geometry, + unsigned short donorZone){}; /*! * \brief Set max length. diff --git a/Common/include/geometry/CPhysicalGeometry.hpp b/Common/include/geometry/CPhysicalGeometry.hpp index d2812857735..12d70a0f5c2 100644 --- a/Common/include/geometry/CPhysicalGeometry.hpp +++ b/Common/include/geometry/CPhysicalGeometry.hpp @@ -414,7 +414,7 @@ class CPhysicalGeometry final : public CGeometry { * \param[in] target_geometry - Solution from the target mesh. * \param[in] donorZone - counter of the donor solution */ - void SetAvgTurboGeoValues(const CConfig *donor_config, CGeometry *donor_geometry, unsigned short donorZone) override; + void SetAvgTurboGeoValues(const CConfig* donor_config, CGeometry* donor_geometry, unsigned short donorZone) override; /*! * \brief Set the edge structure of the control volume. diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index 4d6b9fc0de8..d9a93e66e4b 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -6311,13 +6311,12 @@ void CPhysicalGeometry::GatherInOutAverageValues(CConfig* config, bool allocate) delete[] turboNormal; } -void CPhysicalGeometry::SetAvgTurboGeoValues(const CConfig *donor_config, CGeometry *donor_geometry, - unsigned short donorZone) { - +void CPhysicalGeometry::SetAvgTurboGeoValues(const CConfig* donor_config, CGeometry* donor_geometry, + unsigned short donorZone) { unsigned short iSpan; unsigned short nSpanMaxAllZones = donor_config->GetnSpanMaxAllZones(); - for(iSpan = 0; iSpanGetTurboRadiusIn(donorZone, iSpan), donorZone, iSpan); SetSpanAreaIn(donor_geometry->GetSpanAreaIn(donorZone, iSpan), donorZone, iSpan); SetTangGridVelIn(donor_geometry->GetTangGridVelIn(donorZone, iSpan), donorZone, iSpan); diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index 68208bed37e..fde9360eeb9 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -27,37 +27,35 @@ #include "../../include/output/CTurboOutput.hpp" - -CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState() { - Density = Pressure = TangVelocity = 0.0; -} -CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState(vector TurboPrimitive, - unsigned short nDim, - su2double tangVel) : Density(TurboPrimitive[0]), Pressure(TurboPrimitive[1]), TangVelocity(tangVel) { +CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState() { Density = Pressure = TangVelocity = 0.0; } +CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState(vector TurboPrimitive, unsigned short nDim, + su2double tangVel) + : Density(TurboPrimitive[0]), Pressure(TurboPrimitive[1]), TangVelocity(tangVel) { // Velocity.assign(TurboPrimitive+2, TurboPrimitive + nDim+2 ); - Velocity = {TurboPrimitive.begin()+2, TurboPrimitive.end()}; + Velocity = {TurboPrimitive.begin() + 2, TurboPrimitive.end()}; } -CTurbomachineryCombinedPrimitiveStates::CTurbomachineryCombinedPrimitiveStates(const CTurbomachineryPrimitiveState& inletPrimitiveState, - const CTurbomachineryPrimitiveState& outletPrimitiveState) : InletPrimitiveState(inletPrimitiveState), OutletPrimitiveState(outletPrimitiveState){} +CTurbomachineryCombinedPrimitiveStates::CTurbomachineryCombinedPrimitiveStates( + const CTurbomachineryPrimitiveState& inletPrimitiveState, const CTurbomachineryPrimitiveState& outletPrimitiveState) + : InletPrimitiveState(inletPrimitiveState), OutletPrimitiveState(outletPrimitiveState) {} -CTurbomachineryState::CTurbomachineryState(){ +CTurbomachineryState::CTurbomachineryState() { Density = Pressure = Entropy = Enthalpy = Temperature = TotalTemperature = TotalPressure = TotalEnthalpy = 0.0; AbsFlowAngle = FlowAngle = MassFlow = Rothalpy = TotalRelPressure = 0.0; Area = Radius = 0.0; } -CTurbomachineryState::CTurbomachineryState(unsigned short nDim, su2double area, su2double radius) : CTurbomachineryState() { - generate_n(back_inserter(Velocity),nDim, [] {return 0.0;}); - generate_n(back_inserter(RelVelocity),nDim, [] {return 0.0;}); - generate_n(back_inserter(Mach),nDim, [] {return 0.0;}); - generate_n(back_inserter(RelMach),nDim, [] {return 0.0;}); +CTurbomachineryState::CTurbomachineryState(unsigned short nDim, su2double area, su2double radius) + : CTurbomachineryState() { + generate_n(back_inserter(Velocity), nDim, [] { return 0.0; }); + generate_n(back_inserter(RelVelocity), nDim, [] { return 0.0; }); + generate_n(back_inserter(Mach), nDim, [] { return 0.0; }); + generate_n(back_inserter(RelMach), nDim, [] { return 0.0; }); Area = area; Radius = radius; } -void CTurbomachineryState::ComputeState(CFluidModel& fluidModel, const CTurbomachineryPrimitiveState &primitiveState) { - +void CTurbomachineryState::ComputeState(CFluidModel& fluidModel, const CTurbomachineryPrimitiveState& primitiveState) { /*--- Assign new primitive values ---*/ Density = primitiveState.GetDensity(); Pressure = primitiveState.GetPressure(); @@ -81,7 +79,7 @@ void CTurbomachineryState::ComputeState(CFluidModel& fluidModel, const CTurbomac MassFlow = Density * Velocity[0] * Area; AbsFlowAngle = atan(Velocity[1] / Velocity[0]); Mach.assign(Velocity.begin(), Velocity.end()); - std::for_each(Mach.begin(), Mach.end(), [&](su2double &el) { el /= soundSpeed; }); + std::for_each(Mach.begin(), Mach.end(), [&](su2double& el) { el /= soundSpeed; }); /*--- Compute relative kinematic quantities ---*/ su2double tangVel2 = tangVel * tangVel; @@ -90,7 +88,7 @@ void CTurbomachineryState::ComputeState(CFluidModel& fluidModel, const CTurbomac su2double relVel2 = GetRelVelocityValue(); FlowAngle = atan(RelVelocity[1] / RelVelocity[0]); RelMach.assign(RelVelocity.begin(), RelVelocity.end()); - std::for_each(RelMach.begin(), RelMach.end(), [&](su2double &el) { el /= soundSpeed; }); + std::for_each(RelMach.begin(), RelMach.end(), [&](su2double& el) { el /= soundSpeed; }); /*--- Compute total relative TD quantities ---*/ Rothalpy = Enthalpy + 0.5 * relVel2 - 0.5 * tangVel2; @@ -99,29 +97,21 @@ void CTurbomachineryState::ComputeState(CFluidModel& fluidModel, const CTurbomac /*--- Compute isentropic quantities ---*/ fluidModel.SetTDState_Ps(Pressure, Entropy); - } -CTurbomachineryBladePerformance::CTurbomachineryBladePerformance(CFluidModel& fluidModel, - unsigned short nDim, - su2double areaIn, - su2double radiusIn, - su2double areaOut, - su2double radiusOut) : FluidModel(fluidModel) { - InletState = CTurbomachineryState(nDim, areaIn, radiusIn); - OutletState = CTurbomachineryState(nDim, areaOut,radiusOut); +CTurbomachineryBladePerformance::CTurbomachineryBladePerformance(CFluidModel& fluidModel, unsigned short nDim, + su2double areaIn, su2double radiusIn, + su2double areaOut, su2double radiusOut) + : FluidModel(fluidModel) { + InletState = CTurbomachineryState(nDim, areaIn, radiusIn); + OutletState = CTurbomachineryState(nDim, areaOut, radiusOut); } +CTurbineBladePerformance::CTurbineBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, + su2double radiusIn, su2double areaOut, su2double radiusOut) + : CTurbomachineryBladePerformance(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut) {} -CTurbineBladePerformance::CTurbineBladePerformance(CFluidModel& fluidModel, - unsigned short nDim, - su2double areaIn, - su2double radiusIn, - su2double areaOut, - su2double radiusOut) : CTurbomachineryBladePerformance(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut){} - -void CTurbineBladePerformance::ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) { - +void CTurbineBladePerformance::ComputePerformance(const CTurbomachineryCombinedPrimitiveStates& primitives) { /*--- Compute Inlet and Outlet state ---*/ InletState.ComputeState(FluidModel, primitives.GetInletPrimitiveState()); OutletState.ComputeState(FluidModel, primitives.GetOutletPrimitiveState()); @@ -133,21 +123,18 @@ void CTurbineBladePerformance::ComputePerformance(const CTurbomachineryCombinedP su2double relVelOutIs2 = 2 * (OutletState.GetRothalpy() - enthalpyOutIs) + tangVel * tangVel; /*--- Compute performance ---*/ - EntropyGen = (OutletState.GetEntropy() - InletState.GetEntropy()); // / abs(InletState.GetEntropy() + 1); + EntropyGen = (OutletState.GetEntropy() - InletState.GetEntropy()); // / abs(InletState.GetEntropy() + 1); EulerianWork = InletState.GetTotalEnthalpy() - OutletState.GetTotalEnthalpy(); TotalPressureLoss = (InletState.GetTotalRelPressure() - OutletState.GetTotalRelPressure()) / (OutletState.GetTotalRelPressure() - OutletState.GetPressure()); KineticEnergyLoss = 2 * (OutletState.GetEnthalpy() - enthalpyOutIs) / relVelOutIs2; } -CCompressorBladePerformance::CCompressorBladePerformance(CFluidModel& fluidModel, - unsigned short nDim, - su2double areaIn, - su2double radiusIn, - su2double areaOut, - su2double radiusOut) : CTurbomachineryBladePerformance(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut){} +CCompressorBladePerformance::CCompressorBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, + su2double radiusIn, su2double areaOut, su2double radiusOut) + : CTurbomachineryBladePerformance(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut) {} -void CCompressorBladePerformance::ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) { +void CCompressorBladePerformance::ComputePerformance(const CTurbomachineryCombinedPrimitiveStates& primitives) { /*--- Compute Inlet and Outlet state ---*/ InletState.ComputeState(FluidModel, primitives.GetInletPrimitiveState()); OutletState.ComputeState(FluidModel, primitives.GetOutletPrimitiveState()); @@ -159,68 +146,60 @@ void CCompressorBladePerformance::ComputePerformance(const CTurbomachineryCombin su2double relVelOutIs2 = 2 * (OutletState.GetRothalpy() - enthalpyOutIs) + tangVel * tangVel; /*--- Compute performance ---*/ - EntropyGen = (OutletState.GetEntropy() - InletState.GetEntropy()); // / abs(InletState.GetEntropy() + 1); + EntropyGen = (OutletState.GetEntropy() - InletState.GetEntropy()); // / abs(InletState.GetEntropy() + 1); EulerianWork = OutletState.GetTotalEnthalpy() - InletState.GetTotalEnthalpy(); TotalPressureLoss = (InletState.GetTotalRelPressure() - OutletState.GetTotalRelPressure()) / (InletState.GetTotalRelPressure() - InletState.GetPressure()); KineticEnergyLoss = 2 * (OutletState.GetEnthalpy() - enthalpyOutIs) / relVelOutIs2; } -CPropellorBladePerformance::CPropellorBladePerformance(CFluidModel& fluidModel, - unsigned short nDim, - su2double areaIn, - su2double radiusIn, - su2double areaOut, - su2double radiusOut) : CTurbomachineryBladePerformance(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut){} +CPropellorBladePerformance::CPropellorBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, + su2double radiusIn, su2double areaOut, su2double radiusOut) + : CTurbomachineryBladePerformance(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut) {} -void CPropellorBladePerformance::ComputePerformance(const CTurbomachineryCombinedPrimitiveStates &primitives) { +void CPropellorBladePerformance::ComputePerformance(const CTurbomachineryCombinedPrimitiveStates& primitives) { // TODO: to be implemented } -CTurboOutput::CTurboOutput(const CConfig& config, - const CGeometry& geometry, - CFluidModel& fluidModel) { +CTurboOutput::CTurboOutput(const CConfig& config, const CGeometry& geometry, CFluidModel& fluidModel) { unsigned short nBladesRow = config.GetnMarker_Turbomachinery(); unsigned short nDim = geometry.GetnDim(); for (unsigned short iBladeRow = 0; iBladeRow < nBladesRow; iBladeRow++) { - vector > bladeSpanPerformances; + vector> bladeSpanPerformances; unsigned short nSpan = config.GetnSpanWiseSections(); for (unsigned short iSpan = 0; iSpan < nSpan + 1; iSpan++) { - su2double areaIn = geometry.GetSpanAreaIn(iBladeRow, iSpan); su2double areaOut = geometry.GetSpanAreaOut(iBladeRow, iSpan); su2double radiusIn = geometry.GetTurboRadiusIn(iBladeRow, iSpan); su2double radiusOut = geometry.GetTurboRadiusOut(iBladeRow, iSpan); // TODO: I have a feeling this should not be in such a for loop, to be discussed with Salvo (Nitish) - SU2_OMP_PARALLEL - { + SU2_OMP_PARALLEL { const int thread = omp_get_thread_num(); - /* Switch between the Turbomachinery Performance Kind */ - // TODO: This needs to be fixed - switch (config.GetKind_TurboPerf(iBladeRow)) { - - case TURBO_PERF_KIND::TURBINE: - bladeSpanPerformances.push_back(make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, - radiusOut)); - break; - - case TURBO_PERF_KIND::COMPRESSOR: - bladeSpanPerformances.push_back(make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, - radiusOut)); - break; - - case TURBO_PERF_KIND::PROPELLOR: - bladeSpanPerformances.push_back(make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, - radiusOut)); - break; - - default: - bladeSpanPerformances.push_back(make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, - radiusOut)); - break; + /* Switch between the Turbomachinery Performance Kind */ + // TODO: This needs to be fixed + switch (config.GetKind_TurboPerf(iBladeRow)) { + case TURBO_PERF_KIND::TURBINE: + bladeSpanPerformances.push_back( + make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); + break; + + case TURBO_PERF_KIND::COMPRESSOR: + bladeSpanPerformances.push_back( + make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); + break; + + case TURBO_PERF_KIND::PROPELLOR: + bladeSpanPerformances.push_back( + make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); + break; + + default: + bladeSpanPerformances.push_back( + make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); + break; } } } @@ -229,75 +208,71 @@ CTurboOutput::CTurboOutput(const CConfig& config, } void CTurboOutput::ComputeTurbomachineryPerformance( - vector > const bladesPrimitives) { - for(unsigned i = 0; i < BladesPerformances.size(); ++i) { + vector> const bladesPrimitives) { + for (unsigned i = 0; i < BladesPerformances.size(); ++i) { ComputePerBlade(BladesPerformances[i], bladesPrimitives[i]); } } -void CTurboOutput::ComputePerBlade( - vector > const bladePerformances, - vector const bladePrimitives) { - for(unsigned i = 0; i < bladePerformances.size(); ++i) { +void CTurboOutput::ComputePerBlade(vector> const bladePerformances, + vector const bladePrimitives) { + for (unsigned i = 0; i < bladePerformances.size(); ++i) { ComputePerSpan(bladePerformances[i], bladePrimitives[i]); } } -void CTurboOutput::ComputePerSpan(shared_ptr const spanPerformances, - const CTurbomachineryCombinedPrimitiveStates &spanPrimitives) { +void CTurboOutput::ComputePerSpan(shared_ptr const spanPerformances, + const CTurbomachineryCombinedPrimitiveStates& spanPrimitives) { spanPerformances->ComputePerformance(spanPrimitives); } -CTurbomachineryStagePerformance::CTurbomachineryStagePerformance(CFluidModel& fluid) : fluidModel(fluid) { - -} - -void CTurbomachineryStagePerformance::ComputePerformanceStage(CTurbomachineryState InState, CTurbomachineryState OutState, const CConfig* config) { +CTurbomachineryStagePerformance::CTurbomachineryStagePerformance(CFluidModel& fluid) : fluidModel(fluid) {} +void CTurbomachineryStagePerformance::ComputePerformanceStage(CTurbomachineryState InState, + CTurbomachineryState OutState, const CConfig* config) { switch (config->GetKind_TurboPerf(ZONE_0)) { - case TURBO_PERF_KIND::TURBINE: - ComputeTurbineStagePerformance(InState, OutState); - break; + case TURBO_PERF_KIND::TURBINE: + ComputeTurbineStagePerformance(InState, OutState); + break; - case TURBO_PERF_KIND::COMPRESSOR: - ComputeCompressorStagePerformance(InState, OutState); - break; + case TURBO_PERF_KIND::COMPRESSOR: + ComputeCompressorStagePerformance(InState, OutState); + break; - default: - ComputeTurbineStagePerformance(InState, OutState); - break; + default: + ComputeTurbineStagePerformance(InState, OutState); + break; } } -void CTurbomachineryStagePerformance::ComputeTurbineStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState) { - - /*--- Compute isentropic Outflow quantities ---*/ +void CTurbomachineryStagePerformance::ComputeTurbineStagePerformance(CTurbomachineryState InState, + CTurbomachineryState OutState) { + /*--- Compute isentropic Outflow quantities ---*/ fluidModel.SetTDState_Ps(OutState.GetPressure(), InState.GetEntropy()); su2double enthalpyOutIs = fluidModel.GetStaticEnergy() + OutState.GetPressure() / fluidModel.GetDensity(); - su2double totEnthalpyOutIs = enthalpyOutIs + 0.5*OutState.GetVelocityValue()*OutState.GetVelocityValue(); + su2double totEnthalpyOutIs = enthalpyOutIs + 0.5 * OutState.GetVelocityValue() * OutState.GetVelocityValue(); /*--- Compute turbine stage performance ---*/ - NormEntropyGen = (OutState.GetEntropy() - InState.GetEntropy())/InState.GetEntropy(); + NormEntropyGen = (OutState.GetEntropy() - InState.GetEntropy()) / InState.GetEntropy(); EulerianWork = InState.GetTotalEnthalpy() - OutState.GetTotalEnthalpy(); - TotalStaticEfficiency = EulerianWork/(InState.GetTotalEnthalpy()-enthalpyOutIs); - TotalTotalEfficiency = EulerianWork/(InState.GetTotalEnthalpy()-totEnthalpyOutIs); - TotalStaticPressureRatio = InState.GetTotalPressure()/OutState.GetPressure(); - TotalTotalPressureRatio = InState.GetTotalPressure()/OutState.GetTotalPressure(); + TotalStaticEfficiency = EulerianWork / (InState.GetTotalEnthalpy() - enthalpyOutIs); + TotalTotalEfficiency = EulerianWork / (InState.GetTotalEnthalpy() - totEnthalpyOutIs); + TotalStaticPressureRatio = InState.GetTotalPressure() / OutState.GetPressure(); + TotalTotalPressureRatio = InState.GetTotalPressure() / OutState.GetTotalPressure(); } -void CTurbomachineryStagePerformance::ComputeCompressorStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState) { - +void CTurbomachineryStagePerformance::ComputeCompressorStagePerformance(CTurbomachineryState InState, + CTurbomachineryState OutState) { /*--- Compute isentropic Outflow quantities ---*/ fluidModel.SetTDState_Ps(OutState.GetPressure(), InState.GetEntropy()); su2double enthalpyOutIs = fluidModel.GetStaticEnergy() + OutState.GetPressure() / fluidModel.GetDensity(); - su2double totEnthalpyOutIs = enthalpyOutIs + 0.5*OutState.GetVelocityValue()*OutState.GetVelocityValue(); + su2double totEnthalpyOutIs = enthalpyOutIs + 0.5 * OutState.GetVelocityValue() * OutState.GetVelocityValue(); /*--- Compute compressor stage performance ---*/ - NormEntropyGen = (OutState.GetEntropy() - InState.GetEntropy())/InState.GetEntropy(); + NormEntropyGen = (OutState.GetEntropy() - InState.GetEntropy()) / InState.GetEntropy(); EulerianWork = OutState.GetTotalEnthalpy() - InState.GetTotalEnthalpy(); - TotalStaticEfficiency = (enthalpyOutIs-InState.GetTotalEnthalpy())/EulerianWork; - TotalTotalEfficiency = (totEnthalpyOutIs-InState.GetTotalEnthalpy())/EulerianWork; - TotalStaticPressureRatio = OutState.GetPressure()/InState.GetTotalPressure(); - TotalTotalPressureRatio = OutState.GetTotalPressure()/InState.GetTotalPressure(); - + TotalStaticEfficiency = (enthalpyOutIs - InState.GetTotalEnthalpy()) / EulerianWork; + TotalTotalEfficiency = (totEnthalpyOutIs - InState.GetTotalEnthalpy()) / EulerianWork; + TotalStaticPressureRatio = OutState.GetPressure() / InState.GetTotalPressure(); + TotalTotalPressureRatio = OutState.GetTotalPressure() / InState.GetTotalPressure(); } \ No newline at end of file From 9e02f8871a2d7913528d250036a1feea5c1e3e42 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 20 Apr 2023 10:12:47 +0100 Subject: [PATCH 08/99] SU2_OMP_PARALLEL formatting in CTurboOutput --- .clang-format | 2 +- SU2_CFD/src/output/CTurboOutput.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.clang-format b/.clang-format index cb363900eb6..211546de046 100644 --- a/.clang-format +++ b/.clang-format @@ -2,4 +2,4 @@ BasedOnStyle: Google PointerAlignment: Left DerivePointerAlignment: false ColumnLimit: 120 -SortIncludes: Never +SortIncludes: false diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index fde9360eeb9..b9d85685b64 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -26,6 +26,7 @@ */ #include "../../include/output/CTurboOutput.hpp" +#include "Common/include/parallelization/omp_structure.hpp" CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState() { Density = Pressure = TangVelocity = 0.0; } CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState(vector TurboPrimitive, unsigned short nDim, @@ -176,7 +177,7 @@ CTurboOutput::CTurboOutput(const CConfig& config, const CGeometry& geometry, CFl // TODO: I have a feeling this should not be in such a for loop, to be discussed with Salvo (Nitish) SU2_OMP_PARALLEL { - const int thread = omp_get_thread_num(); + // const int thread = omp_get_thread_num(); /* Switch between the Turbomachinery Performance Kind */ // TODO: This needs to be fixed @@ -202,6 +203,7 @@ CTurboOutput::CTurboOutput(const CConfig& config, const CGeometry& geometry, CFl break; } } + END_SU2_OMP_PARALLEL } BladesPerformances.push_back(bladeSpanPerformances); } From 42f05a1dd0b1c9bdf5878d922a8ce4eb46125c7a Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 20 Apr 2023 10:43:41 +0100 Subject: [PATCH 09/99] Removed vscode auto addition --- SU2_CFD/src/output/CTurboOutput.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index b9d85685b64..c6b1bc5326f 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -26,7 +26,6 @@ */ #include "../../include/output/CTurboOutput.hpp" -#include "Common/include/parallelization/omp_structure.hpp" CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState() { Density = Pressure = TangVelocity = 0.0; } CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState(vector TurboPrimitive, unsigned short nDim, From b94ada373420aee6e71c18a98888ef2a3c8610c8 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 20 Apr 2023 11:39:04 +0100 Subject: [PATCH 10/99] Updated transonic stator test case to fix reg test --- .../transonic_stator_2D/transonic_stator_restart.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg index 87c0f8abaa8..897fab717be 100644 --- a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg +++ b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg @@ -75,6 +75,7 @@ SPATIAL_FOURIER= YES %---------------------------- TURBOMACHINERY SIMULATION -----------------------------% % TURBOMACHINERY_KIND = AXIAL +TURBO_PERF_KIND = TURBINE RAMP_OUTLET_PRESSURE= NO RAMP_OUTLET_PRESSURE_COEFF= (700000.0, 10.0, 500) AVERAGE_PROCESS_KIND= MIXEDOUT From 0fa99f36a03791a0bf50e9b1c279e911235413c8 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 20 Apr 2023 12:37:31 +0100 Subject: [PATCH 11/99] updated all turbo cases --- TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg | 1 + TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg | 1 + TestCases/turbomachinery/centrifugal_blade/centrifugal_blade.cfg | 1 + TestCases/turbomachinery/centrifugal_stage/centrifugal_stage.cfg | 1 + 4 files changed, 4 insertions(+) diff --git a/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg b/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg index a766bc072b0..2e93a8f4489 100755 --- a/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg +++ b/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg @@ -75,6 +75,7 @@ SPATIAL_FOURIER= NO %---------------------------- TURBOMACHINERY SIMULATION -----------------------------% % TURBOMACHINERY_KIND= CENTRIPETAL CENTRIPETAL_AXIAL +TURBO_PERF_KIND = TURBINE TURBINE MIXINGPLANE_INTERFACE_KIND= LINEAR_INTERPOLATION TURBULENT_MIXINGPLANE= YES RAMP_OUTLET_PRESSURE= NO diff --git a/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg b/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg index e1b98aee978..2c5cea96d4f 100755 --- a/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg +++ b/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg @@ -78,6 +78,7 @@ SPATIAL_FOURIER= NO %---------------------------- TURBOMACHINERY SIMULATION -----------------------------% % TURBOMACHINERY_KIND= AXIAL AXIAL +TURBO_PERF_KIND = TURBINE TURBINE TURBULENT_MIXINGPLANE= YES RAMP_OUTLET_PRESSURE= NO RAMP_OUTLET_PRESSURE_COEFF= (140000.0, 10.0, 2000) diff --git a/TestCases/turbomachinery/centrifugal_blade/centrifugal_blade.cfg b/TestCases/turbomachinery/centrifugal_blade/centrifugal_blade.cfg index c50f217363e..b7244e8caf6 100755 --- a/TestCases/turbomachinery/centrifugal_blade/centrifugal_blade.cfg +++ b/TestCases/turbomachinery/centrifugal_blade/centrifugal_blade.cfg @@ -68,6 +68,7 @@ MARKER_PLOTTING= ( wall1, wall2 ) % % Marker(s) between turbomachinery performance are evaluated. Use BLADE for single blade, STAGE for stage and TURBINE for a multi-stage. MARKER_TURBO_PERFORMANCE= (inflow, outflow, BLADE) +TURBO_PERF_KIND = TURBINE % % ----------------------- DYNAMIC MESH DEFINITION -----------------------------% % diff --git a/TestCases/turbomachinery/centrifugal_stage/centrifugal_stage.cfg b/TestCases/turbomachinery/centrifugal_stage/centrifugal_stage.cfg index 8c4f5ebc038..f1a681659b6 100755 --- a/TestCases/turbomachinery/centrifugal_stage/centrifugal_stage.cfg +++ b/TestCases/turbomachinery/centrifugal_stage/centrifugal_stage.cfg @@ -68,6 +68,7 @@ MARKER_PERIODIC= (periodic1, periodic2, 0.0, 0.0, 0.0, 0.0, 0.0, 10.29, 0.0, 0.0 MARKER_PLOTTING= ( wall1, wall2 ) MARKER_MONITORING= ( wall1, wall2 ) MARKER_TURBO_PERFORMANCE= (inflow, outflow, STAGE, inflow, outmix, BLADE, inmix, outflow, BLADE) +TURBO_PERF_KIND = TURBINE TURBINE % % ----------------------- DYNAMIC MESH DEFINITION -----------------------------% % From 71b62833495e15c697edc2b6ee40b975405c3ba3 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 24 Apr 2023 13:43:32 +0100 Subject: [PATCH 12/99] Fixed calculation bug for uneven blade spanwisediv --- SU2_CFD/include/iteration/CIteration.hpp | 2 +- SU2_CFD/include/iteration/CTurboIteration.hpp | 2 +- SU2_CFD/include/output/COutput.hpp | 2 +- SU2_CFD/include/output/CTurboOutput.hpp | 2 +- SU2_CFD/include/solvers/CEulerSolver.hpp | 2 +- SU2_CFD/include/solvers/CSolver.hpp | 2 +- SU2_CFD/src/iteration/CFluidIteration.cpp | 7 ++----- SU2_CFD/src/iteration/CTurboIteration.cpp | 7 ++++--- SU2_CFD/src/output/CTurboOutput.cpp | 8 ++++---- SU2_CFD/src/solvers/CEulerSolver.cpp | 4 ++-- 10 files changed, 18 insertions(+), 20 deletions(-) diff --git a/SU2_CFD/include/iteration/CIteration.hpp b/SU2_CFD/include/iteration/CIteration.hpp index 9938e174c5e..7538fc3413b 100644 --- a/SU2_CFD/include/iteration/CIteration.hpp +++ b/SU2_CFD/include/iteration/CIteration.hpp @@ -265,7 +265,7 @@ class CIteration { /*! * \brief Monitors turbo computation (pressure and turbo ramps). */ - virtual void InitTurboPerformance(CGeometry *geometry, CConfig *config, CFluidModel *fluid) {} + virtual void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid) {} /*! * \brief A virtual member. diff --git a/SU2_CFD/include/iteration/CTurboIteration.hpp b/SU2_CFD/include/iteration/CTurboIteration.hpp index 9846d99ffe7..4f23244fab2 100644 --- a/SU2_CFD/include/iteration/CTurboIteration.hpp +++ b/SU2_CFD/include/iteration/CTurboIteration.hpp @@ -67,5 +67,5 @@ class CTurboIteration : public CFluidIteration { /*! * \brief Initialises turboperformance classes. */ - void InitTurboPerformance(CGeometry *geometry, CConfig *config, CFluidModel *fluid) override; + void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid) override; }; diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 1633ba9fc0d..f3bfd94915b 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -48,7 +48,7 @@ inline su2double hypot(const su2double& a, const su2double& b) { } } } -#include "mel.hpp" +#include "../../../externals/mel/mel.hpp" class CGeometry; class CSolver; diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp index 5471524658d..34a18aa2559 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -217,7 +217,7 @@ class CTurboOutput { // vector> StagePerformances; // shared_ptr MachinePerformances; public: - CTurboOutput(const CConfig& config, const CGeometry& geometry, CFluidModel& fluidModel); + CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel); vector>> diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index cb3ae3eb8ca..c101ee3e330 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -1033,7 +1033,7 @@ class CEulerSolver : public CFVMFlowSolverBaseGetBoolTurbomachinery()){ if (val_iZone == config[ZONE_0]->GetnZone()-1) { ComputeTurboPerformance(solver, geometry, config, config[val_iZone]->GetnInner_Iter()); - + output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], TurbomachineryStagePerformance, TurbomachineryPerformance, val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), config[val_iZone]->GetInnerIter()); @@ -227,7 +227,7 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter()); } - + // should this be in an else statement? output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), config[val_iZone]->GetInnerIter()); @@ -350,9 +350,6 @@ void CFluidIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** TurbomachineryPerformance->ComputeTurbomachineryPerformance(bladesPrimitives); auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); - - /*--- Machine Performance (Takes inlet of Zone 0 and Outlet of Zone N-1) ---*/ - // TODO: This still crashed or gives garbage value if there are uneven spans auto InState = TurbomachineryPerformance->GetBladesPerformances().at(ZONE_0).at(nSpan)->GetInletState(); nSpan = config_container[nZone-1]->GetnSpanWiseSections(); auto OutState = TurbomachineryPerformance->GetBladesPerformances().at(nZone-1).at(nSpan)->GetOutletState(); diff --git a/SU2_CFD/src/iteration/CTurboIteration.cpp b/SU2_CFD/src/iteration/CTurboIteration.cpp index bd73894db42..257394d00e9 100644 --- a/SU2_CFD/src/iteration/CTurboIteration.cpp +++ b/SU2_CFD/src/iteration/CTurboIteration.cpp @@ -40,7 +40,8 @@ void CTurboIteration::Preprocess(COutput* output, CIntegration**** integration, solver[val_iZone][val_iInst][MESH_0], geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], OUTFLOW); if (config[val_iZone]->GetBoolTurbomachinery()) { - InitTurboPerformance(geometry[val_iZone][INST_0][MESH_0], config[val_iZone], solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetFluidModel()); + InitTurboPerformance(geometry[val_iZone][INST_0][MESH_0], config, + solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetFluidModel()); } } @@ -59,7 +60,7 @@ void CTurboIteration::Postprocess(COutput* output, CIntegration**** integration, geometry[val_iZone][val_iInst][MESH_0]); } -void CTurboIteration::InitTurboPerformance(CGeometry *geometry, CConfig *config, CFluidModel *fluid){ - TurbomachineryPerformance = std::make_shared(*config, *geometry, *fluid); +void CTurboIteration::InitTurboPerformance(CGeometry* geometry, CConfig** config, CFluidModel* fluid) { + TurbomachineryPerformance = std::make_shared(config, *geometry, *fluid); TurbomachineryStagePerformance = new CTurbomachineryStagePerformance(*fluid); } diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index c6b1bc5326f..bcd2a2e3126 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -161,13 +161,13 @@ void CPropellorBladePerformance::ComputePerformance(const CTurbomachineryCombine // TODO: to be implemented } -CTurboOutput::CTurboOutput(const CConfig& config, const CGeometry& geometry, CFluidModel& fluidModel) { - unsigned short nBladesRow = config.GetnMarker_Turbomachinery(); +CTurboOutput::CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel) { + unsigned short nBladesRow = config[ZONE_0]->GetnMarker_Turbomachinery(); unsigned short nDim = geometry.GetnDim(); for (unsigned short iBladeRow = 0; iBladeRow < nBladesRow; iBladeRow++) { vector> bladeSpanPerformances; - unsigned short nSpan = config.GetnSpanWiseSections(); + unsigned short nSpan = config[iBladeRow]->GetnSpanWiseSections(); for (unsigned short iSpan = 0; iSpan < nSpan + 1; iSpan++) { su2double areaIn = geometry.GetSpanAreaIn(iBladeRow, iSpan); su2double areaOut = geometry.GetSpanAreaOut(iBladeRow, iSpan); @@ -180,7 +180,7 @@ CTurboOutput::CTurboOutput(const CConfig& config, const CGeometry& geometry, CFl /* Switch between the Turbomachinery Performance Kind */ // TODO: This needs to be fixed - switch (config.GetKind_TurboPerf(iBladeRow)) { + switch (config[iBladeRow]->GetKind_TurboPerf(iBladeRow)) { case TURBO_PERF_KIND::TURBINE: bladeSpanPerformances.push_back( make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index af12fbade90..d2ed4871274 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -362,8 +362,8 @@ void CEulerSolver::InstantiateEdgeNumerics(const CSolver* const* solver_containe END_SU2_OMP_SAFE_GLOBAL_ACCESS } -void CEulerSolver::InitTurboPerformance(CGeometry *geometry, CConfig *config){ - TurbomachineryPerformance = std::make_shared(*config, *geometry, *GetFluidModel()); +void CEulerSolver::InitTurboPerformance(CGeometry *geometry, CConfig** config){ + TurbomachineryPerformance = std::make_shared(config, *geometry, *GetFluidModel()); } void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ From f36f430f3c4603d9b523b182beb9e43e5bed37c4 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 25 Apr 2023 11:26:50 +0100 Subject: [PATCH 13/99] Running AD cases --- .../transonic_stator_2D/transonic_stator.cfg | 1 + TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg | 1 + TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg | 1 + .../transonic_stator_2D/transonic_stator_restart.cfg | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg b/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg index 66c520c0a09..1abba990f96 100644 --- a/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg +++ b/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg @@ -75,6 +75,7 @@ SPATIAL_FOURIER= YES %---------------------------- TURBOMACHINERY SIMULATION -----------------------------% % TURBOMACHINERY_KIND = AXIAL +TURBO_PERF_KIND = TURBINE RAMP_OUTLET_PRESSURE= NO RAMP_OUTLET_PRESSURE_COEFF= (700000.0, 10.0, 500) AVERAGE_PROCESS_KIND= MIXEDOUT diff --git a/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg b/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg index 2e93a8f4489..2f37a975ceb 100755 --- a/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg +++ b/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg @@ -67,6 +67,7 @@ MARKER_PERIODIC= (PER1, PER2, 0.0, 0.0, 0.0, 0.0, 0.0, 18.947368421, 0.0, 0.0, 0 % MARKER_TURBOMACHINERY= (INFLOW, OUTMIX, INMIX, OUTFLOW) MARKER_ANALYZE= (OUTFLOW) +MARKER_ZONE_INTERFACE= (OUTMIX, INMIX) MARKER_MIXINGPLANE_INTERFACE= (OUTMIX, INMIX) MARKER_GILES= (INFLOW, TOTAL_CONDITIONS_PT, 413.6E+03, 477.6, 1.0, 0.0, 0.0, 1.0, 0.0, OUTMIX, MIXING_OUT, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.0, INMIX, MIXING_IN, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.0, OUTFLOW, STATIC_PRESSURE_1D, 67.46E+03, 0.0, 0.0, 0.0, 0.0 , 1.0, 0.0) GILES_EXTRA_RELAXFACTOR= (0.05, 0.05) diff --git a/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg b/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg index 2c5cea96d4f..de28c55c14e 100755 --- a/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg +++ b/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg @@ -69,6 +69,7 @@ MARKER_PERIODIC= ( periodic1, periodic2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.04 MARKER_TURBOMACHINERY= (inflow, outmix, inmix, outflow) MARKER_ANALYZE= (outflow) % +MARKER_ZONE_INTERFACE= (outmix, inmix) % Mixing-plane interface markers must be specified to activate the transfer of information between zones MARKER_MIXINGPLANE_INTERFACE= (outmix, inmix) % diff --git a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg index 897fab717be..73bdce2370e 100644 --- a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg +++ b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg @@ -131,7 +131,7 @@ CFL_REDUCTION_TURB= 1.0 % % --------------------------- CONVERGENCE PARAMETERS --------------------------% % -ITER= 10000 +ITER= 21 CONV_RESIDUAL_MINVAL= -12 CONV_STARTITER= 10 CONV_CAUCHY_ELEMS= 100 From 01dc39e5b4d9a680ade69d5e36cc26dc6516635a Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 25 Apr 2023 18:53:21 +0100 Subject: [PATCH 14/99] Update reg tests, fix threading bug --- SU2_CFD/src/output/CTurboOutput.cpp | 49 +++++++++++++---------------- TestCases/hybrid_regression.py | 10 +++--- TestCases/parallel_regression.py | 10 +++--- TestCases/serial_regression.py | 13 ++++---- externals/codi | 2 +- 5 files changed, 40 insertions(+), 44 deletions(-) diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index bcd2a2e3126..46b37dcc2d4 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -174,35 +174,28 @@ CTurboOutput::CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidMo su2double radiusIn = geometry.GetTurboRadiusIn(iBladeRow, iSpan); su2double radiusOut = geometry.GetTurboRadiusOut(iBladeRow, iSpan); - // TODO: I have a feeling this should not be in such a for loop, to be discussed with Salvo (Nitish) - SU2_OMP_PARALLEL { - // const int thread = omp_get_thread_num(); - - /* Switch between the Turbomachinery Performance Kind */ - // TODO: This needs to be fixed - switch (config[iBladeRow]->GetKind_TurboPerf(iBladeRow)) { - case TURBO_PERF_KIND::TURBINE: - bladeSpanPerformances.push_back( - make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); - break; - - case TURBO_PERF_KIND::COMPRESSOR: - bladeSpanPerformances.push_back( - make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); - break; - - case TURBO_PERF_KIND::PROPELLOR: - bladeSpanPerformances.push_back( - make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); - break; - - default: - bladeSpanPerformances.push_back( - make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); - break; - } + /* Switch between the Turbomachinery Performance Kind */ + switch (config[iBladeRow]->GetKind_TurboPerf(iBladeRow)) { + case TURBO_PERF_KIND::TURBINE: + bladeSpanPerformances.push_back( + make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); + break; + + case TURBO_PERF_KIND::COMPRESSOR: + bladeSpanPerformances.push_back( + make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); + break; + + case TURBO_PERF_KIND::PROPELLOR: + bladeSpanPerformances.push_back( + make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); + break; + + default: + bladeSpanPerformances.push_back( + make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); + break; } - END_SU2_OMP_PARALLEL } BladesPerformances.push_back(bladeSpanPerformances); } diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index 04997ff9ba8..77617f49ce1 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -539,7 +539,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-6.986581, -3.096834, -14.849548, -9.102930, -11.787851, -6.266207, 73266, 73266] + Jones_tc_restart.test_vals = [-6.987181, -3.096835, -14.857733, -9.109735, -11.787852, -6.266208, 73266, 73266] test_list.append(Jones_tc_restart) # 2D axial stage @@ -547,8 +547,8 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [1.047244, 1.661126, -2.914064, 2.588061, -2.486924, 3.050785, 106380, 106380] - axial_stage2D.test_vals_aarch64 = [1.047244, 1.661126, -2.914064, 2.588061, -2.486924, 3.050785, 106380, 106380] + axial_stage2D.test_vals = [1.047861, 1.661689, -2.916002, 2.586160, -2.486401, 3.050953, 106380, 106380] + axial_stage2D.test_vals_aarch64 = [1.047861, 1.661689, -2.916002, 2.586160, -2.486401, 3.050953, 106380, 106380] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -556,8 +556,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-7.542642, -6.840866, -6.669194, -1.578593, -6.793009, -0.742574, -471650] - transonic_stator_restart.test_vals_aarch64 = [-7.542642, -6.840866, -6.669194, -1.578593, -6.793009, -0.742574, -471650] + transonic_stator_restart.test_vals = [-7.545560, -6.807355, -6.697808, -1.582515, -6.801911, -0.746306, -471650] + transonic_stator_restart.test_vals_aarch64 = [-7.545560, -6.807355, -6.697808, -1.582515, -6.801911, -0.746306, -471650] test_list.append(transonic_stator_restart) ###################################### diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 95c486de561..7266dd0ccfe 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -987,12 +987,12 @@ def main(): ### Turbomachinery ### ###################################### - # Jones APU Turbocharger restart + # Jones APU Turbocharger restart Jones_tc_restart = TestCase('jones_turbocharger_restart') Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-6.986563, -3.096834, -14.849532, -9.102914, -11.787851, -6.266208, 7.3266e+04, 7.3266e+04] + Jones_tc_restart.test_vals = [-6.987181, -3.096835, -14.857733, -9.109735, -11.787852, -6.266208, 73266, 73266] test_list.append(Jones_tc_restart) # 2D axial stage @@ -1000,7 +1000,8 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [1.047301, 1.661328, -2.913923, 2.588194, -2.486769, 3.050953, 106380, 106380] + axial_stage2D.test_vals = [1.047861, 1.661689, -2.916002, 2.586160, -2.486401, 3.050953, 106380, 106380] + axial_stage2D.test_vals_aarch64 = [1.047861, 1.661689, -2.916002, 2.586160, -2.486401, 3.050953, 106380, 106380] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -1008,7 +1009,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-7.544516, -6.822541, -6.689799, -1.581068, -6.798361, -0.746758, -471650] + transonic_stator_restart.test_vals = [-7.545560, -6.807355, -6.697808, -1.582515, -6.801911, -0.746306, -471650] + transonic_stator_restart.test_vals_aarch64 = [-7.545560, -6.807355, -6.697808, -1.582515, -6.801911, -0.746306, -471650] test_list.append(transonic_stator_restart) ###################################### diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index b7d00c3f3a0..8adde47a16c 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -845,16 +845,15 @@ def main(): ###################################### - ### turbomachinery ### + ### Turbomachinery ### ###################################### - # Jones APU Turbocharger restart + # Jones APU Turbocharger restart Jones_tc_restart = TestCase('jones_turbocharger_restart') Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-6.986563, -3.096834, -14.849532, -9.102914, -11.787851, -6.266208, 7.3266e+04, 7.3266e+04] - Jones_tc_restart.tol = 0.0001 + Jones_tc_restart.test_vals = [-6.987181, -3.096835, -14.857733, -9.109735, -11.787852, -6.266208, 73266, 73266] test_list.append(Jones_tc_restart) # 2D axial stage @@ -862,7 +861,8 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [1.047323, 1.661341, -2.913940, 2.588179, -2.486770, 3.050954, 1.0638e+05, 1.0638e+05] + axial_stage2D.test_vals = [1.047861, 1.661689, -2.916002, 2.586160, -2.486401, 3.050953, 106380, 106380] + axial_stage2D.test_vals_aarch64 = [1.047861, 1.661689, -2.916002, 2.586160, -2.486401, 3.050953, 106380, 106380] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -870,7 +870,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-7.534574, -6.838075, -6.618228, -1.567726, -6.767343, -0.738638, -4.7165e+05] + transonic_stator_restart.test_vals = [-7.545560, -6.807355, -6.697808, -1.582515, -6.801911, -0.746306, -471650] + transonic_stator_restart.test_vals_aarch64 = [-7.545560, -6.807355, -6.697808, -1.582515, -6.801911, -0.746306, -471650] test_list.append(transonic_stator_restart) diff --git a/externals/codi b/externals/codi index 21e4f6e084d..ca5573d50f9 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 21e4f6e084d635e7834ca55dc9d83b667a5aca2b +Subproject commit ca5573d50f9a54ba50d28a8639822a56d556240b From 979b08d9fb85b1fe289b9bbb022ddce696c69b4c Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 26 Apr 2023 15:13:52 +0100 Subject: [PATCH 15/99] Further reg test and formatting updates --- SU2_CFD/include/output/COutput.hpp | 2 +- SU2_CFD/include/solvers/CEulerSolver.hpp | 2 +- SU2_CFD/include/solvers/CSolver.hpp | 13 ++++++------- TestCases/hybrid_regression.py | 8 ++++---- TestCases/serial_regression.py | 8 ++++---- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index f3bfd94915b..1633ba9fc0d 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -48,7 +48,7 @@ inline su2double hypot(const su2double& a, const su2double& b) { } } } -#include "../../../externals/mel/mel.hpp" +#include "mel.hpp" class CGeometry; class CSolver; diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index c101ee3e330..d3ef6fb8c51 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -1055,7 +1055,7 @@ class CEulerSolver : public CFVMFlowSolverBase GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool Inlet) const { return TurboPrimitive; } /*! * \brief virtual member. @@ -4281,13 +4287,6 @@ class CSolver { */ inline virtual bool GetHasHybridParallel() const { return false; } - /*! - * \brief Get Primal variables for turbo performance computation - * iteration can be executed by multiple threads. - * \return returns Density, pressure and TurboVelocity (IN/OUTLET) - */ - virtual vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool Inlet) {return TurboPrimitive;} - /*! * \brief Get values for streamwise periodic flow: delta P, m_dot, inlet T, integrated heat, etc. * \return Struct holding streamwise periodic values. diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index 77617f49ce1..2e1ef5db9e9 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -547,8 +547,8 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [1.047861, 1.661689, -2.916002, 2.586160, -2.486401, 3.050953, 106380, 106380] - axial_stage2D.test_vals_aarch64 = [1.047861, 1.661689, -2.916002, 2.586160, -2.486401, 3.050953, 106380, 106380] + axial_stage2D.test_vals = [1.047801, 1.661487, -2.916144, 2.586026, -2.486555, 3.050786, 106380, 106380] + axial_stage2D.test_vals_aarch64 = [1.047801, 1.661487, -2.916144, 2.586026, -2.486555, 3.050786, 106380, 106380] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -556,8 +556,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-7.545560, -6.807355, -6.697808, -1.582515, -6.801911, -0.746306, -471650] - transonic_stator_restart.test_vals_aarch64 = [-7.545560, -6.807355, -6.697808, -1.582515, -6.801911, -0.746306, -471650] + transonic_stator_restart.test_vals = [-7.543335, -6.834312, -6.673129, -1.579553, -6.796362, -0.743829, -471650] + transonic_stator_restart.test_vals_aarch64 = [-7.543335, -6.834312, -6.673129, -1.579553, -6.796362, -0.743829, -471650] test_list.append(transonic_stator_restart) ###################################### diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 8adde47a16c..7821a9f1a5a 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -861,8 +861,8 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [1.047861, 1.661689, -2.916002, 2.586160, -2.486401, 3.050953, 106380, 106380] - axial_stage2D.test_vals_aarch64 = [1.047861, 1.661689, -2.916002, 2.586160, -2.486401, 3.050953, 106380, 106380] + axial_stage2D.test_vals = [1.047883, 1.661703, -2.916020, 2.586144, -2.486401, 3.050955, 106380, 106380] + axial_stage2D.test_vals_aarch64 = [1.047883, 1.661703, -2.916020, 2.586144, -2.486401, 3.050955, 106380, 106380] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -870,8 +870,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-7.545560, -6.807355, -6.697808, -1.582515, -6.801911, -0.746306, -471650] - transonic_stator_restart.test_vals_aarch64 = [-7.545560, -6.807355, -6.697808, -1.582515, -6.801911, -0.746306, -471650] + transonic_stator_restart.test_vals = [-7.533443, -6.826845, -6.612243, -1.566209, -6.765890, -0.742094, -471650] + transonic_stator_restart.test_vals_aarch64 = [-7.533443, -6.826845, -6.612243, -1.566209, -6.765890, -0.742094, -471650] test_list.append(transonic_stator_restart) From a8b948a515868b2ef3f119da5480124f4d53d464 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 17 May 2023 13:57:34 +0100 Subject: [PATCH 16/99] Updated screen output, addressed some comments --- SU2_CFD/include/solvers/CEulerSolver.hpp | 2 +- SU2_CFD/include/solvers/CSolver.hpp | 2 +- SU2_CFD/src/output/CFlowCompOutput.cpp | 6 +++--- SU2_CFD/src/output/CTurboOutput.cpp | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index d3ef6fb8c51..9c75d062c74 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -1040,7 +1040,7 @@ class CEulerSolver : public CFVMFlowSolverBase GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool INLET) { + inline vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool INLET) override { TurboPrimitive.clear(); if (INLET) { TurboPrimitive.push_back(DensityIn[iBlade][iSpan]); TurboPrimitive.push_back(PressureIn[iBlade][iSpan]); diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index e0e447e1784..fed5667dba6 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -3762,7 +3762,7 @@ class CSolver { * iteration can be executed by multiple threads. * \return returns Density, pressure and TurboVelocity (IN/OUTLET) */ - virtual vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool Inlet) const { return TurboPrimitive; } + virtual vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool Inlet) { return TurboPrimitive; } /*! * \brief virtual member. diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 1098fc07eff..bb75677ac34 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -511,7 +511,7 @@ void CFlowCompOutput::SetTurboPerformance_Output(std::shared_ptr T TurboInOut << "Tangential Velocity " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[1] << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[1]; TurboInOut << "Mass Flow " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMassFlow() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMassFlow(); TurboInOut << "Mach " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMachValue() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMachValue(); - TurboInOut << "Flow Angle " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER; + TurboInOut << "Abs Flow Angle " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER; TurboInOut.PrintFooter(); } cout<GetOutletState().GetMassFlow()); SetHistoryOutputValue("MachIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMachValue()); SetHistoryOutputValue("MachOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMachValue()); - SetHistoryOutputValue("FlowAngleIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER); - SetHistoryOutputValue("FlowAngleOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER); + SetHistoryOutputValue("AbsFlowAngleIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER); + SetHistoryOutputValue("AbsFlowAngleOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER); } SetHistoryOutputValue("EntropyGeneration", TurboStagePerf->GetNormEntropyGen()*100); SetHistoryOutputValue("EulerianWork", TurboStagePerf->GetEulerianWork()); diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index 46b37dcc2d4..485c5f66f2b 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -164,6 +164,7 @@ void CPropellorBladePerformance::ComputePerformance(const CTurbomachineryCombine CTurboOutput::CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel) { unsigned short nBladesRow = config[ZONE_0]->GetnMarker_Turbomachinery(); unsigned short nDim = geometry.GetnDim(); + unsigned short nStages = SU2_TYPE::Int(nBladesRow / 2); for (unsigned short iBladeRow = 0; iBladeRow < nBladesRow; iBladeRow++) { vector> bladeSpanPerformances; @@ -175,7 +176,7 @@ CTurboOutput::CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidMo su2double radiusOut = geometry.GetTurboRadiusOut(iBladeRow, iSpan); /* Switch between the Turbomachinery Performance Kind */ - switch (config[iBladeRow]->GetKind_TurboPerf(iBladeRow)) { + switch (config[ZONE_0]->GetKind_TurboPerf(iBladeRow)) { case TURBO_PERF_KIND::TURBINE: bladeSpanPerformances.push_back( make_shared(fluidModel, nDim, areaIn, radiusIn, areaOut, radiusOut)); From 84f4617a31a41a50716c2de62fc7b9d4ffcc857b Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 17 May 2023 14:09:15 +0100 Subject: [PATCH 17/99] Removed unused var --- SU2_CFD/src/output/CTurboOutput.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index 485c5f66f2b..600a2987501 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -164,7 +164,6 @@ void CPropellorBladePerformance::ComputePerformance(const CTurbomachineryCombine CTurboOutput::CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel) { unsigned short nBladesRow = config[ZONE_0]->GetnMarker_Turbomachinery(); unsigned short nDim = geometry.GetnDim(); - unsigned short nStages = SU2_TYPE::Int(nBladesRow / 2); for (unsigned short iBladeRow = 0; iBladeRow < nBladesRow; iBladeRow++) { vector> bladeSpanPerformances; From 61fe58a772488b79a28538603c8aa3beb3101ba5 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 17 May 2023 17:27:53 +0100 Subject: [PATCH 18/99] Fixed TURBOMACHINERY special folder output --- SU2 | 1 + SU2_CFD/include/output/CFlowCompOutput.hpp | 10 + SU2_CFD/include/output/COutput.hpp | 12 +- SU2_CFD/include/solvers/CEulerSolver.hpp | 2 +- SU2_CFD/include/solvers/CSolver.hpp | 2 +- SU2_CFD/src/iteration/CFluidIteration.cpp | 2 +- SU2_CFD/src/output/CFlowCompOutput.cpp | 264 ++++++++++++++++++++- SU2_CFD/src/output/CFlowOutput.cpp | 4 +- SU2_CFD/src/output/COutput.cpp | 17 +- 9 files changed, 298 insertions(+), 16 deletions(-) create mode 160000 SU2 diff --git a/SU2 b/SU2 new file mode 160000 index 00000000000..84f4617a31a --- /dev/null +++ b/SU2 @@ -0,0 +1 @@ +Subproject commit 84f4617a31a41a50716c2de62fc7b9d4ffcc857b diff --git a/SU2_CFD/include/output/CFlowCompOutput.hpp b/SU2_CFD/include/output/CFlowCompOutput.hpp index e7f38021fa7..d5ece099e11 100644 --- a/SU2_CFD/include/output/CFlowCompOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompOutput.hpp @@ -103,4 +103,14 @@ class CFlowCompOutput final: public CFlowOutput { void LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) override; + + /*! + * \brief Write the kinematic and thermodynamic variables at each spanwise division + * \param[in] TurboPerf - Turboperformance class + * \param[in] geometry - Geometrical definiton of the problem + * \param[in] config - Descripiton of the particular problem + * \param[in] val_iZone - Idientifier of current zone + */ + void WriteTurboSpanwisePerformance(std::shared_ptr TurboPerf, CGeometry *geometry, CConfig **config, + unsigned short val_iZone) override; }; diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 1633ba9fc0d..c68cc98d4bc 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -387,7 +387,7 @@ class COutput { * \param[in] OuterIter - Value of outer iteration index * \param[in] InnerIter - Value of the inner iteration index */ - void SetHistoryOutput(CGeometry *geometry, CSolver **solver_container, CConfig *config, + void SetHistoryOutput(CGeometry *geometry, CSolver **solver_container, CConfig **config, CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, unsigned short val_iZone, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter); @@ -972,6 +972,16 @@ class COutput { inline virtual void LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) {}; + + /*! + * \brief Write the kinematic and thermodynamic variables at each spanwise division + * \param[in] solver - The container hold all solution data + * \param[in] geometry - Geometrical definiton of the problem + * \param[in] config - Descripiton of the particular problem + * \param[in] val_iZone - Idientifier of current zone + */ + inline virtual void WriteTurboSpanwisePerformance(std::shared_ptr TurboPerf, CGeometry *geometry, CConfig **config, + unsigned short val_iZone) {}; /*! * \brief Set the available history output fields diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index d3ef6fb8c51..9c75d062c74 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -1040,7 +1040,7 @@ class CEulerSolver : public CFVMFlowSolverBase GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool INLET) { + inline vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool INLET) override { TurboPrimitive.clear(); if (INLET) { TurboPrimitive.push_back(DensityIn[iBlade][iSpan]); TurboPrimitive.push_back(PressureIn[iBlade][iSpan]); diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index e0e447e1784..fed5667dba6 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -3762,7 +3762,7 @@ class CSolver { * iteration can be executed by multiple threads. * \return returns Density, pressure and TurboVelocity (IN/OUTLET) */ - virtual vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool Inlet) const { return TurboPrimitive; } + virtual vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool Inlet) { return TurboPrimitive; } /*! * \brief virtual member. diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 04d4e88a9cf..880ab026859 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -221,7 +221,7 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe ComputeTurboPerformance(solver, geometry, config, config[val_iZone]->GetnInner_Iter()); output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], - config[val_iZone], TurbomachineryStagePerformance, TurbomachineryPerformance, val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), + config, TurbomachineryStagePerformance, TurbomachineryPerformance, val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), config[val_iZone]->GetInnerIter()); } diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 1098fc07eff..fb63c6a69b0 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -579,8 +579,8 @@ void CFlowCompOutput::LoadTurboHistoryData(CTurbomachineryStagePerformance* Turb SetHistoryOutputValue("MassFlowOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMassFlow()); SetHistoryOutputValue("MachIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMachValue()); SetHistoryOutputValue("MachOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMachValue()); - SetHistoryOutputValue("FlowAngleIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER); - SetHistoryOutputValue("FlowAngleOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER); + SetHistoryOutputValue("AbsFlowAngleIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER); + SetHistoryOutputValue("AbsFlowAngleOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER); } SetHistoryOutputValue("EntropyGeneration", TurboStagePerf->GetNormEntropyGen()*100); SetHistoryOutputValue("EulerianWork", TurboStagePerf->GetEulerianWork()); @@ -590,3 +590,263 @@ void CFlowCompOutput::LoadTurboHistoryData(CTurbomachineryStagePerformance* Turb SetHistoryOutputValue("PressureRatioTT", TurboStagePerf->GetTotalTotalPressureRatio()); } } + +void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr 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) { + auto BladePerformance = TurboPerf->GetBladesPerformances(); + + + /*--- Start of write file turboperformance spanwise ---*/ + if (rank == MASTER_NODE){ + SpanWiseValuesIn = geometry->GetSpanWiseValue(1); + SpanWiseValuesOut = geometry->GetSpanWiseValue(2); + + + + /*--- 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]\""; + // TODO: These values need to be added to turbomachinery state in CTurboOuput + // file.width(30); file << "\"TurbIntensity[-]\""; + // file.width(30); file << "\"Turb2LamViscRatio[-]\""; + // file.width(30); file << "\"NuFactor[-]\""; + file << endl; + + for(iSpan = 0; iSpan < config[val_iZone]->GetnSpanWiseSections(); iSpan++){ + + file.width(30); file << SpanWiseValuesIn[iSpan]; + file.width(15); file << iSpan; + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetPressure()*config[ZONE_0]->GetPressure_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetTotalPressure()*config[ZONE_0]->GetPressure_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetTemperature()*config[ZONE_0]->GetTemperature_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetTotalTemperature()*config[ZONE_0]->GetTemperature_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetTotalEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetDensity()*config[ZONE_0]->GetDensity_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetEntropy()*config[ZONE_0]->GetEnergy_Ref()/config[ZONE_0]->GetTemperature_Ref(); + // TODO: Add the variables back into CTurboOutput + // if(TurbIntensityIn[val_iZone][iSpan] > 1.0){ + // file.width(30); file << TurbIntensityIn [val_iZone][config[ZONE_0]->GetnSpan_iZones(val_iZone)/2]; + // }else{ + // file.width(30); file << TurbIntensityIn [val_iZone][iSpan]; + // } + // file.width(30); file << Turb2LamViscRatioIn [val_iZone][iSpan]; + // file.width(30); file << NuFactorIn [val_iZone][iSpan]; + // file << endl; + } + + 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.width(30); file << "\"TurbIntensity[-]\""; + // file.width(30); file << "\"Turb2LamViscRatio[-]\""; + // file.width(30); file << "\"NuFactor[-]\""; + file << endl; + + + for(iSpan = 0; iSpan < config[val_iZone]->GetnSpanWiseSections(); iSpan++){ + + file.width(30); file << SpanWiseValuesOut[iSpan]; + file.width(15); file << iSpan; + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetPressure()*config[ZONE_0]->GetPressure_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetTotalPressure()*config[ZONE_0]->GetPressure_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetTemperature()*config[ZONE_0]->GetTemperature_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetTotalTemperature()*config[ZONE_0]->GetTemperature_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetTotalEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetDensity()*config[ZONE_0]->GetDensity_Ref(); + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetEntropy()*config[ZONE_0]->GetEnergy_Ref()/config[ZONE_0]->GetTemperature_Ref(); + // if(TurbIntensityOut[val_iZone][iSpan] > 1.0){ + // file.width(30); file << TurbIntensityOut [val_iZone][config[ZONE_0]->GetnSpan_iZones(val_iZone)/2]; + // }else{ + // file.width(30); file << TurbIntensityOut [val_iZone][iSpan]; + // } + // file.width(30); file << Turb2LamViscRatioOut [val_iZone][iSpan]; + // file.width(30); file << NuFactorOut [val_iZone][iSpan]; + // file << endl; + } + + 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[-]\""; + 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]\""; + 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++){ + + file.width(30); file << SpanWiseValuesIn[iSpan]; + file.width(15); file << iSpan; + for (iDim = 0; iDim < 4; iDim++){ + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetMach()[iDim]; + } + for (iDim = 0; iDim < 4; iDim++){ + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref(); + } + // This captures NaNs + if(isnan(BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetAbsFlowAngle())){ + file.width(30); file << "0.0000"; + } + else { + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetAbsFlowAngle()*180.0/PI_NUMBER; + } + if(isnan(BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetFlowAngle())){ + file.width(30); file << "0.0000"; + } + else{ + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->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[-]\""; + 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]\""; + 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++){ + + file.width(30); file << SpanWiseValuesIn[iSpan]; + file.width(15); file << iSpan; + for (iDim = 0; iDim < 4; iDim++){ + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetMach()[iDim]; + } + for (iDim = 0; iDim < 4; iDim++){ + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref(); + } + if(isnan(BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetAbsFlowAngle())){ + file.width(30); file << "0.0000"; + } + else { + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetAbsFlowAngle()*180.0/PI_NUMBER; + } + if(isnan(BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetAbsFlowAngle())){ + file.width(30); file << "0.0000"; + } + else{ + file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetFlowAngle()*180.0/PI_NUMBER; + } + file << endl; + } + + file.close(); + + } +} +} \ No newline at end of file diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 0f72dac2abf..25cdc0410cd 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -3770,8 +3770,8 @@ void CFlowOutput::AddTurboOutput(unsigned short nZone){ AddHistoryOutput("MassFlowOut_" + tag.str(), "MassFlowOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total efficiency " + tag.str(), HistoryFieldType::DEFAULT); AddHistoryOutput("MachIn_" + tag.str(), "MachIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); AddHistoryOutput("MachOut_" + tag.str(), "MachOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("FlowAngleIn_" + tag.str(), "FlowAngleIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("FlowAngleOut_" + tag.str(), "FlowAngleOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("AbsFlowAngleIn_" + tag.str(), "AbsFlowAngleIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("AbsFlowAngleOut_" + tag.str(), "AbsFlowAngleOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag.str(), HistoryFieldType::DEFAULT); } //Adds turbomachinery machine performance variables AddHistoryOutput("EntropyGeneration", "EntropyGen", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 2899c31d4e2..5351f359b6e 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -230,7 +230,7 @@ void COutput::SetHistoryOutput(CGeometry *geometry, void COutput::SetHistoryOutput(CGeometry *geometry, CSolver **solver, - CConfig *config, + CConfig **config, CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, unsigned short val_iZone, @@ -240,21 +240,22 @@ void COutput::SetHistoryOutput(CGeometry *geometry, unsigned long Iter= InnerIter; - if (config->GetMultizone_Problem()) + if (config[ZONE_0]->GetMultizone_Problem()) Iter = OuterIter; /*--- Turbomachinery Performance Screen summary output---*/ if (Iter%100 == 0) { - SetTurboPerformance_Output(TurboPerf, config, TimeIter, OuterIter, InnerIter); - - if (rank == MASTER_NODE) - SetTurboMultiZonePerformance_Output(TurboStagePerf, TurboPerf, config); + SetTurboPerformance_Output(TurboPerf, config[val_iZone], TimeIter, OuterIter, InnerIter); + if (rank == MASTER_NODE) SetTurboMultiZonePerformance_Output(TurboStagePerf, TurboPerf, config[val_iZone]); + for (int iZone = 0; iZone < config[ZONE_0]->GetnZone(); iZone ++){ + WriteTurboSpanwisePerformance(TurboPerf, geometry, config, iZone); + } } /*--- Update turboperformance history file*/ - LoadTurboHistoryData(TurboStagePerf, TurboPerf, config); + LoadTurboHistoryData(TurboStagePerf, TurboPerf, config[val_iZone]); - SetHistoryOutput(geometry, solver, config, TimeIter, OuterIter,InnerIter); + SetHistoryOutput(geometry, solver, config[val_iZone], TimeIter, OuterIter,InnerIter); } From a5bdb92a66716f5fcc02b3f514d67d9009b97b83 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 22 May 2023 16:43:07 +0100 Subject: [PATCH 19/99] Fixed config input for MZ cases --- SU2_CFD/src/output/COutput.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 5351f359b6e..4e3c49f13d2 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -1329,7 +1329,7 @@ void COutput::PreprocessHistoryOutput(CConfig *config, bool wrt){ /*--- Check for consistency and remove fields that are requested but not available --- */ - CheckHistoryOutput(); + CheckHistoryOutput(config->GetnZone()); if (rank == MASTER_NODE && !noWriting){ @@ -1376,7 +1376,7 @@ void COutput::PreprocessMultizoneHistoryOutput(COutput **output, CConfig **confi /*--- Check for consistency and remove fields that are requested but not available --- */ - CheckHistoryOutput(); + CheckHistoryOutput(config[ZONE_0]->GetnZone()); if (rank == MASTER_NODE && !noWriting){ @@ -1418,7 +1418,7 @@ void COutput::PrepareHistoryFile(CConfig *config){ } -void COutput::CheckHistoryOutput() { +void COutput::CheckHistoryOutput(unsigned short nZone) { /*--- Set screen convergence output header and remove unavailable fields ---*/ @@ -1496,6 +1496,18 @@ void COutput::CheckHistoryOutput() { FieldsToRemove.clear(); vector FoundField(nRequestedHistoryFields, false); + /*--- Checks if TURBO_PERF is enabled in config and sets the final zone calculations to be output ---*/ + + for (unsigned short iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++){ + if (requestedHistoryFields[iReqField] == "TURBO_PERF"){ + char buffer [14]; //This makes the assumption the number of zones is 10 or lower + std::string strZones = std::to_string(nZone-1); + char const *valZones = strZones.c_str(); + snprintf(buffer, 14, "TURBO_PERF[%s]", valZones); + requestedHistoryFields[iReqField] = buffer; + } + } + for (const auto& fieldReference : historyOutput_List) { const auto &field = historyOutput_Map.at(fieldReference); for (unsigned short iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++) { From 1e7ca730ab434420d5fa8e6d489a33d1a6971aad Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 22 May 2023 16:43:35 +0100 Subject: [PATCH 20/99] header changes from prior --- SU2_CFD/include/output/COutput.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index c68cc98d4bc..74651c9ad3a 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -763,7 +763,7 @@ class COutput { /*! * \brief CheckHistoryOutput */ - void CheckHistoryOutput(); + void CheckHistoryOutput(unsigned short nZone); /*! * \brief Open the history file and write the header. From 63e4508bcd80359ef1c012ba12c8f873d051733c Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 28 Jun 2023 16:18:16 +0100 Subject: [PATCH 21/99] codi update --- SU2_CFD/src/output/COutput.cpp | 2 +- externals/codi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index edc6f909a6e..664fad76be1 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -1503,7 +1503,7 @@ void COutput::CheckHistoryOutput(unsigned short nZone) { char buffer [14]; //This makes the assumption the number of zones is 10 or lower std::string strZones = std::to_string(nZone-1); char const *valZones = strZones.c_str(); - snprintf(buffer, 14, "TURBO_PERF[%s]", valZones); + auto snpCatch = snprintf(buffer, 14, "TURBO_PERF[%s]", valZones); requestedHistoryFields[iReqField] = buffer; } } diff --git a/externals/codi b/externals/codi index ca5573d50f9..375f51e6e97 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit ca5573d50f9a54ba50d28a8639822a56d556240b +Subproject commit 375f51e6e972515dc594bbadbd2bc694dab2c780 From f5346ff550fccf0f3f448c6129c7aa39818df871 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 28 Jun 2023 16:25:21 +0100 Subject: [PATCH 22/99] Merge branch 'develop' of https://github.com/su2code/SU2 into new_turbo_outputs --- externals/codi | 2 +- externals/opdi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/externals/codi b/externals/codi index 4237fe38c90..375f51e6e97 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 4237fe38c90b83541f699bd84e00c656099b7d18 +Subproject commit 375f51e6e972515dc594bbadbd2bc694dab2c780 diff --git a/externals/opdi b/externals/opdi index 913535c4909..f33b507c24f 160000 --- a/externals/opdi +++ b/externals/opdi @@ -1 +1 @@ -Subproject commit 913535c490989ea9aa654e8c7df41c7e3718a5a2 +Subproject commit f33b507c24f7448d4cf4df16ab5c53ea254b8774 From 3e8ba472217acbc25b99fad22da985ad59226d4e Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Tue, 11 Jul 2023 13:24:32 -0400 Subject: [PATCH 23/99] add basic support for rotation changes --- Common/include/CConfig.hpp | 7 +++++++ SU2_CFD/include/drivers/CDriver.hpp | 1 + SU2_CFD/src/iteration/CIteration.cpp | 13 ++++++++++++- SU2_CFD/src/python_wrapper_structure.cpp | 7 +++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 39ebcf28c01..83d574deb1c 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5946,6 +5946,13 @@ class CConfig { * \return Rotation velocity of the marker. */ su2double GetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerRotation_Rate[3*iMarkerMoving + iDim];} + /*! + * \brief Set the rotation rate of the marker. + * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) + * \param[in] iDim - spatial component + * \return Rotation velocity of the marker. + */ + void SetMarkerRotation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) const { MarkerRotation_Rate[3*iMarkerMoving + iDim] = val;} /*! * \brief Get the pitching rate of the mesh. diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 236c932b630..e6bcd68eb9a 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -536,6 +536,7 @@ class CDriver : public CDriverBase { */ void SetRotationRate(passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); + void SetMarkerRotationRate(short int iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); /// \} }; diff --git a/SU2_CFD/src/iteration/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index 517f3bff2c4..4b6de158796 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -88,11 +88,18 @@ void CIteration::SetGrid_Movement(CGeometry** geometry, CSurfaceMovement* surfac } break; + + } - if (config->GetSurface_Movement(AEROELASTIC) || config->GetSurface_Movement(AEROELASTIC_RIGID_MOTION)) { + if (config->GetSurface_Movement(AEROELASTIC) || config->GetSurface_Movement(AEROELASTIC_RIGID_MOTION) || config->GetSurface_Movement(MOVING_WALL)) { /*--- Apply rigid mesh transformation to entire grid first, if necessary ---*/ + if (IntIter == 0) { + cout << "TESTING:\n"; + + cout << config->GetSurface_Movement(MOVING_WALL); + cout << "\n"; if (Kind_Grid_Movement == AEROELASTIC_RIGID_MOTION) { if (rank == MASTER_NODE) cout << endl << " Performing rigid mesh transformation." << endl; @@ -110,6 +117,10 @@ void CIteration::SetGrid_Movement(CGeometry** geometry, CSurfaceMovement* surfac grid_movement->UpdateMultiGrid(geometry, config); } + if(config->GetSurface_Movement(MOVING_WALL)){ + geometry[MESH_0]->SetWallVelocity(config, true); + + } } diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index ffcc36d2f54..ffa2b051065 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -166,4 +166,11 @@ void CDriver::SetRotationRate(passivedouble rot_x, passivedouble rot_y, passived config_container[iZone]->SetRotation_Rate(2, rot_z); } } +void CDriver::SetMarkerRotationRate(short int iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z){ + for (iZone = 0; iZone < nZone; iZone++) { + config_container[iZone]->SetMarkerRotation_Rate(iMarker, 0, rot_x); + config_container[iZone]->SetMarkerRotation_Rate(iMarker, 1, rot_y); + config_container[iZone]->SetMarkerRotation_Rate(iMarker, 2, rot_z); + } +} From 5fdc66439e42de5175da68f6948e706b4ad84094 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Fri, 28 Jul 2023 10:38:09 +0200 Subject: [PATCH 24/99] add translation --- Common/include/CConfig.hpp | 11 ++++++++++- SU2_CFD/include/drivers/CDriver.hpp | 17 ++++++++++++++++- SU2_CFD/src/iteration/CIteration.cpp | 5 +---- SU2_CFD/src/python_wrapper_structure.cpp | 7 +++++++ 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 83d574deb1c..9955a9b010a 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5924,6 +5924,14 @@ class CConfig { */ su2double GetMarkerTranslationRate(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerTranslation_Rate[3*iMarkerMoving + iDim];} + /*! + * \brief Set the translation rate of the marker. + * \param[in] iDim - spatial component + * \param[in] val - translational velocity + * \return Translational velocity of the mesh. + */ + void SetMarkerTranslation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) const { MarkerTranslation_Rate[3*iMarkerMoving + iDim] = val;} + /*! * \brief Get the rotation rate of the mesh. * \param[in] iDim - spatial component @@ -5950,7 +5958,8 @@ class CConfig { * \brief Set the rotation rate of the marker. * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) * \param[in] iDim - spatial component - * \return Rotation velocity of the marker. + * \param[in] val - Rotational velocity + */ void SetMarkerRotation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) const { MarkerRotation_Rate[3*iMarkerMoving + iDim] = val;} diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index e6bcd68eb9a..928753dc019 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -535,8 +535,23 @@ class CDriver : public CDriverBase { * \param[in] rot_z - Value of Angular velocity about z-axes. */ void SetRotationRate(passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); - + /*! + * \brief Set the moving wall marker rotation rates. + * \param[in] iMaker - Index of moving wall marker. + * \param[in] rot_x - Value of Angular velocity about x-axes. + * \param[in] rot_y - Value of Angular velocity about y-axes. + * \param[in] rot_z - Value of Angular velocity about z-axes. + */ void SetMarkerRotationRate(short int iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); + /*! + * \brief Set the moving wall marker rotation rates. + * \param[in] iMaker - Index of moving wall marker. + * \param[in] vel_x - Value of velocity about x-axes. + * \param[in] vel_y - Value of velocity about y-axes. + * \param[in] vel_z - Value of velocity about z-axes. + */ + void SetMarkerTranslationRate(short int iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z); + /// \} }; diff --git a/SU2_CFD/src/iteration/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index 4b6de158796..8224b45950a 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -96,10 +96,7 @@ void CIteration::SetGrid_Movement(CGeometry** geometry, CSurfaceMovement* surfac /*--- Apply rigid mesh transformation to entire grid first, if necessary ---*/ if (IntIter == 0) { - cout << "TESTING:\n"; - - cout << config->GetSurface_Movement(MOVING_WALL); - cout << "\n"; + if (Kind_Grid_Movement == AEROELASTIC_RIGID_MOTION) { if (rank == MASTER_NODE) cout << endl << " Performing rigid mesh transformation." << endl; diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index ffa2b051065..ee7ae45a3e7 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -173,4 +173,11 @@ void CDriver::SetMarkerRotationRate(short int iMarker, passivedouble rot_x, pass config_container[iZone]->SetMarkerRotation_Rate(iMarker, 2, rot_z); } } +void CDriver::SetMarkerTranslationRate(short int iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z){ + for (iZone = 0; iZone < nZone; iZone++) { + config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 0, vel_x); + config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 1, vel_y); + config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 2, vel_z); + } +} From ba0e7328ab9eaff30c61e4e0ba95e16ebca8a4f4 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Fri, 28 Jul 2023 14:10:33 +0200 Subject: [PATCH 25/99] add example --- TestCases/py_wrapper/rotating_cylinder/run.py | 30 +++++ .../rotating_cylinder/spinning_cylinder.cfg | 115 ++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 TestCases/py_wrapper/rotating_cylinder/run.py create mode 100644 TestCases/py_wrapper/rotating_cylinder/spinning_cylinder.cfg diff --git a/TestCases/py_wrapper/rotating_cylinder/run.py b/TestCases/py_wrapper/rotating_cylinder/run.py new file mode 100644 index 00000000000..64e36c2eddb --- /dev/null +++ b/TestCases/py_wrapper/rotating_cylinder/run.py @@ -0,0 +1,30 @@ +import sys +from optparse import OptionParser # use a parser for configuration +import pysu2 # imports the SU2 wrapped module +from math import * +import os +import pysu2ad +from mpi4py import MPI +import numpy as np +import shutil +comm = MPI.COMM_WORLD +rank = comm.Get_rank() +ad_com = MPI.COMM_WORLD +rank_ad = ad_com.Get_rank() +n_of_steps = 10 +rotation_vector = np.zeros(n_of_steps)+20 +rotation_vector[5:9] = -rotation_vector[5:9] + +SU2Driver = pysu2.CSinglezoneDriver("spinning_cylinder.cfg",1, comm) + +for i in range(n_of_steps): + + SU2Driver.SetMarkerRotationRate(0,0,0,rotation_vector[n_of_steps-i-1]) + SU2Driver.Preprocess(i) + SU2Driver.Run() + SU2Driver.Postprocess() + SU2Driver.Output(i) + SU2Driver.Update() +SU2Driver.Finalize() + + \ No newline at end of file diff --git a/TestCases/py_wrapper/rotating_cylinder/spinning_cylinder.cfg b/TestCases/py_wrapper/rotating_cylinder/spinning_cylinder.cfg new file mode 100644 index 00000000000..194a46064dd --- /dev/null +++ b/TestCases/py_wrapper/rotating_cylinder/spinning_cylinder.cfg @@ -0,0 +1,115 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Laminar flow around a spinning cylinder % +% Author: Thomas D. Economon % +% Institution: Stanford University % +% Date: 2013.08.21 % +% File Version 7.5.1 "Blackbird" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= NAVIER_STOKES +KIND_TURB_MODEL= NONE +MATH_PROBLEM= DIRECT +RESTART_SOL= NO + +% ----------- COMPRESSIBLE AND INCOMPRESSIBLE FREE-STREAM DEFINITION ----------% +% +MACH_NUMBER= 0.1 +AOA= 0.0 +SIDESLIP_ANGLE= 0.0 +FREESTREAM_TEMPERATURE= 288.15 +REYNOLDS_NUMBER= 200.0 +REYNOLDS_LENGTH= 1.0 + +% ----------------------- DYNAMIC MESH DEFINITION -----------------------------% +% +SURFACE_MOVEMENT= MOVING_WALL +MACH_MOTION= 0.1 +MARKER_MOVING= ( cylinder ) +SURFACE_MOTION_ORIGIN= 0.5 0.0 0.0 +SURFACE_ROTATION_RATE = 0.0 0.0 -199.0738 + +% ---------------------- REFERENCE VALUE DEFINITION ---------------------------% +% +REF_ORIGIN_MOMENT_X = 0.00 +REF_ORIGIN_MOMENT_Y = 0.00 +REF_ORIGIN_MOMENT_Z = 0.00 +REF_LENGTH= 1.0 +REF_AREA= 1.0 + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_HEATFLUX= ( cylinder, 0.0 ) +MARKER_FAR= ( farfield ) +MARKER_PLOTTING= ( cylinder ) +MARKER_MONITORING= ( cylinder ) + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +CFL_NUMBER= 100.0 +CFL_ADAPT= NO +CFL_ADAPT_PARAM= ( 1.5, 0.5, 1.0, 100.0 ) +ITER= 99999 + +% ----------------------- SLOPE LIMITER DEFINITION ----------------------------% +% +VENKAT_LIMITER_COEFF= 0.03 +ADJ_SHARP_LIMITER_COEFF= 3.0 +REF_SHARP_EDGES= 3.0 +SENS_REMOVE_SHARP= NO + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= LU_SGS +LINEAR_SOLVER_ERROR= 1E-4 +LINEAR_SOLVER_ITER= 5 + +% -------------------------- MULTIGRID PARAMETERS -----------------------------% +% +MGLEVEL= 3 +MGCYCLE= V_CYCLE +MG_PRE_SMOOTH= ( 1, 1, 1, 1 ) +MG_POST_SMOOTH= ( 0, 0, 0, 0 ) +MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) +MG_DAMP_RESTRICTION= 0.5 +MG_DAMP_PROLONGATION= 0.5 + +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= ROE +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW= NONE +JST_SENSOR_COEFF= ( 0.5, 0.02 ) +TIME_DISCRE_FLOW= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_RESIDUAL_MINVAL= -15 +CONV_STARTITER= 10 +CONV_CAUCHY_ELEMS= 100 +CONV_CAUCHY_EPS= 1E-7 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +MESH_FILENAME= mesh_cylinder_lam.su2 +MESH_FORMAT= SU2 +MESH_OUT_FILENAME= mesh_out.su2 +SOLUTION_FILENAME= solution_flow.dat +SOLUTION_ADJ_FILENAME= solution_adj.dat +TABULAR_FORMAT= CSV +CONV_FILENAME= history +RESTART_FILENAME= restart_flow.dat +RESTART_ADJ_FILENAME= restart_adj.dat +VOLUME_FILENAME= flow +VOLUME_ADJ_FILENAME= adjoint +GRAD_OBJFUNC_FILENAME= of_grad.dat +SURFACE_FILENAME= surface_flow +SURFACE_ADJ_FILENAME= surface_adjoint +OUTPUT_WRT_FREQ= 100 +SCREEN_OUTPUT= (INNER_ITER, RMS_DENSITY, RMS_ENERGY, LIFT, DRAG) From ce66598aa62f441d18349417e6d61252cb38c8b4 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Sat, 29 Jul 2023 08:50:19 +0200 Subject: [PATCH 26/99] remove unused imports --- TestCases/py_wrapper/rotating_cylinder/run.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/TestCases/py_wrapper/rotating_cylinder/run.py b/TestCases/py_wrapper/rotating_cylinder/run.py index 64e36c2eddb..cbf2d968686 100644 --- a/TestCases/py_wrapper/rotating_cylinder/run.py +++ b/TestCases/py_wrapper/rotating_cylinder/run.py @@ -1,12 +1,8 @@ -import sys -from optparse import OptionParser # use a parser for configuration import pysu2 # imports the SU2 wrapped module from math import * -import os -import pysu2ad from mpi4py import MPI import numpy as np -import shutil + comm = MPI.COMM_WORLD rank = comm.Get_rank() ad_com = MPI.COMM_WORLD From 5d90c340f9600fcacebc21e731d36b47d0505288 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Sat, 29 Jul 2023 21:43:29 +0200 Subject: [PATCH 27/99] i hope the test will pass --- Common/include/CConfig.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 77df929dc58..fd78b7e54ba 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5973,8 +5973,8 @@ class CConfig { * \brief Set the rotation rate of the marker. * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) * \param[in] iDim - spatial component - * \param[in] val - Rotational velocity - + * \param[in] val - Rotational velocity + */ void SetMarkerRotation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) const { MarkerRotation_Rate[3*iMarkerMoving + iDim] = val;} From 7331adb1b8b1944d4212d1df4a4c0b8c8e9d75eb Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Sat, 29 Jul 2023 17:12:36 -0700 Subject: [PATCH 28/99] Apply suggestions from code review --- Common/include/CConfig.hpp | 13 ++++++++----- SU2_CFD/include/drivers/CDriver.hpp | 15 ++++++++------- SU2_CFD/src/iteration/CIteration.cpp | 9 ++++----- SU2_CFD/src/python_wrapper_structure.cpp | 6 ++++-- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index fd78b7e54ba..256444b7f37 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5943,9 +5943,10 @@ class CConfig { * \brief Set the translation rate of the marker. * \param[in] iDim - spatial component * \param[in] val - translational velocity - * \return Translational velocity of the mesh. */ - void SetMarkerTranslation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) const { MarkerTranslation_Rate[3*iMarkerMoving + iDim] = val;} + void SetMarkerTranslationRate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) { + MarkerTranslation_Rate[3 * iMarkerMoving + iDim] = val; + } /*! * \brief Get the rotation rate of the mesh. @@ -5969,14 +5970,16 @@ class CConfig { * \return Rotation velocity of the marker. */ su2double GetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim) const { return MarkerRotation_Rate[3*iMarkerMoving + iDim];} + /*! * \brief Set the rotation rate of the marker. - * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) + * \param[in] iMarkerMoving - Index of the moving marker (as specified in Marker_Moving) * \param[in] iDim - spatial component * \param[in] val - Rotational velocity - */ - void SetMarkerRotation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) const { MarkerRotation_Rate[3*iMarkerMoving + iDim] = val;} + void SetMarkerRotation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) { + MarkerRotation_Rate[3 * iMarkerMoving + iDim] = val; + } /*! * \brief Get the pitching rate of the mesh. diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 928753dc019..74bc0c11059 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -542,15 +542,16 @@ class CDriver : public CDriverBase { * \param[in] rot_y - Value of Angular velocity about y-axes. * \param[in] rot_z - Value of Angular velocity about z-axes. */ - void SetMarkerRotationRate(short int iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); - /*! - * \brief Set the moving wall marker rotation rates. + void SetMarkerRotationRate(unsigned short iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); + + /*! + * \brief Set the moving wall marker translation rates. * \param[in] iMaker - Index of moving wall marker. - * \param[in] vel_x - Value of velocity about x-axes. - * \param[in] vel_y - Value of velocity about y-axes. - * \param[in] vel_z - Value of velocity about z-axes. + * \param[in] vel_x - Value of velocity along x-axis. + * \param[in] vel_y - Value of velocity along y-axis. + * \param[in] vel_z - Value of velocity along z-axis. */ - void SetMarkerTranslationRate(short int iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z); + void SetMarkerTranslationRate(unsigned short iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z); /// \} }; diff --git a/SU2_CFD/src/iteration/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index 8224b45950a..15d8106981d 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -88,8 +88,6 @@ void CIteration::SetGrid_Movement(CGeometry** geometry, CSurfaceMovement* surfac } break; - - } if (config->GetSurface_Movement(AEROELASTIC) || config->GetSurface_Movement(AEROELASTIC_RIGID_MOTION) || config->GetSurface_Movement(MOVING_WALL)) { @@ -114,9 +112,10 @@ void CIteration::SetGrid_Movement(CGeometry** geometry, CSurfaceMovement* surfac grid_movement->UpdateMultiGrid(geometry, config); } - if(config->GetSurface_Movement(MOVING_WALL)){ - geometry[MESH_0]->SetWallVelocity(config, true); - + if (config->GetSurface_Movement(MOVING_WALL)) { + for (auto iMGlevel = 0u; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { + geometry[iMGlevel]->SetWallVelocity(config, iMGlevel == 0u); + } } } diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index ee7ae45a3e7..155ec1e216d 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -166,14 +166,16 @@ void CDriver::SetRotationRate(passivedouble rot_x, passivedouble rot_y, passived config_container[iZone]->SetRotation_Rate(2, rot_z); } } -void CDriver::SetMarkerRotationRate(short int iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z){ + +void CDriver::SetMarkerRotationRate(unsigned short iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z) { for (iZone = 0; iZone < nZone; iZone++) { config_container[iZone]->SetMarkerRotation_Rate(iMarker, 0, rot_x); config_container[iZone]->SetMarkerRotation_Rate(iMarker, 1, rot_y); config_container[iZone]->SetMarkerRotation_Rate(iMarker, 2, rot_z); } } -void CDriver::SetMarkerTranslationRate(short int iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z){ + +void CDriver::SetMarkerTranslationRate(unsigned short iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z) { for (iZone = 0; iZone < nZone; iZone++) { config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 0, vel_x); config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 1, vel_y); From eb21853c7b28660cb663e00cd4abb5fc447cc60d Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Sat, 29 Jul 2023 17:13:45 -0700 Subject: [PATCH 29/99] Apply suggestions from code review --- Common/include/CConfig.hpp | 2 +- SU2_CFD/src/python_wrapper_structure.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 256444b7f37..56987e00989 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5977,7 +5977,7 @@ class CConfig { * \param[in] iDim - spatial component * \param[in] val - Rotational velocity */ - void SetMarkerRotation_Rate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) { + void SetMarkerRotationRate(unsigned short iMarkerMoving, unsigned short iDim, su2double val) { MarkerRotation_Rate[3 * iMarkerMoving + iDim] = val; } diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index 155ec1e216d..61945348c4b 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -169,17 +169,17 @@ void CDriver::SetRotationRate(passivedouble rot_x, passivedouble rot_y, passived void CDriver::SetMarkerRotationRate(unsigned short iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z) { for (iZone = 0; iZone < nZone; iZone++) { - config_container[iZone]->SetMarkerRotation_Rate(iMarker, 0, rot_x); - config_container[iZone]->SetMarkerRotation_Rate(iMarker, 1, rot_y); - config_container[iZone]->SetMarkerRotation_Rate(iMarker, 2, rot_z); + config_container[iZone]->SetMarkerRotationRate(iMarker, 0, rot_x); + config_container[iZone]->SetMarkerRotationRate(iMarker, 1, rot_y); + config_container[iZone]->SetMarkerRotationRate(iMarker, 2, rot_z); } } void CDriver::SetMarkerTranslationRate(unsigned short iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z) { for (iZone = 0; iZone < nZone; iZone++) { - config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 0, vel_x); - config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 1, vel_y); - config_container[iZone]->SetMarkerTranslation_Rate(iMarker, 2, vel_z); + config_container[iZone]->SetMarkerTranslationRate(iMarker, 0, vel_x); + config_container[iZone]->SetMarkerTranslationRate(iMarker, 1, vel_y); + config_container[iZone]->SetMarkerTranslationRate(iMarker, 2, vel_z); } } From d57281fccf4b82182c8e510ef324c7895b2de1d8 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 4 Aug 2023 00:50:21 +0100 Subject: [PATCH 30/99] Comments --- SU2_CFD/include/output/COutput.hpp | 37 +++++++++++------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 100626b75f9..acf63efebf9 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -399,7 +399,6 @@ class COutput { /*! * Collects history data from the individual output per zone, * monitors the convergence and writes to screen and history file. - * \param[in] output - Container holding the output instances per zone. * \param[in] config - Definition of the particular problem per zone. * \param[in] driver_config - Base definition of the particular problem. @@ -602,7 +601,6 @@ class COutput { */ void WriteToFile(CConfig *config, CGeometry *geometry, OUTPUT_TYPE format, string fileName = ""); - protected: /*----------------------------- Protected member functions ----------------------------*/ @@ -937,7 +935,6 @@ class COutput { */ inline virtual void SetVolumeOutputFields(CConfig *config){} - /*! * \brief Load the history output field values * \param[in] config - Definition of the particular problem. @@ -954,36 +951,30 @@ class COutput { inline virtual void LoadMultizoneHistoryData(const COutput* const* output, const CConfig* const* config) {} /*! - * \brief Writes turboperformance to screen - * \param[in] TurboPerf - Turboperformance definition + * \brief Sets the turboperformance screen output + * \param[in] TurboPerf - Turboperformance class * \param[in] config - Definition of the particular problem - * \param[in] TimeIter - Value of the time iteration index - * \param[in] OuterIter - Value of outer iteration index - * \param[in] InnerIter - Value of the inner iteration index + * \param[in] TimeIter - Index of the current time-step + * \param[in] OuterIter - Index of current outer iteration + * \param[in] InnerIter - Index of current inner iteration */ - inline virtual void SetTurboPerformance_Output(std::shared_ptr TurboPerf, CConfig *config, - unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) {}; + inline virtual void SetTurboPerformance_Output(std::shared_ptr TurboPerf, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) {} /*! - * \brief Writes turboperformance to history file - * \param[in] TurboStagePerf - Stage turboperformance definition - * \param[in] TurboPerf - Turboperformance definition + * \brief Sets the multizone turboperformacne screen output + * \param[in] TurboStagePerf - Stage turboperformance class + * \param[in] TurboPerf - Turboperformance class * \param[in] config - Definition of the particular problem */ - inline virtual void SetTurboMultiZonePerformance_Output(CTurbomachineryStagePerformance* TurboStagePerf, - std::shared_ptr TurboPerf, - CConfig *config) {}; + inline virtual void SetTurboMultiZonePerformance_Output(CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) {} /*! - * \brief Writes turboperformance to screen - * \param[in] TurboStagePerf - Stage turboperformance definition - * \param[in] TurboPerf - Turboperformance definition + * \brief Loads the turboperformacne history data + * \param[in] TurboStagePerf - Stage turboperformance class + * \param[in] TurboPerf - Turboperformance class * \param[in] config - Definition of the particular problem - * \param[in] iZone - Current zone */ - inline virtual void LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, - std::shared_ptr TurboPerf, - CConfig *config) {}; + inline virtual void LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) {} /*! * \brief Write the kinematic and thermodynamic variables at each spanwise division From 8a3455bd91b7a81cecaab37e5fe81c4ed5a50ad4 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 4 Aug 2023 00:50:42 +0100 Subject: [PATCH 31/99] comments --- SU2 | 1 - SU2_CFD/include/output/CFlowCompOutput.hpp | 33 +++-- SU2_CFD/include/output/CFlowOutput.hpp | 3 +- SU2_CFD/include/output/CTurboOutput.hpp | 143 ++++++++++++--------- SU2_CFD/include/solvers/CEulerSolver.hpp | 25 ++-- SU2_CFD/include/solvers/CSolver.hpp | 10 +- SU2_CFD/src/integration/CIntegration.cpp | 1 - SU2_CFD/src/output/CFlowCompOutput.cpp | 137 ++++++++++---------- SU2_CFD/src/solvers/CEulerSolver.cpp | 4 - 9 files changed, 190 insertions(+), 167 deletions(-) delete mode 160000 SU2 diff --git a/SU2 b/SU2 deleted file mode 160000 index 84f4617a31a..00000000000 --- a/SU2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 84f4617a31a41a50716c2de62fc7b9d4ffcc857b diff --git a/SU2_CFD/include/output/CFlowCompOutput.hpp b/SU2_CFD/include/output/CFlowCompOutput.hpp index d5ece099e11..e5da7146adc 100644 --- a/SU2_CFD/include/output/CFlowCompOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompOutput.hpp @@ -93,16 +93,31 @@ class CFlowCompOutput final: public CFlowOutput { */ bool WriteHistoryFileOutput(const CConfig *config) override ; - void SetTurboPerformance_Output(std::shared_ptr TurboPerf, CConfig *config, - unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) override; - - void SetTurboMultiZonePerformance_Output(CTurbomachineryStagePerformance* TurboStagePerf, - std::shared_ptr TurboPerf, - CConfig *config) override; + /*! + * \brief Sets the turboperformance screen output + * \param[in] TurboPerf - Turboperformance class + * \param[in] config - Definition of the particular problem + * \param[in] TimeIter - Index of the current time-step + * \param[in] OuterIter - Index of current outer iteration + * \param[in] InnerIter - Index of current inner iteration + */ + void SetTurboPerformance_Output(std::shared_ptr TurboPerf, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) override; - void LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, - std::shared_ptr TurboPerf, - CConfig *config) override; + /*! + * \brief Sets the multizone turboperformacne screen output + * \param[in] TurboStagePerf - Stage turboperformance class + * \param[in] TurboPerf - Turboperformance class + * \param[in] config - Definition of the particular problem + */ + void SetTurboMultiZonePerformance_Output(CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) override; + + /*! + * \brief Loads the turboperformacne history data + * \param[in] TurboStagePerf - Stage turboperformance class + * \param[in] TurboPerf - Turboperformance class + * \param[in] config - Definition of the particular problem + */ + void LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) override; /*! * \brief Write the kinematic and thermodynamic variables at each spanwise division diff --git a/SU2_CFD/include/output/CFlowOutput.hpp b/SU2_CFD/include/output/CFlowOutput.hpp index 3a18791186b..47b9dbf3424 100644 --- a/SU2_CFD/include/output/CFlowOutput.hpp +++ b/SU2_CFD/include/output/CFlowOutput.hpp @@ -30,7 +30,6 @@ #include "CFVMOutput.hpp" #include "../variables/CVariable.hpp" - /*--- Forward declare to avoid including here. ---*/ template struct CPrimitiveIndices; @@ -45,7 +44,7 @@ class CFlowOutput : public CFVMOutput{ */ CFlowOutput(const CConfig *config, unsigned short nDim, bool femOutput); - /* + /* * \brief Add turboperformance outputs as history field * \param[in] nZone - Number of zones in problem */ diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp index 34a18aa2559..4a2c9388caf 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -36,6 +36,11 @@ #include "../../../Common/include/CConfig.hpp" #include "../fluid/CFluidModel.hpp" +/*! + * \brief Class containing the required primitive variables for initiating a turboperformance calculation + * \author S. Vitale, N. Anand, J. Kelly + * \ingroup Output + */ class CTurbomachineryPrimitiveState { private: su2double Density, Pressure, TangVelocity; @@ -46,15 +51,20 @@ class CTurbomachineryPrimitiveState { CTurbomachineryPrimitiveState(vector TurboPrimitives, unsigned short nDim, su2double tangVel); - su2double GetDensity() const& { return Density; } + const su2double& GetDensity() const { return Density; } - su2double GetPressure() const& { return Pressure; } + const su2double& GetPressure() const { return Pressure; } - su2double GetTangVelocity() const& { return TangVelocity; } + const su2double& GetTangVelocity() const { return TangVelocity; } - const std::vector& GetVelocity() const& { return Velocity; } + const std::vector& GetVelocity() const { return Velocity; } }; +/*! + * \brief Class containing the combined primitive inlet and outlet states for a given blade + * \author S. Vitale, N. Anand, J. Kelly + * \ingroup Output + */ class CTurbomachineryCombinedPrimitiveStates { private: CTurbomachineryPrimitiveState InletPrimitiveState; @@ -69,6 +79,11 @@ class CTurbomachineryCombinedPrimitiveStates { CTurbomachineryPrimitiveState GetOutletPrimitiveState() const& { return OutletPrimitiveState; } }; +/*! + * \brief Class containing state information for a turbomachine + * \author S. Vitale, N. Anand, J. Kelly + * \ingroup Output + */ class CTurbomachineryState { private: su2double Density, Pressure, Entropy, Enthalpy, Temperature, TotalTemperature, TotalPressure, TotalEnthalpy; @@ -83,45 +98,45 @@ class CTurbomachineryState { void ComputeState(CFluidModel& fluidModel, const CTurbomachineryPrimitiveState& primitiveState); - su2double GetDensity() const { return Density; } + const su2double GetDensity() const { return Density; } - su2double GetPressure() const { return Pressure; } + const su2double GetPressure() const { return Pressure; } - su2double GetEntropy() const { return Entropy; } + const su2double GetEntropy() const { return Entropy; } - su2double GetEnthalpy() const { return Enthalpy; } + const su2double GetEnthalpy() const { return Enthalpy; } - su2double GetTemperature() const { return Temperature; } + const su2double GetTemperature() const { return Temperature; } - su2double GetTotalTemperature() const { return TotalTemperature; } + const su2double GetTotalTemperature() const { return TotalTemperature; } - su2double GetTotalPressure() const { return TotalPressure; } + const su2double GetTotalPressure() const { return TotalPressure; } - su2double GetTotalRelPressure() const { return TotalRelPressure; } + const su2double GetTotalRelPressure() const { return TotalRelPressure; } - su2double GetTotalEnthalpy() const { return TotalEnthalpy; } + const su2double GetTotalEnthalpy() const { return TotalEnthalpy; } - su2double GetAbsFlowAngle() const { return AbsFlowAngle; } + const su2double GetAbsFlowAngle() const { return AbsFlowAngle; } - su2double GetFlowAngle() const { return FlowAngle; } + const su2double GetFlowAngle() const { return FlowAngle; } - su2double GetMassFlow() const { return MassFlow; } + const su2double GetMassFlow() const { return MassFlow; } - su2double GetRothalpy() const { return Rothalpy; } + const su2double GetRothalpy() const { return Rothalpy; } - vector GetVelocity() const { return Velocity; } + const vector GetVelocity() const { return Velocity; } - vector GetMach() const { return Mach; } + const vector GetMach() const { return Mach; } - su2double GetVelocityValue() const { return Norm(Velocity); } + const su2double GetVelocityValue() const { return Norm(Velocity); } - su2double GetMachValue() const { return Norm(Mach); } + const su2double GetMachValue() const { return Norm(Mach); } - su2double GetRelVelocityValue() const { return Norm(RelVelocity); } + const su2double GetRelVelocityValue() const { return Norm(RelVelocity); } - su2double GetRelMachValue() const { return Norm(RelMach); } + const su2double GetRelMachValue() const { return Norm(RelMach); } - su2double Norm(vector const& u) const { + const su2double Norm(vector const& u) const { su2double accum = 0.; for (auto i = 0u; i < u.size(); ++i) { accum += u[i] * u[i]; @@ -130,6 +145,11 @@ class CTurbomachineryState { } }; +/*! + * \brief Class containing additional states and performance calculation routines for blades in different turbomachines + * \author S. Vitale, N. Anand, J. Kelly + * \ingroup Output + */ class CTurbomachineryBladePerformance { protected: CTurbomachineryState InletState; @@ -138,8 +158,7 @@ class CTurbomachineryBladePerformance { CFluidModel& FluidModel; public: - CTurbomachineryBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, - su2double areaOut, su2double radiusOut); + CTurbomachineryBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, su2double areaOut, su2double radiusOut); virtual ~CTurbomachineryBladePerformance() = default; @@ -149,83 +168,91 @@ class CTurbomachineryBladePerformance { const CTurbomachineryState& GetOutletState() { return OutletState; } - su2double GetKineticEnergyLoss() const { return KineticEnergyLoss; } + const su2double GetKineticEnergyLoss() const { return KineticEnergyLoss; } - su2double GetTotalPressureLoss() const { return TotalPressureLoss; } + const su2double GetTotalPressureLoss() const { return TotalPressureLoss; } - su2double GetEntropyGen() const { return EntropyGen; } + const su2double GetEntropyGen() const { return EntropyGen; } - su2double GetPressureRatio() const { return PressureRatio; } + const su2double GetPressureRatio() const { return PressureRatio; } - su2double GetEulerianWork() const { return EulerianWork; } + const su2double GetEulerianWork() const { return EulerianWork; } }; class CTurbineBladePerformance : public CTurbomachineryBladePerformance { public: - CTurbineBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, - su2double areaOut, su2double radiusOut); + CTurbineBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, su2double areaOut, su2double radiusOut); void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates& primitives) override; }; class CCompressorBladePerformance : public CTurbomachineryBladePerformance { public: - CCompressorBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, - su2double areaOut, su2double radiusOut); + CCompressorBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, su2double areaOut, su2double radiusOut); void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates& primitives) override; }; class CPropellorBladePerformance : public CTurbomachineryBladePerformance { public: - CPropellorBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, - su2double areaOut, su2double radiusOut); + CPropellorBladePerformance(CFluidModel& fluidModel, unsigned short nDim, su2double areaIn, su2double radiusIn, su2double areaOut, su2double radiusOut); void ComputePerformance(const CTurbomachineryCombinedPrimitiveStates& primitives) override; }; +/*! + * \brief Class for computng full stage performance + * \author S. Vitale, N. Anand, J. Kelly + * \ingroup Output + */ class CTurbomachineryStagePerformance { protected: - su2double TotalStaticEfficiency, TotalTotalEfficiency, NormEntropyGen, TotalStaticPressureRatio, - TotalTotalPressureRatio, EulerianWork; + su2double TotalStaticEfficiency, TotalTotalEfficiency, NormEntropyGen, TotalStaticPressureRatio, TotalTotalPressureRatio, EulerianWork; CFluidModel& fluidModel; public: CTurbomachineryStagePerformance(CFluidModel& fluid); + virtual ~CTurbomachineryStagePerformance() = default; - virtual void ComputePerformanceStage(CTurbomachineryState InState, CTurbomachineryState OutState, - const CConfig* config); + + virtual void ComputePerformanceStage(CTurbomachineryState InState, CTurbomachineryState OutState, const CConfig* config); + virtual void ComputeTurbineStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState); + virtual void ComputeCompressorStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState); - su2double GetTotalStaticEfficiency() const { return TotalStaticEfficiency; } - su2double GetTotalTotalEfficiency() const { return TotalTotalEfficiency; } - su2double GetEulerianWork() const { return EulerianWork; } - su2double GetNormEntropyGen() const { return NormEntropyGen; } - su2double GetTotalStaticPressureRatio() const { return TotalStaticPressureRatio; } - su2double GetTotalTotalPressureRatio() const { return TotalTotalPressureRatio; } + + const su2double GetTotalStaticEfficiency() const { return TotalStaticEfficiency; } + + const su2double GetTotalTotalEfficiency() const { return TotalTotalEfficiency; } + + const su2double GetEulerianWork() const { return EulerianWork; } + + const su2double GetNormEntropyGen() const { return NormEntropyGen; } + + const su2double GetTotalStaticPressureRatio() const { return TotalStaticPressureRatio; } + + const su2double GetTotalTotalPressureRatio() const { return TotalTotalPressureRatio; } }; +/*! + * \brief Class for handling the calculation of turboperformance variables across a blade, span and full machine + * \author S. Vitale, N. Anand, J. Kelly + * \ingroup Output + */ class CTurboOutput { private: vector>> BladesPerformances; - static void ComputePerBlade(vector> const bladePerformances, - vector const bladePrimitives); + static void ComputePerBlade(vector> const bladePerformances, vector const bladePrimitives); - static void ComputePerSpan(shared_ptr const spanPerformances, - const CTurbomachineryCombinedPrimitiveStates& spanPrimitives); - // vector> StagePerformances; - // shared_ptr MachinePerformances; + static void ComputePerSpan(shared_ptr const spanPerformances, const CTurbomachineryCombinedPrimitiveStates& spanPrimitives); + public: CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel); vector>> - GetBladesPerformances() const { - return BladesPerformances; - } + const GetBladesPerformances() const { return BladesPerformances; } - // vector> GetStagePerformances() const { return StagePerformances; } - // shared_ptr GetMachinePerformances() const { return MachinePerformances; } void ComputeTurbomachineryPerformance(vector> const primitives); }; \ No newline at end of file diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 9c75d062c74..abafbba222c 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -29,7 +29,7 @@ #include "CFVMFlowSolverBase.hpp" #include "../variables/CEulerVariable.hpp" -#include "../output/CTurboOutput.hpp" + /*! * \class CEulerSolver * \ingroup Euler_Equations @@ -108,7 +108,7 @@ class CEulerSolver : public CFVMFlowSolverBase TurbomachineryPerformance; /*!< \brief turbo performance calculator. */ + vector TurboPrimitive; /*!< \breif Primtive turbo variables vector */ vector FluidModel; /*!< \brief fluid model used in the solver. */ @@ -1027,13 +1027,6 @@ class CEulerSolver : public CFVMFlowSolverBase GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool INLET) override { TurboPrimitive.clear(); if (INLET) { - TurboPrimitive.push_back(DensityIn[iBlade][iSpan]); TurboPrimitive.push_back(PressureIn[iBlade][iSpan]); - TurboPrimitive.push_back(TurboVelocityIn[iBlade][iSpan][0]);TurboPrimitive.push_back(TurboVelocityIn[iBlade][iSpan][1]); + TurboPrimitive.push_back(DensityIn[iBlade][iSpan]); + TurboPrimitive.push_back(PressureIn[iBlade][iSpan]); + TurboPrimitive.push_back(TurboVelocityIn[iBlade][iSpan][0]); + TurboPrimitive.push_back(TurboVelocityIn[iBlade][iSpan][1]); if (nDim==3) - TurboPrimitive.push_back(TurboVelocityIn[iBlade][iSpan][2]); + TurboPrimitive.push_back(TurboVelocityIn[iBlade][iSpan][2]); } else { - TurboPrimitive.push_back(DensityOut[iBlade][iSpan]); TurboPrimitive.push_back(PressureOut[iBlade][iSpan]); - TurboPrimitive.push_back(TurboVelocityOut[iBlade][iSpan][0]);TurboPrimitive.push_back(TurboVelocityOut[iBlade][iSpan][1]); + TurboPrimitive.push_back(DensityOut[iBlade][iSpan]); + TurboPrimitive.push_back(PressureOut[iBlade][iSpan]); + TurboPrimitive.push_back(TurboVelocityOut[iBlade][iSpan][0]); + TurboPrimitive.push_back(TurboVelocityOut[iBlade][iSpan][1]); if (nDim==3) TurboPrimitive.push_back(TurboVelocityOut[iBlade][iSpan][2]); } diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 3915f9b913d..1d9a1be48aa 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -133,8 +133,6 @@ class CSolver { su2activevector iPoint_UndLapl; /*!< \brief Auxiliary variable for the undivided Laplacians. */ su2activevector jPoint_UndLapl; /*!< \brief Auxiliary variable for the undivided Laplacians. */ - vector TurboPrimitive; - int *Restart_Vars; /*!< \brief Auxiliary structure for holding the number of variables and points in a restart. */ int Restart_ExtIter; /*!< \brief Auxiliary structure for holding the external iteration offset from a restart. */ passivedouble *Restart_Data; /*!< \brief Auxiliary structure for holding the data values from a restart. */ @@ -3755,19 +3753,13 @@ class CSolver { * \param[in] config - Definition of the particular problem. */ inline virtual void InitTurboContainers(CGeometry *geometry, CConfig *config) { } - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - inline virtual void InitTurboPerformance(CGeometry *geometry, CConfig** config) { } /*! * \brief Get Primal variables for turbo performance computation * iteration can be executed by multiple threads. * \return returns Density, pressure and TurboVelocity (IN/OUTLET) */ - virtual vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool Inlet) { return TurboPrimitive; } + virtual vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool Inlet) { return vector(5, 0.0); } /*! * \brief virtual member. diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index 06a16a9c688..c1fe4c29bf5 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -91,7 +91,6 @@ void CIntegration::Space_Integration(CGeometry *geometry, if (config->GetBoolTurbomachinery()){ /*--- Average quantities at the inflow and outflow boundaries ---*/ - solver_container[MainSolver]->TurboAverageProcess(solver_container, geometry,config,INFLOW); solver_container[MainSolver]->TurboAverageProcess(solver_container, geometry, config, OUTFLOW); } diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 2e733c0850a..4972581ae86 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -465,7 +465,6 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol if (config->GetEquivArea()) SetNearfieldInverseDesign(flow_solver, geometry, config); - /*--- Keep this as last, since it uses the history values that were set. ---*/ SetCustomOutputs(solver, geometry, config); @@ -519,29 +518,28 @@ void CFlowCompOutput::SetTurboPerformance_Output(std::shared_ptr 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); TurboInOut<<" BLADE ROW INDEX "<GetInletState().GetEntropy() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetEntropy(); - TurboInOut << "Total Enthalpy " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalEnthalpy() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalEnthalpy(); - TurboInOut << "Total Pressure " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalPressure() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalPressure(); - TurboInOut << "Pressure " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetPressure() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetPressure(); - TurboInOut << "Density " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetDensity() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetDensity(); - TurboInOut << "Normal Velocity " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[0] << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[0]; - TurboInOut << "Tangential Velocity " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[1] << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[1]; - TurboInOut << "Mass Flow " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMassFlow() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMassFlow(); - TurboInOut << "Mach " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMachValue() << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMachValue(); - TurboInOut << "Abs Flow Angle " << BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER << BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER; + TurboInOut << "Entropy " << BladePerf->GetInletState().GetEntropy() << BladePerf->GetOutletState().GetEntropy(); + TurboInOut << "Total Enthalpy " << BladePerf->GetInletState().GetTotalEnthalpy() << BladePerf->GetOutletState().GetTotalEnthalpy(); + TurboInOut << "Total Pressure " << BladePerf->GetInletState().GetTotalPressure() << BladePerf->GetOutletState().GetTotalPressure(); + TurboInOut << "Pressure " << BladePerf->GetInletState().GetPressure() << BladePerf->GetOutletState().GetPressure(); + TurboInOut << "Density " << BladePerf->GetInletState().GetDensity() << BladePerf->GetOutletState().GetDensity(); + TurboInOut << "Normal Velocity " << BladePerf->GetInletState().GetVelocity()[0] << BladePerf->GetOutletState().GetVelocity()[0]; + TurboInOut << "Tangential Velocity " << BladePerf->GetInletState().GetVelocity()[1] << BladePerf->GetOutletState().GetVelocity()[1]; + TurboInOut << "Mass Flow " << BladePerf->GetInletState().GetMassFlow() << BladePerf->GetOutletState().GetMassFlow(); + TurboInOut << "Mach " << BladePerf->GetInletState().GetMachValue() << BladePerf->GetOutletState().GetMachValue(); + TurboInOut << "Abs Flow Angle " << BladePerf->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER << BladePerf->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER; TurboInOut.PrintFooter(); } cout< TurboPerf, - CConfig *config) { +void CFlowCompOutput::SetTurboMultiZonePerformance_Output(CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) { stringstream TurboMZPerf; @@ -571,37 +569,37 @@ void CFlowCompOutput::SetTurboMultiZonePerformance_Output(CTurbomachineryStagePe } -void CFlowCompOutput::LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, - std::shared_ptr TurboPerf, - CConfig *config) { +void CFlowCompOutput::LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) { if (rank == MASTER_NODE){ auto BladePerformance = TurboPerf->GetBladesPerformances(); for (unsigned short iZone = 0; iZone <= config->GetnZone()-1; iZone++) { auto nSpan = config->GetnSpan_iZones(iZone); + const auto& BladePerf = BladePerformance.at(iZone).at(nSpan); + stringstream tag; tag << iZone + 1; - SetHistoryOutputValue("EntropyIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetEntropy()); - SetHistoryOutputValue("EntropyOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetEntropy()); - SetHistoryOutputValue("TotalEntahalpyIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalEnthalpy()); - SetHistoryOutputValue("TotalEnthalpyOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalEnthalpy()); - SetHistoryOutputValue("TotalPressureIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetTotalPressure()); - SetHistoryOutputValue("TotalPressureOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetTotalPressure()); - SetHistoryOutputValue("PressureIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetPressure()); - SetHistoryOutputValue("PressureOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetPressure()); - SetHistoryOutputValue("DensityIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetDensity()); - SetHistoryOutputValue("DensityOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetDensity()); - SetHistoryOutputValue("NormalVelocityIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[0]); - SetHistoryOutputValue("NormalVelocityOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[0]); - SetHistoryOutputValue("TangentialVelocityIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetVelocity()[1]); - SetHistoryOutputValue("TangentialVelocityOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetVelocity()[1]); - SetHistoryOutputValue("MassFlowIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMassFlow()); - SetHistoryOutputValue("MassFlowOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMassFlow()); - SetHistoryOutputValue("MachIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetMachValue()); - SetHistoryOutputValue("MachOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetMachValue()); - SetHistoryOutputValue("AbsFlowAngleIn_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER); - SetHistoryOutputValue("AbsFlowAngleOut_" + tag.str(), BladePerformance.at(iZone).at(nSpan)->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER); + SetHistoryOutputValue("EntropyIn_" + tag.str(), BladePerf->GetInletState().GetEntropy()); + SetHistoryOutputValue("EntropyOut_" + tag.str(), BladePerf->GetOutletState().GetEntropy()); + SetHistoryOutputValue("TotalEntahalpyIn_" + tag.str(), BladePerf->GetInletState().GetTotalEnthalpy()); + SetHistoryOutputValue("TotalEnthalpyOut_" + tag.str(), BladePerf->GetOutletState().GetTotalEnthalpy()); + SetHistoryOutputValue("TotalPressureIn_" + tag.str(), BladePerf->GetInletState().GetTotalPressure()); + SetHistoryOutputValue("TotalPressureOut_" + tag.str(), BladePerf->GetOutletState().GetTotalPressure()); + SetHistoryOutputValue("PressureIn_" + tag.str(), BladePerf->GetInletState().GetPressure()); + SetHistoryOutputValue("PressureOut_" + tag.str(), BladePerf->GetOutletState().GetPressure()); + SetHistoryOutputValue("DensityIn_" + tag.str(), BladePerf->GetInletState().GetDensity()); + SetHistoryOutputValue("DensityOut_" + tag.str(), BladePerf->GetOutletState().GetDensity()); + SetHistoryOutputValue("NormalVelocityIn_" + tag.str(), BladePerf->GetInletState().GetVelocity()[0]); + SetHistoryOutputValue("NormalVelocityOut_" + tag.str(), BladePerf->GetOutletState().GetVelocity()[0]); + SetHistoryOutputValue("TangentialVelocityIn_" + tag.str(), BladePerf->GetInletState().GetVelocity()[1]); + SetHistoryOutputValue("TangentialVelocityOut_" + tag.str(), BladePerf->GetOutletState().GetVelocity()[1]); + SetHistoryOutputValue("MassFlowIn_" + tag.str(), BladePerf->GetInletState().GetMassFlow()); + SetHistoryOutputValue("MassFlowOut_" + tag.str(), BladePerf->GetOutletState().GetMassFlow()); + SetHistoryOutputValue("MachIn_" + tag.str(), BladePerf->GetInletState().GetMachValue()); + SetHistoryOutputValue("MachOut_" + tag.str(), BladePerf->GetOutletState().GetMachValue()); + SetHistoryOutputValue("AbsFlowAngleIn_" + tag.str(), BladePerf->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER); + SetHistoryOutputValue("AbsFlowAngleOut_" + tag.str(), BladePerf->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER); } SetHistoryOutputValue("EntropyGeneration", TurboStagePerf->GetNormEntropyGen()*100); SetHistoryOutputValue("EulerianWork", TurboStagePerf->GetEulerianWork()); @@ -612,8 +610,7 @@ void CFlowCompOutput::LoadTurboHistoryData(CTurbomachineryStagePerformance* Turb } } -void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr TurboPerf, CGeometry *geometry, CConfig **config, - unsigned short val_iZone) { +void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr TurboPerf, CGeometry *geometry, CConfig **config, unsigned short val_iZone) { string inMarker_Tag, outMarker_Tag, inMarkerTag_Mix; unsigned short nZone = config[val_iZone]->GetnZone(); @@ -634,8 +631,6 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetSpanWiseValue(1); SpanWiseValuesOut = geometry->GetSpanWiseValue(2); - - /*--- Writing Span wise inflow thermodynamic quantities. ---*/ spanwise_performance_filename = "TURBOMACHINERY/inflow_spanwise_thermodynamic_values.dat"; char buffer[50]; @@ -671,17 +666,18 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); 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 << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetPressure()*config[ZONE_0]->GetPressure_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetTotalPressure()*config[ZONE_0]->GetPressure_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetTemperature()*config[ZONE_0]->GetTemperature_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetTotalTemperature()*config[ZONE_0]->GetTemperature_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetTotalEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetDensity()*config[ZONE_0]->GetDensity_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetEntropy()*config[ZONE_0]->GetEnergy_Ref()/config[ZONE_0]->GetTemperature_Ref(); + 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(); // TODO: Add the variables back into CTurboOutput // if(TurbIntensityIn[val_iZone][iSpan] > 1.0){ // file.width(30); file << TurbIntensityIn [val_iZone][config[ZONE_0]->GetnSpan_iZones(val_iZone)/2]; @@ -728,17 +724,18 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); 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 << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetPressure()*config[ZONE_0]->GetPressure_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetTotalPressure()*config[ZONE_0]->GetPressure_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetTemperature()*config[ZONE_0]->GetTemperature_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetTotalTemperature()*config[ZONE_0]->GetTemperature_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetTotalEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetDensity()*config[ZONE_0]->GetDensity_Ref(); - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetEntropy()*config[ZONE_0]->GetEnergy_Ref()/config[ZONE_0]->GetTemperature_Ref(); + 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(); // if(TurbIntensityOut[val_iZone][iSpan] > 1.0){ // file.width(30); file << TurbIntensityOut [val_iZone][config[ZONE_0]->GetnSpan_iZones(val_iZone)/2]; // }else{ @@ -783,27 +780,28 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); 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 < 4; iDim++){ - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetMach()[iDim]; + file.width(30); file << BladePerf->GetInletState().GetMach()[iDim]; } for (iDim = 0; iDim < 4; iDim++){ - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref(); + file.width(30); file << BladePerf->GetInletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref(); } // This captures NaNs - if(isnan(BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetAbsFlowAngle())){ + if(isnan(BladePerf->GetInletState().GetAbsFlowAngle())){ file.width(30); file << "0.0000"; } else { - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetAbsFlowAngle()*180.0/PI_NUMBER; + file.width(30); file << BladePerf->GetInletState().GetAbsFlowAngle()*180.0/PI_NUMBER; } - if(isnan(BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetFlowAngle())){ + if(isnan(BladePerf->GetInletState().GetFlowAngle())){ file.width(30); file << "0.0000"; } else{ - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetFlowAngle()*180.0/PI_NUMBER; + file.width(30); file << BladePerf->GetInletState().GetFlowAngle()*180.0/PI_NUMBER; } file << endl; } @@ -842,26 +840,27 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); 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 < 4; iDim++){ - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetMach()[iDim]; + file.width(30); file << BladePerf->GetOutletState().GetMach()[iDim]; } for (iDim = 0; iDim < 4; iDim++){ - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref(); + file.width(30); file << BladePerf->GetOutletState().GetVelocity()[iDim]*config[ZONE_0]->GetVelocity_Ref(); } - if(isnan(BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetAbsFlowAngle())){ + if(isnan(BladePerf->GetInletState().GetAbsFlowAngle())){ file.width(30); file << "0.0000"; } else { - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetAbsFlowAngle()*180.0/PI_NUMBER; + file.width(30); file << BladePerf->GetOutletState().GetAbsFlowAngle()*180.0/PI_NUMBER; } - if(isnan(BladePerformance.at(val_iZone).at(iSpan)->GetInletState().GetAbsFlowAngle())){ + if(isnan(BladePerf->GetInletState().GetAbsFlowAngle())){ file.width(30); file << "0.0000"; } else{ - file.width(30); file << BladePerformance.at(val_iZone).at(iSpan)->GetOutletState().GetFlowAngle()*180.0/PI_NUMBER; + file.width(30); file << BladePerf->GetOutletState().GetFlowAngle()*180.0/PI_NUMBER; } file << endl; } diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 8ac01823f4e..68c9bd3767e 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -363,10 +363,6 @@ void CEulerSolver::InstantiateEdgeNumerics(const CSolver* const* solver_containe END_SU2_OMP_SAFE_GLOBAL_ACCESS } -void CEulerSolver::InitTurboPerformance(CGeometry *geometry, CConfig** config){ - TurbomachineryPerformance = std::make_shared(config, *geometry, *GetFluidModel()); -} - void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ /*--- Initialize quantities for the average process for internal flow ---*/ From 737709e33ab743f9410deb543c928a5a5389bb55 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 4 Aug 2023 16:43:25 +0100 Subject: [PATCH 32/99] better solution to mz history output --- SU2_CFD/src/output/COutput.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index a5f406d2027..3b741d46b77 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -1355,11 +1355,10 @@ void COutput::CheckHistoryOutput(unsigned short nZone) { for (unsigned short iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++){ if (requestedHistoryFields[iReqField] == "TURBO_PERF"){ - char buffer [14]; //This makes the assumption the number of zones is 10 or lower - std::string strZones = std::to_string(nZone-1); - char const *valZones = strZones.c_str(); - auto snpCatch = snprintf(buffer, 14, "TURBO_PERF[%s]", valZones); - requestedHistoryFields[iReqField] = buffer; + std::stringstream reqField; + std::string strZones = std::to_string(nZone-1); + reqField << "TURBO_PERF[" << strZones << "]"; + reqField >> requestedHistoryFields[iReqField]; } } From 26f44c6a4cc3b639582a708b8c311c534ccd7da9 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 23 Aug 2023 15:00:34 +0100 Subject: [PATCH 33/99] Data race fix --- SU2_CFD/src/integration/CIntegration.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index c1fe4c29bf5..446bbdb26ea 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -89,11 +89,14 @@ void CIntegration::Space_Integration(CGeometry *geometry, solver_container[MainSolver]->PreprocessBC_Giles(geometry, config, conv_bound_numerics, OUTFLOW); } - if (config->GetBoolTurbomachinery()){ - /*--- Average quantities at the inflow and outflow boundaries ---*/ - solver_container[MainSolver]->TurboAverageProcess(solver_container, geometry,config,INFLOW); - solver_container[MainSolver]->TurboAverageProcess(solver_container, geometry, config, OUTFLOW); + BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS { + if (config->GetBoolTurbomachinery()){ + /*--- Average quantities at the inflow and outflow boundaries ---*/ + solver_container[MainSolver]->TurboAverageProcess(solver_container, geometry,config,INFLOW); + solver_container[MainSolver]->TurboAverageProcess(solver_container, geometry, config, OUTFLOW); + } } + END_SU2_OMP_SAFE_GLOBAL_ACCESS /*--- Weak boundary conditions ---*/ From 0947f63f7c8aeb712dd8958593230bd800772076 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 30 Aug 2023 20:09:03 +0100 Subject: [PATCH 34/99] Fixed heap use after free and vertex structure out --- SU2_CFD/include/output/COutput.hpp | 5 ++-- SU2_CFD/src/iteration/CFluidIteration.cpp | 4 +-- SU2_CFD/src/output/CFlowCompOutput.cpp | 34 +++++++++++++++-------- SU2_CFD/src/output/COutput.cpp | 11 ++++---- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index acf63efebf9..1128b823e05 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -390,11 +390,12 @@ class COutput { * \param[in] TimeIter - Value of the time iteration index * \param[in] OuterIter - Value of outer iteration index * \param[in] InnerIter - Value of the inner iteration index + * \param[in] val_iInst - Index of the instance layer */ - void SetHistoryOutput(CGeometry *geometry, CSolver **solver_container, CConfig **config, + void SetHistoryOutput(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, unsigned short val_iZone, - unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter); + unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iInst); /*! * Collects history data from the individual output per zone, diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 44de0a83b5f..4083d036f5a 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -220,9 +220,9 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe if (val_iZone == config[ZONE_0]->GetnZone()-1) { ComputeTurboPerformance(solver, geometry, config, config[val_iZone]->GetnInner_Iter()); - output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], + output->SetHistoryOutput(geometry, solver, config, TurbomachineryStagePerformance, TurbomachineryPerformance, val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), - config[val_iZone]->GetInnerIter()); + config[val_iZone]->GetInnerIter(), val_iInst); } TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter()); diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 265ed8ed4d7..9d201c417ea 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -639,8 +639,8 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetSpanWiseValue(1); - SpanWiseValuesOut = geometry->GetSpanWiseValue(2); + SpanWiseValuesIn = geometry->GetSpanWiseValue(INFLOW); + SpanWiseValuesOut = geometry->GetSpanWiseValue(OUTFLOW); /*--- Writing Span wise inflow thermodynamic quantities. ---*/ spanwise_performance_filename = "TURBOMACHINERY/inflow_spanwise_thermodynamic_values.dat"; @@ -779,11 +779,15 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnDim() == 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]\""; - file.width(30); file << "\"3rd Component 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]\""; @@ -795,12 +799,14 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnDim(); iDim++){ file.width(30); file << BladePerf->GetInletState().GetMach()[iDim]; } - for (iDim = 0; iDim < 4; 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"; @@ -839,11 +845,15 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnDim() == 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]\""; - file.width(30); file << "\"3rd Component 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]\""; @@ -853,14 +863,16 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); iSpan++){ const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan); - file.width(30); file << SpanWiseValuesIn[iSpan]; + file.width(30); file << SpanWiseValuesOut[iSpan]; file.width(15); file << iSpan; - for (iDim = 0; iDim < 4; iDim++){ + for (iDim = 0; iDim < geometry->GetnDim(); iDim++){ file.width(30); file << BladePerf->GetOutletState().GetMach()[iDim]; } - for (iDim = 0; iDim < 4; 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"; } diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 3b741d46b77..00d9d182ba3 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -228,15 +228,16 @@ void COutput::SetHistoryOutput(CGeometry *geometry, } -void COutput::SetHistoryOutput(CGeometry *geometry, - CSolver **solver, +void COutput::SetHistoryOutput(CGeometry ****geometry, + CSolver *****solver, CConfig **config, CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, unsigned short val_iZone, unsigned long TimeIter, unsigned long OuterIter, - unsigned long InnerIter){ + unsigned long InnerIter, + unsigned short val_iInst){ unsigned long Iter= InnerIter; @@ -248,14 +249,14 @@ void COutput::SetHistoryOutput(CGeometry *geometry, SetTurboPerformance_Output(TurboPerf, config[val_iZone], TimeIter, OuterIter, InnerIter); if (rank == MASTER_NODE) SetTurboMultiZonePerformance_Output(TurboStagePerf, TurboPerf, config[val_iZone]); for (int iZone = 0; iZone < config[ZONE_0]->GetnZone(); iZone ++){ - WriteTurboSpanwisePerformance(TurboPerf, geometry, config, iZone); + WriteTurboSpanwisePerformance(TurboPerf, geometry[iZone][val_iInst][MESH_0], config, iZone); } } /*--- Update turboperformance history file*/ LoadTurboHistoryData(TurboStagePerf, TurboPerf, config[val_iZone]); - SetHistoryOutput(geometry, solver, config[val_iZone], TimeIter, OuterIter,InnerIter); + SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], TimeIter, OuterIter,InnerIter); } From 9b386b054d5fd8971f60de49b79335b53bfe6cf0 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 31 Aug 2023 15:06:53 +0100 Subject: [PATCH 35/99] Updated reg tests --- TestCases/hybrid_regression.py | 10 +++++----- TestCases/parallel_regression.py | 10 +++++----- TestCases/parallel_regression_AD.py | 4 ++-- TestCases/serial_regression.py | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index 0225ee0ee6c..551cd06a2d8 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -561,7 +561,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-6.987181, -3.096835, -14.857733, -9.109735, -11.787852, -6.266208, 73266, 73266] + Jones_tc_restart.test_vals = [-6.594590, -2.792279, -14.336129, -8.776066, -11.371439, -5.845633, 73273, 73273] test_list.append(Jones_tc_restart) # 2D axial stage @@ -569,8 +569,8 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [1.047801, 1.661487, -2.916144, 2.586026, -2.486555, 3.050786, 106380, 106380] - axial_stage2D.test_vals_aarch64 = [1.047801, 1.661487, -2.916144, 2.586026, -2.486555, 3.050786, 106380, 106380] + axial_stage2D.test_vals = [0.983739, 1.534333, -2.888521, 2.606770, -2.418339, 3.087275, 106380, 106380] + axial_stage2D.test_vals_aarch64 = [0.983739, 1.534333, -2.888521, 2.606770, -2.418339, 3.087275, 106380, 106380] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -578,8 +578,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-7.543335, -6.834312, -6.673129, -1.579553, -6.796362, -0.743829, -471650] - transonic_stator_restart.test_vals_aarch64 = [-7.543335, -6.834312, -6.673129, -1.579553, -6.796362, -0.743829, -471650] + transonic_stator_restart.test_vals = [-5.007735, -3.099310, -2.751696, 1.091966, -3.542819, 2.163237, -471630] + transonic_stator_restart.test_vals_aarch64 = [-5.007735, -3.099310, -2.751696, 1.091966, -3.542819, 2.163237, -471630] test_list.append(transonic_stator_restart) ###################################### diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 64f3877fba3..5154c6bffd4 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1039,7 +1039,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-6.987181, -3.096835, -14.857733, -9.109735, -11.787852, -6.266208, 73266, 73266] + Jones_tc_restart.test_vals = [-6.594590, -2.792281, -14.336129, -8.776067, -11.371439, -5.845633, 73273, 73273] test_list.append(Jones_tc_restart) # 2D axial stage @@ -1047,8 +1047,8 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [1.047861, 1.661689, -2.916002, 2.586160, -2.486401, 3.050953, 106380, 106380] - axial_stage2D.test_vals_aarch64 = [1.047861, 1.661689, -2.916002, 2.586160, -2.486401, 3.050953, 106380, 106380] + axial_stage2D.test_vals = [0.983754, 1.534455, -2.888523, 2.606770, -2.418403, 3.087203, 106380, 106380] + axial_stage2D.test_vals_aarch64 = [0.983754, 1.534455, -2.888523, 2.606770, -2.418403, 3.087203, 106380, 106380] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -1056,8 +1056,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-7.545560, -6.807355, -6.697808, -1.582515, -6.801911, -0.746306, -471650] - transonic_stator_restart.test_vals_aarch64 = [-7.545560, -6.807355, -6.697808, -1.582515, -6.801911, -0.746306, -471650] + transonic_stator_restart.test_vals = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630] + transonic_stator_restart.test_vals_aarch64 = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630] test_list.append(transonic_stator_restart) ###################################### diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 10a28c974e1..30309fac00c 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -230,8 +230,8 @@ def main(): discadj_trans_stator.cfg_dir = "disc_adj_turbomachinery/transonic_stator_2D" discadj_trans_stator.cfg_file = "transonic_stator.cfg" discadj_trans_stator.test_iter = 79 - discadj_trans_stator.test_vals = [79, 0.769972, 0.374328, 0.474458, -0.996522, 2.154079, -4.446062] - discadj_trans_stator.test_vals_aarch64 = [79.000000, 0.769908, 0.374328, 0.474687, -0.996522, 2.154079, -4.446062] + discadj_trans_stator.test_vals = [79, 0.769967, 0.374299, 0.474436, -0.996528, 2.154053, -4.446085] + discadj_trans_stator.test_vals_aarch64 = [79, 0.769967, 0.374299, 0.474436, -0.996528, 2.154053, -4.446085] test_list.append(discadj_trans_stator) ################################### diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 6810f88a240..4e72846689a 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -857,7 +857,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-6.987181, -3.096835, -14.857733, -9.109735, -11.787852, -6.266208, 73266, 73266] + Jones_tc_restart.test_vals = [-6.594586, -2.792279, -14.336132, -8.776068, -11.371439, -5.845632, 73273, 73273] test_list.append(Jones_tc_restart) # 2D axial stage @@ -865,8 +865,8 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [1.047883, 1.661703, -2.916020, 2.586144, -2.486401, 3.050955, 106380, 106380] - axial_stage2D.test_vals_aarch64 = [1.047883, 1.661703, -2.916020, 2.586144, -2.486401, 3.050955, 106380, 106380] + axial_stage2D.test_vals = [0.983751, 1.534480, -2.888520, 2.606773, -2.418421, 3.087187, 106380, 106380] + axial_stage2D.test_vals_aarch64 = [0.983751, 1.534480, -2.888520, 2.606773, -2.418421, 3.087187, 106380, 106380] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -874,8 +874,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-7.533443, -6.826845, -6.612243, -1.566209, -6.765890, -0.742094, -471650] - transonic_stator_restart.test_vals_aarch64 = [-7.533443, -6.826845, -6.612243, -1.566209, -6.765890, -0.742094, -471650] + transonic_stator_restart.test_vals = [-5.008547, -3.102420, -2.752033, 1.091152, -3.543849, 2.169844, -471630] + transonic_stator_restart.test_vals_aarch64 = [-5.008547, -3.102420, -2.752033, 1.091152, -3.543849, 2.169844, -471630] test_list.append(transonic_stator_restart) From fa1096f1c8fcb075adef5dcd89b02f00ec78334d Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 31 Aug 2023 15:19:41 +0100 Subject: [PATCH 36/99] Added catch for dummy driver in turbopreprocessing --- SU2_CFD/include/drivers/CDriver.hpp | 3 ++- SU2_CFD/src/drivers/CDriver.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 5ac33896849..6f7bbe2df58 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -290,9 +290,10 @@ class CDriver : public CDriverBase { * \param[in] geometry - Geometrical definition of the problem. * \param[in] solver - Container vector with all the solutions. * \param[in] interface - Class defining the physical transfer of information. + * \param[in] dummy - Definition of dummy driver */ void PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, CSolver***** solver, - CInterface*** interface); + CInterface*** interface, bool dummy); /*! * \brief Ramp some simulation settings for turbomachinery problems. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 63f2789731c..8ec9a600bad 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -247,7 +247,7 @@ CDriverBase(confFile, val_nZone, MPICommunicator), StopCalc(false), fsi(false), if (rank == MASTER_NODE) cout << endl <<"---------------------- Turbomachinery Preprocessing ---------------------" << endl; - PreprocessTurbomachinery(config_container, geometry_container, solver_container, interface_container); + PreprocessTurbomachinery(config_container, geometry_container, solver_container, interface_container, dummy_geo); } @@ -2628,7 +2628,7 @@ void CDriver::PreprocessOutput(CConfig **config, CConfig *driver_config, COutput void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, CSolver***** solver, - CInterface*** interface){ + CInterface*** interface, bool dummy){ unsigned short donorZone,targetZone, nMarkerInt, iMarkerInt; unsigned short nSpanMax = 0; @@ -2700,7 +2700,7 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, config[ZONE_0]->SetnBlades(iZone, nBlades); } - if (rank == MASTER_NODE){ + if (rank == MASTER_NODE && !dummy){ for (iZone = 0; iZone < nZone; iZone++) { areaIn = geometry[iZone][INST_0][MESH_0]->GetSpanAreaIn(iZone, config[iZone]->GetnSpanWiseSections()); areaOut = geometry[iZone][INST_0][MESH_0]->GetSpanAreaOut(iZone, config[iZone]->GetnSpanWiseSections()); From 7e29da624edbb62aced1aff1d546d1a249e8a258 Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Sat, 23 Sep 2023 10:33:58 -0700 Subject: [PATCH 37/99] Update SU2_CFD/include/output/COutput.hpp --- SU2_CFD/include/output/COutput.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 001a3915091..84036a6b117 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -382,6 +382,7 @@ class COutput { * \param[in] config - Definition of the particular problem. */ void SetHistoryOutput(CGeometry *geometry, CSolver **solver_container, CConfig *config); + /*! * \brief Collects history data from the solvers, monitors the convergence and writes to screen and history file. * \param[in] geometry - Geometrical definition of the problem. From 32dcd85b1f2118fbf0ae3607c82b7a037b682378 Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Thu, 26 Oct 2023 13:38:43 +0100 Subject: [PATCH 38/99] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: KürÅŸat Yurt <57598663+kursatyurt@users.noreply.github.com> --- SU2_CFD/include/drivers/CDriver.hpp | 1 + SU2_CFD/src/python_wrapper_structure.cpp | 16 ++++++---------- TestCases/py_wrapper/rotating_cylinder/run.py | 5 ++--- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 74bc0c11059..b2bafc35ea6 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -535,6 +535,7 @@ class CDriver : public CDriverBase { * \param[in] rot_z - Value of Angular velocity about z-axes. */ void SetRotationRate(passivedouble rot_x, passivedouble rot_y, passivedouble rot_z); + /*! * \brief Set the moving wall marker rotation rates. * \param[in] iMaker - Index of moving wall marker. diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index 3e18df5a84d..ede28e36943 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -168,18 +168,14 @@ void CDriver::SetRotationRate(passivedouble rot_x, passivedouble rot_y, passived } void CDriver::SetMarkerRotationRate(unsigned short iMarker, passivedouble rot_x, passivedouble rot_y, passivedouble rot_z) { - for (iZone = 0; iZone < nZone; iZone++) { - config_container[iZone]->SetMarkerRotationRate(iMarker, 0, rot_x); - config_container[iZone]->SetMarkerRotationRate(iMarker, 1, rot_y); - config_container[iZone]->SetMarkerRotationRate(iMarker, 2, rot_z); - } + config_container[selected_zone]->SetMarkerRotationRate(iMarker, 0, rot_x); + config_container[selected_zone]->SetMarkerRotationRate(iMarker, 1, rot_y); + config_container[selected_zone]->SetMarkerRotationRate(iMarker, 2, rot_z); } void CDriver::SetMarkerTranslationRate(unsigned short iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z) { - for (iZone = 0; iZone < nZone; iZone++) { - config_container[iZone]->SetMarkerTranslationRate(iMarker, 0, vel_x); - config_container[iZone]->SetMarkerTranslationRate(iMarker, 1, vel_y); - config_container[iZone]->SetMarkerTranslationRate(iMarker, 2, vel_z); - } + config_container[selected_zone]->SetMarkerTranslationRate(iMarker, 0, vel_x); + config_container[selected_zone]->SetMarkerTranslationRate(iMarker, 1, vel_y); + config_container[selected_zone]->SetMarkerTranslationRate(iMarker, 2, vel_z); } diff --git a/TestCases/py_wrapper/rotating_cylinder/run.py b/TestCases/py_wrapper/rotating_cylinder/run.py index cbf2d968686..737c3dd74ee 100644 --- a/TestCases/py_wrapper/rotating_cylinder/run.py +++ b/TestCases/py_wrapper/rotating_cylinder/run.py @@ -13,9 +13,8 @@ SU2Driver = pysu2.CSinglezoneDriver("spinning_cylinder.cfg",1, comm) -for i in range(n_of_steps): - - SU2Driver.SetMarkerRotationRate(0,0,0,rotation_vector[n_of_steps-i-1]) +for i, rate in enumerate(rotation_vector): + SU2Driver.SetMarkerRotationRate(0,0,0,rate) SU2Driver.Preprocess(i) SU2Driver.Run() SU2Driver.Postprocess() From 8bad923d95e6c6ea9c080975080cc991cf9ad490 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 26 Oct 2023 16:58:48 +0100 Subject: [PATCH 39/99] Changes to address comments --- SU2_CFD/include/output/CTurboOutput.hpp | 60 +++++++++---------- SU2_CFD/include/solvers/CEulerSolver.hpp | 5 +- SU2_CFD/include/solvers/CSolver.hpp | 2 +- .../src/integration/CMultiGridIntegration.cpp | 9 --- SU2_CFD/src/output/CFlowOutput.cpp | 55 +++++++++-------- SU2_CFD/src/output/COutput.cpp | 21 ++----- SU2_CFD/src/output/CTurboOutput.cpp | 16 ++--- 7 files changed, 74 insertions(+), 94 deletions(-) diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp index 4a2c9388caf..a08a845ad8c 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -74,9 +74,9 @@ class CTurbomachineryCombinedPrimitiveStates { CTurbomachineryCombinedPrimitiveStates(const CTurbomachineryPrimitiveState& inletPrimitiveState, const CTurbomachineryPrimitiveState& outletPrimitiveState); - CTurbomachineryPrimitiveState GetInletPrimitiveState() const& { return InletPrimitiveState; } + const CTurbomachineryPrimitiveState& GetInletPrimitiveState() const& { return InletPrimitiveState; } - CTurbomachineryPrimitiveState GetOutletPrimitiveState() const& { return OutletPrimitiveState; } + const CTurbomachineryPrimitiveState& GetOutletPrimitiveState() const& { return OutletPrimitiveState; } }; /*! @@ -98,45 +98,45 @@ class CTurbomachineryState { void ComputeState(CFluidModel& fluidModel, const CTurbomachineryPrimitiveState& primitiveState); - const su2double GetDensity() const { return Density; } + const su2double& GetDensity() const { return Density; } - const su2double GetPressure() const { return Pressure; } + const su2double& GetPressure() const { return Pressure; } - const su2double GetEntropy() const { return Entropy; } + const su2double& GetEntropy() const { return Entropy; } - const su2double GetEnthalpy() const { return Enthalpy; } + const su2double& GetEnthalpy() const { return Enthalpy; } - const su2double GetTemperature() const { return Temperature; } + const su2double& GetTemperature() const { return Temperature; } - const su2double GetTotalTemperature() const { return TotalTemperature; } + const su2double& GetTotalTemperature() const { return TotalTemperature; } - const su2double GetTotalPressure() const { return TotalPressure; } + const su2double& GetTotalPressure() const { return TotalPressure; } - const su2double GetTotalRelPressure() const { return TotalRelPressure; } + const su2double& GetTotalRelPressure() const { return TotalRelPressure; } - const su2double GetTotalEnthalpy() const { return TotalEnthalpy; } + const su2double& GetTotalEnthalpy() const { return TotalEnthalpy; } - const su2double GetAbsFlowAngle() const { return AbsFlowAngle; } + const su2double& GetAbsFlowAngle() const { return AbsFlowAngle; } - const su2double GetFlowAngle() const { return FlowAngle; } + const su2double& GetFlowAngle() const { return FlowAngle; } - const su2double GetMassFlow() const { return MassFlow; } + const su2double& GetMassFlow() const { return MassFlow; } - const su2double GetRothalpy() const { return Rothalpy; } + const su2double& GetRothalpy() const { return Rothalpy; } - const vector GetVelocity() const { return Velocity; } + const vector& GetVelocity() const { return Velocity; } - const vector GetMach() const { return Mach; } + const vector& GetMach() const { return Mach; } - const su2double GetVelocityValue() const { return Norm(Velocity); } + su2double GetVelocityValue() const { return Norm(Velocity); } - const su2double GetMachValue() const { return Norm(Mach); } + const su2double& GetMachValue() const { return Norm(Mach); } - const su2double GetRelVelocityValue() const { return Norm(RelVelocity); } + const su2double& GetRelVelocityValue() const { return Norm(RelVelocity); } - const su2double GetRelMachValue() const { return Norm(RelMach); } + const su2double& GetRelMachValue() const { return Norm(RelMach); } - const su2double Norm(vector const& u) const { + su2double Norm(vector const& u) const { su2double accum = 0.; for (auto i = 0u; i < u.size(); ++i) { accum += u[i] * u[i]; @@ -168,15 +168,15 @@ class CTurbomachineryBladePerformance { const CTurbomachineryState& GetOutletState() { return OutletState; } - const su2double GetKineticEnergyLoss() const { return KineticEnergyLoss; } + const su2double& GetKineticEnergyLoss() const { return KineticEnergyLoss; } - const su2double GetTotalPressureLoss() const { return TotalPressureLoss; } + const su2double& GetTotalPressureLoss() const { return TotalPressureLoss; } - const su2double GetEntropyGen() const { return EntropyGen; } + const su2double& GetEntropyGen() const { return EntropyGen; } - const su2double GetPressureRatio() const { return PressureRatio; } + const su2double& GetPressureRatio() const { return PressureRatio; } - const su2double GetEulerianWork() const { return EulerianWork; } + const su2double& GetEulerianWork() const { return EulerianWork; } }; class CTurbineBladePerformance : public CTurbomachineryBladePerformance { @@ -215,11 +215,11 @@ class CTurbomachineryStagePerformance { virtual ~CTurbomachineryStagePerformance() = default; - virtual void ComputePerformanceStage(CTurbomachineryState InState, CTurbomachineryState OutState, const CConfig* config); + virtual void ComputePerformanceStage(const CTurbomachineryState& InState, const CTurbomachineryState& OutState, const CConfig* config); - virtual void ComputeTurbineStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState); + virtual void ComputeTurbineStagePerformance(const CTurbomachineryState& InState, const CTurbomachineryState& OutState); - virtual void ComputeCompressorStagePerformance(CTurbomachineryState InState, CTurbomachineryState OutState); + virtual void ComputeCompressorStagePerformance(const CTurbomachineryState& InState, const CTurbomachineryState& OutState); const su2double GetTotalStaticEfficiency() const { return TotalStaticEfficiency; } diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 9611aa24843..1e61c53ca06 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -108,8 +108,6 @@ class CEulerSolver : public CFVMFlowSolverBase TurboPrimitive; /*!< \breif Primtive turbo variables vector */ - vector FluidModel; /*!< \brief fluid model used in the solver. */ /*--- Turbomachinery Solver Variables ---*/ @@ -1034,7 +1032,8 @@ class CEulerSolver : public CFVMFlowSolverBase GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool INLET) override { - TurboPrimitive.clear(); + vector TurboPrimitive; + TurboPrimitive.reserve(5); if (INLET) { TurboPrimitive.push_back(DensityIn[iBlade][iSpan]); TurboPrimitive.push_back(PressureIn[iBlade][iSpan]); diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 57d1176c02a..9134c901174 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -3759,7 +3759,7 @@ class CSolver { * iteration can be executed by multiple threads. * \return returns Density, pressure and TurboVelocity (IN/OUTLET) */ - virtual vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool Inlet) { return vector(5, 0.0); } + virtual vector GetTurboPrimitive(unsigned short iBlade, unsigned short iSpan, bool Inlet) { return {}; } /*! * \brief virtual member. diff --git a/SU2_CFD/src/integration/CMultiGridIntegration.cpp b/SU2_CFD/src/integration/CMultiGridIntegration.cpp index 50d37eff541..d335d4d14c4 100644 --- a/SU2_CFD/src/integration/CMultiGridIntegration.cpp +++ b/SU2_CFD/src/integration/CMultiGridIntegration.cpp @@ -680,17 +680,8 @@ void CMultiGridIntegration::NonDimensional_Parameters(CGeometry **geometry, CSol solver_container[FinestMesh][FLOW_SOL]->GatherInOutAverageValues(config, geometry[FinestMesh]); - /* --- compute turboperformance for each stage and the global machine ---*/ - //TODO: for multi-zone turbo this should be move to the last zone ---*/ - // solver_container[FinestMesh][FLOW_SOL]->ComputeTurboPerformance(config, geometry[FinestMesh]); } - /*--- Evaluate the buffet metric if requested ---*/ - /* - if(config->GetnMarker_Monitoring() || config->GetKind_ObjFunc() == BUFFET_SENSOR){ - solver_container[FinestMesh][FLOW_SOL]->Buffet_Monitoring(geometry[FinestMesh], config); - } - */ break; case RUNTIME_ADJFLOW_SYS: diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 91ab160ec6d..cb6e75a5999 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -4054,34 +4054,33 @@ void CFlowOutput::SetFixedCLScreenOutput(const CConfig *config){ void CFlowOutput::AddTurboOutput(unsigned short nZone){ //Adds zone turboperformance history variables for (unsigned short iZone = 0; iZone <= nZone-1; iZone++) { - stringstream tag; - tag << iZone + 1; - AddHistoryOutput("EntropyIn_" + tag.str(), "EntropyIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total pressure loss " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("EntropyOut_" + tag.str(), "EntropyOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Kinetic energy loss " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalEntahalpyIn_" + tag.str(), "TotalEntahalpyIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Entropy generation " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalEnthalpyOut_" + tag.str(), "TotalEnthalpyOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Eulerian work " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalPressureIn_" + tag.str(), "TotPressureIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalPressureOut_" + tag.str(), "TotPressureOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("PressureIn_" + tag.str(), "PressureIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("PressureOut_" + tag.str(), "PressureOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("DensityIn_" + tag.str(), "DensityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle out " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("DensityOut_" + tag.str(), "DensityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("NormalVelocityIn_" + tag.str(), "NormalVelocityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("NormalVelocityOut_" + tag.str(), "NormalVelocityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TangentialVelocityIn_" + tag.str(), "TangentialVelocityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow out " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TangentialVelocityOut_" + tag.str(), "TangentialVelocityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("MassFlowIn_" + tag.str(), "MassFlowIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach out " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("MassFlowOut_" + tag.str(), "MassFlowOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total efficiency " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("MachIn_" + tag.str(), "MachIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("MachOut_" + tag.str(), "MachOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("AbsFlowAngleIn_" + tag.str(), "AbsFlowAngleIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("AbsFlowAngleOut_" + tag.str(), "AbsFlowAngleOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag.str(), HistoryFieldType::DEFAULT); + const auto tag = std::to_string(iZone + 1); + AddHistoryOutput("EntropyIn_" + tag.str(), "EntropyIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total pressure loss " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("EntropyOut_" + tag.str(), "EntropyOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Kinetic energy loss " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalEntahalpyIn_" + tag.str(), "TotalEntahalpyIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Entropy generation " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalEnthalpyOut_" + tag.str(), "TotalEnthalpyOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Eulerian work " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalPressureIn_" + tag.str(), "TotPressureIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalPressureOut_" + tag.str(), "TotPressureOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureIn_" + tag.str(), "PressureIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureOut_" + tag.str(), "PressureOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("DensityIn_" + tag.str(), "DensityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("DensityOut_" + tag.str(), "DensityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("NormalVelocityIn_" + tag.str(), "NormalVelocityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("NormalVelocityOut_" + tag.str(), "NormalVelocityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TangentialVelocityIn_" + tag.str(), "TangentialVelocityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("TangentialVelocityOut_" + tag.str(), "TangentialVelocityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("MassFlowIn_" + tag.str(), "MassFlowIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("MassFlowOut_" + tag.str(), "MassFlowOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total efficiency " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("MachIn_" + tag.str(), "MachIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("MachOut_" + tag.str(), "MachOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("AbsFlowAngleIn_" + tag.str(), "AbsFlowAngleIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("AbsFlowAngleOut_" + tag.str(), "AbsFlowAngleOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag.str(), HistoryFieldType::DEFAULT); } //Adds turbomachinery machine performance variables - AddHistoryOutput("EntropyGeneration", "EntropyGen", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); - AddHistoryOutput("EulerianWork", "EulerianWork", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalStaticEfficiency", "TotStaticEff", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalTotalEfficiency", "TotTotEff", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); - AddHistoryOutput("PressureRatioTS", "PRTS", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); - AddHistoryOutput("PressureRatioTT", "PRTT", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("EntropyGeneration", "EntropyGen", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("EulerianWork", "EulerianWork", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalStaticEfficiency", "TotStaticEff", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalTotalEfficiency", "TotTotEff", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureRatioTS", "PRTS", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureRatioTT", "PRTT", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); } diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index da81bd3a821..3074768b8a5 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -169,8 +169,7 @@ COutput::COutput(const CConfig *config, unsigned short ndim, bool fem_output): volumeDataSorter = nullptr; surfaceDataSorter = nullptr; - headerNeeded = false; - + headerNeeded = false; } COutput::~COutput() { @@ -228,16 +227,7 @@ void COutput::SetHistoryOutput(CGeometry *geometry, } -void COutput::SetHistoryOutput(CGeometry ****geometry, - CSolver *****solver, - CConfig **config, - CTurbomachineryStagePerformance* TurboStagePerf, - std::shared_ptr TurboPerf, - unsigned short val_iZone, - unsigned long TimeIter, - unsigned long OuterIter, - unsigned long InnerIter, - unsigned short val_iInst){ +void COutput::SetHistoryOutput(CGeometry ****geometry, CSolver *****solver, CConfig **config, CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, unsigned short val_iZone, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iInst){ unsigned long Iter= InnerIter; @@ -248,9 +238,10 @@ void COutput::SetHistoryOutput(CGeometry ****geometry, if (Iter%100 == 0) { SetTurboPerformance_Output(TurboPerf, config[val_iZone], TimeIter, OuterIter, InnerIter); if (rank == MASTER_NODE) SetTurboMultiZonePerformance_Output(TurboStagePerf, TurboPerf, config[val_iZone]); - for (int iZone = 0; iZone < config[ZONE_0]->GetnZone(); iZone ++){ - WriteTurboSpanwisePerformance(TurboPerf, geometry[iZone][val_iInst][MESH_0], config, iZone); - } + } + + for (int iZone = 0; iZone < config[ZONE_0]->GetnZone(); iZone ++){ + WriteTurboSpanwisePerformance(TurboPerf, geometry[iZone][val_iInst][MESH_0], config, iZone); } /*--- Update turboperformance history file*/ diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index 600a2987501..335b06e188d 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -2,14 +2,14 @@ * \file CTurboOutput.cpp * \brief Source of the Turbomachinery Performance class * \author S. Vitale, N. Anand - * \version 7.1.1 "Blackbird" + * \version 8.0.0 "Harrier" * * SU2 Project Website: https://su2code.github.io * * The SU2 Project is maintained by the SU2 Foundation * (http://su2foundation.org) * - * Copyright 2012-2019, SU2 Contributors (cf. AUTHORS.md) + * Copyright 2012-2023, SU2 Contributors (cf. AUTHORS.md) * * SU2 is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -222,8 +222,8 @@ void CTurboOutput::ComputePerSpan(shared_ptr co CTurbomachineryStagePerformance::CTurbomachineryStagePerformance(CFluidModel& fluid) : fluidModel(fluid) {} -void CTurbomachineryStagePerformance::ComputePerformanceStage(CTurbomachineryState InState, - CTurbomachineryState OutState, const CConfig* config) { +void CTurbomachineryStagePerformance::ComputePerformanceStage(const CTurbomachineryState& InState, + const CTurbomachineryState& OutState, const CConfig* config) { switch (config->GetKind_TurboPerf(ZONE_0)) { case TURBO_PERF_KIND::TURBINE: ComputeTurbineStagePerformance(InState, OutState); @@ -239,8 +239,8 @@ void CTurbomachineryStagePerformance::ComputePerformanceStage(CTurbomachinerySta } } -void CTurbomachineryStagePerformance::ComputeTurbineStagePerformance(CTurbomachineryState InState, - CTurbomachineryState OutState) { +void CTurbomachineryStagePerformance::ComputeTurbineStagePerformance(const CTurbomachineryState& InState, + const CTurbomachineryState& OutState) { /*--- Compute isentropic Outflow quantities ---*/ fluidModel.SetTDState_Ps(OutState.GetPressure(), InState.GetEntropy()); su2double enthalpyOutIs = fluidModel.GetStaticEnergy() + OutState.GetPressure() / fluidModel.GetDensity(); @@ -255,8 +255,8 @@ void CTurbomachineryStagePerformance::ComputeTurbineStagePerformance(CTurbomachi TotalTotalPressureRatio = InState.GetTotalPressure() / OutState.GetTotalPressure(); } -void CTurbomachineryStagePerformance::ComputeCompressorStagePerformance(CTurbomachineryState InState, - CTurbomachineryState OutState) { +void CTurbomachineryStagePerformance::ComputeCompressorStagePerformance(const CTurbomachineryState& InState, + const CTurbomachineryState& OutState) { /*--- Compute isentropic Outflow quantities ---*/ fluidModel.SetTDState_Ps(OutState.GetPressure(), InState.GetEntropy()); su2double enthalpyOutIs = fluidModel.GetStaticEnergy() + OutState.GetPressure() / fluidModel.GetDensity(); From 4bfcf7b977c8548ec3750f227a60963c833582d9 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 26 Oct 2023 17:49:58 +0100 Subject: [PATCH 40/99] Fixing what I broke --- SU2_CFD/include/output/CTurboOutput.hpp | 6 ++-- SU2_CFD/src/output/CFlowOutput.cpp | 40 ++++++++++++------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp index a08a845ad8c..823c1d48c25 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -130,11 +130,11 @@ class CTurbomachineryState { su2double GetVelocityValue() const { return Norm(Velocity); } - const su2double& GetMachValue() const { return Norm(Mach); } + su2double GetMachValue() const { return Norm(Mach); } - const su2double& GetRelVelocityValue() const { return Norm(RelVelocity); } + su2double GetRelVelocityValue() const { return Norm(RelVelocity); } - const su2double& GetRelMachValue() const { return Norm(RelMach); } + su2double GetRelMachValue() const { return Norm(RelMach); } su2double Norm(vector const& u) const { su2double accum = 0.; diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index cb6e75a5999..5ed2862922a 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -4055,26 +4055,26 @@ void CFlowOutput::AddTurboOutput(unsigned short nZone){ //Adds zone turboperformance history variables for (unsigned short iZone = 0; iZone <= nZone-1; iZone++) { const auto tag = std::to_string(iZone + 1); - AddHistoryOutput("EntropyIn_" + tag.str(), "EntropyIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total pressure loss " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("EntropyOut_" + tag.str(), "EntropyOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Kinetic energy loss " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalEntahalpyIn_" + tag.str(), "TotalEntahalpyIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Entropy generation " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalEnthalpyOut_" + tag.str(), "TotalEnthalpyOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Eulerian work " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalPressureIn_" + tag.str(), "TotPressureIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TotalPressureOut_" + tag.str(), "TotPressureOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("PressureIn_" + tag.str(), "PressureIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("PressureOut_" + tag.str(), "PressureOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("DensityIn_" + tag.str(), "DensityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle out " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("DensityOut_" + tag.str(), "DensityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("NormalVelocityIn_" + tag.str(), "NormalVelocityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("NormalVelocityOut_" + tag.str(), "NormalVelocityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TangentialVelocityIn_" + tag.str(), "TangentialVelocityIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow out " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("TangentialVelocityOut_" + tag.str(), "TangentialVelocityOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("MassFlowIn_" + tag.str(), "MassFlowIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach out " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("MassFlowOut_" + tag.str(), "MassFlowOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total efficiency " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("MachIn_" + tag.str(), "MachIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("MachOut_" + tag.str(), "MachOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("AbsFlowAngleIn_" + tag.str(), "AbsFlowAngleIn_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag.str(), HistoryFieldType::DEFAULT); - AddHistoryOutput("AbsFlowAngleOut_" + tag.str(), "AbsFlowAngleOut_" + tag.str(), ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag.str(), HistoryFieldType::DEFAULT); + AddHistoryOutput("EntropyIn_" + tag, "EntropyIn_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total pressure loss " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("EntropyOut_" + tag, "EntropyOut_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Kinetic energy loss " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalEntahalpyIn_" + tag, "TotalEntahalpyIn_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Entropy generation " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalEnthalpyOut_" + tag, "TotalEnthalpyOut_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Eulerian work " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalPressureIn_" + tag, "TotPressureIn_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("TotalPressureOut_" + tag, "TotPressureOut_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureIn_" + tag, "PressureIn_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Pressure ratio " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("PressureOut_" + tag, "PressureOut_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle in " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("DensityIn_" + tag, "DensityIn_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Flow angle out " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("DensityOut_" + tag, "DensityOut_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("NormalVelocityIn_" + tag, "NormalVelocityIn_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("NormalVelocityOut_" + tag, "NormalVelocityOut_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow in " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("TangentialVelocityIn_" + tag, "TangentialVelocityIn_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mass flow out " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("TangentialVelocityOut_" + tag, "TangentialVelocityOut_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach in " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("MassFlowIn_" + tag, "MassFlowIn_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Mach out " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("MassFlowOut_" + tag, "MassFlowOut_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total efficiency " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("MachIn_" + tag, "MachIn_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("MachOut_" + tag, "MachOut_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Total-to-Static efficiency " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("AbsFlowAngleIn_" + tag, "AbsFlowAngleIn_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle in " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("AbsFlowAngleOut_" + tag, "AbsFlowAngleOut_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Absolute flow angle out " + tag, HistoryFieldType::DEFAULT); } //Adds turbomachinery machine performance variables AddHistoryOutput("EntropyGeneration", "EntropyGen", ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Machine entropy generation", HistoryFieldType::DEFAULT); From a7f4e92312a637d27a2b5b1831bab15a81bd9e21 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Sat, 4 Nov 2023 09:49:52 +0100 Subject: [PATCH 41/99] chaged tests to remove numerical noise, remove unused lines, add name to authors --- AUTHORS.md | 1 + TestCases/hybrid_regression.py | 6 +++--- TestCases/parallel_regression.py | 4 ++-- TestCases/py_wrapper/rotating_cylinder/run.py | 8 +------- TestCases/serial_regression.py | 4 ++-- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index f47640de49a..f8c364f411b 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -71,6 +71,7 @@ Eduardo Molina Edwin van der Weide Ethan Alan Hereth Florian Dittmann +Filip Hahs Francesco Poli Francisco D. Palacios Gaurav Bansal diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index 801ca167f31..11743264640 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -436,7 +436,7 @@ def main(): cavity.cfg_dir = "moving_wall/cavity" cavity.cfg_file = "lam_cavity.cfg" cavity.test_iter = 25 - cavity.test_vals = [-5.627934, -0.164469, 0.052000, 2.547063] + cavity.test_vals = [-5.627868, -0.164404, 0.053310, 2.545839] test_list.append(cavity) # Spinning cylinder @@ -444,8 +444,8 @@ def main(): spinning_cylinder.cfg_dir = "moving_wall/spinning_cylinder" spinning_cylinder.cfg_file = "spinning_cylinder.cfg" spinning_cylinder.test_iter = 25 - spinning_cylinder.test_vals = [-8.001291, -2.607959, 1.501321, 1.488559] - spinning_cylinder.test_vals_aarch64 = [-8.001291, -2.607959, 1.501321, 1.488559] + spinning_cylinder.test_vals = [-8.006541, -2.609759, 1.495662, 1.486341] + spinning_cylinder.test_vals_aarch64 = [-8.006541, -2.609759, 1.495662, 1.486341] test_list.append(spinning_cylinder) ###################################### diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index f26049592b8..f4f3e4ab7b2 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -915,7 +915,7 @@ def main(): cavity.cfg_dir = "moving_wall/cavity" cavity.cfg_file = "lam_cavity.cfg" cavity.test_iter = 25 - cavity.test_vals = [-5.611007, -0.146826, 1.113206, 1.491678] + cavity.test_vals = [-5.610928, -0.146749, 1.114461, 1.490381] test_list.append(cavity) # Spinning cylinder @@ -923,7 +923,7 @@ def main(): spinning_cylinder.cfg_dir = "moving_wall/spinning_cylinder" spinning_cylinder.cfg_file = "spinning_cylinder.cfg" spinning_cylinder.test_iter = 25 - spinning_cylinder.test_vals = [-7.802803, -2.362844, 1.687705, 1.519676] + spinning_cylinder.test_vals = [-7.806016, -2.364954, 1.683365, 1.517059] test_list.append(spinning_cylinder) ###################################### diff --git a/TestCases/py_wrapper/rotating_cylinder/run.py b/TestCases/py_wrapper/rotating_cylinder/run.py index 737c3dd74ee..537cdcb696e 100644 --- a/TestCases/py_wrapper/rotating_cylinder/run.py +++ b/TestCases/py_wrapper/rotating_cylinder/run.py @@ -1,16 +1,10 @@ import pysu2 # imports the SU2 wrapped module -from math import * from mpi4py import MPI import numpy as np comm = MPI.COMM_WORLD rank = comm.Get_rank() -ad_com = MPI.COMM_WORLD -rank_ad = ad_com.Get_rank() -n_of_steps = 10 -rotation_vector = np.zeros(n_of_steps)+20 -rotation_vector[5:9] = -rotation_vector[5:9] - +rotation_vector = np.linspace(0,20,10) SU2Driver = pysu2.CSinglezoneDriver("spinning_cylinder.cfg",1, comm) for i, rate in enumerate(rotation_vector): diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index a8486bc11ea..1ad3263d2e3 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -750,7 +750,7 @@ def main(): cavity.cfg_dir = "moving_wall/cavity" cavity.cfg_file = "lam_cavity.cfg" cavity.test_iter = 25 - cavity.test_vals = [-5.627934, -0.164470, 0.051972, 2.547039] + cavity.test_vals = [ -5.627868, -0.164405, 0.053283, 2.545817] test_list.append(cavity) # Spinning cylinder @@ -758,7 +758,7 @@ def main(): spinning_cylinder.cfg_dir = "moving_wall/spinning_cylinder" spinning_cylinder.cfg_file = "spinning_cylinder.cfg" spinning_cylinder.test_iter = 25 - spinning_cylinder.test_vals = [-7.889994, -2.469385, 1.708162, 1.670039] + spinning_cylinder.test_vals = [-7.892807, -2.467378, 1.702819, 1.669208] test_list.append(spinning_cylinder) ###################################### From d0486c1823ff5bcbe98def4d4cf61fd23a0e14c3 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Sat, 4 Nov 2023 11:46:22 +0100 Subject: [PATCH 42/99] change fsi serial regression test --- TestCases/serial_regression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 1ad3263d2e3..15d9f544ab4 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -1066,7 +1066,7 @@ def main(): airfoilRBF.cfg_dir = "fea_fsi/Airfoil_RBF" airfoilRBF.cfg_file = "config.cfg" airfoilRBF.test_iter = 1 - airfoilRBF.test_vals = [1.000000, -2.786183, -4.977959] + airfoilRBF.test_vals = [ 1.000000, -2.786186, -4.977944] airfoilRBF.multizone = True test_list.append(airfoilRBF) From f5b9698370eccd5192e150db4c216a8b8872e0e1 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 8 Nov 2023 15:33:53 +0000 Subject: [PATCH 43/99] Changes to address comments --- Common/src/CConfig.cpp | 2 +- SU2_CFD/include/iteration/CFluidIteration.hpp | 4 ++-- SU2_CFD/include/iteration/CIteration.hpp | 15 --------------- SU2_CFD/include/iteration/CTurboIteration.hpp | 2 +- SU2_CFD/include/output/CTurboOutput.hpp | 2 +- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 10 ++-------- externals/codi | 2 +- externals/mel | 2 +- subprojects/CoolProp | 2 +- 9 files changed, 10 insertions(+), 31 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index cbb1b3546eb..dee2cc63bef 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -6895,7 +6895,6 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { break; } } - } else { if (Time_Domain) { cout << "Dynamic structural analysis."<< endl; @@ -6903,6 +6902,7 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { } else { cout << "Static structural analysis." << endl; } + } if ((Kind_Solver == MAIN_SOLVER::EULER) || (Kind_Solver == MAIN_SOLVER::NAVIER_STOKES) || (Kind_Solver == MAIN_SOLVER::RANS) || (Kind_Solver == MAIN_SOLVER::INC_EULER) || (Kind_Solver == MAIN_SOLVER::INC_NAVIER_STOKES) || (Kind_Solver == MAIN_SOLVER::INC_RANS) || diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index 3b340f61960..f8f0f72c624 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -110,12 +110,12 @@ class CFluidIteration : public CIteration { /*! * \brief Monitors turbo computation (pressure and turbo ramps). */ - void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) override; + void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter); /*! * \brief Computes turboperformance. */ - void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) override; + void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter); /*! * \brief Postprocesses the fluid system before heading to another physics system or the next iteration. diff --git a/SU2_CFD/include/iteration/CIteration.hpp b/SU2_CFD/include/iteration/CIteration.hpp index f518ad34567..ac2581f12c9 100644 --- a/SU2_CFD/include/iteration/CIteration.hpp +++ b/SU2_CFD/include/iteration/CIteration.hpp @@ -252,21 +252,6 @@ class CIteration { return false; } - /*! - * \brief Monitors turbo computation (pressure and turbo ramps). - */ - virtual void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) {}; - - /*! - * \brief Monitors turbo computation (pressure and turbo ramps). - */ - virtual void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) {}; - - /*! - * \brief Monitors turbo computation (pressure and turbo ramps). - */ - virtual void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid) {} - /*! * \brief A virtual member. * \param[in] output - Pointer to the COutput class. diff --git a/SU2_CFD/include/iteration/CTurboIteration.hpp b/SU2_CFD/include/iteration/CTurboIteration.hpp index ba702d008cf..4b4d9adad04 100644 --- a/SU2_CFD/include/iteration/CTurboIteration.hpp +++ b/SU2_CFD/include/iteration/CTurboIteration.hpp @@ -67,5 +67,5 @@ class CTurboIteration : public CFluidIteration { /*! * \brief Initialises turboperformance classes. */ - void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid) override; + void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid); }; diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp index 823c1d48c25..38bebf8df09 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -227,7 +227,7 @@ class CTurbomachineryStagePerformance { const su2double GetEulerianWork() const { return EulerianWork; } - const su2double GetNormEntropyGen() const { return NormEntropyGen; } + const su2double& GetNormEntropyGen() const { return NormEntropyGen; } const su2double GetTotalStaticPressureRatio() const { return TotalStaticPressureRatio; } diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 6ab4177dd01..36dbdbb4660 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -181,10 +181,8 @@ void CMultizoneDriver::StartSolver() { Preprocess(TimeIter); /*--- Run a block iteration of the multizone problem. ---*/ - switch (driver_config->GetKind_MZSolver()){ - case ENUM_MULTIZONE::MZ_BLOCK_GAUSS_SEIDEL: RunGaussSeidel(); break; // Block Gauss-Seidel iteration - case ENUM_MULTIZONE::MZ_BLOCK_JACOBI: RunJacobi(); break; // Block-Jacobi iteration - } + + Run(); /*--- Update the solution for dual time stepping strategy ---*/ @@ -671,10 +669,6 @@ bool CMultizoneDriver::Monitor(unsigned long TimeIter) { cout << "-------------------------------------------------------------------------" << endl; } - return (FinalTimeReached || MaxIterationsReached); - - - return (FinalTimeReached || MaxIterationsReached); } diff --git a/externals/codi b/externals/codi index eee1b5eea2d..8ee822a9b0b 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit eee1b5eea2ded8126c34c1415e3b9cf15a3e70f2 +Subproject commit 8ee822a9b0bb8235a2494467b774e27fb64ff14f diff --git a/externals/mel b/externals/mel index 46205ab019e..2484cd3258e 160000 --- a/externals/mel +++ b/externals/mel @@ -1 +1 @@ -Subproject commit 46205ab019e5224559091375a6d71aabae6bc5b9 +Subproject commit 2484cd3258ef800a10e361016cb341834ee7930b diff --git a/subprojects/CoolProp b/subprojects/CoolProp index bafdea1f39e..0ce42fcf3bb 160000 --- a/subprojects/CoolProp +++ b/subprojects/CoolProp @@ -1 +1 @@ -Subproject commit bafdea1f39ee873a6bb9833e3a21fe41f90b85e8 +Subproject commit 0ce42fcf3bb2c373512bc825a4f0c1973a78f307 From b9334b10c117e2b4b8a70af1fe44a32214eee39f Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 9 Nov 2023 13:11:54 +0000 Subject: [PATCH 44/99] Fix merge error --- SU2_CFD/src/drivers/CDriver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 6d7b189c7c9..ff80905273b 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -247,7 +247,7 @@ CDriverBase(confFile, val_nZone, MPICommunicator), StopCalc(false), fsi(false), if (rank == MASTER_NODE) cout << endl <<"---------------------- Turbomachinery Preprocessing ---------------------" << endl; - PreprocessTurbomachinery(config_container, geometry_container, solver_container, interface_container); + PreprocessTurbomachinery(config_container, geometry_container, solver_container, interface_container, dummy_geo); } else { mixingplane = false; } From 9ea23bec4400b9544e71f0d1da883beb43379452 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 9 Nov 2023 14:17:04 +0000 Subject: [PATCH 45/99] submodule update --- externals/codi | 2 +- externals/mel | 2 +- subprojects/CoolProp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/externals/codi b/externals/codi index 8ee822a9b0b..0ad036f2c82 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 8ee822a9b0bb8235a2494467b774e27fb64ff14f +Subproject commit 0ad036f2c8254fa7b77180a443d99248c047c877 diff --git a/externals/mel b/externals/mel index 2484cd3258e..46205ab019e 160000 --- a/externals/mel +++ b/externals/mel @@ -1 +1 @@ -Subproject commit 2484cd3258ef800a10e361016cb341834ee7930b +Subproject commit 46205ab019e5224559091375a6d71aabae6bc5b9 diff --git a/subprojects/CoolProp b/subprojects/CoolProp index 0ce42fcf3bb..bafdea1f39e 160000 --- a/subprojects/CoolProp +++ b/subprojects/CoolProp @@ -1 +1 @@ -Subproject commit 0ce42fcf3bb2c373512bc825a4f0c1973a78f307 +Subproject commit bafdea1f39ee873a6bb9833e3a21fe41f90b85e8 From 4e36eee2f72714fb878ff3ae515a3c8ca7ea3c83 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Fri, 10 Nov 2023 16:08:29 +0100 Subject: [PATCH 46/99] more test changes --- TestCases/hybrid_regression_AD.py | 4 ++-- TestCases/serial_regression.py | 2 +- externals/codi | 2 +- externals/mel | 2 +- subprojects/CoolProp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TestCases/hybrid_regression_AD.py b/TestCases/hybrid_regression_AD.py index a2243e14e24..f333c9ba7a9 100644 --- a/TestCases/hybrid_regression_AD.py +++ b/TestCases/hybrid_regression_AD.py @@ -253,8 +253,8 @@ def main(): pywrapper_CFD_AD_MeshDisp.cfg_dir = "py_wrapper/disc_adj_flow/mesh_disp_sens" pywrapper_CFD_AD_MeshDisp.cfg_file = "configAD_flow.cfg" pywrapper_CFD_AD_MeshDisp.test_iter = 1000 - pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.520967, 1.375188, 0.000000] #last 4 columns - pywrapper_CFD_AD_MeshDisp.test_vals_aarch64 = [30.000000, -2.516536, 1.386443, 0.000000] + pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.521399, 1.372319, 0.000000] #last 4 columns + pywrapper_CFD_AD_MeshDisp.test_vals_aarch64 = [30.000000, -2.521399, 1.372319, 0.000000] pywrapper_CFD_AD_MeshDisp.command = TestCase.Command(exec = "python", param = "run_adjoint.py --parallel -f") pywrapper_CFD_AD_MeshDisp.timeout = 1600 pywrapper_CFD_AD_MeshDisp.tol = 1e-4 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 15d9f544ab4..b6d107b6a1b 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -1066,7 +1066,7 @@ def main(): airfoilRBF.cfg_dir = "fea_fsi/Airfoil_RBF" airfoilRBF.cfg_file = "config.cfg" airfoilRBF.test_iter = 1 - airfoilRBF.test_vals = [ 1.000000, -2.786186, -4.977944] + airfoilRBF.test_vals = [1.000000, -2.786183, -4.977961] airfoilRBF.multizone = True test_list.append(airfoilRBF) diff --git a/externals/codi b/externals/codi index 0ad036f2c82..17232fed052 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 0ad036f2c8254fa7b77180a443d99248c047c877 +Subproject commit 17232fed05245dbb8f04a31e274a02d53458c75c diff --git a/externals/mel b/externals/mel index 46205ab019e..2484cd3258e 160000 --- a/externals/mel +++ b/externals/mel @@ -1 +1 @@ -Subproject commit 46205ab019e5224559091375a6d71aabae6bc5b9 +Subproject commit 2484cd3258ef800a10e361016cb341834ee7930b diff --git a/subprojects/CoolProp b/subprojects/CoolProp index bafdea1f39e..0ce42fcf3bb 160000 --- a/subprojects/CoolProp +++ b/subprojects/CoolProp @@ -1 +1 @@ -Subproject commit bafdea1f39ee873a6bb9833e3a21fe41f90b85e8 +Subproject commit 0ce42fcf3bb2c373512bc825a4f0c1973a78f307 From a009c2e271146fc47dfb5c764a226ed15bb79f43 Mon Sep 17 00:00:00 2001 From: Filip Hahs Date: Sun, 12 Nov 2023 16:15:00 +0100 Subject: [PATCH 47/99] Revert "more test changes" This reverts commit 4e36eee2f72714fb878ff3ae515a3c8ca7ea3c83. --- TestCases/hybrid_regression_AD.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/hybrid_regression_AD.py b/TestCases/hybrid_regression_AD.py index 8185eaeba8f..cf419bde4e9 100644 --- a/TestCases/hybrid_regression_AD.py +++ b/TestCases/hybrid_regression_AD.py @@ -253,8 +253,8 @@ def main(): pywrapper_CFD_AD_MeshDisp.cfg_dir = "py_wrapper/disc_adj_flow/mesh_disp_sens" pywrapper_CFD_AD_MeshDisp.cfg_file = "configAD_flow.cfg" pywrapper_CFD_AD_MeshDisp.test_iter = 1000 - pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.521399, 1.372319, 0.000000] #last 4 columns - pywrapper_CFD_AD_MeshDisp.test_vals_aarch64 = [30.000000, -2.521399, 1.372319, 0.000000] + pywrapper_CFD_AD_MeshDisp.test_vals = [30.000000, -2.520967, 1.375188, 0.000000] #last 4 columns + pywrapper_CFD_AD_MeshDisp.test_vals_aarch64 = [30.000000, -2.516536, 1.386443, 0.000000] pywrapper_CFD_AD_MeshDisp.command = TestCase.Command(exec = "python", param = "run_adjoint.py --parallel -f") pywrapper_CFD_AD_MeshDisp.timeout = 1600 pywrapper_CFD_AD_MeshDisp.tol = 1e-3 From d0a280ca768f99a0a2ecee74bb222f6e8cbe5f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 31 Oct 2023 12:39:57 +0100 Subject: [PATCH 48/99] Allow up to 255 colors. --- Common/include/toolboxes/graph_toolbox.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/toolboxes/graph_toolbox.hpp b/Common/include/toolboxes/graph_toolbox.hpp index c5929e8f8da..f1c0854ce27 100644 --- a/Common/include/toolboxes/graph_toolbox.hpp +++ b/Common/include/toolboxes/graph_toolbox.hpp @@ -484,7 +484,7 @@ T createNaturalColoring(Index_t numInnerIndexes) { * \param[out] indexColor - Optional, vector with colors given to the outer indices. * \return Coloring in the same type of the input pattern. */ -template +template T colorSparsePattern(const T& pattern, size_t groupSize = 1, bool balanceColors = false, std::vector* indexColor = nullptr) { static_assert(std::is_integral::value, ""); From 12c63c72133c13e14bf516443b27759ea73d31c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 31 Oct 2023 12:49:58 +0100 Subject: [PATCH 49/99] Report on the number of colors and the efficiency. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 40af46827be..ccf939f1bf1 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -324,6 +324,9 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi << "\n The memory usage of the discrete adjoint solver is higher when using the fallback." #endif << endl; + } else { + cout << "Rank " << SU2_MPI::GetRank() << " uses " << coloring.getOuterSize() << " colors, " + << parallelEff << "efficiency." << endl; } } From 6d34de3428d8b703232d8a68397e71552010c53f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 31 Oct 2023 16:47:53 +0100 Subject: [PATCH 50/99] Add space. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index ccf939f1bf1..bee63030f7d 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -326,7 +326,7 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi << endl; } else { cout << "Rank " << SU2_MPI::GetRank() << " uses " << coloring.getOuterSize() << " colors, " - << parallelEff << "efficiency." << endl; + << parallelEff << " efficiency." << endl; } } From 766d7b1426ec980f06f84de25989073b1b3aa62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Fri, 27 Oct 2023 12:07:46 +0200 Subject: [PATCH 51/99] Maximize color group size per rank. --- Common/src/geometry/CGeometry.cpp | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 9ed1804186a..e912c5aa68f 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3637,6 +3637,42 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- Color the edges. ---*/ constexpr bool balanceColors = true; + + /* find an efficient coloring with maximum possible color group size */ + auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that does not work */ + auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */ + auto lowerEdgeColorGroupSize = 1; /* lower bound that is known to work */ + + while (true) { + auto currentEdgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); + + /* if the coloring fails, reduce the color group size */ + if (currentEdgeColoring.empty()) { + upperEdgeColorGroupSize = nextEdgeColorGroupSize; + nextEdgeColorGroupSize = lowerEdgeColorGroupSize + (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; + continue; + } + + auto currentEfficiency = coloringEfficiency(currentEdgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); + + /* if the coloring is not efficient, reduce the color group size */ + if (currentEfficiency < COLORING_EFF_THRESH) { + upperEdgeColorGroupSize = nextEdgeColorGroupSize; + } + /* otherwise, try to enlarge the color group size */ + else { + lowerEdgeColorGroupSize = nextEdgeColorGroupSize; + } + auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; + + if (increment == 0) { + break; + } + + nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment; + } + + edgeColorGroupSize = lowerEdgeColorGroupSize; edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); /*--- If the coloring fails use the natural coloring. This is a From c454bd84eedbb7101de50fdf8bfd62f4c59b7119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 31 Oct 2023 19:27:12 +0100 Subject: [PATCH 52/99] Add output about chosen color group size. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index bee63030f7d..83eda476613 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -325,8 +325,10 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi #endif << endl; } else { - cout << "Rank " << SU2_MPI::GetRank() << " uses " << coloring.getOuterSize() << " colors, " - << parallelEff << " efficiency." << endl; + cout << "Rank " << SU2_MPI::GetRank() << endl + << "\tnumber of colors " << coloring.getOuterSize() << endl + << "\tcolor group size " << geometry.GetEdgeColorGroupSize() << endl + << "\tefficiency " << parallelEff << endl; } } From 70bf19f28a541374563b0d72d67345f9ef995c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Mon, 13 Nov 2023 17:04:43 +0100 Subject: [PATCH 53/99] Aggregated output of coloring properties on master rank. --- .../include/solvers/CFVMFlowSolverBase.inl | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 83eda476613..14368a547d6 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -325,10 +325,28 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi #endif << endl; } else { - cout << "Rank " << SU2_MPI::GetRank() << endl - << "\tnumber of colors " << coloring.getOuterSize() << endl - << "\tcolor group size " << geometry.GetEdgeColorGroupSize() << endl - << "\tefficiency " << parallelEff << endl; + if (SU2_MPI::GetRank() == MASTER_NODE) { + cout << "All ranks use edge coloring." << endl; + } + } + + su2double coloredParallelEff = ReducerStrategy ? 1.0 : parallelEff; + su2double minColoredParallelEff = 1.0; + SU2_MPI::Reduce(&coloredParallelEff, &minColoredParallelEff, 1, MPI_DOUBLE, MPI_MIN, MASTER_NODE, SU2_MPI::GetComm()); + + unsigned long coloredNumColors = ReducerStrategy ? 0 : coloring.getOuterSize(); + unsigned long maxColoredNumColors = 0; + SU2_MPI::Reduce(&coloredNumColors, &maxColoredNumColors, 1, MPI_UNSIGNED_LONG, MPI_MAX, MASTER_NODE, SU2_MPI::GetComm()); + + unsigned long coloredEdgeColorGroupSize = ReducerStrategy ? 1 << 30 : geometry.GetEdgeColorGroupSize(); + unsigned long minColoredEdgeColorGroupSize = 1 << 30; + SU2_MPI::Reduce(&coloredEdgeColorGroupSize, &minColoredEdgeColorGroupSize, 1, MPI_UNSIGNED_LONG, MPI_MIN, MASTER_NODE, SU2_MPI::GetComm()); + + if (SU2_MPI::GetRank() == MASTER_NODE) { + cout << "Among the ranks that use edge coloring,\n" + << " the minimum efficiency is " << minColoredParallelEff << ",\n" + << " the maximum number of colors is " << maxColoredNumColors << ",\n" + << " the minimum edge color group size is " << minColoredEdgeColorGroupSize << "." << endl; } } From 8a155914c7065efc8cf70c84284b63f92213db91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 14 Nov 2023 13:32:13 +0100 Subject: [PATCH 54/99] Make adaptive edge color group sizes optional. --- Common/include/geometry/CGeometry.hpp | 6 ++- Common/src/geometry/CGeometry.cpp | 58 ++++++++++++++------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index f8111060725..4af65411cc2 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1720,10 +1720,14 @@ class CGeometry { /*! * \brief Get the edge coloring. * \note This method computes the coloring if that has not been done yet. + * \note Can be instructed to determine and use the maximum edge color group size between 1 and + * CGeometry::edgeColorGroupSize that yields a coloring that is at least as efficient as #COLORING_EFF_THRESH. * \param[out] efficiency - optional output of the coloring efficiency. + * \param[in] maximizeEdgeColorGroupSize - use the maximum edge color group size that gives an efficient coloring. * \return Reference to the coloring. */ - const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr); + const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr, + bool maximizeEdgeColorGroupSize = false); /*! * \brief Force the natural (sequential) edge coloring. diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index e912c5aa68f..ffa6a37585c 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3609,7 +3609,7 @@ const su2vector& CGeometry::GetTransposeSparsePatternMap(Connecti return pattern.transposePtr(); } -const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency) { +const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize) { /*--- Check for dry run mode with dummy geometry. ---*/ if (nEdge == 0) return edgeColoring; @@ -3638,41 +3638,45 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- Color the edges. ---*/ constexpr bool balanceColors = true; - /* find an efficient coloring with maximum possible color group size */ - auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that does not work */ - auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */ - auto lowerEdgeColorGroupSize = 1; /* lower bound that is known to work */ + /*--- if requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize) ---*/ + if (maximizeEdgeColorGroupSize) { + auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that is deemed too large */ + auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */ + auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ - while (true) { - auto currentEdgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); + while (true) { + auto currentEdgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); - /* if the coloring fails, reduce the color group size */ - if (currentEdgeColoring.empty()) { - upperEdgeColorGroupSize = nextEdgeColorGroupSize; - nextEdgeColorGroupSize = lowerEdgeColorGroupSize + (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; - continue; - } + /*--- if the coloring fails, reduce the color group size ---*/ + if (currentEdgeColoring.empty()) { + upperEdgeColorGroupSize = nextEdgeColorGroupSize; + nextEdgeColorGroupSize = lowerEdgeColorGroupSize + (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; + continue; + } - auto currentEfficiency = coloringEfficiency(currentEdgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); + su2double currentEfficiency = + coloringEfficiency(currentEdgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); - /* if the coloring is not efficient, reduce the color group size */ - if (currentEfficiency < COLORING_EFF_THRESH) { - upperEdgeColorGroupSize = nextEdgeColorGroupSize; - } - /* otherwise, try to enlarge the color group size */ - else { - lowerEdgeColorGroupSize = nextEdgeColorGroupSize; - } - auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; + /*--- if the coloring is not efficient, reduce the color group size ---*/ + if (currentEfficiency < COLORING_EFF_THRESH) { + upperEdgeColorGroupSize = nextEdgeColorGroupSize; + } + /*--- otherwise, try to enlarge the color group size ---*/ + else { + lowerEdgeColorGroupSize = nextEdgeColorGroupSize; + } + auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; - if (increment == 0) { - break; + nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment; + + if (increment == 0) { + break; + } } - nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment; + edgeColorGroupSize = nextEdgeColorGroupSize; } - edgeColorGroupSize = lowerEdgeColorGroupSize; edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); /*--- If the coloring fails use the natural coloring. This is a From 21a0e4a52d399b7ae43b6eaf8d05b401eeb63cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 14 Nov 2023 13:54:38 +0100 Subject: [PATCH 55/99] Use adaptive edge color group sizes for the discrete adjoint. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 7 +++++++ SU2_CFD/include/solvers/CScalarSolver.inl | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 14368a547d6..9d701789afc 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -288,7 +288,14 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi * sum the fluxes for each cell and set the diagonal of the system matrix. ---*/ su2double parallelEff = 1.0; + +#ifdef CODI_REVERSE_TYPE + /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color + * group size. Find the maximum edge color group size that yields an efficient coloring. ---*/ + const auto& coloring = geometry.GetEdgeColoring(¶llelEff, true); +#else const auto& coloring = geometry.GetEdgeColoring(¶llelEff); +#endif /*--- The decision to use the strategy is local to each rank. ---*/ ReducerStrategy = parallelEff < COLORING_EFF_THRESH; diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 5b6415d65b0..21eac22ead8 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -46,7 +46,13 @@ CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, #ifdef HAVE_OMP /*--- Get the edge coloring, see notes in CEulerSolver's constructor. ---*/ su2double parallelEff = 1.0; +#ifdef CODI_REVERSE_TYPE + /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color + * group size. Find the maximum edge color group size that yields an efficient coloring. ---*/ + const auto& coloring = geometry->GetEdgeColoring(¶llelEff, true); +#else const auto& coloring = geometry->GetEdgeColoring(¶llelEff); +#endif ReducerStrategy = parallelEff < COLORING_EFF_THRESH; From d45447ada250c23ef700cf62c920c5e91c031f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 14 Nov 2023 13:56:19 +0100 Subject: [PATCH 56/99] Larger number of colors for the discrete adjoint. --- Common/include/toolboxes/graph_toolbox.hpp | 2 +- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 5 +++-- SU2_CFD/include/solvers/CScalarSolver.inl | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Common/include/toolboxes/graph_toolbox.hpp b/Common/include/toolboxes/graph_toolbox.hpp index f1c0854ce27..c5929e8f8da 100644 --- a/Common/include/toolboxes/graph_toolbox.hpp +++ b/Common/include/toolboxes/graph_toolbox.hpp @@ -484,7 +484,7 @@ T createNaturalColoring(Index_t numInnerIndexes) { * \param[out] indexColor - Optional, vector with colors given to the outer indices. * \return Coloring in the same type of the input pattern. */ -template +template T colorSparsePattern(const T& pattern, size_t groupSize = 1, bool balanceColors = false, std::vector* indexColor = nullptr) { static_assert(std::is_integral::value, ""); diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 9d701789afc..6d6a76f4ba4 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -291,8 +291,9 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi #ifdef CODI_REVERSE_TYPE /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color - * group size. Find the maximum edge color group size that yields an efficient coloring. ---*/ - const auto& coloring = geometry.GetEdgeColoring(¶llelEff, true); + * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers + * of colors. ---*/ + const auto& coloring = geometry.GetEdgeColoring(¶llelEff, true); #else const auto& coloring = geometry.GetEdgeColoring(¶llelEff); #endif diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 21eac22ead8..3f68ff8d793 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -48,8 +48,9 @@ CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, su2double parallelEff = 1.0; #ifdef CODI_REVERSE_TYPE /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color - * group size. Find the maximum edge color group size that yields an efficient coloring. ---*/ - const auto& coloring = geometry->GetEdgeColoring(¶llelEff, true); + * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers + * of colors. ---*/ + const auto& coloring = geometry->GetEdgeColoring(¶llelEff, true); #else const auto& coloring = geometry->GetEdgeColoring(¶llelEff); #endif From f73946b4d7f91d919087f046e95bda933265520c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 15 Nov 2023 14:27:50 +0100 Subject: [PATCH 57/99] Switch between different numbers of colors. --- Common/include/geometry/CGeometry.hpp | 4 +++- Common/src/geometry/CGeometry.cpp | 16 +++++++++++++--- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 2 +- SU2_CFD/include/solvers/CScalarSolver.inl | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 4af65411cc2..fc5c2931075 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1724,10 +1724,12 @@ class CGeometry { * CGeometry::edgeColorGroupSize that yields a coloring that is at least as efficient as #COLORING_EFF_THRESH. * \param[out] efficiency - optional output of the coloring efficiency. * \param[in] maximizeEdgeColorGroupSize - use the maximum edge color group size that gives an efficient coloring. + * \param[in] largeNumberOfColors - allow up to 255 colors instead of 64 (default) * \return Reference to the coloring. */ const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr, - bool maximizeEdgeColorGroupSize = false); + bool maximizeEdgeColorGroupSize = false, + bool largeNumberOfColors = false); /*! * \brief Force the natural (sequential) edge coloring. diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index ffa6a37585c..b88ef3d2198 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3609,7 +3609,8 @@ const su2vector& CGeometry::GetTransposeSparsePatternMap(Connecti return pattern.transposePtr(); } -const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize) { +const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize, + bool largeNumberOfColors) { /*--- Check for dry run mode with dummy geometry. ---*/ if (nEdge == 0) return edgeColoring; @@ -3638,6 +3639,15 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- Color the edges. ---*/ constexpr bool balanceColors = true; + /*--- lambda to account for different numbers of colors ---*/ + auto getColorSparsePattern = [&](unsigned long edgeColorGroupSize) { + if (largeNumberOfColors) { + return colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); + } else { + return colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); + } + }; + /*--- if requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize) ---*/ if (maximizeEdgeColorGroupSize) { auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that is deemed too large */ @@ -3645,7 +3655,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ while (true) { - auto currentEdgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); + auto currentEdgeColoring = getColorSparsePattern(nextEdgeColorGroupSize); /*--- if the coloring fails, reduce the color group size ---*/ if (currentEdgeColoring.empty()) { @@ -3677,7 +3687,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien edgeColorGroupSize = nextEdgeColorGroupSize; } - edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); + edgeColoring = getColorSparsePattern(edgeColorGroupSize); /*--- If the coloring fails use the natural coloring. This is a * "soft" failure as this "bad" coloring should be detected diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 6d6a76f4ba4..3710340d0a7 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -293,7 +293,7 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers * of colors. ---*/ - const auto& coloring = geometry.GetEdgeColoring(¶llelEff, true); + const auto& coloring = geometry.GetEdgeColoring(¶llelEff, true, true); #else const auto& coloring = geometry.GetEdgeColoring(¶llelEff); #endif diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index 3f68ff8d793..ea2d6925066 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -50,7 +50,7 @@ CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers * of colors. ---*/ - const auto& coloring = geometry->GetEdgeColoring(¶llelEff, true); + const auto& coloring = geometry->GetEdgeColoring(¶llelEff, true, true); #else const auto& coloring = geometry->GetEdgeColoring(¶llelEff); #endif From 3cc21215140d4be6d29d472101c82940e4acabaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 15 Nov 2023 16:21:56 +0100 Subject: [PATCH 58/99] Further relax hybrid AD python wrapper test tolerances. --- TestCases/hybrid_regression_AD.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/hybrid_regression_AD.py b/TestCases/hybrid_regression_AD.py index cf419bde4e9..5ffeb5d71f0 100644 --- a/TestCases/hybrid_regression_AD.py +++ b/TestCases/hybrid_regression_AD.py @@ -242,7 +242,7 @@ def main(): pywrapper_FEA_AD_FlowLoad.test_vals_aarch64 = [-0.131745, -0.553214, -0.000364, -0.003101] pywrapper_FEA_AD_FlowLoad.command = TestCase.Command(exec = "python", param = "run_adjoint.py --parallel -f") pywrapper_FEA_AD_FlowLoad.timeout = 1600 - pywrapper_FEA_AD_FlowLoad.tol = 1e-3 + pywrapper_FEA_AD_FlowLoad.tol = 1e-2 pywrapper_FEA_AD_FlowLoad.new_output = False pywrapper_FEA_AD_FlowLoad.enabled_with_tsan = False test_list.append(pywrapper_FEA_AD_FlowLoad) @@ -257,7 +257,7 @@ def main(): pywrapper_CFD_AD_MeshDisp.test_vals_aarch64 = [30.000000, -2.516536, 1.386443, 0.000000] pywrapper_CFD_AD_MeshDisp.command = TestCase.Command(exec = "python", param = "run_adjoint.py --parallel -f") pywrapper_CFD_AD_MeshDisp.timeout = 1600 - pywrapper_CFD_AD_MeshDisp.tol = 1e-3 + pywrapper_CFD_AD_MeshDisp.tol = 1e-2 pywrapper_CFD_AD_MeshDisp.new_output = False pywrapper_CFD_AD_MeshDisp.enabled_with_tsan = False test_list.append(pywrapper_CFD_AD_MeshDisp) From db1ef8bd4c917ca29305219cc4a647671c4ac46a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 16 Nov 2023 15:46:25 +0100 Subject: [PATCH 59/99] Add config option for discrete adjoint coloring relaxation. --- Common/include/CConfig.hpp | 6 ++++++ Common/src/CConfig.cpp | 3 +++ SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 3 ++- SU2_CFD/include/solvers/CScalarSolver.inl | 3 ++- config_template.cfg | 8 ++++++++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index da11f902606..c5999023515 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1188,6 +1188,7 @@ class CConfig { string caseName; /*!< \brief Name of the current case */ unsigned long edgeColorGroupSize; /*!< \brief Size of the edge groups colored for OpenMP parallelization of edge loops. */ + bool edgeColoringRelaxDiscAdj; /*!< \brief Allow fallback to smaller edge color group sizes and use more colors for the discrete adjoint. */ INLET_SPANWISE_INTERP Kind_InletInterpolationFunction; /*!brief type of spanwise interpolation function to use for the inlet face. */ INLET_INTERP_TYPE Kind_Inlet_InterpolationType; /*!brief type of spanwise interpolation data to use for the inlet face. */ @@ -9738,6 +9739,11 @@ class CConfig { */ unsigned long GetEdgeColoringGroupSize(void) const { return edgeColorGroupSize; } + /*! + * \brief Check if the discrete adjoint is allowed to relax the coloring, that is, allow smaller edge color group sizes and allow more colors. + */ + bool GetEdgeColoringRelaxDiscAdj(void) const { return edgeColoringRelaxDiscAdj; } + /*! * \brief Get the ParMETIS load balancing tolerance. */ diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index a34902142cf..2a82d959af7 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -2952,6 +2952,9 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: Size of the edge groups colored for thread parallel edge loops (0 forces the reducer strategy). */ addUnsignedLongOption("EDGE_COLORING_GROUP_SIZE", edgeColorGroupSize, 512); + /* DESCRIPTION: Allow fallback to smaller edge color group sizes for the discrete adjoint and allow more colors. */ + addBoolOption("EDGE_COLORING_RELAX_DISC_ADJ", edgeColoringRelaxDiscAdj, true); + /*--- options that are used for libROM ---*/ /*!\par CONFIG_CATEGORY:libROM options \ingroup Config*/ diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 3710340d0a7..db39cde78c0 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -293,7 +293,8 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers * of colors. ---*/ - const auto& coloring = geometry.GetEdgeColoring(¶llelEff, true, true); + const bool relax = config.GetEdgeColoringRelaxDiscAdj(); + const auto& coloring = geometry.GetEdgeColoring(¶llelEff, relax, relax); #else const auto& coloring = geometry.GetEdgeColoring(¶llelEff); #endif diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index ea2d6925066..d9f17d17e7b 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -50,7 +50,8 @@ CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, /*--- For the discrete adjoint, the reducer strategy is costly. Prefer coloring, possibly with reduced edge color * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers * of colors. ---*/ - const auto& coloring = geometry->GetEdgeColoring(¶llelEff, true, true); + const bool relax = config->GetEdgeColoringRelaxDiscAdj(); + const auto& coloring = geometry->GetEdgeColoring(¶llelEff, relax, relax); #else const auto& coloring = geometry->GetEdgeColoring(¶llelEff); #endif diff --git a/config_template.cfg b/config_template.cfg index 774d55875e8..ff2862f3924 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -1680,6 +1680,14 @@ UQ_DELTA_B= 1.0 % The optimum value/strategy is case-dependent. EDGE_COLORING_GROUP_SIZE= 512 % +% Coloring tends to perform better for the discrete adjoint than reductions because +% it uses less memory and enables the shared reading optimization for color loops. +% This option allows an automatic fallback to smaller edge color group sizes on ranks +% where the requested edge color group size is not efficient. Specifically, the largest +% edge color group size up to EDGE_COLORING_GROUP_SIZE is chosen that is at least +% 0.875 efficient. Also, this option allows using more colors, up to 255 instead of up to 64. +EDGE_COLORING_RELAX_DISC_ADJ= yes +% % Independent "threads per MPI rank" setting for LU-SGS and ILU preconditioners. % For problems where time is spend mostly in the solution of linear systems (e.g. elasticity, % very high CFL central schemes), AND, if the memory bandwidth of the machine is saturated From 88b127224064d6578d17b456a6f98aa2337ea9f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Fri, 17 Nov 2023 13:43:15 +0100 Subject: [PATCH 60/99] Avoid void. --- Common/include/CConfig.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index c5999023515..2cb959fc3fc 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -9742,7 +9742,7 @@ class CConfig { /*! * \brief Check if the discrete adjoint is allowed to relax the coloring, that is, allow smaller edge color group sizes and allow more colors. */ - bool GetEdgeColoringRelaxDiscAdj(void) const { return edgeColoringRelaxDiscAdj; } + bool GetEdgeColoringRelaxDiscAdj() const { return edgeColoringRelaxDiscAdj; } /*! * \brief Get the ParMETIS load balancing tolerance. From c6681e4e4a2cdfe9186916e2750dae65fa797dc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 22 Nov 2023 14:10:22 +0100 Subject: [PATCH 61/99] Capitalization. --- config_template.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_template.cfg b/config_template.cfg index de4cf72416e..ea621b85e7e 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -2146,7 +2146,7 @@ EDGE_COLORING_GROUP_SIZE= 512 % where the requested edge color group size is not efficient. Specifically, the largest % edge color group size up to EDGE_COLORING_GROUP_SIZE is chosen that is at least % 0.875 efficient. Also, this option allows using more colors, up to 255 instead of up to 64. -EDGE_COLORING_RELAX_DISC_ADJ= yes +EDGE_COLORING_RELAX_DISC_ADJ= YES % % Independent "threads per MPI rank" setting for LU-SGS and ILU preconditioners. % For problems where time is spend mostly in the solution of linear systems (e.g. elasticity, From 2fd31fce9c8e7fdd655b0305a2b218296ca731c4 Mon Sep 17 00:00:00 2001 From: rois1995 Date: Thu, 30 Nov 2023 18:08:29 +0100 Subject: [PATCH 62/99] - Fixed CGNS writing --- .../src/output/filewriter/CCGNSFileWriter.cpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp b/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp index 34f75473b61..6e370d02a68 100644 --- a/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp @@ -38,7 +38,7 @@ void CCGNSFileWriter::WriteData(string val_filename) { /*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/ val_filename.append(fileExt); - + /*--- Open the CGNS file for writing. ---*/ InitializeMeshFile(val_filename); @@ -132,15 +132,16 @@ void CCGNSFileWriter::WriteField(int iField, const string& FieldName) { /*--- Coordinate vector is written in blocks, one for each process. ---*/ cgsize_t nodeBegin = 1; auto nodeEnd = static_cast(nLocalPoints); - - if (isCoord) { - int CoordinateNumber; - CallCGNS(cg_coord_partial_write(cgnsFileID, cgnsBase, cgnsZone, dataType, FieldName.c_str(), &nodeBegin, &nodeEnd, - sendBufferField.data(), &CoordinateNumber)); - } else { - int fieldNumber; - CallCGNS(cg_field_partial_write(cgnsFileID, cgnsBase, cgnsZone, cgnsFields, dataType, FieldName.c_str(), &nodeBegin, - &nodeEnd, sendBufferField.data(), &fieldNumber)); + if(nLocalPoints > 0){ + if (isCoord) { + int CoordinateNumber; + CallCGNS(cg_coord_partial_write(cgnsFileID, cgnsBase, cgnsZone, dataType, FieldName.c_str(), &nodeBegin, &nodeEnd, + sendBufferField.data(), &CoordinateNumber)); + } else { + int fieldNumber; + CallCGNS(cg_field_partial_write(cgnsFileID, cgnsBase, cgnsZone, cgnsFields, dataType, FieldName.c_str(), &nodeBegin, + &nodeEnd, sendBufferField.data(), &fieldNumber)); + } } for (int i = 0; i < size; ++i) { From 35fb9d2f9ee6dfc06c4a06d782a5cade1c954ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 30 Nov 2023 19:22:27 +0100 Subject: [PATCH 63/99] No output if all ranks use the reducer strategy. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index db39cde78c0..fd2eb13328f 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -351,7 +351,7 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi unsigned long minColoredEdgeColorGroupSize = 1 << 30; SU2_MPI::Reduce(&coloredEdgeColorGroupSize, &minColoredEdgeColorGroupSize, 1, MPI_UNSIGNED_LONG, MPI_MIN, MASTER_NODE, SU2_MPI::GetComm()); - if (SU2_MPI::GetRank() == MASTER_NODE) { + if (SU2_MPI::GetRank() == MASTER_NODE && numRanksUsingReducer != SU2_MPI::GetSize()) { cout << "Among the ranks that use edge coloring,\n" << " the minimum efficiency is " << minColoredParallelEff << ",\n" << " the maximum number of colors is " << maxColoredNumColors << ",\n" From a84f9caa435882e8382a6251b3302df92d1613a9 Mon Sep 17 00:00:00 2001 From: Nijso Date: Thu, 30 Nov 2023 21:05:24 +0100 Subject: [PATCH 64/99] Update SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp --- SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp b/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp index 6e370d02a68..4399586c86b 100644 --- a/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp @@ -38,7 +38,6 @@ void CCGNSFileWriter::WriteData(string val_filename) { /*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/ val_filename.append(fileExt); - /*--- Open the CGNS file for writing. ---*/ InitializeMeshFile(val_filename); From f25a4f2c86329b36ffa16ffb1dfe5f9377892f8a Mon Sep 17 00:00:00 2001 From: Nijso Date: Thu, 30 Nov 2023 21:07:12 +0100 Subject: [PATCH 65/99] Update SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp --- SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp b/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp index 4399586c86b..a4b89f39551 100644 --- a/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp @@ -131,7 +131,7 @@ void CCGNSFileWriter::WriteField(int iField, const string& FieldName) { /*--- Coordinate vector is written in blocks, one for each process. ---*/ cgsize_t nodeBegin = 1; auto nodeEnd = static_cast(nLocalPoints); - if(nLocalPoints > 0){ + if (nLocalPoints > 0) { if (isCoord) { int CoordinateNumber; CallCGNS(cg_coord_partial_write(cgnsFileID, cgnsBase, cgnsZone, dataType, FieldName.c_str(), &nodeBegin, &nodeEnd, From 619b21c8f2712759039b31ee7a95f284674c2c32 Mon Sep 17 00:00:00 2001 From: rois1995 Date: Fri, 1 Dec 2023 11:40:34 +0100 Subject: [PATCH 66/99] - Added regression test for CGNS writer --- TestCases/CGNSWrite/config.cfg | 187 +++++++++++++++++++++++++++++++ TestCases/parallel_regression.py | 14 +++ 2 files changed, 201 insertions(+) create mode 100644 TestCases/CGNSWrite/config.cfg diff --git a/TestCases/CGNSWrite/config.cfg b/TestCases/CGNSWrite/config.cfg new file mode 100644 index 00000000000..faeeea3f4f8 --- /dev/null +++ b/TestCases/CGNSWrite/config.cfg @@ -0,0 +1,187 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Transonic simulation RAE2822 (RANS) % +% Author: Francisco Palacios % +% Institution: Stanford University % +% Date: 5/15/2013 % +% File Version 7.4.0 "Blackbird" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= RANS +% +% Specify turbulent model (NONE, SA, SA_NEG, SST) +KIND_TURB_MODEL= SST +% +% Mathematical problem (DIRECT, CONTINUOUS_ADJOINT) +MATH_PROBLEM= DIRECT +% +% Restart solution (NO, YES) +RESTART_SOL= NO + +% -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% +% +% Mach number (non-dimensional, based on the free-stream values) +MACH_NUMBER= 0.2 +% AirSpeed = 279.9663 +% Density = 1.225 +% +% Angle of attack (degrees, only for compressible flows) +AOA= 0.0 +% Free-stream temperature (288.15 K by default) +FREESTREAM_TEMPERATURE= 270.0 +% +% Reynolds number (non-dimensional, based on the free-stream values) +REYNOLDS_NUMBER= 3.28E6 +% +% Reynolds length (1 m by default) +REYNOLDS_LENGTH= 1 +REF_DIMENSIONALIZATION= FREESTREAM_VEL_EQ_MACH + +% ---------------------- REFERENCE VALUE DEFINITION ---------------------------% +% +% Reference origin for moment computation +REF_ORIGIN_MOMENT_X = -0.2473 +REF_ORIGIN_MOMENT_Y = 0.00 +REF_ORIGIN_MOMENT_Z = 0.00 +% +% Reference length for pitching, rolling, and yawing non-dimensional moment +REF_LENGTH= 1 +% +% Reference area for force coefficients (0 implies automatic calculation) +% Body tube cross-area +REF_AREA= 1 + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +% Navier-Stokes wall boundary marker(s) (NONE = no marker) +MARKER_HEATFLUX= ( OuterWall, 0.0, InnerWall, 0.0 ) +% +% Farfield boundary marker(s) (NONE = no marker) +MARKER_FAR= ( Inlet, Outlet ) + +% +% +% Marker(s) of the surface to be plotted or designed +MARKER_PLOTTING= ( InnerWall ) +% +% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated +MARKER_MONITORING= ( InnerWall ) + + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1.0e-6 +% lower memory consumption: +LINEAR_SOLVER_ITER= 15 +% +% -------------------------- MULTIGRID PARAMETERS -----------------------------% +% + +NEWTON_KRYLOV= NO +NEWTON_KRYLOV_IPARAM= (10, 5, 2) % n0, np, ft +NEWTON_KRYLOV_DPARAM= (1.0, 0.01, -6, 1e-5) % r0, tp, rf, e +CFL_ADAPT= YES +CFL_NUMBER= 1 +CFL_REDUCTION_TURB= 1.0 +% +CFL_ADAPT_PARAM= ( 0.5, 1.01, 1.0, 5, 0.0001) + +ITER= 1 + +MGLEVEL= 0 +% +MGCYCLE= V_CYCLE +MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) +MG_POST_SMOOTH= ( 1, 1, 1, 1 ) +MG_CORRECTION_SMOOTH= ( 1, 1, 1, 1 ) +MG_DAMP_RESTRICTION= 0.5 +MG_DAMP_PROLONGATION= 0.5 + +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +% Convective numerical method (JST, LAX-FRIEDRICH, CUSP, ROE, AUSM, HLLC, +% TURKEL_PREC, MSW) +CONV_NUM_METHOD_FLOW= ROE +USE_VECTORIZATION= YES +% +% Monotonic Upwind Scheme for Conservation Laws (TVD) in the flow equations. +% Required for 2nd order upwind schemes (NO, YES) +MUSCL_FLOW= NO +% +% Slope limiter (VENKATAKRISHNAN, MINMOD) +SLOPE_LIMITER_FLOW= VENKATAKRISHNAN +% +% Coefficient for the limiter (smooth regions) +VENKAT_LIMITER_COEFF= 0.03 +% +% 2nd and 4th order artificial dissipation coefficients +JST_SENSOR_COEFF= ( 0.5, 0.02 ) +% +% Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT, EULER_EXPLICIT) +TIME_DISCRE_FLOW= EULER_IMPLICIT + +% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% +% +% Convective numerical method (SCALAR_UPWIND) +CONV_NUM_METHOD_TURB= SCALAR_UPWIND +% +% Monotonic Upwind Scheme for Conservation Laws (TVD) in the turbulence equations. +% Required for 2nd order upwind schemes (NO, YES) +MUSCL_TURB= NO +% +% Time discretization (EULER_IMPLICIT) +TIME_DISCRE_TURB= EULER_IMPLICIT + + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_FIELD= MOMENT_X +CONV_STARTITER= 10 +CONV_CAUCHY_ELEMS= 100 +CONV_CAUCHY_EPS= 1E-6 +% + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +% Mesh input file +MESH_FILENAME= mesh.cgns +% +% Mesh input file format (SU2, CGNS, NETCDF_ASCII) +MESH_FORMAT= CGNS +% +% Restart flow input file +SOLUTION_FILENAME= restart_flow +% +TABULAR_FORMAT= CSV +% +% Output file convergence history (w/o extension) +CONV_FILENAME= history_First +% +% Output file restart flow +RESTART_FILENAME= restart_flow +% +% Output file flow (w/o extension) variables +VOLUME_FILENAME= flow +% +% Output file surface flow coefficient (w/o extension) +SURFACE_FILENAME= surface_flow +% +% Writing solution file frequency +OUTPUT_WRT_FREQ= 100 +% +% +% Screen output fields +SCREEN_OUTPUT= (INNER_ITER, WALL_TIME, RMS_DENSITY, LIFT, DRAG, MOMENT_Z) +OUTPUT_FILES= (SURFACE_CGNS) +WRT_FORCES_BREAKDOWN= NO +VOLUME_OUTPUT= (COORDINATES) +HISTORY_OUTPUT= (ITER) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 3278b46e737..481f355e9eb 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1555,6 +1555,20 @@ def main(): species3_multizone_restart.multizone = True test_list.append(species3_multizone_restart) + ##################### + ## CGNS writer ### + ##################### + + # CGNS writer + CGNSWrite = TestCase('CGNSWrite') + CGNSWrite.cfg_dir = "CGNSWrite" + CGNSWrite.cfg_file = "config.cfg" + CGNSWrite.test_iter = 1 + CGNSWrite.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] + CGNSWrite.command = TestCase.Command("mpirun -n 2", "SU2_CFD") + CGNSWrite.new_output = True + test_list.append(CGNSWrite) + ###################################### ### RUN TESTS ### ###################################### From 6124e0fe836f8257df94881d1de24707ccacd970 Mon Sep 17 00:00:00 2001 From: rois1995 Date: Fri, 1 Dec 2023 12:47:01 +0100 Subject: [PATCH 67/99] - changed mesh for regression case --- TestCases/CGNSWrite/config.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/CGNSWrite/config.cfg b/TestCases/CGNSWrite/config.cfg index faeeea3f4f8..bfad06bafd9 100644 --- a/TestCases/CGNSWrite/config.cfg +++ b/TestCases/CGNSWrite/config.cfg @@ -153,10 +153,10 @@ CONV_CAUCHY_EPS= 1E-6 % ------------------------- INPUT/OUTPUT INFORMATION --------------------------% % % Mesh input file -MESH_FILENAME= mesh.cgns +MESH_FILENAME= mesh.su2 % % Mesh input file format (SU2, CGNS, NETCDF_ASCII) -MESH_FORMAT= CGNS +MESH_FORMAT= SU2 % % Restart flow input file SOLUTION_FILENAME= restart_flow From 90bc63b15fffa0b64903891d82fcdcdd8ec640d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= <55186095+jblueh@users.noreply.github.com> Date: Fri, 1 Dec 2023 16:28:19 +0100 Subject: [PATCH 68/99] Update Common/src/geometry/CGeometry.cpp Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- Common/src/geometry/CGeometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index b88ef3d2198..fd6b2c92bd4 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3639,7 +3639,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- Color the edges. ---*/ constexpr bool balanceColors = true; - /*--- lambda to account for different numbers of colors ---*/ + /*--- Lambda to account for different numbers of colors. ---*/ auto getColorSparsePattern = [&](unsigned long edgeColorGroupSize) { if (largeNumberOfColors) { return colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); From 39168b58e021e25b29ff148762389d8af3913df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Fri, 1 Dec 2023 16:36:33 +0100 Subject: [PATCH 69/99] Add const. --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index fd2eb13328f..2f86931ac2b 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -339,15 +339,15 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi } } - su2double coloredParallelEff = ReducerStrategy ? 1.0 : parallelEff; + const su2double coloredParallelEff = ReducerStrategy ? 1.0 : parallelEff; su2double minColoredParallelEff = 1.0; SU2_MPI::Reduce(&coloredParallelEff, &minColoredParallelEff, 1, MPI_DOUBLE, MPI_MIN, MASTER_NODE, SU2_MPI::GetComm()); - unsigned long coloredNumColors = ReducerStrategy ? 0 : coloring.getOuterSize(); + const unsigned long coloredNumColors = ReducerStrategy ? 0 : coloring.getOuterSize(); unsigned long maxColoredNumColors = 0; SU2_MPI::Reduce(&coloredNumColors, &maxColoredNumColors, 1, MPI_UNSIGNED_LONG, MPI_MAX, MASTER_NODE, SU2_MPI::GetComm()); - unsigned long coloredEdgeColorGroupSize = ReducerStrategy ? 1 << 30 : geometry.GetEdgeColorGroupSize(); + const unsigned long coloredEdgeColorGroupSize = ReducerStrategy ? 1 << 30 : geometry.GetEdgeColorGroupSize(); unsigned long minColoredEdgeColorGroupSize = 1 << 30; SU2_MPI::Reduce(&coloredEdgeColorGroupSize, &minColoredEdgeColorGroupSize, 1, MPI_UNSIGNED_LONG, MPI_MIN, MASTER_NODE, SU2_MPI::GetComm()); From e6ac3dbb06a6ca80ba81ef4f11be8f809b9b7e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Fri, 1 Dec 2023 16:43:52 +0100 Subject: [PATCH 70/99] More const. --- Common/src/geometry/CGeometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index fd6b2c92bd4..eaafe9d49b5 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3664,7 +3664,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien continue; } - su2double currentEfficiency = + const su2double currentEfficiency = coloringEfficiency(currentEdgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); /*--- if the coloring is not efficient, reduce the color group size ---*/ From 09efb1ae7614fd988ddc83e9c8dd8c6b3fc39863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Fri, 1 Dec 2023 18:06:32 +0100 Subject: [PATCH 71/99] Increase the default number of colors. --- Common/include/geometry/CGeometry.hpp | 4 +--- Common/include/toolboxes/graph_toolbox.hpp | 2 +- Common/src/geometry/CGeometry.cpp | 18 ++++-------------- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 2 +- SU2_CFD/include/solvers/CScalarSolver.inl | 2 +- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index fc5c2931075..4af65411cc2 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1724,12 +1724,10 @@ class CGeometry { * CGeometry::edgeColorGroupSize that yields a coloring that is at least as efficient as #COLORING_EFF_THRESH. * \param[out] efficiency - optional output of the coloring efficiency. * \param[in] maximizeEdgeColorGroupSize - use the maximum edge color group size that gives an efficient coloring. - * \param[in] largeNumberOfColors - allow up to 255 colors instead of 64 (default) * \return Reference to the coloring. */ const CCompressedSparsePatternUL& GetEdgeColoring(su2double* efficiency = nullptr, - bool maximizeEdgeColorGroupSize = false, - bool largeNumberOfColors = false); + bool maximizeEdgeColorGroupSize = false); /*! * \brief Force the natural (sequential) edge coloring. diff --git a/Common/include/toolboxes/graph_toolbox.hpp b/Common/include/toolboxes/graph_toolbox.hpp index c5929e8f8da..f1c0854ce27 100644 --- a/Common/include/toolboxes/graph_toolbox.hpp +++ b/Common/include/toolboxes/graph_toolbox.hpp @@ -484,7 +484,7 @@ T createNaturalColoring(Index_t numInnerIndexes) { * \param[out] indexColor - Optional, vector with colors given to the outer indices. * \return Coloring in the same type of the input pattern. */ -template +template T colorSparsePattern(const T& pattern, size_t groupSize = 1, bool balanceColors = false, std::vector* indexColor = nullptr) { static_assert(std::is_integral::value, ""); diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index eaafe9d49b5..08d81daf59f 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3609,8 +3609,7 @@ const su2vector& CGeometry::GetTransposeSparsePatternMap(Connecti return pattern.transposePtr(); } -const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize, - bool largeNumberOfColors) { +const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficiency, bool maximizeEdgeColorGroupSize) { /*--- Check for dry run mode with dummy geometry. ---*/ if (nEdge == 0) return edgeColoring; @@ -3639,15 +3638,6 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- Color the edges. ---*/ constexpr bool balanceColors = true; - /*--- Lambda to account for different numbers of colors. ---*/ - auto getColorSparsePattern = [&](unsigned long edgeColorGroupSize) { - if (largeNumberOfColors) { - return colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); - } else { - return colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); - } - }; - /*--- if requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize) ---*/ if (maximizeEdgeColorGroupSize) { auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that is deemed too large */ @@ -3655,7 +3645,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ while (true) { - auto currentEdgeColoring = getColorSparsePattern(nextEdgeColorGroupSize); + const auto currentEdgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); /*--- if the coloring fails, reduce the color group size ---*/ if (currentEdgeColoring.empty()) { @@ -3675,7 +3665,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien else { lowerEdgeColorGroupSize = nextEdgeColorGroupSize; } - auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; + const auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment; @@ -3687,7 +3677,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien edgeColorGroupSize = nextEdgeColorGroupSize; } - edgeColoring = getColorSparsePattern(edgeColorGroupSize); + edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); /*--- If the coloring fails use the natural coloring. This is a * "soft" failure as this "bad" coloring should be detected diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 2f86931ac2b..c2af5a18d82 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -294,7 +294,7 @@ void CFVMFlowSolverBase::HybridParallelInitialization(const CConfig& confi * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers * of colors. ---*/ const bool relax = config.GetEdgeColoringRelaxDiscAdj(); - const auto& coloring = geometry.GetEdgeColoring(¶llelEff, relax, relax); + const auto& coloring = geometry.GetEdgeColoring(¶llelEff, relax); #else const auto& coloring = geometry.GetEdgeColoring(¶llelEff); #endif diff --git a/SU2_CFD/include/solvers/CScalarSolver.inl b/SU2_CFD/include/solvers/CScalarSolver.inl index d9f17d17e7b..343944ebd6c 100644 --- a/SU2_CFD/include/solvers/CScalarSolver.inl +++ b/SU2_CFD/include/solvers/CScalarSolver.inl @@ -51,7 +51,7 @@ CScalarSolver::CScalarSolver(CGeometry* geometry, CConfig* config, * group size. Find the maximum edge color group size that yields an efficient coloring. Also, allow larger numbers * of colors. ---*/ const bool relax = config->GetEdgeColoringRelaxDiscAdj(); - const auto& coloring = geometry->GetEdgeColoring(¶llelEff, relax, relax); + const auto& coloring = geometry->GetEdgeColoring(¶llelEff, relax); #else const auto& coloring = geometry->GetEdgeColoring(¶llelEff); #endif From 3ee6027398458ef732ec6cf8888d50bddca594bc Mon Sep 17 00:00:00 2001 From: Mickael PHILIT Date: Sat, 2 Dec 2023 10:18:26 +0100 Subject: [PATCH 72/99] Upgrade external CGNS library to 4.4 release. --- externals/cgns/adf/ADF_interface.c | 6 +- externals/cgns/adf/ADF_internals.c | 4 +- externals/cgns/adfh/ADFH.c | 312 +- externals/cgns/adfh/ADFH.h | 4 +- externals/cgns/cg_hashmap.c | 11 +- externals/cgns/cgns_error.c | 4 +- externals/cgns/cgns_header.h | 10 +- externals/cgns/cgns_internals.c | 39 +- externals/cgns/cgns_io.h | 2 +- externals/cgns/cgnslib.c | 4575 ++++++++++++++++++++++++---- externals/cgns/cgnslib.h | 26 +- externals/cgns/pcgnslib.c | 1063 +++++-- externals/cgns/pcgnslib.h | 19 +- 13 files changed, 5143 insertions(+), 932 deletions(-) diff --git a/externals/cgns/adf/ADF_interface.c b/externals/cgns/adf/ADF_interface.c index 11c3502069a..59bd59d5466 100644 --- a/externals/cgns/adf/ADF_interface.c +++ b/externals/cgns/adf/ADF_interface.c @@ -1209,7 +1209,7 @@ else { /** this node is NOT a link **/ CHECK_ADF_ABORT( *error_return ) ; for( i=0; i 0 && lenfilename == strlen( link_data ) ) +else if ( lenfilename == strlen( link_data ) ) { strcpy( file, link_data) ; /** no link ? **/ } @@ -1688,7 +1688,7 @@ if ( lenfilename == 0 ) /** no filename **/ { *len_name = (int)strlen(link_data) - 1; } -else if ( lenfilename > 0 && lenfilename == strlen( link_data ) ) +else if ( lenfilename == strlen( link_data ) ) { *len_file = (int)lenfilename; } diff --git a/externals/cgns/adf/ADF_internals.c b/externals/cgns/adf/ADF_internals.c index a52878e13d6..27c673df9b8 100644 --- a/externals/cgns/adf/ADF_internals.c +++ b/externals/cgns/adf/ADF_internals.c @@ -155,7 +155,7 @@ bytes start end description range / format Variable: min 32 Data-chunks -(Minimum is 32 bytes, which cooresponds to the size required for a free-chunk) +(Minimum is 32 bytes, which corresponds to the size required for a free-chunk) bytes start end description range / format 4 0 3 "DaTa" boundary tag Tag 12 4 15 Pointer to End-of-Data-Tag @@ -7187,7 +7187,7 @@ NULL_STRING_POINTER ADF_FILE_NOT_OPENED PRISTK_NOT_FOUND Note: errors are only important for GET mode since you must then go ahead - and read the data fom the file. The stack is only meant to speed things + and read the data from the file. The stack is only meant to speed things up, not stop the process !!! ***********************************************************************/ int ADFI_stack_control( const unsigned int file_index, diff --git a/externals/cgns/adfh/ADFH.c b/externals/cgns/adfh/ADFH.c index 703cd0b62f6..94ec80cc491 100644 --- a/externals/cgns/adfh/ADFH.c +++ b/externals/cgns/adfh/ADFH.c @@ -61,6 +61,18 @@ static int CompressData = -1; #define ADFH_CONFIG_DEFAULT 0 +#if H5_VERSION_GE(1,10,3) && !defined(H5_USE_18_API) && !defined(H5_USE_16_API) +#define ADFH_HDF5_HAVE_110_API 1 +#else +#define ADFH_HDF5_HAVE_110_API 0 +#endif + +#if H5_VERSION_GE(1,12,0) && !defined(H5_USE_110_API) && !defined(H5_USE_18_API) && !defined(H5_USE_16_API) +#define ADFH_HDF5_HAVE_112_API 1 +#else +#define ADFH_HDF5_HAVE_112_API 0 +#endif + /*** HDF5's CORE FILE DRIVER PARAMETERS ****/ /* Enables using the core file driver */ @@ -72,11 +84,12 @@ static size_t core_vfd_increment = 10L*1024L*1024L; static hbool_t core_vfd_backing_store = ADFH_CONFIG_DEFAULT; /** MISC. HDF5 OPTIMIZATION TUNING PARAMETERS */ -static hsize_t h5pset_alignment_threshold = ADFH_CONFIG_DEFAULT; -static hsize_t h5pset_alignment_alignment = ADFH_CONFIG_DEFAULT; -static hsize_t h5pset_meta_block_size_size = ADFH_CONFIG_DEFAULT; -static hsize_t h5pset_buffer_size_size = ADFH_CONFIG_DEFAULT; -static hsize_t h5pset_sieve_buf_size_size = ADFH_CONFIG_DEFAULT; +static hsize_t h5pset_alignment_threshold = ADFH_CONFIG_DEFAULT; +static hsize_t h5pset_alignment_alignment = ADFH_CONFIG_DEFAULT; +static hsize_t h5pset_meta_block_size_size = ADFH_CONFIG_DEFAULT; +static hsize_t h5pset_buffer_size_size = ADFH_CONFIG_DEFAULT; +static hsize_t h5pset_sieve_buf_size_size = ADFH_CONFIG_DEFAULT; +static unsigned h5pset_elink_file_cache_size_size = ADFH_CONFIG_DEFAULT; #define TO_UPPER( c ) ((islower(c))?(toupper(c)):(c)) @@ -155,10 +168,9 @@ printf aaa ; printf("\n"); fflush(stdout); #define ADFH_MODE_RDO 3 /* the following keeps track of open and mounted files */ +#define ADFH_MAXIMUM_FILES 1024 -#define ADFH_MAXIMUM_FILES 128 - -/* Start to prepare re-entrance into lib, gather statics in one global struct */ +/* Start to prepare re-entrance into lib, gather static variables in one global struct */ /* Then, you'll just have to handle struct with something else but a static... */ /* MTA stands for... Multi-Threads-Aware */ typedef struct _ADFH_MTA { @@ -179,6 +191,9 @@ typedef struct _ADFH_MTA { int g_flags; hid_t g_files[ADFH_MAXIMUM_FILES]; + /* tracking and indexing settings for link creation order */ + unsigned int link_create_order; + #ifndef ADFH_FORCE_ID_CLOSE /* object ids returned to API user that should be closed */ hid_t *g_extids[ADFH_MAXIMUM_FILES]; @@ -289,7 +304,7 @@ if (mta_root == NULL){set_error(ADFH_ERR_ROOTNULL, err);return 1;} static herr_t gfind_by_name(hid_t, const char *, const H5L_info_t*, void *); static herr_t find_by_name(hid_t, const char *, const H5A_info_t*, void *); -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API #define has_child(ID,NAME) H5Literate2(ID, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, gfind_by_name, (void *)NAME) #define has_data(ID) H5Literate2(ID, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, gfind_by_name, (void *)D_DATA) #else @@ -366,7 +381,7 @@ static hid_t get_file_id (hid_t id) int token_cmp; /* find the file ID from the root ID */ -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API if (H5Oget_info_by_name3(id, "/", &gstat, H5O_INFO_BASIC, H5P_DEFAULT) >=0) { #else if (H5Oget_info_by_name(id, "/", &gstat, H5P_DEFAULT) >=0) { @@ -377,7 +392,7 @@ static hid_t get_file_id (hid_t id) if (objs == NULL) return fid; H5Fget_obj_ids(H5F_OBJ_ALL, H5F_OBJ_FILE, -1, objs); for (n = 0; n < nobj; n++) { -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API H5Oget_info_by_name3(objs[n], "/", &rstat, H5O_INFO_BASIC, H5P_DEFAULT); token_cmp = 1; if(gstat.fileno == rstat.fileno){ @@ -1053,7 +1068,7 @@ static herr_t compare_children(hid_t id, const char *name, const H5L_info_t *lin if (*name != D_PREFIX) { pstat = (H5O_info_t *)data; -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API if (H5Oget_info_by_name3(id, name, &stat, H5O_INFO_BASIC, H5P_DEFAULT) >= 0){ token_cmp = 1; if(pstat->fileno == stat.fileno){ @@ -1160,7 +1175,7 @@ static hid_t open_link(hid_t id, int *err) } } #ifdef ADFH_DEBUG_ON -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API H5Oget_info3(lid, &oinfo, H5O_INFO_BASIC); #else H5Oget_info(lid, &oinfo); @@ -1268,7 +1283,7 @@ static herr_t delete_children(hid_t id, const char *name, const H5L_info_t* linf } else { ADFH_DEBUG(("delete_children loop")); -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API if (! is_link(id)) H5Literate_by_name2(id, name, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, delete_children, data, H5P_DEFAULT); #else if (! is_link(id)) H5Literate_by_name(id, name, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, delete_children, data, H5P_DEFAULT); @@ -1428,7 +1443,7 @@ static herr_t fix_dimensions(hid_t id, const char *name, const H5L_info_t* linfo if (*name != D_PREFIX && (gid = H5Gopen2(id, name, H5P_DEFAULT)) >= 0 && !get_str_att(gid, A_TYPE, type, &err) && strcmp(type, ADFH_LK)) { -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API H5Literate2(gid, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, fix_dimensions, NULL); #else H5Literate(gid, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, fix_dimensions, NULL); @@ -1448,12 +1463,14 @@ static herr_t fix_dimensions(hid_t id, const char *name, const H5L_info_t* linfo void ADFH_Configure(const int option, const void *value, int *err) { if (option == ADFH_CONFIG_RESET && (int)((size_t)value == ADFH_CONFIG_RESET_HDF5)) { - core_vfd = ADFH_CONFIG_DEFAULT; - h5pset_alignment_threshold = ADFH_CONFIG_DEFAULT; - h5pset_alignment_alignment = ADFH_CONFIG_DEFAULT; - h5pset_meta_block_size_size = ADFH_CONFIG_DEFAULT; - h5pset_buffer_size_size = ADFH_CONFIG_DEFAULT; - h5pset_sieve_buf_size_size = ADFH_CONFIG_DEFAULT; + core_vfd = ADFH_CONFIG_DEFAULT; + h5pset_alignment_threshold = ADFH_CONFIG_DEFAULT; + h5pset_alignment_alignment = ADFH_CONFIG_DEFAULT; + h5pset_meta_block_size_size = ADFH_CONFIG_DEFAULT; + h5pset_buffer_size_size = ADFH_CONFIG_DEFAULT; + h5pset_sieve_buf_size_size = ADFH_CONFIG_DEFAULT; + h5pset_elink_file_cache_size_size = ADFH_CONFIG_DEFAULT; + set_error(NO_ERROR, err); return; } @@ -1498,6 +1515,10 @@ void ADFH_Configure(const int option, const void *value, int *err) h5pset_sieve_buf_size_size = (hsize_t)value; set_error(NO_ERROR, err); } + else if (option == ADFH_CONFIG_ELINK_FILE_CACHE_SIZE) { + h5pset_elink_file_cache_size_size = (unsigned)((size_t)value); + set_error(NO_ERROR, err); + } #if CG_BUILD_PARALLEL else if (option == ADFH_CONFIG_MPI_COMM) { MPI_Comm* comm = (MPI_Comm*)value; @@ -1550,7 +1571,7 @@ void ADFH_Move_Child(const double pid, /* check that node is actually child of the parent */ -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API if (H5Oget_info_by_name3(hid, ".", &stat, H5O_INFO_BASIC, H5P_DEFAULT) < 0 || !H5Literate2(hpid, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, NULL, compare_children, (void *)&stat)) { #else @@ -1606,7 +1627,7 @@ void ADFH_Move_Child(const double pid, set_int_att(hid, A_ORDER, new_order, err)) return; /*see if we need to decrement any node _orders under the old parent*/ -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API *err = H5Literate2(hpid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, fix_order, (void *)&old_order); #else *err = H5Literate(hpid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, fix_order, (void *)&old_order); @@ -1717,7 +1738,7 @@ void ADFH_Get_Label(const double id, { hid_t hid; char bufflabel[ADF_LABEL_LENGTH+1] = ""; - ADFH_DEBUG((">ADFH_Get_Label [%d]",id)); + ADFH_DEBUG((">ADFH_Get_Label [%f]",id)); if (label == NULL) { set_error(NULL_STRING_POINTER, err); @@ -1792,7 +1813,7 @@ void ADFH_Create(const double pid, new_int_att(gid, A_FLAGS, mta_root->g_flags, err)) return; #else int order = 0; -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API H5Literate2(hpid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, count_children, (void *)&order); #else H5Literate(hpid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, count_children, (void *)&order); @@ -1838,7 +1859,7 @@ void ADFH_Delete(const double pid, /* check that node is actually child of the parent */ -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API if (H5Oget_info_by_name3(hid, ".", &stat, H5O_INFO_BASIC, H5P_DEFAULT) < 0 || !H5Literate2(hpid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, compare_children, (void *)&stat)){ #else @@ -1862,7 +1883,7 @@ void ADFH_Delete(const double pid, if (! is_link(hid)) { -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API H5Literate2(hid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, delete_children, NULL); #else H5Literate(hid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, delete_children, NULL); @@ -1877,7 +1898,7 @@ void ADFH_Delete(const double pid, /* decrement node orders */ #ifndef ADFH_NO_ORDER -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API *err = H5Literate2(hpid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, fix_order, (void *)&old_order); #else *err = H5Literate(hpid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, fix_order, (void *)&old_order); @@ -1906,10 +1927,10 @@ void ADFH_Number_of_Children(const double id, *number = 0; if ((hid = open_node(id, err)) >= 0) { -#if H5_VERSION_GE(1,12,0) - H5Literate2(hid, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, &gskip, count_children, (void *)number); +#if ADFH_HDF5_HAVE_112_API + H5Literate2(hid, mta_root->link_create_order, H5_ITER_NATIVE, &gskip, count_children, (void *)number); #else - H5Literate(hid, H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, &gskip, count_children, (void *)number); + H5Literate(hid, mta_root->link_create_order, H5_ITER_NATIVE, &gskip, count_children, (void *)number); #endif H5Gclose(hid); } @@ -1928,8 +1949,6 @@ void ADFH_Get_Node_ID(const double pid, hid_t sid, hpid; to_HDF_ID(pid,hpid); - ADFH_DEBUG((">ADFH_Get_Node_ID [%s][%d]",name,hpid)); - if (name == NULL) { set_error(NULL_STRING_POINTER, err); return; @@ -1939,6 +1958,8 @@ void ADFH_Get_Node_ID(const double pid, return; } + ADFH_DEBUG((">ADFH_Get_Node_ID [%s][%d]",name,hpid)); + *id = 0; set_error(NO_ERROR, err); if (*name == '/') { @@ -2011,11 +2032,10 @@ void ADFH_Children_Names(const double pid, #ifdef ADFH_NO_ORDER mta_root->i_count = 0; #endif - /*initialize names to null*/ - memset(names, 0, ilen*name_length); + memset(names, 0, (size_t)ilen*(size_t)name_length); if ((hpid = open_node(pid, err)) >= 0) { -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API H5Literate2(hpid,H5_INDEX_CRT_ORDER,H5_ITER_INC, NULL,children_names,(void *)names); #else @@ -2024,7 +2044,7 @@ void ADFH_Children_Names(const double pid, #endif if (names[0]==0) { -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API H5Literate2(hpid,H5_INDEX_NAME,H5_ITER_INC, NULL,children_names,(void *)names); #else @@ -2065,22 +2085,17 @@ void ADFH_Children_IDs(const double pid, mta_root->i_count = 0; #endif if ((hpid = open_node(pid, err)) >= 0) { -#if H5_VERSION_GE(1,12,0) - H5Literate2(hpid,H5_INDEX_CRT_ORDER,H5_ITER_INC, +#if ADFH_HDF5_HAVE_112_API + H5Literate2(hpid,mta_root->link_create_order,H5_ITER_INC, NULL,children_ids,(void *)IDs); #else - H5Literate(hpid,H5_INDEX_CRT_ORDER,H5_ITER_INC, + H5Literate(hpid,mta_root->link_create_order,H5_ITER_INC, NULL,children_ids,(void *)IDs); #endif if (IDs[0]==-1) { -#if H5_VERSION_GE(1,12,0) - H5Literate2(hpid,H5_INDEX_NAME,H5_ITER_INC, - NULL,children_ids,(void *)IDs); -#else - H5Literate(hpid,H5_INDEX_NAME,H5_ITER_INC, - NULL,children_ids,(void *)IDs); -#endif + set_error(CHILDREN_IDS_NOT_FOUND, err); + return; } H5Gclose(hpid); } @@ -2114,8 +2129,6 @@ void ADFH_Database_Open(const char *name, int i, pos, mode; hid_t g_propfileopen; - ADFH_DEBUG(("ADFH_Database_Open [%s]",name)); - /* to be thread safe, should have critical section here */ if (mta_root==NULL) { @@ -2128,6 +2141,8 @@ void ADFH_Database_Open(const char *name, */ mta_root->g_flags = 1; + mta_root->link_create_order = H5_INDEX_CRT_ORDER; + #ifndef ADFH_DEBUG_ON H5Eset_auto2(H5E_DEFAULT, NULL, NULL); #endif @@ -2156,6 +2171,8 @@ void ADFH_Database_Open(const char *name, return; } + ADFH_DEBUG(("ADFH_Database_Open [%s]",name)); + /* get open mode */ strncpy(buff, stat, 9); @@ -2230,14 +2247,17 @@ void ADFH_Database_Open(const char *name, /* HDF5 tuning parameters */ - /* http://www.hdfgroup.org/HDF5/doc/RM/H5P/H5Pset_meta_block_size.htm - * default setting is 2048 bytes + /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title72 + * 'Sets the minimum metadata block size.' + * Default setting is 2048 bytes. */ if ( h5pset_meta_block_size_size != ADFH_CONFIG_DEFAULT ) { H5Pset_meta_block_size(g_propfileopen, h5pset_meta_block_size_size); } - /* http://hdfgroup.org/HDF5/doc/RM/H5P/H5Pset_alignment.htm - * attention: this can increase filesize dramatically if lots of small datasets + /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title41 + * 'Sets alignment properties of a file access property list.' + * Default is no alignment. + * ATTENTION: this can increase filesize dramatically if lots of small datasets */ if ( h5pset_alignment_alignment != ADFH_CONFIG_DEFAULT ) { H5Pset_alignment(g_propfileopen, @@ -2245,42 +2265,36 @@ void ADFH_Database_Open(const char *name, h5pset_alignment_alignment); } - /* http://www.hdfgroup.org/HDF5/doc/RM/H5P/H5Pset_buffer.htm - * 1 MByte is default of hdf5 + /* https://docs.hdfgroup.org/hdf5/develop/group___d_x_p_l.html#title16 + * 'Sets type conversion and background buffers. + * 1 MByte is default. */ if ( h5pset_buffer_size_size != ADFH_CONFIG_DEFAULT ) { void *tconv=NULL; void *bkg=NULL; H5Pset_buffer(g_propfileopen, h5pset_buffer_size_size, tconv, bkg); } - /* http://hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetSieveBufSize - * '.. used by file drivers that are capable of using data sieving' - * 1 MByte is default of hdf5 + /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title78 + * 'Used by file drivers that are capable of using data sieving.' + * 1 MByte is default. */ if ( h5pset_sieve_buf_size_size != ADFH_CONFIG_DEFAULT ) { H5Pset_sieve_buf_size(g_propfileopen, h5pset_sieve_buf_size_size); } + /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title48 + * 'Sets the number of files that can be held open in an external link open file cache.' + * 0 size is default. + */ + if ( h5pset_elink_file_cache_size_size != ADFH_CONFIG_DEFAULT ) { + H5Pset_elink_file_cache_size(g_propfileopen, h5pset_elink_file_cache_size_size); + } + #ifdef ADFH_H5F_CLOSE_STRONG /* set access property to close all open accesses when file closed */ H5Pset_fclose_degree(g_propfileopen, H5F_CLOSE_STRONG); #endif - /* Patch to read file created with CGNS 3.3 and hdf5 > 1.8 */ - if (mode == ADFH_MODE_RDO) { - H5Pset_libver_bounds(g_propfileopen, - H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); - } - else { - /* Compatibility with V1.8 */ - H5Pset_libver_bounds(g_propfileopen, -#if H5_VERSION_GE(1,10,3) - H5F_LIBVER_V18, H5F_LIBVER_V18); -#else - H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); -#endif - } - /* open the file */ #if CG_BUILD_PARALLEL @@ -2314,41 +2328,61 @@ void ADFH_Database_Open(const char *name, set_error(NO_ERROR, err); if (mode == ADFH_MODE_NEW) { + + /* Compatibility with V1.8 */ + H5Pset_libver_bounds(g_propfileopen, +#if ADFH_HDF5_HAVE_110_API + H5F_LIBVER_V18, H5F_LIBVER_V18); +#else + H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); +#endif + hid_t g_propfilecreate = H5Pcreate(H5P_FILE_CREATE); - /* HDF5 tuning parameters */ + /* HDF5 tuning parameters */ - /* http://www.hdfgroup.org/HDF5/doc/RM/H5P/H5Pset_meta_block_size.htm - * default setting is 2048 bytes - */ - if ( h5pset_meta_block_size_size != ADFH_CONFIG_DEFAULT ) { - H5Pset_meta_block_size(g_propfileopen, h5pset_meta_block_size_size); - } + /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title72 + * 'Sets the minimum metadata block size.' + * Default setting is 2048 bytes. + */ + if ( h5pset_meta_block_size_size != ADFH_CONFIG_DEFAULT ) { + H5Pset_meta_block_size(g_propfileopen, h5pset_meta_block_size_size); + } + /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title41 + * 'Sets alignment properties of a file access property list.' + * Default is no alignment. + * ATTENTION: this can increase filesize dramatically if lots of small datasets + */ + if ( h5pset_alignment_alignment != ADFH_CONFIG_DEFAULT ) { + H5Pset_alignment(g_propfileopen, + h5pset_alignment_threshold, + h5pset_alignment_alignment); + } - /* http://hdfgroup.org/HDF5/doc/RM/H5P/H5Pset_alignment.htm - * attention: this can increase filesize dramatically if lots of small datasets - */ - if ( h5pset_alignment_alignment != ADFH_CONFIG_DEFAULT ) { - H5Pset_alignment(g_propfileopen, - h5pset_alignment_threshold, - h5pset_alignment_alignment); - } + /* https://docs.hdfgroup.org/hdf5/develop/group___d_x_p_l.html#title16 + * 'Sets type conversion and background buffers. + * 1 MByte is default. + */ + if ( h5pset_buffer_size_size != ADFH_CONFIG_DEFAULT ) { + void *tconv=NULL; void *bkg=NULL; + H5Pset_buffer(g_propfileopen, h5pset_buffer_size_size, tconv, bkg); + } - /* http://www.hdfgroup.org/HDF5/doc/RM/H5P/H5Pset_buffer.htm - * 1 MByte is default of hdf5 - */ - if ( h5pset_buffer_size_size != ADFH_CONFIG_DEFAULT) { - void *tconv=NULL; void *bkg=NULL; - H5Pset_buffer(g_propfileopen, h5pset_buffer_size_size, tconv, bkg); - } + /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title78 + * 'Used by file drivers that are capable of using data sieving.' + * 1 MByte is default. + */ + if ( h5pset_sieve_buf_size_size != ADFH_CONFIG_DEFAULT ) { + H5Pset_sieve_buf_size(g_propfileopen, h5pset_sieve_buf_size_size); + } - /* http://hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetSieveBufSize - * '.. used by file drivers that are capable of using data sieving' - * 1 MByte is default of hdf5 - */ - if ( h5pset_sieve_buf_size_size != ADFH_CONFIG_DEFAULT) { - H5Pset_sieve_buf_size(g_propfileopen, h5pset_sieve_buf_size_size); - } + /* https://docs.hdfgroup.org/hdf5/develop/group___f_a_p_l.html#title48 + * 'Sets the number of files that can be held open in an external link open file cache.' + * 0 size is default. + */ + if ( h5pset_elink_file_cache_size_size != ADFH_CONFIG_DEFAULT ) { + H5Pset_elink_file_cache_size(g_propfileopen, h5pset_elink_file_cache_size_size); + } #if 0 /* MSB -- DISABLED as it is not compatible with HDF5 1.8 file format, need to resolve this CGNS-166 */ #if HDF5_HAVE_FILE_SPACE_STRATEGY @@ -2360,6 +2394,7 @@ void ADFH_Database_Open(const char *name, (prop set to file creation )*/ H5Pset_link_creation_order(g_propfilecreate, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED); + fid = H5Fcreate(name, H5F_ACC_TRUNC, g_propfilecreate, g_propfileopen); H5Pclose(g_propfilecreate); H5Pclose(g_propfileopen); @@ -2381,7 +2416,7 @@ void ADFH_Database_Open(const char *name, } } else { -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API if (H5Fis_accessible(name, H5P_DEFAULT) <= 0) { #else if (H5Fis_hdf5(name) <= 0) { @@ -2390,29 +2425,80 @@ void ADFH_Database_Open(const char *name, set_error(ADFH_ERR_NOT_HDF5_FILE, err); return; } + #if CG_BUILD_PARALLEL #if HDF5_HAVE_COLL_METADATA H5Pset_all_coll_metadata_ops( g_propfileopen, 1 ); #endif #endif if (mode == ADFH_MODE_RDO) { + /* Patch to read file created with CGNS 3.3 and hdf5 > 1.8 */ + H5Pset_libver_bounds(g_propfileopen, + H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); fid = H5Fopen(name, H5F_ACC_RDONLY, g_propfileopen); } else { + +#if !ADFH_HDF5_HAVE_110_API + H5Pset_libver_bounds(g_propfileopen, + H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); +#endif + fid = H5Fopen(name, H5F_ACC_RDWR, g_propfileopen); + +#if ADFH_HDF5_HAVE_110_API + hid_t access_fapl = H5Fget_access_plist(fid); + + H5F_libver_t low, high; /* File format bounds */ + H5Pget_libver_bounds(access_fapl, &low, &high); + + if(low > H5F_LIBVER_V18) { + /* NOTE: HDF5 can not downgrade to a lower version bound (which can be done with h5repack), so + the best that can be done is not to use a version higher than the lower bound. */ + H5Fset_libver_bounds(fid, low, low); + } else { + H5Fset_libver_bounds(fid, H5F_LIBVER_V18, H5F_LIBVER_V18); + } + + H5Pclose(access_fapl); +#endif + } H5Pclose(g_propfileopen); if (fid < 0) { set_error(FILE_OPEN_ERROR, err); return; } + + /* + NOTE: Creation order was set by default in CGNS 3.1.3, so a + CGNS file created by earlier versions will not have this set. + Therefore, it should not be automatically assumed to be set in + H5Literate. + */ + gid = H5Gopen2(fid, "/", H5P_DEFAULT); + + /* Obtain the group creation flags and check for link creation ordering. */ + { + hid_t pid; + unsigned int crt_order_flags; + pid = H5Gget_create_plist(gid); + H5Pget_link_creation_order(pid, &crt_order_flags); + if (crt_order_flags == 0) { + mta_root->link_create_order = H5_INDEX_NAME; + } else { + mta_root->link_create_order = H5_INDEX_CRT_ORDER; + } + H5Pclose(pid); + } + #ifdef ADFH_FORTRAN_INDEXING if (mode != ADFH_MODE_RDO && child_exists(gid, D_OLDVERS)) { -#if H5_VERSION_GE(1,12,0) - H5Literate2(gid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, fix_dimensions, NULL); +#if ADFH_HDF5_HAVE_112_API + H5Literate2(gid, mta_root->link_create_order, H5_ITER_INC, NULL, fix_dimensions, NULL); #else - H5Literate(gid, H5_INDEX_CRT_ORDER, H5_ITER_INC, NULL, fix_dimensions, NULL); + H5Literate(gid, mta_root->link_create_order, H5_ITER_INC, NULL, fix_dimensions, NULL); #endif H5Lmove(gid, D_OLDVERS, gid, D_VERSION, H5P_DEFAULT, H5P_DEFAULT); } @@ -2437,7 +2523,7 @@ void ADFH_Database_Valid(const char *name, if (NULL == name || 0 == *name) *err = NULL_STRING_POINTER; else -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API *err = H5Fis_accessible(name, H5P_DEFAULT); #else *err = H5Fis_hdf5(name); @@ -2510,7 +2596,7 @@ void ADFH_Database_Delete(const char *name, { ADFH_DEBUG(("ADFH_Database_Delete [%s]",name)); -#if H5_VERSION_GE(1,12,0) +#if ADFH_HDF5_HAVE_112_API if (H5Fis_accessible(name, H5P_DEFAULT) <=0) #else if (H5Fis_hdf5(name) <= 0) @@ -2572,7 +2658,7 @@ void ADFH_Database_Close(const double root, nobj = H5Fget_obj_count(fid, H5F_OBJ_DATATYPE|H5F_OBJ_LOCAL); #ifdef ADFH_DEBUG_ON - printf("%s close DataType [%d] HIDs\n",ADFH_PREFIX,nobj); + printf("%s close DataType [%zd] HIDs\n",ADFH_PREFIX,nobj); #endif if (nobj) { H5Fget_obj_ids(fid, H5F_OBJ_DATATYPE|H5F_OBJ_LOCAL, -1, objs); @@ -2584,7 +2670,7 @@ void ADFH_Database_Close(const double root, nobj = H5Fget_obj_count(fid, H5F_OBJ_DATASET|H5F_OBJ_LOCAL); #ifdef ADFH_DEBUG_ON - printf("%s close DataSet [%d] HIDs\n",ADFH_PREFIX,nobj); + printf("%s close DataSet [%zd] HIDs\n",ADFH_PREFIX,nobj); #endif if (nobj) { H5Fget_obj_ids(fid, H5F_OBJ_DATASET|H5F_OBJ_LOCAL, -1, objs); @@ -2596,7 +2682,7 @@ void ADFH_Database_Close(const double root, nobj = H5Fget_obj_count(fid, H5F_OBJ_ATTR|H5F_OBJ_LOCAL); #ifdef ADFH_DEBUG_ON - printf("%s close Attr [%d] HIDs\n",ADFH_PREFIX,nobj); + printf("%s close Attr [%zd] HIDs\n",ADFH_PREFIX,nobj); #endif if (nobj) { H5Fget_obj_ids(fid, H5F_OBJ_ATTR|H5F_OBJ_LOCAL, -1, objs); @@ -2608,7 +2694,7 @@ void ADFH_Database_Close(const double root, nobj = H5Fget_obj_count(fid, H5F_OBJ_GROUP|H5F_OBJ_LOCAL); #ifdef ADFH_DEBUG_ON - printf("%s close Group [%d] HIDs\n",ADFH_PREFIX,nobj); + printf("%s close Group [%zd] HIDs\n",ADFH_PREFIX,nobj); #endif if (nobj) { H5Fget_obj_ids(fid, H5F_OBJ_GROUP|H5F_OBJ_LOCAL, -1, objs); @@ -3229,7 +3315,7 @@ void ADFH_Library_Version(char *version, return; } H5get_libversion(&maj, &min, &rel); - sprintf(version, "HDF5 Version %d.%d.%d", maj, min, rel); + sprintf(version, "HDF5 Version %u.%u.%u", maj, min, rel); set_error(NO_ERROR, err); } diff --git a/externals/cgns/adfh/ADFH.h b/externals/cgns/adfh/ADFH.h index 2dbd200f33b..d2a07d03b8f 100644 --- a/externals/cgns/adfh/ADFH.h +++ b/externals/cgns/adfh/ADFH.h @@ -117,6 +117,7 @@ #define NULL_NODEID_POINTER 62 #define MAX_FILE_SIZE_EXCEEDED 63 #define MAX_INT32_SIZE_EXCEEDED 64 +#define CHILDREN_IDS_NOT_FOUND 65 #endif /* ADF_INCLUDE */ @@ -175,7 +176,8 @@ #define ADFH_CONFIG_ALIGNMENT 6 #define ADFH_CONFIG_MD_BLOCK_SIZE 7 #define ADFH_CONFIG_HDF5_BUFFER 8 -#define ADFH_CONFIG_HDF5_SIEVE_BUF_SIZE 9 +#define ADFH_CONFIG_HDF5_SIEVE_BUF_SIZE 9 +#define ADFH_CONFIG_ELINK_FILE_CACHE_SIZE 10 #define ADFH_CONFIG_RESET 800 #define ADFH_CONFIG_RESET_HDF5 1 diff --git a/externals/cgns/cg_hashmap.c b/externals/cgns/cg_hashmap.c index 5b47a7978ba..ade13c4dca3 100644 --- a/externals/cgns/cg_hashmap.c +++ b/externals/cgns/cg_hashmap.c @@ -204,10 +204,17 @@ cgi_estimate_keysize(map_ssize_t n) */ #define GROWTH_RATE(d) ((d)->ma_used*2) +/* Dirty trick for unsupported flexible array init */ +struct _static_hashmapobject { + map_ssize_t table_size; + map_ssize_t map_usable; + map_ssize_t map_nentries; + char map_indices[8]; /* we define the size of the array to have a known struct at compile time */ +}; /* This immutable, empty cgns_hashmap_keyobject is used for HashMap_Clear() * (which cannot fail and thus can do no allocation). */ -static cgns_hashmap_keyobject empty_keys_struct = { +static struct _static_hashmapobject empty_keys_struct = { 1, /* table_size */ 0, /* map_usable (immutable) */ 0, /* map_nentries */ @@ -215,7 +222,7 @@ static cgns_hashmap_keyobject empty_keys_struct = { MAPIX_EMPTY, MAPIX_EMPTY, MAPIX_EMPTY, MAPIX_EMPTY}, /* map_indices */ }; -#define MAP_EMPTY_KEYS &empty_keys_struct +#define MAP_EMPTY_KEYS (cgns_hashmap_keyobject *)&empty_keys_struct static cgns_hashmap_keyobject* cgi_new_keys_object(map_ssize_t size) diff --git a/externals/cgns/cgns_error.c b/externals/cgns/cgns_error.c index e5d01d5e632..232a978f6fc 100644 --- a/externals/cgns/cgns_error.c +++ b/externals/cgns/cgns_error.c @@ -32,7 +32,7 @@ char cgns_error_mess[200] = "no CGNS error reported"; CGNSDLL void cgi_error(const char *format, ...) { va_list arg; va_start(arg, format); - vsprintf(cgns_error_mess,format, arg); + vsnprintf(cgns_error_mess, 200, format, arg); va_end(arg); if (cgns_error_handler) (*cgns_error_handler)(1, cgns_error_mess); @@ -43,7 +43,7 @@ CGNSDLL void cgi_warning(const char *format, ...) { va_start(arg, format); if (cgns_error_handler) { char warning_msg[200]; - vsprintf(warning_msg, format, arg); + vsnprintf(warning_msg, 200, format, arg); (*cgns_error_handler)(0, warning_msg); } else { diff --git a/externals/cgns/cgns_header.h b/externals/cgns/cgns_header.h index 140321b6b14..46e4b5e883c 100644 --- a/externals/cgns/cgns_header.h +++ b/externals/cgns/cgns_header.h @@ -1034,8 +1034,8 @@ CGNSDLL cgns_subreg *cgi_get_subreg (cgns_file *cg, int B, int Z, int S); CGNSDLL int cgi_update_posit(int cnt, int *index, char **label); CGNSDLL int cgi_set_posit(int fn, int B, int n, int *index, char **label); CGNSDLL int cgi_posit_id(double *posit_id); -CGNSDLL cgns_posit *cgi_get_posit(); -CGNSDLL int cgi_posit_index_dim(); +CGNSDLL cgns_posit *cgi_get_posit(void); +CGNSDLL int cgi_posit_index_dim(void); /* retrieve memory address of multiple patch children knowing their parent label (posit_label) and their parent memory address (posit) */ @@ -1067,7 +1067,7 @@ cgns_dataset * cgi_bcdataset_address(int local_mode, int given_no, char const *given_name, int *ier); /* read CGNS file into internal database */ -int cgi_read(); +int cgi_read(void); int cgi_read_base(cgns_base *base); int cgi_read_zone(cgns_zone *zone); int cgi_read_zonetype(double parent_id, char_33 parent_name, CGNS_ENUMT(ZoneType_t) *type); @@ -1157,7 +1157,7 @@ int cgi_write_zboco(double parent_id, cgns_zboco *zboco); int cgi_write_boco(double parent_id, cgns_boco *boco); int cgi_write_dataset(double parent_id, const char *label, cgns_dataset *dataset); int cgi_write_bcdata(double bcdata_id, cgns_bcdata *bcdata); -int cgi_write_ptset(double id, char_33 name, cgns_ptset *ptset, +int cgi_write_ptset(double id, char *name, cgns_ptset *ptset, int ndim, void *ptset_ptr); int cgi_write_equations(double parent_id, cgns_equations *equations); int cgi_write_model(double parent_id, cgns_model *model); @@ -1261,7 +1261,7 @@ int cgi_check_strlen(char const * string); int cgi_check_strlen_x2(char const *string); int cgi_check_mode(char const * filename, int file_mode, int mode_wanted); const char *cgi_adf_datatype(CGNS_ENUMT(DataType_t) type); -CGNSDLL CGNS_ENUMT(DataType_t) cgi_datatype(cchar_33 adf_type); +CGNSDLL CGNS_ENUMT(DataType_t) cgi_datatype(const char *adf_type); int cgi_check_dimensions(int ndims, cglong_t *dims); int cgi_check_location(int dim, CGNS_ENUMT(ZoneType_t) type, CGNS_ENUMT(GridLocation_t) loc); diff --git a/externals/cgns/cgns_internals.c b/externals/cgns/cgns_internals.c index 1077afd3bb8..0fd77e829bd 100644 --- a/externals/cgns/cgns_internals.c +++ b/externals/cgns/cgns_internals.c @@ -2126,7 +2126,7 @@ int cgi_read_conn(cgns_conn *conn) /* check */ if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) { if (conn->ptset.id==0) { - cgi_error("Niether PointRange nor PointList defined for GridConnectivity_t '%s'", + cgi_error("Neither PointRange nor PointList defined for GridConnectivity_t '%s'", conn->name); return CG_ERROR; } @@ -2136,7 +2136,7 @@ int cgi_read_conn(cgns_conn *conn) hid_t hid; to_HDF_ID(conn->ptset.id, hid); if (hid==0) { - cgi_error("Niether PointRange nor PointList defined for GridConnectivity_t '%s'", + cgi_error("Neither PointRange nor PointList defined for GridConnectivity_t '%s'", conn->name); return CG_ERROR; } @@ -8282,12 +8282,13 @@ int cgi_write_bcdata(double bcdata_id, cgns_bcdata *bcdata) return CG_OK; } -int cgi_write_ptset(double parent_id, char_33 name, cgns_ptset *ptset, +int cgi_write_ptset(double parent_id, char *name, cgns_ptset *ptset, int ndim, void *ptset_ptr) { cgsize_t dim_vals[12]; int num_dim; char_33 label; + int HDF5storage_type_original = HDF5storage_type; if (ptset->link) { return cgi_write_link(parent_id, name, ptset->link, &ptset->id); @@ -8305,10 +8306,19 @@ int cgi_write_ptset(double parent_id, char_33 name, cgns_ptset *ptset, dim_vals[1]=ptset->npts; num_dim = 2; + // PointLists should be contiguous for parallel reading/writing + if (ptset->type == CGNS_ENUMV(PointList) || + ptset->type == CGNS_ENUMV(PointListDonor) || + ptset->type == CGNS_ENUMV(ElementList) || + ptset->type == CGNS_ENUMV(CellListDonor)) { + HDF5storage_type = CG_CONTIGUOUS; + } + /* Create the node */ if (cgi_new_node(parent_id, name, label, &ptset->id, ptset->data_type, num_dim, dim_vals, ptset_ptr)) return CG_ERROR; + HDF5storage_type = HDF5storage_type_original; return CG_OK; } @@ -9945,15 +9955,15 @@ const char *cgi_adf_datatype(CGNS_ENUMV(DataType_t) type) return "NULL"; } -CGNS_ENUMT(DataType_t) cgi_datatype(cchar_33 adf_type) +CGNS_ENUMT(DataType_t) cgi_datatype(char const *adf_type) { - if (strcmp(adf_type, "I4") == 0) return CGNS_ENUMV(Integer); - if (strcmp(adf_type, "I8") == 0) return CGNS_ENUMV(LongInteger); - if (strcmp(adf_type, "R4") == 0) return CGNS_ENUMV(RealSingle); - if (strcmp(adf_type, "R8") == 0) return CGNS_ENUMV(RealDouble); - if (strcmp(adf_type, "C1") == 0) return CGNS_ENUMV(Character); - if (strcmp(adf_type, "X4") == 0) return CGNS_ENUMV(ComplexSingle); - if (strcmp(adf_type, "X8") == 0) return CGNS_ENUMV(ComplexDouble); + if (strncmp(adf_type, "I4", 33) == 0) return CGNS_ENUMV(Integer); + if (strncmp(adf_type, "I8", 33) == 0) return CGNS_ENUMV(LongInteger); + if (strncmp(adf_type, "R4", 33) == 0) return CGNS_ENUMV(RealSingle); + if (strncmp(adf_type, "R8", 33) == 0) return CGNS_ENUMV(RealDouble); + if (strncmp(adf_type, "C1", 33) == 0) return CGNS_ENUMV(Character); + if (strncmp(adf_type, "X4", 33) == 0) return CGNS_ENUMV(ComplexSingle); + if (strncmp(adf_type, "X8", 33) == 0) return CGNS_ENUMV(ComplexDouble); return CGNS_ENUMV(DataTypeNull); } @@ -11421,6 +11431,13 @@ static int cgi_next_posit(char *label, int index, char *name) label, index + 1, b->user_data[index].id); } } + else if (0 == strcmp (label, "IndexArray_t")) { + if (b->ptset && + (index == 1 || 0 == strcmp (b->ptset->name, name))) { + return cgi_add_posit((void *)b->ptset, + label, 1, b->ptset->id); + } + } else return CG_INCORRECT_PATH; } diff --git a/externals/cgns/cgns_io.h b/externals/cgns/cgns_io.h index e62c0d185e1..d9d49a8aa02 100644 --- a/externals/cgns/cgns_io.h +++ b/externals/cgns/cgns_io.h @@ -121,7 +121,7 @@ CGEXTERN int cgio_configure ( void *value ); -CGEXTERN void cgio_cleanup (); +CGEXTERN void cgio_cleanup (void); CGEXTERN int cgio_check_file ( const char *filename, diff --git a/externals/cgns/cgnslib.c b/externals/cgns/cgnslib.c index 387d0e3de75..6aa344c5e91 100644 --- a/externals/cgns/cgnslib.c +++ b/externals/cgns/cgnslib.c @@ -22,6 +22,64 @@ freely, subject to the following restrictions: * Revisions: * ***********************************************************************/ +/** + * \defgroup AccessingANode Accessing a node + * \defgroup ArbitraryGridMotion Arbitrary Grid Motion + * \defgroup AuxiliaryModel Auxiliary Model + * \defgroup Axisymmetry Axisymmetry + * \defgroup BCData Boundary Condition Data + * \defgroup BCDataset Boundary Condition Datasets + * \defgroup BaseIterativeData Base Iterative Data + * \defgroup BoundaryConditionDatasets Boundary Condition Datasets + * \defgroup BoundaryConditionType Boundary Condition Type and Location + * \defgroup CGNSBaseInformation CGNS Base Information + * \defgroup CGNSFamilyBoundaryDefinition Family Boundary Condition + * \defgroup CGNSFamilyDefinition Family Definition + * \defgroup CGNSFamilyHierarchyTreeDefinition Family Hierarchy Tree + * \defgroup CGNSFile File Operations + * \defgroup CGNSGeometryReference Geometry Reference + * \defgroup CGNSInterfaceCGIO Interfacing with CGIO + * \defgroup CGNSInternals Configuring CGNS Internals + * \defgroup CGNSZoneInformation CGNS Zone Information + * \defgroup ConvergenceHistory Convergence History + * \defgroup DataArrays Data Arrays + * \defgroup DataClass Data Class + * \defgroup DataConversionFactors Data Conversion Factors + * \defgroup DeletingANode Deleting a node + * \defgroup DescriptiveText Descriptive Text + * \defgroup DimensionalExponents Dimensional Exponents + * \defgroup DimensionalUnits Dimensional Units + * \defgroup DiscreteData Discrete Data + * \defgroup ElementConnectivity Element Connectivity + * \defgroup FamilyName Family Name + * \defgroup FlowEquationSet Flow Equation Set + * \defgroup FlowSolution Flow Solution + * \defgroup FlowSolutionData Flow Solution Data + * \defgroup FreeingMemory Freeing Memory + * \defgroup GeneralizedConnectivity Generalized Connectivity + * \defgroup GoverningEquations Governing Equations + * \defgroup Gravity Gravity + * \defgroup GridLocation Grid Location + * \defgroup IntegralData Integral Data + * \defgroup Links Links + * \defgroup OneToOneConnectivity One-to-One Connectivity + * \defgroup OrdinalValue Ordinal Value + * \defgroup OversetHoles Overset Holes + * \defgroup PointSets Point Sets + * \defgroup ReferenceState Reference State + * \defgroup RigidGridMotion Rigid Grid Motion + * \defgroup RindLayers Rind Layers + * \defgroup RotatingCoordinates Rotating Coordinates + * \defgroup SimulationType Simulation Type + * \defgroup SpecialBoundaryConditionProperty Special Boundary Condition Property + * \defgroup SpecialGridConnectivityProperty Special Grid Connectivity Property + * \defgroup UserDefinedData User Defined Data + * \defgroup ZoneGridConnectivity Zone Grid Connectivity + * \defgroup ZoneGridCoordinates Zone Grid Coordinates + * \defgroup ZoneIterativeData Zone Iterative Data + * \defgroup ZoneSubregions Zone Subregions + * + **/ #include #include @@ -259,7 +317,7 @@ const char * AverageInterfaceTypeName[NofValidAverageInterfaceTypes] = int n_open = 0; int cgns_file_size = 0; int file_number_offset = 0; -int VersionList[] = {4200, +int VersionList[] = {4500, 4400, 4300, 4200, 4110, 4100, 4000, 3210, 3200, 3140, 3130, 3110, 3100, @@ -317,7 +375,21 @@ void objlist_status(char *tag) * library functions ***********************************************************************/ -/* check for a valid CGNS file */ + +/** + * \ingroup CGNSFile + * + * \brief Check for a valid CGNS file. + * + * \param[in] filename \FILE_filename + * \param[in] file_type \FILE_file_type + * \return \ier + * + * \details For existing files, the function /e cg_is_cgns may be used to determine if a file is a CGNS file or not, and + * the type of file (\p CG_FILE_ADF or \p CG_FILE_HDF5). If the file is a CGNS file, \e cg_is_cgns returns \p CG_OK, + * otherwise \p CG_ERROR is returned and file_type is set to \p CG_FILE_NONE. + * + */ int cg_is_cgns(const char *filename, int *file_type) { @@ -334,12 +406,42 @@ int cg_is_cgns(const char *filename, int *file_type) return ierr ? CG_ERROR : CG_OK; } -/*********************************************************************** - * cg_open(char *filename, int mode, int *file_number) +/** + * \ingroup CGNSFile * - ***********************************************************************/ + * \brief Open a CGNS file. + * + * \param[in] filename \FILE_filename + * \param[in] mode \FILE_mode + * \param[out] fn \FILE_fn + * \return \ier + * + * \details The function \e cg_open must always be the first one called. It opens a CGNS file for reading and/or writing and returns + * an index number \e file_number. + * The index number serves to identify the CGNS file in subsequent function calls. Several CGNS files can be opened simultaneously. The current + * limit on the number of files opened at once depends on the platform. On an SGI workstation, this limit is set at 100 (parameter FOPEN_MAX in stdio.h). + * The file can be opened in one of the following modes: + * + *| | | + *|---|---| + *|__CG_MODE_READ__ | Read only mode. | + *|__CG_MODE_WRITE__| Write only mode. | + *|__CG_MODE_MODIFY__| Reading and/or writing is allowed.| + * + * When the file is opened, if no \e CGNSLibraryVersion_t node is found, a default value of 1.05 is assumed for the CGNS version number. Note that this + * corresponds to an old version of the CGNS standard, that doesn't include many data structures supported by the current standard. + * + * In order to reduce memory usage and improve execution speed, large arrays such as grid coordinates or flow solutions are not actually + * stored in memory. Instead, only basic information about the node is kept, while reads and writes of the data is directly to and from + * the application's memory. An attempt is also made to do the same with unstructured mesh element data. + * + * \note CGNS maintains one-way forward compatibility insofar as any file open and modified by, for example, version major.minor.patch + * will be readable with major.minor.patch< b>+< /b>. It can't be guaranteed the reverse major.minor.patch< b>-< /b> + * compatibility for that file will be true. + * + */ -int cg_open(const char *filename, int mode, int *file_number) +int cg_open(const char *filename, int mode, int *fn) { int cgio, filetype; cgsize_t dim_vals; @@ -385,7 +487,7 @@ int cg_open(const char *filename, int mode, int *file_number) } cg = &(cgns_files[n_cgns_files]); n_cgns_files++; - (*file_number) = n_cgns_files + file_number_offset; + (*fn) = n_cgns_files + file_number_offset; if (cgio_get_file_type(cgio, &filetype)) { cg_io_error("cgio_get_file_type"); @@ -399,7 +501,7 @@ int cg_open(const char *filename, int mode, int *file_number) cg->filetype = filetype; cg->cgio = cgio; cgio_get_root_id(cgio, &cg->rootid); - cg->file_number = (*file_number); + cg->file_number = (*fn); cg->version = 0; cg->deleted = 0; cg->added = 0; @@ -434,7 +536,7 @@ int cg_open(const char *filename, int mode, int *file_number) /* This code allows reading version newer than the lib, as long as the 1st digit of the versions are equal */ if ((cg->version / 1000) > (CGNSLibVersion / 1000)) { - cgi_error("The file %s was written with a more recent version of the CGNS library. You must update your CGNS library before trying to read this file.",filename); + cgi_error("A more recent version of the CGNS library created the file. Therefore, the CGNS library needs updating before reading the file '%s'.",filename); return CG_ERROR; } /* warn only if different in second digit */ @@ -511,17 +613,30 @@ int cg_open(const char *filename, int mode, int *file_number) return CG_OK; } -int cg_version(int file_number, float *FileVersion) +/** + * \ingroup CGNSFile + * + * \brief Get CGNS file version. + * + * \param[in] fn \FILE_fn + * \param[out] version \FILE_version + * \return \ier + * + * \details The function \e cg_version returns the CGNS version number. + * + */ + +int cg_version(int fn, float *version) { int nnod; double *id; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* if open in CG_MODE_WRITE */ if (cg->version) { - (*FileVersion)=(float)(cg->version)/1000; + (*version)=(float)(cg->version)/1000; return CG_OK; } @@ -531,7 +646,7 @@ int cg_version(int file_number, float *FileVersion) return CG_ERROR; if (nnod==0) { cg->version=3200; - *FileVersion= (float) 3.20; + *version= (float) 3.20; } else if (nnod!=1) { cgi_error("More then one CGNSLibraryVersion_t node found under ROOT."); return CG_ERROR; @@ -558,9 +673,9 @@ int cg_version(int file_number, float *FileVersion) return CG_ERROR; } /* save data */ - *FileVersion = *((float *)data); + *version = *((float *)data); free(data); - cg->version = (int)(1000.0*(*FileVersion)+0.5); + cg->version = (int)(1000.0*(*version)+0.5); /* To prevent round off error in version number for file of older or current version */ temp_version = cg->version; @@ -580,20 +695,32 @@ int cg_version(int file_number, float *FileVersion) free(id); } #if DEBUG_VERSION - printf("FileVersion=%f\n",*FileVersion); + printf("version=%f\n",*version); printf("cg->version=%d\n",cg->version); #endif return CG_OK; } +/** + * \ingroup CGNSFile + * + * \brief Get CGNS file precision. + * + * \param[in] fn \FILE_fn + * \param[out] precision \FILE_precision + * \return \ier + * + * \details Precision used to write the CGNS file. The \e precision value will be one of 32 (32-bit), 64 (64-bit), or 0 if not known. + * + */ -int cg_precision(int file_number, int *precision) +int cg_precision(int fn, int *precision) { int nb, nz; char_33 data_type; *precision = 0; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* if open in CG_MODE_WRITE */ @@ -615,10 +742,24 @@ int cg_precision(int file_number, int *precision) return CG_OK; } -int cg_close(int file_number) +/** + * \ingroup CGNSFile + * + * \brief Close a CGNS file. + * + * \param[in] fn \FILE_fn + * \return \ier + * + * \details The function \e cg_close must always be the last one called. It closes the CGNS file designated by the index number \e fn + * and frees the memory where the CGNS data was kept. When a file is opened for writing, \e cg_close writes all the CGNS data in + * memory onto disk prior to closing the file. Consequently, if is omitted, the CGNS file is not written properly. + * + */ + +int cg_close(int fn) { - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; #ifdef __CG_MALLOC_H__ @@ -667,12 +808,31 @@ int cg_close(int file_number) return CG_OK; } -int cg_save_as(int file_number, const char *filename, int file_type, +/** + * \ingroup CGNSFile + * + * \brief Save the open CGNS file. + * + * \param[in] fn \FILE_fn + * \param[in] filename \FILE_filename + * \param[in] file_type \FILE_file_type + * \param[in] follow_links \FILE_follow_links + * \return \ier + * + * \details The CGNS file identified by \e fn may be saved to a different filename and type using cg_save_as(). + * In order to save as an HDF5 file, the library must have been built with HDF5 support. ADF support is always built. + * The function cg_set_file_type() sets the default file type for newly created CGNS files. The function + * cg_get_file_type() returns the file type for the CGNS file identified by \e fn. If the CGNS library is built + * as 32-bit, the additional file type, \p CG_FILE_ADF2, is available. This allows creation of a 2.5 compatible CGNS file. + * + */ + +int cg_save_as(int fn, const char *filename, int file_type, int follow_links) { int output; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (file_type == CG_FILE_NONE) @@ -695,6 +855,22 @@ int cg_save_as(int file_number, const char *filename, int file_type, } return CG_OK; } +/** + * \ingroup CGNSFile + * + * \brief Set default file type. + * + * \param[in] file_type \FILE_file_type + * \return \ier + * + * \details When a CGNS file is newly created using \p CG_MODE_WRITE, the default type of database manager used is determined + * at compile time. If the CGNS library was built with HDF5 version 1.8 or later support, the file type will be \p CG_FILE_HDF5, + * otherwise \p CG_FILE_ADF is used. This may be changed either by setting an environment variable, \p CGNS_FILETYPE, to one + * of \e adf, \e hdf5, or \e adf2, or by calling the routine cg_set_file_type() prior to the cg_open() call. Calling + * cg_set_file_type() with the argument \p CG_FILE_NONE will reset the library to use the default file type. + * \b Note: If the environment variable \p CGNS_FILETYPE is set, it takes precedence. + * + */ int cg_set_file_type(int file_type) { @@ -734,9 +910,22 @@ int cg_set_file_type(int file_type) return CG_OK; } -int cg_get_file_type(int file_number, int *file_type) +/** + * \ingroup CGNSFile + * + * \brief Get file type for open CGNS file. + * + * \param[in] fn \FILE_fn + * \param[out] file_type \FILE_file_type + * \return \ier + * + * \details The function \p cg_get_file_type gets the file type (\e adf, \e hdf5, or \e adf2) for an open CGNS file. + * + */ + +int cg_get_file_type(int fn, int *file_type) { - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgio_get_file_type(cg->cgio, file_type)) { cg_io_error("cgio_get_file_type"); @@ -745,58 +934,115 @@ int cg_get_file_type(int file_number, int *file_type) return CG_OK; } -int cg_root_id(int file_number, double *root_id) +/** + * \ingroup CGNSInterfaceCGIO + * + * \brief Get the CGIO root node identifier for the CGNS file. + * + * \param[in] fn \FILE_fn + * \param[out] rootid Root node identifier for the CGNS file + * \return \ier + * + * \details The function \p cg_root_id allow the use of the low-level CGIO function + * in conjunction with the Mid Level Library. It returns the root node identifier for the CGNS file. + * + */ +int cg_root_id(int fn, double *rootid) { - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; - if (cgio_get_root_id(cg->cgio, root_id)) { + if (cgio_get_root_id(cg->cgio, rootid)) { cg_io_error("cgio_get_root_id"); return CG_ERROR; } return CG_OK; } -int cg_get_cgio(int file_number, int *cgio_num) +/** + * \ingroup CGNSInterfaceCGIO + * + * \brief Get the CGIO database identifier for the specified CGNS file. + * + * \param[in] fn \FILE_fn + * \param[out] cgio_num CGIO identifier for the CGNS file + * \return \ier + * + * \details The function \p cg_get_cgio allow the use of the low-level CGIO function + * in conjunction with the Mid Level Library. It returns the CGIO database identifier for the CGNS file. + * + */ +int cg_get_cgio(int fn, int *cgio_num) { - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; *cgio_num = cg->cgio; return CG_OK; } /* configure stuff */ - -int cg_configure(int what, void *value) +/** + * \ingroup CGNSInternals + * + * \brief Configure CGNS library internal options. + * + * \param[in] option The option to configure, currently one of \p CG_CONFIG_ERROR, \p CG_CONFIG_COMPRESS, \p CG_CONFIG_SET_PATH, \p CG_CONFIG_ADD_PATH, \p CG_CONFIG_FILE_TYPE, \p CG_CONFIG_RIND_INDEX, \p CG_CONFIG_HDF5_DISKLESS, \p CG_CONFIG_HDF5_DISKLESS_INCR, \p CG_CONFIG_HDF5_DISKLESS_WRITE, \p CG_CONFIG_HDF5_COMPRESS, or \p CG_CONFIG_HDF5_MPI_COMM as defined in cgnslib.h. + * \param[in] value The value to set, type cast as \e void * . In Fortran the type is \e TYPE(C_PTR). + * \return \ier + * + * + * \details The function \p cg_configure allows particular CGNS library internal options to be configured. The currently supported options and expected values are: + * + *| | | + *|---|---| + *|__CG_CONFIG_ERROR__| This allows an error call-back function to be defined by the user. The value should be a pointer to a function to receive the error. The function is defined as `void err_callback(int is_error, char *errmsg)`, and will be called for errors and warnings. The first argument, is_error, will be 0 for warning messages, 1 for error messages, and −1 if the program is going to terminate (i.e., a call to `cg_error_exit()`). The second argument is the error or warning message. If this is defined, warning and error messages will go to the function, rather than the terminal. A value of `NULL` will remove the call-back function. + *|__CG_CONFIG_COMPRESS__| This is the rewrite-upon-close setting. Note: Prior versions of the library would automatically rewrite the CGNS file when it was closed after being opened in modify mode if there was unused space. This is no longer done, due to possible conflicts when using parallel I/O. The previous behavior may be recovered by setting value to a positive integer. In this case the file will be rewritten if the number of node deletions or modifications are equal to or exceed this number. Setting value to a negative number will force the rewrite when the file is closed. The default value is 0 (no rewrite). + *|__CG_CONFIG_SET_PATH__| Sets the search path for locating linked-to files. The argument value should be a character string containing one or more directories, formatted the same as for the `PATH` environment variable. This will replace any current settings. Setting value to `NULL` will remove all paths. + *|__CG_CONFIG_ADD_PATH__| Adds a directory, or list of directories, to the linked-to file search path. This is the same as `CG_CONFIG_SET_PATH`, but adds to the path instead of replacing it. + *|__CG_CONFIG_FILE_TYPE__| Sets the default file type for newly created CGNS files. The argument, value should be set to one of `CG_FILE_NONE`, `CG_FILE_ADF`, `CG_FILE_HDF5`, or `CG_FILE_ADF2`. See the discussion above for `cg_set_file_type`. + *|__CG_CONFIG_RIND_INDEX__| This option affects index bounds on structured arrays with rind planes. By default (`CG_CONFIG_RIND_CORE`), the core array locations always begin at index 1. Lower rind planes, if present, would have an index less than 1. For backward compatibility, `CG_CONFIG_RIND_ZERO` is provided and the index 1 will then locate the start of the array and not necessarily the start the core array. Note: Use of this option does not change the cgns file in any way; it only modifies the API to the library. The API changed for versions of the Mid-Level Library greater than 3.4. Before, it did not produce this behavior. Index 1 always represented the start of an array: in an array with no rind planes, the core location would have index 1; in an array with 1 rind plane, the core location would have index 2. In version 3.4 of the Mid-Level Library, the behavior of the API was fixed to match that specified in the SIDS: core array locations always begin at index 1. This option allows for configuring the library to pre-3.4 indexing behavior (set value to `CG_CONFIG_RIND_ZERO`) or the new default behavior (set value to `CG_CONFIG_RIND_CORE`). Note that using `CG_CONFIG_RIND_ZERO` is considered obsolete, but is provided for backwards compatibility. Most users should not set this option and use the default. Values used for this option do not need to be explicitly cast as `void*`. + *|__CG_CONFIG_HDF5_COMPRESS__| Sets the compression level for data written from HDF5. The default is no compression. Setting value to -1, will use the default compression level of 6. The acceptable values are 0 to 9, corresponding to gzip compression levels. + *|__CG_CONFIG_HDF5_MPI_COMM__| Sets the MPI communicator for parallel I/O. The default is `MPI_COMM_WORLD`. The new communicator is given by typecasting it to a `void *`. This is generally used internally - see `cgp_mpi_comm` instead. + *|__CG_CONFIG_HDF5_DISKLESS_INCR__| Value specifies the increment by which allocated memory is to be increased each time more memory is required, in bytes. The default is 10MiB. Ideally, value should be set large enough to minimize repeated increases. The type of value is size_t in C and C_SIZE_T in Fortran. Due to a bug with gfortran, it is advisable to use C_LOC or C_FUNLOC in-line of the call instead of using a variable. + *|__CG_CONFIG_HDF5_DISKLESS_WRITE__| Value indicates whether to write (value=1) the memory contents to disk when the file is closed. Otherwise, value=0 does not persist the memory to disk. + *|__CG_CONFIG_HDF5_ALIGNMENT__| Configures HDF5's H5Pset_alignment and sets the alignment, value[1], properties of a file access property list so that any file object greater than or equal in size to a threshold, value[0], bytes will be aligned on an address which is a multiple of alignment. + *|__CG_CONFIG_HDF5_MD_BLOCK_SIZE__| Configures HDF5's H5Pset_meta_block_size and sets the minimum size, value (in bytes), of metadata block allocations. + *|__CG_CONFIG_HDF5_BUFFER__| Configures HDF5's H5Pset_buffer and sets the maximum size, value (in bytes), for the type conversion buffer and background buffer. + *|__CG_CONFIG_HDF5_SIEVE_BUF_SIZE__| Configures HDF5's H5Pset_sieve_buf_size and sets the maximum size, value (in bytes), of the data sieve buffer. + *|__CG_CONFIG_RESET__| Value indicates the configuration values to reset to their default values. Currently, only CG_CONFIG_RESET_HDF5 is a valid value and will reset all the CG_CONFIG_HDF5_* parameters, excluding CG_CONFIG_HDF5_MPI_COMM and CG_CONFIG_HDF5_DISKLESS, to their default values. + * + * + */ +int cg_configure(int option, void *value) { /* cgio options */ - if (what > 100) { - if( cgio_configure(what, value) != CG_OK) { + if (option > 100) { + if( cgio_configure(option, value) != CG_OK) { cg_io_error("cgio_configure"); return CG_ERROR; } } /* error message handler */ - else if (what == CG_CONFIG_ERROR) { + else if (option == CG_CONFIG_ERROR) { cgns_error_handler = (void (*)(int, char *))value; } /* file compression */ - else if (what == CG_CONFIG_COMPRESS) { + else if (option == CG_CONFIG_COMPRESS) { cgns_compress = (int)((size_t)value); } /* initialize link search path */ - else if (what == CG_CONFIG_SET_PATH) { + else if (option == CG_CONFIG_SET_PATH) { return cg_set_path((const char *)value); } /* add to link search path */ - else if (what == CG_CONFIG_ADD_PATH) { + else if (option == CG_CONFIG_ADD_PATH) { return cg_set_path((const char *)value); } /* default file type */ - else if (what == CG_CONFIG_FILE_TYPE) { + else if (option == CG_CONFIG_FILE_TYPE) { return cg_set_file_type((int)((size_t)value)); } /* allow pre v3.4 rind-plane indexing */ - else if (what == CG_CONFIG_RIND_INDEX) { + else if (option == CG_CONFIG_RIND_INDEX) { if (value != CG_CONFIG_RIND_ZERO && value != CG_CONFIG_RIND_CORE) { cgi_error("unknown config setting"); @@ -811,24 +1057,56 @@ int cg_configure(int what, void *value) return CG_OK; } +/** + * \ingroup CGNSInternals + * + * \brief Set CGNS error handler + * + * \param[in] func error handler function + * \return \ier + */ int cg_error_handler(void (*func)(int, char *)) { cgns_error_handler = func; return CG_OK; } +/** + * \ingroup CGNSInternals + * + * \brief Set CGNS compression mode + * + * \param[in] compress CGNS compress (rewrite) setting + * \return \ier + */ int cg_set_compress(int compress) { cgns_compress = compress; return CG_OK; } +/** + * \ingroup CGNSInternals + * + * \brief Get CGNS compression mode + * + * \param[out] compress CGNS compress (rewrite) setting + * \return \ier + */ int cg_get_compress(int *compress) { *compress = cgns_compress; return CG_OK; } +/** + * \ingroup CGNSInternals + * + * \brief Set the CGNS link search path + * + * \param[in] path to search for linked to files when opening a file with external links. + * \return \ier + */ int cg_set_path(const char *path) { cgio_path_delete(NULL); @@ -841,6 +1119,14 @@ int cg_set_path(const char *path) return CG_OK; } +/** + * \ingroup CGNSInternals + * + * \brief Add to the CGNS link search path + * + * \param[in] path to search for linked to files when opening a file with external links. + * \return \ier + */ int cg_add_path(const char *path) { if (cgio_path_add(path)) { @@ -966,11 +1252,20 @@ const char *cg_AverageInterfaceTypeName(CGNS_ENUMT( AverageInterfaceType_t ) ty /*****************************************************************************\ * Read and Write CGNSBase_t Nodes \*****************************************************************************/ - -int cg_nbases(int file_number, int *nbases) +/** + * \ingroup CGNSBaseInformation + * + * \brief Get number of CGNS base nodes in file + * + * \param[in] fn \FILE_fn + * \param[out] nbases Number of bases present in the CGNS file fn. + * \return \ier + * + */ +int cg_nbases(int fn, int *nbases) { - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -979,12 +1274,25 @@ int cg_nbases(int file_number, int *nbases) return CG_OK; } -int cg_base_read(int file_number, int B, char *basename, int *cell_dim, +/** + * \ingroup CGNSBaseInformation + * + * \brief Read CGNS base information + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[out] basename Name of the base + * \param[out] cell_dim Dimension of the cells; 3 for volume cells, 2 for surface cells and 1 for line cells. + * \param[out] phys_dim Number of coordinates required to define a vector in the field. + * \return \ier + * + */ +int cg_base_read(int fn, int B, char *basename, int *cell_dim, int *phys_dim) { cgns_base *base; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -999,11 +1307,23 @@ int cg_base_read(int file_number, int B, char *basename, int *cell_dim, return CG_OK; } -int cg_base_id(int file_number, int B, double *base_id) + +/** + * \ingroup CGNSBaseInformation + * + * \brief Get the CGIO identifier of the CGNS base + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[out] base_id CGIO node identifier for the base + * \return \ier + * + */ +int cg_base_id(int fn, int B, double *base_id) { cgns_base *base; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -1015,11 +1335,22 @@ int cg_base_id(int file_number, int B, double *base_id) return CG_OK; } -int cg_cell_dim(int file_number, int B, int *cell_dim) +/** + * \ingroup CGNSBaseInformation + * + * \brief Get the cell dimension for the CGNS base + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[out] cell_dim Dimension of the cells; 3 for volume cells, 2 for surface cells and 1 for line cells. + * \return \ier + * + */ +int cg_cell_dim(int fn, int B, int *cell_dim) { cgns_base *base; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; @@ -1028,7 +1359,20 @@ int cg_cell_dim(int file_number, int B, int *cell_dim) return CG_OK; } -int cg_base_write(int file_number, const char * basename, int cell_dim, +/** + * \ingroup CGNSBaseInformation + * + * \brief Create and/or write to a CGNS base node + * + * \param[in] fn \FILE_fn + * \param[in] basename Name of the base. + * \param[in] cell_dim Dimension of the cells; 3 for volume cells, 2 for surface cells and 1 for line cells. + * \param[in] phys_dim Number of coordinates required to define a vector in the field. + * \param[out] B \B_Base + * \return \ier + * + */ +int cg_base_write(int fn, const char * basename, int cell_dim, int phys_dim, int *B) { cgns_base *base = NULL; @@ -1043,7 +1387,7 @@ int cg_base_write(int file_number, const char * basename, int cell_dim, return CG_ERROR; } /* get memory address for base */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -1101,11 +1445,22 @@ int cg_base_write(int file_number, const char * basename, int cell_dim, * Read and Write Zone_t Nodes \*****************************************************************************/ -int cg_nzones(int file_number, int B, int *nzones) +/** + * \ingroup CGNSZoneInformation + * + * \brief Get number of zone in base + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[out] nzones Number of zones present in base B. + * \return \ier + * + */ +int cg_nzones(int fn, int B, int *nzones) { cgns_base *base; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -1117,11 +1472,23 @@ int cg_nzones(int file_number, int B, int *nzones) return CG_OK; } -int cg_zone_type(int file_number, int B, int Z, CGNS_ENUMT(ZoneType_t) *type) +/** + * \ingroup CGNSZoneInformation + * + * \brief Get type of zone (structured or unstructured) + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] zonetype Type of the zone. The admissible types are Structured and Unstructured. + * \return \ier + * + */ +int cg_zone_type(int fn, int B, int Z, CGNS_ENUMT(ZoneType_t) *zonetype) { cgns_zone *zone; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -1129,16 +1496,43 @@ int cg_zone_type(int file_number, int B, int Z, CGNS_ENUMT(ZoneType_t) *type) zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; - *type = zone->type; + *zonetype = zone->type; return CG_OK; } -int cg_zone_read(int file_number, int B, int Z, char *zonename, cgsize_t *nijk) + +/** + * \ingroup CGNSZoneInformation + * + * \brief Read zone information + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] zonename Name of the zone + * \param[out] size Number of vertices, cells, and boundary vertices in each (index)-dimension. For structured grids, the dimensions have unit stride in the array (e.g., `[NVertexI, NVertexJ, NVertexK, NCellI, NCellJ, NCellK, NBoundVertexI, NBoundVertexJ, NBoundVertexK]`). +Note that for unstructured grids, the number of cells is the number of highest order elements. Thus, in three dimensions it's the number of 3-D cells, and in two dimensions it's the number of 2-D cells. +Also for unstructured grids, if the nodes are sorted between internal nodes and boundary nodes, the optional parameter `NBoundVertex` must be set equal to the number of boundary nodes. By default, `NBoundVertex` equals zero, meaning that the nodes are unsorted. +Note that a non-zero value for `NBoundVertex` only applies to unstructured grids. For structured grids, the `NBoundVertex` parameter always equals 0 in all directions. + *|Mesh Type | Size| + *|---------------|-----| + *| 3D structured | `NVertexI`, `NVertexJ`, `NVertexK` + *| ^ | `NCellI`, `NCellJ`, `NCellK` + *| ^ | `NBoundVertexI = 0`, `NBoundVertexJ = 0`, `NBoundVertexK = 0` + *| 2D structured | `NVertexI`, `NVertexJ` + *| ^ | `NCellI`, `NCellJ` + *| ^ | `NBoundVertexI = 0`, `NBoundVertexJ = 0` + *|3D unstructured| `NVertex`, `NCell3D`, `NBoundVertex` + *|2D unstructured| `NVertex`, `NCell2D`, `NBoundVertex` + * \return \ier + * + */ +int cg_zone_read(int fn, int B, int Z, char *zonename, cgsize_t *size) { cgns_zone *zone; int i; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -1148,16 +1542,17 @@ int cg_zone_read(int file_number, int B, int Z, char *zonename, cgsize_t *nijk) strcpy(zonename, zone->name); - for (i=0; i<3*(zone->index_dim); i++) nijk[i] = zone->nijk[i]; + for (i=0; i<3*(zone->index_dim); i++) size[i] = zone->nijk[i]; return CG_OK; } -int cg_zone_id(int file_number, int B, int Z, double *zone_id) + +int cg_zone_id(int fn, int B, int Z, double *zone_id) { cgns_zone *zone; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -1169,11 +1564,22 @@ int cg_zone_id(int file_number, int B, int Z, double *zone_id) return CG_OK; } -int cg_index_dim(int file_number, int B, int Z, int *index_dim) +/** + * \ingroup CGNSZoneInformation + * + * \brief Get the index dimension of the CGNS zone + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] index_dim Index dimension for the zone. For Structured zones, this will be the base cell dimension and for Unstructured zones it will be 1 + * \return \ier + */ +int cg_index_dim(int fn, int B, int Z, int *index_dim) { cgns_zone *zone; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; @@ -1182,8 +1588,34 @@ int cg_index_dim(int file_number, int B, int Z, int *index_dim) return CG_OK; } -int cg_zone_write(int file_number, int B, const char *zonename, const cgsize_t * nijk, - CGNS_ENUMT( ZoneType_t ) type, int *Z) +/** + * \ingroup CGNSZoneInformation + * + * \brief Create and/or write to a CGNS zone + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] zonename Name of the zone. + * \param[in] size Number of vertices, cells, and boundary vertices in each (index)-dimension. For structured grids, the dimensions have unit stride in the array (e.g., [NVertexI, NVertexJ, NVertexK, NCellI, NCellJ, NCellK, NBoundVertexI, NBoundVertexJ, NBoundVertexK]). + *Note that for unstructured grids, the number of cells is the number of highest order elements. Thus, in three dimensions it's the number of 3-D cells, and in two dimensions it's the number of 2-D cells. + *Also for unstructured grids, if the nodes are sorted between internal nodes and boundary nodes, the optional parameter NBoundVertex must be set equal to the number of boundary nodes. By default, NBoundVertex equals zero, meaning that the nodes are unsorted. + *Note that a non-zero value for NBoundVertex only applies to unstructured grids. For structured grids, the NBoundVertex parameter always equals 0 in all directions. + *|Mesh Type | Size| + *|---------------|-----| + *| 3D structured | NVertexI, NVertexJ, NVertexK + *| | NCellI, NCellJ, NCellK + *| | NBoundVertexI = 0, NBoundVertexJ = 0, NBoundVertexK = 0 + *|2D structured | NVertexI, NVertexJ + *| | NCellI, NCellJ + *| | NBoundVertexI = 0, NBoundVertexJ = 0 + *|3D unstructured| NVertex, NCell3D, NBoundVertex + *|2D unstructured| NVertex, NCell2D, NBoundVertex + * \param[in] zonetype Type of the zone. The admissible types are Structured and Unstructured. + * \param[out] Z \Z_Zone + * \return \ier + */ +int cg_zone_write(int fn, int B, const char *zonename, const cgsize_t * size, + CGNS_ENUMT( ZoneType_t ) zonetype, int *Z) { cgns_base *base; cgns_zone *zone = NULL; @@ -1195,7 +1627,7 @@ int cg_zone_write(int file_number, int B, const char *zonename, const cgsize_t * if (cgi_check_strlen(zonename)) return CG_ERROR; /* get memory address file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -1206,9 +1638,9 @@ int cg_zone_write(int file_number, int B, const char *zonename, const cgsize_t * if (base==0) return CG_ERROR; /* Set index dimension */ - if (type == CGNS_ENUMV( Structured )) + if (zonetype == CGNS_ENUMV( Structured )) index_dim = base->cell_dim; - else if (type == CGNS_ENUMV( Unstructured )) + else if (zonetype == CGNS_ENUMV( Unstructured )) index_dim = 1; else { cgi_error("Invalid zone type - not Structured or Unstructured"); @@ -1216,13 +1648,13 @@ int cg_zone_write(int file_number, int B, const char *zonename, const cgsize_t * } for (i=0; inijk"); return CG_ERROR; } - for (i=0; i<3*index_dim; i++) zone->nijk[i] = nijk[i]; + for (i=0; i<3*index_dim; i++) zone->nijk[i] = size[i]; zone->index_dim = index_dim; - zone->type = type; + zone->type = zonetype; /* save data in file */ dim_vals[0]=zone->index_dim; @@ -1294,9 +1726,9 @@ int cg_zone_write(int file_number, int B, const char *zonename, const cgsize_t * if (cgi_new_node(base->id, zone->name, "Zone_t", &zone->id, CG_SIZE_DATATYPE, 2, dim_vals, (void *)zone->nijk)) return CG_ERROR; - dim_vals[0] = (cgsize_t)strlen(ZoneTypeName[type]); + dim_vals[0] = (cgsize_t)strlen(ZoneTypeName[zonetype]); if (cgi_new_node(zone->id, "ZoneType", "ZoneType_t", &dummy_id, - "C1", 1, dim_vals, ZoneTypeName[type])) return CG_ERROR; + "C1", 1, dim_vals, ZoneTypeName[zonetype])) return CG_ERROR; return CG_OK; } @@ -1305,11 +1737,22 @@ int cg_zone_write(int file_number, int B, const char *zonename, const cgsize_t * * Read and Write Family_t Nodes \*****************************************************************************/ -int cg_nfamilies(int file_number, int B, int *nfamilies) +/** + * \ingroup CGNSFamilyDefinition + * + * \brief Get number of Family_t node at CGNSBase_t level + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[out] nfamilies Number of families in base B + * \return \ier + * + */ +int cg_nfamilies(int fn, int B, int *nfamilies) { cgns_base *base; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -1321,17 +1764,31 @@ int cg_nfamilies(int file_number, int B, int *nfamilies) return CG_OK; } -int cg_family_read(int file_number, int B, int F, char *family_name, +/** + * \ingroup CGNSFamilyDefinition + * + * \brief Read family information (CGNSBase_t level) + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \param[out] family_name Name of the family + * \param[out] nboco Number of boundary conditions for this family. This should be either 0 or 1. + * \param[out] ngeos Number of geometry references for this family. + * \return \ier + * + */ +int cg_family_read(int fn, int B, int Fam, char *family_name, int *nboco, int *ngeos) { cgns_family *family; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; - family = cgi_get_family(cg, B, F); + family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; strcpy(family_name, family->name); @@ -1342,7 +1799,20 @@ int cg_family_read(int file_number, int B, int F, char *family_name, } /* ** FAMILY TREE ** */ -int cg_family_write(int file_number, int B, const char * family_name, int *F) + +/** + * \ingroup CGNSFamilyDefinition + * + * \brief Read family information (CGNSBase_t level) + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] family_name Name of the family + * \param[out] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \return \ier + * + */ +int cg_family_write(int fn, int B, const char * family_name, int *Fam) { int index; cgns_base *base; @@ -1353,7 +1823,7 @@ int cg_family_write(int file_number, int B, const char * family_name, int *F) int skip = 0; /* Check file access */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -1467,7 +1937,7 @@ int cg_family_write(int file_number, int B, const char * family_name, int *F) (*nfamilies_p)++; } - (*F) = index+1; + (*Fam) = index+1; if( ! skip ) { /* If not an existing intermediate family node */ memset( family, 0, sizeof(cgns_family) ); @@ -1491,45 +1961,86 @@ int cg_family_write(int file_number, int B, const char * family_name, int *F) /*----------------------------------------------------------------------*/ -int cg_nfamily_names(int file_number, int B, int F, int *nnames) +/** + * \ingroup CGNSFamilyDefinition + * + * \brief Get number of family names under Family_t (CGNSBase_t level) + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \param[out] nnames Number of FamilyName_t nodes for this family. + * \return \ier + * + */ +int cg_nfamily_names(int fn, int B, int Fam, int *nnames) { cgns_family *fam; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; - fam = cgi_get_family(cg, B, F); + fam = cgi_get_family(cg, B, Fam); if (fam == 0) return CG_ERROR; *nnames = fam->nfamname; return CG_OK; } -int cg_family_name_read(int file_number, int B, int F, int N, char *name, char *family) +/** + * \ingroup CGNSFamilyDefinition + * + * \brief Read multiple family names under Family_t (CGNSBase_t level) + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \param[in] N Family name index number, where 1 ≤ N ≤ nNames. + * \param[out] node_name Name of the FamilyName_t node. FamilyParent is used to refer to the parent family of the Family_t node. + * \param[out] family_name Name of the family + * \return \ier + * + */ +int cg_family_name_read(int fn, int B, int Fam, int N, char *node_name, char *family_name) { cgns_family *fam; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; - fam = cgi_get_family(cg, B, F); + fam = cgi_get_family(cg, B, Fam); if (fam == 0) return CG_ERROR; if (N < 1 || N > fam->nfamname) { cgi_error("family name index out of range\n"); return CG_ERROR; } - strcpy(name, fam->famname[N-1].name); - strcpy(family, fam->famname[N-1].family); + strcpy(node_name, fam->famname[N-1].name); + strcpy(family_name, fam->famname[N-1].family); return CG_OK; } + /* ** FAMILY TREE ** */ -int cg_family_name_write(int file_number, int B, int F, - const char *name, const char *family) + +/** + * \ingroup CGNSFamilyDefinition + * + * \brief Write multiple family names under Family_t (CGNSBase_t level) + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \param[out] node_name Name of the FamilyName_t node. FamilyParent is used to refer to the parent family of the Family_t node. + * \param[out] family_name Name of the family + * \return \ier + * + */ +int cg_family_name_write(int fn, int B, int Fam, + const char *node_name, const char *family_name) { int index; cgsize_t dim; @@ -1537,25 +2048,25 @@ int cg_family_name_write(int file_number, int B, int F, cgns_famname *famname = 0; /* verify input */ - if (cgi_check_strlen(name)) return CG_ERROR; + if (cgi_check_strlen(node_name)) return CG_ERROR; - if ( strlen(family) > (CGIO_MAX_NAME_LENGTH+1)*CG_MAX_GOTO_DEPTH ) { - cgi_error( "Family path too long (%s, size %ld)", family, strlen(family) ); + if ( strlen(family_name) > (CGIO_MAX_NAME_LENGTH+1)*CG_MAX_GOTO_DEPTH ) { + cgi_error( "Family path too long (%s, size %ld)", family_name, strlen(family_name) ); return CG_ERROR; } - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; - fam = cgi_get_family(cg, B, F); + fam = cgi_get_family(cg, B, Fam); if (fam == 0) return CG_ERROR; for (index = 0; index < fam->nfamname; index++) { - if (0 == strcmp(name, fam->famname[index].name)) { + if (0 == strcmp(node_name, fam->famname[index].name)) { if (cg->mode == CG_MODE_WRITE) { - cgi_error("Duplicate child name found: %s", name); + cgi_error("Duplicate child name found: %s", node_name); return CG_ERROR; } if (cgi_delete_node(fam->id, fam->famname[index].id)) @@ -1574,8 +2085,8 @@ int cg_family_name_write(int file_number, int B, int F, fam->nfamname++; } - strcpy(famname->name, name); - strcpy(famname->family, family); + strcpy(famname->name, node_name); + strcpy(famname->family, family_name); dim = (cgsize_t)strlen(famname->family); if (cgi_new_node(fam->id, famname->name, "FamilyName_t", &famname->id, @@ -1584,9 +2095,18 @@ int cg_family_name_write(int file_number, int B, int F, return CG_OK; } -/* ** FAMILY TREE ** */ -/* FamilyTree extension */ -int cg_node_family_write( const char* family_name, int* F) + +/** + * \ingroup CGNSFamilyHierarchyTreeDefinition + * + * \brief Create a Family_t node (Family_t level) + * + * \param[in] family_name Name of the family + * \param[out] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \return \ier + * + */ +int cg_node_family_write( const char* family_name, int* Fam) { int ier=0, n, nfamilies; cgns_family* family; @@ -1604,7 +2124,7 @@ int cg_node_family_write( const char* family_name, int* F) /* check for valid posit */ if (posit == 0) { cgi_error("No current position set by cg_goto\n"); - (*F) = 0; + (*Fam) = 0; return CG_ERROR; } @@ -1631,7 +2151,7 @@ int cg_node_family_write( const char* family_name, int* F) } else { cgi_error("Family_t node not supported under '%s' type node",posit->label); - (*F) = -1; + (*Fam) = -1; return CG_INCORRECT_PATH; } @@ -1645,7 +2165,7 @@ int cg_node_family_write( const char* family_name, int* F) cgi_error( "Could not find Family_t node %s\n" , family_name ); return CG_ERROR; } - *F = n + 1; + *Fam = n + 1; } else { cgi_error( "No Family_t container \n"); @@ -1655,7 +2175,15 @@ int cg_node_family_write( const char* family_name, int* F) return CG_OK; } -/* ** FAMILY TREE ** */ +/** + * \ingroup CGNSFamilyHierarchyTreeDefinition + * + * \brief Get number of families (Family_t level) + * + * \param[out] nfamilies Number of families in current node (CGNSBase_t or Family_t). + * \return \ier + * + */ int cg_node_nfamilies( int* nfamilies ) { /* This is valid and used during write as well as read mode. */ @@ -1682,8 +2210,19 @@ int cg_node_nfamilies( int* nfamilies ) return CG_OK; } -/* ** FAMILY TREE ** */ -int cg_node_family_read( int F, char* family_name, int* nFamBC, int *nGeo ) +/** + * \ingroup CGNSFamilyHierarchyTreeDefinition + * + * \brief Read family info (Family_t level) + * + * \param[in] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \param[out] family_name Name of the family. + * \param[out] nFamBC Number of boundary conditions for this family. This should be either 0 or 1. + * \param[out] nGeo Number of geometry references for this family. + * \return \ier + * + */ +int cg_node_family_read( int Fam, char* family_name, int* nFamBC, int *nGeo ) { int ier = 0; cgns_family* family; @@ -1693,7 +2232,7 @@ int cg_node_family_read( int F, char* family_name, int* nFamBC, int *nGeo ) /* verify input */ if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; - family = cgi_family_address( CG_MODE_READ, F, "dummy", &ier ); + family = cgi_family_address( CG_MODE_READ, Fam, "dummy", &ier ); if( family == 0 ) return ier; strcpy( family_name, family->name ); @@ -1703,7 +2242,16 @@ int cg_node_family_read( int F, char* family_name, int* nFamBC, int *nGeo ) return CG_OK; } -/* ** FAMILY TREE ** */ +/** + * \ingroup CGNSFamilyHierarchyTreeDefinition + * + * \brief Write multiple family names under Family_t (Family_t level) + * + * \param[in] node_name Name of the FamilyName_t node. FamilyParent is used to refer to the parent family of the Family_t node. + * \param[in] family_name Name of the family. + * \return \ier + * + */ int cg_node_family_name_write( const char* node_name, const char* family_name ) { int index; @@ -1767,7 +2315,15 @@ int cg_node_family_name_write( const char* node_name, const char* family_name ) return CG_OK; } -/* ** FAMILY TREE ** */ +/** + * \ingroup CGNSFamilyHierarchyTreeDefinition + * + * \brief Get number of family names under Family_t (Family_t level) + * + * \param[out] nnames Number of FamilyName_t nodes for this family. + * \return \ier + * + */ int cg_node_nfamily_names( int* nnames ) { /* This is valid and used during write as well as read mode. */ @@ -1792,7 +2348,17 @@ int cg_node_nfamily_names( int* nnames ) return CG_OK; } -/* ** FAMILY TREE ** */ +/** + * \ingroup CGNSFamilyHierarchyTreeDefinition + * + * \brief Read family info (Family_t level) + * + * \param[in] N Family name index number, where 1 ≤ N ≤ nNames. + * \param[out] node_name Name of the FamilyName_t node. FamilyParent is used to refer to the parent family of the Family_t node. + * \param[out] family_name Name of the family. + * \return \ier + * + */ int cg_node_family_name_read(int N, char* node_name, char* family_name ) { cgns_famname *famname; @@ -1815,17 +2381,31 @@ int cg_node_family_name_read(int N, char* node_name, char* family_name ) /*----------------------------------------------------------------------*/ -int cg_fambc_read(int file_number, int B, int F, int BC, +/** + * \ingroup CGNSFamilyBoundaryDefinition + * + * \brief Read boundary condition type for a family + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \param[in] BC Family boundary condition index number. This must be equal to 1. + * \param[out] fambc_name Name of the FamilyBC_t node. + * \param[out] bocotype Boundary condition type for the family. See the eligible types for BCType_t in the Typedefs section. + * \return \ier + */ + +int cg_fambc_read(int fn, int B, int Fam, int BC, char *fambc_name, CGNS_ENUMT(BCType_t) *bocotype) { cgns_family *family; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; - family = cgi_get_family(cg, B, F); + family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; if (BC<=0 || BC>family->nfambc) { @@ -1838,7 +2418,21 @@ int cg_fambc_read(int file_number, int B, int F, int BC, return CG_OK; } -int cg_fambc_write(int file_number, int B, int F, const char * fambc_name, +/** + * \ingroup CGNSFamilyBoundaryDefinition + * + * \brief Write boundary condition type for a family + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \param[in] fambc_name Name of the FamilyBC_t node. + * \param[in] bocotype Boundary condition type for the family. See the eligible types for BCType_t in the Typedefs section. + * \param[out] BC Family boundary condition index number. This must be equal to 1. + * \return \ier + * + */ +int cg_fambc_write(int fn, int B, int Fam, const char * fambc_name, CGNS_ENUMT( BCType_t ) bocotype, int *BC) { int index; @@ -1853,13 +2447,13 @@ int cg_fambc_write(int file_number, int B, int F, const char * fambc_name, return CG_ERROR; } - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for family */ - family = cgi_get_family(cg, B, F); + family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; /* Overwrite a FamilyBC_t Node: */ @@ -1906,9 +2500,19 @@ int cg_fambc_write(int file_number, int B, int F, const char * fambc_name, return CG_OK; } -/* FamilyTree extension */ /* ** FAMILY TREE ** */ /*----------------------------------------------------------------------*/ +/** + * \ingroup CGNSFamilyBoundaryDefinition + * + * \brief Read boundary condition information (Family_t level) + * + * \param[in] BC Family boundary condition index number. This must be equal to 1. + * \param[out] fambc_name Name of the FamilyBC_t node. + * \param[out] bocotype Boundary condition type for the family. See the eligible types for BCType_t in the Typedefs section. + * \return \ier + * + */ int cg_node_fambc_read( int BC, char* fambc_name, CGNS_ENUMT(BCType_t) *bocotype) { @@ -1946,6 +2550,17 @@ int cg_node_fambc_read( int BC, char* fambc_name, } /*----------------------------------------------------------------------*/ +/** + * \ingroup CGNSFamilyBoundaryDefinition + * + * \brief Write boundary condition information (Family_t level) + * + * \param[in] fambc_name Name of the FamilyBC_t node. + * \param[in] bocotype Boundary condition type for the family. See the eligible types for BCType_t in the Typedefs section. + * \param[out] BC Family boundary condition index number. This must be equal to 1. + * \return \ier + * + */ int cg_node_fambc_write( const char* fambc_name, CGNS_ENUMT(BCType_t) bocotype, int *BC ) { @@ -2030,18 +2645,33 @@ int cg_node_fambc_write( const char* fambc_name, /*----------------------------------------------------------------------*/ - -int cg_geo_read(int file_number, int B, int F, int G, char *geo_name, +/** + * \ingroup CGNSGeometryReference + * + * \brief Read geometry reference information + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \param[in] G Geometry reference index number, where 1 ≤ G ≤ nGeo. + * \param[out] geo_name Name of GeometryReference_t node. + * \param[out] geo_file Name of geometry file + * \param[out] CAD_name Geometry format + * \param[out] npart Number of geometry entities + * \return \ier + * + */ +int cg_geo_read(int fn, int B, int Fam, int G, char *geo_name, char **geo_file, char *CAD_name, int *npart) { cgns_family *family; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; - family = cgi_get_family(cg, B, F); + family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; if (G<=0 || G>family->ngeos) { @@ -2061,8 +2691,23 @@ int cg_geo_read(int file_number, int B, int F, int G, char *geo_name, return CG_OK; } -int cg_geo_write(int file_number, int B, int F, const char * geo_name, - const char * filename, const char * CADname, int *G) +/** + * \ingroup CGNSGeometryReference + * + * \brief Create a GeometryReference_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \param[in] geo_name Name of GeometryReference_t node. + * \param[in] geo_file Name of geometry file + * \param[in] CAD_name Geometry format + * \param[out] G Geometry reference index number, where 1 ≤ G ≤ nGeo. + * \return \ier + * + */ +int cg_geo_write(int fn, int B, int Fam, const char * geo_name, + const char *geo_file, const char * CAD_name, int *G) { int index; cgsize_t length; @@ -2072,15 +2717,15 @@ int cg_geo_write(int file_number, int B, int F, const char * geo_name, /* verify input */ if (cgi_check_strlen(geo_name)) return CG_ERROR; - if (cgi_check_strlen(CADname)) return CG_ERROR; + if (cgi_check_strlen(CAD_name)) return CG_ERROR; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for family */ - family = cgi_get_family(cg, B, F); + family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; /* Overwrite a GeometryReference_t Node: */ @@ -2119,9 +2764,9 @@ int cg_geo_write(int file_number, int B, int F, const char * geo_name, memset(geo, 0, sizeof(cgns_geo)); strcpy(geo->name, geo_name); - strcpy(geo->format, CADname); + strcpy(geo->format, CAD_name); - length = (int)strlen(filename); + length = (int)strlen(geo_file); if (length<=0) { cgi_error("filename undefined for GeometryReference node!"); return CG_ERROR; @@ -2131,7 +2776,7 @@ int cg_geo_write(int file_number, int B, int F, const char * geo_name, cgi_error("Error allocation geo->file"); return CG_ERROR; } - strcpy(geo->file, filename); + strcpy(geo->file, geo_file); /* save data in file */ if (cgi_new_node(family->id, geo->name, "GeometryReference_t", &geo->id, @@ -2148,6 +2793,19 @@ int cg_geo_write(int file_number, int B, int F, const char * geo_name, /* FamilyTree extension */ /* ** FAMILY TREE ** */ /*----------------------------------------------------------------------*/ +/** + * \ingroup CGNSGeometryReference + * + * \brief Read geometry reference information (Family_t level) + * + * \param[in] G Geometry reference index number, where 1 ≤ G ≤ nGeo. + * \param[out] geo_name Name of GeometryReference_t node. + * \param[out] geo_file Name of geometry file + * \param[out] CAD_name Geometry format + * \param[out] npart Number of geometry entities + * \return \ier + * + */ int cg_node_geo_read( int G, char *geo_name, char **geo_file, char *CAD_name, int *npart ) { @@ -2192,8 +2850,21 @@ int cg_node_geo_read( int G, char *geo_name, } /*----------------------------------------------------------------------*/ +/** + * \ingroup CGNSGeometryReference + * + * \brief Create GeometryReference_t node (Family_t level) + * + * \param[in] geo_name Name of GeometryReference_t node. + * \param[in] geo_file Name of geometry file + * \param[in] CAD_name Geometry format + * \param[out] G Geometry reference index number, where 1 ≤ G ≤ nGeo. + * + * \return \ier + * + */ int cg_node_geo_write( const char *geo_name, - const char *filename, const char *CADname, int *G) + const char *geo_file, const char *CAD_name, int *G) { int index; cgsize_t length; @@ -2203,7 +2874,7 @@ int cg_node_geo_write( const char *geo_name, /* verify input */ if (cgi_check_strlen(geo_name)) return CG_ERROR; - if (cgi_check_strlen(CADname)) return CG_ERROR; + if (cgi_check_strlen(CAD_name)) return CG_ERROR; CHECK_FILE_OPEN @@ -2261,9 +2932,9 @@ int cg_node_geo_write( const char *geo_name, memset(geo, 0, sizeof(cgns_geo)); strcpy(geo->name, geo_name); - strcpy(geo->format, CADname); + strcpy(geo->format, CAD_name); - length = (int)strlen(filename); + length = (int)strlen(geo_file); if (length<=0) { cgi_error("filename undefined for GeometryReference node!"); return CG_ERROR; @@ -2273,7 +2944,7 @@ int cg_node_geo_write( const char *geo_name, cgi_error("Error allocation geo->file"); return CG_ERROR; } - strcpy(geo->file, filename); + strcpy(geo->file, geo_file); /* save data in file */ if (cgi_new_node(family->id, geo->name, "GeometryReference_t", &geo->id, @@ -2291,17 +2962,30 @@ int cg_node_geo_write( const char *geo_name, /*----------------------------------------------------------------------*/ - -int cg_part_read(int file_number, int B, int F, int G, int P, char *part_name) +/** + * \ingroup CGNSGeometryReference + * + * \brief Get geometry entity name + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \param[in] G Geometry reference index number, where 1 ≤ G ≤ nGeo. + * \param[in] P Geometry entity index number, where 1 ≤ P ≤ nparts + * \param[out] part_name Name of a geometry entity in the file FileName. + * \return \ier + * + */ +int cg_part_read(int fn, int B, int Fam, int G, int P, char *part_name) { cgns_family *family; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; - family = cgi_get_family(cg, B, F); + family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; if (P<=0 || P>family->geo[G-1].npart) { @@ -2312,7 +2996,21 @@ int cg_part_read(int file_number, int B, int F, int G, int P, char *part_name) return CG_OK; } -int cg_part_write(int file_number, int B, int F, int G, const char * part_name, +/** + * \ingroup CGNSGeometryReference + * + * \brief Write geometry entity name + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Fam Family index number, where 1 ≤ Fam ≤ nfamilies. + * \param[in] G Geometry reference index number, where 1 ≤ G ≤ nGeo. + * \param[in] part_name Name of a geometry entity in the file FileName. + * \param[out] P Geometry entity index number, where 1 ≤ P ≤ nparts + * \return \ier + * + */ +int cg_part_write(int fn, int B, int Fam, int G, const char * part_name, int *P) { int index; @@ -2323,13 +3021,13 @@ int cg_part_write(int file_number, int B, int F, int G, const char * part_name, /* verify input */ if (cgi_check_strlen(part_name)) return CG_ERROR; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; /* get memory address for geo */ - family = cgi_get_family(cg, B, F); + family = cgi_get_family(cg, B, Fam); if (family==0) return CG_ERROR; if (G > family->ngeos || G <=0) { cgi_error("Invalid index for GeometryEntity_t node"); @@ -2382,6 +3080,17 @@ int cg_part_write(int file_number, int B, int F, int G, const char * part_name, /* FamilyTree extension */ /* ** FAMILY TREE ** */ /*----------------------------------------------------------------------*/ +/** + * \ingroup CGNSGeometryReference + * + * \brief Get geometry entity name (Family_t level) + * + * \param[in] G Geometry reference index number, where 1 ≤ G ≤ nGeo. + * \param[in] P Geometry entity index number, where 1 ≤ P ≤ nparts + * \param[out] part_name Name of a geometry entity in the file FileName. + * \return \ier + * + */ int cg_node_part_read(int G, int P, char *part_name) { cgns_family* family = 0; @@ -2416,6 +3125,17 @@ int cg_node_part_read(int G, int P, char *part_name) } /*----------------------------------------------------------------------*/ +/** + * \ingroup CGNSGeometryReference + * + * \brief Write geometry entity name (Family_t level) + * + * \param[in] G Geometry reference index number, where 1 ≤ G ≤ nGeo. + * \param[in] part_name Name of a geometry entity in the file FileName. + * \param[out] P Geometry entity index number, where 1 ≤ P ≤ nparts + * \return \ier + * + */ int cg_node_part_write(int G, const char * part_name, int *P) { int index; @@ -2498,11 +3218,23 @@ int cg_node_part_write(int G, const char * part_name, int *P) * Read and Write DiscreteData_t Nodes \*****************************************************************************/ -int cg_ndiscrete(int file_number, int B, int Z, int *ndiscrete) +/** + * \ingroup DiscreteData + * + * \brief Get number of `DiscreteData_t` nodes + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] ndiscrete Number of `DiscreteData_t` data structures under zone Z. + * \return \ier + * + */ +int cg_ndiscrete(int fn, int B, int Z, int *ndiscrete) { cgns_zone *zone; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -2514,11 +3246,24 @@ int cg_ndiscrete(int file_number, int B, int Z, int *ndiscrete) return CG_OK; } -int cg_discrete_read(int file_number, int B, int Z, int D, char *discrete_name) +/** + * \ingroup DiscreteData + * + * \brief Get name of `DiscreteData_t` node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] D Discrete data index number, where 1 ≤ D ≤ ndiscrete. + * \param[out] discrete_name Name of `DiscreteData_t` data structures. + * \return \ier + * + */ +int cg_discrete_read(int fn, int B, int Z, int D, char *discrete_name) { cgns_discrete *discrete; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -2531,7 +3276,20 @@ int cg_discrete_read(int file_number, int B, int Z, int D, char *discrete_name) return CG_OK; } -int cg_discrete_write(int file_number, int B, int Z, const char * discrete_name, +/** + * \ingroup DiscreteData + * + * \brief Create a `DiscreteData_t` node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] discrete_name Name of `DiscreteData_t` data structures. + * \param[out] D Discrete data index number, where 1 ≤ D ≤ ndiscrete. + * \return \ier + * + */ +int cg_discrete_write(int fn, int B, int Z, const char * discrete_name, int *D) { cgns_zone *zone; @@ -2541,7 +3299,7 @@ int cg_discrete_write(int file_number, int B, int Z, const char * discrete_name /* verify input */ if (cgi_check_strlen(discrete_name)) return CG_ERROR; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -2593,12 +3351,28 @@ int cg_discrete_write(int file_number, int B, int Z, const char * discrete_name return CG_OK; } -int cg_discrete_size(int file_number, int B, int Z, int D, + + +/** + * \ingroup DiscreteData + * + * \brief Get the dimensions of `DiscreteData_t` node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] D Discrete data index number, where 1 ≤ D ≤ ndiscrete. + * \param[out] data_dim Number of dimensions defining the discrete data. If a point set has been defined, this will be 1, otherwise this will be the current zone index dimension. + * \param[out] dim_vals The array of data_dim dimensions for the discrete data. + * \return \ier + * + */ +int cg_discrete_size(int fn, int B, int Z, int D, int *data_dim, cgsize_t *dim_vals) { cgns_discrete *discrete; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -2621,6 +3395,20 @@ int cg_discrete_size(int file_number, int B, int Z, int D, /*----------------------------------------------------------------------*/ +/** + * \ingroup DiscreteData + * + * \brief Get info about a point set `DiscreteData_t` node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] D Discrete data index number, where 1 ≤ D ≤ ndiscrete. + * \param[out] ptset_type Type of point set defining the interface for the discrete data; either PointRange or PointList. + * \param[out] npnts Number of points defining the interface for the discrete data. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points in the list. + * \return \ier + * + */ int cg_discrete_ptset_info(int fn, int B, int Z, int D, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts) { @@ -2644,6 +3432,19 @@ int cg_discrete_ptset_info(int fn, int B, int Z, int D, return CG_OK; } +/** + * \ingroup DiscreteData + * + * \brief Read a point set `DiscreteData_t` node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] D Discrete data index number, where 1 ≤ D ≤ ndiscrete. + * \param[out] pnts Array of points defining the interface for the discrete data. + * \return \ier + * + */ int cg_discrete_ptset_read(int fn, int B, int Z, int D, cgsize_t *pnts) { int dim = 0; @@ -2667,6 +3468,23 @@ int cg_discrete_ptset_read(int fn, int B, int Z, int D, cgsize_t *pnts) return CG_OK; } +/** + * \ingroup DiscreteData + * + * \brief Create a point set `DiscreteData_t` node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] discrete_name Name of `DiscreteData_t` data structures. + * \param[in] location Grid location where the discrete data is recorded. The current admissible locations are Vertex, CellCenter, IFaceCenter, JFaceCenter, and KFaceCenter. + * \param[in] ptset_type Type of point set defining the interface for the discrete data; either PointRange or PointList. + * \param[in] npnts Number of points defining the interface for the discrete data. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points in the list. + * \param[in] pnts Array of points defining the interface for the discrete data. + * \param[out] D Discrete data index number, where 1 ≤ D ≤ ndiscrete. + * \return \ier + * + */ int cg_discrete_ptset_write(int fn, int B, int Z, const char *discrete_name, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, @@ -2728,11 +3546,23 @@ int cg_discrete_ptset_write(int fn, int B, int Z, * Read and Write GridCoordinates_t Nodes \*****************************************************************************/ -int cg_ngrids(int file_number, int B, int Z, int *ngrids) +/** + * \ingroup ZoneGridCoordinates + * + * \brief Get number of `GridCoordinates_t` nodes + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] ngrids Number of `GridCoordinates_t` nodes for zone Z. + * \return \ier + * + */ +int cg_ngrids(int fn, int B, int Z, int *ngrids) { cgns_zone *zone; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -2745,11 +3575,24 @@ int cg_ngrids(int file_number, int B, int Z, int *ngrids) return CG_OK; } -int cg_grid_read(int file_number, int B, int Z, int G, char *gridname) +/** + * \ingroup ZoneGridCoordinates + * + * \brief Get Name of a `GridCoordinates_t` node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] G \G_Grid + * \param[out] grid_coord_name Name of the GridCoordinates_t node. Note that the name "GridCoordinates" is reserved for the original grid and must be the first GridCoordinates_t node to be defined. + * \return \ier + * + */ +int cg_grid_read(int fn, int B, int Z, int G, char *grid_coord_name) { cgns_zcoor *zcoor; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -2759,21 +3602,34 @@ int cg_grid_read(int file_number, int B, int Z, int G, char *gridname) if (zcoor==0) return CG_ERROR; /* Return ADF name for the GridCoordinates_t node */ - strcpy(gridname,zcoor->name); + strcpy(grid_coord_name,zcoor->name); return CG_OK; } -int cg_grid_write(int file_number, int B, int Z, const char * zcoorname, int *G) +/** + * \ingroup ZoneGridCoordinates + * + * \brief Create a `GridCoordinates_t` nodes + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] grid_coord_name Name of the GridCoordinates_t node. Note that the name "GridCoordinates" is reserved for the original grid and must be the first GridCoordinates_t node to be defined. + * \param[out] G \G_Grid + * \return \ier + * + */ +int cg_grid_write(int fn, int B, int Z, const char * grid_coord_name, int *G) { cgns_zone *zone; cgns_zcoor *zcoor = NULL; int index, n, index_dim; /* verify input */ - if (cgi_check_strlen(zcoorname)) return CG_ERROR; + if (cgi_check_strlen(grid_coord_name)) return CG_ERROR; /* get memory address */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -2783,11 +3639,11 @@ int cg_grid_write(int file_number, int B, int Z, const char * zcoorname, int *G) /* Overwrite a GridCoordinates_t Node: */ for (index=0; indexnzcoor; index++) { - if (strcmp(zcoorname, zone->zcoor[index].name)==0) { + if (strcmp(grid_coord_name, zone->zcoor[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { - cgi_error("Duplicate child name found: %s",zcoorname); + cgi_error("Duplicate child name found: %s",grid_coord_name); return CG_ERROR; } @@ -2816,7 +3672,7 @@ int cg_grid_write(int file_number, int B, int Z, const char * zcoorname, int *G) /* save data in memory */ memset(zcoor, 0, sizeof(cgns_zcoor)); - strcpy(zcoor->name,zcoorname); + strcpy(zcoor->name,grid_coord_name); index_dim = zone->index_dim; zcoor->rind_planes = (int *)malloc(index_dim*2*sizeof(int)); @@ -2838,7 +3694,23 @@ int cg_grid_write(int file_number, int B, int Z, const char * zcoorname, int *G) * Read and Write GridCoordinates_t bounding box \*****************************************************************************/ -int cg_grid_bounding_box_read(int file_number, int B, int Z, int G, CGNS_ENUMT(DataType_t) type, void* boundingbox) +/** + * \ingroup ZoneGridCoordinates + * + * \brief Get bounding box associated with a `GridCoordinates_t` node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] G \G_Grid + * \param[in] datatype Data type of the bounding box array written to the file or read. Admissible data types for a coordinate bounding box are RealSingle and RealDouble. + * \param[out] boundingbox Data Array with bounding box values. + * \return \ier + * + * \details When reading a bounding box, if the information is missing from the file, the boundingbox array will remain untouched, and the CG_NODE_NOT_FOUND status is returned. The CGNS MLL relies on the user to compute the bounding box and ensure that the bounding box being stored is coherent with the coordinates under GridCoordinates_t node. + * + */ +int cg_grid_bounding_box_read(int fn, int B, int Z, int G, CGNS_ENUMT(DataType_t) datatype, void* boundingbox) { cgns_zcoor *zcoor; cgns_base *base; @@ -2849,7 +3721,7 @@ int cg_grid_bounding_box_read(int file_number, int B, int Z, int G, CGNS_ENUMT(D cgsize_t dim_vals[12]; cgsize_t num; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -2866,8 +3738,8 @@ int cg_grid_bounding_box_read(int file_number, int B, int Z, int G, CGNS_ENUMT(D /* check bounding box is not an empty array*/ if (strcmp(data_type,"MT")==0) { - cgi_warning("No bounding box read"); - return CG_OK; + cgi_error("No bounding box found for reading"); + return CG_NODE_NOT_FOUND; } if (strcmp(data_type,"R4") && @@ -2891,25 +3763,41 @@ int cg_grid_bounding_box_read(int file_number, int B, int Z, int G, CGNS_ENUMT(D } /* verify input */ - if (type != CGNS_ENUMV(RealSingle) && type != CGNS_ENUMV(RealDouble)) { - cgi_error("Invalid data type for bounding box array: %d", type); + if (datatype != CGNS_ENUMV(RealSingle) && datatype != CGNS_ENUMV(RealDouble)) { + cgi_error("Invalid data type for bounding box array: %d", datatype); return CG_ERROR; } /* transfer small bounding box data to user with correct data type */ - cgi_convert_data(num, cgi_datatype(data_type), vdata, type, boundingbox); + cgi_convert_data(num, cgi_datatype(data_type), vdata, datatype, boundingbox); CGNS_FREE(vdata); return CG_OK; } -int cg_grid_bounding_box_write(int file_number, int B, int Z, int G, CGNS_ENUMT(DataType_t) type, void* boundingbox) +/** + * \ingroup ZoneGridCoordinates + * + * \brief Write bounding box associated with a `GridCoordinates_t` node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] G \G_Grid + * \param[in] datatype Data type of the bounding box array written to the file or read. Admissible data types for a coordinate bounding box are RealSingle and RealDouble. + * \param[in] boundingbox Data Array with bounding box values. + * \return \ier + * + * \details The CGNS MLL relies on the user to compute the bounding box and ensure that the bounding box being stored is coherent with the coordinates under GridCoordinates_t node. + + */ +int cg_grid_bounding_box_write(int fn, int B, int Z, int G, CGNS_ENUMT(DataType_t) datatype, void* boundingbox) { cgns_base *base; cgns_zcoor *zcoor; cgsize_t dim_vals[2]; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -2940,13 +3828,13 @@ int cg_grid_bounding_box_write(int file_number, int B, int Z, int G, CGNS_ENUMT( /* Check input */ if (boundingbox == NULL) return CG_OK; - if (type != CGNS_ENUMV(RealSingle) && type != CGNS_ENUMV(RealDouble)) { - cgi_error("Invalid data type for bounding box array: %d", type); + if (datatype != CGNS_ENUMV(RealSingle) && datatype != CGNS_ENUMV(RealDouble)) { + cgi_error("Invalid data type for bounding box array: %d", datatype); return CG_ERROR; } /* Write Bounding box into existing GridCoordinates_t node */ - if (cgio_set_dimensions(cg->cgio, zcoor->id, cgi_adf_datatype(type), 2, dim_vals)) { + if (cgio_set_dimensions(cg->cgio, zcoor->id, cgi_adf_datatype(datatype), 2, dim_vals)) { cg_io_error("cgio_set_dimensions"); return CG_ERROR; } @@ -2962,11 +3850,23 @@ int cg_grid_bounding_box_write(int file_number, int B, int Z, int G, CGNS_ENUMT( * Read and Write GridCoordinates_t/DataArray_t Nodes \*****************************************************************************/ -int cg_ncoords(int file_number, int B, int Z, int *ncoords) +/** + * \ingroup ZoneGridCoordinates + * + * \brief Get number of coordinate arrays + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] ncoords Number of coordinate arrays for zone Z. + * \return \ier + * + */ +int cg_ncoords(int fn, int B, int Z, int *ncoords) { cgns_zcoor *zcoor; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -2978,12 +3878,26 @@ int cg_ncoords(int file_number, int B, int Z, int *ncoords) return CG_OK; } -int cg_coord_info(int file_number, int B, int Z, int C, CGNS_ENUMT(DataType_t) *type, +/** + * \ingroup ZoneGridCoordinates + * + * \brief Get info about a coordinate array + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] C \C_Coordinate + * \param[out] datatype Data type of the coordinate array written to the file. Admissible data types for a coordinate array are RealSingle and RealDouble. + * \param[out] coordname Name of the coordinate array. It is strongly advised to use the SIDS nomenclature conventions when naming the coordinate arrays to insure file compatibility. + * \return \ier + * + */ +int cg_coord_info(int fn, int B, int Z, int C, CGNS_ENUMT(DataType_t) *datatype, char *coordname) { cgns_zcoor *zcoor; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -2996,21 +3910,37 @@ int cg_coord_info(int file_number, int B, int Z, int C, CGNS_ENUMT(DataType_t) cgi_error("coord number %d invalid",C); return CG_ERROR; } - *type = cgi_datatype(zcoor->coord[C-1].data_type); + *datatype = cgi_datatype(zcoor->coord[C-1].data_type); strcpy(coordname, zcoor->coord[C-1].name); return CG_OK; } -int cg_coord_read(int file_number, int B, int Z, const char *coordname, - CGNS_ENUMT(DataType_t) type, const cgsize_t *s_rmin, - const cgsize_t *s_rmax, void *coord_ptr) +/** + * \ingroup ZoneGridCoordinates + * + * \brief Read grid coordinate array + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] coordname Name of the coordinate array. It is strongly advised to use the SIDS nomenclature conventions when naming the coordinate arrays to insure file compatibility. + * \param[in] mem_datatype Data type of an array in memory. Admissible data types for a coordinate array are RealSingle and RealDouble. + * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). + * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). + * \param[out] coord_array Array of coordinate values. + * \return \ier + * + */ +int cg_coord_read(int fn, int B, int Z, const char *coordname, + CGNS_ENUMT(DataType_t) mem_datatype, const cgsize_t *s_rmin, + const cgsize_t *s_rmax, void *coord_array) { cgns_zone *zone; int n, m_numdim; /* get memory addresses */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); @@ -3032,12 +3962,32 @@ int cg_coord_read(int file_number, int B, int Z, const char *coordname, m_dimvals[n] = m_rmax[n]; } - return cg_coord_general_read(file_number, B, Z, coordname, - s_rmin, s_rmax, type, + return cg_coord_general_read(fn, B, Z, coordname, + s_rmin, s_rmax, mem_datatype, m_numdim, m_dimvals, m_rmin, m_rmax, - coord_ptr); + coord_array); } +/** + * \ingroup ZoneGridCoordinates + * + * \brief Read subset of grid coordinates to a shaped array + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] coordname Name of the coordinate array. It is strongly advised to use the SIDS nomenclature conventions when naming the coordinate arrays to insure file compatibility. + * \param[in] m_type Data type of an array in memory. Admissible data types for a coordinate array are RealSingle and RealDouble. + * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). + * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). + * \param[in] m_numdim Number of dimensions of array in memory. + * \param[in] m_dimvals Dimensions of array in memory. + * \param[in] m_rmin Lower range index in memory (eg., imin, jmin, kmin). + * \param[in] m_rmax Upper range index in memory (eg., imax, jmax, kmax). + * \param[out] coord_ptr Array of coordinate values. + * \return \ier + * + */ int cg_coord_general_read(int fn, int B, int Z, const char *coordname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, @@ -3087,11 +4037,11 @@ int cg_coord_general_read(int fn, int B, int Z, const char *coordname, coord_ptr); } -int cg_coord_id(int file_number, int B, int Z, int C, double *coord_id) +int cg_coord_id(int fn, int B, int Z, int C, double *coord_id) { cgns_zcoor *zcoor; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -3109,7 +4059,22 @@ int cg_coord_id(int file_number, int B, int Z, int C, double *coord_id) return CG_OK; } -int cg_coord_write(int file_number, int B, int Z, CGNS_ENUMT(DataType_t) type, +/** + * \ingroup ZoneGridCoordinates + * + * \brief Write grid coordinates + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] datatype Data type of the coordinate array written to the file. Admissible data types for a coordinate array are RealSingle and RealDouble. + * \param[in] coordname Name of the coordinate array. It is strongly advised to use the SIDS nomenclature conventions when naming the coordinate arrays to insure file compatibility. + * \param[in] coord_ptr Array of coordinate values. + * \param[out] C \C_Coordinate + * \return \ier + * + */ +int cg_coord_write(int fn, int B, int Z, CGNS_ENUMT(DataType_t) datatype, const char *coordname, const void *coord_ptr, int *C) { cgns_zone *zone; @@ -3121,12 +4086,12 @@ int cg_coord_write(int file_number, int B, int Z, CGNS_ENUMT(DataType_t) type, /* verify input */ if (cgi_check_strlen(coordname)) return CG_ERROR; - if (type!=CGNS_ENUMV( RealSingle ) && type!=CGNS_ENUMV( RealDouble )) { - cgi_error("Invalid datatype for coord. array: %d", type); + if (datatype!=CGNS_ENUMV( RealSingle ) && datatype!=CGNS_ENUMV( RealDouble )) { + cgi_error("Invalid datatype for coord. array: %d", datatype); return CG_ERROR; } /* get memory addresses */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); @@ -3157,17 +4122,34 @@ int cg_coord_write(int file_number, int B, int Z, CGNS_ENUMT(DataType_t) type, m_rmax[n] = m_dimvals[n]; } - status = cg_coord_general_write(file_number, B, Z, coordname, - type, s_rmin, s_rmax, - type, m_numdim, m_dimvals, m_rmin, m_rmax, + status = cg_coord_general_write(fn, B, Z, coordname, + datatype, s_rmin, s_rmax, + datatype, m_numdim, m_dimvals, m_rmin, m_rmax, coord_ptr, C); HDF5storage_type = CG_COMPACT; return status; } -int cg_coord_partial_write(int file_number, int B, int Z, - CGNS_ENUMT(DataType_t) type, +/** + * \ingroup ZoneGridCoordinates + * + * \brief Write subset of grid coordinates + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] datatype Data type of the coordinate array written to the file. Admissible data types for a coordinate array are RealSingle and RealDouble. + * \param[in] coordname Name of the coordinate array. It is strongly advised to use the SIDS nomenclature conventions when naming the coordinate arrays to insure file compatibility. + * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). + * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). + * \param[in] coord_ptr Array of coordinate values. + * \param[out] C \C_Coordinate + * \return \ier + * + */ +int cg_coord_partial_write(int fn, int B, int Z, + CGNS_ENUMT(DataType_t) datatype, const char *coordname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, const void *coord_ptr, int *C) @@ -3177,7 +4159,7 @@ int cg_coord_partial_write(int file_number, int B, int Z, int status; /* get memory addresses */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); @@ -3198,13 +4180,35 @@ int cg_coord_partial_write(int file_number, int B, int Z, m_dimvals[n] = m_rmax[n]; } - status = cg_coord_general_write(file_number, B, Z, coordname, - type, s_rmin, s_rmax, - type, m_numdim, m_dimvals, m_rmin, m_rmax, + status = cg_coord_general_write(fn, B, Z, coordname, + datatype, s_rmin, s_rmax, + datatype, m_numdim, m_dimvals, m_rmin, m_rmax, coord_ptr, C); return status; } +/** + * \ingroup ZoneGridCoordinates + * + * \brief Write shaped array to a subset of grid coordinates + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] coordname Name of the coordinate array. It is strongly advised to use the SIDS nomenclature conventions when naming the coordinate arrays to insure file compatibility. + * \param[in] s_type Data type of the coordinate array written to the file. Admissible data types for a coordinate array are RealSingle and RealDouble. + * \param[in] m_type Data type of an array in memory. Admissible data types for a coordinate array are RealSingle and RealDouble. + * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). + * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). + * \param[in] m_numdim Number of dimensions of array in memory. + * \param[in] m_dimvals Dimensions of array in memory. + * \param[in] m_rmin Lower range index in memory (eg., imin, jmin, kmin). + * \param[in] m_rmax Upper range index in memory (eg., imax, jmax, kmax). + * \param[in] coord_ptr Array of coordinate values. + * \param[out] C \C_Coordinate + * \return \ier + * + */ int cg_coord_general_write(int fn, int B, int Z, const char *coordname, CGNS_ENUMT(DataType_t) s_type, const cgsize_t *s_rmin, const cgsize_t *s_rmax, @@ -3435,11 +4439,23 @@ static int read_parent_data(cgns_section *section) /*----------------------------------------------------------------------*/ -int cg_nsections(int file_number, int B, int Z, int *nsections) +/** + * \ingroup ElementConnectivity + * + * \brief Get number of element sections + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] nsections Number of element sections. + * \return \ier + * + */ +int cg_nsections(int fn, int B, int Z, int *nsections) { cgns_zone *zone; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -3452,13 +4468,31 @@ int cg_nsections(int file_number, int B, int Z, int *nsections) return CG_OK; } -int cg_section_read(int file_number, int B, int Z, int S, char *SectionName, +/** + * \ingroup ElementConnectivity + * + * \brief Get info for an element section + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] type Type of element. See the eligible types for ElementType_t in the Typedefs section. + * \param[out] SectionName Name of the Elements_t node. + * \param[out] start Index of first element in the section. + * \param[out] end Index of last element in the section. + * \param[out] nbndry Index of last boundary element in the section. Set to zero if the elements are unsorted. + * \param[out] parent_flag Flag indicating if the parent data are defined. If the parent data exist, parent_flag is set to 1; otherwise it is set to 0. + * \return \ier + * + */ +int cg_section_read(int fn, int B, int Z, int S, char *SectionName, CGNS_ENUMT(ElementType_t) *type, cgsize_t *start, cgsize_t *end, int *nbndry, int *parent_flag) { cgns_section *section; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -3478,7 +4512,27 @@ int cg_section_read(int file_number, int B, int Z, int S, char *SectionName, return CG_OK; } -int cg_section_write(int file_number, int B, int Z, const char * SectionName, +/** + * \ingroup ElementConnectivity + * + * \brief Write fixed size element data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] type Type of element. See the eligible types for ElementType_t in the Typedefs section. + * \param[in] SectionName Name of the Elements_t node. + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] nbndry Index of last boundary element in the section. Set to zero if the elements are unsorted. + * \param[in] elements Element connectivity data. The element connectivity order is given in Element Numbering Conventions. + * \param[out] S \CONN_S + * \return \ier + * + * \details This writing function only works with fixed size elements. + * + */ +int cg_section_write(int fn, int B, int Z, const char * SectionName, CGNS_ENUMT(ElementType_t)type, cgsize_t start, cgsize_t end, int nbndry, const cgsize_t * elements, int *S) @@ -3491,7 +4545,7 @@ int cg_section_write(int file_number, int B, int Z, const char * SectionName, return CG_ERROR; } - if (cg_section_general_write(file_number, B, Z, SectionName, type, + if (cg_section_general_write(fn, B, Z, SectionName, type, cgi_datatype(CG_SIZE_DATATYPE), start, end, 0, nbndry, S)){ return CG_ERROR; @@ -3510,7 +4564,26 @@ int cg_section_write(int file_number, int B, int Z, const char * SectionName, return CG_OK; } -int cg_poly_section_write(int file_number, int B, int Z, const char * SectionName, +/** + * \ingroup ElementConnectivity + * + * \brief Write element data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] type Type of element. See the eligible types for ElementType_t in the Typedefs section. + * \param[in] SectionName Name of the Elements_t node. + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] nbndry Index of last boundary element in the section. Set to zero if the elements are unsorted. + * \param[in] elements Element connectivity data. The element connectivity order is given in Element Numbering Conventions. + * \param[in] connect_offset Element connectivity offset data. This is required for NGON_n, NFACE_n and MIXED according to Elements_t Structure Definition. + * \param[out] S \CONN_S + * \return \ier + * + */ +int cg_poly_section_write(int fn, int B, int Z, const char * SectionName, CGNS_ENUMT(ElementType_t)type, cgsize_t start, cgsize_t end, int nbndry, const cgsize_t * elements, const cgsize_t * connect_offset, int *S) @@ -3520,7 +4593,7 @@ int cg_poly_section_write(int file_number, int B, int Z, const char * SectionNam cgsize_t num, ElementDataSize=0; /* get file and check mode */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; num = end - start + 1; @@ -3537,7 +4610,7 @@ int cg_poly_section_write(int file_number, int B, int Z, const char * SectionNam if (ElementDataSize < 0) return CG_ERROR; /* Create empty section */ - if (cg_section_general_write(file_number, B, Z, SectionName, type, + if (cg_section_general_write(fn, B, Z, SectionName, type, cgi_datatype(CG_SIZE_DATATYPE), start, end, ElementDataSize, nbndry, S)){ return CG_ERROR; @@ -3567,7 +4640,24 @@ int cg_poly_section_write(int file_number, int B, int Z, const char * SectionNam return CG_OK; } -int cg_section_partial_write(int file_number, int B, int Z, const char * SectionName, +/** + * \ingroup ElementConnectivity + * + * \brief Write subset of element data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] type Type of element. See the eligible types for ElementType_t in the Typedefs section. + * \param[in] SectionName Name of the Elements_t node. + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] nbndry Index of last boundary element in the section. Set to zero if the elements are unsorted. + * \param[out] S \CONN_S + * \return \ier + * + */ +int cg_section_partial_write(int fn, int B, int Z, const char * SectionName, CGNS_ENUMT(ElementType_t) type, cgsize_t start, cgsize_t end, int nbndry, int *S) { @@ -3580,20 +4670,39 @@ int cg_section_partial_write(int file_number, int B, int Z, const char * Section ElementDataSize = num * elemsize; /* create empty section */ - if (cg_section_general_write(file_number, B, Z, SectionName, type, + if (cg_section_general_write(fn, B, Z, SectionName, type, cgi_datatype(CG_SIZE_DATATYPE), start, end, ElementDataSize, nbndry, S)){ return CG_ERROR; } /* if not fixed element size, need to create valid data for sizing */ - if (cg_section_initialize(file_number, B, Z, *S)) { + if (cg_section_initialize(fn, B, Z, *S)) { return CG_ERROR; } return CG_OK; } -int cg_section_general_write(int file_number, int B, int Z, const char * SectionName, +/** + * \ingroup ElementConnectivity + * + * \brief Write section data without element data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] type Type of element. See the eligible types for ElementType_t in the Typedefs section. + * \param[in] elementDataType Data type of an array. Admissible data types are Integer and LongInteger. + * \param[in] SectionName Name of the Elements_t node. + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] elementDataSize Number of element connectivity data values. + * \param[in] nbndry Index of last boundary element in the section. Set to zero if the elements are unsorted. + * \param[out] S \CONN_S + * \return \ier + * + */ +int cg_section_general_write(int fn, int B, int Z, const char * SectionName, const CGNS_ENUMT(ElementType_t) type, const CGNS_ENUMT(DataType_t) elementDataType, cgsize_t start, cgsize_t end, cgsize_t elementDataSize, int nbndry, int *S) @@ -3650,7 +4759,7 @@ int cg_section_general_write(int file_number, int B, int Z, const char * Section } /* get file and check mode */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) @@ -3771,12 +4880,11 @@ int cg_section_general_write(int file_number, int B, int Z, const char * Section /* Do not write I8 in library that is not 64bit */ return CG_ERROR; } + HDF5storage_type = CG_CONTIGUOUS; /* ElementRange */ if (cgi_new_node(section->id, "ElementRange", "IndexRange_t", &dummy_id, data_type, 1, &dim_vals, prange)) return CG_ERROR; - HDF5storage_type = CG_CONTIGUOUS; - /* ElementStartOffset */ if (section->connect_offset && cgi_new_node(section->id, section->connect_offset->name, "DataArray_t", @@ -3793,11 +4901,22 @@ int cg_section_general_write(int file_number, int B, int Z, const char * Section return CG_OK; } -/* This function is a kind of helper to be used after a cg_section_general_write +/** + * \ingroup ElementConnectivity + * + * \brief Initialize element data for not fixed size elements + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] S \CONN_S + * \return \ier + * + * \details This function is a kind of helper to be used after a cg_section_general_write * cg_section_general_write reserve enough space while this function put * coherent init data. Then cg_poly_elements_partial_write would run safely. */ -int cg_section_initialize(int file_number, int B, int Z, int S) +int cg_section_initialize(int fn, int B, int Z, int S) { cgsize_t nm, nn, num, val; cgsize_t s_start, s_end, s_stride; @@ -3807,7 +4926,7 @@ int cg_section_initialize(int file_number, int B, int Z, int S) cgns_section *section = NULL; /* get file and check mode */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -4010,17 +5129,28 @@ int cg_section_initialize(int file_number, int B, int Z, int S) return CG_OK; } - /*----------------------------------------------------------------------*/ -/* This function was created for revision 1.2 to return the size of the - connectivity vector, which can't be known without it *when type=MIXED */ - -int cg_ElementDataSize(int file_number, int B, int Z, int S, +/** + * \ingroup ElementConnectivity + * + * \brief Get size of element connectivity data array + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[out] ElementDataSize Number of element connectivity data values. + * \return \ier + * + * \details This function was created for revision 1.2 to return the size of the + * connectivity vector, which can't be known without it *when type=MIXED* + */ +int cg_ElementDataSize(int fn, int B, int Z, int S, cgsize_t *ElementDataSize) { cgns_section *section; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -4033,13 +5163,30 @@ int cg_ElementDataSize(int file_number, int B, int Z, int S, return CG_OK; } -int cg_ElementPartialSize(int file_number, int B, int Z, int S, +/** + * \ingroup ElementConnectivity + * + * \brief Get size of element connectivity data array for partial read + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[out] ElementDataSize Number of element connectivity data values. + * \return \ier + * + * \details This function was created for revision 1.2 to return the size of the + * connectivity vector, which can't be known without it *when type=MIXED* + */ +int cg_ElementPartialSize(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, cgsize_t *ElementDataSize) { cgns_section *section; cgsize_t size, cnt, *offset_data; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -4131,14 +5278,27 @@ int cg_ElementPartialSize(int file_number, int B, int Z, int S, } /*----------------------------------------------------------------------*/ - -int cg_elements_read(int file_number, int B, int Z, int S, cgsize_t *elements, +/** + * \ingroup ElementConnectivity + * + * \brief Read fixed size element data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[out] elements Element connectivity data. The element connectivity order is given in Element Numbering Conventions. + * \param[out] parent_data For boundary or interface elements, this array contains information on the cell(s) and cell face(s) sharing the element. If you do not need to read the ParentData when reading the ElementData, you may set the value to NULL. + * \return \ier + * + */ +int cg_elements_read(int fn, int B, int Z, int S, cgsize_t *elements, cgsize_t *parent_data) { cgns_section *section; cgsize_t count, num, ElementDataSize=0; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -4191,15 +5351,29 @@ int cg_elements_read(int file_number, int B, int Z, int S, cgsize_t *elements, } /*----------------------------------------------------------------------*/ - -int cg_poly_elements_read(int file_number, int B, int Z, int S, cgsize_t *elements, +/** + * \ingroup ElementConnectivity + * + * \brief Read element data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[out] elements Element connectivity data. The element connectivity order is given in Element Numbering Conventions. + * \param[out] connect_offset Element connectivity offset data. This is required for NGON_n, NFACE_n and MIXED according to Elements_t Structure Definition. + * \param[out] parent_data For boundary or interface elements, this array contains information on the cell(s) and cell face(s) sharing the element. If you do not need to read the ParentData when reading the ElementData, you may set the value to NULL. + * \return \ier + * + */ +int cg_poly_elements_read(int fn, int B, int Z, int S, cgsize_t *elements, cgsize_t *connect_offset, cgsize_t *parent_data) { cgns_section *section; cgsize_t count, num, ElementDataSize=0, ConnectOffsetSize=0; cgsize_t *offset_data=0; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -4264,7 +5438,24 @@ int cg_poly_elements_read(int file_number, int B, int Z, int S, cgsize_t *elemen } /*----------------------------------------------------------------------*/ -int cg_elements_partial_read(int file_number, int B, int Z, int S, + +/** + * \ingroup ElementConnectivity + * + * \brief Read subset of fixed size element data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[out] elements Element connectivity data. The element connectivity order is given in Element Numbering Conventions. + * \param[out] parent_data For boundary or interface elements, this array contains information on the cell(s) and cell face(s) sharing the element. If you do not need to read the ParentData when reading the ElementData, you may set the value to NULL. + * \return \ier + * + */ +int cg_elements_partial_read(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, cgsize_t *elements, cgsize_t *parent_data) { @@ -4274,7 +5465,7 @@ int cg_elements_partial_read(int file_number, int B, int Z, int S, cgsize_t s_start[2], s_end[2], s_stride[2]; cgsize_t m_start[2], m_end[2], m_stride[2], m_dim[2]; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -4437,19 +5628,34 @@ int cg_elements_partial_read(int file_number, int B, int Z, int S, return CG_OK; } - /*----------------------------------------------------------------------*/ -int cg_elements_general_read(int file_number, int B, int Z, int S, +/** + * \ingroup ElementConnectivity + * + * \brief Read subset of fixed size element data to a typed array + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] m_type Data type of an array in memory. Admissible data types are Integer and LongInteger. + * \param[out] elements Element connectivity data. The element connectivity order is given in Element Numbering Conventions. + * \return \ier + * + */ +int cg_elements_general_read(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* elements) { cgns_section* section; - cgsize_t size; + cgsize_t size = 0; cgsize_t s_start[1], s_end[1], s_stride[1]; cgsize_t m_start[1], m_end[1], m_stride[1], m_dim[1]; CGNS_ENUMT(DataType_t) s_type; int ier = CG_OK; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -4563,8 +5769,24 @@ int cg_elements_general_read(int file_number, int B, int Z, int S, /*----------------------------------------------------------------------*/ -int cg_parent_elements_general_read(int file_number, int B, int Z, int S, - cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* parelem) +/** + * \ingroup ElementConnectivity + * + * \brief Read parent info for an element section + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] m_type Data type of an array in memory. Admissible data types are Integer and LongInteger. + * \param[out] ParentElement For boundary or interface elements, this array contains information on the cell(s) sharing the element. + * \return \ier + * + */ +int cg_parent_elements_general_read(int fn, int B, int Z, int S, + cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* ParentElement) { cgns_section* section; cgsize_t s_start[2], s_end[2], s_stride[2]; @@ -4572,7 +5794,7 @@ int cg_parent_elements_general_read(int file_number, int B, int Z, int S, CGNS_ENUMT(DataType_t) s_type; int ier = CG_OK; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -4596,7 +5818,7 @@ int cg_parent_elements_general_read(int file_number, int B, int Z, int S, return CG_ERROR; } - if (parelem == NULL || section->parelem == NULL) { + if (ParentElement == NULL || section->parelem == NULL) { cgi_error("Error reading ParentElementsPosition."); return CG_ERROR; } @@ -4623,7 +5845,7 @@ int cg_parent_elements_general_read(int file_number, int B, int Z, int S, if (section->connect->dim_vals[0] == m_end[0] && section->connect->dim_vals[1] == 2) { if (cgio_read_all_data_type(cg->cgio, section->parelem->id, - cgi_adf_datatype(m_type), parelem)) { + cgi_adf_datatype(m_type), ParentElement)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } @@ -4631,7 +5853,7 @@ int cg_parent_elements_general_read(int file_number, int B, int Z, int S, else { if (cgio_read_data_type(cg->cgio, section->parelem->id, s_start, s_end, s_stride, cgi_adf_datatype(m_type), 2, m_dim, - m_start, m_end, m_stride, parelem)) { + m_start, m_end, m_stride, ParentElement)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } @@ -4663,7 +5885,7 @@ int cg_parent_elements_general_read(int file_number, int B, int Z, int S, return CG_ERROR; } } - ier = cgi_convert_data(2*m_dim[0], s_type, conv_data, m_type, parelem); + ier = cgi_convert_data(2*m_dim[0], s_type, conv_data, m_type, ParentElement); free(conv_data); if (ier) return CG_ERROR; } @@ -4672,7 +5894,7 @@ int cg_parent_elements_general_read(int file_number, int B, int Z, int S, if (section->parelem->dim_vals[0] == m_dim[0] && section->parelem->dim_vals[1] == 2) { if (cgio_read_all_data_type(cg->cgio, section->parelem->id, - cgi_adf_datatype(m_type), parelem)) { + cgi_adf_datatype(m_type), ParentElement)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } @@ -4680,7 +5902,7 @@ int cg_parent_elements_general_read(int file_number, int B, int Z, int S, else { if (cgio_read_data_type(cg->cgio, section->parelem->id, s_start, s_end, s_stride, cgi_adf_datatype(m_type), 2, m_dim, - m_start, m_end, m_stride, parelem)) { + m_start, m_end, m_stride, ParentElement)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } @@ -4690,8 +5912,25 @@ int cg_parent_elements_general_read(int file_number, int B, int Z, int S, } /*----------------------------------------------------------------------*/ -int cg_parent_elements_position_general_read(int file_number, int B, int Z, int S, - cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* parface) + +/** + * \ingroup ElementConnectivity + * + * \brief Read parent position info for an element section + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] m_type Data type of an array in memory. Admissible data types are Integer and LongInteger. + * \param[out] ParentFace For boundary or interface elements, this array contains information on the cell face(s) sharing the element. + * \return \ier + * + */ +int cg_parent_elements_position_general_read(int fn, int B, int Z, int S, + cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* ParentFace) { cgns_section* section; cgsize_t s_start[2], s_end[2], s_stride[2]; @@ -4699,7 +5938,7 @@ int cg_parent_elements_position_general_read(int file_number, int B, int Z, int CGNS_ENUMT(DataType_t) s_type; int ier = CG_OK; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -4723,7 +5962,7 @@ int cg_parent_elements_position_general_read(int file_number, int B, int Z, int return CG_ERROR; } - if (parface == NULL || section->parface == NULL) { + if (ParentFace == NULL || section->parface == NULL) { cgi_error("Error reading ParentElementsPosition."); return CG_ERROR; } @@ -4750,7 +5989,7 @@ int cg_parent_elements_position_general_read(int file_number, int B, int Z, int if (section->connect->dim_vals[0] == m_end[0] && section->connect->dim_vals[1] == 2) { if (cgio_read_all_data_type(cg->cgio, section->parface->id, - cgi_adf_datatype(m_type), parface)) { + cgi_adf_datatype(m_type), ParentFace)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } @@ -4758,7 +5997,7 @@ int cg_parent_elements_position_general_read(int file_number, int B, int Z, int else { if (cgio_read_data_type(cg->cgio, section->parface->id, s_start, s_end, s_stride, cgi_adf_datatype(m_type), 2, m_dim, - m_start, m_end, m_stride, parface)) { + m_start, m_end, m_stride, ParentFace)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } @@ -4790,7 +6029,7 @@ int cg_parent_elements_position_general_read(int file_number, int B, int Z, int return CG_ERROR; } } - ier = cgi_convert_data(m_dim[0]*2, s_type, conv_data, m_type, parface); + ier = cgi_convert_data(m_dim[0]*2, s_type, conv_data, m_type, ParentFace); free(conv_data); if (ier) return CG_ERROR; } @@ -4799,7 +6038,7 @@ int cg_parent_elements_position_general_read(int file_number, int B, int Z, int if (section->connect->dim_vals[0] == m_dim[0] && section->connect->dim_vals[1] == 2) { if (cgio_read_all_data_type(cg->cgio, section->parface->id, - cgi_adf_datatype(m_type), parface)) { + cgi_adf_datatype(m_type), ParentFace)) { cg_io_error("cgio_read_all_data_type"); return CG_ERROR; } @@ -4807,7 +6046,7 @@ int cg_parent_elements_position_general_read(int file_number, int B, int Z, int else { if (cgio_read_data_type(cg->cgio, section->parface->id, s_start, s_end, s_stride, cgi_adf_datatype(m_type), 2, m_dim, - m_start, m_end, m_stride, parface)) { + m_start, m_end, m_stride, ParentFace)) { cg_io_error("cgio_read_data_type"); return CG_ERROR; } @@ -4817,7 +6056,24 @@ int cg_parent_elements_position_general_read(int file_number, int B, int Z, int } /*----------------------------------------------------------------------*/ -int cg_poly_elements_partial_read(int file_number, int B, int Z, int S, +/** + * \ingroup ElementConnectivity + * + * \brief Read subset of element data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[out] elements Element connectivity data. The element connectivity order is given in Element Numbering Conventions. + * \param[out] connect_offset Element connectivity offset data. This is required for NGON_n, NFACE_n and MIXED according to Elements_t Structure Definition. + * \param[out] parent_data For boundary or interface elements, this array contains information on the cell(s) and cell face(s) sharing the element. If you do not need to read the ParentData when reading the ElementData, you may set the value to NULL. + * \return \ier + * + */ +int cg_poly_elements_partial_read(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, cgsize_t *elements, cgsize_t *connect_offset, cgsize_t *parent_data) { @@ -4827,7 +6083,7 @@ int cg_poly_elements_partial_read(int file_number, int B, int Z, int S, cgsize_t s_start[2], s_end[2], s_stride[2]; cgsize_t m_start[2], m_end[2], m_stride[2], m_dim[2]; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -4996,7 +6252,24 @@ int cg_poly_elements_partial_read(int file_number, int B, int Z, int S, } /*----------------------------------------------------------------------*/ -int cg_poly_elements_general_read(int file_number, int B, int Z, int S, +/** + * \ingroup ElementConnectivity + * + * \brief Read subset of element data to typed arrays + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] m_type Data type of an array in memory. Admissible data types are Integer and LongInteger. + * \param[out] elements Element connectivity data. The element connectivity order is given in Element Numbering Conventions. + * \param[out] connect_offset Element connectivity offset data. This is required for NGON_n, NFACE_n and MIXED according to Elements_t Structure Definition. + * \return \ier + * + */ +int cg_poly_elements_general_read(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, CGNS_ENUMT(DataType_t) m_type, void* elements, void* connect_offset) { @@ -5007,7 +6280,7 @@ int cg_poly_elements_general_read(int file_number, int B, int Z, int S, CGNS_ENUMT(DataType_t) s_type; int ier = CG_OK; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* verify input */ @@ -5130,12 +6403,26 @@ int cg_poly_elements_general_read(int file_number, int B, int Z, int S, } /*----------------------------------------------------------------------*/ - -int cg_elements_partial_write(int file_number, int B, int Z, int S, +/** + * \ingroup ElementConnectivity + * + * \brief Write element data for a fixed size element section + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] elements Element connectivity data. The element connectivity order is given in Element Numbering Conventions. + * \return \ier + * + */ +int cg_elements_partial_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const cgsize_t *elements) { - if (cg_elements_general_write(file_number, B, Z, S, + if (cg_elements_general_write(fn, B, Z, S, start, end, cgi_datatype(CG_SIZE_DATATYPE), elements)) { return CG_ERROR; } @@ -5302,7 +6589,23 @@ int cg_elements_partial_write(int file_number, int B, int Z, int S, } \ } -int cg_elements_general_write(int file_number, int B, int Z, int S, +/** + * \ingroup ElementConnectivity + * + * \brief Write element data for a fixed size element section + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] m_type Data type of an array in memory. Admissible data types are Integer and LongInteger. + * \param[in] elements Element connectivity data. The element connectivity order is given in Element Numbering Conventions. + * \return \ier + * + */ +int cg_elements_general_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const CGNS_ENUMT(DataType_t) m_type, const void *elements) { @@ -5318,7 +6621,7 @@ int cg_elements_general_write(int file_number, int B, int Z, int S, int ier = CG_OK; /* get file and check mode */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) @@ -5601,11 +6904,27 @@ int cg_elements_general_write(int file_number, int B, int Z, int S, return CG_OK; } -int cg_poly_elements_partial_write(int file_number, int B, int Z, int S, +/** + * \ingroup ElementConnectivity + * + * \brief Write element data for an element section + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] elements Element connectivity data. The element connectivity order is given in Element Numbering Conventions. + * \param[in] connect_offset Element connectivity offset data. This is required for NGON_n, NFACE_n and MIXED according to Elements_t Structure Definition. + * \return \ier + * + */ +int cg_poly_elements_partial_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const cgsize_t *elements, const cgsize_t *connect_offset) { - if (cg_poly_elements_general_write(file_number, B, Z, S, + if (cg_poly_elements_general_write(fn, B, Z, S, start, end, cgi_datatype(CG_SIZE_DATATYPE), elements, connect_offset)) { return CG_ERROR; @@ -5613,7 +6932,24 @@ int cg_poly_elements_partial_write(int file_number, int B, int Z, int S, return CG_OK; } -int cg_poly_elements_general_write(int file_number, int B, int Z, int S, +/** + * \ingroup ElementConnectivity + * + * \brief Write element data for an element section + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] m_type Data type of an array in memory. Admissible data types are Integer and LongInteger. + * \param[in] elements Element connectivity data. The element connectivity order is given in Element Numbering Conventions. + * \param[in] input_connect_offset Element connectivity offset data. This is required for NGON_n, NFACE_n and MIXED according to Elements_t Structure Definition. + * \return \ier + * + */ +int cg_poly_elements_general_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const CGNS_ENUMT(DataType_t) m_type, const void *elements, const void *input_connect_offset) { @@ -5634,7 +6970,7 @@ int cg_poly_elements_general_write(int file_number, int B, int Z, int S, CGNS_ENUMT(DataType_t) s_type; /* get file and check mode */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) @@ -6198,15 +7534,27 @@ int cg_poly_elements_general_write(int file_number, int B, int Z, int S, } /*----------------------------------------------------------------------*/ - -int cg_parent_data_write(int file_number, int B, int Z, int S, +/** + * \ingroup ElementConnectivity + * + * \brief Write parent info for an element section + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] parent_data For boundary or interface elements, this array contains information on the cell(s) and cell face(s) sharing the element. If you do not need to read the ParentData when reading the ElementData, you may set the value to NULL. + * \return \ier + * + */ +int cg_parent_data_write(int fn, int B, int Z, int S, const cgsize_t * parent_data) { cgns_section *section; cgsize_t num; /* get file and check mode */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) @@ -6289,9 +7637,22 @@ int cg_parent_data_write(int file_number, int B, int Z, int S, return CG_OK; } - - -int cg_parent_data_partial_write(int file_number, int B, int Z, int S, +/** + * \ingroup ElementConnectivity + * + * \brief Write subset of parent info for an element section + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start Index of first element in the section. + * \param[in] end Index of last element in the section. + * \param[in] parent_data For boundary or interface elements, this array contains information on the cell(s) and cell face(s) sharing the element. If you do not need to read the ParentData when reading the ElementData, you may set the value to NULL. + * \return \ier + * + */ +int cg_parent_data_partial_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const cgsize_t *parent_data) { @@ -6299,7 +7660,7 @@ int cg_parent_data_partial_write(int file_number, int B, int Z, int S, cgsize_t size; /* get file and check mode */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -6414,11 +7775,23 @@ int cg_parent_data_partial_write(int file_number, int B, int Z, int S, * Read and Write FlowSolution_t Nodes \*****************************************************************************/ -int cg_nsols(int file_number, int B, int Z, int *nsols) +/** + * \ingroup FlowSolution + * + * \brief Get number of FlowSolution_t nodes + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] nsols Number of flow solutions for zone Z. + * \return \ier + * + */ +int cg_nsols(int fn, int B, int Z, int *nsols) { cgns_zone *zone; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -6430,12 +7803,26 @@ int cg_nsols(int file_number, int B, int Z, int *nsols) return CG_OK; } -int cg_sol_info(int file_number, int B, int Z, int S, char *solname, +/** + * \ingroup FlowSolution + * + * \brief Get information about a FlowSolution_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \SOL_S + * \param[out] solname Name of the flow solution. + * \param[out] location Grid location where the solution is recorded. The current admissible locations are Vertex, CellCenter, IFaceCenter, JFaceCenter, and KFaceCenter. + * \return \ier + * + */ +int cg_sol_info(int fn, int B, int Z, int S, char *solname, CGNS_ENUMT(GridLocation_t) *location) { cgns_sol *sol; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -6448,11 +7835,11 @@ int cg_sol_info(int file_number, int B, int Z, int S, char *solname, return CG_OK; } -int cg_sol_id(int file_number, int B, int Z, int S, double *sol_id) +int cg_sol_id(int fn, int B, int Z, int S, double *sol_id) { cgns_sol *sol; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -6464,7 +7851,21 @@ int cg_sol_id(int file_number, int B, int Z, int S, double *sol_id) return CG_OK; } -int cg_sol_write(int file_number, int B, int Z, const char * solname, +/** + * \ingroup FlowSolution + * + * \brief Create and/or write to a FlowSolution_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] solname Name of the flow solution. + * \param[in] location Grid location where the solution is recorded. The current admissible locations are Vertex, CellCenter, IFaceCenter, JFaceCenter, and KFaceCenter. + * \param[out] S \SOL_S + * \return \ier + * + */ +int cg_sol_write(int fn, int B, int Z, const char * solname, CGNS_ENUMT(GridLocation_t) location, int *S) { cgns_zone *zone; @@ -6487,7 +7888,7 @@ int cg_sol_write(int file_number, int B, int Z, const char * solname, } */ /* get memory address for FlowSolution node */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -6562,12 +7963,26 @@ int cg_sol_write(int file_number, int B, int Z, const char * solname, return CG_OK; } -int cg_sol_size(int file_number, int B, int Z, int S, +/** + * \ingroup FlowSolution + * + * \brief Get the dimensions of a FlowSolution_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \SOL_S + * \param[out] data_dim Number of dimensions defining the solution data. If a point set has been defined, this will be 1, otherwise this will be the current zone index dimension. + * \param[out] dim_vals The array of data_dim dimensions for the solution data. + * \return \ier + * + */ +int cg_sol_size(int fn, int B, int Z, int S, int *data_dim, cgsize_t *dim_vals) { cgns_sol *sol; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -6589,7 +8004,20 @@ int cg_sol_size(int file_number, int B, int Z, int S, } /*----------------------------------------------------------------------*/ - +/** + * \ingroup FlowSolution + * + * \brief Get info about a point set FlowSolution_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \SOL_S + * \param[out] ptset_type Type of point set defining the interface in the current solution; either PointRange or PointList. + * \param[out] npnts Number of points defining the interface in the current solution. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points in the PointList. + * \return \ier + * + */ int cg_sol_ptset_info(int fn, int B, int Z, int S, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts) { @@ -6613,6 +8041,19 @@ int cg_sol_ptset_info(int fn, int B, int Z, int S, return CG_OK; } +/** + * \ingroup FlowSolution + * + * \brief Read a point set FlowSolution_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \SOL_S + * \param[out] pnts Array of points defining the interface in the current solution. + * \return \ier + * + */ int cg_sol_ptset_read(int fn, int B, int Z, int S, cgsize_t *pnts) { int dim = 0; @@ -6636,6 +8077,23 @@ int cg_sol_ptset_read(int fn, int B, int Z, int S, cgsize_t *pnts) return CG_OK; } +/** + * \ingroup FlowSolution + * + * \brief Create a point set FlowSolution_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] solname Name of the flow solution. + * \param[in] location Grid location where the solution is recorded. The current admissible locations are Vertex, CellCenter, IFaceCenter, JFaceCenter, and KFaceCenter. + * \param[in] ptset_type Type of point set defining the interface in the current solution; either PointRange or PointList. + * \param[in] npnts Number of points defining the interface in the current solution. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points in the PointList. + * \param[in] pnts Array of points defining the interface in the current solution. + * \param[out] S \SOL_S + * \return \ier + * + */ int cg_sol_ptset_write(int fn, int B, int Z, const char *solname, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, @@ -6696,12 +8154,24 @@ int cg_sol_ptset_write(int fn, int B, int Z, const char *solname, /*****************************************************************************\ * Read and Write flow field DataArray_t Nodes \*****************************************************************************/ - -int cg_nfields(int file_number, int B, int Z, int S, int *nfields) +/** + * \ingroup FlowSolutionData + * + * \brief Get number of flow solution arrays + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \SOL_S + * \param[out] nfields Number of data arrays in flow solution S. + * \return \ier + * + */ +int cg_nfields(int fn, int B, int Z, int S, int *nfields) { cgns_sol *sol; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -6713,12 +8183,27 @@ int cg_nfields(int file_number, int B, int Z, int S, int *nfields) return CG_OK; } -int cg_field_info(int file_number, int B, int Z, int S, int F, - CGNS_ENUMT(DataType_t) *type, char *fieldname) +/** + * \ingroup FlowSolutionData + * + * \brief Get info about a flow solution array + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \SOL_S + * \param[in] F Solution array index number, where 1 ≤ F ≤ nfields. + * \param[out] datatype Data type of the solution array written to the file. Admissible data types for a solution array are Integer, LongInteger, RealSingle, and RealDouble. + * \param[out] fieldname Name of the solution array. It is strongly advised to use the SIDS nomenclature conventions when naming the solution arrays to insure file compatibility. + * \return \ier + * + */ +int cg_field_info(int fn, int B, int Z, int S, int F, + CGNS_ENUMT(DataType_t) *datatype, char *fieldname) { cgns_array *field; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -6727,20 +8212,37 @@ int cg_field_info(int file_number, int B, int Z, int S, int F, if (field==0) return CG_ERROR; strcpy(fieldname, field->name); - *type = cgi_datatype(field->data_type); + *datatype = cgi_datatype(field->data_type); return CG_OK; } -int cg_field_read(int file_number, int B, int Z, int S, const char *fieldname, - CGNS_ENUMT(DataType_t) type, const cgsize_t *s_rmin, +/** + * \ingroup FlowSolutionData + * + * \brief Read flow solution + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \SOL_S + * \param[in] fieldname Name of the solution array. It is strongly advised to use the SIDS nomenclature conventions when naming the solution arrays to insure file compatibility. + * \param[in] mem_datatype Data type of an array in memory. Admissible data types for a solution array are Integer, LongInteger, RealSingle, and RealDouble. + * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). + * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). + * \param[out] field_ptr Array of solution values. + * \return \ier + * + */ +int cg_field_read(int fn, int B, int Z, int S, const char *fieldname, + CGNS_ENUMT(DataType_t) mem_datatype, const cgsize_t *s_rmin, const cgsize_t *s_rmax, void *field_ptr) { cgns_sol *sol; int n, m_numdim; /* get memory addresses */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* get memory address for solution */ @@ -6767,12 +8269,33 @@ int cg_field_read(int file_number, int B, int Z, int S, const char *fieldname, m_dimvals[n] = m_rmax[n]; } - return cg_field_general_read(file_number, B, Z, S, fieldname, - s_rmin, s_rmax, type, + return cg_field_general_read(fn, B, Z, S, fieldname, + s_rmin, s_rmax, mem_datatype, m_numdim, m_dimvals, m_rmin, m_rmax, field_ptr); } +/** + * \ingroup FlowSolutionData + * + * \brief Read subset of flow solution to a shaped array + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \SOL_S + * \param[in] fieldname Name of the solution array. It is strongly advised to use the SIDS nomenclature conventions when naming the solution arrays to insure file compatibility. + * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). + * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). + * \param[in] m_type Data type of an array in memory. Admissible data types for a solution array are Integer, LongInteger, RealSingle, and RealDouble. + * \param[in] m_numdim Number of dimensions of array in memory. + * \param[in] m_dimvals Dimensions of array in memory. + * \param[in] m_rmin Lower range index in memory (eg., imin, jmin, kmin). + * \param[in] m_rmax Upper range index in memory (eg., imax, jmax, kmax). + * \param[out] field_ptr Array of solution values. + * \return \ier + * + */ int cg_field_general_read(int fn, int B, int Z, int S, const char *fieldname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, @@ -6826,11 +8349,11 @@ int cg_field_general_read(int fn, int B, int Z, int S, const char *fieldname, field_ptr); } -int cg_field_id(int file_number, int B, int Z, int S, int F, double *field_id) +int cg_field_id(int fn, int B, int Z, int S, int F, double *field_id) { cgns_array *field; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -6842,7 +8365,23 @@ int cg_field_id(int file_number, int B, int Z, int S, int F, double *field_id) return CG_OK; } -int cg_field_write(int file_number, int B, int Z, int S, +/** + * \ingroup FlowSolutionData + * + * \brief Write flow solution + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \SOL_S + * \param[in] fieldname Name of the solution array. It is strongly advised to use the SIDS nomenclature conventions when naming the solution arrays to insure file compatibility. + * \param[in] type Data type of the solution array written to the file. Admissible data types for a solution array are Integer, LongInteger, RealSingle, and RealDouble. + * \param[in] field_ptr Array of solution values. + * \param[out] F \SOL_F + * \return \ier + * + */ +int cg_field_write(int fn, int B, int Z, int S, CGNS_ENUMT(DataType_t) type, const char *fieldname, const void *field_ptr, int *F) { @@ -6862,7 +8401,7 @@ int cg_field_write(int file_number, int B, int Z, int S, } /* get memory addresses */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); @@ -6900,13 +8439,31 @@ int cg_field_write(int file_number, int B, int Z, int S, m_rmax[n] = m_dimvals[n]; } - return cg_field_general_write(file_number, B, Z, S, fieldname, + return cg_field_general_write(fn, B, Z, S, fieldname, type, s_rmin, s_rmax, type, m_numdim, m_dimvals, m_rmin, m_rmax, field_ptr, F); } -int cg_field_partial_write(int file_number, int B, int Z, int S, +/** + * \ingroup FlowSolutionData + * + * \brief Write subset of flow solution + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \SOL_S + * \param[in] fieldname Name of the solution array. It is strongly advised to use the SIDS nomenclature conventions when naming the solution arrays to insure file compatibility. + * \param[in] type Data type of the solution array written to the file. Admissible data types for a solution array are Integer, LongInteger, RealSingle, and RealDouble. + * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). + * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). + * \param[in] field_ptr Array of solution values. + * \param[out] F \SOL_F + * \return \ier + * + */ +int cg_field_partial_write(int fn, int B, int Z, int S, CGNS_ENUMT( DataType_t ) type, const char *fieldname, const cgsize_t *s_rmin, const cgsize_t *s_rmax, const void *field_ptr, int *F) @@ -6917,7 +8474,7 @@ int cg_field_partial_write(int file_number, int B, int Z, int S, int status; /* get memory addresses */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; zone = cgi_get_zone(cg, B, Z); @@ -6948,7 +8505,7 @@ int cg_field_partial_write(int file_number, int B, int Z, int S, m_dimvals[n] = m_rmax[n]; } - status = cg_field_general_write(file_number, B, Z, S, fieldname, + status = cg_field_general_write(fn, B, Z, S, fieldname, type, s_rmin, s_rmax, type, m_numdim, m_dimvals, m_rmin, m_rmax, field_ptr, F); @@ -6958,6 +8515,30 @@ int cg_field_partial_write(int file_number, int B, int Z, int S, } +/** + * \ingroup FlowSolutionData + * + * \brief Write shaped array to a subset of flow solution + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \SOL_S + * \param[in] fieldname Name of the solution array. It is strongly advised to use the SIDS nomenclature conventions when naming the solution arrays to insure file compatibility. + * \param[in] s_type Data type of the solution array written to the file. Admissible data types for a solution array are Integer, LongInteger, RealSingle, and RealDouble. + * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). + * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). + * + * \param[in] m_type Data type of an array in memory. Admissible data types for a solution array are Integer, LongInteger, RealSingle, and RealDouble. + * \param[in] m_numdim Number of dimensions of array in memory. + * \param[in] m_dimvals Dimensions of array in memory. + * \param[in] m_rmin Lower range index in memory (eg., imin, jmin, kmin). + * \param[in] m_rmax Upper range index in memory (eg., imax, jmax, kmax). + * \param[in] field_ptr Array of solution values. + * \param[out] F \SOL_F + * \return \ier + * + */ int cg_field_general_write(int fn, int B, int Z, int S, const char *fieldname, CGNS_ENUMT(DataType_t) s_type, const cgsize_t *s_rmin, const cgsize_t *s_rmax, @@ -7030,7 +8611,19 @@ int cg_field_general_write(int fn, int B, int Z, int S, const char *fieldname, * Read and write ZoneSubRegion_t Nodes * \*************************************************************************/ -int cg_nsubregs(int fn, int B, int Z, int *nsubreg) +/** + * \ingroup ZoneSubregions + * + * \brief Get number of ZoneSubRegion_t nodes + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] nsubregs Number of ZoneSubRegion_t nodes under Zone Z. + * \return \ier + * + */ +int cg_nsubregs(int fn, int B, int Z, int *nsubregs) { cgns_zone *zone; @@ -7042,7 +8635,7 @@ int cg_nsubregs(int fn, int B, int Z, int *nsubreg) zone = cgi_get_zone(cg, B, Z); if (zone==0) return CG_ERROR; - (*nsubreg) = zone->nsubreg; + (*nsubregs) = zone->nsubreg; return CG_OK; } @@ -7056,7 +8649,26 @@ static cgns_subreg *cg_subreg_read(int fn, int B, int Z, int S) return cgi_get_subreg(cg, B, Z, S); } -int cg_subreg_info(int fn, int B, int Z, int S, char *name, int *dimension, +/** + * \ingroup ZoneSubregions + * + * \brief Get info about a ZoneSubRegion_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. + * \param[out] regname Name of the ZoneSubRegion_t node. + * \param[out] dimension Dimensionality of the subregion, 1 for lines, 2 for faces, 3 for volumes. + * \param[out] location Grid location used in the definition of the point set. The currently admissible locations are Vertex and CellCenter. + * \param[out] ptset_type Type of point set defining the interface for the subregion data; either PointRange or PointList. + * \param[out] npnts Number of points defining the interface for the subregion data. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points in the PointList. + * \param[out] bcname_len String length of bcname. + * \param[out] gcname_len String length of gcname. + * \return \ier + * + */ +int cg_subreg_info(int fn, int B, int Z, int S, char *regname, int *dimension, CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, int *bcname_len, int *gcname_len) @@ -7065,7 +8677,7 @@ int cg_subreg_info(int fn, int B, int Z, int S, char *name, int *dimension, if (subreg == NULL) return CG_ERROR; - strcpy(name,subreg->name); + strcpy(regname,subreg->name); *dimension = subreg->reg_dim; *location = subreg->location; if (subreg->ptset) { @@ -7088,6 +8700,19 @@ int cg_subreg_info(int fn, int B, int Z, int S, char *name, int *dimension, return CG_OK; } +/** + * \ingroup ZoneSubregions + * + * \brief Read point set data for a ZoneSubRegion_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. + * \param[out] pnts Array of points defining the interface for the subregion data. + * \return \ier + * + */ int cg_subreg_ptset_read(int fn, int B, int Z, int S, cgsize_t *pnts) { int dim = 0; @@ -7105,6 +8730,19 @@ int cg_subreg_ptset_read(int fn, int B, int Z, int S, cgsize_t *pnts) return CG_OK; } +/** + * \ingroup ZoneSubregions + * + * \brief Read the BC_t node name for a ZoneSubRegion_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. + * \param[out] bcname The name of a BC_t node which defines the subregion. + * \return \ier + * + */ int cg_subreg_bcname_read(int fn, int B, int Z, int S, char *bcname) { cgns_subreg *subreg = cg_subreg_read(fn, B, Z, S); @@ -7119,6 +8757,19 @@ int cg_subreg_bcname_read(int fn, int B, int Z, int S, char *bcname) return CG_OK; } +/** + * \ingroup ZoneSubregions + * + * \brief Read the GridConnectivity_t node name for a ZoneSubRegion_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. + * \param[out] gcname The name of a GridConnectivity_t or GridConnectivity1to1_t node which defines the subregion. + * \return \ier + * + */ int cg_subreg_gcname_read(int fn, int B, int Z, int S, char *gcname) { cgns_subreg *subreg = cg_subreg_read(fn, B, Z, S); @@ -7198,7 +8849,25 @@ static cgns_subreg *cg_subreg_write(int fn, int B, int Z, const char *name, return subreg; } -int cg_subreg_ptset_write(int fn, int B, int Z, const char *name, +/** + * \ingroup ZoneSubregions + * + * \brief Create a point set ZoneSubRegion_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] regname Name of the ZoneSubRegion_t node. + * \param[in] dimension Dimensionality of the subregion, 1 for lines, 2 for faces, 3 for volumes. + * \param[in] location Grid location used in the definition of the point set. The currently admissible locations are Vertex and CellCenter. + * \param[in] ptset_type Type of point set defining the interface for the subregion data; either PointRange or PointList. + * \param[in] npnts Number of points defining the interface for the subregion data. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points in the PointList. + * \param[in] pnts Array of points defining the interface for the subregion data. + * \param[out] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. + * \return \ier + * + */ +int cg_subreg_ptset_write(int fn, int B, int Z, const char *regname, int dimension, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t *pnts, int *S) @@ -7221,7 +8890,7 @@ int cg_subreg_ptset_write(int fn, int B, int Z, const char *name, if (cgi_check_location(dimension+1, cg->base[B-1].zone[Z-1].type, location)) return CG_ERROR; - subreg = cg_subreg_write(fn, B, Z, name, dimension, S); + subreg = cg_subreg_write(fn, B, Z, regname, dimension, S); if (subreg == NULL) return CG_ERROR; subreg->location = location; @@ -7261,7 +8930,22 @@ int cg_subreg_ptset_write(int fn, int B, int Z, const char *name, return CG_OK; } -int cg_subreg_bcname_write(int fn, int B, int Z, const char *name, int dimension, +/** + * \ingroup ZoneSubregions + * + * \brief Create a ZoneSubRegion_t node that references a BC_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] regname Name of the ZoneSubRegion_t node. + * \param[in] dimension Dimensionality of the subregion, 1 for lines, 2 for faces, 3 for volumes. + * \param[in] bcname The name of a BC_t node which defines the subregion. + * \param[out] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. + * \return \ier + * + */ +int cg_subreg_bcname_write(int fn, int B, int Z, const char *regname, int dimension, const char *bcname, int *S) { cgsize_t dim_vals = 1; @@ -7273,7 +8957,7 @@ int cg_subreg_bcname_write(int fn, int B, int Z, const char *name, int dimension return CG_ERROR; } - subreg = cg_subreg_write(fn, B, Z, name, dimension, S); + subreg = cg_subreg_write(fn, B, Z, regname, dimension, S); if (subreg == NULL) return CG_ERROR; subreg->bcname = CGNS_NEW(cgns_descr, 1); @@ -7296,7 +8980,22 @@ int cg_subreg_bcname_write(int fn, int B, int Z, const char *name, int dimension return CG_OK; } -int cg_subreg_gcname_write(int fn, int B, int Z, const char *name, int dimension, +/** + * \ingroup ZoneSubregions + * + * \brief Create a ZoneSubRegion_t node that references a GridConnectivity_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] regname Name of the ZoneSubRegion_t node. + * \param[in] dimension Dimensionality of the subregion, 1 for lines, 2 for faces, 3 for volumes. + * \param[in] gcname The name of a GridConnectivity_t or GridConnectivity1to1_t node which defines the subregion. + * \param[out] S ZoneSubRegion index number, where 1 ≤ S ≤ nsubregs. + * \return \ier + * + */ +int cg_subreg_gcname_write(int fn, int B, int Z, const char *regname, int dimension, const char *gcname, int *S) { cgsize_t dim_vals = 1; @@ -7308,7 +9007,7 @@ int cg_subreg_gcname_write(int fn, int B, int Z, const char *name, int dimension return CG_ERROR; } - subreg = cg_subreg_write(fn, B, Z, name, dimension, S); + subreg = cg_subreg_write(fn, B, Z, regname, dimension, S); if (subreg == NULL) return CG_ERROR; subreg->gcname = CGNS_NEW(cgns_descr, 1); @@ -7335,6 +9034,18 @@ int cg_subreg_gcname_write(int fn, int B, int Z, const char *name, int dimension * Read and write ZoneGridConnectivity_t Nodes * \*************************************************************************/ +/** + * \ingroup ZoneGridConnectivity + * + * \brief Get number of ZoneGridConnectivity_t nodes + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] nzconns Number of ZoneGridConnectivity_t nodes under Zone Z. + * \return \ier + * + */ int cg_nzconns(int fn, int B, int Z, int *nzconns) { cgns_zone *zone; @@ -7352,7 +9063,20 @@ int cg_nzconns(int fn, int B, int Z, int *nzconns) return CG_OK; } -int cg_zconn_read(int fn, int B, int Z, int C, char *name) +/** + * \ingroup ZoneGridConnectivity + * + * \brief Read ZoneGridConnectivity_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] ZC Zone grid connectivity index number, where 1 ≤ ZC ≤ nzconns. + * \param[out] zcname Name of the ZoneGridConnectivity_t node + * \return \ier + * + */ +int cg_zconn_read(int fn, int B, int Z, int ZC, char *zcname) { cgns_zconn *zconn; @@ -7363,22 +9087,35 @@ int cg_zconn_read(int fn, int B, int Z, int C, char *name) /* Get memory address for ZoneGridConnectivity_t node */ /* cgi_get_zconnZC() also sets active ZoneGridConnectivity_t node */ - zconn = cgi_get_zconnZC(cg, B, Z, C); + zconn = cgi_get_zconnZC(cg, B, Z, ZC); if (zconn==0) return CG_ERROR; /* Return name for the ZoneGridConnectivity_t node */ - strcpy(name,zconn->name); + strcpy(zcname,zconn->name); return CG_OK; } -int cg_zconn_write(int fn, int B, int Z, const char *name, int *C) +/** + * \ingroup ZoneGridConnectivity + * + * \brief Create ZoneGridConnectivity_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] zcname Name of the ZoneGridConnectivity_t node + * \param[out] ZC Zone grid connectivity index number, where 1 ≤ ZC ≤ nzconns. + * \return \ier + * + */ +int cg_zconn_write(int fn, int B, int Z, const char *zcname, int *ZC) { cgns_zone *zone; cgns_zconn *zconn = NULL; int index; /* verify input */ - if (cgi_check_strlen(name)) return CG_ERROR; + if (cgi_check_strlen(zcname)) return CG_ERROR; /* get memory address */ cg = cgi_get_file(fn); @@ -7391,11 +9128,11 @@ int cg_zconn_write(int fn, int B, int Z, const char *name, int *C) /* Overwrite a ZoneGridConnectivity_t Node: */ for (index = 0; index < zone->nzconn; index++) { - if (0 == strcmp(name, zone->zconn[index].name)) { + if (0 == strcmp(zcname, zone->zconn[index].name)) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode == CG_MODE_WRITE) { - cgi_error("Duplicate child name found: %s",name); + cgi_error("Duplicate child name found: %s",zcname); return CG_ERROR; } @@ -7421,11 +9158,11 @@ int cg_zconn_write(int fn, int B, int Z, const char *name, int *C) zconn = &(zone->zconn[zone->nzconn]); zone->nzconn++; } - (*C) = index+1; - zone->active_zconn = *C; + (*ZC) = index+1; + zone->active_zconn = *ZC; memset(zconn, 0, sizeof(cgns_zconn)); - strcpy(zconn->name,name); + strcpy(zconn->name,zcname); /* save data in file */ if (cgi_new_node(zone->id, zconn->name, "ZoneGridConnectivity_t", @@ -7434,7 +9171,19 @@ int cg_zconn_write(int fn, int B, int Z, const char *name, int *C) return CG_OK; } -int cg_zconn_get(int fn, int B, int Z, int *C) +/** + * \ingroup ZoneGridConnectivity + * + * \brief Get the current ZoneGridConnectivity_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] ZC Zone grid connectivity index number, where 1 ≤ ZC ≤ nzconns. + * \return \ier + * + */ +int cg_zconn_get(int fn, int B, int Z, int *ZC) { cgns_zone *zone; @@ -7446,18 +9195,30 @@ int cg_zconn_get(int fn, int B, int Z, int *C) if (zone==0) return CG_ERROR; if (zone->nzconn <= 0) { - *C = 0; + *ZC = 0; cgi_error("no ZoneGridConnectivity_t node found."); return CG_NODE_NOT_FOUND; } if (zone->active_zconn <= 0 || zone->active_zconn > zone->nzconn) zone->active_zconn = 1; - *C = zone->active_zconn; + *ZC = zone->active_zconn; return CG_OK; } -int cg_zconn_set(int fn, int B, int Z, int C) +/** + * \ingroup ZoneGridConnectivity + * + * \brief Set the current ZoneGridConnectivity_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] ZC Zone grid connectivity index number, where 1 ≤ ZC ≤ nzconns. + * \return \ier + * + */ +int cg_zconn_set(int fn, int B, int Z, int ZC) { cgns_zconn *zconn; @@ -7466,7 +9227,7 @@ int cg_zconn_set(int fn, int B, int Z, int C) /* Get memory address for ZoneGridConnectivity_t node */ /* cgi_get_zconnZC() also sets active ZoneGridConnectivity_t node */ - zconn = cgi_get_zconnZC(cg, B, Z, C); + zconn = cgi_get_zconnZC(cg, B, Z, ZC); if (zconn==0) return CG_ERROR; return CG_OK; } @@ -7475,11 +9236,23 @@ int cg_zconn_set(int fn, int B, int Z, int C) * Read and Write OversetHoles_t Nodes \*****************************************************************************/ -int cg_nholes(int file_number, int B, int Z, int *nholes) +/** + * \ingroup OversetHoles + * + * \brief Get number of overset holes in a zone + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] nholes Number of overset holes in zone Z. + * \return \ier + * + */ +int cg_nholes(int fn, int B, int Z, int *nholes) { cgns_zconn *zconn; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -7490,14 +9263,31 @@ int cg_nholes(int file_number, int B, int Z, int *nholes) return CG_OK; } -int cg_hole_info(int file_number, int B, int Z, int J, char *holename, +/** + * \ingroup OversetHoles + * + * \brief Get info about an overset hole + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Overset hole index number, where 1 ≤ J ≤ nholes. + * \param[out] holename Name of the overset hole. + * \param[out] location Grid location used in the definition of the point set. The currently admissible locations are Vertex and CellCenter. + * \param[out] ptset_type The extent of the overset hole may be defined using a range of points or cells, or using a discrete list of all points or cells in the overset hole. If a range of points or cells is used, ptset_type is set to PointRange. When a discrete list of points or cells is used, ptset_type equals PointList. + * \param[out] nptsets Number of point sets used to define the hole. If ptset_type is PointRange, several point sets may be used. If ptset_type is PointList, only one point set is allowed. + * \param[out] npnts Number of points (or cells) in the point set. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points or cells in the PointList. + * \return \ier + * + */ +int cg_hole_info(int fn, int B, int Z, int J, char *holename, CGNS_ENUMT(GridLocation_t) *location, CGNS_ENUMT(PointSetType_t) *ptset_type, int *nptsets, cgsize_t *npnts) { cgns_hole *hole; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -7515,12 +9305,25 @@ int cg_hole_info(int file_number, int B, int Z, int J, char *holename, return CG_OK; } -int cg_hole_read(int file_number, int B, int Z, int J, cgsize_t *pnts) +/** + * \ingroup OversetHoles + * + * \brief Read overset hole data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Overset hole index number, where 1 ≤ J ≤ nholes. + * \param[out] pnts Array of points or cells in the point set. + * \return \ier + * + */ +int cg_hole_read(int fn, int B, int Z, int J, cgsize_t *pnts) { cgns_hole *hole; int set, index_dim; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -7561,11 +9364,11 @@ int cg_hole_read(int file_number, int B, int Z, int J, cgsize_t *pnts) return CG_OK; } -int cg_hole_id(int file_number, int B, int Z, int J, double *hole_id) +int cg_hole_id(int fn, int B, int Z, int J, double *hole_id) { cgns_hole *hole; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -7577,7 +9380,25 @@ int cg_hole_id(int file_number, int B, int Z, int J, double *hole_id) return CG_OK; } -int cg_hole_write(int file_number, int B, int Z, const char * holename, +/** + * \ingroup OversetHoles + * + * \brief Write overset hole data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] holename Name of the overset hole. + * \param[in] location Grid location used in the definition of the point set. The currently admissible locations are Vertex and CellCenter. + * \param[in] ptset_type The extent of the overset hole may be defined using a range of points or cells, or using a discrete list of all points or cells in the overset hole. If a range of points or cells is used, ptset_type is set to PointRange. When a discrete list of points or cells is used, ptset_type equals PointList. + * \param[in] nptsets Number of point sets used to define the hole. If ptset_type is PointRange, several point sets may be used. If ptset_type is PointList, only one point set is allowed. + * \param[in] npnts Number of points (or cells) in the point set. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points or cells in the PointList. + * \param[in] pnts Array of points or cells in the point set. + * \param[out] J Overset hole index number, where 1 ≤ J ≤ nholes. + * \return \ier + * + */ +int cg_hole_write(int fn, int B, int Z, const char * holename, CGNS_ENUMT(GridLocation_t) location, CGNS_ENUMT(PointSetType_t) ptset_type, int nptsets, cgsize_t npnts, const cgsize_t * pnts, int *J) @@ -7611,7 +9432,7 @@ int cg_hole_write(int file_number, int B, int Z, const char * holename, return CG_ERROR; } /* get memory address for file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -7740,11 +9561,23 @@ int cg_hole_write(int file_number, int B, int Z, const char * holename, * Read and Write GridConnectivity_t Nodes \*****************************************************************************/ -int cg_nconns(int file_number, int B, int Z, int *nconns) +/** + * \ingroup GeneralizedConnectivity + * + * \brief Get number of generalized connectivity interfaces in a zone + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] nconns Number of interfaces for zone Z. + * \return \ier + * + */ +int cg_nconns(int fn, int B, int Z, int *nconns) { cgns_zconn *zconn; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -7755,21 +9588,46 @@ int cg_nconns(int file_number, int B, int Z, int *nconns) return CG_OK; } -/* in cg_conn_info, donor_datatype is useless starting with version 1.27, because - it's always I4. However this arg. is left for backward compatibility of API - and to be able to read old files */ -int cg_conn_info(int file_number, int B, int Z, int J, char *connectname, +/** + * \ingroup GeneralizedConnectivity + * + * \brief Get info about a generalized connectivity interface + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Interface index number, where 1 ≤ J ≤ nconns. + * \param[out] connectname Name of the interface. + * \param[out] location Grid location used in the definition of the point set. The currently admissible locations are Vertex and CellCenter. + * \param[out] connect_type Type of interface being defined. The admissible types are Overset, Abutting, and Abutting1to1. + * \param[out] ptset_type Type of point set defining the interface in the current zone; either PointRange or PointList. + * \param[out] npnts Number of points defining the interface in the current zone. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points in the PointList. + * \param[out] donorname Name of the zone interfacing with the current zone. + * \param[out] donor_zonetype Type of the donor zone. The admissible types are Structured and Unstructured. + * \param[out] donor_ptset_type Type of point set defining the interface in the donor zone; either PointListDonor or CellListDonor. + * \param[out] donor_datatype Data type in which the donor points are stored in the file. As of Version 3.0, this value is ignored when writing, and on reading it will return either Integer or LongInteger depending on whether the file was written using 32 or 64-bit. The donor_datatype argument was left in these functions only for backward compatibility. The donor data is always read as cgsize_t. + * \param[out] ndata_donor Number of points or cells in the current zone. These are paired with points, cells, or fractions thereof in the donor zone. + * \return \ier + * + * \details In cg_conn_info, donor_datatype is useless starting with version 1.27, because + * it's always I4. However this arg. is left for backward compatibility of API + * and to be able to read old files + * + */ +int cg_conn_info(int fn, int B, int Z, int J, char *connectname, CGNS_ENUMT(GridLocation_t) *location, - CGNS_ENUMT(GridConnectivityType_t) *type, + CGNS_ENUMT(GridConnectivityType_t) *connect_type, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, char *donorname, CGNS_ENUMT(ZoneType_t) *donor_zonetype, CGNS_ENUMT(PointSetType_t) *donor_ptset_type, CGNS_ENUMT(DataType_t) *donor_datatype, cgsize_t *ndata_donor) { - int dZ; + int dZ, dB; cgns_conn *conn; + char_33 basedonorname, zonedonorname; + char *separator; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -7778,7 +9636,7 @@ int cg_conn_info(int file_number, int B, int Z, int J, char *connectname, if (conn==0) return CG_ERROR; strcpy(connectname, conn->name); - *type = conn->type; + *connect_type = conn->type; *location = conn->location; *ptset_type = conn->ptset.type; *npnts = conn->ptset.npts; @@ -7789,12 +9647,34 @@ int cg_conn_info(int file_number, int B, int Z, int J, char *connectname, *ndata_donor = conn->dptset.npts; *donor_ptset_type = conn->dptset.type; + /* Split donorname into BaseName + zoneName */ + separator = strchr(donorname, '/'); + if (separator != NULL) { + /* get ending zoneName */ + strcpy(zonedonorname, separator + sizeof(char)); + /* get base but do not use path syntax */ + memcpy(basedonorname, donorname, (separator - donorname)*sizeof(char)); + basedonorname[separator - donorname] = '\0'; + /* Find donor base index */ + for (dB=0;dBnbases; dB++) { + if (strcmp(cg->base[dB].name,basedonorname)==0) { + break; + } + } + } + else { + /* zoneName is in current base */ + strcpy(basedonorname, cg->base[B-1].name); + strcpy(zonedonorname, donorname); + dB = B-1; + } + /* Find ZoneType_t of DonorZone given its name */ *donor_zonetype = CGNS_ENUMV( ZoneTypeNull ); - for (dZ=0; dZbase[B-1].nzones; dZ++) { - if (strcmp(cg->base[B-1].zone[dZ].name,donorname)==0) { - *donor_zonetype = cg->base[B-1].zone[dZ].type; + for (dZ=0; dZbase[dB].nzones; dZ++) { + if (strcmp(cg->base[dB].zone[dZ].name,zonedonorname)==0) { + *donor_zonetype = cg->base[dB].zone[dZ].type; break; } } @@ -7805,10 +9685,25 @@ int cg_conn_info(int file_number, int B, int Z, int J, char *connectname, return CG_OK; } -/* in cg_conn_read, donor_datatype is useless starting with version 1.27, because - it's always I4. However this arg. is left for backward compatibility of API - and to be able to read old files */ -int cg_conn_read(int file_number, int B, int Z, int J, cgsize_t *pnts, +/** + * \ingroup GeneralizedConnectivity + * + * \brief Read generalized connectivity data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Interface index number, where 1 ≤ J ≤ nconns. + * \param[out] pnts Array of points defining the interface in the current zone. + * \param[out] donor_datatype Data type in which the donor points are stored in the file. As of Version 3.0, this value is ignored when writing, and on reading it will return either Integer or LongInteger depending on whether the file was written using 32 or 64-bit. The donor_datatype argument was left in these functions only for backward compatibility. The donor data is always read as cgsize_t. + * \param[out] donor_data Array of donor points or cells corresponding to ndata_donor. Note that it is possible that the same donor point or cell may be used multiple times. + * \return \ier + * + * \details in cg_conn_read, donor_datatype is useless starting with version 1.27, because + * it's always I4. However this arg. is left for backward compatibility of API + * and to be able to read old files + */ +int cg_conn_read(int fn, int B, int Z, int J, cgsize_t *pnts, CGNS_ENUMT(DataType_t) donor_datatype, cgsize_t *donor_data) { cgns_conn *conn; @@ -7824,7 +9719,7 @@ int cg_conn_read(int file_number, int B, int Z, int J, cgsize_t *pnts, #endif /* Find address */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -7872,16 +9767,29 @@ int cg_conn_read(int file_number, int B, int Z, int J, cgsize_t *pnts, return CG_OK; } -int cg_conn_read_short(int file_number, int B, int Z, int J, cgsize_t *pnts) +/** + * \ingroup GeneralizedConnectivity + * + * \brief Read generalized connectivity data without donor information + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Interface index number, where 1 ≤ J ≤ nconns. + * \param[out] pnts Array of points defining the interface in the current zone. + * \return \ier + * + */ +int cg_conn_read_short(int fn, int B, int Z, int J, cgsize_t *pnts) { - return cg_conn_read(file_number, B, Z, J, pnts, CGNS_ENUMV(DataTypeNull), NULL); + return cg_conn_read(fn, B, Z, J, pnts, CGNS_ENUMV(DataTypeNull), NULL); } -int cg_conn_id(int file_number, int B, int Z, int J, double *conn_id) +int cg_conn_id(int fn, int B, int Z, int J, double *conn_id) { cgns_conn *conn; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -7893,9 +9801,33 @@ int cg_conn_id(int file_number, int B, int Z, int J, double *conn_id) return CG_OK; } -int cg_conn_write(int file_number, int B, int Z, const char * connectname, +/** + * \ingroup GeneralizedConnectivity + * + * \brief Write generalized connectivity data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] connectname Name of the interface. + * \param[in] location Grid location used in the definition of the point set. The currently admissible locations are Vertex and CellCenter. + * \param[in] connect_type Type of interface being defined. The admissible types are Overset, Abutting, and Abutting1to1. + * \param[in] ptset_type Type of point set defining the interface in the current zone; either PointRange or PointList. + * \param[in] npnts Number of points defining the interface in the current zone. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points in the PointList. + * \param[in] pnts Array of points defining the interface in the current zone. + * \param[in] donorname Name of the zone interfacing with the current zone. + * \param[in] donor_zonetype Type of the donor zone. The admissible types are Structured and Unstructured. + * \param[in] donor_ptset_type Type of point set defining the interface in the donor zone; either PointListDonor or CellListDonor. + * \param[in] donor_datatype Data type in which the donor points are stored in the file. As of Version 3.0, this value is ignored when writing, and on reading it will return either Integer or LongInteger depending on whether the file was written using 32 or 64-bit. The donor_datatype argument was left in these functions only for backward compatibility. The donor data is always read as cgsize_t. + * \param[in] ndata_donor Number of points or cells in the current zone. These are paired with points, cells, or fractions thereof in the donor zone. + * \param[in] donor_data Array of donor points or cells corresponding to ndata_donor. Note that it is possible that the same donor point or cell may be used multiple times. + * \param[out] J Interface index number, where 1 ≤ J ≤ nconns. + * \return \ier + * + */ +int cg_conn_write(int fn, int B, int Z, const char * connectname, CGNS_ENUMT(GridLocation_t) location, - CGNS_ENUMT(GridConnectivityType_t) type, + CGNS_ENUMT(GridConnectivityType_t) connect_type, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t * pnts, const char * donorname, CGNS_ENUMT(ZoneType_t) donor_zonetype, @@ -7917,8 +9849,8 @@ int cg_conn_write(int file_number, int B, int Z, const char * connectname, /* verify input */ if (cgi_check_strlen(connectname)) return CG_ERROR; if (cgi_check_strlen(donorname)) return CG_ERROR; - if (INVALID_ENUM(type,NofValidGridConnectivityTypes)) { - cgi_error("Invalid input: GridConnectivityType=%d ?",type); + if (INVALID_ENUM(connect_type,NofValidGridConnectivityTypes)) { + cgi_error("Invalid input: GridConnectivityType=%d ?",connect_type); return CG_ERROR; } if (location != CGNS_ENUMV(Vertex) && @@ -7930,7 +9862,7 @@ int cg_conn_write(int file_number, int B, int Z, const char * connectname, cgi_error("Invalid input: GridLocation=%d ?",location); return CG_ERROR; } - if (type == CGNS_ENUMV(Overset) && + if (connect_type == CGNS_ENUMV(Overset) && location != CGNS_ENUMV(Vertex) && location != CGNS_ENUMV(CellCenter)) { cgi_error("GridLocation must be Vertex or CellCenter for Overset"); @@ -7986,7 +9918,7 @@ int cg_conn_write(int file_number, int B, int Z, const char * connectname, } /* get memory address of file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -8060,7 +9992,7 @@ int cg_conn_write(int file_number, int B, int Z, const char * connectname, } } else PointListSize=npnts; - if (ndata_donor && type == CGNS_ENUMV(Abutting1to1) && PointListSize != ndata_donor) { + if (ndata_donor && connect_type == CGNS_ENUMV(Abutting1to1) && PointListSize != ndata_donor) { cgi_error("Invalid input for ndata_donor in cg_conn_write"); return CG_ERROR; } @@ -8100,7 +10032,7 @@ int cg_conn_write(int file_number, int B, int Z, const char * connectname, /* write conn info to internal memory */ memset(conn, 0, sizeof(cgns_conn)); strcpy(conn->name,connectname); - conn->type = type; + conn->type = connect_type; conn->location = location; conn->ptset.id = 0; conn->ptset.link = 0; @@ -8180,15 +10112,34 @@ int cg_conn_write(int file_number, int B, int Z, const char * connectname, return CG_OK; } -int cg_conn_write_short(int file_number, int B, int Z, const char * connectname, +/** + * \ingroup GeneralizedConnectivity + * + * \brief Write generalized connectivity data without donor information + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] connectname Name of the interface. + * \param[in] location Grid location used in the definition of the point set. The currently admissible locations are Vertex and CellCenter. + * \param[in] connect_type Type of interface being defined. The admissible types are Overset, Abutting, and Abutting1to1. + * \param[in] ptset_type Type of point set defining the interface in the current zone; either PointRange or PointList. + * \param[in] npnts Number of points defining the interface in the current zone. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points in the PointList. + * \param[in] pnts Array of points defining the interface in the current zone. + * \param[in] donorname Name of the zone interfacing with the current zone. + * \param[out] J Interface index number, where 1 ≤ J ≤ nconns. + * \return \ier + * + */ +int cg_conn_write_short(int fn, int B, int Z, const char * connectname, CGNS_ENUMT(GridLocation_t) location, - CGNS_ENUMT(GridConnectivityType_t) type, + CGNS_ENUMT(GridConnectivityType_t) connect_type, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t * pnts, const char * donorname, int *J) { - return cg_conn_write (file_number, B, Z, connectname, location, - type, ptset_type, npnts, pnts, donorname, + return cg_conn_write (fn, B, Z, connectname, location, + connect_type, ptset_type, npnts, pnts, donorname, CGNS_ENUMV(ZoneTypeNull), CGNS_ENUMV(PointSetTypeNull), CGNS_ENUMV(DataTypeNull), 0, NULL, J); } @@ -8197,11 +10148,23 @@ int cg_conn_write_short(int file_number, int B, int Z, const char * connectname * Read and write GridConnectivity1to1_t Nodes \*****************************************************************************/ -int cg_n1to1(int file_number, int B, int Z, int *n1to1) +/** + * \ingroup OneToOneConnectivity + * + * \brief Get number of 1-to-1 interfaces in a zone + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] n1to1 Number of one-to-one interfaces in zone Z, stored under GridConnectivity1to1_t nodes. (I.e., this does not include one-to-one interfaces that may be stored under GridConnectivity_t nodes, used for generalized zone interfaces.) + * \return \ier + * + */ +int cg_n1to1(int fn, int B, int Z, int *n1to1) { cgns_zconn *zconn; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -8212,7 +10175,18 @@ int cg_n1to1(int file_number, int B, int Z, int *n1to1) return CG_OK; } -int cg_n1to1_global(int file_number, int B, int *n1to1_global) +/** + * \ingroup OneToOneConnectivity + * + * \brief Get total number of 1-to-1 interfaces in a database + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] n1to1_global Total number of one-to-one interfaces in base B, stored under GridConnectivity1to1_t nodes. (I.e., this does not include one-to-one interfaces that may be stored under GridConnectivity_t nodes, used for generalized zone interfaces.) Note that the function cg_n1to1 (described below) may be used to get the number of one-to-one interfaces in a specific zone. + * \return \ier + * + */ +int cg_n1to1_global(int fn, int B, int *n1to1_global) { cgns_base *base; cgns_zone *zone; @@ -8227,7 +10201,7 @@ int cg_n1to1_global(int file_number, int B, int *n1to1_global) cgsize6_t *Drange = 0, *Ddonor_range = 0; int index_dim; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -8244,7 +10218,7 @@ int cg_n1to1_global(int file_number, int B, int *n1to1_global) if (zconn==0) continue; /* if ZoneGridConnectivity_t is undefined */ if (zconn->n1to1 ==0) continue; for (J=1; J<=zconn->n1to1; J++) { - if (cg_1to1_read(file_number, B, Z, J, connectname, donorname, + if (cg_1to1_read(fn, B, Z, J, connectname, donorname, range, donor_range, transform)) return CG_ERROR; if (cgi_zone_no(base, donorname, &D)) return CG_ERROR; @@ -8268,7 +10242,24 @@ int cg_n1to1_global(int file_number, int B, int *n1to1_global) return CG_OK; } -int cg_1to1_read(int file_number, int B, int Z, int J, char *connectname, +/** + * \ingroup OneToOneConnectivity + * + * \brief Read 1-to-1 connectivity data for a zone + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Interface index number, where 1 ≤ J ≤ n1to1. + * \param[out] connectname Name of the interface. + * \param[out] donorname Name of the zone interfacing with the current zone. + * \param[out] range Range of points for the current zone. + * \param[out] donor_range Range of points for the donor zone. + * \param[out] transform Short hand notation for the transformation matrix defining the relative orientation of the two zones. + * \return \ier + * + */ +int cg_1to1_read(int fn, int B, int Z, int J, char *connectname, char *donorname, cgsize_t *range, cgsize_t *donor_range, int *transform) { @@ -8280,7 +10271,7 @@ int cg_1to1_read(int file_number, int B, int Z, int J, char *connectname, in 3D, range[0], range[1], range[2] = imin, jmin, kmin range[3], range[4], range[5] = imax, jmax, kmax */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -8315,7 +10306,23 @@ int cg_1to1_read(int file_number, int B, int Z, int J, char *connectname, return CG_OK; } -int cg_1to1_read_global(int file_number, int B, char **connectname, char **zonename, +/** + * \ingroup OneToOneConnectivity + * + * \brief Read data for all 1-to-1 interfaces in a database + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[out] connectname Name of the interface. + * \param[out] zonename Name of the first zone, for all one-to-one interfaces in base B. + * \param[out] donorname Name of the second zone, for all one-to-one interfaces in base B. + * \param[out] range Range of points for the first zone, for all one-to-one interfaces in base B. + * \param[out] donor_range Range of points for the current zone, for all one-to-one interfaces in base B. + * \param[out] transform Short hand notation for the transformation matrix defining the relative orientation of the two zones. This transformation is given for all one-to-one interfaces in base B. + * \return \ier + * + */ +int cg_1to1_read_global(int fn, int B, char **connectname, char **zonename, char **donorname, cgsize_t **range, cgsize_t **donor_range, int **transform) { @@ -8331,7 +10338,7 @@ int cg_1to1_read_global(int file_number, int B, char **connectname, char **zonen char_33 *Dzonename = 0; cgsize6_t *Drange = 0, *Ddonor_range = 0; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -8350,7 +10357,7 @@ int cg_1to1_read_global(int file_number, int B, char **connectname, char **zonen if (zconn==0) continue; /* if ZoneGridConnectivity_t is undefined */ if (zconn->n1to1 ==0) continue; for (J=1; J<=zconn->n1to1; J++) { - if (cg_1to1_read(file_number, B, Z, J, connect, donor, rang, + if (cg_1to1_read(fn, B, Z, J, connect, donor, rang, drang, trans)) return CG_ERROR; if (cgi_zone_no(base, donor, &D)) return CG_ERROR; /* count each interface only once */ @@ -8376,11 +10383,11 @@ int cg_1to1_read_global(int file_number, int B, char **connectname, char **zonen return CG_OK; } -int cg_1to1_id(int file_number, int B, int Z, int J, double *one21_id) +int cg_1to1_id(int fn, int B, int Z, int J, double *one21_id) { cgns_1to1 *one21; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -8392,7 +10399,24 @@ int cg_1to1_id(int file_number, int B, int Z, int J, double *one21_id) return CG_OK; } -int cg_1to1_write(int file_number, int B, int Z, const char * connectname, +/** + * \ingroup OneToOneConnectivity + * + * \brief Write 1-to-1 connectivity data for a zone + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] connectname Name of the interface. + * \param[in] donorname Name of the zone interfacing with the current zone. + * \param[in] range Range of points for the current zone. + * \param[in] donor_range Range of points for the donor zone. + * \param[in] transform Short hand notation for the transformation matrix defining the relative orientation of the two zones. + * \param[out] J Interface index number, where 1 ≤ J ≤ n1to1. + * \return \ier + * + */ +int cg_1to1_write(int fn, int B, int Z, const char * connectname, const char * donorname, const cgsize_t * range, const cgsize_t * donor_range, const int * transform, int *J) { @@ -8412,7 +10436,7 @@ int cg_1to1_write(int file_number, int B, int Z, const char * connectname, #endif /* get memory address of file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -8554,12 +10578,23 @@ int cg_1to1_write(int file_number, int B, int Z, const char * connectname, /*****************************************************************************\ * Read and write BC_t Nodes \*****************************************************************************/ - -int cg_nbocos(int file_number, int B, int Z, int *nbocos) +/** + * \ingroup BoundaryConditionType + * + * \brief Get number of boundary condition in zone + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] nbocos Number of boundary conditions in zone Z. + * \return \ier + * + */ +int cg_nbocos(int fn, int B, int Z, int *nbocos) { cgns_zboco *zboco; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -8570,7 +10605,27 @@ int cg_nbocos(int file_number, int B, int Z, int *nbocos) return CG_OK; } -int cg_boco_info(int file_number, int B, int Z, int BC, char *boconame, +/** + * \ingroup BoundaryConditionType + * + * \brief Get boundary condition info + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \param[out] boconame Name of the boundary condition. + * \param[out] bocotype Type of boundary condition defined. See the eligible types for BCType_t in the Typedefs section. Note that if bocotype is FamilySpecified the boundary condition type is being specified for the family to which the boundary belongs. The boundary condition type for the family may be read and written using cg_fambc_read and cg_fambc_write. + * \param[out] ptset_type The extent of the boundary condition may be defined using a range of points or elements using PointRange, or using a discrete list of all points or elements at which the boundary condition is applied using PointList. When the boundary condition is to be applied anywhere other than points, then GridLocation_t under the BC_t node must be used to indicate this. The value of GridLocation_t may be read or written by cg_boco_gridlocation_read and cg_boco_gridlocation_write. As in previous versions of the library, this may also be done by first using cg_goto to access the BC_t node, then using cg_gridlocation_read or cg_gridlocation_write. + * \param[out] npnts Number of points or elements defining the boundary condition region. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points or elements in the list. + * \param[out] NormalIndex Index vector indicating the computational coordinate direction of the boundary condition patch normal. + * \param[out] NormalListSize If the normals are defined in NormalList, NormalListSize is the number of points in the patch times phys_dim, the number of coordinates required to define a vector in the field. If the normals are not defined in NormalList, NormalListSize is 0. + * \param[out] NormalDataType Data type used in the definition of the normals. Admissible data types for the normals are RealSingle and RealDouble. + * \param[out] ndataset Number of boundary condition datasets for the current boundary condition. + * \return \ier + * + */ +int cg_boco_info(int fn, int B, int Z, int BC, char *boconame, CGNS_ENUMT(BCType_t) *bocotype, CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts, int *NormalIndex, cgsize_t *NormalListSize, CGNS_ENUMT(DataType_t) *NormalDataType, int *ndataset) @@ -8578,7 +10633,7 @@ int cg_boco_info(int file_number, int B, int Z, int BC, char *boconame, cgns_boco *boco; int n, index_dim; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -8619,12 +10674,26 @@ int cg_boco_info(int file_number, int B, int Z, int BC, char *boconame, return CG_OK; } -int cg_boco_read(int file_number, int B, int Z, int BC, cgsize_t *pnts, void *NormalList) +/** + * \ingroup BoundaryConditionType + * + * \brief Read boundary condition data and normals + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \param[out] pnts Array of point or element indices defining the boundary condition region. There should be npnts values, each of dimension IndexDimension (i.e., 1 for unstructured grids, and 2 or 3 for structured grids with 2-D or 3-D elements, respectively). + * \param[out] NormalList List of vectors normal to the boundary condition patch pointing into the interior of the zone. + * \return \ier + * + */ +int cg_boco_read(int fn, int B, int Z, int BC, cgsize_t *pnts, void *NormalList) { cgns_boco *boco; int dim = 0; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -8634,7 +10703,7 @@ int cg_boco_read(int file_number, int B, int Z, int BC, cgsize_t *pnts, void *No /* Read point-set directly from ADF-file */ if (boco->ptset && boco->ptset->npts > 0) { - cg_index_dim(file_number, B, Z, &dim); + cg_index_dim(fn, B, Z, &dim); if (cgi_read_int_data(boco->ptset->id, boco->ptset->data_type, boco->ptset->npts * dim, pnts)) return CG_ERROR; } else { @@ -8652,11 +10721,11 @@ int cg_boco_read(int file_number, int B, int Z, int BC, cgsize_t *pnts, void *No return CG_OK; } -int cg_boco_id(int file_number, int B, int Z, int BC, double *boco_id) +int cg_boco_id(int fn, int B, int Z, int BC, double *boco_id) { cgns_boco *boco; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -8668,12 +10737,25 @@ int cg_boco_id(int file_number, int B, int Z, int BC, double *boco_id) return CG_OK; } -int cg_boco_gridlocation_read(int file_number, int B, int Z, +/** + * \ingroup BoundaryConditionType + * + * \brief Read boundary condition location + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \param[out] location Grid location used in the definition of the point set. The currently admissible locations are Vertex (the default if not given), and CellCenter. Interpretation of CellCenter, and additional allowable values of grid location depends on the base cell dimension. For CellDim=1, CellCenter refers to line elements. For CellDim=2, CellCenter refers to area elements, and the additional value EdgeCenter is allowed. For CellDim=3, CellCenter refers to volume elements, and in addition to EdgeCenter, the values of FaceCenter, IFaceCenter, JFaceCenter, and KFaceCenter may be used. + * \return \ier + * + */ +int cg_boco_gridlocation_read(int fn, int B, int Z, int BC, CGNS_ENUMT(GridLocation_t) *location) { cgns_boco *boco; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -8685,7 +10767,24 @@ int cg_boco_gridlocation_read(int file_number, int B, int Z, return CG_OK; } -int cg_boco_write(int file_number, int B, int Z, const char * boconame, +/** + * \ingroup BoundaryConditionType + * + * \brief Write boundary condition type and data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] boconame Name of the boundary condition. + * \param[in] bocotype Type of boundary condition defined. See the eligible types for BCType_t in the Typedefs section. Note that if bocotype is FamilySpecified the boundary condition type is being specified for the family to which the boundary belongs. The boundary condition type for the family may be read and written using cg_fambc_read and cg_fambc_write. + * \param[in] ptset_type The extent of the boundary condition may be defined using a range of points or elements using PointRange, or using a discrete list of all points or elements at which the boundary condition is applied using PointList. When the boundary condition is to be applied anywhere other than points, then GridLocation_t under the BC_t node must be used to indicate this. The value of GridLocation_t may be read or written by cg_boco_gridlocation_read and cg_boco_gridlocation_write. As in previous versions of the library, this may also be done by first using cg_goto to access the BC_t node, then using cg_gridlocation_read or cg_gridlocation_write. + * \param[in] npnts Number of points or elements defining the boundary condition region. For a ptset_type of PointRange, npnts is always two. For a ptset_type of PointList, npnts is the number of points or elements in the list. + * \param[in] pnts Array of point or element indices defining the boundary condition region. There should be npnts values, each of dimension IndexDimension (i.e., 1 for unstructured grids, and 2 or 3 for structured grids with 2-D or 3-D elements, respectively). + * \param[out] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \return \ier + * + */ +int cg_boco_write(int fn, int B, int Z, const char * boconame, CGNS_ENUMT(BCType_t) bocotype, CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t * pnts, int *BC) @@ -8699,7 +10798,7 @@ int cg_boco_write(int file_number, int B, int Z, const char * boconame, cgsize_t length; /* get memory address of file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) @@ -8804,6 +10903,7 @@ int cg_boco_write(int file_number, int B, int Z, const char * boconame, boco->location = location; boco->ptset = CGNS_NEW(cgns_ptset,1); boco->ptset->type = ptype; + strcpy(boco->ptset->name, PointSetTypeName[boco->ptset->type]); strcpy(boco->ptset->data_type,CG_SIZE_DATATYPE); boco->ptset->npts = npnts; @@ -8844,9 +10944,7 @@ int cg_boco_write(int file_number, int B, int Z, const char * boconame, /* Save Point-Set on Disk */ if (npnts > 0) { - char_33 PointSetName; - strcpy(PointSetName, PointSetTypeName[boco->ptset->type]); - if (cgi_write_ptset(boco->id, PointSetName, boco->ptset, index_dim, + if (cgi_write_ptset(boco->id, boco->ptset->name, boco->ptset, index_dim, (void *)pnts)) return CG_ERROR; } if (boco->location != CGNS_ENUMV(Vertex)) { @@ -8860,14 +10958,27 @@ int cg_boco_write(int file_number, int B, int Z, const char * boconame, return CG_OK; } -int cg_boco_gridlocation_write(int file_number, int B, int Z, +/** + * \ingroup BoundaryConditionType + * + * \brief Write boundary condition location + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \param[in] location Grid location used in the definition of the point set. The currently admissible locations are Vertex (the default if not given), and CellCenter. Interpretation of CellCenter, and additional allowable values of grid location depends on the base cell dimension. For CellDim=1, CellCenter refers to line elements. For CellDim=2, CellCenter refers to area elements, and the additional value EdgeCenter is allowed. For CellDim=3, CellCenter refers to volume elements, and in addition to EdgeCenter, the values of FaceCenter, IFaceCenter, JFaceCenter, and KFaceCenter may be used. + * \return \ier + * + */ +int cg_boco_gridlocation_write(int fn, int B, int Z, int BC, CGNS_ENUMT(GridLocation_t) location) { cgns_boco *boco; cgsize_t dim_vals; double dummy_id; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -8892,7 +11003,23 @@ int cg_boco_gridlocation_write(int file_number, int B, int Z, return CG_OK; } -int cg_boco_normal_write(int file_number, int B, int Z, int BC, const int * NormalIndex, +/** + * \ingroup BoundaryConditionType + * + * \brief Write boundary condition normals + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \param[in] NormalIndex Index vector indicating the computational coordinate direction of the boundary condition patch normal. + * \param[in] NormalListFlag Flag indicating if the normals are defined in NormalList and are to be written out; 1 if they are defined, 0 if they're not. + * \param[in] NormalDataType Data type used in the definition of the normals. Admissible data types for the normals are RealSingle and RealDouble. + * \param[in] NormalList List of vectors normal to the boundary condition patch pointing into the interior of the zone. + * \return \ier + * + */ +int cg_boco_normal_write(int fn, int B, int Z, int BC, const int * NormalIndex, int NormalListFlag, CGNS_ENUMT(DataType_t) NormalDataType, const void * NormalList) { @@ -8901,7 +11028,7 @@ int cg_boco_normal_write(int file_number, int B, int Z, int BC, const int * Norm cgsize_t npnts, index_dim; /* get memory address of file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -8975,13 +11102,30 @@ int cg_boco_normal_write(int file_number, int B, int Z, int BC, const int * Norm * Read and write BCDataSet_t Nodes \*****************************************************************************/ -int cg_dataset_read(int file_number, int B, int Z, int BC, int DSet, char *name, +/** + * \ingroup BCDataset + * + * \brief Read boundary condition dataset info + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \param[in] DSet Dataset index number, where 1 ≤ Dset ≤ ndataset. + * \param[out] DatasetName Name of dataset. + * \param[out] BCType Simple boundary condition type for the dataset. The supported types are listed in the table of Simple Boundary Condition Types in the SIDS manual, but note that FamilySpecified does not apply here. + * \param[out] DirichletFlag Flag indicating if the dataset contains Dirichlet data. + * \param[out] NeumannFlag Flag indicating if the dataset contains Neumann data. + * \return \ier + * + */ +int cg_dataset_read(int fn, int B, int Z, int BC, int DSet, char *DatasetName, CGNS_ENUMT(BCType_t) *BCType, int *DirichletFlag, int *NeumannFlag) { cgns_dataset *dataset; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -8989,7 +11133,7 @@ int cg_dataset_read(int file_number, int B, int Z, int BC, int DSet, char *name, dataset = cgi_get_dataset(cg, B, Z, BC, DSet); if (dataset==0) return CG_ERROR; - strcpy(name, dataset->name); + strcpy(DatasetName, dataset->name); *BCType = dataset->type; if (dataset->dirichlet) *DirichletFlag=1; else *DirichletFlag=0; @@ -8999,7 +11143,22 @@ int cg_dataset_read(int file_number, int B, int Z, int BC, int DSet, char *name, return CG_OK; } -int cg_dataset_write(int file_number, int B, int Z, int BC, const char * name, +/** + * \ingroup BCDataset + * + * \brief Write boundary condition dataset info + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \param[in] DatasetName Name of dataset. + * \param[in] BCType Simple boundary condition type for the dataset. The supported types are listed in the table of Simple Boundary Condition Types in the SIDS manual, but note that FamilySpecified does not apply here. + * \param[out] Dset Dataset index number, where 1 ≤ Dset ≤ ndataset. + * \return \ier + * + */ +int cg_dataset_write(int fn, int B, int Z, int BC, const char * DatasetName, CGNS_ENUMT( BCType_t ) BCType, int *Dset) { cgns_boco *boco; @@ -9012,10 +11171,10 @@ int cg_dataset_write(int file_number, int B, int Z, int BC, const char * name, cgi_error("Invalid BCType: %d",BCType); return CG_ERROR; } - if (cgi_check_strlen(name)) return CG_ERROR; + if (cgi_check_strlen(DatasetName)) return CG_ERROR; /* get memory address of file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -9025,11 +11184,11 @@ int cg_dataset_write(int file_number, int B, int Z, int BC, const char * name, /* Overwrite a BCDataSet_t node : */ for (index=0; indexndataset; index++) { - if (strcmp(name, boco->dataset[index].name)==0) { + if (strcmp(DatasetName, boco->dataset[index].name)==0) { /* in CG_MODE_WRITE, children names must be unique */ if (cg->mode==CG_MODE_WRITE) { - cgi_error("Duplicate child name found: %s",name); + cgi_error("Duplicate child name found: %s",DatasetName); return CG_ERROR; } @@ -9058,7 +11217,7 @@ int cg_dataset_write(int file_number, int B, int Z, int BC, const char * name, /* save data in memory */ memset(dataset, 0, sizeof(cgns_dataset)); dataset->type = BCType; - strcpy(dataset->name, name); + strcpy(dataset->name, DatasetName); dataset->location = CGNS_ENUMV(Vertex); /* save data in file */ @@ -9072,7 +11231,23 @@ int cg_dataset_write(int file_number, int B, int Z, int BC, const char * name, * write BCdata_t Nodes \*****************************************************************************/ -int cg_bcdata_write(int file_number, int B, int Z, int BC, int Dset, +/** + * \ingroup BCData + * + * \brief Write boundary condition data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \param[in] Dset Dataset index number, where 1 ≤ Dset ≤ ndataset. + * \param[in] BCDataType Type of boundary condition in the dataset. Admissible boundary condition types are Dirichlet and Neumann. + * \return \ier + * + * \details To write the boundary condition data itself, after creating the BCData_t node using the function cg_bcdata_write, use cg_goto to access the node, then cg_array_write to write the data. Note that when using cg_goto to access a BCData_t node, the node index should be specified as either Dirichlet or Neumann, depending on the type of boundary condition. See the description of cg_goto for details. + * + */ +int cg_bcdata_write(int fn, int B, int Z, int BC, int Dset, CGNS_ENUMT(BCDataType_t) BCDataType) { cgns_dataset *dataset; @@ -9085,7 +11260,7 @@ int cg_bcdata_write(int file_number, int B, int Z, int BC, int Dset, } /* get memory address of file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -9136,11 +11311,23 @@ int cg_bcdata_write(int file_number, int B, int Z, int BC, int Dset, * Read and write RigidGridMotion_t Nodes \*****************************************************************************/ -int cg_n_rigid_motions(int file_number, int B, int Z, int *n_rigid_motions) +/** + * \ingroup RigidGridMotion + * + * \brief Get number of RigidGridMotion_t nodes + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] n_rigid_motions Number of RigidGridMotion_t nodes under zone Z. + * \return \ier + * + */ +int cg_n_rigid_motions(int fn, int B, int Z, int *n_rigid_motions) { cgns_zone *zone; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -9153,13 +11340,27 @@ int cg_n_rigid_motions(int file_number, int B, int Z, int *n_rigid_motions) return CG_OK; } -int cg_rigid_motion_read(int file_number, int B, int Z, int R, char *name, +/** + * \ingroup RigidGridMotion + * + * \brief Read RigidGridMotion_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] R Rigid rotation index number, where 1 ≤ R ≤ n_rigid_motions. + * \param[out] name Name of the RigidGridMotion_t node. + * \param[out] type Type of rigid grid motion. The admissible types are CG_Null, CG_UserDefined, ConstantRate, and VariableRate. + * \return \ier + * + */ +int cg_rigid_motion_read(int fn, int B, int Z, int R, char *name, CGNS_ENUMT(RigidGridMotionType_t) *type) { cgns_rmotion *rmotion; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -9173,7 +11374,21 @@ int cg_rigid_motion_read(int file_number, int B, int Z, int R, char *name, return CG_OK; } -int cg_rigid_motion_write(int file_number, int B, int Z, const char * rmotionname, +/** + * \ingroup RigidGridMotion + * + * \brief Create RigidGridMotion_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] rmotionname Name of the RigidGridMotion_t node. + * \param[in] type Type of rigid grid motion. The admissible types are CG_Null, CG_UserDefined, ConstantRate, and VariableRate. + * \param[out] R Rigid rotation index number, where 1 ≤ R ≤ n_rigid_motions. + * \return \ier + * + */ +int cg_rigid_motion_write(int fn, int B, int Z, const char * rmotionname, CGNS_ENUMT(RigidGridMotionType_t) type, int *R) { cgns_zone *zone; @@ -9190,7 +11405,7 @@ int cg_rigid_motion_write(int file_number, int B, int Z, const char * rmotionnam } /* get memory address for RigidGridMotion_t node */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -9248,11 +11463,23 @@ int cg_rigid_motion_write(int file_number, int B, int Z, const char * rmotionnam * Read and write ArbitraryGridMotion_t Nodes \*****************************************************************************/ -int cg_n_arbitrary_motions(int file_number, int B, int Z, int *n_arbitrary_motions) +/** + * \ingroup ArbitraryGridMotion + * + * \brief Get number of ArbitraryGridMotion_t nodes + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] n_arbitrary_motions Number of ArbitraryGridMotion_t nodes under zone Z. + * \return \ier + * + */ +int cg_n_arbitrary_motions(int fn, int B, int Z, int *n_arbitrary_motions) { cgns_zone *zone; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -9265,13 +11492,27 @@ int cg_n_arbitrary_motions(int file_number, int B, int Z, int *n_arbitrary_motio return CG_OK; } -int cg_arbitrary_motion_read(int file_number, int B, int Z, int A, char *name, +/** + * \ingroup ArbitraryGridMotion + * + * \brief Read ArbitraryGridMotion_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] A Arbitrary grid motion index number, where 1 ≤ A ≤ n_arbitrary_motions. + * \param[out] name Name of the ArbitraryGridMotion_t node. + * \param[out] type Type of arbitrary grid motion. The admissible types are CG_Null, CG_UserDefined, NonDeformingGrid, and DeformingGrid. + * \return \ier + * + */ +int cg_arbitrary_motion_read(int fn, int B, int Z, int A, char *name, CGNS_ENUMT(ArbitraryGridMotionType_t) *type) { cgns_amotion *amotion; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -9285,7 +11526,21 @@ int cg_arbitrary_motion_read(int file_number, int B, int Z, int A, char *name, return CG_OK; } -int cg_arbitrary_motion_write(int file_number, int B, int Z, const char * amotionname, +/** + * \ingroup ArbitraryGridMotion + * + * \brief Write ArbitraryGridMotion_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] amotionname Name of the ArbitraryGridMotion_t node. + * \param[in] type Type of arbitrary grid motion. The admissible types are CG_Null, CG_UserDefined, NonDeformingGrid, and DeformingGrid. + * \param[out] A Arbitrary grid motion index number, where 1 ≤ A ≤ n_arbitrary_motions. + * \return \ier + * + */ +int cg_arbitrary_motion_write(int fn, int B, int Z, const char * amotionname, CGNS_ENUMT(ArbitraryGridMotionType_t) type, int *A) { cgns_zone *zone; @@ -9302,7 +11557,7 @@ int cg_arbitrary_motion_write(int file_number, int B, int Z, const char * amotio } /* get memory address for ArbitraryGridMotion_t node */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -9360,11 +11615,22 @@ int cg_arbitrary_motion_write(int file_number, int B, int Z, const char * amotio * Read and write SimulationType_t Node \*****************************************************************************/ -int cg_simulation_type_read(int file_number, int B, CGNS_ENUMT(SimulationType_t) *type) +/** + * \ingroup SimulationType + * + * \brief Read simulation type + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[out] SimulationType Type of simulation. Valid types are CG_Null, CG_UserDefined, TimeAccurate, and NonTimeAccurate. + * \return \ier + * + */ +int cg_simulation_type_read(int fn, int B, CGNS_ENUMT(SimulationType_t) *SimulationType) { cgns_base *base; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -9372,24 +11638,35 @@ int cg_simulation_type_read(int file_number, int B, CGNS_ENUMT(SimulationType_t) base = cgi_get_base(cg, B); if (base==0) return CG_ERROR; - *type = base->type; + *SimulationType = base->type; return CG_OK; } -int cg_simulation_type_write(int file_number, int B, CGNS_ENUMT(SimulationType_t) type) +/** + * \ingroup SimulationType + * + * \brief Write simulation type + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] SimulationType Type of simulation. Valid types are CG_Null, CG_UserDefined, TimeAccurate, and NonTimeAccurate. + * \return \ier + * + */ +int cg_simulation_type_write(int fn, int B, CGNS_ENUMT(SimulationType_t) SimulationType) { cgns_base *base; cgsize_t length; /* check input */ - if (INVALID_ENUM(type,NofValidSimulationTypes)) { - cgi_error("Invalid input: SimulationType=%d ?",type); + if (INVALID_ENUM(SimulationType,NofValidSimulationTypes)) { + cgi_error("Invalid input: SimulationType=%d ?", SimulationType); return CG_ERROR; } /* get memory address for file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -9408,13 +11685,13 @@ int cg_simulation_type_write(int file_number, int B, CGNS_ENUMT(SimulationType_t if (cgi_delete_node(base->id, base->type_id)) return CG_ERROR; } - base->type = type; + base->type = SimulationType; base->type_id = 0; /* save data in file */ - length = (cgsize_t)strlen(SimulationTypeName[type]); + length = (cgsize_t)strlen(SimulationTypeName[SimulationType]); if (cgi_new_node(base->id, "SimulationType", "SimulationType_t", &base->type_id, - "C1", 1, &length, (void *)SimulationTypeName[type])) return CG_ERROR; + "C1", 1, &length, (void *)SimulationTypeName[SimulationType])) return CG_ERROR; return CG_OK; } @@ -9423,11 +11700,23 @@ int cg_simulation_type_write(int file_number, int B, CGNS_ENUMT(SimulationType_t * read and write BaseIterativeData_t Node \*****************************************************************************/ -int cg_biter_read(int file_number, int B, char *bitername, int *nsteps) +/** + * \ingroup BaseIterativeData + * + * \brief Read BaseIterativeData_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[out] bitername Name of the BaseIterativeData_t node. + * \param[out] nsteps Number of time steps or iterations. + * \return \ier + * + */ +int cg_biter_read(int fn, int B, char *bitername, int *nsteps) { cgns_biter *biter; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -9441,7 +11730,19 @@ int cg_biter_read(int file_number, int B, char *bitername, int *nsteps) return CG_OK; } -int cg_biter_write(int file_number, int B, const char * bitername, int nsteps) +/** + * \ingroup BaseIterativeData + * + * \brief Write BaseIterativeData_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] bitername Name of the BaseIterativeData_t node. + * \param[in] nsteps Number of time steps or iterations. + * \return \ier + * + */ +int cg_biter_write(int fn, int B, const char * bitername, int nsteps) { cgns_base *base; cgns_biter *biter; @@ -9454,7 +11755,7 @@ int cg_biter_write(int file_number, int B, const char * bitername, int nsteps) } /* get memory address for BaseIterativeData_t node */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -9498,11 +11799,23 @@ int cg_biter_write(int file_number, int B, const char * bitername, int nsteps) * read and write ZoneIterativeData_t Node \*****************************************************************************/ -int cg_ziter_read(int file_number, int B, int Z, char *zitername) +/** + * \ingroup ZoneIterativeData + * + * \brief Read ZontIterativeData_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[out] zitername Name of the ZoneIterativeData_t node. + * \return \ier + * + */ +int cg_ziter_read(int fn, int B, int Z, char *zitername) { cgns_ziter *ziter; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -9515,7 +11828,19 @@ int cg_ziter_read(int file_number, int B, int Z, char *zitername) return CG_OK; } -int cg_ziter_write(int file_number, int B, int Z, const char * zitername) +/** + * \ingroup ZoneIterativeData + * + * \brief Write ZontIterativeData_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] zitername Name of the ZoneIterativeData_t node. + * \return \ier + * + */ +int cg_ziter_write(int fn, int B, int Z, const char * zitername) { cgns_zone *zone; cgns_ziter *ziter; @@ -9524,7 +11849,7 @@ int cg_ziter_write(int file_number, int B, int Z, const char * zitername) if (cgi_check_strlen(zitername)) return CG_ERROR; /* get memory address for ZoneIterativeData_t node */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -9565,13 +11890,24 @@ int cg_ziter_write(int file_number, int B, int Z, const char * zitername) * read and write Gravity_t Node \*****************************************************************************/ -int cg_gravity_read(int file_number, int B, float *gravity_vector) +/** + * \ingroup Gravity + * + * \brief Read Gravity_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] gravity_vector Components of the gravity vector. The number of components must equal PhysicalDimension. (In Fortran, this is an array of Real*4 values.) + * \return \ier + * + */ +int cg_gravity_read(int fn, int B, float *gravity_vector) { cgns_base *base; cgns_gravity *gravity; /* get memory address for file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -9588,13 +11924,24 @@ int cg_gravity_read(int file_number, int B, float *gravity_vector) return CG_OK; } -int cg_gravity_write(int file_number, int B, float const *gravity_vector) +/** + * \ingroup Gravity + * + * \brief Write Gravity_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] gravity_vector Components of the gravity vector. The number of components must equal PhysicalDimension. (In Fortran, this is an array of Real*4 values.) + * \return \ier + * + */ +int cg_gravity_write(int fn, int B, float const *gravity_vector) { cgns_base *base; cgns_gravity *gravity; /* get memory address for file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -9644,14 +11991,28 @@ int cg_gravity_write(int file_number, int B, float const *gravity_vector) * read and write Axisymmetry_t Node \*****************************************************************************/ -int cg_axisym_read(int file_number, int B, float *ref_point, float *axis) +/** + * \ingroup Axisymmetry + * + * \brief Read Axisymmetry_t node + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[out] ref_point Origin used for defining the axis of rotation. (In Fortran, this is an array of Real*4 values.) + * \param[out] axis Direction cosines of the axis of rotation, through the reference point. (In Fortran, this is an array of Real*4 values.) + * \return \ier + * + * \details This node can only be used for a bi-dimensional model, i.e., PhysicalDimension must equal two. + * + */ +int cg_axisym_read(int fn, int B, float *ref_point, float *axis) { int n; cgns_base *base; cgns_axisym *axisym; /* get memory address for file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -9673,14 +12034,28 @@ int cg_axisym_read(int file_number, int B, float *ref_point, float *axis) return CG_OK; } -int cg_axisym_write(int file_number, int B, float const *ref_point, float const *axis) +/** + * \ingroup Axisymmetry + * + * \brief Create axisymmetry data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] ref_point Origin used for defining the axis of rotation. (In Fortran, this is an array of Real*4 values.) + * \param[in] axis Direction cosines of the axis of rotation, through the reference point. (In Fortran, this is an array of Real*4 values.) + * \return \ier + * + * \details Axisymmetry_t node can only be used for a bi-dimensional model, i.e., PhysicalDimension must equal two. + * + */ +int cg_axisym_write(int fn, int B, float const *ref_point, float const *axis) { int n; cgns_base *base; cgns_axisym *axisym; /* get memory address for file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -9739,14 +12114,28 @@ int cg_axisym_write(int file_number, int B, float const *ref_point, float const /*****************************************************************************\ * read and write BCProperty_t Node \*****************************************************************************/ - -int cg_bc_wallfunction_read(int file_number, int B, int Z, int BC, +/** + * \ingroup SpecialBoundaryConditionProperty + * + * \brief Read wall function data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \param[out] WallFunctionType The wall function type. Valid types are CG_Null, CG_UserDefined, and Generic. + * \return \ier + * + * \details The "read" functions will return with ier = 2 = CG_NODE_NOT_FOUND if the requested boundary condition property, or the BCProperty_t node itself, doesn't exist. + * + */ +int cg_bc_wallfunction_read(int fn, int B, int Z, int BC, CGNS_ENUMT(WallFunctionType_t) *WallFunctionType) { cgns_bprop *bprop; /* get memory address for file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -9764,7 +12153,22 @@ int cg_bc_wallfunction_read(int file_number, int B, int Z, int BC, return CG_OK; } -int cg_bc_wallfunction_write(int file_number, int B, int Z, int BC, +/** + * \ingroup SpecialBoundaryConditionProperty + * + * \brief Write wall function data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \param[in] WallFunctionType The wall function type. Valid types are CG_Null, CG_UserDefined, and Generic. + * \return \ier + * + * \details The "write" functions will create the BCProperty_t node if it doesn't already exist, then add the appropriate boundary condition property. Multiple boundary condition properties may be recorded under the same BCProperty_t node. + * + */ +int cg_bc_wallfunction_write(int fn, int B, int Z, int BC, CGNS_ENUMT(WallFunctionType_t) WallFunctionType) { cgns_bprop *bprop; @@ -9780,7 +12184,7 @@ int cg_bc_wallfunction_write(int file_number, int B, int Z, int BC, } /* get memory address of file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -9853,8 +12257,24 @@ int cg_bc_wallfunction_write(int file_number, int B, int Z, int BC, } /*----------------------------------------------------------------------*/ - -int cg_bc_area_read(int file_number, int B, int Z, int BC, +/** + * \ingroup SpecialBoundaryConditionProperty + * + * \brief Read area related data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \param[out] AreaType The type of area. Valid types are CG_Null, CG_UserDefined, BleedArea, and CaptureArea. + * \param[out] SurfaceArea The size of the area. (In Fortran, this is a Real*4 value.) + * \param[out] RegionName The name of the region, 32 characters max. + * \return \ier + * + * \details The "read" functions will return with ier = 2 = CG_NODE_NOT_FOUND if the requested boundary condition property, or the BCProperty_t node itself, doesn't exist. + * + */ +int cg_bc_area_read(int fn, int B, int Z, int BC, CGNS_ENUMT(AreaType_t) *AreaType, float *SurfaceArea, char *RegionName) { @@ -9862,7 +12282,7 @@ int cg_bc_area_read(int file_number, int B, int Z, int BC, cgns_bprop *bprop; /* get memory address for file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -9888,7 +12308,24 @@ int cg_bc_area_read(int file_number, int B, int Z, int BC, return CG_OK; } -int cg_bc_area_write(int file_number, int B, int Z, int BC, +/** + * \ingroup SpecialBoundaryConditionProperty + * + * \brief Write area related data + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] BC Boundary condition index number, where 1 ≤ BC ≤ nbocos. + * \param[in] AreaType The type of area. Valid types are CG_Null, CG_UserDefined, BleedArea, and CaptureArea. + * \param[in] SurfaceArea The size of the area. (In Fortran, this is a Real*4 value.) + * \param[in] RegionName The name of the region, 32 characters max. + * \return \ier + * + * \details The "write" functions will create the BCProperty_t node if it doesn't already exist, then add the appropriate boundary condition property. Multiple boundary condition properties may be recorded under the same BCProperty_t node. + * + */ +int cg_bc_area_write(int fn, int B, int Z, int BC, CGNS_ENUMT( AreaType_t ) AreaType, float SurfaceArea, const char *RegionName) { @@ -9907,7 +12344,7 @@ int cg_bc_area_write(int file_number, int B, int Z, int BC, } /* get memory address of file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -10018,8 +12455,24 @@ int cg_bc_area_write(int file_number, int B, int Z, int BC, /*****************************************************************************\ * read and write GridConnectivityProperty_t Node \*****************************************************************************/ - -int cg_conn_periodic_read(int file_number, int B, int Z, int J, +/** + * \ingroup SpecialGridConnectivityProperty + * + * \brief Read data for periodic interface + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. + * \param[out] RotationCenter An array of size phys_dim defining the coordinates of the origin for defining the rotation angle between the periodic interfaces. (phys_dim is the number of coordinates required to define a vector in the field.) (In Fortran, this is an array of Real*4 values.) + * \param[out] RotationAngle An array of size phys_dim defining the rotation angle from the current interface to the connecting interface. If rotating about more than one axis, the rotation is performed first about the x-axis, then the y-axis, then the z-axis. (In Fortran, this is an array of Real*4 values.) + * \param[out] Translation An array of size phys_dim defining the translation from the current interface to the connecting interface. (In Fortran, this is an array of Real*4 values.) + * \return \ier + * + * \details The "read" functions will return with ier = 2 = CG_NODE_NOT_FOUND if the requested connectivity property, or the GridConnectivityProperty_t node itself, doesn't exist. + * + */ +int cg_conn_periodic_read(int fn, int B, int Z, int J, float *RotationCenter, float *RotationAngle, float *Translation) { @@ -10029,7 +12482,7 @@ int cg_conn_periodic_read(int file_number, int B, int Z, int J, cgns_cperio *cperio; /* get memory address for file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -10061,7 +12514,24 @@ int cg_conn_periodic_read(int file_number, int B, int Z, int J, return CG_OK; } -int cg_conn_periodic_write(int file_number, int B, int Z, int J, +/** + * \ingroup SpecialGridConnectivityProperty + * + * \brief Write data for periodic interface + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. + * \param[in] RotationCenter An array of size phys_dim defining the coordinates of the origin for defining the rotation angle between the periodic interfaces. (phys_dim is the number of coordinates required to define a vector in the field.) (In Fortran, this is an array of Real*4 values.) + * \param[in] RotationAngle An array of size phys_dim defining the rotation angle from the current interface to the connecting interface. If rotating about more than one axis, the rotation is performed first about the x-axis, then the y-axis, then the z-axis. (In Fortran, this is an array of Real*4 values.) + * \param[in] Translation An array of size phys_dim defining the translation from the current interface to the connecting interface. (In Fortran, this is an array of Real*4 values.) + * \return \ier + * + * \details The "write" functions will create the GridConnectivityProperty_t node if it doesn't already exist, then add the appropriate connectivity property. Multiple grid connectivity properties may be recorded under the same GridConnectivityProperty_t node. + * + */ +int cg_conn_periodic_write(int fn, int B, int Z, int J, float const *RotationCenter, float const *RotationAngle, float const *Translation) { @@ -10072,7 +12542,7 @@ int cg_conn_periodic_write(int file_number, int B, int Z, int J, int n; /* get memory address of file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -10166,14 +12636,28 @@ int cg_conn_periodic_write(int file_number, int B, int Z, int J, } /*----------------------------------------------------------------------*/ - -int cg_conn_average_read(int file_number, int B, int Z, int J, +/** + * \ingroup SpecialGridConnectivityProperty + * + * \brief Read data for averaging interface + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. + * \param[out] AverageInterfaceType The type of averaging to be done. Valid types are CG_Null, CG_UserDefined, AverageAll, AverageCircumferential, AverageRadial, AverageI, AverageJ, and AverageK. + * \return \ier + * + * \details The "read" functions will return with ier = 2 = CG_NODE_NOT_FOUND if the requested connectivity property, or the GridConnectivityProperty_t node itself, doesn't exist. + * + */ +int cg_conn_average_read(int fn, int B, int Z, int J, CGNS_ENUMT(AverageInterfaceType_t) *AverageInterfaceType) { cgns_cprop *cprop; /* get memory address for file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -10191,7 +12675,22 @@ int cg_conn_average_read(int file_number, int B, int Z, int J, return CG_OK; } -int cg_conn_average_write(int file_number, int B, int Z, int J, +/** + * \ingroup SpecialGridConnectivityProperty + * + * \brief Write data for averaging interface + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. + * \param[in] AverageInterfaceType The type of averaging to be done. Valid types are CG_Null, CG_UserDefined, AverageAll, AverageCircumferential, AverageRadial, AverageI, AverageJ, and AverageK. + * \return \ier + * + * \details The "write" functions will create the GridConnectivityProperty_t node if it doesn't already exist, then add the appropriate connectivity property. Multiple grid connectivity properties may be recorded under the same GridConnectivityProperty_t node. + * + */ +int cg_conn_average_write(int fn, int B, int Z, int J, CGNS_ENUMT(AverageInterfaceType_t) AverageInterfaceType) { cgns_cprop *cprop; @@ -10207,7 +12706,7 @@ int cg_conn_average_write(int file_number, int B, int Z, int J, } /* get memory address of file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -10278,8 +12777,24 @@ int cg_conn_average_write(int file_number, int B, int Z, int J, } /*----------------------------------------------------------------------*/ - -int cg_1to1_periodic_read(int file_number, int B, int Z, int J, +/** + * \ingroup SpecialGridConnectivityProperty + * + * \brief Read data for periodic interface + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. + * \param[out] RotationCenter An array of size phys_dim defining the coordinates of the origin for defining the rotation angle between the periodic interfaces. (phys_dim is the number of coordinates required to define a vector in the field.) (In Fortran, this is an array of Real*4 values.) + * \param[out] RotationAngle An array of size phys_dim defining the rotation angle from the current interface to the connecting interface. If rotating about more than one axis, the rotation is performed first about the x-axis, then the y-axis, then the z-axis. (In Fortran, this is an array of Real*4 values.) + * \param[out] Translation An array of size phys_dim defining the translation from the current interface to the connecting interface. (In Fortran, this is an array of Real*4 values.) + * \return \ier + * + * \details The "read" functions will return with ier = 2 = CG_NODE_NOT_FOUND if the requested connectivity property, or the GridConnectivityProperty_t node itself, doesn't exist. + * + */ +int cg_1to1_periodic_read(int fn, int B, int Z, int J, float *RotationCenter, float *RotationAngle, float *Translation) { @@ -10290,7 +12805,7 @@ int cg_1to1_periodic_read(int file_number, int B, int Z, int J, cgns_1to1 *one21; /* get memory address for file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -10324,7 +12839,24 @@ int cg_1to1_periodic_read(int file_number, int B, int Z, int J, return CG_OK; } -int cg_1to1_periodic_write(int file_number, int B, int Z, int J, +/** + * \ingroup SpecialGridConnectivityProperty + * + * \brief Write data for periodic interface + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. + * \param[in] RotationCenter An array of size phys_dim defining the coordinates of the origin for defining the rotation angle between the periodic interfaces. (phys_dim is the number of coordinates required to define a vector in the field.) (In Fortran, this is an array of Real*4 values.) + * \param[in] RotationAngle An array of size phys_dim defining the rotation angle from the current interface to the connecting interface. If rotating about more than one axis, the rotation is performed first about the x-axis, then the y-axis, then the z-axis. (In Fortran, this is an array of Real*4 values.) + * \param[in] Translation An array of size phys_dim defining the translation from the current interface to the connecting interface. (In Fortran, this is an array of Real*4 values.) + * \return \ier + * + * \details The "write" functions will create the GridConnectivityProperty_t node if it doesn't already exist, then add the appropriate connectivity property. Multiple grid connectivity properties may be recorded under the same GridConnectivityProperty_t node. + * + */ +int cg_1to1_periodic_write(int fn, int B, int Z, int J, float const *RotationCenter, float const *RotationAngle, float const *Translation) @@ -10336,7 +12868,7 @@ int cg_1to1_periodic_write(int file_number, int B, int Z, int J, int n; /* get memory address of file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -10432,15 +12964,29 @@ int cg_1to1_periodic_write(int file_number, int B, int Z, int J, } /*----------------------------------------------------------------------*/ - -int cg_1to1_average_read(int file_number, int B, int Z, int J, +/** + * \ingroup SpecialGridConnectivityProperty + * + * \brief Read data for averaging interface + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. + * \param[out] AverageInterfaceType The type of averaging to be done. Valid types are CG_Null, CG_UserDefined, AverageAll, AverageCircumferential, AverageRadial, AverageI, AverageJ, and AverageK. + * \return \ier + * + * \details The "read" functions will return with ier = 2 = CG_NODE_NOT_FOUND if the requested connectivity property, or the GridConnectivityProperty_t node itself, doesn't exist. + * + */ +int cg_1to1_average_read(int fn, int B, int Z, int J, CGNS_ENUMT(AverageInterfaceType_t) *AverageInterfaceType) { cgns_cprop *cprop; cgns_1to1 *one21; /* get memory address for file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; @@ -10460,7 +13006,22 @@ int cg_1to1_average_read(int file_number, int B, int Z, int J, return CG_OK; } -int cg_1to1_average_write(int file_number, int B, int Z, int J, +/** + * \ingroup SpecialGridConnectivityProperty + * + * \brief Write data for averaging interface + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] J Grid connectivity index number, where 1 ≤ J ≤ nconns for the "cg_conn" functions, and 1 ≤ J ≤ n1to1 for the "cg_1to1" functions. + * \param[in] AverageInterfaceType The type of averaging to be done. Valid types are CG_Null, CG_UserDefined, AverageAll, AverageCircumferential, AverageRadial, AverageI, AverageJ, and AverageK. + * \return \ier + * + * \details The "write" functions will create the GridConnectivityProperty_t node if it doesn't already exist, then add the appropriate connectivity property. Multiple grid connectivity properties may be recorded under the same GridConnectivityProperty_t node. + * + */ +int cg_1to1_average_write(int fn, int B, int Z, int J, CGNS_ENUMT(AverageInterfaceType_t) AverageInterfaceType) { cgns_cprop *cprop; @@ -10476,7 +13037,7 @@ int cg_1to1_average_write(int file_number, int B, int Z, int J, } /* get memory address of file */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; @@ -10555,7 +13116,7 @@ int cg_1to1_average_write(int file_number, int B, int Z, int J, * Go - To Function \*****************************************************************************/ -int vcg_goto(int file_number, int B, va_list ap) +int vcg_goto(int fn, int B, va_list ap) { int n; int index[CG_MAX_GOTO_DEPTH]; @@ -10565,7 +13126,7 @@ int vcg_goto(int file_number, int B, va_list ap) posit = 0; /* set global variable cg */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; /* read variable argument list */ @@ -10575,15 +13136,41 @@ int vcg_goto(int file_number, int B, va_list ap) if (strcmp("end",label[n])==0 || strcmp("END",label[n])==0) break; index[n] = va_arg(ap, int); } - return cgi_set_posit(file_number, B, n, index, label); + return cgi_set_posit(fn, B, n, index, label); } -int cg_goto(int file_number, int B, ...) +/** + * \ingroup AccessingANode + * + * \brief Access a node via label/name, index pairs + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] ... Variable argument list used to specify the path to a node. It is composed of an unlimited list of pair-arguments identifying each node in the path. Nodes may be identified by their label or name. Thus, a pair-argument may be of the form + + "CGNS_NodeLabel", NodeIndex + +where CGNS_NodeLabel is the node label and NodeIndex is the node index, or + + "CGNS_NodeName", 0 + +where CGNS_NodeName is the node name. The 0 in the second form is required, to indicate that a node name is being specified rather than a node label. In addition, a pair-argument may be specified as + + "..", 0 + +indicating the parent of the current node. The different pair-argument forms may be intermixed in the same function call. + +There is one exception to this rule. When accessing a BCData_t node, the index must be set to either Dirichlet or Neumann since only these two types are allowed. (Note that Dirichlet and Neumann are defined in the include files cgnslib.h and cgnslib_f.h). Since "Dirichlet" and "Neuman" are also the names for these nodes, you may also use the "Dirichlet", 0 or "Neuman", 0 to access the node. See the example below. + * \return \ier + * + * \details The character string "end" (or 'end' for the Fortran function) must be the last argument. It is used to indicate the end of the argument list. You may also use the empty string, "" ('' for Fortran), or the NULL string in C, to terminate the list. + */ +int cg_goto(int fn, int B, ...) { va_list ap; int status; va_start(ap, B); - status = vcg_goto(file_number, B, ap); + status = vcg_goto(fn, B, ap); va_end(ap); return status; } @@ -10599,7 +13186,7 @@ int cg_goto(int file_number, int B, ...) * */ -int cg_goto_f08(int file_number, int B, ...) +int cg_goto_f08(int fn, int B, ...) { int n; @@ -10611,7 +13198,7 @@ int cg_goto_f08(int file_number, int B, ...) posit = 0; /* set global variable cg */ - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; va_start(ap, B); @@ -10625,12 +13212,12 @@ int cg_goto_f08(int file_number, int B, ...) } va_end(ap); - return cgi_set_posit(file_number, B, n, index, label); + return cgi_set_posit(fn, B, n, index, label); } /*-----------------------------------------------------------------------*/ -int vcg_gorel(int file_number, va_list ap) +int vcg_gorel(int fn, va_list ap) { int n = 0; int index[CG_MAX_GOTO_DEPTH]; @@ -10640,7 +13227,7 @@ int vcg_gorel(int file_number, va_list ap) cgi_error ("position not set with cg_goto"); return CG_ERROR; } - if (file_number != posit_file) { + if (fn != posit_file) { cgi_error("current position is in the wrong file"); return CG_ERROR; } @@ -10655,12 +13242,37 @@ int vcg_gorel(int file_number, va_list ap) return cgi_update_posit(n, index, label); } -int cg_gorel(int file_number, ...) +/** + * \ingroup AccessingANode + * + * \brief Access a node via relative path + * + * \param[in] fn \FILE_fn + * \param[in] ... Variable argument list used to specify the path to a node. It is composed of an unlimited list of pair-arguments identifying each node in the path. Nodes may be identified by their label or name. Thus, a pair-argument may be of the form + + "CGNS_NodeLabel", NodeIndex + +where CGNS_NodeLabel is the node label and NodeIndex is the node index, or + + "CGNS_NodeName", 0 + +where CGNS_NodeName is the node name. The 0 in the second form is required, to indicate that a node name is being specified rather than a node label. In addition, a pair-argument may be specified as + + "..", 0 + +indicating the parent of the current node. The different pair-argument forms may be intermixed in the same function call. + +There is one exception to this rule. When accessing a BCData_t node, the index must be set to either Dirichlet or Neumann since only these two types are allowed. (Note that Dirichlet and Neumann are defined in the include files cgnslib.h and cgnslib_f.h). Since "Dirichlet" and "Neuman" are also the names for these nodes, you may also use the "Dirichlet", 0 or "Neuman", 0 to access the node. See the example below. + * \return \ier + * + * \details The character string "end" (or 'end' for the Fortran function) must be the last argument. It is used to indicate the end of the argument list. You may also use the empty string, "" ('' for Fortran), or the NULL string in C, to terminate the list. + */ +int cg_gorel(int fn, ...) { va_list ap; int status; - va_start (ap, file_number); - status = vcg_gorel(file_number, ap); + va_start (ap, fn); + status = vcg_gorel(fn, ap); va_end(ap); return status; } @@ -10675,7 +13287,7 @@ int cg_gorel(int file_number, ...) * directly callable from FORTRAN. * */ -int cg_gorel_f08(int file_number, ...) +int cg_gorel_f08(int fn, ...) { int n = 0; int index[CG_MAX_GOTO_DEPTH]; @@ -10686,12 +13298,12 @@ int cg_gorel_f08(int file_number, ...) cgi_error ("position not set with cg_goto"); return CG_ERROR; } - if (file_number != posit_file) { + if (fn != posit_file) { cgi_error("current position is in the wrong file"); return CG_ERROR; } - va_start (ap, file_number); + va_start (ap, fn); for (n = 0; n < CG_MAX_GOTO_DEPTH; n++) { label[n] = va_arg(ap, char *); if (label[n] == NULL || label[n][0] == 0) break; @@ -10704,8 +13316,18 @@ int cg_gorel_f08(int file_number, ...) } /*-----------------------------------------------------------------------*/ +/** + * \ingroup AccessingANode + * + * \brief Access a node via pathname + * + * \param[in] fn \FILE_fn + * \param[in] path The pathname for the node to go to. If a position has been already set, this may be a relative path, otherwise it is an absolute path name, starting with "/Basename", where Basename is the base under which you wish to move. -int cg_gopath(int file_number, const char *path) + * \return \ier + * + */ +int cg_gopath(int fn, const char *path) { int n, len; const char *p = path, *s; @@ -10742,7 +13364,7 @@ int cg_gopath(int file_number, const char *path) strncpy(label[0], p, len); label[0][len] = 0; - cg = cgi_get_file(file_number); + cg = cgi_get_file(fn); if (cg == 0) return CG_ERROR; for (n = 0; n < cg->nbases; n++) { @@ -10755,7 +13377,7 @@ int cg_gopath(int file_number, const char *path) cgi_error("base '%s' not found", label[0]); return CG_ERROR; } - ierr = cgi_set_posit(file_number, B, 0, index, lab); + ierr = cgi_set_posit(fn, B, 0, index, lab); if (ierr != CG_OK) return ierr; if (s == 0) return CG_OK; p = s; @@ -10768,7 +13390,7 @@ int cg_gopath(int file_number, const char *path) cgi_error("position not set with cg_goto"); return CG_ERROR; } - if (file_number != posit_file) { + if (fn != posit_file) { cgi_error("current position is in the wrong file"); return CG_ERROR; } @@ -10804,19 +13426,43 @@ int cg_gopath(int file_number, const char *path) } /*-----------------------------------------------------------------------*/ - -int cg_golist(int file_number, int B, int depth, char **label, int *index) +/** + * \ingroup AccessingANode + * + * \brief Access a node via arrays of labels and indices + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] depth Depth of the path list. The maximum depth is defined in cgnslib.h by CG_MAX_GOTO_DEPTH, and is currently equal to 20. + * \param[in] label Array of node labels for the path. This argument may be passed as NULL to cg_where(), otherwise it must be dimensioned by the calling program. The maximum size required is label[MAX_GO_TO_DEPTH][33]. You may call cg_where() with both label and index set to NULL in order to get the current depth, then dimension to that value. + * \param[in] index Array of node indices for the path. This argument may be passed as NULL to cg_where(), otherwise it must be dimensioned by the calling program. The maximum size required is index[MAX_GO_TO_DEPTH]. You may call cg_where() with both label and index set to NULL in order to get the current depth, then dimension to that value. + * \return \ier + * + */ +int cg_golist(int fn, int B, int depth, char **label, int *index) { if (depth >= CG_MAX_GOTO_DEPTH) { cgi_error("path is too deep"); return CG_ERROR; } - return cgi_set_posit(file_number, B, depth, index, label); + return cgi_set_posit(fn, B, depth, index, label); } /*-----------------------------------------------------------------------*/ - -int cg_where(int *file_number, int *B, int *depth, char **label, int *num) +/** + * \ingroup AccessingANode + * + * \brief Get path to current node + * + * \param[out] fn \FILE_fn + * \param[out] B \B_Base + * \param[out] depth Depth of the path list. The maximum depth is defined in cgnslib.h by CG_MAX_GOTO_DEPTH, and is currently equal to 20. + * \param[out] label Array of node labels for the path. This argument may be passed as NULL to cg_where(), otherwise it must be dimensioned by the calling program. The maximum size required is label[MAX_GO_TO_DEPTH][33]. You may call cg_where() with both label and index set to NULL in order to get the current depth, then dimension to that value. + * \param[out] num Array of node indices for the path. This argument may be passed as NULL to cg_where(), otherwise it must be dimensioned by the calling program. The maximum size required is index[MAX_GO_TO_DEPTH]. You may call cg_where() with both label and index set to NULL in order to get the current depth, then dimension to that value. + * \return \ier + * + */ +int cg_where(int *fn, int *B, int *depth, char **label, int *num) { int n; @@ -10824,7 +13470,7 @@ int cg_where(int *file_number, int *B, int *depth, char **label, int *num) cgi_error ("position not set with cg_goto"); return CG_ERROR; } - *file_number = posit_file; + *fn = posit_file; *B = posit_base; /* first entry is base */ *depth = posit_depth > 1 ? posit_depth - 1 : 0; @@ -10843,6 +13489,15 @@ int cg_where(int *file_number, int *B, int *depth, char **label, int *num) * Read and write Multiple path nodes \*****************************************************************************/ +/** + * \ingroup FamilyName + * + * \brief Read family name + * + * \param[out] family_name Family name. + * \return \ier + * + */ int cg_famname_read(char *family_name) { char *famname; @@ -10861,6 +13516,15 @@ int cg_famname_read(char *family_name) return CG_OK; } +/** + * \ingroup FamilyName + * + * \brief Write family name + * + * \param[in] family_name Family name. + * \return \ier + * + */ int cg_famname_write(const char * family_name) { char *famname; @@ -10891,7 +13555,15 @@ int cg_famname_write(const char * family_name) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup FamilyName + * + * \brief Get Number of family names + * + * \param[out] nfams Number of additional family names. + * \return \ier + * + */ int cg_nmultifam(int *nfams) { CHECK_FILE_OPEN @@ -10922,6 +13594,17 @@ int cg_nmultifam(int *nfams) return CG_OK; } +/** + * \ingroup FamilyName + * + * \brief Read multiple family names + * + * \param[in] N Family name index number, where 1 ≤ N ≤ nNames. + * \param[out] name Node name. + * \param[out] family Family name + * \return \ier + * + */ int cg_multifam_read(int N, char *name, char *family) { cgns_famname *famname; @@ -10940,6 +13623,17 @@ int cg_multifam_read(int N, char *name, char *family) return CG_OK; } +/** + * \ingroup FamilyName + * + * \brief Write multiple family names + * + * \param[in] name Node name. + * \param[in] family Family name + * \return \ier + * + * \details The additional family names written with cg_multifam_write are stored in AdditionalFamilyName_t nodes. + */ int cg_multifam_write(const char *name, const char *family) { cgns_famname *famname; @@ -10975,7 +13669,18 @@ int cg_multifam_write(const char *name, const char *family) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup ConvergenceHistory + * + * \brief Read ConvergenceHistory_t node + * + * \param[out] iterations Number of iterations for which convergence information is recorded. + * \param[out] NormDefinitions Description of the convergence information recorded in the data arrays. + * \return \ier + * + * \details The function cg_convergence_read reads a ConvergenceHistory_t node. If NormDefinitions is not defined in the CGNS database, this function returns a null string. If NormDefinitions exists, the library will allocate the space to store the description string, and return the description string to the application. It is the responsibility of the application to free this space when it is no longer needed by a call to cg_free(NormDefinitions). + * + */ int cg_convergence_read(int *iterations, char **NormDefinitions) { cgns_converg *converg; @@ -11002,6 +13707,18 @@ int cg_convergence_read(int *iterations, char **NormDefinitions) return CG_OK; } +/** + * \ingroup ConvergenceHistory + * + * \brief Write ConvergenceHistory_t node + * + * \param[in] iterations Number of iterations for which convergence information is recorded. + * \param[in] NormDefinitions Description of the convergence information recorded in the data arrays. + * \return \ier + * + * \details The function cg_convergence_write creates a ConvergenceHistory_t node. It must be the first one called when recording convergence history data. The NormDefinitions may be left undefined (i.e., a blank string). After creation of this node, the descriptors, data arrays, data class, and dimensional units characterizing the ConvergenceHistory_t data structure may be added. + * + */ int cg_convergence_write(int iterations, const char * NormDefinitions) { cgns_converg *converg; @@ -11052,7 +13769,17 @@ int cg_convergence_write(int iterations, const char * NormDefinitions) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup ReferenceState + * + * \brief Read text description of reference state. + * + * \param[in] StateDescription Text description of reference state. + * \return \ier + * + * \details The function cg_state_read reads the StateDescription of the local ReferenceState_t node. If StateDescription is undefined in the CGNS database, this function returns a null string. If StateDescription exists, the library will allocate the space to store the description string, and return the description string to the application. It is the responsibility of the application to free this space when it is no longer needed by a call to cg_free(StateDescription). + * + */ int cg_state_read(char **StateDescription) { cgns_state *state; @@ -11078,6 +13805,17 @@ int cg_state_read(char **StateDescription) return CG_OK; } +/** + * \ingroup ReferenceState + * + * \brief Create ReferenceState_t node + * + * \param[in] StateDescription Text description of reference state. + * \return \ier + * + * \details The function cg_state_write creates the ReferenceState_t node and must be called even if StateDescription is undefined (i.e., a blank string). The descriptors, data arrays, data class, and dimensional units characterizing the ReferenceState_t data structure may be added to this data structure after its creation. + * + */ int cg_state_write(const char * StateDescription) { cgns_state *state; @@ -11127,7 +13865,21 @@ int cg_state_write(const char * StateDescription) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup FlowEquationSet + * + * \brief Read Flow equation set info + * + * \param[out] EquationDimension Dimensionality of the governing equations; it is the number of spatial variables describing the flow. + * \param[out] GoverningEquationsFlag Flag indicating whether or not this FlowEquationSet_t node includes the definition of the governing equations; 0 if it doesn't, 1 if it does. + * \param[out] GasModelFlag Flag indicating whether or not this FlowEquationSet_t node includes the definition of a gas model; 0 if it doesn't, 1 if it does. + * \param[out] ViscosityModelFlag Flag indicating whether or not this FlowEquationSet_t node includes the definition of a viscosity model; 0 if it doesn't, 1 if it does. + * \param[out] ThermalConductivityModelFlag Flag indicating whether or not this FlowEquationSet_t node includes the definition of a thermal conductivity model; 0 if it doesn't, 1 if it does. + * \param[out] TurbulenceClosureFlag Flag indicating whether or not this FlowEquationSet_t node includes the definition of the turbulence closure; 0 if it doesn't, 1 if it does. + * \param[out] TurbulenceModelFlag Flag indicating whether or not this FlowEquationSet_t node includes the definition of a turbulence model; 0 if it doesn't, 1 if it does. + * \return \ier + * + */ int cg_equationset_read(int *EquationDimension, int *GoverningEquationsFlag, int *GasModelFlag, int *ViscosityModelFlag, int *ThermalConductivityModelFlag, @@ -11169,6 +13921,16 @@ int cg_equationset_read(int *EquationDimension, return CG_OK; } +/** + * \ingroup FlowEquationSet + * + * \brief Read chemistry equation set info + * + * \param[out] ThermalRelaxationFlag Flag indicating whether or not this FlowEquationSet_t node includes the definition of a thermal relaxation model; 0 if it doesn't, 1 if it does. + * \param[out] ChemicalKineticsFlag Flag indicating whether or not this FlowEquationSet_t node includes the definition of a chemical kinetics model; 0 if it doesn't, 1 if it does. + * \return \ier + * + */ int cg_equationset_chemistry_read(int *ThermalRelaxationFlag, int *ChemicalKineticsFlag) { @@ -11192,6 +13954,17 @@ int cg_equationset_chemistry_read(int *ThermalRelaxationFlag, return CG_OK; } +/** + * \ingroup FlowEquationSet + * + * \brief Read electromagnetic equation set info + * + * \param[out] ElecFldModelFlag Flag indicating whether or not this FlowEquationSet_t node includes the definition of an electric field model for electromagnetic flows;; 0 if it doesn't, 1 if it does. + * \param[out] MagnFldModelFlag Flag indicating whether or not this FlowEquationSet_t node includes the definition of a magnetic field model for electromagnetic flows;; 0 if it doesn't, 1 if it does. + * \param[out] ConductivityModelFlag Flag indicating whether or not this FlowEquationSet_t node includes the definition of a conductivity model for electromagnetic flows; 0 if it doesn't, 1 if it does. + * \return \ier + * + */ int cg_equationset_elecmagn_read(int *ElecFldModelFlag, int *MagnFldModelFlag, int *ConductivityModelFlag) { @@ -11218,6 +13991,15 @@ int cg_equationset_elecmagn_read(int *ElecFldModelFlag, int *MagnFldModelFlag, return CG_OK; } +/** + * \ingroup FlowEquationSet + * + * \brief Write dimensionality of flow equations + * + * \param[in] EquationDimension Dimensionality of the governing equations; it is the number of spatial variables describing the flow. + * \return \ier + * + */ int cg_equationset_write(int EquationDimension) { cgns_equations *equations; @@ -11263,6 +14045,15 @@ int cg_equationset_write(int EquationDimension) /*----------------------------------------------------------------------*/ +/** + * \ingroup GoverningEquations + * + * \brief Read type of governing equation + * + * \param[out] EquationsType Type of governing equations. The admissible types are CG_Null, CG_UserDefined, FullPotential, Euler, NSLaminar, NSTurbulent, NSLaminarIncompressible, and NSTurbulentIncompressible. + * \return \ier + * + */ int cg_governing_read(CGNS_ENUMT(GoverningEquationsType_t) *EquationsType) { cgns_governing *governing; @@ -11280,6 +14071,16 @@ int cg_governing_read(CGNS_ENUMT(GoverningEquationsType_t) *EquationsType) return CG_OK; } + +/** + * \ingroup GoverningEquations + * + * \brief Write type of governing equation + * + * \param[in] Equationstype Type of governing equations. The admissible types are CG_Null, CG_UserDefined, FullPotential, Euler, NSLaminar, NSTurbulent, NSLaminarIncompressible, and NSTurbulentIncompressible. + * \return \ier + * + */ int cg_governing_write(CGNS_ENUMT(GoverningEquationsType_t) Equationstype) { cgns_governing *governing; @@ -11336,6 +14137,15 @@ int cg_governing_write(CGNS_ENUMT(GoverningEquationsType_t) Equationstype) /*----------------------------------------------------------------------*/ +/** + * \ingroup GoverningEquations + * + * \brief Read flags for diffusion terms + * + * \param[out] diffusion_model Flags defining which diffusion terms are included in the governing equations. This is only applicable to the Navier-Stokes equations with structured grids. See the discussion in the SIDS manual for details. + * \return \ier + * + */ int cg_diffusion_read(int *diffusion_model) { int n, ndata, ier=0; @@ -11373,6 +14183,15 @@ int cg_diffusion_read(int *diffusion_model) return CG_OK; } +/** + * \ingroup GoverningEquations + * + * \brief Write flags for diffusion terms + * + * \param[in] diffusion_model Flags defining which diffusion terms are included in the governing equations. This is only applicable to the Navier-Stokes equations with structured grids. See the discussion in the SIDS manual for details. + * \return \ier + * + */ int cg_diffusion_write(const int * diffusion_model) { int *diffusion; @@ -11421,6 +14240,36 @@ int cg_diffusion_write(const int * diffusion_model) /*----------------------------------------------------------------------*/ +/** + * \ingroup AuxiliaryModel + * + * \brief Read auxiliary model types + * + * \param[out] ModelLabel The CGNS label for the model being defined. The models supported by CGNS are: + * - GasModel_t + * - ViscosityModel_t + * - ThermalConductivityModel_t + * - TurbulenceClosure_t + * - TurbulenceModel_t + * - ThermalRelaxationModel_t + * - ChemicalKineticsModel_t + * - EMElectricFieldModel_t + * - EMMagneticFieldModel_t + * - EMConductivityModel_t + * \param[out] ModelType One of the model types (listed below) allowed for the ModelLabel selected. + * The types allowed for the various models are: + * GasModel_t CG_Null, CG_UserDefined, Ideal, VanderWaals, CaloricallyPerfect, ThermallyPerfect, ConstantDensity, RedlichKwong + * ViscosityModel_t CG_Null, CG_UserDefined, Constant, PowerLaw, SutherlandLaw + * ThermalConductivityModel_t CG_Null, CG_UserDefined, PowerLaw, SutherlandLaw, ConstantPrandtl + * TurbulenceModel_t CG_Null, CG_UserDefined, Algebraic_BaldwinLomax, Algebraic_CebeciSmith, HalfEquation_JohnsonKing, OneEquation_BaldwinBarth, OneEquation_SpalartAllmaras, TwoEquation_JonesLaunder, TwoEquation_MenterSST, TwoEquation_Wilcox + * TurbulenceClosure_t CG_Null, CG_UserDefined, EddyViscosity, ReynoldsStress, ReynoldsStressAlgebraic + * ThermalRelaxationModel_t CG_Null, CG_UserDefined, Frozen, ThermalEquilib, ThermalNonequilib + * ChemicalKineticsModel_t CG_Null, CG_UserDefined, Frozen, ChemicalEquilibCurveFit, ChemicalEquilibMinimization, ChemicalNonequilib + * EMElectricFieldModel_t CG_Null, CG_UserDefined, Constant, Frozen, Interpolated, Voltage + * EMMagneticFieldModel_t CG_Null, CG_UserDefined, Constant, Frozen, Interpolated + * EMConductivityModel_t CG_Null, CG_UserDefined, Constant, Frozen, Equilibrium_LinRessler, Chemistry_LinRessler + * \return \ier + */ int cg_model_read(const char *ModelLabel, CGNS_ENUMT(ModelType_t) *ModelType) { cgns_model *model; @@ -11439,6 +14288,36 @@ int cg_model_read(const char *ModelLabel, CGNS_ENUMT(ModelType_t) *ModelType) return CG_OK; } +/** + * \ingroup AuxiliaryModel + * + * \brief Write auxiliary model types + * + * \param[in] ModelLabel The CGNS label for the model being defined. The models supported by CGNS are: + * - GasModel_t + * - ViscosityModel_t + * - ThermalConductivityModel_t + * - TurbulenceClosure_t + * - TurbulenceModel_t + * - ThermalRelaxationModel_t + * - ChemicalKineticsModel_t + * - EMElectricFieldModel_t + * - EMMagneticFieldModel_t + * - EMConductivityModel_t + * \param[in] ModelType One of the model types (listed below) allowed for the ModelLabel selected. + * The types allowed for the various models are: + * GasModel_t CG_Null, CG_UserDefined, Ideal, VanderWaals, CaloricallyPerfect, ThermallyPerfect, ConstantDensity, RedlichKwong + * ViscosityModel_t CG_Null, CG_UserDefined, Constant, PowerLaw, SutherlandLaw + * ThermalConductivityModel_t CG_Null, CG_UserDefined, PowerLaw, SutherlandLaw, ConstantPrandtl + * TurbulenceModel_t CG_Null, CG_UserDefined, Algebraic_BaldwinLomax, Algebraic_CebeciSmith, HalfEquation_JohnsonKing, OneEquation_BaldwinBarth, OneEquation_SpalartAllmaras, TwoEquation_JonesLaunder, TwoEquation_MenterSST, TwoEquation_Wilcox + * TurbulenceClosure_t CG_Null, CG_UserDefined, EddyViscosity, ReynoldsStress, ReynoldsStressAlgebraic + * ThermalRelaxationModel_t CG_Null, CG_UserDefined, Frozen, ThermalEquilib, ThermalNonequilib + * ChemicalKineticsModel_t CG_Null, CG_UserDefined, Frozen, ChemicalEquilibCurveFit, ChemicalEquilibMinimization, ChemicalNonequilib + * EMElectricFieldModel_t CG_Null, CG_UserDefined, Constant, Frozen, Interpolated, Voltage + * EMMagneticFieldModel_t CG_Null, CG_UserDefined, Constant, Frozen, Interpolated + * EMConductivityModel_t CG_Null, CG_UserDefined, Constant, Frozen, Equilibrium_LinRessler, Chemistry_LinRessler + * \return \ier + */ int cg_model_write(const char * ModelLabel, CGNS_ENUMT(ModelType_t) ModelType) { cgns_model *model; @@ -11604,7 +14483,15 @@ int cg_model_write(const char * ModelLabel, CGNS_ENUMT(ModelType_t) ModelType) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup DataArrays + * + * \brief Get number of data arrays under current node + * + * \param[out] narrays Number of DataArray_t nodes under the current node. + * + * \return \ier + */ int cg_narrays(int *narrays) { @@ -11731,6 +14618,19 @@ int cg_narrays(int *narrays) return CG_OK; } +/** + * \ingroup DataArrays + * + * \brief Get data array info + * + * \param[in] A Data array index, where 1 ≤ A ≤ narrays. + * \param[out] ArrayName Name of the DataArray_t node. + * \param[out] DataType Type of data held in the DataArray_t node. The admissible types are Integer, LongInteger, RealSingle, RealDouble, and Character. + * \param[out] DataDimension Number of dimensions of array in file (max 12). See Node Management Routines in CGIO User's Guide. + * \param[out] DimensionVector Dimensions of array in file. + * + * \return \ier + */ int cg_array_info(int A, char *ArrayName, CGNS_ENUMT(DataType_t) *DataType, int *DataDimension, cgsize_t *DimensionVector) { @@ -11754,6 +14654,16 @@ int cg_array_info(int A, char *ArrayName, CGNS_ENUMT(DataType_t) *DataType, return CG_OK; } +/** + * \ingroup DataArrays + * + * \brief Read data array + * + * \param[in] A Data array index, where 1 ≤ A ≤ narrays. + * \param[out] Data The data array in memory. + * + * \return \ier + */ int cg_array_read(int A, void *Data) { cgns_array *array; @@ -11783,6 +14693,18 @@ int cg_array_read(int A, void *Data) return CG_OK; } + +/** + * \ingroup DataArrays + * + * \brief Read data array as a certain type + * + * \param[in] A Data array index, where 1 ≤ A ≤ narrays. + * \param[in] type Type of data held in the DataArray_t node. The admissible types are Integer, LongInteger, RealSingle, RealDouble, and Character. + * \param[out] Data The data array in memory. + * + * \return \ier + */ int cg_array_read_as(int A, CGNS_ENUMT(DataType_t) type, void *Data) { cgns_array *array; @@ -11843,6 +14765,27 @@ int cg_array_read_as(int A, CGNS_ENUMT(DataType_t) type, void *Data) return ier ? CG_ERROR : CG_OK; } + +/** + * \ingroup DataArrays + * + * \brief Read subset of data array to a shaped memory + * + * \param[in] A Data array index, where 1 ≤ A ≤ narrays. + * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). + * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). + * \param[in] m_type The type of data held in memory. The admissible types are Integer, LongInteger, RealSingle, RealDouble, and Character. + * \param[in] m_numdim Number of dimensions of array in memory (max 12). + * \param[in] m_dimvals Dimensions of array in memory. + * \param[in] m_rmin Lower range index in memory (eg., imin, jmin, kmin). + * \param[in] m_rmax Upper range index in memory (eg., imax, jmax, kmax). + * \param[out] data The data array in memory. + * + * \return \ier + * + * \details The functions cg_array_general_read allow for type conversion when reading from the file. + * When using cg_array_general_read, the lower core elements in the file have index 1 for defining range_min and range_max; whereas for the array in memory, defined by mem_rank and mem_dimensions, the lower array elements in memory have index 1 for defining mem_range_min and mem_range_max. The actual lower and upper bounds of the array in memory can be anything. For example, to fully read a two-dimensional 6 × 6 data array with 1 rind plane on each side in the file to an 8 × 8 array in memory (mem_rank = 2 and mem_dimensions = (8,8)), set range_min and range_max to (0,0) and (7,7), and set mem_range_min and mem_range_max to (1,1) and (8,8). + */ int cg_array_general_read(int A, const cgsize_t *s_rmin, const cgsize_t *s_rmax, CGNS_ENUMT(DataType_t) m_type, @@ -11883,6 +14826,19 @@ int cg_array_general_read(int A, data); } +/** + * \ingroup DataArrays + * + * \brief Write data array + * + * \param[in] ArrayName Name of the DataArray_t node. + * \param[in] DataType Type of data held in the DataArray_t node. The admissible types are Integer, LongInteger, RealSingle, RealDouble, and Character. + * \param[in] DataDimension Number of dimensions of array in file (max 12). See Node Management Routines in CGIO User's Guide. + * \param[in] DimensionVector Dimensions of array in file. + * \param[in] Data The data array in memory. + * + * \return \ier + */ int cg_array_write(const char * ArrayName, CGNS_ENUMT(DataType_t) DataType, int DataDimension, const cgsize_t * DimensionVector, const void * Data) @@ -11948,6 +14904,30 @@ int cg_array_write(const char * ArrayName, CGNS_ENUMT(DataType_t) DataType, return CG_OK; } +/** + * \ingroup DataArrays + * + * \brief Write shaped array to a subset of data array + * + * \param[in] arrayname Name of the DataArray_t node. + * \param[in] s_type Type of data held in the DataArray_t node. The admissible types are Integer, LongInteger, RealSingle, RealDouble, and Character. + * \param[in] s_numdim Number of dimensions of array in file (max 12). See Node Management Routines in CGIO User's Guide. + * \param[in] s_dimvals Dimensions of array in file. + * \param[in] s_rmin Lower range index in file (eg., imin, jmin, kmin). + * \param[in] s_rmax Upper range index in file (eg., imax, jmax, kmax). + * \param[in] m_type The type of data held in memory. The admissible types are Integer, LongInteger, RealSingle, RealDouble, and Character. + * \param[in] m_numdim Number of dimensions of array in memory (max 12). + * \param[in] m_dimvals Dimensions of array in memory. + * \param[in] m_rmin Lower range index in memory (eg., imin, jmin, kmin). + * \param[in] m_rmax Upper range index in memory (eg., imax, jmax, kmax). + * \param[in] data The data array in memory. + * + * \return \ier + * + * \details The function cg_array_general_write may be used to write from a subset of the array in memory to a subset of the array in the file. When using the partial write, any existing data from range_min to range_max will be overwritten by the new values. All other values will not be affected. + * The functions cg_array_general_write allow for type conversion when reading to the file. + * When using cg_array_general_write, the lower core elements in the file have index 1 for defining range_min and range_max; whereas for the array in memory, defined by mem_rank and mem_dimensions, the lower array elements in memory have index 1 for defining mem_range_min and mem_range_max. The actual lower and upper bounds of the array in memory can be anything. For example, to fully read a two-dimensional 6 × 6 data array with 1 rind plane on each side in the file to an 8 × 8 array in memory (mem_rank = 2 and mem_dimensions = (8,8)), set range_min and range_max to (0,0) and (7,7), and set mem_range_min and mem_range_max to (1,1) and (8,8). + */ int cg_array_general_write(const char *arrayname, CGNS_ENUMT(DataType_t) s_type, int s_numdim, const cgsize_t *s_dimvals, @@ -12013,7 +14993,15 @@ int cg_array_general_write(const char *arrayname, } /*----------------------------------------------------------------------*/ - +/** + * \ingroup IntegralData + * + * \brief Get number of IntegralData_t nodes + * + * \param[out] nintegrals Number of IntegralData_t nodes under current node. + * + * \return \ier + */ int cg_nintegrals(int *nintegrals) { CHECK_FILE_OPEN @@ -12043,6 +15031,16 @@ int cg_nintegrals(int *nintegrals) return CG_OK; } +/** + * \ingroup IntegralData + * + * \brief Get name of an IntegralData_t node + * + * \param[in] IntegralDataIndex Integral data index number, where 1 ≤ IntegralDataIndex ≤ nintegrals. + * \param[out] IntegralDataName Name of the IntegralData_t data structure. + * + * \return \ier + */ int cg_integral_read(int IntegralDataIndex, char *IntegralDataName) { int ier=0; @@ -12061,6 +15059,15 @@ int cg_integral_read(int IntegralDataIndex, char *IntegralDataName) return CG_OK; } +/** + * \ingroup IntegralData + * + * \brief Create IntegralData_t node + * + * \param[in] IntegralDataName Name of the IntegralData_t data structure. + * + * \return \ier + */ int cg_integral_write(const char * IntegralDataName) { cgns_integral *integral; @@ -12095,7 +15102,15 @@ int cg_integral_write(const char * IntegralDataName) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup RindLayers + * + * \brief Read number of rind layers + * + * \param[out] RindData Number of rind layers for each computational direction (structured grid) or number of rind points or elements (unstructured grid). For structured grids, the low/high sides have unit stride in the array (e.g., [NRindLowI, NRindHighI, NRindLowJ, NRindHighJ, NRindLowK, NRindHighK]). + * + * \return \ier + */ int cg_rind_read(int *RindData) { int n, ier=0; @@ -12120,6 +15135,17 @@ int cg_rind_read(int *RindData) return CG_OK; } +/** + * \ingroup RindLayers + * + * \brief Write number of rind layers + * + * \param[in] RindData Number of rind layers for each computational direction (structured grid) or number of rind points or elements (unstructured grid). For structured grids, the low/high sides have unit stride in the array (e.g., [NRindLowI, NRindHighI, NRindLowJ, NRindHighJ, NRindLowK, NRindHighK]). + * + * \return \ier + * + * \details When writing rind data for elements, cg_section_write must be called first, followed by cg_goto to access the Elements_t node, and then cg_rind_write. + */ int cg_rind_write(const int * RindData) { int n, ier=0; @@ -12160,7 +15186,15 @@ int cg_rind_write(const int * RindData) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup DescriptiveText + * + * \brief Get number of descriptors in file + * + * \param[out] ndescriptors Number of Descriptor_t nodes under the current node. + * \return \ier + * + */ int cg_ndescriptors(int *ndescriptors) { @@ -12287,6 +15321,20 @@ int cg_ndescriptors(int *ndescriptors) return CG_OK; } +/** + * \ingroup DescriptiveText + * + * \brief Read descriptive text + * + * \param[in] descr_no Descriptor index number, where 1 ≤ descr_no ≤ ndescriptors. + * \param[out] descr_name Name of the Descriptor_t node. + * \param[out] descr_text Description held in the Descriptor_t node. + * \return \ier + * + * + * \details Note that with cg_descriptor_read the memory for the descriptor character string, text, will be allocated by the Mid-Level Library. The application code is responsible for releasing this memory when it is no longer needed by calling cg_free(text). + * + */ int cg_descriptor_read(int descr_no, char *descr_name, char **descr_text) { cgns_descr *descr; @@ -12309,6 +15357,15 @@ int cg_descriptor_read(int descr_no, char *descr_name, char **descr_text) return CG_OK; } +/** + * \ingroup DescriptiveText + * + * \brief Write descriptive text + * + * \param[in] descr_name Name of the Descriptor_t node. + * \param[in] descr_text Description held in the Descriptor_t node. + * \return \ier + */ int cg_descriptor_write(const char * descr_name, const char * descr_text) { cgns_descr *descr; @@ -12343,7 +15400,14 @@ int cg_descriptor_write(const char * descr_name, const char * descr_text) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup DimensionalUnits + * + * \brief Get number of dimensional units + * + * \param[out] nunits Number of units used in the file (i.e., either 5 or 8). + * \return \ier + */ int cg_nunits(int *nunits) { cgns_units *units; @@ -12361,6 +15425,19 @@ int cg_nunits(int *nunits) return CG_OK; } +/** + * \ingroup DimensionalUnits + * + * \brief Read first five dimensional units + * + * \param[out] mass Mass units. Admissible values are CG_Null, CG_UserDefined, Kilogram, Gram, Slug, and PoundMass. + * \param[out] length Length units. Admissible values are CG_Null, CG_UserDefined, Meter, Centimeter, Millimeter, Foot, and Inch. + * \param[out] time Time units. Admissible values are CG_Null, CG_UserDefined, and Second. + * \param[out] temperature Temperature units. Admissible values are CG_Null, CG_UserDefined, Kelvin, Celsius, Rankine, and Fahrenheit. + * \param[out] angle Angle units. Admissible values are CG_Null, CG_UserDefined, Degree, and Radian. + * + * \return \ier + */ int cg_units_read(CGNS_ENUMT(MassUnits_t) *mass, CGNS_ENUMT(LengthUnits_t) *length, CGNS_ENUMT(TimeUnits_t) *time, @@ -12386,6 +15463,19 @@ int cg_units_read(CGNS_ENUMT(MassUnits_t) *mass, return CG_OK; } +/** + * \ingroup DimensionalUnits + * + * \brief Write first five dimensional units + * + * \param[in] mass Mass units. Admissible values are CG_Null, CG_UserDefined, Kilogram, Gram, Slug, and PoundMass. + * \param[in] length Length units. Admissible values are CG_Null, CG_UserDefined, Meter, Centimeter, Millimeter, Foot, and Inch. + * \param[in] time Time units. Admissible values are CG_Null, CG_UserDefined, and Second. + * \param[in] temperature Temperature units. Admissible values are CG_Null, CG_UserDefined, Kelvin, Celsius, Rankine, and Fahrenheit. + * \param[in] angle Angle units. Admissible values are CG_Null, CG_UserDefined, Degree, and Radian. + * + * \return \ier + */ int cg_units_write(CGNS_ENUMT(MassUnits_t) mass, CGNS_ENUMT(LengthUnits_t) length, CGNS_ENUMT(TimeUnits_t) time, @@ -12444,6 +15534,21 @@ int cg_units_write(CGNS_ENUMT(MassUnits_t) mass, return CG_OK; } +/** + * \ingroup DimensionalUnits + * + * \brief Read all eight dimensional units + * + * \param[out] mass Mass units. Admissible values are CG_Null, CG_UserDefined, Kilogram, Gram, Slug, and PoundMass. + * \param[out] length Length units. Admissible values are CG_Null, CG_UserDefined, Meter, Centimeter, Millimeter, Foot, and Inch. + * \param[out] time Time units. Admissible values are CG_Null, CG_UserDefined, and Second. + * \param[out] temperature Temperature units. Admissible values are CG_Null, CG_UserDefined, Kelvin, Celsius, Rankine, and Fahrenheit. + * \param[out] angle Angle units. Admissible values are CG_Null, CG_UserDefined, Degree, and Radian. + * \param[out] current Electric current units. Admissible values are CG_Null, CG_UserDefined, Ampere, Abampere, Statampere, Edison, and auCurrent. + * \param[out] amount Substance amount units. Admissible values are CG_Null, CG_UserDefined, Mole, Entities, StandardCubicFoot, and StandardCubicMeter. + * \param[out] intensity Luminous intensity units. Admissible values are CG_Null, CG_UserDefined, Candela, Candle, Carcel, Hefner, and Violle. + * \return \ier + */ int cg_unitsfull_read(CGNS_ENUMT(MassUnits_t) *mass, CGNS_ENUMT(LengthUnits_t) *length, CGNS_ENUMT(TimeUnits_t) *time, @@ -12475,6 +15580,22 @@ int cg_unitsfull_read(CGNS_ENUMT(MassUnits_t) *mass, return CG_OK; } +/** + * \ingroup DimensionalUnits + * + * \brief Write all eight dimensional units + * + * \param[in] mass Mass units. Admissible values are CG_Null, CG_UserDefined, Kilogram, Gram, Slug, and PoundMass. + * \param[in] length Length units. Admissible values are CG_Null, CG_UserDefined, Meter, Centimeter, Millimeter, Foot, and Inch. + * \param[in] time Time units. Admissible values are CG_Null, CG_UserDefined, and Second. + * \param[in] temperature Temperature units. Admissible values are CG_Null, CG_UserDefined, Kelvin, Celsius, Rankine, and Fahrenheit. + * \param[in] angle Angle units. Admissible values are CG_Null, CG_UserDefined, Degree, and Radian. + * \param[in] current Electric current units. Admissible values are CG_Null, CG_UserDefined, Ampere, Abampere, Statampere, Edison, and auCurrent. + * \param[in] amount Substance amount units. Admissible values are CG_Null, CG_UserDefined, Mole, Entities, StandardCubicFoot, and StandardCubicMeter. + * \param[in] intensity Luminous intensity units. Admissible values are CG_Null, CG_UserDefined, Candela, Candle, Carcel, Hefner, and Violle. + * + * \return \ier + */ int cg_unitsfull_write(CGNS_ENUMT(MassUnits_t) mass, CGNS_ENUMT(LengthUnits_t) length, CGNS_ENUMT(TimeUnits_t) time, @@ -12553,6 +15674,13 @@ int cg_unitsfull_write(CGNS_ENUMT(MassUnits_t) mass, /*----------------------------------------------------------------------*/ +/** + * \ingroup DimensionalExponents + * + * \brief Get exponent data type + * \param[out] DataType Data type in which the exponents are recorded. Admissible data types for the exponents are RealSingle and RealDouble. + * \return \ier + */ int cg_exponents_info(CGNS_ENUMT(DataType_t) *DataType) { cgns_exponent *exponent; @@ -12570,6 +15698,13 @@ int cg_exponents_info(CGNS_ENUMT(DataType_t) *DataType) return CG_OK; } +/** + * \ingroup DimensionalExponents + * + * \brief Get number of dimensional exponents + * \param[out] numexp Number of exponents used in the file (i.e., either 5 or 8). + * \return \ier + */ int cg_nexponents(int *numexp) { cgns_exponent *exponent; @@ -12587,6 +15722,15 @@ int cg_nexponents(int *numexp) return CG_OK; } +/** + * \ingroup DimensionalExponents + * + * \brief Read first five dimensional exponents + * \param[out] exponents Exponents for the dimensional units for mass, length, time, temperature, angle, electric current, substance amount, and luminous intensity, in that order. + * \return \ier + * + * \details When reading exponent data, either cg_exponents_read or cg_expfull_read may be used, regardless of the number of exponents used in the file. If cg_exponents_read is used, but all eight exponents are used in the file, only the first five exponents are returned. If cg_expfull_read is used, but only five exponents are used in the file, the returned values of the exponents for electric current, substance amount, and luminous intensity will be zero. + */ int cg_exponents_read(void *exponents) { cgns_exponent *exponent; @@ -12617,6 +15761,15 @@ int cg_exponents_read(void *exponents) return CG_OK; } + +/** + * \ingroup DimensionalExponents + * + * \brief Write first five dimensional exponents + * \param[in] DataType Data type in which the exponents are recorded. Admissible data types for the exponents are RealSingle and RealDouble. + * \param[in] exponents Exponents for the dimensional units for mass, length, time, temperature, angle, electric current, substance amount, and luminous intensity, in that order. + * \return \ier + */ int cg_exponents_write(CGNS_ENUMT(DataType_t) DataType, const void * exponents) { cgns_exponent *exponent; @@ -12666,6 +15819,15 @@ int cg_exponents_write(CGNS_ENUMT(DataType_t) DataType, const void * exponents) return CG_OK; } +/** + * \ingroup DimensionalExponents + * + * \brief Read all eight dimensional exponents + * \param[out] exponents Exponents for the dimensional units for mass, length, time, temperature, angle, electric current, substance amount, and luminous intensity, in that order. + * \return \ier + * + * \details When reading exponent data, either cg_exponents_read or cg_expfull_read may be used, regardless of the number of exponents used in the file. If cg_exponents_read is used, but all eight exponents are used in the file, only the first five exponents are returned. If cg_expfull_read is used, but only five exponents are used in the file, the returned values of the exponents for electric current, substance amount, and luminous intensity will be zero. + */ int cg_expfull_read(void *exponents) { cgns_exponent *exponent; @@ -12723,6 +15885,14 @@ int cg_expfull_read(void *exponents) return CG_OK; } +/** + * \ingroup DimensionalExponents + * + * \brief Write all eight dimensional exponents + * \param[in] DataType Data type in which the exponents are recorded. Admissible data types for the exponents are RealSingle and RealDouble. + * \param[in] exponents Exponents for the dimensional units for mass, length, time, temperature, angle, electric current, substance amount, and luminous intensity, in that order. + * \return \ier + */ int cg_expfull_write(CGNS_ENUMT(DataType_t) DataType, const void * exponents) { cgns_exponent *exponent; @@ -12779,7 +15949,13 @@ int cg_expfull_write(CGNS_ENUMT(DataType_t) DataType, const void * exponents) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup DataConversionFactors + * + * \brief Get conversion factors data type + * \param[out] DataType Data type in which the conversion factors are recorded. Admissible data types for the exponents are RealSingle and RealDouble. + * \return \ier + */ int cg_conversion_info(CGNS_ENUMT(DataType_t) *DataType) { cgns_conversion *conversion; @@ -12797,6 +15973,20 @@ int cg_conversion_info(CGNS_ENUMT(DataType_t) *DataType) return CG_OK; } +/** + * \ingroup DataConversionFactors + * + * \brief Read conversion factors + * \param[out] ConversionFactors Two-element array containing the scaling and offset factors. + * \return \ier + * + * \details The DataConversion_t data structure contains factors to convert the nondimensional data to "raw" dimensional data. The scaling and offset factors are contained in the two-element array ConversionFactors. In pseudo-Fortran, the conversion process is as follows: + + ConversionScale = ConversionFactors(1) + ConversionOffset = ConversionFactors(2) + Data(raw) = Data(nondimensional)*ConversionScale + ConversionOffset + + */ int cg_conversion_read(void *ConversionFactors) { cgns_conversion *conversion; @@ -12821,6 +16011,14 @@ int cg_conversion_read(void *ConversionFactors) return CG_OK; } +/** + * \ingroup DataConversionFactors + * + * \brief Write conversion factors + * \param[in] DataType Data type in which the conversion factors are recorded. Admissible data types for the exponents are RealSingle and RealDouble. + * \param[in] ConversionFactors Two-element array containing the scaling and offset factors. + * \return \ier + */ int cg_conversion_write(CGNS_ENUMT(DataType_t) DataType, const void * ConversionFactors) { @@ -12868,7 +16066,23 @@ int cg_conversion_write(CGNS_ENUMT(DataType_t) DataType, } /*----------------------------------------------------------------------*/ +/** + * \ingroup DataClass + * + * \brief Read data class + * \param[out] dataclass Data class for the nodes at this level. See below for the data classes currently supported in CGNS. + * \return \ier + * + * \details The data classes currently supported in CGNS are: + + Dimensional Regular dimensional data. + NormalizedByDimensional Nondimensional data that is normalized by dimensional reference quantities. + NormalizedByUnknownDimensional All fields and reference data are nondimensional. + NondimensionalParameter Nondimensional parameters such as Mach number and lift coefficient. + DimensionlessConstant Constant such as Ï€. +These classes are declared within typedef DataClass_t in cgnslib.h, and as parameters in cgnslib_f.h. + */ int cg_dataclass_read(CGNS_ENUMT(DataClass_t) *dataclass) { CGNS_ENUMT(DataClass_t) *DataClass; @@ -12887,6 +16101,23 @@ int cg_dataclass_read(CGNS_ENUMT(DataClass_t) *dataclass) return CG_OK; } +/** + * \ingroup DataClass + * + * \brief Write data class + * \param[in] dataclass Data class for the nodes at this level. See below for the data classes currently supported in CGNS. + * \return \ier + * + * \details The data classes currently supported in CGNS are: + + Dimensional Regular dimensional data. + NormalizedByDimensional Nondimensional data that is normalized by dimensional reference quantities. + NormalizedByUnknownDimensional All fields and reference data are nondimensional. + NondimensionalParameter Nondimensional parameters such as Mach number and lift coefficient. + DimensionlessConstant Constant such as Ï€. + +These classes are declared within typedef DataClass_t in cgnslib.h, and as parameters in cgnslib_f.h. + */ int cg_dataclass_write(CGNS_ENUMT(DataClass_t) dataclass) { CGNS_ENUMT(DataClass_t) *DataClass; @@ -12910,7 +16141,14 @@ int cg_dataclass_write(CGNS_ENUMT(DataClass_t) dataclass) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup GridLocation + * + * \brief Read grid location + * \param[out] GridLocation Location in the grid. The admissible locations are CG_Null, CG_UserDefined, Vertex, CellCenter, FaceCenter, IFaceCenter, JFaceCenter, KFaceCenter, and EdgeCenter. + * \return \ier + * + */ int cg_gridlocation_read(CGNS_ENUMT(GridLocation_t) *GridLocation) { CGNS_ENUMT(GridLocation_t) *location; @@ -12940,6 +16178,14 @@ int cg_gridlocation_read(CGNS_ENUMT(GridLocation_t) *GridLocation) return CG_OK; } +/** + * \ingroup GridLocation + * + * \brief Write grid location + * \param[in] GridLocation Location in the grid. The admissible locations are CG_Null, CG_UserDefined, Vertex, CellCenter, FaceCenter, IFaceCenter, JFaceCenter, KFaceCenter, and EdgeCenter. + * \return \ier + * + */ int cg_gridlocation_write(CGNS_ENUMT(GridLocation_t) GridLocation) { CGNS_ENUMT(GridLocation_t) *location; @@ -13023,6 +16269,14 @@ int cg_gridlocation_write(CGNS_ENUMT(GridLocation_t) GridLocation) /*----------------------------------------------------------------------*/ +/** + * \ingroup OrdinalValue + * + * \brief Read ordinal value + * \param[out] Ordinal Any integer value. + * \return \ier + * + */ int cg_ordinal_read(int *Ordinal) { int *ordinal; @@ -13040,6 +16294,14 @@ int cg_ordinal_read(int *Ordinal) return CG_OK; } +/** + * \ingroup OrdinalValue + * + * \brief Write ordinal value + * \param[in] Ordinal Any integer value. + * \return \ier + * + */ int cg_ordinal_write(int Ordinal) { int *ordinal; @@ -13063,7 +16325,14 @@ int cg_ordinal_write(int Ordinal) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup Links + * + * \brief Test if a node is a link + * \param[out] path_length Length of the path name of the linked node. The value 0 is returned if the node is not a link + * \return \ier + * + */ int cg_is_link(int *path_length) { double posit_id; @@ -13086,6 +16355,19 @@ int cg_is_link(int *path_length) return CG_OK; } +/** + * \ingroup Links + * + * \brief Get path information for a link at the current location + * \param[out] filename Name of the linked file, or empty string if the link is within the same file. + * \param[out] link_path Path name of the node which the link points to. + * + * \return \ier + * + * \details Use cg_goto(_f) to position to a location in the file prior to calling these routines. + * Memory is allocated by the library for the return values of the C function cg_link_read. This memory should be freed by the user when no longer needed by calling cg_free(filename) and cg_free(link_path). + * + */ int cg_link_read(char **filename, char **link_path) { int name_len, file_len; @@ -13115,6 +16397,26 @@ int cg_link_read(char **filename, char **link_path) return CG_OK; } +/** + * \ingroup Links + * + * \brief Create a link at the current location + * + * \param[in] nodename Name of the link node to create, e.g., GridCoordinates. + * \param[in] filename Name of the linked file, or empty string if the link is within the same file. + * \param[in] name_in_file Path name of the node which the link points to. This can be a simple or a compound name, e.g., Base/Zone 1/GridCoordinates. + * + * \return \ier + * + * \details Use cg_goto(_f) to position to a location in the file prior to calling these routines. + +When using cg_link_write, the node being linked to does not have to exist when the link is created. However, when the link is used, an error will occur if the linked-to node does not exist. + +Only nodes that support child nodes will support links. + +It is assumed that the CGNS version for the file containing the link, as determined by the CGNSLibraryVersion_t node, is also applicable to filename, the file containing the linked node. + * + */ int cg_link_write(const char * nodename, const char * filename, const char * name_in_file) { double posit_id, link_id; @@ -13199,7 +16501,26 @@ int cg_link_write(const char * nodename, const char * filename, const char * nam } /*----------------------------------------------------------------------*/ - +/** + * \ingroup UserDefinedData + * + * + * \brief Get number of UserDefinedData_t nodes + * + * \param[out] nuser_data Number of UserDefinedData_t nodes under current node. + * + * \return \ier + * + * \details After accessing a particular UserDefinedData_t node using cg_goto, + * the Point Set functions may be used to read or write point set information for the node. + * The function cg_gridlocation_write may also be used to specify the location of the data with respect to the grid (e.g., Vertex or FaceCenter). + * + * Multiple levels of UserDefinedData_t nodes may be written and retrieved by positioning via cg_goto. E.g., + * + * ier = cg_goto(fn, B, "Zone_t", Z, "UserDefinedData_t", ud1, + * "UserDefinedData_t", ud2, "UserDefinedData_t", ud3, "end"); + * + */ int cg_nuser_data(int *nuser_data) { @@ -13320,6 +16641,18 @@ int cg_nuser_data(int *nuser_data) return CG_OK; } +/** + * \ingroup UserDefinedData + * + * + * \brief Get name of an UserDefinedData_t node + * + * \param[in] Index User-defined data index number, where 1 ≤ Index ≤ nuser_data. + * \param[out] UserDataName Name of the UserDefinedData_t node. + * + * \return \ier + * + */ int cg_user_data_read(int Index, char *UserDataName) { int ier=0; @@ -13338,6 +16671,17 @@ int cg_user_data_read(int Index, char *UserDataName) return CG_OK; } +/** + * \ingroup UserDefinedData + * + * + * \brief Create UserDefinedData_t node + * + * \param[in] UserDataName Name of the UserDefinedData_t node. + * + * \return \ier + * + */ int cg_user_data_write(const char * UserDataName) { cgns_user_data *user_data; @@ -13369,7 +16713,18 @@ int cg_user_data_write(const char * UserDataName) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup RotatingCoordinates + * + * + * \brief Read rotating coordinates data + * + * \param[out] rot_rate Components of the angular velocity of the grid about the center of rotation. (In Fortran, this is an array of Real*4 values.) + * \param[out] rot_center Coordinates of the center of rotation. (In Fortran, this is an array of Real*4 values.) + * + * \return \ier + * + */ int cg_rotating_read(float *rot_rate, float *rot_center) { cgns_rotating *rotating; @@ -13400,6 +16755,18 @@ int cg_rotating_read(float *rot_rate, float *rot_center) return CG_OK; } +/** + * \ingroup RotatingCoordinates + * + * + * \brief Create rotating coordinates data + * + * \param[in] rot_rate Components of the angular velocity of the grid about the center of rotation. (In Fortran, this is an array of Real*4 values.) + * \param[in] rot_center Coordinates of the center of rotation. (In Fortran, this is an array of Real*4 values.) + * + * \return \ier + * + */ int cg_rotating_write(float const *rot_rate, float const *rot_center) { cgns_rotating *rotating; @@ -13469,7 +16836,18 @@ int cg_rotating_write(float const *rot_rate, float const *rot_center) } /*----------------------------------------------------------------------*/ - +/** + * \ingroup PointSets + * + * + * \brief Get point set information + * + * \param[out] ptset_type The point set type; either PointRange for a range of points or cells, or PointList for a list of discrete points or cells. + * \param[out] npnts The number of points or cells in the point set. For a point set type of PointRange, npnts is always two. For a point set type of PointList, npnts is the number of points or cells in the list. + * + * \return \ier + * + */ int cg_ptset_info(CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts) { cgns_ptset *ptset; @@ -13490,6 +16868,17 @@ int cg_ptset_info(CGNS_ENUMT(PointSetType_t) *ptset_type, cgsize_t *npnts) return CG_OK; } +/** + * \ingroup PointSets + * + * + * \brief Read point set data + * + * \param[out] pnts The array of point or cell indices defining the point set. There should be npnts values, each of dimension IndexDimension (i.e., 1 for unstructured grids, and 2 or 3 for structured grids with 2-D or 3-D elements, respectively). + * + * \return \ier + * + */ int cg_ptset_read(cgsize_t *pnts) { cgns_ptset *ptset; @@ -13517,6 +16906,19 @@ int cg_ptset_read(cgsize_t *pnts) return CG_OK; } +/** + * \ingroup PointSets + * + * + * \brief Write point set data + * + * \param[in] ptset_type The point set type; either PointRange for a range of points or cells, or PointList for a list of discrete points or cells. + * \param[in] npnts The number of points or cells in the point set. For a point set type of PointRange, npnts is always two. For a point set type of PointList, npnts is the number of points or cells in the list. + * \param[in] pnts The array of point or cell indices defining the point set. There should be npnts values, each of dimension IndexDimension (i.e., 1 for unstructured grids, and 2 or 3 for structured grids with 2-D or 3-D elements, respectively). + * + * \return \ier + * + */ int cg_ptset_write(CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, const cgsize_t * pnts) { @@ -13605,6 +17007,17 @@ int cg_ptset_write(CGNS_ENUMT(PointSetType_t) ptset_type, cgsize_t npnts, * Read and write FamilyBCDataSet_t nodes \*****************************************************************************/ +/** + * \ingroup BoundaryConditionDatasets + * + * + * \brief Get number of family boundary condition datasets + * + * \param[out] n_dataset Number of BCDataSet nodes under the current FamilyBC_t node. + * \return \ier + * + * \details The above functions are applicable to BCDataSet_t nodes that are used to define boundary conditions for a CFD family, and thus are children of a FamilyBC_t node. The FamilyBC_t node must first be accessed using cg_goto. + */ int cg_bcdataset_info(int *n_dataset) { CHECK_FILE_OPEN @@ -13628,6 +17041,22 @@ int cg_bcdataset_info(int *n_dataset) return CG_OK; } + +/** + * \ingroup BoundaryConditionDatasets + * + * + * \brief Read family boundary condition dataset info + * + * \param[in] index Dataset index number, where 1 ≤ index ≤ ndataset. + * \param[out] name Name of dataset. + * \param[out] BCType Simple boundary condition type for the dataset. The supported types are listed in the table of Simple Boundary Condition Types in the SIDS manual, but note that FamilySpecified does not apply here. + * \param[out] DirichletFlag Flag indicating if the dataset contains Dirichlet data. + * \param[out] NeumannFlag Flag indicating if the dataset contains Neumann data. + * \return \ier + * + * \details The above functions are applicable to BCDataSet_t nodes that are used to define boundary conditions for a CFD family, and thus are children of a FamilyBC_t node. The FamilyBC_t node must first be accessed using cg_goto. + */ int cg_bcdataset_read(int index, char *name, CGNS_ENUMT(BCType_t) *BCType, int *DirichletFlag, int *NeumannFlag) { @@ -13651,6 +17080,21 @@ int cg_bcdataset_read(int index, char *name, CGNS_ENUMT(BCType_t) *BCType, return CG_OK; } + +/** + * \ingroup BoundaryConditionDatasets + * + * + * \brief Write family boundary condition dataset info + * + * \param[in] name Name of dataset. + * \param[in] BCType Simple boundary condition type for the dataset. The supported types are listed in the table of Simple Boundary Condition Types in the SIDS manual, but note that FamilySpecified does not apply here. + * \param[in] BCDataType Type of boundary condition in the dataset (i.e., for a BCData_t child node). Admissible types are Dirichlet and Neumann. + * \return \ier + * + * \details The above functions are applicable to BCDataSet_t nodes that are used to define boundary conditions for a CFD family, and thus are children of a FamilyBC_t node. The FamilyBC_t node must first be accessed using cg_goto. + * The first time cg_bcdataset_write is called with a particular DatasetName, BCType, and BCDataType, a new BCDataSet_t node is created, with a child BCData_t node. Subsequent calls with the same DatasetName and BCType may be made to add additional BCData_t nodes, of type BCDataType, to the existing BCDataSet_t node. + */ int cg_bcdataset_write(const char *name, CGNS_ENUMT(BCType_t) BCType, CGNS_ENUMT(BCDataType_t) BCDataType) { @@ -13771,9 +17215,20 @@ int cg_bcdataset_write(const char *name, CGNS_ENUMT(BCType_t) BCType, } /****************************************************************************/ -/* the index in this list IS the cgnslib.h/ElementType_t index */ +/** + * \ingroup ElementConnectivity + * + * + * \brief Get number of nodes for an element type. + * + * \param[in] type Type of element. See the eligible types for ElementType_t in the Typedefs section. + * \param[out] npe Number of nodes for an element of type type. + * \return \ier + * + */ int cg_npe(CGNS_ENUMT( ElementType_t ) type, int *npe) { +/* the index in this list IS the cgnslib.h/ElementType_t index */ static int el_size[NofValidElementTypes] = { 0, /* ElementTypeNull */ 0, /* ElementTypeUserDefined */ @@ -13904,7 +17359,39 @@ int cg_npe(CGNS_ENUMT( ElementType_t ) type, int *npe) /*****************************************************************************\ * General Delete Function \*****************************************************************************/ - +/** + * \ingroup DeletingANode + * + * \brief Delete a node + * + * \param[in] node_name Name of the child to be deleted. + * \return \ier + * + * \details The function cg_delete_node is used is conjunction with cg_goto. Once positioned at a parent node with cg_goto, a child of this node can be deleted with cg_delete_node. This function requires a single argument, NodeName, which is the name of the child to be deleted. + +Since the highest level that can be pointed to with cg_goto is a base node for a CGNS database (CGNSBase_t), the highest-level nodes that can be deleted are the children of a CGNSBase_t node. In other words, nodes located directly under the ADF (or HDF) root node (CGNSBase_t and CGNSLibraryVersion_t) can not be deleted with cg_delete. + +A few other nodes are not allowed to be deleted from the database because these are required nodes as defined by the SIDS, and deleting them would make the file non-CGNS compliant. These are: + + Under Zone_t: ZoneType + Under GridConnectivity1to1_t: PointRange, PointRangeDonor, Transform + Under OversetHoles_t: PointList and any IndexRange_t + Under GridConnectivity_t: PointRange, PointList, CellListDonor, PointListDonor + Under BC_t: PointList, PointRange + Under GeometryReference_t: GeometryFile, GeometryFormat + Under Elements_t: ElementRange, ElementConnectivity + Under Gravity_t: GravityVector + Under Axisymmetry_t: AxisymmetryReferencePoint, AxisymmetryAxisVector + Under RotatingCoordinates_t: RotationCenter, RotationRateVector + Under Periodic_t: RotationCenter, RotationAngle, Translation + Under AverageInterface_t: AverageInterfaceType + Under WallFunction_t: WallFunctionType + Under Area_t: AreaType, SurfaceArea, RegionName + +When a child node is deleted, both the database and the file on disk are updated to remove the node. One must be careful not to delete a node from within a loop of that node type. For example, if the number of zones below a CGNSBase_t node is nzones, a zone should never be deleted from within a zone loop! By deleting a zone, the total number of zones (nzones) changes, as well as the zone indexing. Suppose for example that nzones is 5, and that the third zone is deleted. After calling cg_delete_node, nzones is changed to 4, and the zones originally indexed 4 and 5 are now indexed 3 and 4. + * + * + */ int cg_delete_node(const char *node_name) { int n, m, index_dim; @@ -14797,7 +18284,19 @@ int cg_delete_node(const char *node_name) /*****************************************************************************\ * Free library malloced memory \*****************************************************************************/ +/** + * \ingroup FreeingMemory + * + * \brief Release library-allocated memory + * + * \param[in] data Data allocated by the Mid-Level Library. + * \return \ier + * + * \details This function does not affect the structure of a CGNS file; it is provided as a convenience to free memory allocated by the Mid-Level Library. This isn't necessary in Fortran, and thus an equivalent Fortran function is not provided. +The functions that are used to allocate memory for return values are cg_descriptor_read, cg_convergence_read, cg_geo_read, cg_link_read, and cg_state_read. Each of these may allocate space to contain the data returned to the application. It is the responsibility of the application to free this data when it is no longer needed. Calling cg_free is identical to calling the standard C function free, however it is probably safer in that the memory is freed in the same module in which it is created, particularly when the Mid-Level Library is a shared library or DLL. The routine checks for NULL data and will return CG_ERROR in this case, otherwise it returns CG_OK. + * + */ int cg_free(void *data) { if (data != NULL) { CGNS_FREE (data); diff --git a/externals/cgns/cgnslib.h b/externals/cgns/cgnslib.h index f2b3d5c2218..476c7689da1 100644 --- a/externals/cgns/cgnslib.h +++ b/externals/cgns/cgnslib.h @@ -32,16 +32,19 @@ * |_____|_| |_|_| \____/|_| \_\ |_/_/ \_\_| \_| |_| * * ------------------- DEVELOPER'S NOTES --------------------------- + * * (1) When adding a defined constant to this file, also add the same defined * constant to cgns_f.F90 + * + * (2) Fortran length of names for variables is limited to 31 characters. * * ------------------------------------------------------------------------- */ #ifndef CGNSLIB_H #define CGNSLIB_H -#define CGNS_VERSION 4200 -#define CGNS_DOTVERS 4.20 +#define CGNS_VERSION 4400 +#define CGNS_DOTVERS 4.40 #define CGNS_COMPATVERSION 2540 #define CGNS_COMPATDOTVERS 2.54 @@ -129,15 +132,16 @@ #define CG_CONFIG_FILE_TYPE 5 #define CG_CONFIG_RIND_INDEX 6 -#define CG_CONFIG_HDF5_COMPRESS 201 -#define CG_CONFIG_HDF5_MPI_COMM 202 -#define CG_CONFIG_HDF5_DISKLESS 203 -#define CG_CONFIG_HDF5_DISKLESS_INCR 204 -#define CG_CONFIG_HDF5_DISKLESS_WRITE 205 -#define CG_CONFIG_HDF5_ALIGNMENT 206 -#define CG_CONFIG_HDF5_MD_BLOCK_SIZE 207 -#define CG_CONFIG_HDF5_BUFFER 208 -#define CG_CONFIG_HDF5_SIEVE_BUF_SIZE 209 +#define CG_CONFIG_HDF5_COMPRESS 201 +#define CG_CONFIG_HDF5_MPI_COMM 202 +#define CG_CONFIG_HDF5_DISKLESS 203 +#define CG_CONFIG_HDF5_DISKLESS_INCR 204 +#define CG_CONFIG_HDF5_DISKLESS_WRITE 205 +#define CG_CONFIG_HDF5_ALIGNMENT 206 +#define CG_CONFIG_HDF5_MD_BLOCK_SIZE 207 +#define CG_CONFIG_HDF5_BUFFER 208 +#define CG_CONFIG_HDF5_SIEVE_BUF_SIZE 209 +#define CG_CONFIG_HDF5_ELINK_CACHE_SIZE 210 #define CG_CONFIG_RESET 1000 diff --git a/externals/cgns/pcgnslib.c b/externals/cgns/pcgnslib.c index 1acc54a5b30..90079fd9f29 100644 --- a/externals/cgns/pcgnslib.c +++ b/externals/cgns/pcgnslib.c @@ -17,6 +17,14 @@ freely, subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------*/ +/** + * \defgroup ParallelMisc Parallel Miscellaneous Routines + * \defgroup ParallelFile Parallel File Operations + * \defgroup ParallelGridCoordinate Parallel Grid Coordinate Data + * \defgroup ElementConnectivityData Parallel Element Connectivity Data + * \defgroup SolutionData Parallel Solution Data + * \defgroup ArrayData Parallel Array Data + **/ #include #include @@ -48,6 +56,13 @@ typedef struct cg_rw_t { } u; } cg_rw_t; +typedef struct cg_rw__ptr_t { + union { + void **rbuf; /* Pointer to buffer for read */ + const void **wbuf; /* Pointer to buffer to write */ + } u; +} cg_rw_ptr_t; + /* flag for parallel reading or parallel writing */ enum cg_par_rw{ CG_PAR_READ, @@ -358,6 +373,15 @@ static int check_parallel(cgns_file *cgfile) /*== Begin Function Definitions ==*/ /*================================*/ +/** + * \ingroup ParallelMisc + * + * \brief Set the MPI communicator. + * + * \param[in] comm The MPI communicator to be used by the CGNS library. + * \details Sets the MPI communicator for parallel operations by the CGNS library. The default value is MPI_COMM_WORLD. + * \return \ier + */ int cgp_mpi_comm(MPI_Comm comm) { /* check if we are actually running a parallel program */ @@ -378,7 +402,15 @@ int cgp_mpi_comm(MPI_Comm comm) return ctx_cgio.pcg_mpi_initialized ? CG_OK : CG_ERROR; } - +/** + * \ingroup ParallelMisc + * + * \brief Set the MPI info object. + * + * \param[in] info The MPI info object to be used by the CGNS library. + * \return \ier + * \details Passes the MPI info object for parallel operations to the CGNS library. Notes for Fortran: the data type for info is an INTEGER. + */ int cgp_mpi_info(MPI_Info info) { ctx_cgio.pcg_mpi_info = info; @@ -387,7 +419,16 @@ int cgp_mpi_info(MPI_Info info) } /*---------------------------------------------------------*/ - +/** + * \ingroup ParallelMisc + * + * \brief Set the parallel IO mode. + * + * \param[in] mode Parallel input/output mode. + * \return \ier + * \details Sets the mode for parallel data reads and writes. The default value is \p CGP_COLLECTIVE, which allows any number of processes to access the data. + * When set to \p CGP_COLLECTIVE, all processes must access the data. + */ int cgp_pio_mode(CGNS_ENUMT(PIOmode_t) mode) { if (mode == CGP_INDEPENDENT) @@ -404,6 +445,14 @@ int cgp_pio_mode(CGNS_ENUMT(PIOmode_t) mode) /*---------------------------------------------------------*/ +/** + * \ingroup ParallelMisc + * + * \brief Exit with error message. + * + * \details Is similar to \e cg_error_exit in that the process will exit with an error message. + * However, it will also print the process rank, and call \p MPI_Abort with an exit code of 1. + */ void cgp_error_exit(void) { @@ -416,6 +465,17 @@ void cgp_error_exit(void) } /*===== File IO Prototypes ================================*/ +/** + * \ingroup ParallelFile + * + * \brief Open a file for parallel IO. + * + * \param[in] filename \FILE_filename + * \param[in] mode \FILE_mode + * \param[out] fn \FILE_fn + * \return \ier + * \details Similar to \e cg_open and calls that routine. The differences is that \e cgp_open explicitly sets an internal CGNS flag to indicate parallel access. + */ int cgp_open(const char *filename, int mode, int *fn) { @@ -439,7 +499,15 @@ int cgp_open(const char *filename, int mode, int *fn) } /*---------------------------------------------------------*/ - +/** + * \ingroup ParallelFile + * + * \brief Close a CGNS file. + * + * \param[in] fn \FILE_fn + * \return \ier + * \details Similar to \e cg_close and calls that routine. + */ int cgp_close(int fn) { /* reset parallel access */ @@ -448,6 +516,22 @@ int cgp_close(int fn) } /*===== Grid IO Prototypes ================================*/ +/** + * \ingroup ParallelGridCoordinate + * + * \brief Create a coordinate data node by multiple processes in a parallel fashion. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] type \PGRID_datatype + * \param[in] coordname \PGRID_coordname + * \param[out] C \PGRID_Coordinate + * \return \ier + * \details To write the data in parallel, first call /e cgp_coord_write to create an empty data node. This call is identical + * to /e cg_coord_write with /p coord_array set to NULL (no data written). The actual data is then written to the node in parallel + * using either /e cgp_coord_write_data or /e cgp_coord_general_write_data where /p range_min and /p range_max specify the subset of coordinate data to be written by a given process. + */ int cgp_coord_write(int fn, int B, int Z, CGNS_ENUMT(DataType_t) type, const char *coordname, int *C) @@ -459,6 +543,24 @@ int cgp_coord_write(int fn, int B, int Z, CGNS_ENUMT(DataType_t) type, } /*---------------------------------------------------------*/ +/** + * \ingroup ParallelGridCoordinate + * + * \brief Write coordinate data in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] C \C_Coordinate + * \param[in] rmin \PGRID_range_min + * \param[in] rmax \PGRID_range_max + * \param[in] coords \PGRID_coord_array + * \return \ier + * \details Writes the actual data to the node in parallel, where /p rmin and /p rmax specify the subset + * of coordinate data to be written by a given process. It is the + * responsibility of the application to ensure that the data type for the coordinate data + * matches that as defined in the file; no conversions are done. + */ int cgp_coord_write_data(int fn, int B, int Z, int C, const cgsize_t *rmin, const cgsize_t *rmax, const void *coords) @@ -509,10 +611,29 @@ int cgp_coord_write_data(int fn, int B, int Z, int C, } /*---------------------------------------------------------*/ +/** + * \ingroup ParallelGridCoordinate + * + * \brief Write shaped array to a subset of grid coordinates in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] C \PGRID_Coordinate + * \param[in] rmin \PGRID_range_min + * \param[in] rmax \PGRID_range_max + * \param[in] m_type \PGRID_mem_datatype + * \param[in] m_numdim \PGRID_mem_rank + * \param[in] m_arg_dimvals \PGRID_mem_dimensions + * \param[in] m_rmin \PGRID_mem_range_min + * \param[in] m_rmax \PGRID_mem_range_max + * \param[out] coords \PGRID_coord_array + * \return \ier + * \details The \e cgp_coord_general_write_data perform data conversions if \e datatype is different from \e mem_datatype. If \e coords == NULL, meaning + * this processor writes no data, then only \e fn, \e B, \e Z, and \e C need be set. In this case, \e Z and \e C are "representative" + * and can point to any valid zone. + */ -/* Note: if data == NULL, meaning this processor reads no data, then - only fn, B, Z, and C need be set. In this case, Z and C are "representative" - and can point to any valid zone */ int cgp_coord_general_write_data(int fn, int B, int Z, int C, const cgsize_t *rmin, const cgsize_t *rmax, CGNS_ENUMT(DataType_t) m_type, @@ -598,6 +719,24 @@ int cgp_coord_general_write_data(int fn, int B, int Z, int C, } /*---------------------------------------------------------*/ +/** + * \ingroup ParallelGridCoordinate + * + * \brief Read coordinate data in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] C \C_Coordinate + * \param[in] rmin \PGRID_range_min + * \param[in] rmax \PGRID_range_max + * \param[out] coords \PGRID_coord_array + * \return \ier + * \details Reads the actual data to the node in parallel, where /p rmin and /p rmax specify the subset + * of coordinate data to be read by a given process. It is the + * responsibility of the application to ensure that the data type for the coordinate data + * matches that as defined in the file; no conversions are done. + */ int cgp_coord_read_data(int fn, int B, int Z, int C, const cgsize_t *rmin, const cgsize_t *rmax, void *coords) @@ -647,10 +786,29 @@ int cgp_coord_read_data(int fn, int B, int Z, int C, } /*---------------------------------------------------------*/ +/** + * \ingroup ParallelGridCoordinate + * + * \brief Read shaped array to a subset of grid coordinates in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] C \C_Coordinate + * \param[in] rmin \PGRID_range_min + * \param[in] rmax \PGRID_range_max + * \param[in] m_type \PGRID_mem_datatype + * \param[in] m_numdim \PGRID_mem_rank + * \param[in] m_arg_dimvals \PGRID_mem_dimensions + * \param[in] m_rmin \PGRID_mem_range_min + * \param[in] m_rmax \PGRID_mem_range_max + * \param[out] coords \PGRID_coord_array + * \return \ier + * \details The \e cgp_coord_general_read_data perform data conversions if \e datatype is different from \e mem_datatype. If \e coords == NULL, meaning + * this processor reads no data, then only \e fn, \e B, \e Z, and \e C need be set. In this case, \e Z and \e C are "representative" + * and can point to any valid zone. + */ -/* Note: if data == NULL, meaning this processor reads no data, then - only fn, B, Z, and C need be set. In this case, Z and C are "representative" - and can point to any valid zone */ int cgp_coord_general_read_data(int fn, int B, int Z, int C, const cgsize_t *rmin, const cgsize_t *rmax, CGNS_ENUMT(DataType_t) m_type, @@ -736,6 +894,28 @@ int cgp_coord_general_read_data(int fn, int B, int Z, int C, } /*===== Elements IO Prototypes ============================*/ +/* TODO: ref. cg_section_write + Add somewhere: (Note that for Fortran calls, all integer arguments are integer*4 in 32-bit mode and integer*8 in 64-bit mode. See 64-bit Fortran Portability and Issues.) +*/ +/** + * \ingroup ElementConnectivityData + * + * \brief Create a section data node. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] sectionname \PCONN_ElementSectionName + * \param[in] type \PCONN_type + * \param[in] start \PCONN_start + * \param[in] end \PCONN_end + * \param[in] nbndry \PCONN_nbndry + * \param[out] S \CONN_S + * \return \ier + * \details \p cgp_section_write is used to write element connectivity data by multiple processes in a parallel fashion. To write the element data in parallel, first call \e cgp_section_write to create an empty data node. This call is identical to \e cg_section_write with \e Elements set to \e NULL (no data written). The actual element data is then written to the node in parallel using \p cgp_element_write_data where \e start and \e end specify the range of the elements to be written by a given process. + * NOTE (1): Routine only works for constant sized elements, since it is not possible to compute file offsets for variable sized elements without knowledge of the entire element connectivity data. + * NOTE (2): It is the responsibility of the application to ensure that \e cgsize_t in the application is the same size as that defined in the file; no conversions are done. + */ int cgp_section_write(int fn, int B, int Z, const char *sectionname, CGNS_ENUMT(ElementType_t) type, cgsize_t start, cgsize_t end, @@ -751,19 +931,31 @@ int cgp_section_write(int fn, int B, int Z, const char *sectionname, return cg_section_partial_write(fn, B, Z, sectionname, type, start, end, nbndry, S); } +/** + * \ingroup ElementConnectivityData + * + * \brief Create a section data node. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] sectionname \PCONN_ElementSectionName + * \param[in] type \PCONN_type + * \param[in] start \PCONN_start + * \param[in] end \PCONN_end + * \param[in] maxoffset \PCONN_MaxOffset + * \param[in] nbndry \PCONN_nbndry + * \param[out] S \CONN_S + * \return \ier + * \details \p cgp_poly_section_write is used to write element connectivity data by multiple processes in a parallel fashion. To write the element data in parallel, first call \e cgp_section_write to create an empty data node. This call is identical to \e cg_section_write with \e Elements set to \e NULL (no data written). The actual element data is then written to the node in parallel using \p cgp_element_write_data where \e start and \e end specify the range of the elements to be written by a given process. + * NOTE (1): Routine only works for constant sized elements, since it is not possible to compute file offsets for variable sized elements without knowledge of the entire element connectivity data. + * NOTE (2): It is the responsibility of the application to ensure that \e cgsize_t in the application is the same size as that defined in the file; no conversions are done. + */ int cgp_poly_section_write(int fn, int B, int Z, const char *sectionname, CGNS_ENUMT(ElementType_t) type, cgsize_t start, cgsize_t end, cgsize_t maxoffset, int nbndry, int *S) { - cgns_zone *zone; - cgns_section *section = NULL; - double dummy_id; - int index; - int data[2]; - cgsize_t dim_vals; - cgsize_t num, ElementDataSize=0; - cg = cgi_get_file(fn); if (check_parallel(cg)) return CG_ERROR; if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) @@ -780,7 +972,23 @@ int cgp_poly_section_write(int fn, int B, int Z, const char *sectionname, } /*---------------------------------------------------------*/ - +/** + * \ingroup ElementConnectivityData + * + * \brief Write element data in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start \PCONN_start + * \param[in] end \PCONN_end + * \param[in] elements \PCONN_Elements + * \return \ier + * \details \p cgp_elements_write_data is used to write element connectivity data by multiple processes in a parallel fashion. To write the element data in parallel, first call \e cgp_section_write to create an empty data node. This call is identical to \e cg_section_write with \e Elements set to \e NULL (no data written). The actual element data is then written to the node in parallel using \p cgp_element_write_data where \e start and \e end specify the range of the elements to be written by a given process. + * NOTE (1): Routine only works for constant sized elements, since it is not possible to compute file offsets for variable sized elements without knowledge of the entire element connectivity data. + * NOTE (2): It is the responsibility of the application to ensure that \e cgsize_t in the application is the same size as that defined in the file; no conversions are done. + */ int cgp_elements_write_data(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const cgsize_t *elements) { @@ -827,7 +1035,21 @@ int cgp_elements_write_data(int fn, int B, int Z, int S, cgsize_t start, } /*---------------------------------------------------------*/ - +/** + * \ingroup ElementConnectivityData + * + * \brief Write element data in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start \PCONN_start + * \param[in] end \PCONN_end + * \param[in] elements \PCONN_Elements + * \param[in] offsets \PCONN_Offsets + * \return \ier + */ int cgp_poly_elements_write_data(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const cgsize_t *elements, const cgsize_t *offsets) { @@ -902,7 +1124,20 @@ int cgp_poly_elements_write_data(int fn, int B, int Z, int S, cgsize_t start, /*---------------------------------------------------------*/ - +/** + * \ingroup ElementConnectivityData + * + * \brief Read element data in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start \PCONN_start + * \param[in] end \PCONN_end + * \param[out] elements \PCONN_Elements + * \return \ier + */ int cgp_elements_read_data(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, cgsize_t *elements) { @@ -946,7 +1181,20 @@ int cgp_elements_read_data(int fn, int B, int Z, int S, cgsize_t start, return readwrite_data_parallel(hid, type, 1, &rmin, &rmax, &Data, CG_PAR_READ); } - +/** + * \ingroup ElementConnectivityData + * + * \brief Write parent info for an element section data in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \CONN_S + * \param[in] start \PCONN_start + * \param[in] end \PCONN_end + * \param[in] parent_data \PCONN_Elements + * \return \ier + */ int cgp_parent_data_write(int fn, int B, int Z, int S, cgsize_t start, cgsize_t end, const cgsize_t *parent_data) @@ -1062,7 +1310,20 @@ int cgp_parent_data_write(int fn, int B, int Z, int S, } /*===== Solution IO Prototypes ============================*/ - +/** + * \ingroup SolutionData + * + * \brief Create a solution field data node in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \PSOL_S + * \param[in] DataType \PSOL_datatype + * \param[in] fieldname \PSOL_fieldname + * \param[in] F \PSOL_F + * \return \ier + */ int cgp_field_write(int fn, int B, int Z, int S, CGNS_ENUMT(DataType_t) DataType, const char *fieldname, int *F) { @@ -1073,13 +1334,27 @@ int cgp_field_write(int fn, int B, int Z, int S, } /*---------------------------------------------------------*/ - +/** + * \ingroup SolutionData + * + * \brief Write field data in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \PSOL_S + * \param[in] F \PSOL_F + * \param[in] rmin \PSOL_range_min + * \param[in] rmax \PSOL_range_max + * \param[in] data \PSOL_solution_array + * \return \ier + */ int cgp_field_write_data(int fn, int B, int Z, int S, int F, const cgsize_t *rmin, const cgsize_t *rmax, const void *data) { int n; hid_t hid; - cgns_array *field; + cgns_array *field = NULL; CGNS_ENUMT(DataType_t) type; cg = cgi_get_file(fn); @@ -1114,9 +1389,29 @@ int cgp_field_write_data(int fn, int B, int Z, int S, int F, /*---------------------------------------------------------*/ -/* Note: if data == NULL, meaning this processor reads no data, then - only fn, B, Z, S, and F need be set. In this case, Z, S, and F are - "representative" and can point to any valid zone */ +/** + * \ingroup SolutionData + * + * \brief Write shaped array to a subset of flow solution field in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \PSOL_S + * \param[in] F \PSOL_F + * \param[in] rmin \PSOL_range_min + * \param[in] rmax \PSOL_range_max + * \param[in] m_type \PSOL_mem_datatype + * \param[in] m_numdim \PSOL_mem_rank + * \param[in] m_arg_dimvals \PSOL_mem_dimensions + * \param[in] m_rmin \PSOL_mem_range_min + * \param[in] m_rmax \PSOL_mem_range_max + * \param[in] data \PSOL_solution_array + * \return \ier + * \details If \e data == NULL, meaning this processor reads no data, then + * only \e fn,\e B, \e Z, \e S, and \e F need be set. In this case, \e Z, \e S, and \e F are + * "representative" and can point to any valid zone. + */ int cgp_field_general_write_data(int fn, int B, int Z, int S, int F, const cgsize_t *rmin, const cgsize_t *rmax, CGNS_ENUMT(DataType_t) m_type, @@ -1127,7 +1422,7 @@ int cgp_field_general_write_data(int fn, int B, int Z, int S, int F, int n, ier; hid_t hid; cgns_sol *sol; - cgns_array *field; + cgns_array *field = NULL; /* get memory addresses */ cg = cgi_get_file(fn); @@ -1198,13 +1493,27 @@ int cgp_field_general_write_data(int fn, int B, int Z, int S, int F, } /*---------------------------------------------------------*/ - +/** + * \ingroup SolutionData + * + * \brief Read field data in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \PSOL_S + * \param[in] F \PSOL_F + * \param[in] rmin \PSOL_range_min + * \param[in] rmax \PSOL_range_max + * \param[in] data \PSOL_solution_array + * \return \ier + */ int cgp_field_read_data(int fn, int B, int Z, int S, int F, const cgsize_t *rmin, const cgsize_t *rmax, void *data) { int n; hid_t hid; - cgns_array *field; + cgns_array *field = NULL; CGNS_ENUMT(DataType_t) type; cg = cgi_get_file(fn); @@ -1238,9 +1547,29 @@ int cgp_field_read_data(int fn, int B, int Z, int S, int F, /*---------------------------------------------------------*/ -/* Note: if data == NULL, meaning this processor reads no data, then - only fn, B, Z, S, and F need be set. In this case, Z, S, and F are - "representative" and can point to any valid zone */ +/** + * \ingroup SolutionData + * + * \brief Read subset of flow solution field to a shaped array in parallel. + * + * \param[in] fn \FILE_fn + * \param[in] B \B_Base + * \param[in] Z \Z_Zone + * \param[in] S \PSOL_S + * \param[in] F \PSOL_F + * \param[in] rmin \PSOL_range_min + * \param[in] rmax \PSOL_range_max + * \param[in] m_type \PSOL_mem_datatype + * \param[in] m_numdim \PSOL_mem_rank + * \param[in] m_arg_dimvals \PSOL_mem_dimensions + * \param[in] m_rmin \PSOL_mem_range_min + * \param[in] m_rmax \PSOL_mem_range_max + * \param[out] data \PSOL_solution_array + * \return \ier + * \details If \e data == NULL, meaning this processor reads no data, then + * only \e fn, \e B, \e Z, \e S, and \e F need be set. In this case, \e Z, \e S, and \e F are + * "representative" and can point to any valid zone. + */ int cgp_field_general_read_data(int fn, int B, int Z, int S, int F, const cgsize_t *rmin, const cgsize_t *rmax, CGNS_ENUMT(DataType_t) m_type, @@ -1251,7 +1580,7 @@ int cgp_field_general_read_data(int fn, int B, int Z, int S, int F, int n, ier; hid_t hid; cgns_sol *sol; - cgns_array *field; + cgns_array *field = NULL; /* get memory addresses */ cg = cgi_get_file(fn); @@ -1321,7 +1650,18 @@ int cgp_field_general_read_data(int fn, int B, int Z, int S, int F, } /*===== Array IO Prototypes ===============================*/ - +/** + * \ingroup ArrayData + * + * \brief Create an array data node. + * + * \param[in] ArrayName \PARR_arrayname + * \param[in] DataType \PARR_datatype + * \param[in] DataDimension \PARR_rank + * \param[in] DimensionVector \PARR_dimensions + * \param[in] A \PARR_A + * \return \ier + */ int cgp_array_write(const char *ArrayName, CGNS_ENUMT(DataType_t) DataType, int DataDimension, const cgsize_t *DimensionVector, int *A) { @@ -1355,7 +1695,17 @@ int cgp_array_write(const char *ArrayName, CGNS_ENUMT(DataType_t) DataType, } /*---------------------------------------------------------*/ - +/** + * \ingroup ArrayData + * + * \brief Write array data in parallel. + * + * \param[in] A \PARR_A + * \param[in] rmin \PARR_range_min + * \param[in] rmax \PARR_range_max + * \param[in] data \PARR_data + * \return \ier + */ int cgp_array_write_data(int A, const cgsize_t *rmin, const cgsize_t *rmax, const void *data) { @@ -1390,9 +1740,26 @@ int cgp_array_write_data(int A, const cgsize_t *rmin, /*---------------------------------------------------------*/ -/* Note: if data == NULL, meaning this processor reads no data, then - only A need be set. In this case, A is "representative" and can point to - any valid array being written by another processor */ +/** + * \ingroup ArrayData + * + * \brief Write shaped array to a subset of data array in parallel. + * + * \param[in] A \PARR_A + * \param[in] rmin \PARR_range_min + * \param[in] rmax \PARR_range_max + * \param[in] m_type \PARR_mem_datatype + * \param[in] m_numdim \PARR_mem_rank + * \param[in] m_arg_dimvals \PARR_mem_dimensions + * \param[in] m_rmin \PARR_mem_range_min + * \param[in] m_rmax \PARR_mem_range_max + * \param[out] data \PARR_data + * \return \ier + * \details If \e data == NULL, meaning this processor reads no data, then + * only \e A need be set. In this case, \e A is "representative" and can point to + * any valid array being written by another processor + * + */ int cgp_array_general_write_data(int A, const cgsize_t *rmin, const cgsize_t *rmax, CGNS_ENUMT(DataType_t) m_type, @@ -1468,7 +1835,17 @@ int cgp_array_general_write_data(int A, } /*---------------------------------------------------------*/ - +/** + * \ingroup ArrayData + * + * \brief Read array data in parallel. + * + * \param[in] A \PARR_A + * \param[in] rmin \PARR_range_min + * \param[in] rmax \PARR_range_max + * \param[in] data \PARR_data + * \return \ier + */ int cgp_array_read_data(int A, const cgsize_t *rmin, const cgsize_t *rmax, void *data) { @@ -1502,9 +1879,25 @@ int cgp_array_read_data(int A, const cgsize_t *rmin, /*---------------------------------------------------------*/ -/* Note: if data == NULL, meaning this processor reads no data, then - only A need be set. In this case, A is "representative" and can point to - any valid array being written by another processor */ +/** + * \ingroup ArrayData + * + * \brief Read subset of data array to a shaped array in parallel. + * + * \param[in] A \PARR_A + * \param[in] rmin \PARR_range_min + * \param[in] rmax \PARR_range_max + * \param[in] m_type \PARR_mem_datatype + * \param[in] m_numdim \PARR_mem_rank + * \param[in] m_arg_dimvals \PARR_mem_dimensions + * \param[in] m_rmin \PARR_mem_range_min + * \param[in] m_rmax \PARR_mem_range_max + * \param[out] data \PARR_data + * \return \ier + * \details If \e data == NULL, meaning this processor reads no data, then + only \e A need be set. In this case, \e A is "representative" and can point to + any valid array being written by another processor. + */ int cgp_array_general_read_data(int A, const cgsize_t *rmin, const cgsize_t *rmax, CGNS_ENUMT(DataType_t) m_type, @@ -1579,17 +1972,18 @@ int cgp_array_general_read_data(int A, dataset, CG_PAR_READ); } +/******************************** + Multidataset APIs +*********************************/ -#if HDF5_HAVE_MULTI_DATASETS - -static int readwrite_multi_data_parallel(size_t count, H5D_rw_multi_t *multi_info, +static int readwrite_multi_data_parallel(size_t count, hid_t *dset_id, hid_t *mem_type_id, hid_t *mem_space_id, hid_t *file_space_id, + cg_rw_ptr_t *data, int ndims, const cgsize_t *rmin, const cgsize_t *rmax, enum cg_par_rw rw_mode) { /* * Needs to handle a NULL dataset. MSB */ int k, n; - hid_t data_id, mem_shape_id, data_shape_id, hid; hsize_t *start, *dims; herr_t herr; hid_t plist_id; @@ -1599,24 +1993,24 @@ static int readwrite_multi_data_parallel(size_t count, H5D_rw_multi_t *multi_inf /* convert from CGNS to HDF5 data type */ for (n = 0; n < count; n++) { - switch ((CGNS_ENUMT(DataType_t))multi_info[n].mem_type_id) { + switch ((CGNS_ENUMT(DataType_t))mem_type_id[n]) { case CGNS_ENUMV(Character): - multi_info[n].mem_type_id = H5T_NATIVE_CHAR; + mem_type_id[n] = H5T_NATIVE_CHAR; break; case CGNS_ENUMV(Integer): - multi_info[n].mem_type_id = H5T_NATIVE_INT32; + mem_type_id[n] = H5T_NATIVE_INT32; break; case CGNS_ENUMV(LongInteger): - multi_info[n].mem_type_id = H5T_NATIVE_INT64; + mem_type_id[n] = H5T_NATIVE_INT64; break; case CGNS_ENUMV(RealSingle): - multi_info[n].mem_type_id = H5T_NATIVE_FLOAT; + mem_type_id[n] = H5T_NATIVE_FLOAT; break; case CGNS_ENUMV(RealDouble): - multi_info[n].mem_type_id = H5T_NATIVE_DOUBLE; + mem_type_id[n] = H5T_NATIVE_DOUBLE; break; default: - cgi_error("unhandled data type %d\n", multi_info[n].mem_type_id); + cgi_error("unhandled data type %ld\n", mem_type_id[n]); free(start); free(dims); return CG_ERROR; @@ -1632,8 +2026,8 @@ static int readwrite_multi_data_parallel(size_t count, H5D_rw_multi_t *multi_inf for (k = 0; k < count; k++) { /* Create a shape for the data in memory */ - multi_info[k].mem_space_id = H5Screate_simple(ndims, dims, NULL); - if (multi_info[k].mem_space_id < 0) { + mem_space_id[k] = H5Screate_simple(ndims, dims, NULL); + if (mem_space_id[k] < 0) { cgi_error("H5Screate_simple() failed"); free(start); free(dims); @@ -1641,8 +2035,8 @@ static int readwrite_multi_data_parallel(size_t count, H5D_rw_multi_t *multi_inf } /* Open the data */ - if ((multi_info[k].dset_id = H5Dopen2(multi_info[k].dset_id, " data", H5P_DEFAULT)) < 0) { - H5Sclose(multi_info[k].mem_space_id); /** needs loop **/ + if ((dset_id[k] = H5Dopen2(dset_id[k], " data", H5P_DEFAULT)) < 0) { + H5Sclose(mem_space_id[k]); /** needs loop **/ cgi_error("H5Dopen2() failed"); free(start); free(dims); @@ -1650,10 +2044,10 @@ static int readwrite_multi_data_parallel(size_t count, H5D_rw_multi_t *multi_inf } /* Create a shape for the data in the file */ - multi_info[k].dset_space_id = H5Dget_space(multi_info[k].dset_id); - if (multi_info[k].dset_space_id < 0) { - H5Sclose(multi_info[k].mem_space_id); - H5Dclose(multi_info[k].dset_id); + file_space_id[k] = H5Dget_space(dset_id[k]); + if (file_space_id[k] < 0) { + H5Sclose(mem_space_id[k]); + H5Dclose(dset_id[k]); cgi_error("H5Dget_space() failed"); free(start); free(dims); @@ -1661,12 +2055,11 @@ static int readwrite_multi_data_parallel(size_t count, H5D_rw_multi_t *multi_inf } /* Select a section of the array in the file */ - herr = H5Sselect_hyperslab(multi_info[k].dset_space_id, H5S_SELECT_SET, start, + herr = H5Sselect_hyperslab(file_space_id[k], H5S_SELECT_SET, start, NULL, dims, NULL); if (herr < 0) { - H5Sclose(data_shape_id); - H5Sclose(mem_shape_id); - H5Dclose(data_id); + H5Sclose(mem_space_id[k]); + H5Dclose(dset_id[k]); cgi_error("H5Sselect_hyperslab() failed"); free(start); free(dims); @@ -1677,9 +2070,6 @@ static int readwrite_multi_data_parallel(size_t count, H5D_rw_multi_t *multi_inf /* Set the access property list for data transfer */ plist_id = H5Pcreate(H5P_DATASET_XFER); if (plist_id < 0) { - H5Sclose(data_shape_id); - H5Sclose(mem_shape_id); - H5Dclose(data_id); cgi_error("H5Pcreate() failed"); free(start); free(dims); @@ -1690,31 +2080,43 @@ static int readwrite_multi_data_parallel(size_t count, H5D_rw_multi_t *multi_inf herr = H5Pset_dxpl_mpio(plist_id, ctx_cgio.default_pio_mode); if (herr < 0) { H5Pclose(plist_id); - H5Sclose(data_shape_id); - H5Sclose(mem_shape_id); - H5Dclose(data_id); cgi_error("H5Pset_dxpl_mpio() failed"); free(start); free(dims); return CG_ERROR; } + /* If HDF5 does not support multi-dataset APIs, then resort to doing them one-by-one */ +#if HDF5_HAVE_MULTI_DATASETS /* Read or Write the data in parallel */ if (rw_mode == CG_PAR_READ) { - herr = H5Dread_multi(plist_id, count, multi_info); + herr = H5Dread_multi(count, dset_id, mem_type_id, mem_space_id, file_space_id, plist_id, data[0].u.rbuf); if (herr < 0) { cgi_error("H5Dread_multi() failed"); } } else { - herr = H5Dwrite_multi(plist_id, count, multi_info); + herr = H5Dwrite_multi(count, dset_id, mem_type_id, mem_space_id, file_space_id, plist_id, data[0].u.wbuf); if (herr < 0) { cgi_error("H5Dwrite_multi() failed"); } } +#else + for (k = 0; k < count; k++) { + if (rw_mode == CG_PAR_READ) { + herr = H5Dread(dset_id[k], mem_type_id[k], mem_space_id[k], file_space_id[k], plist_id, data[0].u.rbuf[k]); + if (herr < 0) { + cgi_error("H5Dread_multi() -- pseudo -- failed"); + } + } else { + herr = H5Dwrite(dset_id[k], mem_type_id[k], mem_space_id[k], file_space_id[k], plist_id, data[0].u.wbuf[k]); + if (herr < 0) { + cgi_error("H5Dwrite_multi() -- pseudo -- failed"); + } + } + } +#endif + H5Pclose(plist_id); - H5Sclose(data_shape_id); - H5Sclose(mem_shape_id); - H5Dclose(data_id); free(start); free(dims); return herr < 0 ? CG_ERROR : CG_OK; @@ -1723,72 +2125,97 @@ static int readwrite_multi_data_parallel(size_t count, H5D_rw_multi_t *multi_inf /*------------------- multi-dataset functions --------------------------------------*/ int cgp_coord_multi_read_data(int fn, int B, int Z, int *C, const cgsize_t *rmin, const cgsize_t *rmax, - void *coordsX, void *coordsY, void *coordsZ) + int nsets, void *buf[]) { - int n; - hid_t hid; - cgns_zone *zone; - cgns_zcoor *zcoor; - cgsize_t dims[3]; - cgsize_t index_dim; - CGNS_ENUMT(DataType_t) type[3]; - H5D_rw_multi_t multi_info[3]; + int n; + hid_t hid; + cgns_zone *zone = NULL; + cgns_zcoor *zcoor = NULL; + cgsize_t dims[3]; - cg = cgi_get_file(fn); - if (check_parallel(cg)) return CG_ERROR; + hid_t *dset_id = NULL; + hid_t *mem_type_id = NULL; + hid_t *mem_space_id = NULL; + hid_t *file_space_id = NULL; - if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) - return CG_ERROR; + int status; - zone = cgi_get_zone(cg, B, Z); - if (zone==0) return CG_ERROR; + cg = cgi_get_file(fn); + if (check_parallel(cg)) return CG_ERROR; - zcoor = cgi_get_zcoorGC(cg, B, Z); - if (zcoor==0) return CG_ERROR; + if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) + goto error; - for (n = 0; n < 3; n++) { - if (C[n] > zcoor->ncoords || C[n] <= 0) { - cgi_error("coord number %d invalid",C[n]); - return CG_ERROR; + dset_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + mem_type_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + mem_space_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + file_space_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + + zone = cgi_get_zone(cg, B, Z); + if (zone==0) goto error; + + zcoor = cgi_get_zcoorGC(cg, B, Z); + if (zcoor==0) goto error; + + for (n = 0; n < nsets; n++) { + if (C[n] > zcoor->ncoords || C[n] <= 0) { + cgi_error("coord number %d invalid",C[n]); + goto error; + } } - } - for (n = 0; n < zone->index_dim; n++) { - dims[n] = zone->nijk[n] + zcoor->rind_planes[2*n] + - zcoor->rind_planes[2*n+1]; - if (rmin[n] > rmax[n] || rmin[n] < 1 || rmax[n] > dims[n]) { - cgi_error("Invalid index ranges."); - return CG_ERROR; + for (n = 0; n < zone->index_dim; n++) { + dims[n] = zone->nijk[n] + zcoor->rind_planes[2*n] + + zcoor->rind_planes[2*n+1]; + if (rmin[n] > rmax[n] || rmin[n] < 1 || rmax[n] > dims[n]) { + cgi_error("Invalid index ranges."); + goto error; + } } - } - for (n = 0; n < 3; n++) { - multi_info[n].mem_type_id = cgi_datatype(zcoor->coord[C[n]-1].data_type); - to_HDF_ID(zcoor->coord[C[n]-1].id, hid); - multi_info[n].dset_id = hid; - } + for (n = 0; n < nsets; n++) { + mem_type_id[n] = cgi_datatype(zcoor->coord[C[n]-1].data_type); + to_HDF_ID(zcoor->coord[C[n]-1].id, hid); + dset_id[n] = hid; + } - multi_info[0].u.rbuf = coordsX; - multi_info[1].u.rbuf = coordsY; - multi_info[2].u.rbuf = coordsZ; + cg_rw_ptr_t Data; + Data.u.rbuf = buf; + status = readwrite_multi_data_parallel(nsets, dset_id, mem_type_id, mem_space_id, file_space_id, &Data, + zone->index_dim, rmin, rmax, CG_PAR_READ); - return readwrite_multi_data_parallel(3, multi_info, - zone->index_dim, rmin, rmax, CG_PAR_READ); + return status; + + error: + if(dset_id) + free(dset_id); + if(mem_type_id) + free(mem_type_id); + if(mem_space_id) + free(mem_space_id); + if(file_space_id) + free(file_space_id); + + return CG_ERROR; } /*---------------------------------------------------------*/ int cgp_coord_multi_write_data(int fn, int B, int Z, int *C, const cgsize_t *rmin, const cgsize_t *rmax, - const void *coordsX, const void *coordsY, const void *coordsZ) + int nsets, const void *buf[]) { int n; - cgns_zone *zone; - cgns_zcoor *zcoor; - cgsize_t dims[3]; - cgsize_t index_dim; - CGNS_ENUMT(DataType_t) type[3]; - H5D_rw_multi_t multi_info[3]; hid_t hid; + cgns_zone *zone = NULL; + cgns_zcoor *zcoor = NULL; + cgsize_t dims[3]; + + hid_t *dset_id = NULL; + hid_t *mem_type_id = NULL; + hid_t *mem_space_id = NULL; + hid_t *file_space_id = NULL; + + int status; cg = cgi_get_file(fn); if (check_parallel(cg)) return CG_ERROR; @@ -1796,16 +2223,21 @@ int cgp_coord_multi_write_data(int fn, int B, int Z, int *C, const cgsize_t *rmi if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; + dset_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + mem_type_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + mem_space_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + file_space_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + zone = cgi_get_zone(cg, B, Z); - if (zone==0) return CG_ERROR; + if (zone==0) goto error; zcoor = cgi_get_zcoorGC(cg, B, Z); - if (zcoor==0) return CG_ERROR; + if (zcoor==0) goto error; - for (n = 0; n < 3; n++) { + for (n = 0; n < nsets; n++) { if (C[n] > zcoor->ncoords || C[n] <= 0) { cgi_error("coord number %d invalid",C[n]); - return CG_ERROR; + goto error; } } @@ -1814,35 +2246,52 @@ int cgp_coord_multi_write_data(int fn, int B, int Z, int *C, const cgsize_t *rmi zcoor->rind_planes[2*n+1]; if (rmin[n] > rmax[n] || rmin[n] < 1 || rmax[n] > dims[n]) { cgi_error("Invalid index ranges."); - return CG_ERROR; + goto error; } } - for (n = 0; n < 3; n++) { - multi_info[n].mem_type_id = cgi_datatype(zcoor->coord[C[n]-1].data_type); + for (n = 0; n < nsets; n++) { + mem_type_id[n] = cgi_datatype(zcoor->coord[C[n]-1].data_type); to_HDF_ID(zcoor->coord[C[n]-1].id, hid); - multi_info[n].dset_id = hid; + dset_id[n] = hid; } - multi_info[0].u.wbuf = coordsX; - multi_info[1].u.wbuf = coordsY; - multi_info[2].u.wbuf = coordsZ; + cg_rw_ptr_t Data; + Data.u.wbuf = buf; + status = readwrite_multi_data_parallel(nsets, dset_id, mem_type_id, mem_space_id, file_space_id, &Data, + zone->index_dim, rmin, rmax, CG_PAR_WRITE); + + return status; + + error: + if(dset_id) + free(dset_id); + if(mem_type_id) + free(mem_type_id); + if(mem_space_id) + free(mem_space_id); + if(file_space_id) + free(file_space_id); + + return CG_ERROR; - return readwrite_multi_data_parallel(3, multi_info, - zone->index_dim, rmin, rmax, CG_PAR_WRITE); } /*---------------------------------------------------------*/ -int vcgp_field_multi_write_data(int fn, int B, int Z, int S, int *F, - const cgsize_t *rmin, const cgsize_t *rmax, int nsets, va_list ap) +int cgp_field_multi_write_data(int fn, int B, int Z, int S, int *F, + const cgsize_t *rmin, const cgsize_t *rmax, int nsets, const void *buf[]) { int n, m; hid_t hid; - cgns_array *field; - CGNS_ENUMT(DataType_t) type; - H5D_rw_multi_t *multi_info; + cgns_array *field = NULL; + + hid_t *dset_id = NULL; + hid_t *mem_type_id = NULL; + hid_t *mem_space_id = NULL; + hid_t *file_space_id = NULL; + int status; cg = cgi_get_file(fn); @@ -1851,7 +2300,10 @@ int vcgp_field_multi_write_data(int fn, int B, int Z, int S, int *F, if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) return CG_ERROR; - multi_info = (H5D_rw_multi_t *)malloc(nsets*sizeof(H5D_rw_multi_t)); + dset_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + mem_type_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + mem_space_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + file_space_id = (hid_t *)malloc(nsets*sizeof(hid_t)); for (n = 0; n < nsets; n++) { field = cgi_get_field(cg, B, Z, S, F[n]); @@ -1867,50 +2319,50 @@ int vcgp_field_multi_write_data(int fn, int B, int Z, int S, int *F, } } - multi_info[n].u.wbuf = va_arg(ap, const void *); - - multi_info[n].mem_type_id = cgi_datatype(field->data_type); + mem_type_id[n] = cgi_datatype(field->data_type); to_HDF_ID(field->id,hid); - multi_info[n].dset_id = hid; + dset_id[n] = hid; } - status = readwrite_multi_data_parallel(nsets, multi_info, + cg_rw_ptr_t Data; + Data.u.wbuf = buf; + status = readwrite_multi_data_parallel(nsets, dset_id, mem_type_id, mem_space_id, file_space_id, &Data, field->data_dim, rmin, rmax, CG_PAR_WRITE); - free(multi_info); + free(dset_id); + free(mem_type_id); + free(mem_space_id); + free(file_space_id); return status; error: - if(multi_info) - free(multi_info); + if(dset_id) + free(dset_id); + if(mem_type_id) + free(mem_type_id); + if(mem_space_id) + free(mem_space_id); + if(file_space_id) + free(file_space_id); return CG_ERROR; } -int cgp_field_multi_write_data(int fn, int B, int Z, int S, int *F, - const cgsize_t *rmin, const cgsize_t *rmax, int nsets, ...) -{ - va_list ap; - int status; - va_start(ap, nsets); - status = vcgp_field_multi_write_data(fn, B, Z, S, F, rmin, rmax, nsets, ap); - va_end(ap); - return status; - -} - - /*---------------------------------------------------------*/ -int vcgp_field_multi_read_data(int fn, int B, int Z, int S, int *F, - const cgsize_t *rmin, const cgsize_t *rmax, int nsets, va_list ap) +int cgp_field_multi_read_data(int fn, int B, int Z, int S, int *F, + const cgsize_t *rmin, const cgsize_t *rmax, int nsets, void *buf[]) { int n, m; hid_t hid; - cgns_array *field; - CGNS_ENUMT(DataType_t) type; - H5D_rw_multi_t *multi_info; + cgns_array *field = NULL; + + hid_t *dset_id; + hid_t *mem_type_id; + hid_t *mem_space_id; + hid_t *file_space_id; + int status; cg = cgi_get_file(fn); @@ -1919,7 +2371,10 @@ int vcgp_field_multi_read_data(int fn, int B, int Z, int S, int *F, if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) return CG_ERROR; - multi_info = (H5D_rw_multi_t *)malloc(nsets*sizeof(H5D_rw_multi_t)); + dset_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + mem_type_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + mem_space_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + file_space_id = (hid_t *)malloc(nsets*sizeof(hid_t)); for (n = 0; n < nsets; n++) { @@ -1935,54 +2390,60 @@ int vcgp_field_multi_read_data(int fn, int B, int Z, int S, int *F, goto error; } } - multi_info[n].u.rbuf = va_arg(ap, void *); - multi_info[n].mem_type_id = cgi_datatype(field->data_type); + mem_type_id[n] = cgi_datatype(field->data_type); to_HDF_ID(field->id,hid); - multi_info[n].dset_id = hid; + dset_id[n] = hid; } - status = readwrite_multi_data_parallel(nsets, multi_info, + cg_rw_ptr_t Data; + Data.u.rbuf = buf; + status = readwrite_multi_data_parallel(nsets, dset_id, mem_type_id, mem_space_id, file_space_id, &Data, field->data_dim, rmin, rmax, CG_PAR_READ); - free(multi_info); + + free(dset_id); + free(mem_type_id); + free(mem_space_id); + free(file_space_id); return status; error: - if(multi_info) - free(multi_info); + if(dset_id) + free(dset_id); + if(mem_type_id) + free(mem_type_id); + if(mem_space_id) + free(mem_space_id); + if(file_space_id) + free(file_space_id); return CG_ERROR; } -int cgp_field_multi_read_data(int fn, int B, int Z, int S, int *F, - const cgsize_t *rmin, const cgsize_t *rmax, int nsets, ...) -{ - va_list ap; - int status; - va_start(ap, nsets); - status = vcgp_field_multi_read_data(fn, B, Z, S, F, rmin, rmax, nsets, ap); - va_end(ap); - return status; - -} - /*---------------------------------------------------------*/ -int vcgp_array_multi_write_data(int fn, int *A, const cgsize_t *rmin, - const cgsize_t *rmax, int nsets, va_list ap) +int cgp_array_multi_write_data(int fn, int *A, const cgsize_t *rmin, + const cgsize_t *rmax, int nsets, const void *buf[]) { int n, m, ierr = 0; hid_t hid; - cgns_array *array; - CGNS_ENUMT(DataType_t) type; - H5D_rw_multi_t *multi_info; + cgns_array *array = NULL; + + hid_t *dset_id; + hid_t *mem_type_id; + hid_t *mem_space_id; + hid_t *file_space_id; + int status; cg = cgi_get_file(fn); if (check_parallel(cg)) return CG_ERROR; - multi_info = (H5D_rw_multi_t *)malloc(nsets*sizeof(H5D_rw_multi_t)); + dset_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + mem_type_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + mem_space_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + file_space_id = (hid_t *)malloc(nsets*sizeof(hid_t)); for (n = 0; n < nsets; n++) { @@ -1999,55 +2460,60 @@ int vcgp_array_multi_write_data(int fn, int *A, const cgsize_t *rmin, } } - multi_info[n].u.wbuf = va_arg(ap, const void *); - - multi_info[n].mem_type_id = cgi_datatype(array->data_type); + mem_type_id[n] = cgi_datatype(array->data_type); to_HDF_ID(array->id, hid); - multi_info[n].dset_id = hid; + dset_id[n] = hid; } - status = readwrite_multi_data_parallel(nsets, multi_info, + cg_rw_ptr_t Data; + Data.u.wbuf = buf; + status = readwrite_multi_data_parallel(nsets, dset_id, mem_type_id, mem_space_id, file_space_id, &Data, array->data_dim, rmin, rmax, CG_PAR_WRITE); - free(multi_info); + free(dset_id); + free(mem_type_id); + free(mem_space_id); + free(file_space_id); return status; error: - if(multi_info) - free(multi_info); - - return CG_ERROR; -} - -int cgp_array_multi_write_data(int fn, int *A, const cgsize_t *rmin, - const cgsize_t *rmax, int nsets, ...) -{ - va_list ap; - int status; - va_start(ap, nsets); - status = vcgp_array_multi_write_data(fn, A, rmin, rmax, nsets, ap); - va_end(ap); - return status; + if(dset_id) + free(dset_id); + if(mem_type_id) + free(mem_type_id); + if(mem_space_id) + free(mem_space_id); + if(file_space_id) + free(file_space_id); + return CG_ERROR; } /*---------------------------------------------------------*/ -int vcgp_array_multi_read_data(int fn, int *A, const cgsize_t *rmin, - const cgsize_t *rmax, int nsets, va_list ap) +int cgp_array_multi_read_data(int fn, int *A, const cgsize_t *rmin, + const cgsize_t *rmax, int nsets, void *buf[]) { int n, m, ierr = 0; hid_t hid; - cgns_array *array; - CGNS_ENUMT(DataType_t) type; - H5D_rw_multi_t *multi_info; + cgns_array *array = NULL; + + hid_t *dset_id; + hid_t *mem_type_id; + hid_t *mem_space_id; + hid_t *file_space_id; + int status; cg = cgi_get_file(fn); if (check_parallel(cg)) return CG_ERROR; - multi_info = (H5D_rw_multi_t *)malloc(nsets*sizeof(H5D_rw_multi_t)); + + dset_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + mem_type_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + mem_space_id = (hid_t *)malloc(nsets*sizeof(hid_t)); + file_space_id = (hid_t *)malloc(nsets*sizeof(hid_t)); for (n = 0; n < nsets; n++) { @@ -2063,36 +2529,159 @@ int vcgp_array_multi_read_data(int fn, int *A, const cgsize_t *rmin, goto error; } } - multi_info[n].u.rbuf = va_arg(ap, void *); - multi_info[n].mem_type_id = cgi_datatype(array->data_type); + mem_type_id[n] = cgi_datatype(array->data_type); to_HDF_ID(array->id, hid); - multi_info[n].dset_id = hid; + dset_id[n] = hid; } - status = readwrite_multi_data_parallel(nsets, multi_info, + + cg_rw_ptr_t Data; + Data.u.rbuf = buf; + status = readwrite_multi_data_parallel(nsets, dset_id, mem_type_id, mem_space_id, file_space_id, &Data, array->data_dim, rmin, rmax, CG_PAR_READ); - free(multi_info); + free(dset_id); + free(mem_type_id); + free(mem_space_id); + free(file_space_id); return status; error: - if(multi_info) - free(multi_info); + if(dset_id) + free(dset_id); + if(mem_type_id) + free(mem_type_id); + if(mem_space_id) + free(mem_space_id); + if(file_space_id) + free(file_space_id); return CG_ERROR; } -int cgp_array_multi_read_data(int fn, int *A, const cgsize_t *rmin, - const cgsize_t *rmax, int nsets, ...) +/*===== PointList Functions =============================*/ + +/** + * \ingroup PointListData + * + * \brief Write index array to PointList in parallel. + * + * \details Must use functions in @ref AccessingANode to point to a PointSet to read from + * + * \param[in] file_number \FILE_fn + * \param[in] rmin Lower range index in file + * \param[in] rmax Upper range index in file + * \param[in] points Array of points + * \return \ier + */ +int cgp_ptlist_write_data(int file_number, cgsize_t rmin, + cgsize_t end, const cgsize_t *points) { - va_list ap; - int status; - va_start(ap, nsets); - status = vcgp_array_multi_read_data(fn, A, rmin, rmax, nsets, ap); - va_end(ap); - return status; + hid_t hid; + cgns_ptset *ptset; + cgsize_t range_min[2], range_max[2]; + CGNS_ENUMT(DataType_t) type; + + /* get memory address of file */ + cg = cgi_get_file(file_number); + if (check_parallel(cg)) return CG_ERROR; + + if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) + return CG_ERROR; + + if (posit == 0) { + cgi_error("No current position set by cg_goto\n"); + return CG_ERROR; + } + else if (strcmp(posit->label, "IndexArray_t") == 0) { + ptset = (cgns_ptset *) posit->posit; + } else { + cgi_error("Goto not pointing to IndexArray_t, but %s\n", posit->label); + return CG_ERROR; + } + + if (points) { + if (rmin > end || + rmin < 1 || + end > ptset->npts) { + cgi_error("Error in requested point set range."); + return CG_ERROR; + } + } + + range_min[0] = 1; + range_max[0] = 1; + range_min[1] = rmin; + range_max[1] = end; + type = cgi_datatype(ptset->data_type); + to_HDF_ID(ptset->id, hid); + + cg_rw_t Data; + Data.u.wbuf = points; + return readwrite_data_parallel(hid, type, + 2, range_min, range_max, &Data, CG_PAR_WRITE); } -#endif +/** + * \ingroup PointListData + * + * \brief Read index array to PointList in parallel. + * + * \details Must use functions in @ref AccessingANode to point to a PointSet to read from + * + * \param[in] file_number \FILE_fn + * \param[in] rmin Lower range index in file + * \param[in] rmax Upper range index in file + * \param[in] points Array of points + * \return \ier + */ +int cgp_ptlist_read_data(int file_number, cgsize_t rmin, cgsize_t rmax, cgsize_t *points) +{ + hid_t hid; + cgns_ptset *ptset; + cgsize_t range_min[2], range_max[2]; + CGNS_ENUMT(DataType_t) type; + + /* get memory address of file */ + cg = cgi_get_file(file_number); + if (check_parallel(cg)) return CG_ERROR; + + if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) + return CG_ERROR; + + if (posit == 0) { + cgi_error("No current position set by cg_goto\n"); + return CG_ERROR; + } + else if (strcmp(posit->label, "IndexArray_t") == 0) { + ptset = (cgns_ptset *) posit->posit; + } else { + cgi_error("Goto not pointing to IndexArray_t, but %s\n", posit->label); + return CG_ERROR; + } + + if (points) { + if (rmin > rmax || + rmin < 1 || + rmax > ptset->npts) { + cgi_error("Error in requested point set range."); + return CG_ERROR; + } + } + + range_min[0] = 1; + range_max[0] = 1; + range_min[1] = rmin; + range_max[1] = rmax; + type = cgi_datatype(ptset->data_type); + + to_HDF_ID(ptset->id, hid); + + cg_rw_t Data; + Data.u.rbuf = points; + return readwrite_data_parallel(hid, type, + 2, range_min, range_max, &Data, CG_PAR_READ); +} +/*---------------------------------------------------------*/ diff --git a/externals/cgns/pcgnslib.h b/externals/cgns/pcgnslib.h index 5f96aa6bb5e..542b0a73e2b 100644 --- a/externals/cgns/pcgnslib.h +++ b/externals/cgns/pcgnslib.h @@ -78,10 +78,10 @@ CGNSDLL int cgp_coord_general_read_data(int fn, int B, int Z, int C, const cgsize_t *m_rmin, const cgsize_t *m_rmax, void *coords); CGNSDLL int cgp_coord_multi_read_data(int fn, int B, int Z, int *C, const cgsize_t *rmin, const cgsize_t *rmax, - void *coordsX, void *coordsY, void *coordsZ); + int nsets, void **buf); CGNSDLL int cgp_coord_multi_write_data(int fn, int B, int Z, int *C, const cgsize_t *rmin, const cgsize_t *rmax, - const void *coordsX, const void *coordsY, const void *coordsZ); + int nsets, const void **buf); /*===== Unstructured Grid Prototypes =====*/ @@ -123,11 +123,12 @@ CGNSDLL int cgp_field_general_read_data(int fn, int B, int Z, int S, int F, int m_numdim, const cgsize_t *m_arg_dimvals, const cgsize_t *m_rmin, const cgsize_t *m_rmax, void *data); + CGNSDLL int cgp_field_multi_read_data(int fn, int B, int Z, int S, int *F, - const cgsize_t *rmin, const cgsize_t *rmax, int nsets, ...); + const cgsize_t *rmin, const cgsize_t *rmax, int nsets, void **buf); CGNSDLL int cgp_field_multi_write_data(int fn, int B, int Z, int S, int *F, - const cgsize_t *rmin, const cgsize_t *rmax, int nsets, ...); + const cgsize_t *rmin, const cgsize_t *rmax, int nsets, const void **buf); /*===== Array IO Prototypes =====*/ @@ -150,10 +151,16 @@ CGNSDLL int cgp_array_general_read_data(int A, const cgsize_t *m_rmin, const cgsize_t *m_rmax, void *data); CGNSDLL int cgp_array_multi_write_data(int fn, int *A, const cgsize_t *rmin, - const cgsize_t *rmax, int nsets, ...); + const cgsize_t *rmax, int nsets, const void **buf); CGNSDLL int cgp_array_multi_read_data(int fn, int *A, const cgsize_t *rmin, - const cgsize_t *rmax, int nsets, ...); + const cgsize_t *rmax, int nsets, void **buf); + + +/*===== PointList Prototypes =====*/ +CGNSDLL int cgp_ptlist_write_data(int file_number, cgsize_t start, + cgsize_t end, const cgsize_t *points); +CGNSDLL int cgp_ptlist_read_data(int file_number, cgsize_t start, cgsize_t end, cgsize_t *points); /*===== exit with error and call MPI_Abort =====*/ From 87554b3d33407949fabfa2ed0c3ab9f19678b325 Mon Sep 17 00:00:00 2001 From: rois1995 <43813346+rois1995@users.noreply.github.com> Date: Mon, 4 Dec 2023 15:15:23 +0100 Subject: [PATCH 73/99] Update TestCases/parallel_regression.py Co-authored-by: Mickael PHILIT --- TestCases/parallel_regression.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 481f355e9eb..80591acdf91 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1560,14 +1560,14 @@ def main(): ##################### # CGNS writer - CGNSWrite = TestCase('CGNSWrite') - CGNSWrite.cfg_dir = "CGNSWrite" - CGNSWrite.cfg_file = "config.cfg" - CGNSWrite.test_iter = 1 - CGNSWrite.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] - CGNSWrite.command = TestCase.Command("mpirun -n 2", "SU2_CFD") - CGNSWrite.new_output = True - test_list.append(CGNSWrite) + cgns_writer = TestCase('CGNSWrite') + cgns_writer.cfg_dir = "CGNSWrite" + cgns_writer.cfg_file = "config.cfg" + cgns_writer.test_iter = 1 + cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] + cgns_writer.command = TestCase.Command("mpirun -n 2", "SU2_CFD") + cgns_writer.new_output = True + test_list.append(cgns_writer) ###################################### ### RUN TESTS ### From 1b4091ddc176d74b6dd8924326dddf358dd9a23a Mon Sep 17 00:00:00 2001 From: rois1995 Date: Mon, 4 Dec 2023 15:25:04 +0100 Subject: [PATCH 74/99] - Changed name to regression case --- TestCases/{CGNSWrite => cgns_writer}/config.cfg | 0 TestCases/parallel_regression.py | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename TestCases/{CGNSWrite => cgns_writer}/config.cfg (100%) diff --git a/TestCases/CGNSWrite/config.cfg b/TestCases/cgns_writer/config.cfg similarity index 100% rename from TestCases/CGNSWrite/config.cfg rename to TestCases/cgns_writer/config.cfg diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 80591acdf91..e1acb128581 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1560,8 +1560,8 @@ def main(): ##################### # CGNS writer - cgns_writer = TestCase('CGNSWrite') - cgns_writer.cfg_dir = "CGNSWrite" + cgns_writer = TestCase('cgns_writer') + cgns_writer.cfg_dir = "cgns_writer" cgns_writer.cfg_file = "config.cfg" cgns_writer.test_iter = 1 cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] From 87f99447b48bfd449225b6d12b2d1df43fffa889 Mon Sep 17 00:00:00 2001 From: rois1995 Date: Tue, 5 Dec 2023 08:49:16 +0100 Subject: [PATCH 75/99] - Removed comments from regression config --- TestCases/cgns_writer/config.cfg | 103 ++----------------------------- 1 file changed, 6 insertions(+), 97 deletions(-) diff --git a/TestCases/cgns_writer/config.cfg b/TestCases/cgns_writer/config.cfg index bfad06bafd9..12930ef75c9 100644 --- a/TestCases/cgns_writer/config.cfg +++ b/TestCases/cgns_writer/config.cfg @@ -1,144 +1,73 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % SU2 configuration file % -% Case description: Transonic simulation RAE2822 (RANS) % -% Author: Francisco Palacios % -% Institution: Stanford University % -% Date: 5/15/2013 % -% File Version 7.4.0 "Blackbird" % +% Case description: Subsonic U-Turn % +% Author: Andrea Rausa % +% Institution: Politecnico di Milano % +% Date: 12/2/2023 % +% File Version 8.0.0 "Harrier" % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% % -% Physical governing equations (EULER, NAVIER_STOKES, -% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, -% POISSON_EQUATION) SOLVER= RANS -% -% Specify turbulent model (NONE, SA, SA_NEG, SST) KIND_TURB_MODEL= SST -% -% Mathematical problem (DIRECT, CONTINUOUS_ADJOINT) MATH_PROBLEM= DIRECT -% -% Restart solution (NO, YES) RESTART_SOL= NO % -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% % -% Mach number (non-dimensional, based on the free-stream values) MACH_NUMBER= 0.2 -% AirSpeed = 279.9663 -% Density = 1.225 -% -% Angle of attack (degrees, only for compressible flows) AOA= 0.0 -% Free-stream temperature (288.15 K by default) FREESTREAM_TEMPERATURE= 270.0 -% -% Reynolds number (non-dimensional, based on the free-stream values) REYNOLDS_NUMBER= 3.28E6 -% -% Reynolds length (1 m by default) REYNOLDS_LENGTH= 1 REF_DIMENSIONALIZATION= FREESTREAM_VEL_EQ_MACH % ---------------------- REFERENCE VALUE DEFINITION ---------------------------% % -% Reference origin for moment computation REF_ORIGIN_MOMENT_X = -0.2473 REF_ORIGIN_MOMENT_Y = 0.00 REF_ORIGIN_MOMENT_Z = 0.00 -% -% Reference length for pitching, rolling, and yawing non-dimensional moment REF_LENGTH= 1 -% -% Reference area for force coefficients (0 implies automatic calculation) -% Body tube cross-area REF_AREA= 1 % -------------------- BOUNDARY CONDITION DEFINITION --------------------------% % -% Navier-Stokes wall boundary marker(s) (NONE = no marker) MARKER_HEATFLUX= ( OuterWall, 0.0, InnerWall, 0.0 ) -% -% Farfield boundary marker(s) (NONE = no marker) MARKER_FAR= ( Inlet, Outlet ) - -% -% -% Marker(s) of the surface to be plotted or designed MARKER_PLOTTING= ( InnerWall ) -% -% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated MARKER_MONITORING= ( InnerWall ) - % ------------------------ LINEAR SOLVER DEFINITION ---------------------------% % LINEAR_SOLVER= FGMRES LINEAR_SOLVER_PREC= ILU LINEAR_SOLVER_ERROR= 1.0e-6 -% lower memory consumption: LINEAR_SOLVER_ITER= 15 -% + % -------------------------- MULTIGRID PARAMETERS -----------------------------% % - -NEWTON_KRYLOV= NO -NEWTON_KRYLOV_IPARAM= (10, 5, 2) % n0, np, ft -NEWTON_KRYLOV_DPARAM= (1.0, 0.01, -6, 1e-5) % r0, tp, rf, e CFL_ADAPT= YES CFL_NUMBER= 1 CFL_REDUCTION_TURB= 1.0 -% CFL_ADAPT_PARAM= ( 0.5, 1.01, 1.0, 5, 0.0001) - ITER= 1 -MGLEVEL= 0 -% -MGCYCLE= V_CYCLE -MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) -MG_POST_SMOOTH= ( 1, 1, 1, 1 ) -MG_CORRECTION_SMOOTH= ( 1, 1, 1, 1 ) -MG_DAMP_RESTRICTION= 0.5 -MG_DAMP_PROLONGATION= 0.5 - % -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% % -% Convective numerical method (JST, LAX-FRIEDRICH, CUSP, ROE, AUSM, HLLC, -% TURKEL_PREC, MSW) CONV_NUM_METHOD_FLOW= ROE USE_VECTORIZATION= YES -% -% Monotonic Upwind Scheme for Conservation Laws (TVD) in the flow equations. -% Required for 2nd order upwind schemes (NO, YES) MUSCL_FLOW= NO -% -% Slope limiter (VENKATAKRISHNAN, MINMOD) SLOPE_LIMITER_FLOW= VENKATAKRISHNAN -% -% Coefficient for the limiter (smooth regions) VENKAT_LIMITER_COEFF= 0.03 -% -% 2nd and 4th order artificial dissipation coefficients -JST_SENSOR_COEFF= ( 0.5, 0.02 ) -% -% Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT, EULER_EXPLICIT) TIME_DISCRE_FLOW= EULER_IMPLICIT % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% % -% Convective numerical method (SCALAR_UPWIND) CONV_NUM_METHOD_TURB= SCALAR_UPWIND -% -% Monotonic Upwind Scheme for Conservation Laws (TVD) in the turbulence equations. -% Required for 2nd order upwind schemes (NO, YES) MUSCL_TURB= NO -% -% Time discretization (EULER_IMPLICIT) TIME_DISCRE_TURB= EULER_IMPLICIT @@ -148,38 +77,18 @@ CONV_FIELD= MOMENT_X CONV_STARTITER= 10 CONV_CAUCHY_ELEMS= 100 CONV_CAUCHY_EPS= 1E-6 -% % ------------------------- INPUT/OUTPUT INFORMATION --------------------------% % -% Mesh input file MESH_FILENAME= mesh.su2 -% -% Mesh input file format (SU2, CGNS, NETCDF_ASCII) MESH_FORMAT= SU2 -% -% Restart flow input file SOLUTION_FILENAME= restart_flow -% TABULAR_FORMAT= CSV -% -% Output file convergence history (w/o extension) CONV_FILENAME= history_First -% -% Output file restart flow RESTART_FILENAME= restart_flow -% -% Output file flow (w/o extension) variables VOLUME_FILENAME= flow -% -% Output file surface flow coefficient (w/o extension) SURFACE_FILENAME= surface_flow -% -% Writing solution file frequency OUTPUT_WRT_FREQ= 100 -% -% -% Screen output fields SCREEN_OUTPUT= (INNER_ITER, WALL_TIME, RMS_DENSITY, LIFT, DRAG, MOMENT_Z) OUTPUT_FILES= (SURFACE_CGNS) WRT_FORCES_BREAKDOWN= NO From f457da5e0e04f0eca60a8e7b9b1a86487694b4f5 Mon Sep 17 00:00:00 2001 From: rois1995 Date: Tue, 5 Dec 2023 15:00:42 +0100 Subject: [PATCH 76/99] - Format spaces in parallel_regression.py --- TestCases/parallel_regression.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index e1acb128581..f11842ae25c 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1560,13 +1560,13 @@ def main(): ##################### # CGNS writer - cgns_writer = TestCase('cgns_writer') - cgns_writer.cfg_dir = "cgns_writer" - cgns_writer.cfg_file = "config.cfg" - cgns_writer.test_iter = 1 - cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] - cgns_writer.command = TestCase.Command("mpirun -n 2", "SU2_CFD") - cgns_writer.new_output = True + cgns_writer = TestCase('cgns_writer') + cgns_writer.cfg_dir = "cgns_writer" + cgns_writer.cfg_file = "config.cfg" + cgns_writer.test_iter = 1 + cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873] + cgns_writer.command = TestCase.Command("mpirun -n 2", "SU2_CFD") + cgns_writer.new_output = True test_list.append(cgns_writer) ###################################### From 224c5017cf3272f2121c7719d7973cb0bde1f856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 5 Dec 2023 18:11:58 +0100 Subject: [PATCH 77/99] Avoid recomputation of final coloring. --- Common/src/geometry/CGeometry.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 08d81daf59f..a3e92cf7045 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3645,17 +3645,17 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ while (true) { - const auto currentEdgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); + const auto edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); /*--- if the coloring fails, reduce the color group size ---*/ - if (currentEdgeColoring.empty()) { + if (edgeColoring.empty()) { upperEdgeColorGroupSize = nextEdgeColorGroupSize; nextEdgeColorGroupSize = lowerEdgeColorGroupSize + (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; continue; } const su2double currentEfficiency = - coloringEfficiency(currentEdgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); + coloringEfficiency(edgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); /*--- if the coloring is not efficient, reduce the color group size ---*/ if (currentEfficiency < COLORING_EFF_THRESH) { @@ -3675,10 +3675,10 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien } edgeColorGroupSize = nextEdgeColorGroupSize; + } else { + edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); } - edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); - /*--- If the coloring fails use the natural coloring. This is a * "soft" failure as this "bad" coloring should be detected * downstream and a fallback strategy put in place. ---*/ From df30b2f0fc6dd7461cfedab7bcb27e0ad71da30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 5 Dec 2023 18:12:52 +0100 Subject: [PATCH 78/99] Fix edge color group size. --- Common/src/geometry/CGeometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index a3e92cf7045..b603786dcaf 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3645,7 +3645,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ while (true) { - const auto edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); + const auto edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); /*--- if the coloring fails, reduce the color group size ---*/ if (edgeColoring.empty()) { From 81f834b2ddd708d655a8b0f6598797458e28c23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 5 Dec 2023 18:55:02 +0100 Subject: [PATCH 79/99] Comment formatting. --- Common/src/geometry/CGeometry.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index b603786dcaf..58fbfc42da6 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3638,7 +3638,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- Color the edges. ---*/ constexpr bool balanceColors = true; - /*--- if requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize) ---*/ + /*--- If requested, find an efficient coloring with maximum color group size (up to edgeColorGroupSize). ---*/ if (maximizeEdgeColorGroupSize) { auto upperEdgeColorGroupSize = edgeColorGroupSize + 1; /* upper bound that is deemed too large */ auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */ @@ -3647,7 +3647,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien while (true) { const auto edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); - /*--- if the coloring fails, reduce the color group size ---*/ + /*--- If the coloring fails, reduce the color group size. ---*/ if (edgeColoring.empty()) { upperEdgeColorGroupSize = nextEdgeColorGroupSize; nextEdgeColorGroupSize = lowerEdgeColorGroupSize + (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; @@ -3657,11 +3657,11 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien const su2double currentEfficiency = coloringEfficiency(edgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); - /*--- if the coloring is not efficient, reduce the color group size ---*/ + /*--- If the coloring is not efficient, reduce the color group size. ---*/ if (currentEfficiency < COLORING_EFF_THRESH) { upperEdgeColorGroupSize = nextEdgeColorGroupSize; } - /*--- otherwise, try to enlarge the color group size ---*/ + /*--- Otherwise, enlarge the color group size. ---*/ else { lowerEdgeColorGroupSize = nextEdgeColorGroupSize; } From 799c9bb5555928091182f381d78b39799c5fc0b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 5 Dec 2023 19:00:20 +0100 Subject: [PATCH 80/99] Ensure that failed colorings reach the terminating condition. --- Common/src/geometry/CGeometry.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 58fbfc42da6..a2b02ac27f9 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3650,23 +3650,23 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- If the coloring fails, reduce the color group size. ---*/ if (edgeColoring.empty()) { upperEdgeColorGroupSize = nextEdgeColorGroupSize; - nextEdgeColorGroupSize = lowerEdgeColorGroupSize + (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; - continue; } - - const su2double currentEfficiency = - coloringEfficiency(edgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); - - /*--- If the coloring is not efficient, reduce the color group size. ---*/ - if (currentEfficiency < COLORING_EFF_THRESH) { - upperEdgeColorGroupSize = nextEdgeColorGroupSize; - } - /*--- Otherwise, enlarge the color group size. ---*/ + /*--- If the coloring succeeds, check the efficiency. ---*/ else { - lowerEdgeColorGroupSize = nextEdgeColorGroupSize; + const su2double currentEfficiency = + coloringEfficiency(edgeColoring, omp_get_max_threads(), nextEdgeColorGroupSize); + + /*--- If the coloring is not efficient, reduce the color group size. ---*/ + if (currentEfficiency < COLORING_EFF_THRESH) { + upperEdgeColorGroupSize = nextEdgeColorGroupSize; + } + /*--- Otherwise, enlarge the color group size. ---*/ + else { + lowerEdgeColorGroupSize = nextEdgeColorGroupSize; + } } - const auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; + const auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment; if (increment == 0) { From de3b94e24b9c088067a47ae68454a80e133c41ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 5 Dec 2023 19:03:17 +0100 Subject: [PATCH 81/99] Add comment. --- Common/src/geometry/CGeometry.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index a2b02ac27f9..404ff102c56 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3669,6 +3669,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien const auto increment = (upperEdgeColorGroupSize - lowerEdgeColorGroupSize) / 2; nextEdgeColorGroupSize = lowerEdgeColorGroupSize + increment; + /*--- Terminating condition. ---*/ if (increment == 0) { break; } From de941f3f28ba084bd09aabce9bf580ab29dd921f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Tue, 5 Dec 2023 19:17:24 +0100 Subject: [PATCH 82/99] Use member variable directly. --- Common/src/geometry/CGeometry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 404ff102c56..5ce438a33a8 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3645,7 +3645,7 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ while (true) { - const auto edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); + edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); /*--- If the coloring fails, reduce the color group size. ---*/ if (edgeColoring.empty()) { From aec3aabae4539192154ad2cd6c47932ea4c0e504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Wed, 6 Dec 2023 16:46:10 +0100 Subject: [PATCH 83/99] Avoid recomputation if last coloring was admissible. --- Common/src/geometry/CGeometry.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 5ce438a33a8..aeca6421763 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3644,12 +3644,15 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien auto nextEdgeColorGroupSize = edgeColorGroupSize; /* next value that we are going to try */ auto lowerEdgeColorGroupSize = 1ul; /* lower bound that is known to work */ + bool admissibleColoring = false; /* keep track wether the last tested coloring is admissible */ + while (true) { edgeColoring = colorSparsePattern(pattern, nextEdgeColorGroupSize, balanceColors); /*--- If the coloring fails, reduce the color group size. ---*/ if (edgeColoring.empty()) { upperEdgeColorGroupSize = nextEdgeColorGroupSize; + admissibleColoring = false; } /*--- If the coloring succeeds, check the efficiency. ---*/ else { @@ -3659,10 +3662,12 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien /*--- If the coloring is not efficient, reduce the color group size. ---*/ if (currentEfficiency < COLORING_EFF_THRESH) { upperEdgeColorGroupSize = nextEdgeColorGroupSize; + admissibleColoring = false; } /*--- Otherwise, enlarge the color group size. ---*/ else { lowerEdgeColorGroupSize = nextEdgeColorGroupSize; + admissibleColoring = true; } } @@ -3676,7 +3681,14 @@ const CCompressedSparsePatternUL& CGeometry::GetEdgeColoring(su2double* efficien } edgeColorGroupSize = nextEdgeColorGroupSize; - } else { + + /*--- If the last tested coloring was not admissible, recompute the final coloring. ---*/ + if (!admissibleColoring) { + edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); + } + } + /*--- No adaptivity. ---*/ + else { edgeColoring = colorSparsePattern(pattern, edgeColorGroupSize, balanceColors); } From 8b89e857ff72782b0caccc3f63385c03bc67f6f7 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 6 Dec 2023 15:01:13 -0800 Subject: [PATCH 84/99] fix submodules --- externals/codi | 2 +- externals/mel | 2 +- subprojects/CoolProp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/externals/codi b/externals/codi index 17232fed052..0ad036f2c82 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 17232fed05245dbb8f04a31e274a02d53458c75c +Subproject commit 0ad036f2c8254fa7b77180a443d99248c047c877 diff --git a/externals/mel b/externals/mel index 2484cd3258e..46205ab019e 160000 --- a/externals/mel +++ b/externals/mel @@ -1 +1 @@ -Subproject commit 2484cd3258ef800a10e361016cb341834ee7930b +Subproject commit 46205ab019e5224559091375a6d71aabae6bc5b9 diff --git a/subprojects/CoolProp b/subprojects/CoolProp index 0ce42fcf3bb..bafdea1f39e 160000 --- a/subprojects/CoolProp +++ b/subprojects/CoolProp @@ -1 +1 @@ -Subproject commit 0ce42fcf3bb2c373512bc825a4f0c1973a78f307 +Subproject commit bafdea1f39ee873a6bb9833e3a21fe41f90b85e8 From e0e61c6680526c80998e8c4574ae14d50006b69e Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 16 Jan 2024 14:32:16 +0000 Subject: [PATCH 85/99] github-adv-security comments --- SU2_CFD/include/output/CTurboOutput.hpp | 10 +++++----- SU2_CFD/src/output/CFlowCompOutput.cpp | 24 ------------------------ SU2_CFD/src/output/CTurboOutput.cpp | 5 ++--- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp index 38bebf8df09..9dc1a88b265 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -221,17 +221,17 @@ class CTurbomachineryStagePerformance { virtual void ComputeCompressorStagePerformance(const CTurbomachineryState& InState, const CTurbomachineryState& OutState); - const su2double GetTotalStaticEfficiency() const { return TotalStaticEfficiency; } + su2double GetTotalStaticEfficiency() const { return TotalStaticEfficiency; } - const su2double GetTotalTotalEfficiency() const { return TotalTotalEfficiency; } + su2double GetTotalTotalEfficiency() const { return TotalTotalEfficiency; } - const su2double GetEulerianWork() const { return EulerianWork; } + su2double GetEulerianWork() const { return EulerianWork; } const su2double& GetNormEntropyGen() const { return NormEntropyGen; } - const su2double GetTotalStaticPressureRatio() const { return TotalStaticPressureRatio; } + su2double GetTotalStaticPressureRatio() const { return TotalStaticPressureRatio; } - const su2double GetTotalTotalPressureRatio() const { return TotalTotalPressureRatio; } + su2double GetTotalTotalPressureRatio() const { return TotalTotalPressureRatio; } }; /*! diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 8017a852c51..b12e09ddc99 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -669,10 +669,6 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); iSpan++){ @@ -688,15 +684,6 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetInletState().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(); - // TODO: Add the variables back into CTurboOutput - // if(TurbIntensityIn[val_iZone][iSpan] > 1.0){ - // file.width(30); file << TurbIntensityIn [val_iZone][config[ZONE_0]->GetnSpan_iZones(val_iZone)/2]; - // }else{ - // file.width(30); file << TurbIntensityIn [val_iZone][iSpan]; - // } - // file.width(30); file << Turb2LamViscRatioIn [val_iZone][iSpan]; - // file.width(30); file << NuFactorIn [val_iZone][iSpan]; - // file << endl; } file.close(); @@ -727,9 +714,6 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetOutletState().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(); - // if(TurbIntensityOut[val_iZone][iSpan] > 1.0){ - // file.width(30); file << TurbIntensityOut [val_iZone][config[ZONE_0]->GetnSpan_iZones(val_iZone)/2]; - // }else{ - // file.width(30); file << TurbIntensityOut [val_iZone][iSpan]; - // } - // file.width(30); file << Turb2LamViscRatioOut [val_iZone][iSpan]; - // file.width(30); file << NuFactorOut [val_iZone][iSpan]; - // file << endl; } file.close(); diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index 335b06e188d..c17f78f87cc 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -31,7 +31,6 @@ CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState() { Density = Press CTurbomachineryPrimitiveState::CTurbomachineryPrimitiveState(vector TurboPrimitive, unsigned short nDim, su2double tangVel) : Density(TurboPrimitive[0]), Pressure(TurboPrimitive[1]), TangVelocity(tangVel) { - // Velocity.assign(TurboPrimitive+2, TurboPrimitive + nDim+2 ); Velocity = {TurboPrimitive.begin() + 2, TurboPrimitive.end()}; } @@ -123,7 +122,7 @@ void CTurbineBladePerformance::ComputePerformance(const CTurbomachineryCombinedP su2double relVelOutIs2 = 2 * (OutletState.GetRothalpy() - enthalpyOutIs) + tangVel * tangVel; /*--- Compute performance ---*/ - EntropyGen = (OutletState.GetEntropy() - InletState.GetEntropy()); // / abs(InletState.GetEntropy() + 1); + EntropyGen = (OutletState.GetEntropy() - InletState.GetEntropy()); EulerianWork = InletState.GetTotalEnthalpy() - OutletState.GetTotalEnthalpy(); TotalPressureLoss = (InletState.GetTotalRelPressure() - OutletState.GetTotalRelPressure()) / (OutletState.GetTotalRelPressure() - OutletState.GetPressure()); @@ -146,7 +145,7 @@ void CCompressorBladePerformance::ComputePerformance(const CTurbomachineryCombin su2double relVelOutIs2 = 2 * (OutletState.GetRothalpy() - enthalpyOutIs) + tangVel * tangVel; /*--- Compute performance ---*/ - EntropyGen = (OutletState.GetEntropy() - InletState.GetEntropy()); // / abs(InletState.GetEntropy() + 1); + EntropyGen = (OutletState.GetEntropy() - InletState.GetEntropy()); EulerianWork = OutletState.GetTotalEnthalpy() - InletState.GetTotalEnthalpy(); TotalPressureLoss = (InletState.GetTotalRelPressure() - OutletState.GetTotalRelPressure()) / (InletState.GetTotalRelPressure() - InletState.GetPressure()); From efeabbdb48d71fd32ef1b7754807ce82377b44b8 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 16 Jan 2024 18:17:21 +0000 Subject: [PATCH 86/99] codeql check & singlezone bugfix --- SU2_CFD/src/output/CFlowCompOutput.cpp | 436 +++++++++++++------------ SU2_CFD/src/output/COutput.cpp | 2 +- 2 files changed, 220 insertions(+), 218 deletions(-) diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index b12e09ddc99..ec1b4a5f8c5 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -637,234 +637,236 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetSpanWiseValue(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)); + if (rank != MASTER_NODE){ + return 0; + } + + 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.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.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.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.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"; } - - 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(); + else { + file.width(30); file << BladePerf->GetInletState().GetAbsFlowAngle()*180.0/PI_NUMBER; } - - 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)); + if(isnan(BladePerf->GetInletState().GetFlowAngle())){ + file.width(30); file << "0.0000"; + } + else{ + file.width(30); file << BladePerf->GetInletState().GetFlowAngle()*180.0/PI_NUMBER; } - - 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.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.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.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.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(); + file.close(); } } -} \ No newline at end of file diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 29f2cc96a38..5b2695bcfd2 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -1346,7 +1346,7 @@ void COutput::CheckHistoryOutput(unsigned short nZone) { /*--- Checks if TURBO_PERF is enabled in config and sets the final zone calculations to be output ---*/ for (unsigned short iReqField = 0; iReqField < nRequestedHistoryFields; iReqField++){ - if (requestedHistoryFields[iReqField] == "TURBO_PERF"){ + if (requestedHistoryFields[iReqField] == "TURBO_PERF" && nZone > 1){ std::stringstream reqField; std::string strZones = std::to_string(nZone-1); reqField << "TURBO_PERF[" << strZones << "]"; From 36c730f042cefea53cd061875ccbe4d77a943b2c Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 16 Jan 2024 18:27:11 +0000 Subject: [PATCH 87/99] typo --- SU2_CFD/src/output/CFlowCompOutput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index ec1b4a5f8c5..09f37f9c574 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -638,7 +638,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetSpanWiseValue(INFLOW); From 463d001161d5cb9189f64690aef7d157e334d0a7 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 16 Jan 2024 18:30:47 +0000 Subject: [PATCH 88/99] better way --- SU2_CFD/src/output/CFlowCompOutput.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 09f37f9c574..f203c5a9324 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -632,15 +632,13 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetBladesPerformances(); - - - /*--- Start of write file turboperformance spanwise ---*/ if (rank != MASTER_NODE){ return; } + auto BladePerformance = TurboPerf->GetBladesPerformances(); + + /*--- Start of write file turboperformance spanwise ---*/ SpanWiseValuesIn = geometry->GetSpanWiseValue(INFLOW); SpanWiseValuesOut = geometry->GetSpanWiseValue(OUTFLOW); @@ -867,6 +865,4 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr Date: Mon, 22 Jan 2024 12:26:47 +0000 Subject: [PATCH 89/99] Added catch to prevent segfault when not including TURBO_PERF_KIND --- Common/src/CConfig.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 9922838f129..23dafdb1d6d 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1631,9 +1631,6 @@ void CConfig::SetConfig_Options() { \n OPTIONS: see \link TurboPerfKind_Map \endlink \n Default: TURBINE */ addEnumListOption("TURBO_PERF_KIND", nTurboMachineryKind, Kind_TurboPerf, TurboPerfKind_Map); /*!\brief MARKER_SHROUD \n DESCRIPTION: markers in which velocity is forced to 0.0. -========= - /*!\brief MARKER_SHROUD \n DESCRIPTION: markers in which velocity is forced to 0.0. ->>>>>>>>> Temporary merge branch 2 * \n Format: (shroud1, shroud2, ...)*/ addStringListOption("MARKER_SHROUD", nMarker_Shroud, Marker_Shroud); /*!\brief MARKER_SUPERSONIC_INLET \n DESCRIPTION: Supersonic inlet boundary marker(s) @@ -4026,6 +4023,11 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i SU2_MPI::Error("Giles Boundary conditions can only be used with turbomachinery markers", CURRENT_FUNCTION); } + /*--- Check if turbomachinery performance kind is specified with turbo markers ---*/ + if (GetBoolTurbomachinery() && !(nTurboMachineryKind/nZone == 1)){ + SU2_MPI::Error("Insufficient TURBO_PERF_KIND options specified with turbomachinery markers", CURRENT_FUNCTION); + } + /*--- Check for Boundary condition available for NICFD ---*/ if ((!ideal_gas) && (!noneq_gas)) { From 7eb2d36b816513e7e53e93a3c0cb4e2869f001c1 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 30 Jan 2024 16:57:50 +0000 Subject: [PATCH 90/99] bug fix and update reg tests --- SU2_CFD/src/drivers/CDriver.cpp | 1 - SU2_CFD/src/solvers/CEulerSolver.cpp | 2 +- TestCases/hybrid_regression.py | 10 +++++----- TestCases/parallel_regression.py | 10 +++++----- TestCases/serial_regression.py | 10 +++++----- .../turbomachinery/APU_turbocharger/Jones_restart.cfg | 2 +- .../turbomachinery/axial_stage_2D/Axial_stage2D.cfg | 2 +- .../transonic_stator_2D/transonic_stator_restart.cfg | 2 +- 8 files changed, 19 insertions(+), 20 deletions(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index ff80905273b..0fdfb2c2a2e 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2691,7 +2691,6 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, } } - //TODO: Fix mass flow for (iZone = 0; iZone < nZone-1; iZone++) { geometry[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config[iZone],geometry[iZone][INST_0][MESH_0], iZone); } diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 01fd0903d04..bc8369c55f0 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -9395,7 +9395,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC auto TurboVel = (marker_flag == INFLOW) ? TurboVelocityIn[iMarkerTP - 1][iSpan] : TurboVelocityOut[iMarkerTP - 1][iSpan]; if (performance_average_process == MIXEDOUT) { - for (auto iDim = 0u; iDim < nDim; iDim++) TurboVel[iDim] = avgMixTurboVelocity[iDim]; + for (auto iDim = 0u; iDim < nDim; iDim++) TurboVel[iDim] = avgVelocity[iDim]; } else { ComputeTurboVelocity(avgVelocity, AverageTurboNormal , TurboVel, marker_flag, config->GetKind_TurboMachinery(iZone)); } diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index 4ff8d5f4651..2f58282d6fc 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -561,7 +561,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-6.594590, -2.792279, -14.336129, -8.776066, -11.371439, -5.845633, 73273, 73273] + Jones_tc_restart.test_vals = [-6.594590, -2.792279, -14.336129, -8.776066, -11.371439, -5.845633, 73273, 73273, 0.019884, 82.491] test_list.append(Jones_tc_restart) # 2D axial stage @@ -569,8 +569,8 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [0.983739, 1.534333, -2.888521, 2.606770, -2.418339, 3.087275, 106380, 106380] - axial_stage2D.test_vals_aarch64 = [0.983739, 1.534333, -2.888521, 2.606770, -2.418339, 3.087275, 106380, 106380] + axial_stage2D.test_vals = [0.983739, 1.534333, -2.888521, 2.606770, -2.418339, 3.087275, 106380, 106380, 5.7325, 64.711] + axial_stage2D.test_vals_aarch64 = [0.983739, 1.534333, -2.888521, 2.606770, -2.418339, 3.087275, 106380, 106380, 5.7325, 64.711] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -578,8 +578,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-5.007735, -3.099310, -2.751696, 1.091966, -3.542819, 2.163237, -471630] - transonic_stator_restart.test_vals_aarch64 = [-5.007735, -3.099310, -2.751696, 1.091966, -3.542819, 2.163237, -471630] + transonic_stator_restart.test_vals = [-5.007735, -3.099310, -2.751696, 1.091966, -3.542819, 2.163237, -471630, 94.866, -0.0035806] + transonic_stator_restart.test_vals_aarch64 = [-5.007735, -3.099310, -2.751696, 1.091966, -3.542819, 2.163237, -471630, 94.866, -0.0035806] test_list.append(transonic_stator_restart) ###################################### diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index eca22d49b8e..3b1a0d4922a 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1049,7 +1049,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-6.594590, -2.792281, -14.336129, -8.776067, -11.371439, -5.845633, 73273, 73273] + Jones_tc_restart.test_vals = [-6.594590, -2.792281, -14.336129, -8.776067, -11.371439, -5.845633, 73273, 73273, 0.019884, 82.491] test_list.append(Jones_tc_restart) # 2D axial stage @@ -1057,8 +1057,8 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [0.983754, 1.534455, -2.888523, 2.606770, -2.418403, 3.087203, 106380, 106380] - axial_stage2D.test_vals_aarch64 = [0.983754, 1.534455, -2.888523, 2.606770, -2.418403, 3.087203, 106380, 106380] + axial_stage2D.test_vals = [0.983754, 1.534455, -2.888523, 2.606770, -2.418403, 3.087203, 106380, 106380, 5.7325, 64.711] + axial_stage2D.test_vals_aarch64 = [0.983754, 1.534455, -2.888523, 2.606770, -2.418403, 3.087203, 106380, 106380, 5.7325, 64.711] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -1066,8 +1066,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630] - transonic_stator_restart.test_vals_aarch64 = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630] + transonic_stator_restart.test_vals = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.866, -0.0035806] + transonic_stator_restart.test_vals_aarch64 = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.866, -0.0035806] test_list.append(transonic_stator_restart) ###################################### diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index ad18bc59b3d..b17ffc4a874 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -857,7 +857,7 @@ def main(): Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" Jones_tc_restart.test_iter = 5 - Jones_tc_restart.test_vals = [-6.594586, -2.792279, -14.336132, -8.776068, -11.371439, -5.845632, 73273, 73273] + Jones_tc_restart.test_vals = [-6.594586, -2.792279, -14.336132, -8.776068, -11.371439, -5.845632, 73273, 73273, 0.019884, 82.491] test_list.append(Jones_tc_restart) # 2D axial stage @@ -865,8 +865,8 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [0.983751, 1.534480, -2.888520, 2.606773, -2.418421, 3.087187, 106380, 106380] - axial_stage2D.test_vals_aarch64 = [0.983751, 1.534480, -2.888520, 2.606773, -2.418421, 3.087187, 106380, 106380] + axial_stage2D.test_vals = [0.983751, 1.534480, -2.888520, 2.606773, -2.418421, 3.087187, 106380, 106380, 5.7325, 64.711] + axial_stage2D.test_vals_aarch64 = [0.983751, 1.534480, -2.888520, 2.606773, -2.418421, 3.087187, 106380, 106380, 5.7325, 64.711] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -874,8 +874,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-5.008547, -3.102420, -2.752033, 1.091152, -3.543849, 2.169844, -471630] - transonic_stator_restart.test_vals_aarch64 = [-5.008547, -3.102420, -2.752033, 1.091152, -3.543849, 2.169844, -471630] + transonic_stator_restart.test_vals = [-5.008547, -3.102420, -2.752033, 1.091152, -3.543849, 2.169844, -471630, 94.866, -0.0035806] + transonic_stator_restart.test_vals_aarch64 = [-5.008547, -3.102420, -2.752033, 1.091152, -3.543849, 2.169844, -471630, 94.866, -0.0035806] test_list.append(transonic_stator_restart) diff --git a/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg b/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg index c2dc86d4572..42de00358bd 100755 --- a/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg +++ b/TestCases/turbomachinery/APU_turbocharger/Jones_restart.cfg @@ -139,7 +139,7 @@ CONV_CAUCHY_EPS= 1E-6 % % ------------------------- INPUT/OUTPUT INFORMATION --------------------------% % -SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], AVG_BGS_RES[1], RMS_DENSITY[0], RMS_ENERGY[0], RMS_DENSITY[1], RMS_ENERGY[1], SURFACE_TOTAL_PRESSURE[1] +SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], AVG_BGS_RES[1], RMS_DENSITY[0], RMS_ENERGY[0], RMS_DENSITY[1], RMS_ENERGY[1], SURFACE_TOTAL_PRESSURE[1], MassFlowOut_2[1], TotalStaticEfficiency[1] MESH_FILENAME= mesh_jones_turbine.su2 MESH_FORMAT= SU2 MESH_OUT_FILENAME= meshout.su2 diff --git a/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg b/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg index bae9194f79d..75be16ada08 100755 --- a/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg +++ b/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg @@ -141,7 +141,7 @@ CONV_CAUCHY_EPS= 1E-6 % % ------------------------- INPUT/OUTPUT INFORMATION --------------------------% % -SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], AVG_BGS_RES[1], RMS_DENSITY[0], RMS_ENERGY[0], RMS_DENSITY[1], RMS_ENERGY[1], SURFACE_TOTAL_PRESSURE[1] +SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], AVG_BGS_RES[1], RMS_DENSITY[0], RMS_ENERGY[0], RMS_DENSITY[1], RMS_ENERGY[1], SURFACE_TOTAL_PRESSURE[1], MassFlowOut_2[1], TotalStaticEfficiency[1] MESH_FILENAME= mesh_axial_stage_2d_turb.su2 MESH_FORMAT= SU2 MESH_OUT_FILENAME= meshout.su2 diff --git a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg index 3c5be8144aa..7608b5cebf3 100644 --- a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg +++ b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_restart.cfg @@ -139,7 +139,7 @@ CONV_CAUCHY_EPS= 1E-6 % % ------------------------- INPUT/OUTPUT INFORMATION --------------------------% % -SCREEN_OUTPUT= INNER_ITER, RMS_RES, SURFACE_PRESSURE_DROP +SCREEN_OUTPUT= INNER_ITER, RMS_RES, SURFACE_PRESSURE_DROP, MassFlowOut_1, TotalStaticEfficiency MESH_FILENAME= mesh_stator_turb.su2 MESH_FORMAT= SU2 MESH_OUT_FILENAME= su2mesh_per.su2 From 10f814fe1ee8d4090546ade75a0f34eccbffc619 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 30 Jan 2024 17:34:52 +0000 Subject: [PATCH 91/99] unused var --- SU2_CFD/src/solvers/CEulerSolver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index bc8369c55f0..260f72f3de6 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -9246,7 +9246,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC const bool belowMachLimit = (abs(MachTest)< config->GetAverageMachLimit()); su2double avgDensity{0}, avgPressure{0}, avgKine{0}, avgOmega{0}, avgNu{0}, - avgVelocity[MAXNDIM] = {0}, avgMixTurboVelocity[MAXNDIM] = {0}; + avgVelocity[MAXNDIM] = {0} for (auto iVar = 0u; iVar Date: Tue, 30 Jan 2024 17:48:05 +0000 Subject: [PATCH 92/99] semi-colon --- SU2_CFD/src/solvers/CEulerSolver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 260f72f3de6..05aec1c2843 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -9246,7 +9246,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC const bool belowMachLimit = (abs(MachTest)< config->GetAverageMachLimit()); su2double avgDensity{0}, avgPressure{0}, avgKine{0}, avgOmega{0}, avgNu{0}, - avgVelocity[MAXNDIM] = {0} + avgVelocity[MAXNDIM] = {0}; for (auto iVar = 0u; iVar Date: Wed, 31 Jan 2024 11:12:48 +0000 Subject: [PATCH 93/99] update regtest values --- TestCases/hybrid_regression.py | 4 ++-- TestCases/parallel_regression.py | 4 ++-- TestCases/serial_regression.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index 2f58282d6fc..16176bd5d8a 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -578,8 +578,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-5.007735, -3.099310, -2.751696, 1.091966, -3.542819, 2.163237, -471630, 94.866, -0.0035806] - transonic_stator_restart.test_vals_aarch64 = [-5.007735, -3.099310, -2.751696, 1.091966, -3.542819, 2.163237, -471630, 94.866, -0.0035806] + transonic_stator_restart.test_vals = [-5.007735, -3.099310, -2.751696, 1.091966, -3.542819, 2.163237, -471630, 94.866, -0.035738] + transonic_stator_restart.test_vals_aarch64 = [-5.007735, -3.099310, -2.751696, 1.091966, -3.542819, 2.163237, -471630, 94.866, -0.035738] test_list.append(transonic_stator_restart) ###################################### diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 3b1a0d4922a..3d8f362042b 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1066,8 +1066,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.866, -0.0035806] - transonic_stator_restart.test_vals_aarch64 = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.866, -0.0035806] + transonic_stator_restart.test_vals = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.868, -0.0035888] + transonic_stator_restart.test_vals_aarch64 = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.868, -0.0035888] test_list.append(transonic_stator_restart) ###################################### diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index b17ffc4a874..a75b17d48aa 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -874,8 +874,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-5.008547, -3.102420, -2.752033, 1.091152, -3.543849, 2.169844, -471630, 94.866, -0.0035806] - transonic_stator_restart.test_vals_aarch64 = [-5.008547, -3.102420, -2.752033, 1.091152, -3.543849, 2.169844, -471630, 94.866, -0.0035806] + transonic_stator_restart.test_vals = [-5.008547, -3.102420, -2.752033, 1.091152, -3.543849, 2.169844, -471630, 94.866, -0.035806] + transonic_stator_restart.test_vals_aarch64 = [-5.008547, -3.102420, -2.752033, 1.091152, -3.543849, 2.169844, -471630, 94.866, -0.035806] test_list.append(transonic_stator_restart) From c9c84499e8eaeb0afdf9fbf2912c32b209b918e7 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 31 Jan 2024 13:08:03 +0000 Subject: [PATCH 94/99] too many zeros --- TestCases/parallel_regression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 3d8f362042b..9e3c6b38df1 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1066,8 +1066,8 @@ def main(): transonic_stator_restart.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_restart.cfg_file = "transonic_stator_restart.cfg" transonic_stator_restart.test_iter = 20 - transonic_stator_restart.test_vals = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.868, -0.0035888] - transonic_stator_restart.test_vals_aarch64 = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.868, -0.0035888] + transonic_stator_restart.test_vals = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.868, -0.035888] + transonic_stator_restart.test_vals_aarch64 = [-5.011834, -3.091110, -2.757795, 1.087934, -3.544707, 2.166101, -471630, 94.868, -0.035888] test_list.append(transonic_stator_restart) ###################################### From be833010b0532aa9eadd8e6119d0e90917cfeb22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 1 Feb 2024 14:57:16 +0100 Subject: [PATCH 95/99] CoDiPack update. --- externals/codi | 2 +- meson_scripts/init.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/externals/codi b/externals/codi index 0ad036f2c82..9ca6c382806 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 0ad036f2c8254fa7b77180a443d99248c047c877 +Subproject commit 9ca6c38280610b3ea5337ca3e5b5085ee1c66b59 diff --git a/meson_scripts/init.py b/meson_scripts/init.py index 6bda759c734..63955c2579e 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -55,7 +55,7 @@ def init_submodules( # This information of the modules is used if projects was not cloned using git # The sha tag must be maintained manually to point to the correct commit - sha_version_codi = "0ad036f2c8254fa7b77180a443d99248c047c877" + sha_version_codi = "9ca6c38280610b3ea5337ca3e5b5085ee1c66b59" github_repo_codi = "https://github.com/scicompkl/CoDiPack" sha_version_medi = "aafc2d1966ba1233640af737e71c77c1a86183fd" github_repo_medi = "https://github.com/SciCompKL/MeDiPack" From 90ead3fc4f04f5b98ce723383d75b93df54c94ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 1 Feb 2024 15:04:19 +0100 Subject: [PATCH 96/99] OpDiLib update. --- externals/opdi | 2 +- meson_scripts/init.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/externals/opdi b/externals/opdi index c42cca71a3d..93d05a762f1 160000 --- a/externals/opdi +++ b/externals/opdi @@ -1 +1 @@ -Subproject commit c42cca71a3d0b44fb482e268ecd40b623e71776b +Subproject commit 93d05a762f1b614a84767ea5ba75fd7e2c27f317 diff --git a/meson_scripts/init.py b/meson_scripts/init.py index 63955c2579e..529c44cc2cc 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -59,7 +59,7 @@ def init_submodules( github_repo_codi = "https://github.com/scicompkl/CoDiPack" sha_version_medi = "aafc2d1966ba1233640af737e71c77c1a86183fd" github_repo_medi = "https://github.com/SciCompKL/MeDiPack" - sha_version_opdi = "c42cca71a3d0b44fb482e268ecd40b623e71776b" + sha_version_opdi = "93d05a762f1b614a84767ea5ba75fd7e2c27f317" github_repo_opdi = "https://github.com/SciCompKL/OpDiLib" sha_version_meson = "41c650a040d50e0912d268af7a903a9ce1456dfa" github_repo_meson = "https://github.com/mesonbuild/meson" From ad9c69736d0ba4deaffa2ec2285c328c12af8c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 1 Feb 2024 15:08:38 +0100 Subject: [PATCH 97/99] Update MeDiPack. --- externals/medi | 2 +- meson_scripts/init.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/externals/medi b/externals/medi index aafc2d1966b..85711944f8d 160000 --- a/externals/medi +++ b/externals/medi @@ -1 +1 @@ -Subproject commit aafc2d1966ba1233640af737e71c77c1a86183fd +Subproject commit 85711944f8d5d03dd75c635f8a18e220b216040d diff --git a/meson_scripts/init.py b/meson_scripts/init.py index 529c44cc2cc..5507767dbd4 100755 --- a/meson_scripts/init.py +++ b/meson_scripts/init.py @@ -57,7 +57,7 @@ def init_submodules( # The sha tag must be maintained manually to point to the correct commit sha_version_codi = "9ca6c38280610b3ea5337ca3e5b5085ee1c66b59" github_repo_codi = "https://github.com/scicompkl/CoDiPack" - sha_version_medi = "aafc2d1966ba1233640af737e71c77c1a86183fd" + sha_version_medi = "85711944f8d5d03dd75c635f8a18e220b216040d" github_repo_medi = "https://github.com/SciCompKL/MeDiPack" sha_version_opdi = "93d05a762f1b614a84767ea5ba75fd7e2c27f317" github_repo_opdi = "https://github.com/SciCompKL/OpDiLib" From 23883743d1959c49eddf0292ef1ea503a84db066 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 1 Feb 2024 16:33:51 +0000 Subject: [PATCH 98/99] indentation and reorganising of output function called for improved stack --- Common/src/CConfig.cpp | 14 +-- SU2_CFD/src/iteration/CFluidIteration.cpp | 1 - SU2_CFD/src/output/CFlowCompOutput.cpp | 135 ++++++++++------------ SU2_CFD/src/output/COutput.cpp | 13 ++- 4 files changed, 78 insertions(+), 85 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 23dafdb1d6d..86a0d31e456 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -6916,14 +6916,14 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { break; } } - else { - if (Time_Domain) { - cout << "Dynamic structural analysis."<< endl; - cout << "Time step provided by the user for the dynamic analysis(s): "<< Time_Step << "." << endl; - } else { - cout << "Static structural analysis." << endl; + else { + if (Time_Domain) { + cout << "Dynamic structural analysis."<< endl; + cout << "Time step provided by the user for the dynamic analysis(s): "<< Time_Step << "." << endl; + } else { + cout << "Static structural analysis." << endl; + } } - } if ((Kind_Solver == MAIN_SOLVER::EULER) || (Kind_Solver == MAIN_SOLVER::NAVIER_STOKES) || (Kind_Solver == MAIN_SOLVER::RANS) || (Kind_Solver == MAIN_SOLVER::INC_EULER) || (Kind_Solver == MAIN_SOLVER::INC_NAVIER_STOKES) || (Kind_Solver == MAIN_SOLVER::INC_RANS) || diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 0f2bf9b5a81..c35dcf6d742 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -227,7 +227,6 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter()); } - // should this be in an else statement? output->SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), config[val_iZone]->GetInnerIter()); diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index f203c5a9324..efd8c530175 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -513,40 +513,38 @@ void CFlowCompOutput::SetTurboPerformance_Output(std::shared_ptr T curInnerIter = InnerIter; stringstream TurboInOutTable, TurboPerfTable; - if(rank == MASTER_NODE) { - auto BladePerformance = TurboPerf->GetBladesPerformances(); + auto BladePerformance = TurboPerf->GetBladesPerformances(); /*-- Table for Turbomachinery Performance Values --*/ PrintingToolbox::CTablePrinter TurboInOut(&TurboInOutTable); - TurboInOutTable<<"-- Turbomachinery inlet and outlet property Summary:"<GetnZone()-1; iZone++) { - auto nSpan = config->GetnSpan_iZones(iZone); - const auto& BladePerf = BladePerformance.at(iZone).at(nSpan); - - TurboInOut<<" BLADE ROW INDEX "<GetInletState().GetEntropy() << BladePerf->GetOutletState().GetEntropy(); - TurboInOut << "Total Enthalpy " << BladePerf->GetInletState().GetTotalEnthalpy() << BladePerf->GetOutletState().GetTotalEnthalpy(); - TurboInOut << "Total Pressure " << BladePerf->GetInletState().GetTotalPressure() << BladePerf->GetOutletState().GetTotalPressure(); - TurboInOut << "Pressure " << BladePerf->GetInletState().GetPressure() << BladePerf->GetOutletState().GetPressure(); - TurboInOut << "Density " << BladePerf->GetInletState().GetDensity() << BladePerf->GetOutletState().GetDensity(); - TurboInOut << "Normal Velocity " << BladePerf->GetInletState().GetVelocity()[0] << BladePerf->GetOutletState().GetVelocity()[0]; - TurboInOut << "Tangential Velocity " << BladePerf->GetInletState().GetVelocity()[1] << BladePerf->GetOutletState().GetVelocity()[1]; - TurboInOut << "Mass Flow " << BladePerf->GetInletState().GetMassFlow() << BladePerf->GetOutletState().GetMassFlow(); - TurboInOut << "Mach " << BladePerf->GetInletState().GetMachValue() << BladePerf->GetOutletState().GetMachValue(); - TurboInOut << "Abs Flow Angle " << BladePerf->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER << BladePerf->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER; - TurboInOut.PrintFooter(); - } - cout<GetnZone()-1; iZone++) { + auto nSpan = config->GetnSpan_iZones(iZone); + const auto& BladePerf = BladePerformance.at(iZone).at(nSpan); + + TurboInOut<<" BLADE ROW INDEX "<GetInletState().GetEntropy() << BladePerf->GetOutletState().GetEntropy(); + TurboInOut << "Total Enthalpy " << BladePerf->GetInletState().GetTotalEnthalpy() << BladePerf->GetOutletState().GetTotalEnthalpy(); + TurboInOut << "Total Pressure " << BladePerf->GetInletState().GetTotalPressure() << BladePerf->GetOutletState().GetTotalPressure(); + TurboInOut << "Pressure " << BladePerf->GetInletState().GetPressure() << BladePerf->GetOutletState().GetPressure(); + TurboInOut << "Density " << BladePerf->GetInletState().GetDensity() << BladePerf->GetOutletState().GetDensity(); + TurboInOut << "Normal Velocity " << BladePerf->GetInletState().GetVelocity()[0] << BladePerf->GetOutletState().GetVelocity()[0]; + TurboInOut << "Tangential Velocity " << BladePerf->GetInletState().GetVelocity()[1] << BladePerf->GetOutletState().GetVelocity()[1]; + TurboInOut << "Mass Flow " << BladePerf->GetInletState().GetMassFlow() << BladePerf->GetOutletState().GetMassFlow(); + TurboInOut << "Mach " << BladePerf->GetInletState().GetMachValue() << BladePerf->GetOutletState().GetMachValue(); + TurboInOut << "Abs Flow Angle " << BladePerf->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER << BladePerf->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER; + TurboInOut.PrintFooter(); + } + cout< TurboPerf, CConfig *config) { @@ -580,44 +578,41 @@ void CFlowCompOutput::SetTurboMultiZonePerformance_Output(CTurbomachineryStagePe } void CFlowCompOutput::LoadTurboHistoryData(CTurbomachineryStagePerformance* TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) { - - if (rank == MASTER_NODE){ - auto BladePerformance = TurboPerf->GetBladesPerformances(); - for (unsigned short iZone = 0; iZone <= config->GetnZone()-1; iZone++) { - auto nSpan = config->GetnSpan_iZones(iZone); - const auto& BladePerf = BladePerformance.at(iZone).at(nSpan); - - stringstream tag; - tag << iZone + 1; - - SetHistoryOutputValue("EntropyIn_" + tag.str(), BladePerf->GetInletState().GetEntropy()); - SetHistoryOutputValue("EntropyOut_" + tag.str(), BladePerf->GetOutletState().GetEntropy()); - SetHistoryOutputValue("TotalEntahalpyIn_" + tag.str(), BladePerf->GetInletState().GetTotalEnthalpy()); - SetHistoryOutputValue("TotalEnthalpyOut_" + tag.str(), BladePerf->GetOutletState().GetTotalEnthalpy()); - SetHistoryOutputValue("TotalPressureIn_" + tag.str(), BladePerf->GetInletState().GetTotalPressure()); - SetHistoryOutputValue("TotalPressureOut_" + tag.str(), BladePerf->GetOutletState().GetTotalPressure()); - SetHistoryOutputValue("PressureIn_" + tag.str(), BladePerf->GetInletState().GetPressure()); - SetHistoryOutputValue("PressureOut_" + tag.str(), BladePerf->GetOutletState().GetPressure()); - SetHistoryOutputValue("DensityIn_" + tag.str(), BladePerf->GetInletState().GetDensity()); - SetHistoryOutputValue("DensityOut_" + tag.str(), BladePerf->GetOutletState().GetDensity()); - SetHistoryOutputValue("NormalVelocityIn_" + tag.str(), BladePerf->GetInletState().GetVelocity()[0]); - SetHistoryOutputValue("NormalVelocityOut_" + tag.str(), BladePerf->GetOutletState().GetVelocity()[0]); - SetHistoryOutputValue("TangentialVelocityIn_" + tag.str(), BladePerf->GetInletState().GetVelocity()[1]); - SetHistoryOutputValue("TangentialVelocityOut_" + tag.str(), BladePerf->GetOutletState().GetVelocity()[1]); - SetHistoryOutputValue("MassFlowIn_" + tag.str(), BladePerf->GetInletState().GetMassFlow()); - SetHistoryOutputValue("MassFlowOut_" + tag.str(), BladePerf->GetOutletState().GetMassFlow()); - SetHistoryOutputValue("MachIn_" + tag.str(), BladePerf->GetInletState().GetMachValue()); - SetHistoryOutputValue("MachOut_" + tag.str(), BladePerf->GetOutletState().GetMachValue()); - SetHistoryOutputValue("AbsFlowAngleIn_" + tag.str(), BladePerf->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER); - SetHistoryOutputValue("AbsFlowAngleOut_" + tag.str(), BladePerf->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER); - } - SetHistoryOutputValue("EntropyGeneration", TurboStagePerf->GetNormEntropyGen()*100); - SetHistoryOutputValue("EulerianWork", TurboStagePerf->GetEulerianWork()); - SetHistoryOutputValue("TotalStaticEfficiency", TurboStagePerf->GetTotalStaticEfficiency()*100); - SetHistoryOutputValue("TotalTotalEfficiency", TurboStagePerf->GetTotalTotalEfficiency()*100); - SetHistoryOutputValue("PressureRatioTS", TurboStagePerf->GetTotalStaticPressureRatio()); - SetHistoryOutputValue("PressureRatioTT", TurboStagePerf->GetTotalTotalPressureRatio()); - } + auto BladePerformance = TurboPerf->GetBladesPerformances(); + for (unsigned short iZone = 0; iZone <= config->GetnZone()-1; iZone++) { + auto nSpan = config->GetnSpan_iZones(iZone); + const auto& BladePerf = BladePerformance.at(iZone).at(nSpan); + + stringstream tag; + tag << iZone + 1; + + SetHistoryOutputValue("EntropyIn_" + tag.str(), BladePerf->GetInletState().GetEntropy()); + SetHistoryOutputValue("EntropyOut_" + tag.str(), BladePerf->GetOutletState().GetEntropy()); + SetHistoryOutputValue("TotalEntahalpyIn_" + tag.str(), BladePerf->GetInletState().GetTotalEnthalpy()); + SetHistoryOutputValue("TotalEnthalpyOut_" + tag.str(), BladePerf->GetOutletState().GetTotalEnthalpy()); + SetHistoryOutputValue("TotalPressureIn_" + tag.str(), BladePerf->GetInletState().GetTotalPressure()); + SetHistoryOutputValue("TotalPressureOut_" + tag.str(), BladePerf->GetOutletState().GetTotalPressure()); + SetHistoryOutputValue("PressureIn_" + tag.str(), BladePerf->GetInletState().GetPressure()); + SetHistoryOutputValue("PressureOut_" + tag.str(), BladePerf->GetOutletState().GetPressure()); + SetHistoryOutputValue("DensityIn_" + tag.str(), BladePerf->GetInletState().GetDensity()); + SetHistoryOutputValue("DensityOut_" + tag.str(), BladePerf->GetOutletState().GetDensity()); + SetHistoryOutputValue("NormalVelocityIn_" + tag.str(), BladePerf->GetInletState().GetVelocity()[0]); + SetHistoryOutputValue("NormalVelocityOut_" + tag.str(), BladePerf->GetOutletState().GetVelocity()[0]); + SetHistoryOutputValue("TangentialVelocityIn_" + tag.str(), BladePerf->GetInletState().GetVelocity()[1]); + SetHistoryOutputValue("TangentialVelocityOut_" + tag.str(), BladePerf->GetOutletState().GetVelocity()[1]); + SetHistoryOutputValue("MassFlowIn_" + tag.str(), BladePerf->GetInletState().GetMassFlow()); + SetHistoryOutputValue("MassFlowOut_" + tag.str(), BladePerf->GetOutletState().GetMassFlow()); + SetHistoryOutputValue("MachIn_" + tag.str(), BladePerf->GetInletState().GetMachValue()); + SetHistoryOutputValue("MachOut_" + tag.str(), BladePerf->GetOutletState().GetMachValue()); + SetHistoryOutputValue("AbsFlowAngleIn_" + tag.str(), BladePerf->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER); + SetHistoryOutputValue("AbsFlowAngleOut_" + tag.str(), BladePerf->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER); + } + SetHistoryOutputValue("EntropyGeneration", TurboStagePerf->GetNormEntropyGen()*100); + SetHistoryOutputValue("EulerianWork", TurboStagePerf->GetEulerianWork()); + SetHistoryOutputValue("TotalStaticEfficiency", TurboStagePerf->GetTotalStaticEfficiency()*100); + SetHistoryOutputValue("TotalTotalEfficiency", TurboStagePerf->GetTotalTotalEfficiency()*100); + SetHistoryOutputValue("PressureRatioTS", TurboStagePerf->GetTotalStaticPressureRatio()); + SetHistoryOutputValue("PressureRatioTT", TurboStagePerf->GetTotalTotalPressureRatio()); } void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr TurboPerf, CGeometry *geometry, CConfig **config, unsigned short val_iZone) { @@ -632,10 +627,6 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetBladesPerformances(); /*--- Start of write file turboperformance spanwise ---*/ diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 5b2695bcfd2..99f6203074a 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -235,18 +235,21 @@ void COutput::SetHistoryOutput(CGeometry ****geometry, CSolver *****solver, CCon Iter = OuterIter; /*--- Turbomachinery Performance Screen summary output---*/ - if (Iter%100 == 0) { + if (Iter%100 == 0 && rank == MASTER_NODE) { SetTurboPerformance_Output(TurboPerf, config[val_iZone], TimeIter, OuterIter, InnerIter); - if (rank == MASTER_NODE) SetTurboMultiZonePerformance_Output(TurboStagePerf, TurboPerf, config[val_iZone]); + SetTurboMultiZonePerformance_Output(TurboStagePerf, TurboPerf, config[val_iZone]); } for (int iZone = 0; iZone < config[ZONE_0]->GetnZone(); iZone ++){ - WriteTurboSpanwisePerformance(TurboPerf, geometry[iZone][val_iInst][MESH_0], config, iZone); + if (rank == MASTER_NODE) { + WriteTurboSpanwisePerformance(TurboPerf, geometry[iZone][val_iInst][MESH_0], config, iZone); + } } /*--- Update turboperformance history file*/ - LoadTurboHistoryData(TurboStagePerf, TurboPerf, config[val_iZone]); - + if (rank == MASTER_NODE){ + LoadTurboHistoryData(TurboStagePerf, TurboPerf, config[val_iZone]); + } SetHistoryOutput(geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], TimeIter, OuterIter,InnerIter); } From 9629bb2fdd2fe11bb2e84c51106236079c54041f Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 6 Feb 2024 16:25:03 +0000 Subject: [PATCH 99/99] changes to address comments --- Common/include/option_structure.hpp | 12 ++-- Common/src/geometry/CPhysicalGeometry.cpp | 82 +++++++++++------------ SU2_CFD/include/iteration/CIteration.hpp | 1 - SU2_CFD/include/output/CTurboOutput.hpp | 8 +-- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 5 +- SU2_CFD/src/iteration/CFluidIteration.cpp | 2 - SU2_CFD/src/output/CFlowCompOutput.cpp | 48 +++++-------- TestCases/parallel_regression.py | 2 +- TestCases/serial_regression.py | 2 +- 9 files changed, 72 insertions(+), 90 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index f537ca33637..a2b5f551525 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1780,12 +1780,12 @@ static const MapType SpanWise_Map = { /*! * \brief Types of mixing process for averaging quantities at the boundaries. */ -enum TURBOMACHINERY_TYPE { - AXIAL = 1, /*!< \brief axial turbomachinery. */ - CENTRIFUGAL = 2, /*!< \brief centrifugal turbomachinery. */ - CENTRIPETAL = 3, /*!< \brief centripetal turbomachinery. */ - CENTRIPETAL_AXIAL = 4, /*!< \brief mixed flow turbine. */ - AXIAL_CENTRIFUGAL = 5 /*!< \brief mixed flow turbine. */ +enum class TURBOMACHINERY_TYPE { + AXIAL, /*!< \brief axial turbomachinery. */ + CENTRIFUGAL, /*!< \brief centrifugal turbomachinery. */ + CENTRIPETAL, /*!< \brief centripetal turbomachinery. */ + CENTRIPETAL_AXIAL, /*!< \brief mixed flow turbine. */ + AXIAL_CENTRIFUGAL /*!< \brief mixed flow turbine. */ }; static const MapType TurboMachinery_Map = { MakePair("AXIAL", TURBOMACHINERY_TYPE::AXIAL) diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index 217a05083bc..8be327af7a7 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -4830,23 +4830,23 @@ void CPhysicalGeometry::ComputeNSpan(CConfig* config, unsigned short val_iZone, coord = nodes->GetCoord(iPoint); radius = sqrt(coord[0] * coord[0] + coord[1] * coord[1]); switch (config->GetKind_TurboMachinery(val_iZone)) { - case CENTRIFUGAL: + case TURBOMACHINERY_TYPE::CENTRIFUGAL: valueSpan[nSpan_loc] = coord[2]; break; - case CENTRIPETAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL: valueSpan[nSpan_loc] = coord[2]; break; - case AXIAL: + case TURBOMACHINERY_TYPE::AXIAL: valueSpan[nSpan_loc] = radius; break; - case CENTRIPETAL_AXIAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL_AXIAL: if (marker_flag == OUTFLOW) { valueSpan[nSpan_loc] = radius; } else { valueSpan[nSpan_loc] = coord[2]; } break; - case AXIAL_CENTRIFUGAL: + case TURBOMACHINERY_TYPE::AXIAL_CENTRIFUGAL: if (marker_flag == INFLOW) { valueSpan[nSpan_loc] = radius; } else { @@ -4922,16 +4922,16 @@ void CPhysicalGeometry::ComputeNSpan(CConfig* config, unsigned short val_iZone, coord = nodes->GetCoord(iPoint); radius = sqrt(coord[0] * coord[0] + coord[1] * coord[1]); switch (config->GetKind_TurboMachinery(val_iZone)) { - case CENTRIFUGAL: - case CENTRIPETAL: + case TURBOMACHINERY_TYPE::CENTRIFUGAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL: if (coord[2] < min) min = coord[2]; if (coord[2] > max) max = coord[2]; break; - case AXIAL: + case TURBOMACHINERY_TYPE::AXIAL: if (radius < min) min = radius; if (radius > max) max = radius; break; - case CENTRIPETAL_AXIAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL_AXIAL: if (marker_flag == OUTFLOW) { if (radius < min) min = radius; if (radius > max) max = radius; @@ -4940,7 +4940,7 @@ void CPhysicalGeometry::ComputeNSpan(CConfig* config, unsigned short val_iZone, if (coord[2] > max) max = coord[2]; } break; - case AXIAL_CENTRIFUGAL: + case TURBOMACHINERY_TYPE::AXIAL_CENTRIFUGAL: if (marker_flag == INFLOW) { if (radius < min) min = radius; if (radius > max) max = radius; @@ -5094,8 +5094,8 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone coord = nodes->GetCoord(iPoint); switch (config->GetKind_TurboMachinery(val_iZone)) { - case CENTRIFUGAL: - case CENTRIPETAL: + case TURBOMACHINERY_TYPE::CENTRIFUGAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL: for (iSpan = 0; iSpan < nSpanWiseSections[marker_flag - 1]; iSpan++) { if (dist > (abs(coord[2] - SpanWiseValue[marker_flag - 1][iSpan]))) { dist = abs(coord[2] - SpanWiseValue[marker_flag - 1][iSpan]); @@ -5103,7 +5103,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone } } break; - case AXIAL: + case TURBOMACHINERY_TYPE::AXIAL: radius = sqrt(coord[0] * coord[0] + coord[1] * coord[1]); for (iSpan = 0; iSpan < nSpanWiseSections[marker_flag - 1]; iSpan++) { if (dist > (abs(radius - SpanWiseValue[marker_flag - 1][iSpan]))) { @@ -5112,7 +5112,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone } } break; - case CENTRIPETAL_AXIAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL_AXIAL: if (marker_flag == OUTFLOW) { radius = sqrt(coord[0] * coord[0] + coord[1] * coord[1]); for (iSpan = 0; iSpan < nSpanWiseSections[marker_flag - 1]; iSpan++) { @@ -5131,7 +5131,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone } break; - case AXIAL_CENTRIFUGAL: + case TURBOMACHINERY_TYPE::AXIAL_CENTRIFUGAL: if (marker_flag == INFLOW) { radius = sqrt(coord[0] * coord[0] + coord[1] * coord[1]); for (iSpan = 0; iSpan < nSpanWiseSections[marker_flag - 1]; iSpan++) { @@ -5194,8 +5194,8 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone coord = nodes->GetCoord(iPoint); switch (config->GetKind_TurboMachinery(val_iZone)) { - case CENTRIFUGAL: - case CENTRIPETAL: + case TURBOMACHINERY_TYPE::CENTRIFUGAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL: for (iSpan = 0; iSpan < nSpanWiseSections[marker_flag - 1]; iSpan++) { if (dist > (abs(coord[2] - SpanWiseValue[marker_flag - 1][iSpan]))) { dist = abs(coord[2] - SpanWiseValue[marker_flag - 1][iSpan]); @@ -5203,7 +5203,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone } } break; - case AXIAL: + case TURBOMACHINERY_TYPE::AXIAL: radius = sqrt(coord[0] * coord[0] + coord[1] * coord[1]); for (iSpan = 0; iSpan < nSpanWiseSections[marker_flag - 1]; iSpan++) { if (dist > (abs(radius - SpanWiseValue[marker_flag - 1][iSpan]))) { @@ -5212,7 +5212,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone } } break; - case CENTRIPETAL_AXIAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL_AXIAL: if (marker_flag == OUTFLOW) { radius = sqrt(coord[0] * coord[0] + coord[1] * coord[1]); for (iSpan = 0; iSpan < nSpanWiseSections[marker_flag - 1]; iSpan++) { @@ -5231,7 +5231,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone } break; - case AXIAL_CENTRIFUGAL: + case TURBOMACHINERY_TYPE::AXIAL_CENTRIFUGAL: if (marker_flag == INFLOW) { radius = sqrt(coord[0] * coord[0] + coord[1] * coord[1]); for (iSpan = 0; iSpan < nSpanWiseSections[marker_flag - 1]; iSpan++) { @@ -5285,7 +5285,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone /*--- find nodes at minimum pitch among all nodes---*/ if (coord[1] < min) { min = coord[1]; - if (nDim == 2 && config->GetKind_TurboMachinery(val_iZone) == AXIAL) { + if (nDim == 2 && config->GetKind_TurboMachinery(val_iZone) == TURBOMACHINERY_TYPE::AXIAL) { MinAngularCoord[iMarker][iSpan] = coord[1]; } else { MinAngularCoord[iMarker][iSpan] = atan(coord[1] / coord[0]); @@ -5298,7 +5298,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone if (coord[1] < minInt) { if (nodes->GetDomain(iPoint)) { minInt = coord[1]; - if (nDim == 2 && config->GetKind_TurboMachinery(val_iZone) == AXIAL) { + if (nDim == 2 && config->GetKind_TurboMachinery(val_iZone) == TURBOMACHINERY_TYPE::AXIAL) { minIntAngPitch[iSpan] = coord[1]; } else { minIntAngPitch[iSpan] = atan(coord[1] / coord[0]); @@ -5310,7 +5310,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone if (coord[1] > max) { if (nodes->GetDomain(iPoint)) { max = coord[1]; - if (nDim == 2 && config->GetKind_TurboMachinery(val_iZone) == AXIAL) { + if (nDim == 2 && config->GetKind_TurboMachinery(val_iZone) == TURBOMACHINERY_TYPE::AXIAL) { MaxAngularCoord[iMarker][iSpan] = coord[1]; } else { MaxAngularCoord[iMarker][iSpan] = atan(coord[1] / coord[0]); @@ -5329,7 +5329,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone checkAssign[iSpan][kSpanVertex] = true; coord = nodes->GetCoord(ordered[iSpan][iSpanVertex]); target = coord[1]; - if (nDim == 2 && config->GetKind_TurboMachinery(val_iZone) == AXIAL) { + if (nDim == 2 && config->GetKind_TurboMachinery(val_iZone) == TURBOMACHINERY_TYPE::AXIAL) { angPitch[iSpan][iSpanVertex] = coord[1]; } else { angPitch[iSpan][iSpanVertex] = atan(coord[1] / coord[0]); @@ -5350,7 +5350,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone turbovertex[iMarker][iSpan][iInternalVertex]->SetAngularCoord(angPitch[iSpan][iSpanVertex]); turbovertex[iMarker][iSpan][iInternalVertex]->SetDeltaAngularCoord(deltaAngPitch[iSpan][iSpanVertex]); switch (config->GetKind_TurboMachinery(val_iZone)) { - case CENTRIFUGAL: + case TURBOMACHINERY_TYPE::CENTRIFUGAL: Normal2 = 0.0; for (iDim = 0; iDim < 2; iDim++) Normal2 += coord[iDim] * coord[iDim]; if (marker_flag == INFLOW) { @@ -5363,7 +5363,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone TurboNormal[2] = 0.0; } break; - case CENTRIPETAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL: Normal2 = 0.0; for (iDim = 0; iDim < 2; iDim++) Normal2 += coord[iDim] * coord[iDim]; if (marker_flag == OUTFLOW) { @@ -5376,7 +5376,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone TurboNormal[2] = 0.0; } break; - case AXIAL: + case TURBOMACHINERY_TYPE::AXIAL: Normal2 = 0.0; for (iDim = 0; iDim < 2; iDim++) Normal2 += coord[iDim] * coord[iDim]; if (nDim == 3) { @@ -5402,7 +5402,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone } break; - case CENTRIPETAL_AXIAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL_AXIAL: Normal2 = 0.0; for (iDim = 0; iDim < 2; iDim++) Normal2 += coord[iDim] * coord[iDim]; if (marker_flag == INFLOW) { @@ -5416,7 +5416,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone } break; - case AXIAL_CENTRIFUGAL: + case TURBOMACHINERY_TYPE::AXIAL_CENTRIFUGAL: Normal2 = 0.0; for (iDim = 0; iDim < 2; iDim++) Normal2 += coord[iDim] * coord[iDim]; if (marker_flag == INFLOW) { @@ -5720,7 +5720,7 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone myfile << z_loc[iSpan][iSpanVertex]; myfile.width(20); myfile << radius; - if (nDim == 2 && config->GetKind_TurboMachinery(val_iZone)) { + if (nDim == 2) { myfile.width(20); myfile << angCoord_loc[iSpan][iSpanVertex]; myfile.width(20); @@ -5788,7 +5788,7 @@ void CPhysicalGeometry::UpdateTurboVertex(CConfig* config, unsigned short val_iZ coord = nodes->GetCoord(iPoint); /*--- compute appropriate turbo normal ---*/ switch (config->GetKind_TurboMachinery(val_iZone)) { - case CENTRIFUGAL: + case TURBOMACHINERY_TYPE::CENTRIFUGAL: Normal2 = 0.0; for (iDim = 0; iDim < 2; iDim++) Normal2 += coord[iDim] * coord[iDim]; if (marker_flag == INFLOW) { @@ -5801,7 +5801,7 @@ void CPhysicalGeometry::UpdateTurboVertex(CConfig* config, unsigned short val_iZ TurboNormal[2] = 0.0; } break; - case CENTRIPETAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL: Normal2 = 0.0; for (iDim = 0; iDim < 2; iDim++) Normal2 += coord[iDim] * coord[iDim]; if (marker_flag == OUTFLOW) { @@ -5814,7 +5814,7 @@ void CPhysicalGeometry::UpdateTurboVertex(CConfig* config, unsigned short val_iZ TurboNormal[2] = 0.0; } break; - case AXIAL: + case TURBOMACHINERY_TYPE::AXIAL: Normal2 = 0.0; for (iDim = 0; iDim < 2; iDim++) Normal2 += coord[iDim] * coord[iDim]; if (nDim == 3) { @@ -5840,7 +5840,7 @@ void CPhysicalGeometry::UpdateTurboVertex(CConfig* config, unsigned short val_iZ } break; - case CENTRIPETAL_AXIAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL_AXIAL: Normal2 = 0.0; for (iDim = 0; iDim < 2; iDim++) Normal2 += coord[iDim] * coord[iDim]; if (marker_flag == INFLOW) { @@ -5854,7 +5854,7 @@ void CPhysicalGeometry::UpdateTurboVertex(CConfig* config, unsigned short val_iZ } break; - case AXIAL_CENTRIFUGAL: + case TURBOMACHINERY_TYPE::AXIAL_CENTRIFUGAL: Normal2 = 0.0; for (iDim = 0; iDim < 2; iDim++) Normal2 += coord[iDim] * coord[iDim]; if (marker_flag == INFLOW) { @@ -6030,8 +6030,8 @@ void CPhysicalGeometry::SetAvgTurboValue(CConfig* config, unsigned short val_iZo AverageGridVel[iMarker][iSpan][iDim] = TotalGridVel[iDim] / nTotVertexSpan[iMarker][iSpan]; } switch (config->GetKind_TurboMachinery(val_iZone)) { - case CENTRIFUGAL: - case CENTRIPETAL: + case TURBOMACHINERY_TYPE::CENTRIFUGAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL: if (marker_flag == INFLOW) { AverageTangGridVel[iMarker][iSpan] = -(AverageTurboNormal[iMarker][iSpan][0] * AverageGridVel[iMarker][iSpan][1] - @@ -6042,7 +6042,7 @@ void CPhysicalGeometry::SetAvgTurboValue(CConfig* config, unsigned short val_iZo AverageTurboNormal[iMarker][iSpan][1] * AverageGridVel[iMarker][iSpan][0]; } break; - case AXIAL: + case TURBOMACHINERY_TYPE::AXIAL: if (marker_flag == INFLOW && nDim == 2) { AverageTangGridVel[iMarker][iSpan] = -AverageTurboNormal[iMarker][iSpan][0] * AverageGridVel[iMarker][iSpan][1] + @@ -6053,7 +6053,7 @@ void CPhysicalGeometry::SetAvgTurboValue(CConfig* config, unsigned short val_iZo AverageTurboNormal[iMarker][iSpan][1] * AverageGridVel[iMarker][iSpan][0]; } break; - case CENTRIPETAL_AXIAL: + case TURBOMACHINERY_TYPE::CENTRIPETAL_AXIAL: if (marker_flag == OUTFLOW) { AverageTangGridVel[iMarker][iSpan] = (AverageTurboNormal[iMarker][iSpan][0] * AverageGridVel[iMarker][iSpan][1] - @@ -6064,7 +6064,7 @@ void CPhysicalGeometry::SetAvgTurboValue(CConfig* config, unsigned short val_iZo AverageTurboNormal[iMarker][iSpan][1] * AverageGridVel[iMarker][iSpan][0]); } break; - case AXIAL_CENTRIFUGAL: + case TURBOMACHINERY_TYPE::AXIAL_CENTRIFUGAL: if (marker_flag == INFLOW) { AverageTangGridVel[iMarker][iSpan] = AverageTurboNormal[iMarker][iSpan][0] * AverageGridVel[iMarker][iSpan][1] - @@ -6289,7 +6289,7 @@ void CPhysicalGeometry::GatherInOutAverageValues(CConfig* config, bool allocate) if (iSpan == nSpanWiseSections) { config->SetFreeStreamTurboNormal(turboNormal); - if (config->GetKind_TurboMachinery(config->GetiZone()) == AXIAL && nDim == 2) { + if (config->GetKind_TurboMachinery(config->GetiZone()) == TURBOMACHINERY_TYPE::AXIAL && nDim == 2) { nBlades = 1 / Pitch; } else { nBlades = 2 * PI_NUMBER / Pitch; diff --git a/SU2_CFD/include/iteration/CIteration.hpp b/SU2_CFD/include/iteration/CIteration.hpp index ac2581f12c9..483712a8a16 100644 --- a/SU2_CFD/include/iteration/CIteration.hpp +++ b/SU2_CFD/include/iteration/CIteration.hpp @@ -251,7 +251,6 @@ class CIteration { unsigned short val_iInst) { return false; } - /*! * \brief A virtual member. * \param[in] output - Pointer to the COutput class. diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp index 9dc1a88b265..2d0e08c0489 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -136,7 +136,7 @@ class CTurbomachineryState { su2double GetRelMachValue() const { return Norm(RelMach); } - su2double Norm(vector const& u) const { + su2double Norm(const vector& u) const { su2double accum = 0.; for (auto i = 0u; i < u.size(); ++i) { accum += u[i] * u[i]; @@ -227,7 +227,7 @@ class CTurbomachineryStagePerformance { su2double GetEulerianWork() const { return EulerianWork; } - const su2double& GetNormEntropyGen() const { return NormEntropyGen; } + su2double GetNormEntropyGen() const { return NormEntropyGen; } su2double GetTotalStaticPressureRatio() const { return TotalStaticPressureRatio; } @@ -250,9 +250,7 @@ class CTurboOutput { public: CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel); - vector>> - - const GetBladesPerformances() const { return BladesPerformances; } + const vector>>& GetBladesPerformances() const { return BladesPerformances; } void ComputeTurbomachineryPerformance(vector> const primitives); }; \ No newline at end of file diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 36dbdbb4660..0cf6d838a65 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -181,7 +181,6 @@ void CMultizoneDriver::StartSolver() { Preprocess(TimeIter); /*--- Run a block iteration of the multizone problem. ---*/ - Run(); /*--- Update the solution for dual time stepping strategy ---*/ @@ -288,10 +287,10 @@ void CMultizoneDriver::RunGaussSeidel() { } /*--- Loop over the number of outer iterations ---*/ - for (auto iOuter_Iter = 0ul; iOuter_Iter < driver_config->GetnOuter_Iter(); iOuter_Iter++){ + for (auto iOuter_Iter = 0ul; iOuter_Iter < driver_config->GetnOuter_Iter(); iOuter_Iter++) { /*--- Loop over the number of zones (IZONE) ---*/ - for (iZone = 0; iZone < nZone; iZone++){ + for (iZone = 0; iZone < nZone; iZone++) { /*--- In principle, the mesh does not need to be updated ---*/ UpdateMesh = 0; diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index c35dcf6d742..1d29f185ad8 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -28,7 +28,6 @@ #include "../../include/iteration/CFluidIteration.hpp" #include "../../include/output/COutput.hpp" - void CFluidIteration::Preprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, @@ -231,7 +230,6 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe config[val_iZone], config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), config[val_iZone]->GetInnerIter()); - /*--- If convergence was reached --*/ StopCalc = output->GetConvergence(); /* --- Checking convergence of Fixed CL mode to target CL, and perform finite differencing if needed --*/ diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index efd8c530175..c44ee947ead 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -95,7 +95,6 @@ CFlowCompOutput::CFlowCompOutput(const CConfig *config, unsigned short nDim) : C cauchySerie.resize(convFields.size(), vector(nCauchy_Elems, 0.0)); } } - } void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ @@ -480,7 +479,6 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol SetCustomOutputs(solver, geometry, config); SetCustomAndComboObjectives(FLOW_SOL, config, solver); - } bool CFlowCompOutput::SetInitResiduals(const CConfig *config){ @@ -635,15 +633,11 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr 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)); + 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); @@ -682,13 +676,11 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr 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)); + 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); @@ -728,13 +720,11 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr 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)); + 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); @@ -793,14 +783,12 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr 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)); - } - + 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"); + } file.open (spanwise_performance_filename.data(), ios::out | ios::trunc); file.setf(ios::scientific); file.precision(12); diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 9e3c6b38df1..946cc6b52b3 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1044,7 +1044,7 @@ def main(): ### Turbomachinery ### ###################################### - # Jones APU Turbocharger restart + # Jones APU Turbocharger restart Jones_tc_restart = TestCase('jones_turbocharger_restart') Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg" diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index a75b17d48aa..8b00b3c8f5b 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -852,7 +852,7 @@ def main(): ### Turbomachinery ### ###################################### - # Jones APU Turbocharger restart + # Jones APU Turbocharger restart Jones_tc_restart = TestCase('jones_turbocharger_restart') Jones_tc_restart.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_restart.cfg_file = "Jones_restart.cfg"