From 98989f771545a00c6533602d3944d167e0bd646d Mon Sep 17 00:00:00 2001 From: Joshua Kelly Date: Tue, 18 Feb 2025 16:15:10 +0000 Subject: [PATCH 01/79] Fixes from tagging tool --- SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp | 16 ++++++++++++---- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 6 +++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index d25e4a18ecbe..eedf32187ecd 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -471,16 +471,24 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** solvers0[FLOW_SOL]->InitiateComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); solvers0[FLOW_SOL]->CompleteComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); - if (config[iZone]->GetBoolTurbomachinery()) { - solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], INFLOW); - solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], OUTFLOW); - } if (turbulent && !config[iZone]->GetFrozen_Visc_Disc()) { solvers0[TURB_SOL]->Postprocessing(geometry0, solvers0, config[iZone], MESH_0); solvers0[TURB_SOL]->InitiateComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); solvers0[TURB_SOL]->CompleteComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); } + if (config[iZone]->GetBoolTurbomachinery()) { + if (config[iZone]->GetBoolGiles() && config[iZone]->GetSpatialFourier()){ + auto conv_bound_numerics = numerics[iZone][iInst][MESH_0][FLOW_SOL][CONV_BOUND_TERM + omp_get_thread_num()*MAX_TERMS]; + solvers0[FLOW_SOL]->PreprocessBC_Giles(geometry0, config[iZone], conv_bound_numerics, INFLOW); + solvers0[FLOW_SOL]->PreprocessBC_Giles(geometry0, config[iZone], conv_bound_numerics, OUTFLOW); + } + solvers0[FLOW_SOL]->PreprocessAverage(solvers0, geometry0, config[iZone], INFLOW); + solvers0[FLOW_SOL]->PreprocessAverage(solvers0, geometry0, config[iZone], OUTFLOW); + solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], INFLOW); + solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], OUTFLOW); + solvers0[FLOW_SOL]->GatherInOutAverageValues(config[iZone], geometry0); + } if (config[iZone]->GetKind_Species_Model() != SPECIES_MODEL::NONE) { solvers0[SPECIES_SOL]->Preprocessing(geometry0, solvers0, config[iZone], MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS, true); solvers0[SPECIES_SOL]->InitiateComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index eada9828e352..9c60407d9a4c 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -219,14 +219,14 @@ void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, boo if ((config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE) && (KindDirect_Solver == RUNTIME_FLOW_SYS) && config->GetBoolTurbomachinery()){ - BPressure = config->GetPressureOut_BC(); - Temperature = config->GetTotalTemperatureIn_BC(); - if (!reset){ AD::RegisterInput(BPressure); AD::RegisterInput(Temperature); } + BPressure = config->GetPressureOut_BC(); + Temperature = config->GetTotalTemperatureIn_BC(); + config->SetPressureOut_BC(BPressure); config->SetTotalTemperatureIn_BC(Temperature); } From 6082eac4ac6b530fa8637409e978392b4fcc4495 Mon Sep 17 00:00:00 2001 From: Joshua Kelly Date: Tue, 18 Feb 2025 16:47:34 +0000 Subject: [PATCH 02/79] Config catch + fix preacc in ComputeVorticityandStrainMag --- Common/src/CConfig.cpp | 11 ++++++++++- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index c61fc1acb2a3..3483b5cedb5f 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -3413,8 +3413,17 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i /*--- Using default frequency of 250 for all files when steady, and 1 for unsteady. ---*/ for (auto iVolumeFreq = 0; iVolumeFreq < nVolumeOutputFrequencies; iVolumeFreq++){ - VolumeOutputFrequencies[iVolumeFreq] = Time_Domain ? 1 : 250; + if (Multizone_Problem && DiscreteAdjoint) { + VolumeOutputFrequencies[iVolumeFreq] = nOuterIter; + } + else { + VolumeOutputFrequencies[iVolumeFreq] = Time_Domain ? 1 : 250; + } } + } else if (Multizone_Problem && DiscreteAdjoint) { + SU2_MPI::Error(string("OUTPUT_WRT_FREQ cannot be specified for this solver " + "(writing of restart and sensitivity files not possible for multizone discrete adjoint during runtime yet).\n" + "Please remove this option from the config file, output files will be written when solver finalizes.\n"), CURRENT_FUNCTION); } else if (nVolumeOutputFrequencies < nVolumeOutputFiles) { /*--- If there are fewer frequencies than files, repeat the last frequency. * This is useful to define 1 frequency for the restart file and 1 frequency for all the visualization files. ---*/ diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index d7a634e82271..2b8560c4712a 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -672,11 +672,12 @@ void CFVMFlowSolverBase::ComputeVorticityAndStrainMag(const CConfig& confi StrainMag(iPoint) = sqrt(2.0*StrainMag(iPoint)); AD::SetPreaccOut(StrainMag(iPoint)); + AD::EndPreacc(); + /*--- Max is not differentiable, so we not register them for preacc. ---*/ strainMax = max(strainMax, StrainMag(iPoint)); omegaMax = max(omegaMax, GeometryToolbox::Norm(3, Vorticity)); - AD::EndPreacc(); } END_SU2_OMP_FOR From b3267b6b13603fa7896415dc4e13809059883ca2 Mon Sep 17 00:00:00 2001 From: Joshua Kelly Date: Thu, 20 Feb 2025 16:45:20 +0000 Subject: [PATCH 03/79] Initial add turbo obj functions --- Common/include/CConfig.hpp | 44 +++++++++++++++++++ Common/include/option_structure.hpp | 6 +++ Common/src/CConfig.cpp | 17 +++++++ .../include/solvers/CFVMFlowSolverBase.inl | 9 ++++ SU2_CFD/src/iteration/CFluidIteration.cpp | 15 +++++++ SU2_CFD/src/output/CTurboOutput.cpp | 5 +++ 6 files changed, 96 insertions(+) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index d55416ed681b..5959c76e8196 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -445,6 +445,11 @@ class CConfig { TURBOMACHINERY_TYPE *Kind_TurboMachinery; su2vector Kind_TurboInterface; + /* Turbomachinery objective functions */ + su2double *EntropyGeneration; + su2double *TotalPressureLoss; + su2double *KineticEnergyLoss; + /* 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. */ @@ -7990,6 +7995,27 @@ class CConfig { * \param[in] val_surface_species_variance - Value of the species variance. */ void SetSurface_Species_Variance(unsigned short val_marker, su2double val_surface_species_variance) { Surface_Species_Variance[val_marker] = val_surface_species_variance; } + + /*! + * \brief Set entropy generation for a turbomachinery zone + * \param[in] val_iZone - zone index + * \param[in] val_entropy_generation - value of entropy generation + */ + void SetEntropyGeneration(unsigned short val_iZone, su2double val_entropy_generation) { EntropyGeneration[val_iZone] = val_entropy_generation; } + + /*! + * \brief Get total pressure loss for a turbomachinery zone + * \param[in] val_iZone - zone index + * \param[in] val_total_pressure_loss - value of total pressure loss + */ + void SetTotalPressureLoss(unsigned short val_iZone, su2double val_total_pressure_loss) { TotalPressureLoss[val_iZone] = val_total_pressure_loss; } + + /*! + * \brief Get kinetic energy loss for a turbomachinery zone + * \param[in] val_iZone - zone index + * \param[in] val_kinetic_energy_loss - value of kinetic energy loss + */ + void SetKineticEnergyLoss(unsigned short val_iZone, su2double val_kinetic_energy_loss) { KineticEnergyLoss[val_iZone] = val_kinetic_energy_loss; } /*! * \brief Get the back pressure (static) at an outlet boundary. @@ -8271,6 +8297,24 @@ class CConfig { */ su2double GetSurface_Species_Variance(unsigned short val_marker) const { return Surface_Species_Variance[val_marker]; } + /*! + * \brief Get entropy generation for a turbomachine at a boundary + * \param[in] val_iZone - zone index + */ + su2double GetEntropyGeneration(unsigned short val_iZone) const { return EntropyGeneration[val_iZone]; } + + /*! + * \brief Get total pressure loss for a turbomachinery zone + * \param[in] val_iZone - zone index + */ + su2double GetTotalPressureLoss(unsigned short val_iZone) const { return TotalPressureLoss[val_iZone]; } + + /*! + * \brief Get kinetic energy loss for a turbomachinery zone + * \param[in] val_iZone - zone index + */ + su2double GetKineticEnergyLoss(unsigned short val_iZone) const { return KineticEnergyLoss[val_iZone]; } + /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index ddf570ab6978..1ae80331fdec 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -2010,6 +2010,9 @@ enum ENUM_OBJECTIVE { TOPOL_DISCRETENESS = 63, /*!< \brief Measure of the discreteness of the current topology. */ TOPOL_COMPLIANCE = 64, /*!< \brief Measure of the discreteness of the current topology. */ STRESS_PENALTY = 65, /*!< \brief Penalty function of VM stresses above a maximum value. */ + ENTROPY_GENERATION = 80, /*!< \brief Entropy generation turbomachinery objective function. */ + TOTAL_PRESSURE_LOSS = 81, /*!< \brief Total pressure loss turbomachinery objective function. */ + KINETIC_ENERGY_LOSS = 82 /*!< \breif Kinetic energy loss coefficient turbomachinery objective function. */ }; static const MapType Objective_Map = { MakePair("DRAG", DRAG_COEFFICIENT) @@ -2052,6 +2055,9 @@ static const MapType Objective_Map = { MakePair("TOPOL_DISCRETENESS", TOPOL_DISCRETENESS) MakePair("TOPOL_COMPLIANCE", TOPOL_COMPLIANCE) MakePair("STRESS_PENALTY", STRESS_PENALTY) + MakePair("ENTROPY_GENERATION", ENTROPY_GENERATION) + MakePair("TOTAL_PRESSURE_LOSS", TOTAL_PRESSURE_LOSS) + MakePair("KINETIC_ENERGY_LOSS", KINETIC_ENERGY_LOSS) }; /*! diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 3483b5cedb5f..9f8d9f969611 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1048,6 +1048,11 @@ void CConfig::SetPointersNull() { nBlades = nullptr; FreeStreamTurboNormal = nullptr; + /*--- Turbomachinery Objective Functions ---*/ + EntropyGeneration = nullptr; + TotalPressureLoss = nullptr; + KineticEnergyLoss = nullptr; + top_optim_kernels = nullptr; top_optim_kernel_params = nullptr; top_optim_filter_radius = nullptr; @@ -6065,6 +6070,11 @@ void CConfig::SetMarkers(SU2_COMPONENT val_software) { Marker_CfgFile_ZoneInterface[iMarker_CfgFile] = YES; } + /*--- Allocate memory for turbomachinery objective functions ---*/ + EntropyGeneration = new su2double[nZone] (); + TotalPressureLoss = new su2double[nZone] (); + KineticEnergyLoss = new su2double[nZone] (); + /*--- Identification of Turbomachinery markers and flag them---*/ for (iMarker_CfgFile = 0; iMarker_CfgFile < nMarker_CfgFile; iMarker_CfgFile++) { @@ -8373,6 +8383,10 @@ CConfig::~CConfig() { delete [] nBlades; delete [] FreeStreamTurboNormal; + + delete [] EntropyGeneration; + delete [] TotalPressureLoss; + delete [] KineticEnergyLoss; } string CConfig::GetFilename(string filename, const string& ext, int timeIter) const { @@ -8550,6 +8564,9 @@ string CConfig::GetObjFunc_Extension(string val_filename) const { case TOPOL_DISCRETENESS: AdjExt = "_topdisc"; break; case TOPOL_COMPLIANCE: AdjExt = "_topcomp"; break; case STRESS_PENALTY: AdjExt = "_stress"; break; + case ENTROPY_GENERATION: AdjExt = "_entg"; break; + case TOTAL_PRESSURE_LOSS: AdjExt = "_tot_press_loss"; break; + case KINETIC_ENERGY_LOSS: AdjExt = "_kin_en_loss"; break; } } else{ diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 2b8560c4712a..ba44c5df9c51 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -2935,6 +2935,15 @@ su2double CFVMFlowSolverBase::EvaluateCommonObjFunc(const CConfig& config) case SURFACE_SPECIES_VARIANCE: objFun += weight * config.GetSurface_Species_Variance(0); break; + case ENTROPY_GENERATION: + objFun += weight * config.GetEntropyGeneration(config.GetnMarker_Turbomachinery()); + break; + case TOTAL_PRESSURE_LOSS: + objFun += weight * config.GetTotalPressureLoss(config.GetnMarker_Turbomachinery()); + break; + case KINETIC_ENERGY_LOSS: + objFun += weight * config.GetKineticEnergyLoss(config.GetnMarker_Turbomachinery()); + break; case CUSTOM_OBJFUNC: objFun += weight * Total_Custom_ObjFunc; break; diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 4ca6c45a1724..0c1ffb71cea9 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -352,6 +352,21 @@ void CFluidIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** auto OutState = TurbomachineryPerformance->GetBladesPerformances().at(nZone-1).at(nSpan)->GetOutletState(); TurbomachineryStagePerformance->ComputePerformanceStage(InState, OutState, config_container[nZone-1]); + + /*--- Set turbomachinery objective function value in each zone ---*/ + for (auto iBlade = 0u; iBlade < nBladesRow; iBlade++) { + // Should we set in ZONE_0 or nZone-1? + auto iBladePerf = TurbomachineryPerformance->GetBladesPerformances().at(iBlade).at(nSpan); + InState = iBladePerf->GetInletState(); + OutState = iBladePerf->GetOutletState(); + config_container[nZone-1]->SetEntropyGeneration(iBlade, (OutState.GetEntropy() - InState.GetEntropy())/InState.GetEntropy() * 100); + config_container[nZone-1]->SetTotalPressureLoss(iBlade, iBladePerf->GetTotalPressureLoss()); + config_container[nZone-1]->SetKineticEnergyLoss(iBlade, iBladePerf->GetKineticEnergyLoss()); + } + /*--- Set global turbomachinery objective function ---*/ + config_container[nZone-1]->SetEntropyGeneration(nBladesRow, TurbomachineryStagePerformance->GetNormEntropyGen()*100); + config_container[nZone-1]->SetTotalPressureLoss(nBladesRow, TurbomachineryStagePerformance->GetTotalPressureLoss()); + config_container[nZone-1]->SetKineticEnergyLoss(nBladesRow, TurbomachineryStagePerformance->GetKineticEnergyLoss()); } } diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index 0633b3673dd0..929ed502ba81 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -265,6 +265,8 @@ void CTurbomachineryStagePerformance::ComputeCompressorStagePerformance(const CT 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 tangVel = OutState.GetTangVelocity(); + su2double relVelOutIs2 = 2 * (OutState.GetRothalpy() - enthalpyOutIs) + tangVel * tangVel; /*--- Compute compressor stage performance ---*/ NormEntropyGen = (OutState.GetEntropy() - InState.GetEntropy()) / InState.GetEntropy(); @@ -273,4 +275,7 @@ void CTurbomachineryStagePerformance::ComputeCompressorStagePerformance(const CT TotalTotalEfficiency = (totEnthalpyOutIs - InState.GetTotalEnthalpy()) / EulerianWork; TotalStaticPressureRatio = OutState.GetPressure() / InState.GetTotalPressure(); TotalTotalPressureRatio = OutState.GetTotalPressure() / InState.GetTotalPressure(); + TotalPressureLoss = (InState.GetTotalRelPressure() - OutState.GetTotalRelPressure()) / + (InState.GetTotalRelPressure() - InState.GetPressure()); + KineticEnergyLoss = 2 * (OutState.GetEnthalpy() - enthalpyOutIs) / relVelOutIs2; } \ No newline at end of file From c459ce9d00b6091fddee1bdc59e16cc230295d7f Mon Sep 17 00:00:00 2001 From: Joshua Kelly Date: Tue, 11 Mar 2025 16:24:56 +0000 Subject: [PATCH 04/79] Initial refactoring of turboperformance into solver for correct recording of objective function calculation --- SU2_CFD/include/solvers/CEulerSolver.hpp | 65 +++++++++++++++++++ .../include/solvers/CFVMFlowSolverBase.inl | 9 --- SU2_CFD/include/solvers/CSolver.hpp | 4 ++ .../src/drivers/CDiscAdjMultizoneDriver.cpp | 5 ++ SU2_CFD/src/iteration/CFluidIteration.cpp | 14 ++-- SU2_CFD/src/solvers/CEulerSolver.cpp | 16 +++++ 6 files changed, 97 insertions(+), 16 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 83c4cbe18e6a..8dea53b7ea2d 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -155,6 +155,71 @@ class CEulerSolver : public CFVMFlowSolverBase > > CkInflow, CkOutflow1, CkOutflow2; + /*--- Structure for handling turbomachinery objective functions ---*/ + // Evaluating these in the solver as they need to be declared in the solution + + struct TurboObjectiveFunction { + su2double* EntropyGeneration = nullptr; + su2double* TotalPressureLoss = nullptr; + su2double* KineticEnergyLoss = nullptr; + int _nTurboPerfMarkers = 0; + + void allocate(int nTurboPerfMarkers) { + _nTurboPerfMarkers = nTurboPerfMarkers; + EntropyGeneration = new su2double[nTurboPerfMarkers]; + TotalPressureLoss = new su2double[nTurboPerfMarkers]; + KineticEnergyLoss = new su2double[nTurboPerfMarkers]; + setZero(); + } + + void setZero() { + for (int i = 0u; i < _nTurboPerfMarkers; i++) { + if (_nTurboPerfMarkers) { + EntropyGeneration[i] = 0; + TotalPressureLoss[i] = 0; + KineticEnergyLoss[i] = 0; + } + } + } + + void Set(short unsigned int ObjFunc, int bladeRow, su2double val) const { + switch (ObjFunc) { + case ENTROPY_GENERATION: + EntropyGeneration[bladeRow] = val; + break; + case TOTAL_PRESSURE_LOSS: + TotalPressureLoss[bladeRow] = val; + break; + case KINETIC_ENERGY_LOSS: + KineticEnergyLoss[bladeRow] = val; + break; + default: + break; + } + } + + su2double Get(short unsigned int ObjFunc, int bladeRow) const { + switch (ObjFunc) { + case ENTROPY_GENERATION: + return EntropyGeneration[bladeRow]; + case TOTAL_PRESSURE_LOSS: + return TotalPressureLoss[bladeRow]; + case KINETIC_ENERGY_LOSS: + return KineticEnergyLoss[bladeRow]; + default: + return 0.0; + } + } + }; + + TurboObjectiveFunction TurboObjFunc; + + // I will move these they are here for convenience right now! + + inline su2double GetTurboObjectiveFunction(short unsigned int ObjFunc, int bladeRow) const final { return TurboObjFunc.Get(ObjFunc, bladeRow); } + + inline void SetTurboObjectiveFunction(short unsigned int ObjFunc, int bladeRow, su2double val) final { TurboObjFunc.Set(ObjFunc, bladeRow, val); } + /*--- End of Turbomachinery Solver Variables ---*/ /*! diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index ba44c5df9c51..2b8560c4712a 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -2935,15 +2935,6 @@ su2double CFVMFlowSolverBase::EvaluateCommonObjFunc(const CConfig& config) case SURFACE_SPECIES_VARIANCE: objFun += weight * config.GetSurface_Species_Variance(0); break; - case ENTROPY_GENERATION: - objFun += weight * config.GetEntropyGeneration(config.GetnMarker_Turbomachinery()); - break; - case TOTAL_PRESSURE_LOSS: - objFun += weight * config.GetTotalPressureLoss(config.GetnMarker_Turbomachinery()); - break; - case KINETIC_ENERGY_LOSS: - objFun += weight * config.GetKineticEnergyLoss(config.GetnMarker_Turbomachinery()); - break; case CUSTOM_OBJFUNC: objFun += weight * Total_Custom_ObjFunc; break; diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 2ed78a78a9be..220c4f81ac06 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -1089,6 +1089,10 @@ class CSolver { CConfig *config, unsigned short val_marker) { } + inline virtual void SetTurboObjectiveFunction(short unsigned int ObjFunc, int bladeRow, su2double val) { } + + inline virtual su2double GetTurboObjectiveFunction(short unsigned int ObjFunc, int bladeRow) const { return 0.0; } + /*! * \brief A virtual member. * \param[in] geometry - Geometrical definition of the problem. diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 6e5519a63f2e..b7144b5e0ae0 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -718,6 +718,11 @@ void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) { } direct_output[iZone]->SetHistoryOutput(geometry, solvers, config); + // Need to evaluate turbomachinery objective functions here as they are only calculated in the final zone + if (config->GetBoolTurbomachinery() && iZone == nZone-1){ + const auto weight = config->GetWeight_ObjFunc(0); + ObjFunc += weight * solvers[FLOW_SOL]->GetTurboObjectiveFunction(config->GetKind_ObjFunc(), config_container[ZONE_0]->GetnMarker_Turbomachinery()); + } ObjFunc += solvers[FLOW_SOL]->GetTotal_ComboObj(); break; diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 0c1ffb71cea9..65146fd6c25d 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -359,14 +359,14 @@ void CFluidIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** auto iBladePerf = TurbomachineryPerformance->GetBladesPerformances().at(iBlade).at(nSpan); InState = iBladePerf->GetInletState(); OutState = iBladePerf->GetOutletState(); - config_container[nZone-1]->SetEntropyGeneration(iBlade, (OutState.GetEntropy() - InState.GetEntropy())/InState.GetEntropy() * 100); - config_container[nZone-1]->SetTotalPressureLoss(iBlade, iBladePerf->GetTotalPressureLoss()); - config_container[nZone-1]->SetKineticEnergyLoss(iBlade, iBladePerf->GetKineticEnergyLoss()); + solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, iBlade, TurbomachineryStagePerformance->GetNormEntropyGen()*100); + solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, iBlade, iBladePerf->GetTotalPressureLoss()); + solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, iBlade, iBladePerf->GetKineticEnergyLoss()); } - /*--- Set global turbomachinery objective function ---*/ - config_container[nZone-1]->SetEntropyGeneration(nBladesRow, TurbomachineryStagePerformance->GetNormEntropyGen()*100); - config_container[nZone-1]->SetTotalPressureLoss(nBladesRow, TurbomachineryStagePerformance->GetTotalPressureLoss()); - config_container[nZone-1]->SetKineticEnergyLoss(nBladesRow, TurbomachineryStagePerformance->GetKineticEnergyLoss()); + /*--- Set global turbomachinery objective function (evaluated in final zone as dependent on values from all previous zones ) ---*/ + solver[nZone-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, nBladesRow, TurbomachineryStagePerformance->GetNormEntropyGen()*100); + solver[nZone-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, nBladesRow, TurbomachineryStagePerformance->GetTotalPressureLoss()); + solver[nZone-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, nBladesRow, TurbomachineryStagePerformance->GetKineticEnergyLoss()); } } diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 01626563d405..8f2d8e32fcd9 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -457,6 +457,13 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ CkOutflow2[iMarker] = CkOutflow1[iMarker]; } } + + /*--- Initialize objective function containers ---*/ + TurboObjFunc.allocate(config->GetnMarker_Turbomachinery()); + + /*--- Initialize turboperformance classes ---*/ + TurbomachineryPerformance = std::make_shared(config, *geometry, *fluid); + TurbomachineryStagePerformance = std::make_shared(*fluid); } void CEulerSolver::Set_MPI_ActDisk(CSolver **solver_container, CGeometry *geometry, CConfig *config) { @@ -4751,6 +4758,15 @@ void CEulerSolver::Evaluate_ObjFunc(const CConfig *config, CSolver**) { case SURFACE_MACH: Total_ComboObj+=Weight_ObjFunc*config->GetSurface_Mach(0); break; + // case ENTROPY_GENERATION: + // Total_ComboObj+=Weight_ObjFunc*GetTurboObjectiveFunction(Kind_ObjFunc, config->GetnMarker_Turbomachinery()); + // break; + // case TOTAL_PRESSURE_LOSS: + // Total_ComboObj+=Weight_ObjFunc*GetTurboObjectiveFunction(Kind_ObjFunc, config->GetnMarker_Turbomachinery()); + // break; + // case KINETIC_ENERGY_LOSS: + // Total_ComboObj+=Weight_ObjFunc*GetTurboObjectiveFunction(Kind_ObjFunc, config->GetnMarker_Turbomachinery()); + // break; default: break; } From 16147841f616c247dc6229fb6699f2548d800adf Mon Sep 17 00:00:00 2001 From: Joshua Kelly Date: Thu, 1 May 2025 13:19:15 +0100 Subject: [PATCH 05/79] Adding geometry to AD recording for turbo calcs. (NOT WORKING CURRENTLY) --- Common/include/geometry/CGeometry.hpp | 7 +- Common/src/geometry/CGeometry.cpp | 56 +++++++++++ .../iteration/CDiscAdjFluidIteration.hpp | 2 +- SU2_CFD/include/iteration/CFluidIteration.hpp | 5 - SU2_CFD/include/iteration/CIteration.hpp | 13 +++ SU2_CFD/include/iteration/CTurboIteration.hpp | 7 +- SU2_CFD/include/solvers/CEulerSolver.hpp | 96 +++++++------------ .../src/drivers/CDiscAdjMultizoneDriver.cpp | 8 +- SU2_CFD/src/drivers/CDriver.cpp | 2 +- .../src/iteration/CDiscAdjFluidIteration.cpp | 19 +++- SU2_CFD/src/iteration/CFluidIteration.cpp | 50 +--------- SU2_CFD/src/iteration/CTurboIteration.cpp | 49 ++++++++++ SU2_CFD/src/solvers/CEulerSolver.cpp | 11 +-- 13 files changed, 193 insertions(+), 132 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 9519877e2533..594ff983ed69 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -62,6 +62,7 @@ extern "C" { #include "../CConfig.hpp" #include "../toolboxes/graph_toolbox.hpp" #include "../adt/CADTElemClass.hpp" +#include "../../../SU2_CFD/include/interfaces/CInterface.hpp" using namespace std; @@ -776,7 +777,7 @@ class CGeometry { inline virtual void GatherInOutAverageValues(CConfig* config, bool allocate) {} /*! - * \brief Store all the turboperformance in the solver in ZONE_0. + * \brief Store all the turboperformance in the solver in final zone. * \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 @@ -1352,6 +1353,10 @@ class CGeometry { */ static void UpdateGeometry(CGeometry** geometry_container, CConfig* config); + static void UpdateTurboGeometry(CGeometry**** geometry, CInterface*** interface, CConfig** config_container); + + static void InitTurboVertexAdj(CGeometry**** geometry, CConfig** config); + /*! * \brief Update the multi-grid structure for the customized boundary conditions * \param geometry_container - Geometrical definition. diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 0bd1a4bf8eef..6efd4d2043b3 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -2346,6 +2346,62 @@ void CGeometry::UpdateGeometry(CGeometry** geometry_container, CConfig* config) geometry_container[MESH_0]->ComputeSurfaceAreaCfgFile(config); } +void CGeometry::InitTurboVertexAdj(CGeometry**** geometry, CConfig** config){ + auto nSpanMax = 0u; + auto nZone = config[ZONE_0]->GetnZone(); + + /*--- Create turbovertex ---*/ + for (auto iZone = 0u; iZone < nZone; iZone++){ + geometry[iZone][INST_0][MESH_0]->ComputeNSpan(config[iZone], iZone, INFLOW, true); + geometry[iZone][INST_0][MESH_0]->ComputeNSpan(config[iZone], iZone, OUTFLOW, true); + if (config[iZone]->GetnSpanWiseSections() > nSpanMax){ + nSpanMax = config[iZone]->GetnSpanWiseSections(); + } + + 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); + } + + /*--- Set max span in all zones ---*/ + for (auto iZone = 0u; iZone < nZone; iZone++){ + if (config[iZone]->GetBoolTurbomachinery()) { + config[iZone]->SetnSpanMaxAllZones(nSpanMax); + } + } +} + +void CGeometry::UpdateTurboGeometry(CGeometry**** geometry, CInterface*** interface, CConfig** config){ + auto nZone = config[ZONE_0]->GetnZone(); + + for (auto iZone = 0u; iZone < nZone; iZone++) { + geometry[iZone][INST_0][MESH_0]->SetAvgTurboValue(config[iZone], iZone, INFLOW, true); + geometry[iZone][INST_0][MESH_0]->SetAvgTurboValue(config[iZone],iZone, OUTFLOW, true); + geometry[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config[iZone], true); + } + + if(config[ZONE_0]->GetBoolMixingPlaneInterface()){ + for (auto donorZone = 0u; donorZone < nZone; donorZone++) { + for (auto targetZone = 0u; targetZone < nZone; targetZone++) { + if (interface[donorZone][targetZone] != nullptr){ + interface[donorZone][targetZone]->SetSpanWiseLevels(config[donorZone], config[targetZone]); + } + } + } + } + + for (auto iZone = 0u; 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---*/ + for (auto iZone = 1u; iZone < nZone; iZone++) { + auto nBlades = config[iZone]->GetnBlades(iZone); + config[ZONE_0]->SetnBlades(iZone, nBlades); + } +} + void CGeometry::SetCustomBoundary(CConfig* config) { unsigned short iMarker; unsigned long iVertex; diff --git a/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp b/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp index e9046e5a2875..e2a69703aa8f 100644 --- a/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp @@ -157,7 +157,7 @@ class CDiscAdjFluidIteration final : public CIteration { * \param[in] iInst - Index of the zone. * \param[in] kind_recording - The kind of recording (geometry or flow). */ - void SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, CConfig** config, + void SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, CConfig** config, CInterface*** interface, unsigned short iZone, unsigned short iInst, RECORDING kind_recording) override; }; diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index 346f763581cf..5e0d47a435c1 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -116,11 +116,6 @@ class CFluidIteration : public CIteration { */ void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter, unsigned short iZone); - /*! - * \brief Computes turboperformance. - */ - 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. * \param[in] solver - Container vector with all the solutions. diff --git a/SU2_CFD/include/iteration/CIteration.hpp b/SU2_CFD/include/iteration/CIteration.hpp index bd8df8ef50e6..f27f3f96810e 100644 --- a/SU2_CFD/include/iteration/CIteration.hpp +++ b/SU2_CFD/include/iteration/CIteration.hpp @@ -293,6 +293,19 @@ class CIteration { virtual void SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, CConfig** config, unsigned short iZone, unsigned short iInst, RECORDING kind_recording) {} + virtual void SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, CConfig** config, CInterface*** interface, + unsigned short iZone, unsigned short iInst, RECORDING kind_recording) {} + virtual void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, unsigned short iZone, unsigned short iInst) {} + + /*! + * \brief Computes turboperformance. + */ + virtual void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container){} + + /*! + * \brief Initialises turboperformance classes. + */ + virtual void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid){}; }; diff --git a/SU2_CFD/include/iteration/CTurboIteration.hpp b/SU2_CFD/include/iteration/CTurboIteration.hpp index 876be3e755a9..64341f894863 100644 --- a/SU2_CFD/include/iteration/CTurboIteration.hpp +++ b/SU2_CFD/include/iteration/CTurboIteration.hpp @@ -67,5 +67,10 @@ class CTurboIteration : public CFluidIteration { /*! * \brief Initialises turboperformance classes. */ - void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid); + void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid) override; + + /*! + * \brief Computes turboperformance. + */ + void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container) override; }; diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 8dea53b7ea2d..67eb2d950fa5 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -155,70 +155,9 @@ class CEulerSolver : public CFVMFlowSolverBase > > CkInflow, CkOutflow1, CkOutflow2; - /*--- Structure for handling turbomachinery objective functions ---*/ - // Evaluating these in the solver as they need to be declared in the solution - - struct TurboObjectiveFunction { - su2double* EntropyGeneration = nullptr; - su2double* TotalPressureLoss = nullptr; - su2double* KineticEnergyLoss = nullptr; - int _nTurboPerfMarkers = 0; - - void allocate(int nTurboPerfMarkers) { - _nTurboPerfMarkers = nTurboPerfMarkers; - EntropyGeneration = new su2double[nTurboPerfMarkers]; - TotalPressureLoss = new su2double[nTurboPerfMarkers]; - KineticEnergyLoss = new su2double[nTurboPerfMarkers]; - setZero(); - } - - void setZero() { - for (int i = 0u; i < _nTurboPerfMarkers; i++) { - if (_nTurboPerfMarkers) { - EntropyGeneration[i] = 0; - TotalPressureLoss[i] = 0; - KineticEnergyLoss[i] = 0; - } - } - } - - void Set(short unsigned int ObjFunc, int bladeRow, su2double val) const { - switch (ObjFunc) { - case ENTROPY_GENERATION: - EntropyGeneration[bladeRow] = val; - break; - case TOTAL_PRESSURE_LOSS: - TotalPressureLoss[bladeRow] = val; - break; - case KINETIC_ENERGY_LOSS: - KineticEnergyLoss[bladeRow] = val; - break; - default: - break; - } - } - - su2double Get(short unsigned int ObjFunc, int bladeRow) const { - switch (ObjFunc) { - case ENTROPY_GENERATION: - return EntropyGeneration[bladeRow]; - case TOTAL_PRESSURE_LOSS: - return TotalPressureLoss[bladeRow]; - case KINETIC_ENERGY_LOSS: - return KineticEnergyLoss[bladeRow]; - default: - return 0.0; - } - } - }; - - TurboObjectiveFunction TurboObjFunc; - - // I will move these they are here for convenience right now! - - inline su2double GetTurboObjectiveFunction(short unsigned int ObjFunc, int bladeRow) const final { return TurboObjFunc.Get(ObjFunc, bladeRow); } - - inline void SetTurboObjectiveFunction(short unsigned int ObjFunc, int bladeRow, su2double val) final { TurboObjFunc.Set(ObjFunc, bladeRow, val); } + vector EntropyGeneration; + vector TotalPressureLoss; + vector KineticEnergyLoss; /*--- End of Turbomachinery Solver Variables ---*/ @@ -1210,6 +1149,35 @@ class CEulerSolver : public CFVMFlowSolverBaseSetDependencies(solver_container, geometry_container, numerics_container, - config_container, iZone, INST_0, kind_recording); + config_container, interface_container, iZone, INST_0, kind_recording); } AD::Push_TapePosition(); /// DEPENDENCIES @@ -636,7 +636,7 @@ void CDiscAdjMultizoneDriver::SetRecording(RECORDING kind_recording, Kind_Tape t for (iZone = 0; iZone < nZone; iZone++) { if (Has_Deformation(iZone)) { iteration_container[iZone][INST_0]->SetDependencies(solver_container, geometry_container, numerics_container, - config_container, iZone, INST_0, kind_recording); + config_container, interface_container, iZone, INST_0, kind_recording); } } SetObjFunction(kind_recording); @@ -719,7 +719,9 @@ void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) { direct_output[iZone]->SetHistoryOutput(geometry, solvers, config); // Need to evaluate turbomachinery objective functions here as they are only calculated in the final zone - if (config->GetBoolTurbomachinery() && iZone == nZone-1){ + if (config->GetBoolTurbomachinery() && iZone == config->GetnZone()-1){ + direct_iteration[iZone][INST_0]->InitTurboPerformance(geometry, config_container, solvers[FLOW_SOL]->GetFluidModel()); + direct_iteration[iZone][INST_0]->ComputeTurboPerformance(solver_container, geometry_container, config_container); const auto weight = config->GetWeight_ObjFunc(0); ObjFunc += weight * solvers[FLOW_SOL]->GetTurboObjectiveFunction(config->GetKind_ObjFunc(), config_container[ZONE_0]->GetnMarker_Turbomachinery()); } diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 047650701075..5be91fcaf90b 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -243,7 +243,7 @@ CDriverBase(confFile, val_nZone, MPICommunicator), StopCalc(false), fsi(false), } } - if (config_container[ZONE_0]->GetBoolTurbomachinery()){ + if (config_container[ZONE_0]->GetBoolTurbomachinery() && !config_container[ZONE_0]->GetDiscrete_Adjoint()){ if (rank == MASTER_NODE) cout << endl <<"---------------------- Turbomachinery Preprocessing ---------------------" << endl; diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index eedf32187ecd..ac10975a70c4 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -447,7 +447,7 @@ void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** ge } void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, - CConfig** config, unsigned short iZone, unsigned short iInst, + CConfig** config, CInterface*** interface, unsigned short iZone, unsigned short iInst, RECORDING kind_recording) { auto solvers0 = solver[iZone][iInst][MESH_0]; auto geometry0 = geometry[iZone][iInst][MESH_0]; @@ -478,6 +478,23 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** solvers0[TURB_SOL]->CompleteComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); } if (config[iZone]->GetBoolTurbomachinery()) { + if (iZone == ZONE_0){ + // Defines geometric dependency in turbo simulations, this is done in ZONE_0 as it requires a loop over all zones first + // This step is very similar to the turbo preprocessing in CDriver but it is not recorded to the tape their, hence repeated here + // Do this in two parts as solver step is necessary in the middle + for (auto jZone = 0u; jZone < nZone; jZone++){ + SU2_OMP_PARALLEL + CGeometry::UpdateGeometry(geometry[jZone][iInst], config[jZone]); + END_SU2_OMP_PARALLEL + + CGeometry::ComputeWallDistance(config, geometry); + } + geometry[iZone][MESH_0][INST_0]->InitTurboVertexAdj(geometry, config); + for (auto iZone = 0u; iZone < nZone; iZone++) { + solver[iZone][INST_0][MESH_0][FLOW_SOL]->InitTurboContainers(geometry[iZone][INST_0][MESH_0],config[iZone]); + } + geometry[iZone][MESH_0][INST_0]->UpdateTurboGeometry(geometry, interface, config); + } if (config[iZone]->GetBoolGiles() && config[iZone]->GetSpatialFourier()){ auto conv_bound_numerics = numerics[iZone][iInst][MESH_0][FLOW_SOL][CONV_BOUND_TERM + omp_get_thread_num()*MAX_TERMS]; solvers0[FLOW_SOL]->PreprocessBC_Giles(geometry0, config[iZone], conv_bound_numerics, INFLOW); diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 65146fd6c25d..22b0e18679c8 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -226,7 +226,7 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe /*--- Turbomachinery Specific Montior ---*/ if (config[ZONE_0]->GetBoolTurbomachinery()){ if (val_iZone == config[ZONE_0]->GetnZone()-1) { - ComputeTurboPerformance(solver, geometry, config, config[val_iZone]->GetnInner_Iter()); + ComputeTurboPerformance(solver, geometry, config); output->SetHistoryOutput(geometry, solver, config, TurbomachineryStagePerformance, TurbomachineryPerformance, val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), @@ -322,54 +322,6 @@ void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** c } } -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); - - auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); - 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]); - - /*--- Set turbomachinery objective function value in each zone ---*/ - for (auto iBlade = 0u; iBlade < nBladesRow; iBlade++) { - // Should we set in ZONE_0 or nZone-1? - auto iBladePerf = TurbomachineryPerformance->GetBladesPerformances().at(iBlade).at(nSpan); - InState = iBladePerf->GetInletState(); - OutState = iBladePerf->GetOutletState(); - solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, iBlade, TurbomachineryStagePerformance->GetNormEntropyGen()*100); - solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, iBlade, iBladePerf->GetTotalPressureLoss()); - solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, iBlade, iBladePerf->GetKineticEnergyLoss()); - } - /*--- Set global turbomachinery objective function (evaluated in final zone as dependent on values from all previous zones ) ---*/ - solver[nZone-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, nBladesRow, TurbomachineryStagePerformance->GetNormEntropyGen()*100); - solver[nZone-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, nBladesRow, TurbomachineryStagePerformance->GetTotalPressureLoss()); - solver[nZone-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, nBladesRow, TurbomachineryStagePerformance->GetKineticEnergyLoss()); - } -} - 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 b56ba3e1a3cb..3158a3b62643 100644 --- a/SU2_CFD/src/iteration/CTurboIteration.cpp +++ b/SU2_CFD/src/iteration/CTurboIteration.cpp @@ -64,3 +64,52 @@ void CTurboIteration::InitTurboPerformance(CGeometry* geometry, CConfig** config TurbomachineryPerformance = std::make_shared(config, *geometry, *fluid); TurbomachineryStagePerformance = std::make_shared(*fluid); } + +void CTurboIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container) { + unsigned short nDim = geometry_container[ZONE_0][INST_0][MESH_0]->GetnDim(); + unsigned short nBladesRow = config_container[ZONE_0]->GetnMarker_Turbomachinery(); + unsigned short nZone = config_container[ZONE_0]->GetnZone(); + 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); + + auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); + 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]); + + /*--- Set turbomachinery objective function value in each zone ---*/ + for (auto iBlade = 0u; iBlade < nBladesRow; iBlade++) { + // Should we set in ZONE_0 or nZone-1? + auto iBladePerf = TurbomachineryPerformance->GetBladesPerformances().at(iBlade).at(nSpan); + InState = iBladePerf->GetInletState(); + OutState = iBladePerf->GetOutletState(); + solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, iBlade, TurbomachineryStagePerformance->GetNormEntropyGen()*100); + solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, iBlade, iBladePerf->GetTotalPressureLoss()); + solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, iBlade, iBladePerf->GetKineticEnergyLoss()); + } + /*--- Set global turbomachinery objective function (evaluated in final zone as dependent on values from all previous zones ) ---*/ + solver[nBladesRow-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, nBladesRow, TurbomachineryStagePerformance->GetNormEntropyGen()*100); + solver[nBladesRow-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, nBladesRow, TurbomachineryStagePerformance->GetTotalPressureLoss()); + solver[nBladesRow-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, nBladesRow, TurbomachineryStagePerformance->GetKineticEnergyLoss()); + } +} diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 714f01c7e932..eafbfb9595dd 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -458,12 +458,11 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ } } - /*--- Initialize objective function containers ---*/ - TurboObjFunc.allocate(config->GetnMarker_Turbomachinery()); - - /*--- Initialize turboperformance classes ---*/ - TurbomachineryPerformance = std::make_shared(config, *geometry, *fluid); - TurbomachineryStagePerformance = std::make_shared(*fluid); + /*--- Initialsize turbomachinery objective functions (+1 as value for stage values) ---*/ + auto nMarker_Turbo = config->GetnMarker_Turbomachinery() + 1; + EntropyGeneration.resize(nMarker_Turbo); + TotalPressureLoss.resize(nMarker_Turbo); + KineticEnergyLoss.resize(nMarker_Turbo); } void CEulerSolver::Set_MPI_ActDisk(CSolver **solver_container, CGeometry *geometry, CConfig *config) { From d43fef58dbcfe2fded16903bf7b3e6fab392cce0 Mon Sep 17 00:00:00 2001 From: Joshua Kelly Date: Mon, 9 Jun 2025 05:40:45 +0100 Subject: [PATCH 06/79] Singlezone working with validated gradients and turbo obj funcs. Need to run in quasi-MZ approach. (NEEDS CLEANING) --- SU2_CFD/include/iteration/CIteration.hpp | 4 +- SU2_CFD/include/iteration/CTurboIteration.hpp | 10 ---- SU2_CFD/include/output/CFlowCompOutput.hpp | 2 + SU2_CFD/include/output/CTurboOutput.hpp | 5 ++ SU2_CFD/include/solvers/CDiscAdjSolver.hpp | 9 ++++ SU2_CFD/include/solvers/CSolver.hpp | 8 +++ .../src/drivers/CDiscAdjMultizoneDriver.cpp | 12 ++--- .../src/drivers/CDiscAdjSinglezoneDriver.cpp | 2 +- SU2_CFD/src/drivers/CDriver.cpp | 2 +- SU2_CFD/src/integration/CIntegration.cpp | 16 +++--- .../src/iteration/CDiscAdjFluidIteration.cpp | 25 ++++++--- SU2_CFD/src/iteration/CFluidIteration.cpp | 3 ++ SU2_CFD/src/iteration/CIteration.cpp | 53 ++++++++++++++++++ SU2_CFD/src/iteration/CTurboIteration.cpp | 54 ------------------- SU2_CFD/src/output/CFlowCompOutput.cpp | 9 ++++ SU2_CFD/src/output/CTurboOutput.cpp | 3 +- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 18 +++++++ SU2_CFD/src/solvers/CEulerSolver.cpp | 12 ++--- 18 files changed, 145 insertions(+), 102 deletions(-) diff --git a/SU2_CFD/include/iteration/CIteration.hpp b/SU2_CFD/include/iteration/CIteration.hpp index f27f3f96810e..b31f28e2702e 100644 --- a/SU2_CFD/include/iteration/CIteration.hpp +++ b/SU2_CFD/include/iteration/CIteration.hpp @@ -302,10 +302,10 @@ class CIteration { /*! * \brief Computes turboperformance. */ - virtual void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container){} + void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container); /*! * \brief Initialises turboperformance classes. */ - virtual void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid){}; + void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid); }; diff --git a/SU2_CFD/include/iteration/CTurboIteration.hpp b/SU2_CFD/include/iteration/CTurboIteration.hpp index 64341f894863..b46a5a837150 100644 --- a/SU2_CFD/include/iteration/CTurboIteration.hpp +++ b/SU2_CFD/include/iteration/CTurboIteration.hpp @@ -63,14 +63,4 @@ 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 Initialises turboperformance classes. - */ - void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid) override; - - /*! - * \brief Computes turboperformance. - */ - void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container) override; }; diff --git a/SU2_CFD/include/output/CFlowCompOutput.hpp b/SU2_CFD/include/output/CFlowCompOutput.hpp index c7644a37f277..e1d697671f60 100644 --- a/SU2_CFD/include/output/CFlowCompOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompOutput.hpp @@ -74,6 +74,8 @@ class CFlowCompOutput final: public CFlowOutput { */ void SetHistoryOutputFields(CConfig *config) override; + void SetTurbomachineryObjectiveFunctions(CSolver *solver, CConfig *config); + /*! * \brief Check whether the base values for relative residuals should be initialized * \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 5a1741530cdb..784d1831145d 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -96,6 +96,11 @@ class CTurbomachineryState { CTurbomachineryState(unsigned short nDim, su2double area, su2double radius); + inline void SetZeroValues() { + Density = Pressure = Entropy = Enthalpy = Temperature = TotalTemperature = TotalPressure = TotalEnthalpy = 0.0; + AbsFlowAngle = FlowAngle = MassFlow = Rothalpy = TotalRelPressure = 0.0; + }; + void ComputeState(CFluidModel& fluidModel, const CTurbomachineryPrimitiveState& primitiveState); const su2double& GetDensity() const { return Density; } diff --git a/SU2_CFD/include/solvers/CDiscAdjSolver.hpp b/SU2_CFD/include/solvers/CDiscAdjSolver.hpp index 84af2e4a7556..6d97c4e025b0 100644 --- a/SU2_CFD/include/solvers/CDiscAdjSolver.hpp +++ b/SU2_CFD/include/solvers/CDiscAdjSolver.hpp @@ -106,6 +106,15 @@ class CDiscAdjSolver final : public CSolver { */ void RegisterOutput(CGeometry *geometry, CConfig *config) override; + /*! + * \brief performs the preprocessing of the adjoint AD-based solver. + * Registers the normals at turbomachinery boundaries of interest on the tape + * Called while tape is active. + * \param[in] geometry - the geometrical definition of the problem + * \param[in] config - the particular config + */ + void Register_VertexNormals(CGeometry *geometry, CConfig *config, bool input) override; + /*! * \brief Sets the adjoint values of the output of the flow (+turb.) iteration * before evaluation of the tape. diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 32f1558bd201..6842df935894 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -3517,6 +3517,14 @@ class CSolver { */ inline virtual void RegisterOutput(CGeometry *geometry_container, CConfig *config) { } + /*! + * \brief A vritual member + * \param[in] geometry - the geometrical definition of the problem + * \param[in] config - the particular config + * \param[in] input - Boolean whether In- or Output should be registered + */ + inline virtual void Register_VertexNormals(CGeometry *geometry, CConfig *config, bool input) { }; + /*! * \brief A virtual member. * \param[in] input - Boolean whether In- or Output should be registered. diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 85c5bbf5f6cd..f6e0dbe21cca 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -690,6 +690,11 @@ void CDiscAdjMultizoneDriver::DirectIteration(unsigned short iZone, RECORDING ki solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0); + // /*--- Turbo Specific Post-Procesisng ---*/ + // if (config_container[iZone]->GetBoolTurbomachinery()){ + // direct_iteration[iZone][INST_0]->Postprocess(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0); + // } + } void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) { @@ -718,13 +723,6 @@ void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) { } direct_output[iZone]->SetHistoryOutput(geometry, solvers, config); - // Need to evaluate turbomachinery objective functions here as they are only calculated in the final zone - if (config->GetBoolTurbomachinery() && iZone == config->GetnZone()-1){ - direct_iteration[iZone][INST_0]->InitTurboPerformance(geometry, config_container, solvers[FLOW_SOL]->GetFluidModel()); - direct_iteration[iZone][INST_0]->ComputeTurboPerformance(solver_container, geometry_container, config_container); - const auto weight = config->GetWeight_ObjFunc(0); - ObjFunc += weight * solvers[FLOW_SOL]->GetTurboObjectiveFunction(config->GetKind_ObjFunc(), config_container[ZONE_0]->GetnMarker_Turbomachinery()); - } ObjFunc += solvers[FLOW_SOL]->GetTotal_ComboObj(); break; diff --git a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp index de39415300ce..5e7df5f68292 100644 --- a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp @@ -285,7 +285,7 @@ void CDiscAdjSinglezoneDriver::SetRecording(RECORDING kind_recording){ /*--- Set the dependencies of the iteration ---*/ - iteration->SetDependencies(solver_container, geometry_container, numerics_container, config_container, ZONE_0, + iteration->SetDependencies(solver_container, geometry_container, numerics_container, config_container, nullptr, ZONE_0, INST_0, kind_recording); /*--- Do one iteration of the direct solver ---*/ diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 5be91fcaf90b..047650701075 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -243,7 +243,7 @@ CDriverBase(confFile, val_nZone, MPICommunicator), StopCalc(false), fsi(false), } } - if (config_container[ZONE_0]->GetBoolTurbomachinery() && !config_container[ZONE_0]->GetDiscrete_Adjoint()){ + if (config_container[ZONE_0]->GetBoolTurbomachinery()){ if (rank == MASTER_NODE) cout << endl <<"---------------------- Turbomachinery Preprocessing ---------------------" << endl; diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index a3af58d572bf..37cf6f91f8cd 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -89,14 +89,14 @@ void CIntegration::Space_Integration(CGeometry *geometry, solver_container[MainSolver]->PreprocessBC_Giles(geometry, config, conv_bound_numerics, 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 + // 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 ---*/ diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index ac10975a70c4..cf45edaa2caf 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -416,6 +416,10 @@ void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** ge if (turbulent && !config[iZone]->GetFrozen_Visc_Disc()) { solvers0[ADJTURB_SOL]->RegisterSolution(geometry0, config[iZone]); } + if (config[iZone]->GetBoolTurbomachinery()) { + geometry0->RegisterCoordinates(); + solvers0[ADJFLOW_SOL]->Register_VertexNormals(geometry0, config[iZone], true); + } if (config[iZone]->GetKind_Species_Model() != SPECIES_MODEL::NONE) { solvers0[ADJSPECIES_SOL]->RegisterSolution(geometry0, config[iZone]); } @@ -482,16 +486,16 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** // Defines geometric dependency in turbo simulations, this is done in ZONE_0 as it requires a loop over all zones first // This step is very similar to the turbo preprocessing in CDriver but it is not recorded to the tape their, hence repeated here // Do this in two parts as solver step is necessary in the middle - for (auto jZone = 0u; jZone < nZone; jZone++){ - SU2_OMP_PARALLEL - CGeometry::UpdateGeometry(geometry[jZone][iInst], config[jZone]); - END_SU2_OMP_PARALLEL + // for (auto jZone = 0u; jZone < nZone; jZone++){ + // SU2_OMP_PARALLEL + // CGeometry::UpdateGeometry(geometry[jZone][iInst], config[jZone]); + // END_SU2_OMP_PARALLEL - CGeometry::ComputeWallDistance(config, geometry); - } + // CGeometry::ComputeWallDistance(config, geometry); + // } geometry[iZone][MESH_0][INST_0]->InitTurboVertexAdj(geometry, config); - for (auto iZone = 0u; iZone < nZone; iZone++) { - solver[iZone][INST_0][MESH_0][FLOW_SOL]->InitTurboContainers(geometry[iZone][INST_0][MESH_0],config[iZone]); + for (auto jZone = 0u; jZone < nZone; jZone++) { + solver[jZone][INST_0][MESH_0][FLOW_SOL]->InitTurboContainers(geometry[jZone][INST_0][MESH_0],config[jZone]); } geometry[iZone][MESH_0][INST_0]->UpdateTurboGeometry(geometry, interface, config); } @@ -504,7 +508,9 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** solvers0[FLOW_SOL]->PreprocessAverage(solvers0, geometry0, config[iZone], OUTFLOW); solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], INFLOW); solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], OUTFLOW); + InitTurboPerformance(geometry0, config, solvers0[FLOW_SOL]->GetFluidModel()); solvers0[FLOW_SOL]->GatherInOutAverageValues(config[iZone], geometry0); + if (iZone == nZone-1) ComputeTurboPerformance(solver, geometry, config); } if (config[iZone]->GetKind_Species_Model() != SPECIES_MODEL::NONE) { solvers0[SPECIES_SOL]->Preprocessing(geometry0, solvers0, config[iZone], MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS, true); @@ -544,6 +550,9 @@ void CDiscAdjFluidIteration::RegisterOutput(CSolver***** solver, CGeometry**** g if (turbulent && !config[iZone]->GetFrozen_Visc_Disc()) { solvers0[ADJTURB_SOL]->RegisterOutput(geometry0, config[iZone]); } + if (config[iZone]->GetBoolTurbomachinery()) { + solvers0[ADJFLOW_SOL]->Register_VertexNormals(geometry0, config[iZone], false); + } if (config[iZone]->GetKind_Species_Model() != SPECIES_MODEL::NONE) { solvers0[ADJSPECIES_SOL]->RegisterOutput(geometry0, config[iZone]); } diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 22b0e18679c8..0017182a2d2e 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -365,6 +365,9 @@ void CFluidIteration::Solve(COutput* output, CIntegration**** integration, CGeom Iterate(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, val_iZone, INST_0); + /*--- Postprocessing Step ---*/ + Postprocess(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, val_iZone, val_iInst); + /*--- Monitor the pseudo-time ---*/ StopCalc = Monitor(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, val_iZone, INST_0); diff --git a/SU2_CFD/src/iteration/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index 54fe1e00998a..4288fb2ecf6b 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -209,3 +209,56 @@ void CIteration::Output(COutput* output, CGeometry**** geometry, CSolver***** so output->SetResultFiles(geometry[val_iZone][INST_0][MESH_0], config[val_iZone], solver[val_iZone][INST_0][MESH_0], InnerIter); } + +void CIteration::InitTurboPerformance(CGeometry* geometry, CConfig** config, CFluidModel* fluid) { + TurbomachineryPerformance = std::make_shared(config, *geometry, *fluid); + TurbomachineryStagePerformance = std::make_shared(*fluid); +} + +void CIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container) { + const auto nDim = geometry_container[ZONE_0][INST_0][MESH_0]->GetnDim(); + const auto nBladesRow = config_container[ZONE_0]->GetnMarker_Turbomachinery(); + const auto nZone = config_container[ZONE_0]->GetnZone(); + vector TurboPrimitiveIn, TurboPrimitiveOut; + std::vector> bladesPrimitives; + + if (rank == MASTER_NODE) { + for (auto iBlade = 0u; iBlade < nBladesRow; iBlade++){ + /* Blade Primitive initialized per blade */ + std::vector bladePrimitives; + auto nSpan = config_container[iBlade]->GetnSpanWiseSections(); + for (auto 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); + + auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); + 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]); + + /*--- Set turbomachinery objective function value in each zone ---*/ + for (auto iBlade = 0u; iBlade < nBladesRow; iBlade++) { + // Should we set in ZONE_0 or nZone-1? + auto iBladePerf = TurbomachineryPerformance->GetBladesPerformances().at(iBlade).at(nSpan); + InState = iBladePerf->GetInletState(); + OutState = iBladePerf->GetOutletState(); + solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, iBlade, TurbomachineryStagePerformance->GetNormEntropyGen()*100); + solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, iBlade, iBladePerf->GetTotalPressureLoss()); + solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, iBlade, iBladePerf->GetKineticEnergyLoss()); + } + /*--- Set global turbomachinery objective function (evaluated in final zone as dependent on values from all previous zones ) ---*/ + solver[nBladesRow-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, nBladesRow, TurbomachineryStagePerformance->GetNormEntropyGen()*100); + solver[nBladesRow-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, nBladesRow, TurbomachineryStagePerformance->GetTotalPressureLoss()); + solver[nBladesRow-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, nBladesRow, TurbomachineryStagePerformance->GetKineticEnergyLoss()); + } +} diff --git a/SU2_CFD/src/iteration/CTurboIteration.cpp b/SU2_CFD/src/iteration/CTurboIteration.cpp index 3158a3b62643..355f7a59c9fa 100644 --- a/SU2_CFD/src/iteration/CTurboIteration.cpp +++ b/SU2_CFD/src/iteration/CTurboIteration.cpp @@ -59,57 +59,3 @@ 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 = std::make_shared(*fluid); -} - -void CTurboIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container) { - unsigned short nDim = geometry_container[ZONE_0][INST_0][MESH_0]->GetnDim(); - unsigned short nBladesRow = config_container[ZONE_0]->GetnMarker_Turbomachinery(); - unsigned short nZone = config_container[ZONE_0]->GetnZone(); - 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); - - auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); - 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]); - - /*--- Set turbomachinery objective function value in each zone ---*/ - for (auto iBlade = 0u; iBlade < nBladesRow; iBlade++) { - // Should we set in ZONE_0 or nZone-1? - auto iBladePerf = TurbomachineryPerformance->GetBladesPerformances().at(iBlade).at(nSpan); - InState = iBladePerf->GetInletState(); - OutState = iBladePerf->GetOutletState(); - solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, iBlade, TurbomachineryStagePerformance->GetNormEntropyGen()*100); - solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, iBlade, iBladePerf->GetTotalPressureLoss()); - solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, iBlade, iBladePerf->GetKineticEnergyLoss()); - } - /*--- Set global turbomachinery objective function (evaluated in final zone as dependent on values from all previous zones ) ---*/ - solver[nBladesRow-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, nBladesRow, TurbomachineryStagePerformance->GetNormEntropyGen()*100); - solver[nBladesRow-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, nBladesRow, TurbomachineryStagePerformance->GetTotalPressureLoss()); - solver[nBladesRow-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, nBladesRow, TurbomachineryStagePerformance->GetKineticEnergyLoss()); - } -} diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index d3c76e75a361..5e000feee37b 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -474,6 +474,9 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol if (config->GetEquivArea()) SetNearfieldInverseDesign(flow_solver, geometry, config); + /*--- Set Turbomachinery Objective functions ---*/ + SetTurbomachineryObjectiveFunctions(flow_solver, config); + /*--- Keep this as last, since it uses the history values that were set. ---*/ SetCustomOutputs(solver, geometry, config); @@ -481,6 +484,12 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol SetCustomAndComboObjectives(FLOW_SOL, config, solver); } +void CFlowCompOutput::SetTurbomachineryObjectiveFunctions(CSolver *solver, CConfig *config){ + const auto weight = config->GetWeight_ObjFunc(0); + const auto ObjFunc = solver->GetTurboObjectiveFunction(config->GetKind_ObjFunc(), config->GetnMarker_Turbomachinery()); + solver->SetTotal_Custom_ObjFunc(weight*ObjFunc); +} + bool CFlowCompOutput::SetInitResiduals(const CConfig *config){ return (config->GetTime_Marching() != TIME_MARCHING::STEADY && (curInnerIter == 0))|| diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index 929ed502ba81..b69511d34806 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -39,8 +39,7 @@ CTurbomachineryCombinedPrimitiveStates::CTurbomachineryCombinedPrimitiveStates( : InletPrimitiveState(inletPrimitiveState), OutletPrimitiveState(outletPrimitiveState) {} CTurbomachineryState::CTurbomachineryState() { - Density = Pressure = Entropy = Enthalpy = Temperature = TotalTemperature = TotalPressure = TotalEnthalpy = 0.0; - AbsFlowAngle = FlowAngle = MassFlow = Rothalpy = TotalRelPressure = 0.0; + SetZeroValues(); Area = Radius = 0.0; } diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 330309632e56..fe1ce12a6f2f 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -307,6 +307,24 @@ void CDiscAdjSolver::RegisterOutput(CGeometry *geometry, CConfig *config) { direct_solver->RegisterComplementary(false, config); } +void CDiscAdjSolver::Register_VertexNormals(CGeometry *geometry, CConfig *config, bool input) { + // Only need vertex normals for boundaries declared as turbomachinery markers? + + for (auto iMarker=0ul; iMarker < nMarker; iMarker++) { + for (auto iMarkerTP = 1; iMarkerTP < config->GetnMarker_Turbomachinery() + 1; iMarkerTP++) { + if (config->GetMarker_All_Turbomachinery(iMarker) == iMarkerTP) { + for (auto iVertex = 0ul; iVertex < geometry->GetnVertex(iMarker); iVertex++) { + const auto Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); + for (auto iDim = 0u; iDim < nDim; iDim++) { + if (input) AD::RegisterInput(Normal[iDim]); + else AD::RegisterOutput(Normal[iDim]); + } + } + } + } + } +} + void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm) { const bool time_n1_needed = config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND; diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index eafbfb9595dd..d5ce0acee9f9 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4757,15 +4757,9 @@ void CEulerSolver::Evaluate_ObjFunc(const CConfig *config, CSolver**) { case SURFACE_MACH: Total_ComboObj+=Weight_ObjFunc*config->GetSurface_Mach(0); break; - // case ENTROPY_GENERATION: - // Total_ComboObj+=Weight_ObjFunc*GetTurboObjectiveFunction(Kind_ObjFunc, config->GetnMarker_Turbomachinery()); - // break; - // case TOTAL_PRESSURE_LOSS: - // Total_ComboObj+=Weight_ObjFunc*GetTurboObjectiveFunction(Kind_ObjFunc, config->GetnMarker_Turbomachinery()); - // break; - // case KINETIC_ENERGY_LOSS: - // Total_ComboObj+=Weight_ObjFunc*GetTurboObjectiveFunction(Kind_ObjFunc, config->GetnMarker_Turbomachinery()); - // break; + case ENTROPY_GENERATION: + Total_ComboObj+=Weight_ObjFunc*GetTurboObjectiveFunction(Kind_ObjFunc, config->GetnMarker_Turbomachinery()); + break; default: break; } From ae2f0014557ee8e98cd40e3db6ffe406f6079502 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 6 Oct 2025 13:40:07 +0100 Subject: [PATCH 07/79] Messy commit of refactoring --- Common/include/geometry/CGeometry.hpp | 4 +- Common/src/CConfig.cpp | 1 + Common/src/geometry/CGeometry.cpp | 66 +++++----- Common/src/geometry/CPhysicalGeometry.cpp | 4 + SU2_CFD/include/drivers/CDriver.hpp | 21 ++- SU2_CFD/include/drivers/CDriverBase.hpp | 3 +- SU2_CFD/include/drivers/CMultizoneDriver.hpp | 9 -- .../integration/CMultiGridIntegration.hpp | 2 +- SU2_CFD/include/interfaces/CInterface.hpp | 13 ++ SU2_CFD/include/iteration/CIteration.hpp | 19 ++- SU2_CFD/include/output/CFlowCompOutput.hpp | 10 +- SU2_CFD/include/output/COutput.hpp | 10 +- SU2_CFD/include/output/CTurboOutput.hpp | 8 +- SU2_CFD/include/solvers/CEulerSolver.hpp | 27 ++-- SU2_CFD/include/solvers/CSolver.hpp | 12 +- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 29 ++++- .../src/drivers/CDiscAdjSinglezoneDriver.cpp | 4 + SU2_CFD/src/drivers/CDriver.cpp | 121 +++++++++++------- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 32 ++--- SU2_CFD/src/integration/CIntegration.cpp | 3 +- .../src/integration/CMultiGridIntegration.cpp | 22 ++-- SU2_CFD/src/interfaces/CInterface.cpp | 5 + .../cfd/CConservativeVarsInterface.cpp | 1 + .../interfaces/cfd/CMixingPlaneInterface.cpp | 5 + .../src/interfaces/cfd/CSlidingInterface.cpp | 1 + .../fsi/CDiscAdjFlowTractionInterface.cpp | 1 + .../fsi/CDisplacementsInterface.cpp | 1 + .../interfaces/fsi/CFlowTractionInterface.cpp | 1 + .../src/iteration/CDiscAdjFluidIteration.cpp | 64 +++++---- SU2_CFD/src/iteration/CFluidIteration.cpp | 80 ++++++------ SU2_CFD/src/iteration/CIteration.cpp | 94 +++++++------- SU2_CFD/src/iteration/CTurboIteration.cpp | 54 +++++--- SU2_CFD/src/numerics/flow/convection/roe.cpp | 2 + SU2_CFD/src/output/CFlowCompOutput.cpp | 36 +++--- SU2_CFD/src/output/COutput.cpp | 10 +- SU2_CFD/src/output/CTurboOutput.cpp | 70 +++++----- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 3 + SU2_CFD/src/solvers/CEulerSolver.cpp | 46 +++++-- 38 files changed, 527 insertions(+), 367 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 2c01b7bb9d7b..8803cbdf92e1 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1353,9 +1353,9 @@ class CGeometry { */ static void UpdateGeometry(CGeometry** geometry_container, CConfig* config); - static void UpdateTurboGeometry(CGeometry**** geometry, CInterface*** interface, CConfig** config_container); + static void UpdateTurboGeometry(CGeometry**** geometry, CInterface*** interface, CConfig** config_container, unsigned short iZone); - static void InitTurboVertexAdj(CGeometry**** geometry, CConfig** config); + static void InitTurboVertexAdj(CGeometry**** geometry, CConfig** config, unsigned short iZone); /*! * \brief Update the multi-grid structure for the customized boundary conditions diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 4b3c840d5852..d57492a892d1 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -6899,6 +6899,7 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) { case TOPOL_DISCRETENESS: cout << "Topology discreteness objective function." << endl; break; case TOPOL_COMPLIANCE: cout << "Topology compliance objective function." << endl; break; case STRESS_PENALTY: cout << "Stress penalty objective function." << endl; break; + case ENTROPY_GENERATION: cout << "Entropy generation objective function." << endl; break; } } else { diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index a0b02f04d4ed..032b282c1e94 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -33,6 +33,8 @@ #include "../../include/toolboxes/geometry_toolbox.hpp" #include "../../include/toolboxes/ndflattener.hpp" +#include "../../../SU2_CFD/include/interfaces/CInterface.hpp" + CGeometry::CGeometry() : size(SU2_MPI::GetSize()), rank(SU2_MPI::GetRank()) {} CGeometry::~CGeometry() { @@ -2360,60 +2362,50 @@ void CGeometry::UpdateGeometry(CGeometry** geometry_container, CConfig* config) geometry_container[MESH_0]->ComputeSurfaceAreaCfgFile(config); } -void CGeometry::InitTurboVertexAdj(CGeometry**** geometry, CConfig** config){ +void CGeometry::InitTurboVertexAdj(CGeometry**** geometry, CConfig** config, unsigned short iZone){ auto nSpanMax = 0u; auto nZone = config[ZONE_0]->GetnZone(); /*--- Create turbovertex ---*/ - for (auto iZone = 0u; iZone < nZone; iZone++){ - geometry[iZone][INST_0][MESH_0]->ComputeNSpan(config[iZone], iZone, INFLOW, true); - geometry[iZone][INST_0][MESH_0]->ComputeNSpan(config[iZone], iZone, OUTFLOW, true); - if (config[iZone]->GetnSpanWiseSections() > nSpanMax){ - nSpanMax = config[iZone]->GetnSpanWiseSections(); - } + geometry[iZone][INST_0][MESH_0]->ComputeNSpan(config[iZone], iZone, INFLOW, true); + geometry[iZone][INST_0][MESH_0]->ComputeNSpan(config[iZone], iZone, OUTFLOW, true); + if (config[iZone]->GetnSpanWiseSections() > nSpanMax){ + nSpanMax = config[iZone]->GetnSpanWiseSections(); + } - config[nZone-1]->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); - } + geometry[iZone][INST_0][MESH_0]->SetTurboVertex(config[iZone], iZone, INFLOW, true); + geometry[iZone][INST_0][MESH_0]->SetTurboVertex(config[iZone], iZone, OUTFLOW, true); /*--- Set max span in all zones ---*/ - for (auto iZone = 0u; iZone < nZone; iZone++){ - if (config[iZone]->GetBoolTurbomachinery()) { - config[iZone]->SetnSpanMaxAllZones(nSpanMax); - } + if (config[iZone]->GetBoolTurbomachinery()) { + config[iZone]->SetnSpanMaxAllZones(nSpanMax); } } -void CGeometry::UpdateTurboGeometry(CGeometry**** geometry, CInterface*** interface, CConfig** config){ +void CGeometry::UpdateTurboGeometry(CGeometry**** geometry, CInterface*** interface, CConfig** config, unsigned short iZone){ auto nZone = config[ZONE_0]->GetnZone(); - for (auto iZone = 0u; iZone < nZone; iZone++) { - geometry[iZone][INST_0][MESH_0]->SetAvgTurboValue(config[iZone], iZone, INFLOW, true); - geometry[iZone][INST_0][MESH_0]->SetAvgTurboValue(config[iZone],iZone, OUTFLOW, true); - geometry[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config[iZone], true); - } + geometry[iZone][INST_0][MESH_0]->SetAvgTurboValue(config[iZone], iZone, INFLOW, true); + geometry[iZone][INST_0][MESH_0]->SetAvgTurboValue(config[iZone],iZone, OUTFLOW, true); + geometry[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config[iZone], true); - if(config[ZONE_0]->GetBoolMixingPlaneInterface()){ - for (auto donorZone = 0u; donorZone < nZone; donorZone++) { - for (auto targetZone = 0u; targetZone < nZone; targetZone++) { - if (interface[donorZone][targetZone] != nullptr){ - interface[donorZone][targetZone]->SetSpanWiseLevels(config[donorZone], config[targetZone]); - } - } - } - } + // if(config[ZONE_0]->GetBoolMixingPlaneInterface()){ + // for (auto donorZone = 0u; donorZone < nZone; donorZone++) { + // for (auto targetZone = 0u; targetZone < nZone; targetZone++) { + // if (interface[donorZone][targetZone] != nullptr){ + // interface[iZone][targetZone]->SetSpanWiseLevels(config[donorZone], config[targetZone]); + // } + // } + // } + // } - for (auto iZone = 0u; iZone < nZone-1; iZone++) { - geometry[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config[iZone],geometry[iZone][INST_0][MESH_0], 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---*/ - for (auto iZone = 1u; iZone < nZone; iZone++) { - auto nBlades = config[iZone]->GetnBlades(iZone); - config[ZONE_0]->SetnBlades(iZone, nBlades); - } + auto nBlades = config[iZone]->GetnBlades(iZone); + config[ZONE_0]->SetnBlades(iZone, nBlades); } void CGeometry::SetCustomBoundary(CConfig* config) { diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index 7162e5ded8d3..f5c3156d8c2b 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -50,6 +50,8 @@ #include "../../include/geometry/primal_grid/CPrism.hpp" #include "../../include/geometry/primal_grid/CVertexMPI.hpp" +#include "../../../Common/include/tracy_structure.hpp" + #include #include #include @@ -6326,6 +6328,8 @@ void CPhysicalGeometry::GatherInOutAverageValues(CConfig* config, bool allocate) void CPhysicalGeometry::SetAvgTurboGeoValues(const CConfig* donor_config, CGeometry* donor_geometry, unsigned short donorZone) { + + SU2_ZONE_SCOPED_N("SetAvgTurboGeoValues"); unsigned short iSpan; unsigned short nSpanMaxAllZones = donor_config->GetnSpanMaxAllZones(); diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 96b29e75b2dd..8a39fcb8532b 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -79,6 +79,8 @@ class CDriver : public CDriverBase { CInterface*** interface_container; /*!< \brief Definition of the interface of information and physics. */ bool dry_run; /*!< \brief Flag if SU2_CFD was started as dry-run via "SU2_CFD -d .cfg" */ + //std::shared_ptr TurbomachineryStagePerformance; /*!< \brief turbo stage performance calculator. */ + public: /*! * \brief Constructor of the class. @@ -198,13 +200,11 @@ class CDriver : public CDriverBase { * \param[in] config - Definition of the particular problem. * \param[in] solver - Container vector with all the solutions. * \param[in] geometry - Geometrical definition of the problem. - * \param[in] interface_types - Type of coupling between the distinct (physical) zones. * \param[in] interface - Class defining the physical transfer of information. * \param[in] interpolation - Object defining the interpolation. */ void InitializeInterface(CConfig** config, CSolver***** solver, CGeometry**** geometry, - unsigned short** interface_types, CInterface*** interface, - vector>>& interpolation); + CInterface*** interface, vector>>& interpolation); /*! * \brief Definition and allocation of all solver classes. @@ -284,23 +284,22 @@ class CDriver : public CDriverBase { */ void PreprocessStaticMesh(const CConfig* config, CGeometry** geometry); + /*! + * \brief Initiate value for static mesh movement such as the gridVel for the ROTATING frame. + */ + void InitStaticMeshMovement(unsigned short iZone, bool print); + /*! * \brief Initiate value for static mesh movement such as the gridVel for the ROTATING frame. * \param[in] config - Definition of the particular problem. * \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] iteration - Class defining the iteration strcuture. * \param[in] dummy - Definition of dummy driver */ void PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, CSolver***** solver, - CInterface*** interface, bool dummy); - - /*! - * \brief Ramp some simulation settings for turbomachinery problems. - * \param[in] iter - Iteration for the ramp (can be outer or time depending on type of simulation). - * \note TODO This is not compatible with inner iterations because they are delegated to the iteration class. - */ - void RampTurbomachineryValues(unsigned long iter); + CInterface*** interface, CIteration*** iteration, bool dummy); /*! * \brief A virtual member. diff --git a/SU2_CFD/include/drivers/CDriverBase.hpp b/SU2_CFD/include/drivers/CDriverBase.hpp index b5dc5b6d30e1..cf5604688949 100644 --- a/SU2_CFD/include/drivers/CDriverBase.hpp +++ b/SU2_CFD/include/drivers/CDriverBase.hpp @@ -60,8 +60,7 @@ class CDriverBase { nZone, /*!< \brief Total number of zones in the problem. */ nDim, /*!< \brief Number of dimensions. */ iInst, /*!< \brief Iterator on instance levels. */ - *nInst, /*!< \brief Total number of instances in the problem (per zone). */ - **interface_types; /*!< \brief Type of coupling between the distinct (physical) zones. */ + *nInst; /*!< \brief Total number of instances in the problem (per zone). */ CConfig* driver_config = nullptr; /*!< \brief Definition of the driver configuration. */ COutput* driver_output = nullptr; /*!< \brief Definition of the driver output. */ diff --git a/SU2_CFD/include/drivers/CMultizoneDriver.hpp b/SU2_CFD/include/drivers/CMultizoneDriver.hpp index c5f72f98ce04..c5ee4b253758 100644 --- a/SU2_CFD/include/drivers/CMultizoneDriver.hpp +++ b/SU2_CFD/include/drivers/CMultizoneDriver.hpp @@ -83,15 +83,6 @@ class CMultizoneDriver : public CDriver { */ bool TransferData(unsigned short donorZone, unsigned short targetZone); - - /*! - * \brief Transfer the local turboperfomance quantities (for each blade row) from all the donorZones to the - * targetZone (ZONE_0). - * \note IMPORTANT: This approach of multi-zone performances rely upon the fact that turbomachinery markers follow - * the natural (stator-rotor) development of the real machine. - */ - void SetTurboPerformance(); - /*! * \brief Check the convergence at the outer level. */ diff --git a/SU2_CFD/include/integration/CMultiGridIntegration.hpp b/SU2_CFD/include/integration/CMultiGridIntegration.hpp index a29dc8f2c06c..36134e3b4c51 100644 --- a/SU2_CFD/include/integration/CMultiGridIntegration.hpp +++ b/SU2_CFD/include/integration/CMultiGridIntegration.hpp @@ -119,7 +119,7 @@ class CMultiGridIntegration final : public CIntegration { */ void NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, CNumerics ****numerics_container, CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, - su2double *monitor); + su2double *monitor, unsigned short iZone); /*! * \brief Compute the fine solution from a coarse solution. diff --git a/SU2_CFD/include/interfaces/CInterface.hpp b/SU2_CFD/include/interfaces/CInterface.hpp index 3d911f0dd010..e10dac5ffd6e 100644 --- a/SU2_CFD/include/interfaces/CInterface.hpp +++ b/SU2_CFD/include/interfaces/CInterface.hpp @@ -65,6 +65,8 @@ class CInterface { su2double *Target_Variable = nullptr; bool valAggregated = false; + unsigned short InterfaceType; /*!< \brief The type of interface. */ + /*--- Mixing Plane interface variable ---*/ su2double *SpanValueCoeffTarget = nullptr; unsigned short *SpanLevelDonor = nullptr; @@ -224,4 +226,15 @@ class CInterface { * \param[in] val_contact_resistance - Contact resistance value in m^2/W */ inline virtual void SetContactResistance(su2double val_contact_resistance) {}; + + /*! + * \brief Set the type of an interface + * \param[in] interface_type - The type of interface + */ + void SetInterfaceType(unsigned short interface_type) { InterfaceType = interface_type; } + + /*! + * \brief Get the type of an interface + */ + unsigned short GetInterfaceType(void) const { return InterfaceType; } }; diff --git a/SU2_CFD/include/iteration/CIteration.hpp b/SU2_CFD/include/iteration/CIteration.hpp index 45d9bfc2ba1e..6ee587c13710 100644 --- a/SU2_CFD/include/iteration/CIteration.hpp +++ b/SU2_CFD/include/iteration/CIteration.hpp @@ -60,9 +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. */ +// std::shared_ptr TurbomachineryPerformance; /*!< \brief turbo performance calculator. */ std::shared_ptr TurbomachineryStagePerformance; /*!< \brief turbo stage performance calculator. */ - + //std::vector> TurbomachineryBladePerformances; /*!< \brief Vector of turboperformances */ public: /*! * \brief Constructor of the class. @@ -299,6 +299,9 @@ class CIteration { virtual void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, unsigned short iZone, unsigned short iInst) {} + + // void ComputeTurboBladePerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned short iBlade); + /*! * \brief Computes turboperformance. */ @@ -307,5 +310,15 @@ class CIteration { /*! * \brief Initialises turboperformance classes. */ - void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid); + void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid, unsigned short val_iZone); + + inline vector> GetBladesPerformanceVector(CSolver***** solver, unsigned short nBladeRow){ + vector> bladePerformances; + bladePerformances.reserve(nBladeRow); + for (auto iBladeRow = 0u; iBladeRow < nBladeRow; iBladeRow++) { + auto const turboPerf = solver[iBladeRow][INST_0][MESH_0][FLOW_SOL]->GetTurboBladePerformance(); + bladePerformances.push_back(turboPerf); + } + return bladePerformances; + } }; diff --git a/SU2_CFD/include/output/CFlowCompOutput.hpp b/SU2_CFD/include/output/CFlowCompOutput.hpp index 832dd7704031..116211ff8461 100644 --- a/SU2_CFD/include/output/CFlowCompOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompOutput.hpp @@ -53,6 +53,8 @@ class CFlowCompOutput final: public CFlowOutput { */ void LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver) override; + void LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short iZone); + /*! * \brief Set the available volume output fields * \param[in] config - Definition of the particular problem. @@ -103,7 +105,7 @@ class CFlowCompOutput final: public CFlowOutput { * \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 SetTurboPerformance_Output(std::vector> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) override; /*! * \brief Sets the multizone turboperformacne screen output @@ -111,7 +113,7 @@ class CFlowCompOutput final: public CFlowOutput { * \param[in] TurboPerf - Turboperformance class * \param[in] config - Definition of the particular problem */ - void SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) override; + void SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, std::vector> TurboBladePerfs, CConfig *config) override; /*! * \brief Loads the turboperformacne history data @@ -119,7 +121,7 @@ class CFlowCompOutput final: public CFlowOutput { * \param[in] TurboPerf - Turboperformance class * \param[in] config - Definition of the particular problem */ - void LoadTurboHistoryData(std::shared_ptr TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) override; + void LoadTurboHistoryData(std::shared_ptr TurboStagePerf, std::vector> TurboBladePerfs, CConfig *config) override; /*! * \brief Write the kinematic and thermodynamic variables at each spanwise division @@ -128,6 +130,6 @@ class CFlowCompOutput final: public CFlowOutput { * \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, + void WriteTurboSpanwisePerformance(std::vector> TurboBladePerfs, 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 81d4f77cb461..e46b601fe7ff 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -406,7 +406,7 @@ class COutput { */ void SetHistoryOutput(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, std::shared_ptr TurboStagePerf, - std::shared_ptr TurboPerf, unsigned short val_iZone, + std::vector> TurboBladePerfs, unsigned short val_iZone, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iInst); /*! @@ -977,7 +977,7 @@ class COutput { * \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::vector> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) {} /*! * \brief Sets the multizone turboperformacne screen output @@ -985,7 +985,7 @@ class COutput { * \param[in] TurboPerf - Turboperformance class * \param[in] config - Definition of the particular problem */ - inline virtual void SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) {} + inline virtual void SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, std::vector> TurboPerf, CConfig *config) {} /*! * \brief Loads the turboperformacne history data @@ -993,7 +993,7 @@ class COutput { * \param[in] TurboPerf - Turboperformance class * \param[in] config - Definition of the particular problem */ - inline virtual void LoadTurboHistoryData(std::shared_ptr TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) {} + inline virtual void LoadTurboHistoryData(std::shared_ptr TurboStagePerf, std::vector> TurboPerf, CConfig *config) {} /*! * \brief Write the kinematic and thermodynamic variables at each spanwise division @@ -1002,7 +1002,7 @@ class COutput { * \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, + inline virtual void WriteTurboSpanwisePerformance(std::vector> TurboBladePerfs, CGeometry *geometry, CConfig **config, unsigned short val_iZone) {}; /*! diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp index 838e714c80cf..6b7e35bb83b5 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -252,16 +252,16 @@ class CTurbomachineryStagePerformance { */ class CTurboOutput { private: - vector>> BladesPerformances; + vector> BladesPerformances; static void ComputePerBlade(vector> const bladePerformances, vector const bladePrimitives); static void ComputePerSpan(shared_ptr const spanPerformances, const CTurbomachineryCombinedPrimitiveStates& spanPrimitives); public: - CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel); + CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel, unsigned short iBladeRow); - const vector>>& GetBladesPerformances() const { return BladesPerformances; } + const vector>& GetBladesPerformances() const { return BladesPerformances; } - void ComputeTurbomachineryPerformance(vector> const primitives); + void ComputeTurbomachineryPerformance(vector const primitives, unsigned short iBladeRow); }; \ No newline at end of file diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 280524cee94a..0d5b28a651e5 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 "../output/CTurboOutput.hpp" /*! * \class CEulerSolver @@ -155,9 +156,9 @@ class CEulerSolver : public CFVMFlowSolverBase > > CkInflow, CkOutflow1, CkOutflow2; - vector EntropyGeneration; - vector TotalPressureLoss; - vector KineticEnergyLoss; + su2double EntropyGeneration; + su2double TotalPressureLoss; + su2double KineticEnergyLoss; /*--- End of Turbomachinery Solver Variables ---*/ @@ -1041,7 +1042,7 @@ class CEulerSolver : public CFVMFlowSolverBase GetTurboBladePerformance() const final { return TurbomachineryPerformance; } + /*! * \brief it take a velocity in the cartesian reference of framework and transform into the turbomachinery frame of reference. * \param[in] cartesianVelocity - cartesian components of velocity vector. diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 75b8f12b9914..d2cf24b457cc 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -57,6 +57,8 @@ #include "../../../Common/include/toolboxes/MMS/CVerificationSolution.hpp" #include "../variables/CVariable.hpp" +#include "../output/CTurboOutput.hpp" + #ifdef HAVE_LIBROM #include "librom.h" #endif @@ -149,6 +151,8 @@ class CSolver { vector VertexTraction; /*- Temporary, this will be moved to a new postprocessing structure once in place -*/ vector VertexTractionAdjoint; /*- Also temporary -*/ + std::shared_ptr TurbomachineryPerformance; /*!< \brief turbo performance calculator. */ + string SolverName; /*!< \brief Store the name of the solver for output purposes. */ /*! @@ -1089,10 +1093,12 @@ class CSolver { CConfig *config, unsigned short val_marker) { } - inline virtual void SetTurboObjectiveFunction(short unsigned int ObjFunc, int bladeRow, su2double val) { } + inline virtual void SetTurboObjectiveFunction(short unsigned int ObjFunc, su2double val) { } inline virtual su2double GetTurboObjectiveFunction(short unsigned int ObjFunc, int bladeRow) const { return 0.0; } + inline virtual std::shared_ptr GetTurboBladePerformance() const { return std::shared_ptr(nullptr); } + /*! * \brief A virtual member. * \param[in] geometry - Geometrical definition of the problem. @@ -3763,7 +3769,7 @@ class CSolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - inline virtual void InitTurboContainers(CGeometry *geometry, CConfig *config) { } + inline virtual void InitTurboContainers(CGeometry *geometry, CConfig **config, unsigned short iZone) { } /*! * \brief Get Primal variables for turbo performance computation @@ -3803,6 +3809,8 @@ class CSolver { */ inline virtual void GatherInOutAverageValues(CConfig *config, CGeometry *geometry) { } + inline virtual void ComputeTurboBladePerformance(CGeometry* geometry, CConfig* config, unsigned short iBlade) { }; + /*! * \brief A virtual member. * \param[in] val_marker - bound marker. diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 3e7c313dc317..2bbeddecf647 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -31,6 +31,8 @@ #include "../../include/output/COutput.hpp" #include "../../include/iteration/CIterationFactory.hpp" +#include "../../../Common/include/tracy_structure.hpp" + CDiscAdjMultizoneDriver::CDiscAdjMultizoneDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunicator) @@ -685,6 +687,8 @@ void CDiscAdjMultizoneDriver::EvaluateSensitivities(unsigned long Iter, bool for void CDiscAdjMultizoneDriver::SetRecording(RECORDING kind_recording, Kind_Tape tape_type, unsigned short record_zone) { + SU2_ZONE_SCOPED_N("SetRecording_driver"); + AD::Reset(); /*--- Prepare for recording by resetting the solution to the initial converged solution. ---*/ @@ -801,6 +805,12 @@ void CDiscAdjMultizoneDriver::SetRecording(RECORDING kind_recording, Kind_Tape t void CDiscAdjMultizoneDriver::DirectIteration(unsigned short iZone, RECORDING kind_recording) { + SU2_ZONE_SCOPED_N("DirectIteration"); + + // if (config_container[iZone]->GetBoolTurbomachinery()) { + // InitStaticMeshMovement(iZone, false); + // } + /*--- Do one iteration of the direct solver ---*/ direct_iteration[iZone][INST_0]->Preprocess(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, @@ -811,8 +821,8 @@ void CDiscAdjMultizoneDriver::DirectIteration(unsigned short iZone, RECORDING ki solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0); - // /*--- Turbo Specific Post-Procesisng ---*/ - // if (config_container[iZone]->GetBoolTurbomachinery()){ + /*--- Turbo Specific Post-Procesisng ---*/ + // if (config_container[iZone]->GetBoolTurbomachinery()){ // direct_iteration[iZone][INST_0]->Postprocess(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0); // } @@ -843,6 +853,19 @@ void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) { solvers[HEAT_SOL]->Heat_Fluxes(geometry, solvers, config); } + if(config->GetBoolTurbomachinery()){ + solvers[FLOW_SOL]->TurboAverageProcess(solvers, geometry, config, INFLOW); + solvers[FLOW_SOL]->TurboAverageProcess(solvers, geometry, config, OUTFLOW); + + /*--- Gather Inflow and Outflow quantities on the Master Node to compute performance ---*/ + + solvers[FLOW_SOL]->GatherInOutAverageValues(config, geometry); + + /*--- Compute the turboperformance ---*/ + + solvers[FLOW_SOL]->ComputeTurboBladePerformance(geometry, config, iZone); + } + direct_output[iZone]->SetHistoryOutput(geometry, solvers, config); ObjFunc += solvers[FLOW_SOL]->GetTotal_ComboObj(); break; @@ -969,6 +992,8 @@ void CDiscAdjMultizoneDriver::InitializeCrossTerms() { void CDiscAdjMultizoneDriver::HandleDataTransfer() { + SU2_ZONE_SCOPED_N("HandleDataTransfer"); + for(iZone = 0; iZone < nZone; iZone++) { /*--- In principle, the mesh does not need to be updated ---*/ diff --git a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp index fd8799af34a3..7a3f8ea8d8aa 100644 --- a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp @@ -33,6 +33,8 @@ #include "../../include/iteration/CTurboIteration.hpp" #include "../../../Common/include/toolboxes/CQuasiNewtonInvLeastSquares.hpp" +#include "../../../Common/include/tracy_structure.hpp" + CDiscAdjSinglezoneDriver::CDiscAdjSinglezoneDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunicator) : CSinglezoneDriver(confFile, @@ -247,6 +249,8 @@ void CDiscAdjSinglezoneDriver::Postprocess() { void CDiscAdjSinglezoneDriver::SetRecording(RECORDING kind_recording){ + SU2_ZONE_SCOPED_N("SetRecording_SingleZoneDriver"); + AD::Reset(); /*--- Prepare for recording by resetting the solution to the initial converged solution. ---*/ diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 9df834e28561..29ec4e53af7f 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -233,7 +233,7 @@ CDriverBase(confFile, val_nZone, MPICommunicator), StopCalc(false), fsi(false), cout << endl <<"------------------- Multizone Interface Preprocessing -------------------" << endl; InitializeInterface(config_container, solver_container, geometry_container, - interface_types, interface_container, interpolator_container); + interface_container, interpolator_container); } if (fsi) { @@ -249,7 +249,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, dummy_geo); + PreprocessTurbomachinery(config_container, geometry_container, solver_container, interface_container, iteration_container, dummy_geo); } else { mixingplane = false; } @@ -314,7 +314,6 @@ void CDriver::InitializeContainers(){ grid_movement = nullptr; FFDBox = nullptr; interface_container = nullptr; - interface_types = nullptr; nInst = nullptr; /*--- Definition and of the containers for all possible zones. ---*/ @@ -330,16 +329,12 @@ void CDriver::InitializeContainers(){ FFDBox = new CFreeFormDefBox**[nZone] (); interpolator_container.resize(nZone); interface_container = new CInterface**[nZone] (); - interface_types = new unsigned short*[nZone] (); output_container = new COutput*[nZone] (); nInst = new unsigned short[nZone] (); driver_config = nullptr; driver_output = nullptr; - for (iZone = 0; iZone < nZone; iZone++) { - interface_types[iZone] = new unsigned short[nZone]; - nInst[iZone] = 1; - } + for (iZone = 0; iZone < nZone; iZone++) nInst[iZone] = 1; } @@ -417,12 +412,6 @@ void CDriver::Finalize() { if (rank == MASTER_NODE) cout << "Deleted CInterface container." << endl; } - if (interface_types != nullptr) { - for (iZone = 0; iZone < nZone; iZone++) - delete [] interface_types[iZone]; - delete [] interface_types; - } - for (iZone = 0; iZone < nZone; iZone++) { if (geometry_container[iZone] != nullptr) { for (iInst = 0; iInst < nInst[iZone]; iInst++){ @@ -1293,7 +1282,7 @@ void CDriver::InstantiateTurbulentNumerics(unsigned short nVar_Turb, int offset, } else if (menter_sst) { numerics[iMGlevel][TURB_SOL][conv_bound_term] = new CUpwSca_TurbSST(nDim, nVar_Turb, config); - numerics[iMGlevel][TURB_SOL][visc_bound_term] = new CAvgGrad_TurbSST(nDim, nVar_Turb, constants, false, + numerics[iMGlevel][TURB_SOL][visc_bound_term] = new CAvgGrad_TurbSST(nDim, nVar_Turb, constants, true, config); } } @@ -2408,8 +2397,7 @@ void CDriver::PreprocessDynamicMesh(CConfig *config, CGeometry **geometry, CSolv } -void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeometry**** geometry, - unsigned short** interface_types, CInterface ***interface, +void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeometry**** geometry, CInterface ***interface, vector > >& interpolation) { /*--- Setup interpolation and transfer for all possible donor/target pairs. ---*/ @@ -2418,19 +2406,9 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet for (auto donor = 0u; donor < nZone; donor++) { - /*--- Aliases to make code less verbose. ---*/ - auto& interface_type = interface_types[donor][target]; - - if (donor == target) { - interface_type = ZONES_ARE_EQUAL; - continue; - } - interface_type = NO_TRANSFER; - /*--- If there is a common interface setup the interpolation and transfer. ---*/ - - if (!CInterpolator::CheckZonesInterface(config[donor], config[target])) { - interface_type = NO_COMMON_INTERFACE; + if (!CInterpolator::CheckZonesInterface(config[donor], config[target]) || donor == target) { + continue; } else { /*--- Begin the creation of the communication pattern among zones. ---*/ @@ -2457,7 +2435,7 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet if (rank == MASTER_NODE) cout << " Transferring "; if (fluid_donor && structural_target) { - interface_type = FLOW_TRACTION; + auto nConst = 2; bool conservative = config[target]->GetConservativeInterpolation(); if(!config[ZONE_0]->GetDiscrete_Adjoint()) { @@ -2472,7 +2450,6 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet SU2_MPI::Error("Mesh deformation was not correctly specified for the fluid/heat zone.\n" "Use DEFORM_MESH=YES, and setup MARKER_DEFORM_MESH=(...)", CURRENT_FUNCTION); } - interface_type = BOUNDARY_DISPLACEMENTS; if (!config[donor]->GetTime_Domain()) interface[donor][target] = new CDisplacementsInterface(nDim, 0); else interface[donor][target] = new CDisplacementsInterface(2*nDim, 0); if (rank == MASTER_NODE) cout << "boundary displacements from the structural solver." << endl; @@ -2483,7 +2460,6 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet auto interfaceIndex = donor+target; // Here we assume that the interfaces at each side are the same kind switch (config[donor]->GetKind_TurboInterface(interfaceIndex)) { case TURBO_INTERFACE_KIND::MIXING_PLANE: { - 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 << "using a mixing-plane interface from donor zone " << donor << " to target zone " << target << "." << endl; @@ -2491,7 +2467,6 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet } case TURBO_INTERFACE_KIND::FROZEN_ROTOR: { 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 << "using a fluid interface interface from donor zone " << donor << " to target zone " << target << "." << endl; } @@ -2499,30 +2474,31 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet } 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) { + unsigned short interface_type; if (heat_donor && heat_target){ - interface_type = CONJUGATE_HEAT_SS; + interface_type = ENUM_TRANSFER::CONJUGATE_HEAT_SS; } else { const auto fluidZone = heat_target? donor : target; if (config[fluidZone]->GetEnergy_Equation() || (config[fluidZone]->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE) || (config[fluidZone]->GetKind_FluidModel() == ENUM_FLUIDMODEL::FLUID_FLAMELET)) - interface_type = heat_target? CONJUGATE_HEAT_FS : CONJUGATE_HEAT_SF; + interface_type = heat_target? ENUM_TRANSFER::CONJUGATE_HEAT_FS : ENUM_TRANSFER::CONJUGATE_HEAT_SF; else if (config[fluidZone]->GetWeakly_Coupled_Heat()) - interface_type = heat_target? CONJUGATE_HEAT_WEAKLY_FS : CONJUGATE_HEAT_WEAKLY_SF; + interface_type = heat_target? ENUM_TRANSFER::CONJUGATE_HEAT_WEAKLY_FS : ENUM_TRANSFER::CONJUGATE_HEAT_WEAKLY_SF; else - interface_type = NO_TRANSFER; + interface_type = ENUM_TRANSFER::NO_TRANSFER; } if (interface_type != NO_TRANSFER) { auto nVar = 4; interface[donor][target] = new CConjugateHeatInterface(nVar, 0); + interface[donor][target]->SetInterfaceType(interface_type); if (rank == MASTER_NODE) cout << "conjugate heat variables." << endl; } else { @@ -2534,7 +2510,6 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet SU2_MPI::Error("Could not determine the number of variables for transfer.", CURRENT_FUNCTION); auto nVar = solver[donor][INST_0][MESH_0][FLOW_SOL]->GetnVar(); - interface_type = CONSERVATIVE_VARIABLES; interface[donor][target] = new CConservativeVarsInterface(nVar, 0); if (rank == MASTER_NODE) cout << "generic conservative variables." << endl; } @@ -2629,9 +2604,61 @@ void CDriver::PreprocessOutput(CConfig **config, CConfig *driver_config, COutput } +void CDriver::InitStaticMeshMovement(unsigned short iZone, bool print) { + unsigned short iMGlevel; + unsigned short Kind_Grid_Movement; + + int rank = MASTER_NODE; +#ifdef HAVE_MPI + MPI_Comm_rank(MPI_COMM_WORLD, &rank); +#endif + + Kind_Grid_Movement = config_container[iZone]->GetKind_GridMovement(); + + switch (Kind_Grid_Movement) { + + case ROTATING_FRAME: + + /*--- Steadily rotating frame: set the grid velocities just once + before the first iteration flow solver. ---*/ + + if (rank == MASTER_NODE && print) { + cout << endl << " Setting rotating frame grid velocities"; + cout << " for zone " << iZone << "." << endl; + } + + /*--- Set the grid velocities on all multigrid levels for a steadily + rotating reference frame. ---*/ + + for (iMGlevel = 0; iMGlevel <= config_container[ZONE_0]->GetnMGLevels(); iMGlevel++){ + geometry_container[iZone][INST_0][MESH_0]->SetRotationalVelocity(config_container[iZone], print); + geometry_container[iZone][INST_0][MESH_0]->SetShroudVelocity(config_container[iZone]); + } + + break; + + case STEADY_TRANSLATION: + + /*--- Set the translational velocity and hold the grid fixed during + the calculation (similar to rotating frame, but there is no extra + source term for translation). ---*/ + + if (rank == MASTER_NODE && print) + cout << endl << " Setting translational grid velocities." << endl; + + /*--- Set the translational velocity on all grid levels. ---*/ + + for (iMGlevel = 0; iMGlevel <= config_container[ZONE_0]->GetnMGLevels(); iMGlevel++) + geometry_container[iZone][INST_0][iMGlevel]->SetTranslationalVelocity(config_container[iZone], iMGlevel == 0); + + + + break; + } +} void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, CSolver***** solver, - CInterface*** interface, bool dummy){ + CInterface*** interface, CIteration*** iteration, bool dummy){ unsigned short donorZone,targetZone, nMarkerInt, iMarkerInt; unsigned short nSpanMax = 0; @@ -2666,12 +2693,6 @@ 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 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]); - } - // TODO(turbo): make it general for turbo HB if (rank == MASTER_NODE) cout<<"Compute inflow and outflow average geometric quantities." << endl; for (iZone = 0; iZone < nZone; iZone++) { @@ -2680,6 +2701,10 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, geometry[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config[iZone], true); } + 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); + } if(mixingplane){ if (rank == MASTER_NODE) cout << "Set span-wise sections between zones on Mixing-Plane interface." << endl; @@ -2720,7 +2745,8 @@ 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 (interface_types[donorZone][targetZone]==MIXING_PLANE){ + if (donorZone == targetZone) continue; + if (interface[donorZone][targetZone]->GetInterfaceType()==MIXING_PLANE){ interface[donorZone][targetZone]->PreprocessAverage(geometry[donorZone][INST_0][MESH_0], geometry[targetZone][INST_0][MESH_0], config[donorZone], config[targetZone], iMarkerInt); @@ -2757,6 +2783,7 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, } } + //TurbomachineryStagePerformance = std::make_shared(solver[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetFluidModel()); } CDriver::~CDriver() = default; diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index ea84c96a64bb..a8290759abda 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -30,6 +30,7 @@ #include "../../../Common/include/interface_interpolation/CInterpolator.hpp" #include "../../include/output/COutput.hpp" #include "../../include/iteration/CIteration.hpp" +#include "../../../Common/include/tracy_structure.hpp" CMultizoneDriver::CMultizoneDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunicator) : CDriver(confFile, val_nZone, MPICommunicator, false) { @@ -532,6 +533,8 @@ void CMultizoneDriver::DynamicMeshUpdate(unsigned short val_iZone, unsigned long bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short targetZone) { + SU2_ZONE_SCOPED_N("TransferData"); + bool UpdateMesh = false; /*--- Select the transfer method according to the magnitudes being transferred ---*/ @@ -547,7 +550,10 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar config_container[targetZone]); }; - switch (interface_types[donorZone][targetZone]) { + // Zones are equal or unconnected + if(donorZone == targetZone || interface_container[donorZone][targetZone] == nullptr) return UpdateMesh; + + switch (interface_container[donorZone][targetZone]->GetInterfaceType()) { case SLIDING_INTERFACE: BroadcastData(FLOW_SOL, FLOW_SOL); @@ -598,17 +604,15 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar } /*--- Set average value donorZone->targetZone ---*/ - interface_container[donorZone][targetZone]->SetAverageValues(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL],solver_container[targetZone][INST_0][MESH_0][FLOW_SOL], donorZone); - - /*--- Set average geometrical properties FROM donorZone IN targetZone ---*/ - geometry_container[targetZone][INST_0][MESH_0]->SetAvgTurboGeoValues(config_container[iZone],geometry_container[iZone][INST_0][MESH_0], iZone); + //interface_container[donorZone][targetZone]->SetAverageValues(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL],solver_container[targetZone][INST_0][MESH_0][FLOW_SOL], donorZone); + // /*--- Set average geometrical properties FROM donorZone IN targetZone ---*/ + // if (donorZone != nZone - 1){ + // geometry_container[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config_container[donorZone],geometry_container[donorZone][INST_0][MESH_0], donorZone); + // } + break; } - case NO_TRANSFER: - case ZONES_ARE_EQUAL: - case NO_COMMON_INTERFACE: - break; default: if(rank == MASTER_NODE) cout << "WARNING: One of the intended interface transfer routines is not " @@ -619,16 +623,6 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar return UpdateMesh; } - - -void CMultizoneDriver::SetTurboPerformance() { - for (auto donorZone = 1u; donorZone < nZone; donorZone++) { - interface_container[donorZone][ZONE_0]->SetAverageValues(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL], - solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL], - donorZone); - } -} - bool CMultizoneDriver::Monitor(unsigned long TimeIter) { /*--- Check whether the inner solver has converged --- */ diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index f0ffb95bae09..1f3056999c0d 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -85,7 +85,6 @@ void CIntegration::Space_Integration(CGeometry *geometry, if (config->GetBoolGiles() && config->GetSpatialFourier()){ solver_container[MainSolver]->PreprocessBC_Giles(geometry, config, conv_bound_numerics, INFLOW); - solver_container[MainSolver]->PreprocessBC_Giles(geometry, config, conv_bound_numerics, OUTFLOW); } @@ -196,7 +195,7 @@ void CIntegration::Space_Integration(CGeometry *geometry, else if (config->GetMarker_All_KindBC(iMarker)==EULER_WALL) solver_container[MainSolver]->BC_Euler_Wall(geometry, solver_container, conv_bound_numerics, visc_bound_numerics, config, iMarker); } - //AD::ResumePreaccumulation(pausePreacc); + // AD::ResumePreaccumulation(pausePreacc); } diff --git a/SU2_CFD/src/integration/CMultiGridIntegration.cpp b/SU2_CFD/src/integration/CMultiGridIntegration.cpp index 7f07b4447e37..55eb2b14ebeb 100644 --- a/SU2_CFD/src/integration/CMultiGridIntegration.cpp +++ b/SU2_CFD/src/integration/CMultiGridIntegration.cpp @@ -119,7 +119,7 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, NonDimensional_Parameters(geometry[iZone][iInst], solver_container[iZone][iInst], numerics_container[iZone][iInst], config[iZone], - FinestMesh, RunTime_EqSystem, &monitor); + FinestMesh, RunTime_EqSystem, &monitor, iZone); } END_SU2_OMP_PARALLEL @@ -656,7 +656,7 @@ void CMultiGridIntegration::SetRestricted_Gradient(unsigned short RunTime_EqSyst void CMultiGridIntegration::NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, CNumerics ****numerics_container, CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, - su2double *monitor) { + su2double *monitor, unsigned short iZone) { BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS switch (RunTime_EqSystem) { @@ -669,18 +669,22 @@ void CMultiGridIntegration::NonDimensional_Parameters(CGeometry **geometry, CSol solver_container[FinestMesh][FLOW_SOL]->Friction_Forces(geometry[FinestMesh], config); /*--- Calculate the turbo performance ---*/ - if (config->GetBoolTurbomachinery()){ + // if (config->GetBoolTurbomachinery()){ - /*--- Average quantities at the inflow and outflow boundaries ---*/ + // /*--- 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); + // 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 ---*/ + // /*--- Gather Inflow and Outflow quantities on the Master Node to compute performance ---*/ - solver_container[FinestMesh][FLOW_SOL]->GatherInOutAverageValues(config, geometry[FinestMesh]); + // solver_container[FinestMesh][FLOW_SOL]->GatherInOutAverageValues(config, geometry[FinestMesh]); - } + // /*--- Compute the turboperformance ---*/ + + // solver_container[FinestMesh][FLOW_SOL]->ComputeTurboBladePerformance(geometry[FinestMesh], config, iZone); + + // } break; diff --git a/SU2_CFD/src/interfaces/CInterface.cpp b/SU2_CFD/src/interfaces/CInterface.cpp index 969730850b06..a38e13d88dc0 100644 --- a/SU2_CFD/src/interfaces/CInterface.cpp +++ b/SU2_CFD/src/interfaces/CInterface.cpp @@ -30,6 +30,7 @@ #include "../../../Common/include/CConfig.hpp" #include "../../../Common/include/geometry/CGeometry.hpp" #include "../../include/solvers/CSolver.hpp" +#include "../../../Common/include/tracy_structure.hpp" CInterface::CInterface() : rank(SU2_MPI::GetRank()), @@ -204,6 +205,8 @@ void CInterface::PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_ const CConfig *donor_config, const CConfig *target_config, unsigned short iMarkerInt){ + SU2_ZONE_SCOPED_N("PreprocessAverage"); + unsigned short nMarkerDonor, nMarkerTarget; // Number of markers on the interface, donor and target side unsigned short iMarkerDonor, iMarkerTarget; // Variables for iteration over markers unsigned short iSpan,jSpan, tSpan = 0, kSpan = 0, nSpanDonor, nSpanTarget, Donor_Flag = 0, Target_Flag = 0; @@ -332,6 +335,8 @@ void CInterface::PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_ void CInterface::AllgatherAverage(CSolver *donor_solution, CSolver *target_solution, CGeometry *donor_geometry, CGeometry *target_geometry, const CConfig *donor_config, const CConfig *target_config, unsigned short iMarkerInt){ + + SU2_ZONE_SCOPED_N("AllgatherAverage"); unsigned short nMarkerDonor, nMarkerTarget; // Number of markers on the interface, donor and target side unsigned short iMarkerDonor, iMarkerTarget; // Variables for iteration over markers diff --git a/SU2_CFD/src/interfaces/cfd/CConservativeVarsInterface.cpp b/SU2_CFD/src/interfaces/cfd/CConservativeVarsInterface.cpp index 8784b5220b70..9a39d9314cdd 100644 --- a/SU2_CFD/src/interfaces/cfd/CConservativeVarsInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CConservativeVarsInterface.cpp @@ -33,6 +33,7 @@ CConservativeVarsInterface::CConservativeVarsInterface(unsigned short val_nVar, unsigned short val_nConst) : CInterface(val_nVar, val_nConst) { + InterfaceType = ENUM_TRANSFER::CONSERVATIVE_VARIABLES; } void CConservativeVarsInterface::GetDonor_Variable(CSolver *donor_solution, CGeometry *donor_geometry, diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 5b4528bf1d12..bee108d7f8a2 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -30,11 +30,13 @@ #include "../../../../Common/include/CConfig.hpp" #include "../../../../Common/include/geometry/CGeometry.hpp" #include "../../../include/solvers/CSolver.hpp" +#include "../../../Common/include/tracy_structure.hpp" CMixingPlaneInterface::CMixingPlaneInterface(unsigned short val_nVar, unsigned short val_nConst){ nVar = val_nVar; Donor_Variable = new su2double[nVar + 5](); Target_Variable = new su2double[nVar + 5](); + InterfaceType = ENUM_TRANSFER::MIXING_PLANE; } void CMixingPlaneInterface::SetSpanWiseLevels(const CConfig *donor_config, const CConfig *target_config){ @@ -115,6 +117,9 @@ void CMixingPlaneInterface::SetTarget_Variable(CSolver *target_solution, CGeomet void CMixingPlaneInterface::SetAverageValues(CSolver *donor_solution, CSolver *target_solution, unsigned short donorZone){ + + SU2_ZONE_SCOPED_N("SetAverageValues"); + unsigned short iSpan; for(iSpan = 0; iSpanCompleteComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); } if (config[iZone]->GetBoolTurbomachinery()) { - if (iZone == ZONE_0){ - // Defines geometric dependency in turbo simulations, this is done in ZONE_0 as it requires a loop over all zones first - // This step is very similar to the turbo preprocessing in CDriver but it is not recorded to the tape their, hence repeated here - // Do this in two parts as solver step is necessary in the middle - // for (auto jZone = 0u; jZone < nZone; jZone++){ - // SU2_OMP_PARALLEL - // CGeometry::UpdateGeometry(geometry[jZone][iInst], config[jZone]); - // END_SU2_OMP_PARALLEL - - // CGeometry::ComputeWallDistance(config, geometry); - // } - geometry[iZone][MESH_0][INST_0]->InitTurboVertexAdj(geometry, config); - for (auto jZone = 0u; jZone < nZone; jZone++) { - solver[jZone][INST_0][MESH_0][FLOW_SOL]->InitTurboContainers(geometry[jZone][INST_0][MESH_0],config[jZone]); - } - geometry[iZone][MESH_0][INST_0]->UpdateTurboGeometry(geometry, interface, config); - } + // if ((config_container[iZone]->GetGrid_Movement())) { + // iteration_container[iZone][INST_0]->SetGrid_Movement(geometry_container[iZone][INST_0],surface_movement[iZone], + // grid_movement[iZone][INST_0], solver_container[iZone][INST_0], + // config_container[iZone], 0, TimeIter); + // } + // if (iZone == ZONE_0){ + // geometry[iZone][MESH_0][INST_0]->InitTurboVertexAdj(geometry, config, iZone); + // geometry[iZone][MESH_0][INST_0]->UpdateTurboGeometry(geometry, interface, config, iZone); + // for (auto donorZone = 0; donorZone < nZone; donorZone++) { + // auto nMarkerInt = config[donorZone]->GetnMarker_MixingPlaneInterface()/2; + // for (auto iMarkerInt = 1; iMarkerInt <= nMarkerInt; iMarkerInt++){ + // for (auto targetZone = 0; targetZone < nZone; targetZone++) { + // if (donorZone == targetZone || interface[donorZone][targetZone] == nullptr) continue; + // if (interface[donorZone][targetZone]->GetInterfaceType() == MIXING_PLANE){ + // interface[donorZone][targetZone]->PreprocessAverage(geometry[donorZone][INST_0][MESH_0], geometry[targetZone][INST_0][MESH_0], + // config[donorZone], config[targetZone], + // iMarkerInt); + // } + // } + // } + // } + // } + //solver[iZone][INST_0][MESH_0][FLOW_SOL]->InitTurboContainers(geometry[iZone][INST_0][MESH_0],config, iZone); + solvers0[FLOW_SOL]->PreprocessAverage(solvers0, geometry0, config[iZone], INFLOW); + solvers0[FLOW_SOL]->PreprocessAverage(solvers0, geometry0, config[iZone], OUTFLOW); + // solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], INFLOW); + // solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], OUTFLOW); if (config[iZone]->GetBoolGiles() && config[iZone]->GetSpatialFourier()){ auto conv_bound_numerics = numerics[iZone][iInst][MESH_0][FLOW_SOL][CONV_BOUND_TERM + omp_get_thread_num()*MAX_TERMS]; solvers0[FLOW_SOL]->PreprocessBC_Giles(geometry0, config[iZone], conv_bound_numerics, INFLOW); solvers0[FLOW_SOL]->PreprocessBC_Giles(geometry0, config[iZone], conv_bound_numerics, OUTFLOW); } - solvers0[FLOW_SOL]->PreprocessAverage(solvers0, geometry0, config[iZone], INFLOW); - solvers0[FLOW_SOL]->PreprocessAverage(solvers0, geometry0, config[iZone], OUTFLOW); - solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], INFLOW); - solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], OUTFLOW); - InitTurboPerformance(geometry0, config, solvers0[FLOW_SOL]->GetFluidModel()); - solvers0[FLOW_SOL]->GatherInOutAverageValues(config[iZone], geometry0); - if (iZone == nZone-1) ComputeTurboPerformance(solver, geometry, config); + // solvers0[FLOW_SOL]->GatherInOutAverageValues(config[iZone], geometry0); + // solvers0[FLOW_SOL]->ComputeTurboBladePerformance(geometry0, config[iZone], iZone); } if (config[iZone]->GetKind_Species_Model() != SPECIES_MODEL::NONE) { solvers0[SPECIES_SOL]->Preprocessing(geometry0, solvers0, config[iZone], MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS, true); diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index e72a1f4eff88..286482380fb1 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -224,16 +224,12 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe /*--- Turbomachinery Specific Montior ---*/ - if (config[ZONE_0]->GetBoolTurbomachinery()){ - if (val_iZone == config[ZONE_0]->GetnZone()-1) { - ComputeTurboPerformance(solver, geometry, config); - - output->SetHistoryOutput(geometry, solver, - config, TurbomachineryStagePerformance, TurbomachineryPerformance, val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), - config[val_iZone]->GetInnerIter(), val_iInst); - } - - TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone); + if (config[ZONE_0]->GetBoolTurbomachinery() && val_iZone == config[val_iZone]->GetnZone()-1){ + if (rank == MASTER_NODE) ComputeTurboPerformance(solver, geometry, config); + auto TurbomachineryBladePerformances = GetBladesPerformanceVector(solver, config[val_iZone]->GetnZone()); + output->SetHistoryOutput(geometry, solver, config, TurbomachineryStagePerformance, TurbomachineryBladePerformances, + val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), + config[val_iZone]->GetInnerIter(), val_iInst); } 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(), @@ -322,38 +318,38 @@ void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** c } } -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); - - auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); - 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]); - } -} +// void CFluidIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container) { +// 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); + +// auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); +// 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]); +// } +// } void CFluidIteration::Postprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, diff --git a/SU2_CFD/src/iteration/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index 8ec100da5a81..b2aec96a2dd9 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -210,55 +210,61 @@ void CIteration::Output(COutput* output, CGeometry**** geometry, CSolver***** so InnerIter); } -void CIteration::InitTurboPerformance(CGeometry* geometry, CConfig** config, CFluidModel* fluid) { - TurbomachineryPerformance = std::make_shared(config, *geometry, *fluid); +void CIteration::InitTurboPerformance(CGeometry* geometry, CConfig** config, CFluidModel* fluid, unsigned short val_iZone) { + //TurbomachineryPerformance = std::make_shared(config, *geometry, *fluid, val_iZone); TurbomachineryStagePerformance = std::make_shared(*fluid); + //TurbomachineryBladePerformances = std::make_shared>>(); } +// void CIteration::ComputeTurboBladePerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned short iBlade) { +// // Computes the turboperformance per blade in zone iBlade +// const auto nDim = geometry_container[ZONE_0][INST_0][MESH_0]->GetnDim(); +// const auto nBladesRow = config_container[ZONE_0]->GetnMarker_Turbomachinery(); +// const auto nZone = config_container[ZONE_0]->GetnZone(); +// vector TurboPrimitiveIn, TurboPrimitiveOut; +// if (rank == MASTER_NODE) { +// /* Blade Primitive initialized per blade */ +// std::vector bladePrimitives; +// auto nSpan = config_container[iBlade]->GetnSpanWiseSections(); +// for (auto 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); +// } +// TurbomachineryPerformance->ComputeTurbomachineryPerformance(bladePrimitives, iBlade); +// solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboBladePerformance(TurbomachineryPerformance); + +// auto BladePerf = TurbomachineryPerformance->GetBladesPerformances().at(nSpan); + +// solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, BladePerf->GetEntropyGen()*100); +// solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, BladePerf->GetTotalPressureLoss()); +// solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, BladePerf->GetKineticEnergyLoss()); +// } +// } + void CIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container) { + // Computes the turboperformance per blade in zone iBlade const auto nDim = geometry_container[ZONE_0][INST_0][MESH_0]->GetnDim(); const auto nBladesRow = config_container[ZONE_0]->GetnMarker_Turbomachinery(); const auto nZone = config_container[ZONE_0]->GetnZone(); - vector TurboPrimitiveIn, TurboPrimitiveOut; - std::vector> bladesPrimitives; - - if (rank == MASTER_NODE) { - for (auto iBlade = 0u; iBlade < nBladesRow; iBlade++){ - /* Blade Primitive initialized per blade */ - std::vector bladePrimitives; - auto nSpan = config_container[iBlade]->GetnSpanWiseSections(); - for (auto 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); - - auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); - 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]); - - /*--- Set turbomachinery objective function value in each zone ---*/ - for (auto iBlade = 0u; iBlade < nBladesRow; iBlade++) { - // Should we set in ZONE_0 or nZone-1? - auto iBladePerf = TurbomachineryPerformance->GetBladesPerformances().at(iBlade).at(nSpan); - InState = iBladePerf->GetInletState(); - OutState = iBladePerf->GetOutletState(); - solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, iBlade, TurbomachineryStagePerformance->GetNormEntropyGen()*100); - solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, iBlade, iBladePerf->GetTotalPressureLoss()); - solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, iBlade, iBladePerf->GetKineticEnergyLoss()); - } - /*--- Set global turbomachinery objective function (evaluated in final zone as dependent on values from all previous zones ) ---*/ - solver[nBladesRow-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, nBladesRow, TurbomachineryStagePerformance->GetNormEntropyGen()*100); - solver[nBladesRow-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, nBladesRow, TurbomachineryStagePerformance->GetTotalPressureLoss()); - solver[nBladesRow-1][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, nBladesRow, TurbomachineryStagePerformance->GetKineticEnergyLoss()); - } + + auto TurbomachineryBladePerformances = GetBladesPerformanceVector(solver, nZone); + + auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); + auto InState = TurbomachineryBladePerformances.at(ZONE_0)->GetBladesPerformances().at(nSpan)->GetInletState(); + nSpan = config_container[nZone-1]->GetnSpanWiseSections(); + auto OutState = TurbomachineryBladePerformances.at(nZone-1)->GetBladesPerformances().at(nSpan)->GetOutletState(); + + TurbomachineryStagePerformance->ComputePerformanceStage(InState, OutState, config_container[nZone-1]); + + // /*--- Set turbomachinery objective function value in each zone ---*/ + // for (auto iBlade = 0u; iBlade < nBladesRow; iBlade++) { + // /*--- Set global turbomachinery objective functions ---*/ + // solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, nBladesRow, TurbomachineryStagePerformance->GetNormEntropyGen()*100); + // solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, nBladesRow, TurbomachineryStagePerformance->GetTotalPressureLoss()); + // solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, nBladesRow, TurbomachineryStagePerformance->GetKineticEnergyLoss()); + // } } diff --git a/SU2_CFD/src/iteration/CTurboIteration.cpp b/SU2_CFD/src/iteration/CTurboIteration.cpp index b1d95ba18bdb..bc803a51cb94 100644 --- a/SU2_CFD/src/iteration/CTurboIteration.cpp +++ b/SU2_CFD/src/iteration/CTurboIteration.cpp @@ -28,34 +28,50 @@ #include "../../include/iteration/CTurboIteration.hpp" #include "../../include/output/COutput.hpp" #include "../../include/output/CTurboOutput.hpp" +#include "../../../Common/include/tracy_structure.hpp" void CTurboIteration::Preprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { - /*--- Average quantities at the inflow and outflow boundaries ---*/ - 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], 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, - solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetFluidModel()); - } + + SU2_ZONE_SCOPED_N("Preprocess_Turbo"); + + // CNumerics* conv_bound_numerics = numerics[val_iZone][val_iInst][MESH_0][FLOW_SOL][CONV_BOUND_TERM + omp_get_thread_num()*MAX_TERMS]; + + // if (config[val_iZone]->GetBoolGiles() && config[val_iZone]->GetSpatialFourier()){ + // solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->PreprocessBC_Giles(geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], conv_bound_numerics, INFLOW); + // solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->PreprocessBC_Giles(geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], conv_bound_numerics, OUTFLOW); + // } + + /*--- Average quantities at the inflow and outflow boundaries ---*/ + 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], 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); + + InitTurboPerformance(geometry[val_iZone][val_iInst][MESH_0], config, solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetFluidModel(), val_iZone); + } void CTurboIteration::Postprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { - /*--- Average quantities at the inflow and outflow boundaries ---*/ - 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], 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); - - /*--- Gather Inflow and Outflow quantities on the Master Node to compute performance ---*/ - solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GatherInOutAverageValues(config[val_iZone], - geometry[val_iZone][val_iInst][MESH_0]); + /*--- Average quantities at the inflow and outflow boundaries ---*/ + 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], 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); + + /*--- Gather Inflow and Outflow quantities on the Master Node to compute performance ---*/ + + solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GatherInOutAverageValues(config[val_iZone], geometry[val_iZone][val_iInst][MESH_0]); + + /*--- Compute the turboperformance ---*/ + + solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->ComputeTurboBladePerformance(geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], val_iZone); + + TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone); // ???? + } diff --git a/SU2_CFD/src/numerics/flow/convection/roe.cpp b/SU2_CFD/src/numerics/flow/convection/roe.cpp index 12e0cefb20f2..e39169bdf2a1 100644 --- a/SU2_CFD/src/numerics/flow/convection/roe.cpp +++ b/SU2_CFD/src/numerics/flow/convection/roe.cpp @@ -244,6 +244,8 @@ CNumerics::ResidualType<> CUpwRoeBase_Flow::ComputeResidual(const CConfig* confi } AD::SetPreaccOut(Flux, nVar); + // AD::SetPreaccOut(Jacobian_i, nVar, nVar); + // AD::SetPreaccOut(Jacobian_j, nVar, nVar); AD::EndPreacc(); return ResidualType<>(Flux, Jacobian_i, Jacobian_j); diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 9868f20c3154..ba579b40dcba 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -475,7 +475,7 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol if (config->GetEquivArea()) SetNearfieldInverseDesign(flow_solver, geometry, config); /*--- Set Turbomachinery Objective functions ---*/ - SetTurbomachineryObjectiveFunctions(flow_solver, config); + //SetTurbomachineryObjectiveFunctions(flow_solver, config); /*--- Keep this as last, since it uses the history values that were set. ---*/ @@ -484,9 +484,16 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol SetCustomAndComboObjectives(FLOW_SOL, config, solver); } +// void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short iZone) { +// /*--- Set Turbomachinery Objective functions ---*/ +// SetTurbomachineryObjectiveFunctions(solver[FLOW_SOL], config, iZone); + +// LoadHistoryData(config, geometry, solver); +// } + void CFlowCompOutput::SetTurbomachineryObjectiveFunctions(CSolver *solver, CConfig *config){ const auto weight = config->GetWeight_ObjFunc(0); - const auto ObjFunc = solver->GetTurboObjectiveFunction(config->GetKind_ObjFunc(), config->GetnMarker_Turbomachinery()); + const auto ObjFunc = solver->GetTurboObjectiveFunction(config->GetKind_ObjFunc(), config->GetnMarker_Turbomachinery())/config->GetnZone(); solver->SetTotal_Custom_ObjFunc(weight*ObjFunc); } @@ -508,7 +515,7 @@ bool CFlowCompOutput::WriteHistoryFileOutput(const CConfig *config) { return !config->GetFinite_Difference_Mode() && COutput::WriteHistoryFileOutput(config); } -void CFlowCompOutput::SetTurboPerformance_Output(std::shared_ptr TurboPerf, +void CFlowCompOutput::SetTurboPerformance_Output(std::vector> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, @@ -520,8 +527,6 @@ void CFlowCompOutput::SetTurboPerformance_Output(std::shared_ptr T curInnerIter = InnerIter; stringstream TurboInOutTable, TurboPerfTable; - auto BladePerformance = TurboPerf->GetBladesPerformances(); - /*-- Table for Turbomachinery Performance Values --*/ PrintingToolbox::CTablePrinter TurboInOut(&TurboInOutTable); @@ -534,7 +539,7 @@ 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); + const auto& BladePerf = TurboBladePerfs.at(iZone)->GetBladesPerformances().at(nSpan); TurboInOut<<" BLADE ROW INDEX "< T cout< TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) { +void CFlowCompOutput::SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, std::vector> TurboPerf, CConfig *config) { stringstream TurboMZPerf; @@ -584,11 +589,10 @@ void CFlowCompOutput::SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) { - auto BladePerformance = TurboPerf->GetBladesPerformances(); +void CFlowCompOutput::LoadTurboHistoryData(std::shared_ptr TurboStagePerf, std::vector> TurboBladePerfs, CConfig *config) { for (unsigned short iZone = 0; iZone <= config->GetnZone()-1; iZone++) { auto nSpan = config->GetnSpan_iZones(iZone); - const auto& BladePerf = BladePerformance.at(iZone).at(nSpan); + const auto& BladePerf = TurboBladePerfs.at(iZone)->GetBladesPerformances().at(nSpan); stringstream tag; tag << iZone + 1; @@ -630,7 +634,7 @@ void CFlowCompOutput::LoadTurboHistoryData(std::shared_ptrGetTotalPressureLoss()); } -void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptr TurboPerf, CGeometry *geometry, CConfig **config, unsigned short val_iZone) { +void CFlowCompOutput::WriteTurboSpanwisePerformance(std::vector> TurboBladePerfs, CGeometry *geometry, CConfig **config, unsigned short val_iZone) { string inMarker_Tag, outMarker_Tag, inMarkerTag_Mix; unsigned short nZone = config[val_iZone]->GetnZone(); @@ -642,8 +646,6 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetBladesPerformances(); - /*--- Start of write file turboperformance spanwise ---*/ SpanWiseValuesIn = geometry->GetSpanWiseValue(INFLOW); SpanWiseValuesOut = geometry->GetSpanWiseValue(OUTFLOW); @@ -675,7 +677,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); iSpan++){ - const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan); + const auto& BladePerf = TurboBladePerfs.at(val_iZone)->GetBladesPerformances().at(iSpan); file.width(30); file << SpanWiseValuesIn[iSpan]; file.width(15); file << iSpan; @@ -719,7 +721,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); iSpan++){ - const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan); + const auto& BladePerf = TurboBladePerfs.at(val_iZone)->GetBladesPerformances().at(iSpan); file.width(30); file << SpanWiseValuesOut[iSpan]; file.width(15); file << iSpan; @@ -769,7 +771,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); iSpan++){ - const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan); + const auto& BladePerf = TurboBladePerfs.at(val_iZone)->GetBladesPerformances().at(iSpan); file.width(30); file << SpanWiseValuesIn[iSpan]; file.width(15); file << iSpan; @@ -833,7 +835,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); iSpan++){ - const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan); + const auto& BladePerf = TurboBladePerfs.at(val_iZone)->GetBladesPerformances().at(iSpan); file.width(30); file << SpanWiseValuesOut[iSpan]; file.width(15); file << iSpan; diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index fe90afd98882..6ba6a8eb8cc2 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -228,7 +228,7 @@ void COutput::SetHistoryOutput(CGeometry *geometry, } -void COutput::SetHistoryOutput(CGeometry ****geometry, CSolver *****solver, CConfig **config, std::shared_ptr(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, std::shared_ptr(TurboStagePerf), std::vector> TurboBladePerfs, unsigned short val_iZone, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iInst){ unsigned long Iter= InnerIter; @@ -237,19 +237,19 @@ void COutput::SetHistoryOutput(CGeometry ****geometry, CSolver *****solver, CCon /*--- Turbomachinery Performance Screen summary output---*/ if (Iter%100 == 0 && rank == MASTER_NODE) { - SetTurboPerformance_Output(TurboPerf, config[val_iZone], TimeIter, OuterIter, InnerIter); - SetTurboMultiZonePerformance_Output(TurboStagePerf, TurboPerf, config[val_iZone]); + SetTurboPerformance_Output(TurboBladePerfs, config[val_iZone], TimeIter, OuterIter, InnerIter); //Blade-row index scree + SetTurboMultiZonePerformance_Output(TurboStagePerf, TurboBladePerfs, config[val_iZone]); //Stage performance screen } for (int iZone = 0; iZone < config[ZONE_0]->GetnZone(); iZone ++){ if (rank == MASTER_NODE) { - WriteTurboSpanwisePerformance(TurboPerf, geometry[iZone][val_iInst][MESH_0], config, iZone); + WriteTurboSpanwisePerformance(TurboBladePerfs, geometry[iZone][val_iInst][MESH_0], config, iZone); //Spanwise files } } /*--- Update turboperformance history file*/ if (rank == MASTER_NODE){ - LoadTurboHistoryData(TurboStagePerf, TurboPerf, config[val_iZone]); + LoadTurboHistoryData(TurboStagePerf, TurboBladePerfs, config[val_iZone]); //History files } } diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index d3ea8798212d..b78299bea5db 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -159,51 +159,47 @@ void CPropellorBladePerformance::ComputePerformance(const CTurbomachineryCombine // TODO: to be implemented } -CTurboOutput::CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel) { +CTurboOutput::CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel, unsigned short iBladeRow) { 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[iBladeRow]->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); - - /* Switch between the Turbomachinery Performance Kind */ - switch (config[ZONE_0]->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; - } + vector> bladeSpanPerformances; + unsigned short nSpan = config[iBladeRow]->GetnSpanWiseSections(); + for (unsigned short iSpan = 0; iSpan < nSpan + 1; iSpan++) { + auto areaIn = geometry.GetSpanAreaIn(iBladeRow, iSpan); + auto areaOut = geometry.GetSpanAreaOut(iBladeRow, iSpan); + auto radiusIn = geometry.GetTurboRadiusIn(iBladeRow, iSpan); + auto radiusOut = geometry.GetTurboRadiusOut(iBladeRow, iSpan); + + /* Switch between the Turbomachinery Performance Kind */ + switch (config[ZONE_0]->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; } - BladesPerformances.push_back(bladeSpanPerformances); } + BladesPerformances = bladeSpanPerformances; } void CTurboOutput::ComputeTurbomachineryPerformance( - vector> const bladesPrimitives) { - for (unsigned i = 0; i < BladesPerformances.size(); ++i) { - ComputePerBlade(BladesPerformances[i], bladesPrimitives[i]); - } + vector const bladePrimitives, unsigned short iBladeRow) { + ComputePerBlade(BladesPerformances, bladePrimitives); } void CTurboOutput::ComputePerBlade(vector> const bladePerformances, diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 2feff7629b84..1c78a6c0a6e1 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -28,6 +28,7 @@ #include "../../include/solvers/CDiscAdjSolver.hpp" #include "../../../Common/include/toolboxes/geometry_toolbox.hpp" #include "../../../Common/include/parallelization/omp_structure.hpp" +#include "../../../Common/include/tracy_structure.hpp" CDiscAdjSolver::CDiscAdjSolver(CGeometry *geometry, CConfig *config, CSolver *direct_sol, unsigned short Kind_Solver, unsigned short iMesh) : CSolver() { @@ -116,6 +117,8 @@ CDiscAdjSolver::~CDiscAdjSolver() { delete nodes; } void CDiscAdjSolver::SetRecording(CGeometry* geometry, CConfig *config){ + SU2_ZONE_SCOPED_N("SetRecording_Solver"); + const bool time_n1_needed = config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND; const bool time_n_needed = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || time_n1_needed; diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 2708524b798a..c25cd73456bd 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -36,8 +36,11 @@ #include "../../include/fluid/CCoolProp.hpp" #include "../../include/numerics_simd/CNumericsSIMD.hpp" #include "../../include/limiters/CLimiterDetails.hpp" +#include "../../include/output/COutput.hpp" #include "../../include/output/CTurboOutput.hpp" +#include "../../../Common/include/tracy_structure.hpp" + CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh, const bool navier_stokes) : @@ -385,10 +388,11 @@ void CEulerSolver::InstantiateEdgeNumerics(const CSolver* const* solver_containe END_SU2_OMP_SAFE_GLOBAL_ACCESS } -void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ +void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig **config_container, unsigned short iZone){ - /*--- Initialize quantities for the average process for internal flow ---*/ + auto config = config_container[iZone]; + /*--- Initialize quantities for the average process for internal flow ---*/ const auto nSpanWiseSections = config->GetnSpanWiseSections(); AverageVelocity.resize(nMarker); @@ -458,11 +462,7 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ } } - /*--- Initialsize turbomachinery objective functions (+1 as value for stage values) ---*/ - auto nMarker_Turbo = config->GetnMarker_Turbomachinery() + 1; - EntropyGeneration.resize(nMarker_Turbo); - TotalPressureLoss.resize(nMarker_Turbo); - KineticEnergyLoss.resize(nMarker_Turbo); + TurbomachineryPerformance = std::make_shared(config_container, *geometry, *GetFluidModel(), iZone); } void CEulerSolver::Set_MPI_ActDisk(CSolver **solver_container, CGeometry *geometry, CConfig *config) { @@ -4761,7 +4761,7 @@ void CEulerSolver::Evaluate_ObjFunc(const CConfig *config, CSolver**) { Total_ComboObj+=Weight_ObjFunc*config->GetSurface_Mach(0); break; case ENTROPY_GENERATION: - Total_ComboObj+=Weight_ObjFunc*GetTurboObjectiveFunction(Kind_ObjFunc, config->GetnMarker_Turbomachinery()); + Total_ComboObj+=Weight_ObjFunc*EntropyGeneration; break; default: break; @@ -8932,6 +8932,8 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CConfig *config, unsigned short marker_flag) { + SU2_ZONE_SCOPED_N("TurboAverageProcess"); + const auto average_process = config->GetKind_AverageProcess(); const auto performance_average_process = config->GetKind_PerformanceAverageProcess(); const auto iZone = config->GetiZone(); @@ -9535,3 +9537,31 @@ void CEulerSolver::GatherInOutAverageValues(CConfig *config, CGeometry *geometry } } } + +void CEulerSolver::ComputeTurboBladePerformance(CGeometry* geometry, CConfig* config, unsigned short iBlade) { + // Computes the turboperformance per blade in zone iBlade + const auto nDim = geometry->GetnDim(); + const auto nBladesRow = config->GetnMarker_Turbomachinery(); + const auto nZone = config->GetnZone(); + vector TurboPrimitiveIn, TurboPrimitiveOut; + if (rank == MASTER_NODE) { + /* Blade Primitive initialized per blade */ + std::vector bladePrimitives; + auto nSpan = config->GetnSpanWiseSections(); + for (auto iSpan = 0; iSpan < nSpan + 1; iSpan++) { + TurboPrimitiveIn= GetTurboPrimitive(iBlade, iSpan, true); + TurboPrimitiveOut= GetTurboPrimitive(iBlade, iSpan, false); + auto spanInletPrimitive = CTurbomachineryPrimitiveState(TurboPrimitiveIn, nDim, geometry->GetTangGridVelIn(iBlade, iSpan)); + auto spanOutletPrimitive = CTurbomachineryPrimitiveState(TurboPrimitiveOut, nDim, geometry->GetTangGridVelOut(iBlade, iSpan)); + auto spanCombinedPrimitive = CTurbomachineryCombinedPrimitiveStates(spanInletPrimitive, spanOutletPrimitive); + bladePrimitives.push_back(spanCombinedPrimitive); + } + TurbomachineryPerformance->ComputeTurbomachineryPerformance(bladePrimitives, iBlade); + + auto BladePerf = TurbomachineryPerformance->GetBladesPerformances().at(nSpan); + + EntropyGeneration = BladePerf->GetEntropyGen(); + TotalPressureLoss = BladePerf->GetTotalPressureLoss(); + KineticEnergyLoss = BladePerf->GetKineticEnergyLoss(); + } +} From 32956c4b66229948285b8dd1533dbd526f43e0c3 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sun, 12 Oct 2025 01:27:02 +0100 Subject: [PATCH 08/79] Cleaned up branch + Euler MZ working / Issues with RANS remain + Init MZ turbo testcase --- Common/include/CConfig.hpp | 18 -- Common/include/geometry/CGeometry.hpp | 5 - Common/src/geometry/CGeometry.cpp | 48 ---- Common/src/geometry/CPhysicalGeometry.cpp | 1 - SU2_CFD/include/drivers/CDriver.hpp | 5 - .../integration/CMultiGridIntegration.hpp | 2 +- .../iteration/CDiscAdjFluidIteration.hpp | 2 +- SU2_CFD/include/iteration/CFluidIteration.hpp | 2 +- SU2_CFD/include/iteration/CIteration.hpp | 8 - .../src/drivers/CDiscAdjMultizoneDriver.cpp | 25 +-- .../src/drivers/CDiscAdjSinglezoneDriver.cpp | 5 +- SU2_CFD/src/drivers/CDriver.cpp | 53 ----- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 12 - SU2_CFD/src/integration/CIntegration.cpp | 11 +- .../src/integration/CMultiGridIntegration.cpp | 22 +- SU2_CFD/src/interfaces/CInterface.cpp | 5 - .../interfaces/cfd/CMixingPlaneInterface.cpp | 3 - .../src/iteration/CDiscAdjFluidIteration.cpp | 34 +-- SU2_CFD/src/iteration/CFluidIteration.cpp | 35 +-- SU2_CFD/src/iteration/CIteration.cpp | 39 ---- SU2_CFD/src/iteration/CTurboIteration.cpp | 12 +- SU2_CFD/src/numerics/flow/convection/roe.cpp | 4 +- SU2_CFD/src/output/CFlowCompOutput.cpp | 16 -- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 3 - SU2_CFD/src/solvers/CEulerSolver.cpp | 7 +- .../axial_stage_2D/Axial_stage2D.cfg | 211 ++++++++++++++++++ .../transonic_stator_2D/transonic_stator.cfg | 2 +- TestCases/parallel_regression_AD.py | 9 + 28 files changed, 236 insertions(+), 363 deletions(-) create mode 100755 TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index f544d488ee8d..03cb4fff9f46 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -8396,24 +8396,6 @@ class CConfig { */ su2double GetSurface_Species_Variance(unsigned short val_marker) const { return Surface_Species_Variance[val_marker]; } - /*! - * \brief Get entropy generation for a turbomachine at a boundary - * \param[in] val_iZone - zone index - */ - su2double GetEntropyGeneration(unsigned short val_iZone) const { return EntropyGeneration[val_iZone]; } - - /*! - * \brief Get total pressure loss for a turbomachinery zone - * \param[in] val_iZone - zone index - */ - su2double GetTotalPressureLoss(unsigned short val_iZone) const { return TotalPressureLoss[val_iZone]; } - - /*! - * \brief Get kinetic energy loss for a turbomachinery zone - * \param[in] val_iZone - zone index - */ - su2double GetKineticEnergyLoss(unsigned short val_iZone) const { return KineticEnergyLoss[val_iZone]; } - /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 8803cbdf92e1..194219388844 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -62,7 +62,6 @@ extern "C" { #include "../CConfig.hpp" #include "../toolboxes/graph_toolbox.hpp" #include "../adt/CADTElemClass.hpp" -#include "../../../SU2_CFD/include/interfaces/CInterface.hpp" using namespace std; @@ -1353,10 +1352,6 @@ class CGeometry { */ static void UpdateGeometry(CGeometry** geometry_container, CConfig* config); - static void UpdateTurboGeometry(CGeometry**** geometry, CInterface*** interface, CConfig** config_container, unsigned short iZone); - - static void InitTurboVertexAdj(CGeometry**** geometry, CConfig** config, unsigned short iZone); - /*! * \brief Update the multi-grid structure for the customized boundary conditions * \param geometry_container - Geometrical definition. diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 032b282c1e94..dd962f3f9701 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -33,8 +33,6 @@ #include "../../include/toolboxes/geometry_toolbox.hpp" #include "../../include/toolboxes/ndflattener.hpp" -#include "../../../SU2_CFD/include/interfaces/CInterface.hpp" - CGeometry::CGeometry() : size(SU2_MPI::GetSize()), rank(SU2_MPI::GetRank()) {} CGeometry::~CGeometry() { @@ -2362,52 +2360,6 @@ void CGeometry::UpdateGeometry(CGeometry** geometry_container, CConfig* config) geometry_container[MESH_0]->ComputeSurfaceAreaCfgFile(config); } -void CGeometry::InitTurboVertexAdj(CGeometry**** geometry, CConfig** config, unsigned short iZone){ - auto nSpanMax = 0u; - auto nZone = config[ZONE_0]->GetnZone(); - - /*--- Create turbovertex ---*/ - geometry[iZone][INST_0][MESH_0]->ComputeNSpan(config[iZone], iZone, INFLOW, true); - geometry[iZone][INST_0][MESH_0]->ComputeNSpan(config[iZone], iZone, OUTFLOW, true); - if (config[iZone]->GetnSpanWiseSections() > nSpanMax){ - nSpanMax = config[iZone]->GetnSpanWiseSections(); - } - - 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); - - /*--- Set max span in all zones ---*/ - if (config[iZone]->GetBoolTurbomachinery()) { - config[iZone]->SetnSpanMaxAllZones(nSpanMax); - } -} - -void CGeometry::UpdateTurboGeometry(CGeometry**** geometry, CInterface*** interface, CConfig** config, unsigned short iZone){ - auto nZone = config[ZONE_0]->GetnZone(); - - geometry[iZone][INST_0][MESH_0]->SetAvgTurboValue(config[iZone], iZone, INFLOW, true); - geometry[iZone][INST_0][MESH_0]->SetAvgTurboValue(config[iZone],iZone, OUTFLOW, true); - geometry[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config[iZone], true); - - // if(config[ZONE_0]->GetBoolMixingPlaneInterface()){ - // for (auto donorZone = 0u; donorZone < nZone; donorZone++) { - // for (auto targetZone = 0u; targetZone < nZone; targetZone++) { - // if (interface[donorZone][targetZone] != nullptr){ - // interface[iZone][targetZone]->SetSpanWiseLevels(config[donorZone], config[targetZone]); - // } - // } - // } - // } - - 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---*/ - auto nBlades = config[iZone]->GetnBlades(iZone); - config[ZONE_0]->SetnBlades(iZone, nBlades); -} - void CGeometry::SetCustomBoundary(CConfig* config) { unsigned short iMarker; unsigned long iVertex; diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index f5c3156d8c2b..146d8b9c4f60 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -6329,7 +6329,6 @@ void CPhysicalGeometry::GatherInOutAverageValues(CConfig* config, bool allocate) void CPhysicalGeometry::SetAvgTurboGeoValues(const CConfig* donor_config, CGeometry* donor_geometry, unsigned short donorZone) { - SU2_ZONE_SCOPED_N("SetAvgTurboGeoValues"); unsigned short iSpan; unsigned short nSpanMaxAllZones = donor_config->GetnSpanMaxAllZones(); diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 8a39fcb8532b..41812a04d3b0 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -284,11 +284,6 @@ class CDriver : public CDriverBase { */ void PreprocessStaticMesh(const CConfig* config, CGeometry** geometry); - /*! - * \brief Initiate value for static mesh movement such as the gridVel for the ROTATING frame. - */ - void InitStaticMeshMovement(unsigned short iZone, bool print); - /*! * \brief Initiate value for static mesh movement such as the gridVel for the ROTATING frame. * \param[in] config - Definition of the particular problem. diff --git a/SU2_CFD/include/integration/CMultiGridIntegration.hpp b/SU2_CFD/include/integration/CMultiGridIntegration.hpp index 36134e3b4c51..a29dc8f2c06c 100644 --- a/SU2_CFD/include/integration/CMultiGridIntegration.hpp +++ b/SU2_CFD/include/integration/CMultiGridIntegration.hpp @@ -119,7 +119,7 @@ class CMultiGridIntegration final : public CIntegration { */ void NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, CNumerics ****numerics_container, CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, - su2double *monitor, unsigned short iZone); + su2double *monitor); /*! * \brief Compute the fine solution from a coarse solution. diff --git a/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp b/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp index df588102177b..630a06fe9daa 100644 --- a/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp @@ -157,7 +157,7 @@ class CDiscAdjFluidIteration final : public CIteration { * \param[in] iInst - Index of the zone. * \param[in] kind_recording - The kind of recording (geometry or flow). */ - void SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, CConfig** config, CInterface*** interface, + void SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, CConfig** config, unsigned short iZone, unsigned short iInst, RECORDING kind_recording) override; }; diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index 7ab580bcf974..faaefac87244 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -114,7 +114,7 @@ class CFluidIteration : public CIteration { * \param[in] ExtIter - The current iteration of the problem * \param[in] iZone - The current zone */ - void TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter, unsigned short iZone); + void UpdateRamps(CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter, unsigned short iZone); /*! * \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 6ee587c13710..8ebd0a211c55 100644 --- a/SU2_CFD/include/iteration/CIteration.hpp +++ b/SU2_CFD/include/iteration/CIteration.hpp @@ -60,9 +60,7 @@ class CIteration { su2double StartTime{0.0}, /*!< \brief Tracking wall time. */ StopTime{0.0}, UsedTime{0.0}; -// std::shared_ptr TurbomachineryPerformance; /*!< \brief turbo performance calculator. */ std::shared_ptr TurbomachineryStagePerformance; /*!< \brief turbo stage performance calculator. */ - //std::vector> TurbomachineryBladePerformances; /*!< \brief Vector of turboperformances */ public: /*! * \brief Constructor of the class. @@ -293,15 +291,9 @@ class CIteration { virtual void SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, CConfig** config, unsigned short iZone, unsigned short iInst, RECORDING kind_recording) {} - virtual void SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, CConfig** config, CInterface*** interface, - unsigned short iZone, unsigned short iInst, RECORDING kind_recording) {} - virtual void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, unsigned short iZone, unsigned short iInst) {} - - // void ComputeTurboBladePerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned short iBlade); - /*! * \brief Computes turboperformance. */ diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 2bbeddecf647..09923aa8c4ae 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -31,8 +31,6 @@ #include "../../include/output/COutput.hpp" #include "../../include/iteration/CIterationFactory.hpp" -#include "../../../Common/include/tracy_structure.hpp" - CDiscAdjMultizoneDriver::CDiscAdjMultizoneDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunicator) @@ -687,8 +685,6 @@ void CDiscAdjMultizoneDriver::EvaluateSensitivities(unsigned long Iter, bool for void CDiscAdjMultizoneDriver::SetRecording(RECORDING kind_recording, Kind_Tape tape_type, unsigned short record_zone) { - SU2_ZONE_SCOPED_N("SetRecording_driver"); - AD::Reset(); /*--- Prepare for recording by resetting the solution to the initial converged solution. ---*/ @@ -747,7 +743,7 @@ void CDiscAdjMultizoneDriver::SetRecording(RECORDING kind_recording, Kind_Tape t for (iZone = 0; iZone < nZone; iZone++) { iteration_container[iZone][INST_0]->SetDependencies(solver_container, geometry_container, numerics_container, - config_container, interface_container, iZone, INST_0, kind_recording); + config_container, iZone, INST_0, kind_recording); } AD::Push_TapePosition(); /// DEPENDENCIES @@ -761,7 +757,7 @@ void CDiscAdjMultizoneDriver::SetRecording(RECORDING kind_recording, Kind_Tape t for (iZone = 0; iZone < nZone; iZone++) { if (Has_Deformation(iZone)) { iteration_container[iZone][INST_0]->SetDependencies(solver_container, geometry_container, numerics_container, - config_container, interface_container, iZone, INST_0, kind_recording); + config_container, iZone, INST_0, kind_recording); } } SetObjFunction(kind_recording); @@ -805,12 +801,6 @@ void CDiscAdjMultizoneDriver::SetRecording(RECORDING kind_recording, Kind_Tape t void CDiscAdjMultizoneDriver::DirectIteration(unsigned short iZone, RECORDING kind_recording) { - SU2_ZONE_SCOPED_N("DirectIteration"); - - // if (config_container[iZone]->GetBoolTurbomachinery()) { - // InitStaticMeshMovement(iZone, false); - // } - /*--- Do one iteration of the direct solver ---*/ direct_iteration[iZone][INST_0]->Preprocess(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, @@ -821,11 +811,6 @@ void CDiscAdjMultizoneDriver::DirectIteration(unsigned short iZone, RECORDING ki solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0); - /*--- Turbo Specific Post-Procesisng ---*/ - // if (config_container[iZone]->GetBoolTurbomachinery()){ - // direct_iteration[iZone][INST_0]->Postprocess(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0); - // } - } void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) { @@ -858,11 +843,7 @@ void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) { solvers[FLOW_SOL]->TurboAverageProcess(solvers, geometry, config, OUTFLOW); /*--- Gather Inflow and Outflow quantities on the Master Node to compute performance ---*/ - solvers[FLOW_SOL]->GatherInOutAverageValues(config, geometry); - - /*--- Compute the turboperformance ---*/ - solvers[FLOW_SOL]->ComputeTurboBladePerformance(geometry, config, iZone); } @@ -992,8 +973,6 @@ void CDiscAdjMultizoneDriver::InitializeCrossTerms() { void CDiscAdjMultizoneDriver::HandleDataTransfer() { - SU2_ZONE_SCOPED_N("HandleDataTransfer"); - for(iZone = 0; iZone < nZone; iZone++) { /*--- In principle, the mesh does not need to be updated ---*/ diff --git a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp index 7a3f8ea8d8aa..960adbe92a50 100644 --- a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp @@ -33,7 +33,6 @@ #include "../../include/iteration/CTurboIteration.hpp" #include "../../../Common/include/toolboxes/CQuasiNewtonInvLeastSquares.hpp" -#include "../../../Common/include/tracy_structure.hpp" CDiscAdjSinglezoneDriver::CDiscAdjSinglezoneDriver(char* confFile, unsigned short val_nZone, @@ -249,8 +248,6 @@ void CDiscAdjSinglezoneDriver::Postprocess() { void CDiscAdjSinglezoneDriver::SetRecording(RECORDING kind_recording){ - SU2_ZONE_SCOPED_N("SetRecording_SingleZoneDriver"); - AD::Reset(); /*--- Prepare for recording by resetting the solution to the initial converged solution. ---*/ @@ -289,7 +286,7 @@ void CDiscAdjSinglezoneDriver::SetRecording(RECORDING kind_recording){ /*--- Set the dependencies of the iteration ---*/ - iteration->SetDependencies(solver_container, geometry_container, numerics_container, config_container, nullptr, ZONE_0, + iteration->SetDependencies(solver_container, geometry_container, numerics_container, config_container, ZONE_0, INST_0, kind_recording); /*--- Do one iteration of the direct solver ---*/ diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 29ec4e53af7f..e97150e249be 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2604,59 +2604,6 @@ void CDriver::PreprocessOutput(CConfig **config, CConfig *driver_config, COutput } -void CDriver::InitStaticMeshMovement(unsigned short iZone, bool print) { - unsigned short iMGlevel; - unsigned short Kind_Grid_Movement; - - int rank = MASTER_NODE; -#ifdef HAVE_MPI - MPI_Comm_rank(MPI_COMM_WORLD, &rank); -#endif - - Kind_Grid_Movement = config_container[iZone]->GetKind_GridMovement(); - - switch (Kind_Grid_Movement) { - - case ROTATING_FRAME: - - /*--- Steadily rotating frame: set the grid velocities just once - before the first iteration flow solver. ---*/ - - if (rank == MASTER_NODE && print) { - cout << endl << " Setting rotating frame grid velocities"; - cout << " for zone " << iZone << "." << endl; - } - - /*--- Set the grid velocities on all multigrid levels for a steadily - rotating reference frame. ---*/ - - for (iMGlevel = 0; iMGlevel <= config_container[ZONE_0]->GetnMGLevels(); iMGlevel++){ - geometry_container[iZone][INST_0][MESH_0]->SetRotationalVelocity(config_container[iZone], print); - geometry_container[iZone][INST_0][MESH_0]->SetShroudVelocity(config_container[iZone]); - } - - break; - - case STEADY_TRANSLATION: - - /*--- Set the translational velocity and hold the grid fixed during - the calculation (similar to rotating frame, but there is no extra - source term for translation). ---*/ - - if (rank == MASTER_NODE && print) - cout << endl << " Setting translational grid velocities." << endl; - - /*--- Set the translational velocity on all grid levels. ---*/ - - for (iMGlevel = 0; iMGlevel <= config_container[ZONE_0]->GetnMGLevels(); iMGlevel++) - geometry_container[iZone][INST_0][iMGlevel]->SetTranslationalVelocity(config_container[iZone], iMGlevel == 0); - - - - break; - } -} - void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, CSolver***** solver, CInterface*** interface, CIteration*** iteration, bool dummy){ diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index a8290759abda..176d64cbebfd 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -30,7 +30,6 @@ #include "../../../Common/include/interface_interpolation/CInterpolator.hpp" #include "../../include/output/COutput.hpp" #include "../../include/iteration/CIteration.hpp" -#include "../../../Common/include/tracy_structure.hpp" CMultizoneDriver::CMultizoneDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunicator) : CDriver(confFile, val_nZone, MPICommunicator, false) { @@ -533,8 +532,6 @@ void CMultizoneDriver::DynamicMeshUpdate(unsigned short val_iZone, unsigned long bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short targetZone) { - SU2_ZONE_SCOPED_N("TransferData"); - bool UpdateMesh = false; /*--- Select the transfer method according to the magnitudes being transferred ---*/ @@ -602,15 +599,6 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar geometry_container[donorZone][INST_0][MESH_0],geometry_container[targetZone][INST_0][MESH_0], config_container[donorZone], config_container[targetZone], iMarkerInt ); } - - /*--- Set average value donorZone->targetZone ---*/ - //interface_container[donorZone][targetZone]->SetAverageValues(solver_container[donorZone][INST_0][MESH_0][FLOW_SOL],solver_container[targetZone][INST_0][MESH_0][FLOW_SOL], donorZone); - - // /*--- Set average geometrical properties FROM donorZone IN targetZone ---*/ - // if (donorZone != nZone - 1){ - // geometry_container[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config_container[donorZone],geometry_container[donorZone][INST_0][MESH_0], donorZone); - // } - break; } default: diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index 1f3056999c0d..3b6e43149f08 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -88,15 +88,6 @@ void CIntegration::Space_Integration(CGeometry *geometry, solver_container[MainSolver]->PreprocessBC_Giles(geometry, config, conv_bound_numerics, 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 ---*/ for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { @@ -195,7 +186,7 @@ void CIntegration::Space_Integration(CGeometry *geometry, else if (config->GetMarker_All_KindBC(iMarker)==EULER_WALL) solver_container[MainSolver]->BC_Euler_Wall(geometry, solver_container, conv_bound_numerics, visc_bound_numerics, config, iMarker); } - // AD::ResumePreaccumulation(pausePreacc); + //AD::ResumePreaccumulation(pausePreacc); } diff --git a/SU2_CFD/src/integration/CMultiGridIntegration.cpp b/SU2_CFD/src/integration/CMultiGridIntegration.cpp index 55eb2b14ebeb..f6549e7e209d 100644 --- a/SU2_CFD/src/integration/CMultiGridIntegration.cpp +++ b/SU2_CFD/src/integration/CMultiGridIntegration.cpp @@ -119,7 +119,7 @@ void CMultiGridIntegration::MultiGrid_Iteration(CGeometry ****geometry, NonDimensional_Parameters(geometry[iZone][iInst], solver_container[iZone][iInst], numerics_container[iZone][iInst], config[iZone], - FinestMesh, RunTime_EqSystem, &monitor, iZone); + FinestMesh, RunTime_EqSystem, &monitor); } END_SU2_OMP_PARALLEL @@ -656,7 +656,7 @@ void CMultiGridIntegration::SetRestricted_Gradient(unsigned short RunTime_EqSyst void CMultiGridIntegration::NonDimensional_Parameters(CGeometry **geometry, CSolver ***solver_container, CNumerics ****numerics_container, CConfig *config, unsigned short FinestMesh, unsigned short RunTime_EqSystem, - su2double *monitor, unsigned short iZone) { + su2double *monitor) { BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS switch (RunTime_EqSystem) { @@ -668,24 +668,6 @@ 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 the turboperformance ---*/ - - // solver_container[FinestMesh][FLOW_SOL]->ComputeTurboBladePerformance(geometry[FinestMesh], config, iZone); - - // } - break; case RUNTIME_ADJFLOW_SYS: diff --git a/SU2_CFD/src/interfaces/CInterface.cpp b/SU2_CFD/src/interfaces/CInterface.cpp index a38e13d88dc0..969730850b06 100644 --- a/SU2_CFD/src/interfaces/CInterface.cpp +++ b/SU2_CFD/src/interfaces/CInterface.cpp @@ -30,7 +30,6 @@ #include "../../../Common/include/CConfig.hpp" #include "../../../Common/include/geometry/CGeometry.hpp" #include "../../include/solvers/CSolver.hpp" -#include "../../../Common/include/tracy_structure.hpp" CInterface::CInterface() : rank(SU2_MPI::GetRank()), @@ -205,8 +204,6 @@ void CInterface::PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_ const CConfig *donor_config, const CConfig *target_config, unsigned short iMarkerInt){ - SU2_ZONE_SCOPED_N("PreprocessAverage"); - unsigned short nMarkerDonor, nMarkerTarget; // Number of markers on the interface, donor and target side unsigned short iMarkerDonor, iMarkerTarget; // Variables for iteration over markers unsigned short iSpan,jSpan, tSpan = 0, kSpan = 0, nSpanDonor, nSpanTarget, Donor_Flag = 0, Target_Flag = 0; @@ -335,8 +332,6 @@ void CInterface::PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_ void CInterface::AllgatherAverage(CSolver *donor_solution, CSolver *target_solution, CGeometry *donor_geometry, CGeometry *target_geometry, const CConfig *donor_config, const CConfig *target_config, unsigned short iMarkerInt){ - - SU2_ZONE_SCOPED_N("AllgatherAverage"); unsigned short nMarkerDonor, nMarkerTarget; // Number of markers on the interface, donor and target side unsigned short iMarkerDonor, iMarkerTarget; // Variables for iteration over markers diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index bee108d7f8a2..9b357c734ae3 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -30,7 +30,6 @@ #include "../../../../Common/include/CConfig.hpp" #include "../../../../Common/include/geometry/CGeometry.hpp" #include "../../../include/solvers/CSolver.hpp" -#include "../../../Common/include/tracy_structure.hpp" CMixingPlaneInterface::CMixingPlaneInterface(unsigned short val_nVar, unsigned short val_nConst){ nVar = val_nVar; @@ -118,8 +117,6 @@ void CMixingPlaneInterface::SetTarget_Variable(CSolver *target_solution, CGeomet void CMixingPlaneInterface::SetAverageValues(CSolver *donor_solution, CSolver *target_solution, unsigned short donorZone){ - SU2_ZONE_SCOPED_N("SetAverageValues"); - unsigned short iSpan; for(iSpan = 0; iSpanCompleteComms(geometry0, config[iZone], MPI_QUANTITIES::SOLUTION); } if (config[iZone]->GetBoolTurbomachinery()) { - // if ((config_container[iZone]->GetGrid_Movement())) { - // iteration_container[iZone][INST_0]->SetGrid_Movement(geometry_container[iZone][INST_0],surface_movement[iZone], - // grid_movement[iZone][INST_0], solver_container[iZone][INST_0], - // config_container[iZone], 0, TimeIter); - // } - // if (iZone == ZONE_0){ - // geometry[iZone][MESH_0][INST_0]->InitTurboVertexAdj(geometry, config, iZone); - // geometry[iZone][MESH_0][INST_0]->UpdateTurboGeometry(geometry, interface, config, iZone); - // for (auto donorZone = 0; donorZone < nZone; donorZone++) { - // auto nMarkerInt = config[donorZone]->GetnMarker_MixingPlaneInterface()/2; - // for (auto iMarkerInt = 1; iMarkerInt <= nMarkerInt; iMarkerInt++){ - // for (auto targetZone = 0; targetZone < nZone; targetZone++) { - // if (donorZone == targetZone || interface[donorZone][targetZone] == nullptr) continue; - // if (interface[donorZone][targetZone]->GetInterfaceType() == MIXING_PLANE){ - // interface[donorZone][targetZone]->PreprocessAverage(geometry[donorZone][INST_0][MESH_0], geometry[targetZone][INST_0][MESH_0], - // config[donorZone], config[targetZone], - // iMarkerInt); - // } - // } - // } - // } - // } - //solver[iZone][INST_0][MESH_0][FLOW_SOL]->InitTurboContainers(geometry[iZone][INST_0][MESH_0],config, iZone); solvers0[FLOW_SOL]->PreprocessAverage(solvers0, geometry0, config[iZone], INFLOW); solvers0[FLOW_SOL]->PreprocessAverage(solvers0, geometry0, config[iZone], OUTFLOW); - // solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], INFLOW); - // solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], OUTFLOW); if (config[iZone]->GetBoolGiles() && config[iZone]->GetSpatialFourier()){ auto conv_bound_numerics = numerics[iZone][iInst][MESH_0][FLOW_SOL][CONV_BOUND_TERM + omp_get_thread_num()*MAX_TERMS]; solvers0[FLOW_SOL]->PreprocessBC_Giles(geometry0, config[iZone], conv_bound_numerics, INFLOW); solvers0[FLOW_SOL]->PreprocessBC_Giles(geometry0, config[iZone], conv_bound_numerics, OUTFLOW); } - // solvers0[FLOW_SOL]->GatherInOutAverageValues(config[iZone], geometry0); - // solvers0[FLOW_SOL]->ComputeTurboBladePerformance(geometry0, config[iZone], iZone); } if (config[iZone]->GetKind_Species_Model() != SPECIES_MODEL::NONE) { solvers0[SPECIES_SOL]->Preprocessing(geometry0, solvers0, config[iZone], MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS, true); diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 286482380fb1..05c0817c98f9 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -247,7 +247,7 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe return StopCalc; } -void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone) { +void CFluidIteration::UpdateRamps(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone) { auto* config = config_container[iZone]; if (config_container[ZONE_0]->GetMultizone_Problem()) @@ -318,39 +318,6 @@ void CFluidIteration::TurboMonitor(CGeometry**** geometry_container, CConfig** c } } -// void CFluidIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container) { -// 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); - -// auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); -// 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]); -// } -// } - 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/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index b2aec96a2dd9..912728786b35 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -211,40 +211,9 @@ void CIteration::Output(COutput* output, CGeometry**** geometry, CSolver***** so } void CIteration::InitTurboPerformance(CGeometry* geometry, CConfig** config, CFluidModel* fluid, unsigned short val_iZone) { - //TurbomachineryPerformance = std::make_shared(config, *geometry, *fluid, val_iZone); TurbomachineryStagePerformance = std::make_shared(*fluid); - //TurbomachineryBladePerformances = std::make_shared>>(); } -// void CIteration::ComputeTurboBladePerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned short iBlade) { -// // Computes the turboperformance per blade in zone iBlade -// const auto nDim = geometry_container[ZONE_0][INST_0][MESH_0]->GetnDim(); -// const auto nBladesRow = config_container[ZONE_0]->GetnMarker_Turbomachinery(); -// const auto nZone = config_container[ZONE_0]->GetnZone(); -// vector TurboPrimitiveIn, TurboPrimitiveOut; -// if (rank == MASTER_NODE) { -// /* Blade Primitive initialized per blade */ -// std::vector bladePrimitives; -// auto nSpan = config_container[iBlade]->GetnSpanWiseSections(); -// for (auto 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); -// } -// TurbomachineryPerformance->ComputeTurbomachineryPerformance(bladePrimitives, iBlade); -// solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboBladePerformance(TurbomachineryPerformance); - -// auto BladePerf = TurbomachineryPerformance->GetBladesPerformances().at(nSpan); - -// solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, BladePerf->GetEntropyGen()*100); -// solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, BladePerf->GetTotalPressureLoss()); -// solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, BladePerf->GetKineticEnergyLoss()); -// } -// } - void CIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container) { // Computes the turboperformance per blade in zone iBlade const auto nDim = geometry_container[ZONE_0][INST_0][MESH_0]->GetnDim(); @@ -259,12 +228,4 @@ void CIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geom auto OutState = TurbomachineryBladePerformances.at(nZone-1)->GetBladesPerformances().at(nSpan)->GetOutletState(); TurbomachineryStagePerformance->ComputePerformanceStage(InState, OutState, config_container[nZone-1]); - - // /*--- Set turbomachinery objective function value in each zone ---*/ - // for (auto iBlade = 0u; iBlade < nBladesRow; iBlade++) { - // /*--- Set global turbomachinery objective functions ---*/ - // solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::ENTROPY_GENERATION, nBladesRow, TurbomachineryStagePerformance->GetNormEntropyGen()*100); - // solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::TOTAL_PRESSURE_LOSS, nBladesRow, TurbomachineryStagePerformance->GetTotalPressureLoss()); - // solver[iBlade][INST_0][MESH_0][FLOW_SOL]->SetTurboObjectiveFunction(ENUM_OBJECTIVE::KINETIC_ENERGY_LOSS, nBladesRow, TurbomachineryStagePerformance->GetKineticEnergyLoss()); - // } } diff --git a/SU2_CFD/src/iteration/CTurboIteration.cpp b/SU2_CFD/src/iteration/CTurboIteration.cpp index bc803a51cb94..c11092abec48 100644 --- a/SU2_CFD/src/iteration/CTurboIteration.cpp +++ b/SU2_CFD/src/iteration/CTurboIteration.cpp @@ -28,22 +28,12 @@ #include "../../include/iteration/CTurboIteration.hpp" #include "../../include/output/COutput.hpp" #include "../../include/output/CTurboOutput.hpp" -#include "../../../Common/include/tracy_structure.hpp" void CTurboIteration::Preprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { - SU2_ZONE_SCOPED_N("Preprocess_Turbo"); - - // CNumerics* conv_bound_numerics = numerics[val_iZone][val_iInst][MESH_0][FLOW_SOL][CONV_BOUND_TERM + omp_get_thread_num()*MAX_TERMS]; - - // if (config[val_iZone]->GetBoolGiles() && config[val_iZone]->GetSpatialFourier()){ - // solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->PreprocessBC_Giles(geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], conv_bound_numerics, INFLOW); - // solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->PreprocessBC_Giles(geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], conv_bound_numerics, OUTFLOW); - // } - /*--- Average quantities at the inflow and outflow boundaries ---*/ 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], INFLOW); @@ -72,6 +62,6 @@ void CTurboIteration::Postprocess(COutput* output, CIntegration**** integration, solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->ComputeTurboBladePerformance(geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], val_iZone); - TurboMonitor(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone); // ???? + UpdateRamps(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone); } diff --git a/SU2_CFD/src/numerics/flow/convection/roe.cpp b/SU2_CFD/src/numerics/flow/convection/roe.cpp index e39169bdf2a1..8213478404ea 100644 --- a/SU2_CFD/src/numerics/flow/convection/roe.cpp +++ b/SU2_CFD/src/numerics/flow/convection/roe.cpp @@ -244,8 +244,8 @@ CNumerics::ResidualType<> CUpwRoeBase_Flow::ComputeResidual(const CConfig* confi } AD::SetPreaccOut(Flux, nVar); - // AD::SetPreaccOut(Jacobian_i, nVar, nVar); - // AD::SetPreaccOut(Jacobian_j, nVar, nVar); + AD::SetPreaccOut(Jacobian_i, nVar, nVar); + AD::SetPreaccOut(Jacobian_j, nVar, nVar); AD::EndPreacc(); return ResidualType<>(Flux, Jacobian_i, Jacobian_j); diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index ba579b40dcba..5b74f8ec0e04 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -474,9 +474,6 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol if (config->GetEquivArea()) SetNearfieldInverseDesign(flow_solver, geometry, config); - /*--- Set Turbomachinery Objective functions ---*/ - //SetTurbomachineryObjectiveFunctions(flow_solver, config); - /*--- Keep this as last, since it uses the history values that were set. ---*/ SetCustomOutputs(solver, geometry, config); @@ -484,19 +481,6 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol SetCustomAndComboObjectives(FLOW_SOL, config, solver); } -// void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned short iZone) { -// /*--- Set Turbomachinery Objective functions ---*/ -// SetTurbomachineryObjectiveFunctions(solver[FLOW_SOL], config, iZone); - -// LoadHistoryData(config, geometry, solver); -// } - -void CFlowCompOutput::SetTurbomachineryObjectiveFunctions(CSolver *solver, CConfig *config){ - const auto weight = config->GetWeight_ObjFunc(0); - const auto ObjFunc = solver->GetTurboObjectiveFunction(config->GetKind_ObjFunc(), config->GetnMarker_Turbomachinery())/config->GetnZone(); - solver->SetTotal_Custom_ObjFunc(weight*ObjFunc); -} - bool CFlowCompOutput::SetInitResiduals(const CConfig *config){ return (config->GetTime_Marching() != TIME_MARCHING::STEADY && (curInnerIter == 0))|| diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 1c78a6c0a6e1..2feff7629b84 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -28,7 +28,6 @@ #include "../../include/solvers/CDiscAdjSolver.hpp" #include "../../../Common/include/toolboxes/geometry_toolbox.hpp" #include "../../../Common/include/parallelization/omp_structure.hpp" -#include "../../../Common/include/tracy_structure.hpp" CDiscAdjSolver::CDiscAdjSolver(CGeometry *geometry, CConfig *config, CSolver *direct_sol, unsigned short Kind_Solver, unsigned short iMesh) : CSolver() { @@ -117,8 +116,6 @@ CDiscAdjSolver::~CDiscAdjSolver() { delete nodes; } void CDiscAdjSolver::SetRecording(CGeometry* geometry, CConfig *config){ - SU2_ZONE_SCOPED_N("SetRecording_Solver"); - const bool time_n1_needed = config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND; const bool time_n_needed = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || time_n1_needed; diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index c25cd73456bd..fb8be3dd8bbe 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -39,9 +39,6 @@ #include "../../include/output/COutput.hpp" #include "../../include/output/CTurboOutput.hpp" -#include "../../../Common/include/tracy_structure.hpp" - - CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh, const bool navier_stokes) : CFVMFlowSolverBase(*geometry, *config) { @@ -8932,8 +8929,6 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CConfig *config, unsigned short marker_flag) { - SU2_ZONE_SCOPED_N("TurboAverageProcess"); - const auto average_process = config->GetKind_AverageProcess(); const auto performance_average_process = config->GetKind_PerformanceAverageProcess(); const auto iZone = config->GetiZone(); @@ -9564,4 +9559,4 @@ void CEulerSolver::ComputeTurboBladePerformance(CGeometry* geometry, CConfig* co TotalPressureLoss = BladePerf->GetTotalPressureLoss(); KineticEnergyLoss = BladePerf->GetKineticEnergyLoss(); } -} +} \ No newline at end of file diff --git a/TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg b/TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg new file mode 100755 index 000000000000..d87f092e6a72 --- /dev/null +++ b/TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg @@ -0,0 +1,211 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: 2D Discrete Adjoint Axial stage % +% Author: J. Kelly % +% Institution: University of Liverpool. % +% Date: Oct 11th, 2025 % +% File Version 8.3.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +MULTIZONE= YES +CONFIG_LIST= (zone_1.cfg, zone_2.cfg) +% +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= RANS +KIND_TURB_MODEL= SST +READ_BINARY_RESTART=NO +RESTART_SOL= NO +% +% -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% +% +MACH_NUMBER= 0.05 +AOA= 0.0 +FREESTREAM_PRESSURE= 140000.0 +FREESTREAM_TEMPERATURE= 300.0 +FREESTREAM_DENSITY= 1.7418 +FREESTREAM_OPTION= TEMPERATURE_FS +FREESTREAM_TURBULENCEINTENSITY = 0.03 +FREESTREAM_TURB2LAMVISCRATIO = 100.0 +INIT_OPTION= TD_CONDITIONS +% +% ---------------------- 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 +REF_DIMENSIONALIZATION= DIMENSIONAL +% +% ------------------------------ EQUATION OF STATE ----------------------------% +% +FLUID_MODEL= IDEAL_GAS +GAMMA_VALUE= 1.4 +GAS_CONSTANT= 287.058 +% +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +VISCOSITY_MODEL= CONSTANT_VISCOSITY +MU_REF= 1.716E-5 +MU_T_REF= 273.15 +SUTHERLAND_CONSTANT= 110.4 +% +% --------------------------- THERMAL CONDUCTIVITY MODEL ----------------------% +% +CONDUCTIVITY_MODEL= CONSTANT_PRANDTL +% +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_HEATFLUX= ( wall1, 0.0, wall2, 0.0) +% +MARKER_PERIODIC= ( periodic1, periodic2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.04463756775, 0.0, periodic3, periodic4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.04463756775, 0.0) +% +%-------- INFLOW/OUTFLOW BOUNDARY CONDITION SPECIFIC FOR TURBOMACHINERY --------% +% +% Inflow and Outflow markers must be specified, for each blade (zone), following the natural groth of the machine (i.e, from the first blade to the last) +MARKER_TURBOMACHINERY= (inflow, outmix, inmix, 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) +% +MARKER_GILES= (inflow, TOTAL_CONDITIONS_PT, 169623.33, 305.76, 1.0, 0.0, 0.0,1.0,1.0, outmix, MIXING_OUT, 0.0, 0.0, 0.0, 0.0, 0.0,1.0,1.0, inmix, MIXING_IN, 0.0, 0.0, 0.0, 0.0, 0.0,1.0, 1.0 outflow, STATIC_PRESSURE, 99741.00, 0.0, 0.0, 0.0, 0.0,1.0,1.0) +% +SPATIAL_FOURIER= YES +% +% +%---------------------------- 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) +AVERAGE_PROCESS_KIND= MIXEDOUT +PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT +MIXEDOUT_COEFF= (1.0, 1.0E-05, 15) +AVERAGE_MACH_LIMIT= 0.05 +% +% ------------------------ SURFACES IDENTIFICATION ----------------------------% +% +MARKER_PLOTTING= wall1, wall2 +MARKER_MONITORING= wall1, wall2 +MARKER_DESIGNING= wall1, wall2 +MARKER_ANALYZE= wall1, wall2 +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +CFL_NUMBER= 10.0 +CFL_ADAPT= NO +CFL_ADAPT_PARAM= ( 1.3, 1.2, 1.0, 10.0) +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= LU_SGS +LINEAR_SOLVER_ERROR= 1E-4 +LINEAR_SOLVER_ITER= 20 +% +% ----------------------- SLOPE LIMITER DEFINITION ----------------------------% +% +VENKAT_LIMITER_COEFF= 0.05 +LIMITER_ITER= 999999 +% +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= ROE +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW= VAN_ALBADA_EDGE +ENTROPY_FIX_COEFF= 0.1 +JST_SENSOR_COEFF= ( 0.5, 0.02 ) +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% +% +CONV_NUM_METHOD_TURB= SCALAR_UPWIND +MUSCL_TURB= NO +SLOPE_LIMITER_TURB= VENKATAKRISHNAN +TIME_DISCRE_TURB= EULER_IMPLICIT +CFL_REDUCTION_TURB= 1.0 +% +% ----------------------- DESIGN VARIABLE PARAMETERS --------------------------% +% +DV_KIND= FFD_CONTROL_POINT_2D, FFD_CONTROL_POINT_2D +DV_MARKER= ( wall1, wall2 ) +DV_PARAM=( STATOR, 0, 0, 1.0, 0.0 ); ( ROTOR, 2, 2, 1.0, 0.0 ) +DV_VALUE=0.0,0.0 +% +% FFD_CONTROL_POINT_2D +DEFINITION_DV= ( 19, 1.0 | wall1 | STATOR, 0, 0, 1.0, 0.0 ); ( 19, 1.0 | wall2 | ROTOR, 2, 2, 1.0, 0.0 ); +% +% ------------------------ GRID DEFORMATION PARAMETERS ------------------------% +% +% Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) +DEFORM_LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (ILU, LU_SGS, JACOBI) +DEFORM_LINEAR_SOLVER_PREC= ILU +% +% Number of smoothing iterations for mesh deformation +DEFORM_LINEAR_SOLVER_ITER= 1000 +% +% Number of nonlinear deformation iterations (surface deformation increments) +DEFORM_NONLINEAR_ITER= 1 +% +% Minimum residual criteria for the linear solver convergence of grid deformation +DEFORM_LINEAR_SOLVER_ERROR= 1E-14 +% +% Print the residuals during mesh deformation to the console (YES, NO) +DEFORM_CONSOLE_OUTPUT= YES +% +% Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, +% WALL_DISTANCE, CONSTANT_STIFFNESS) +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +% +% -------------------- FREE-FORM DEFORMATION PARAMETERS -----------------------% +% +FFD_TOLERANCE= 1E-10 +FFD_ITERATIONS= 500 +FFD_DEFINITION= (STATOR, 0.139, -0.0038, 0.0, 0.186, -0.0567, 0.0, 0.193, -0.031, 0.0, 0.156, 0.010, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); (ROTOR, 0.200, -0.040, 0.0, 0.259, -0.001, 0.0, 0.259, 0.032, 0.0, 0.200, -0.007, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) +FFD_DEGREE= ( 2 , 2 , 0 ); (2, 2, 0) +FFD_CONTINUITY= 2ND_DERIVATIVE +% +% --------------------- OBJECTIVE FUNCTION DEFINITION -----------------------% +% +OBJECTIVE_FUNCTION= ENTROPY_GENERATION +% +% ------------------------- CONVERGENCE PARAMETERS --------------------------% +% +OUTER_ITER= 101 +CONV_RESIDUAL_MINVAL= -16 +CONV_STARTITER= 10 +CONV_CAUCHY_ELEMS= 100 +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], COMBO +HISTORY_OUTPUT= COMBO +MESH_FILENAME= axial_stage_2D.su2 +MESH_FORMAT= SU2 +MESH_OUT_FILENAME= mesh_out.su2 +SOLUTION_FILENAME= solution_flow +SOLUTION_ADJ_FILENAME= solution_adj +TABULAR_FORMAT= CSV +OUTPUT_FILES= RESTART_ASCII, TECPLOT, SURFACE_TECPLOT +CONV_FILENAME= history +RESTART_FILENAME= restart_flow +RESTART_ADJ_FILENAME= restart_adj +VOLUME_FILENAME= flow +VOLUME_ADJ_FILENAME= adjoint +GRAD_OBJFUNC_FILENAME= of_grad.dat +SURFACE_FILENAME= surface_flow +SURFACE_ADJ_FILENAME= surface_adjoint +SURFACE_SENS_FILENAME= surface_sens +WRT_ZONE_CONV= NO +WRT_ZONE_HIST= YES +OUTPUT_PRECISION= 16 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 cf0ee9ff2d80..7e4e90594f51 100644 --- a/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg +++ b/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg @@ -5,7 +5,7 @@ % Author: S. Vitale % % Institution: Delft University of Technology % % Date: 2017.03.01 % -% File Version 8.2.0 "Harrier" % +% File Version 8.3.0 "Harrier" % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 0922b45bde68..33f6ba5bf497 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -234,6 +234,15 @@ def main(): discadj_trans_stator.test_vals_aarch64 = [79, 0.668058, 0.483608, 0.518789, -1.013227] test_list.append(discadj_trans_stator) + # Axial stage 2D + discadj_axial_stage = TestCase('axial_stage_2D') + discadj_axial_stage.cfg_dir = "disc_adj_turbomachinery/axial_stage_2D" + discadj_axial_stage.cfg_file = "Axial_stage2D.cfg" + discadj_axial_stage.test_iter = 79 + discadj_axial_stage.test_vals = [79, 0.668058, 0.483608, 0.518789, -1.013227] + discadj_axial_stage.test_vals_aarch64 = [79, 0.668058, 0.483608, 0.518789, -1.013227] + test_list.append(discadj_axial_stage) + ################################### ### Structural Adjoint ### ################################### From 912aeeaa8b17937ff70983f14844fcc8b58022b2 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sun, 12 Oct 2025 17:38:25 +0100 Subject: [PATCH 09/79] merge issue --- SU2_CFD/include/iteration/CFluidIteration.hpp | 2 +- SU2_CFD/src/iteration/CFluidIteration.cpp | 14 +++++++------- SU2_CFD/src/iteration/CTurboIteration.cpp | 7 +++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index 883540f65ac0..b6ff154273ca 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -115,7 +115,7 @@ class CFluidIteration : public CIteration { * \param[in] iZone - The current zone * \param[in] ramp_flag - Flag indicating type of ramp (grid or boundary) */ - void UpdateRamp(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, RAMP_TYPE ramp_flag); + void UpdateRamps(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, RAMP_TYPE ramp_flag); /*! * \brief Computes turboperformance. diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index d445f3948fbf..0e83b640d6e0 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -226,20 +226,20 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe /*--- Turbomachinery Specific Montior ---*/ if (config[ZONE_0]->GetBoolTurbomachinery()){ if (val_iZone == config[ZONE_0]->GetnZone()-1) { - ComputeTurboPerformance(solver, geometry, config, config[val_iZone]->GetnInner_Iter()); + auto TurbomachineryBladePerformances = GetBladesPerformanceVector(solver, config[val_iZone]->GetnZone()); - output->SetHistoryOutput(geometry, solver, - config, TurbomachineryStagePerformance, TurbomachineryPerformance, val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), - config[val_iZone]->GetInnerIter(), val_iInst); + output->SetHistoryOutput(geometry, solver, config, TurbomachineryStagePerformance, TurbomachineryBladePerformances, + val_iZone, config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), + config[val_iZone]->GetInnerIter(), val_iInst); } /*--- Update ramps, grid first then outlet boundary ---*/ if (config[val_iZone]->GetRampMotionFrame()) - UpdateRamp(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::GRID); + UpdateRamps(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::GRID); } // Outside turbo scope as Riemann boundaries can be ramped (pressure only) if (config[val_iZone]->GetRampOutflow()) - UpdateRamp(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::BOUNDARY); + UpdateRamps(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::BOUNDARY); 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(), @@ -257,7 +257,7 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe return StopCalc; } -void CFluidIteration::UpdateRamp(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, RAMP_TYPE ramp_flag) { +void CFluidIteration::UpdateRamps(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, RAMP_TYPE ramp_flag) { /*--- Generic function for handling ramps ---*/ // Grid updates (i.e. rotation/translation) handled seperately to boundary (i.e. pressure/mass flow) updates auto* config = config_container[iZone]; diff --git a/SU2_CFD/src/iteration/CTurboIteration.cpp b/SU2_CFD/src/iteration/CTurboIteration.cpp index fb064137a01d..1ddd23fdb0e5 100644 --- a/SU2_CFD/src/iteration/CTurboIteration.cpp +++ b/SU2_CFD/src/iteration/CTurboIteration.cpp @@ -40,7 +40,7 @@ void CTurboIteration::Preprocess(COutput* output, CIntegration**** integration, 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); - InitTurboPerformance(geometry[val_iZone][val_iInst][MESH_0], config, solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetFluidModel(), val_iZone); + InitTurboPerformance(geometry[val_iZone][val_iInst][MESH_0], config, solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->GetFluidModel()); } @@ -62,9 +62,8 @@ void CTurboIteration::Postprocess(COutput* output, CIntegration**** integration, solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->ComputeTurboBladePerformance(geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], val_iZone); - UpdateRamps(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone); +} void CTurboIteration::InitTurboPerformance(CGeometry* geometry, CConfig** config, CFluidModel* fluid) { - TurbomachineryPerformance = std::make_shared(config, *geometry, *fluid); - TurbomachineryStagePerformance = std::make_shared(*fluid); + TurbomachineryStagePerformance = std::make_shared(*fluid); } From a0bfb5309311fe1d21bba118ec26463c75153f4b Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sun, 12 Oct 2025 17:45:38 +0100 Subject: [PATCH 10/79] 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 86c21eba26e3..a64d680c1336 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -160,7 +160,6 @@ void CPropellorBladePerformance::ComputePerformance(const CTurbomachineryCombine } CTurboOutput::CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel, unsigned short iBladeRow) { - unsigned short nBladesRow = config[ZONE_0]->GetnMarker_Turbomachinery(); unsigned short nDim = geometry.GetnDim(); vector> bladeSpanPerformances; From 1303145ad1ca6bdac160a1500073b005256e5272 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sun, 12 Oct 2025 18:10:37 +0100 Subject: [PATCH 11/79] Unused var --- SU2_CFD/src/solvers/CEulerSolver.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 1f28fca82f03..5035be44e51b 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -9558,8 +9558,6 @@ void CEulerSolver::GatherInOutAverageValues(CConfig *config, CGeometry *geometry void CEulerSolver::ComputeTurboBladePerformance(CGeometry* geometry, CConfig* config, unsigned short iBlade) { // Computes the turboperformance per blade in zone iBlade const auto nDim = geometry->GetnDim(); - const auto nBladesRow = config->GetnMarker_Turbomachinery(); - const auto nZone = config->GetnZone(); vector TurboPrimitiveIn, TurboPrimitiveOut; if (rank == MASTER_NODE) { /* Blade Primitive initialized per blade */ From 23bf8c3a364db8162cfbbd7e2a48da46cd0ed234 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 10 Nov 2025 09:57:49 +0000 Subject: [PATCH 12/79] Fixes to fluid interface for disc adj + proper recording of turb variables in turbo averaging --- SU2_CFD/src/drivers/CDriver.cpp | 4 +-- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 5 ++- SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 2 ++ SU2_CFD/src/solvers/CEulerSolver.cpp | 34 +++++++++++++++++++- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 038a0bb9b966..346deb34b9c5 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -1275,9 +1275,9 @@ void CDriver::InstantiateTurbulentNumerics(unsigned short nVar_Turb, int offset, numerics[iMGlevel][TURB_SOL][conv_bound_term] = new CUpwSca_TurbSA(nDim, nVar_Turb, config); if (config->GetSAParsedOptions().version == SA_OPTIONS::NEG) { - numerics[iMGlevel][TURB_SOL][visc_bound_term] = new CAvgGrad_TurbSA_Neg(nDim, nVar_Turb, false, config); + numerics[iMGlevel][TURB_SOL][visc_bound_term] = new CAvgGrad_TurbSA_Neg(nDim, nVar_Turb, true, config); } else { - numerics[iMGlevel][TURB_SOL][visc_bound_term] = new CAvgGrad_TurbSA(nDim, nVar_Turb, false, config); + numerics[iMGlevel][TURB_SOL][visc_bound_term] = new CAvgGrad_TurbSA(nDim, nVar_Turb, true, config); } } else if (menter_sst) { diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 27429ede9b09..4e1a87aebdf8 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -557,7 +557,10 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar /*--- Additional transfer for turbulence variables. ---*/ if (config_container[targetZone]->GetKind_Solver() == MAIN_SOLVER::RANS || - config_container[targetZone]->GetKind_Solver() == MAIN_SOLVER::INC_RANS) { + config_container[targetZone]->GetKind_Solver() == MAIN_SOLVER::INC_RANS || + config_container[targetZone]->GetKind_Solver() == MAIN_SOLVER::DISC_ADJ_RANS || + config_container[targetZone]->GetKind_Solver() == MAIN_SOLVER::DISC_ADJ_INC_RANS + ) { BroadcastData(TURB_SOL, TURB_SOL); } diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index ed833df16a2f..4c4341dfe21f 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -481,6 +481,8 @@ CNumerics::ResidualType<> CAvgGrad_Flow::ComputeResidual(const CConfig* config) } AD::SetPreaccOut(Proj_Flux_Tensor, nVar); + AD::SetPreaccOut(Jacobian_i, nVar, nVar); + AD::SetPreaccOut(Jacobian_j, nVar, nVar); AD::EndPreacc(); return ResidualType<>(Proj_Flux_Tensor, Jacobian_i, Jacobian_j); diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 5035be44e51b..5354277c190a 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -8816,11 +8816,16 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon const auto nSpanWiseSections = config->GetnSpanWiseSections(); const auto iZone = config->GetiZone(); + const bool spalart_allmaras = (config->GetKind_Turb_Model() == TURB_MODEL::SA); + const bool menter_sst = (config->GetKind_Turb_Model() == TURB_MODEL::SST); for (auto iSpan= 0u; iSpan < nSpanWiseSections; iSpan++){ su2double TotalAreaVelocity[MAXNDIM]={0.0}, TotalAreaPressure{0}, - TotalAreaDensity{0}; + TotalAreaDensity{0}, + TotalAreaNu{0}, + TotalAreaKine{0}, + TotalAreaOmega{0}; for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++){ for (auto iMarkerTP=1; iMarkerTP < config->GetnMarker_Turbomachinery()+1; iMarkerTP++){ if (config->GetMarker_All_Turbomachinery(iMarker) == iMarkerTP){ @@ -8837,6 +8842,16 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon auto Pressure = nodes->GetPressure(iPoint); auto Density = nodes->GetDensity(iPoint); + /*--- This is in Euler, however we also need to average the turbulent variables so we do it here too ---*/ + su2double Kine{0}, Omega{0}, Nu{0}; + if(menter_sst){ + Kine = solver[TURB_SOL]->GetNodes()->GetSolution(iPoint,0); + Omega = solver[TURB_SOL]->GetNodes()->GetSolution(iPoint,1); + } + if(spalart_allmaras){ + Nu = solver[TURB_SOL]->GetNodes()->GetSolution(iPoint,0); + } + su2double UnitNormal[MAXNDIM]={0}, TurboNormal[MAXNDIM]={0}, TurboVelocity[MAXNDIM], @@ -8857,6 +8872,9 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon TotalAreaDensity += Area*Density; for (auto iDim = 0u; iDim < nDim; iDim++) TotalAreaVelocity[iDim] += Area*Velocity[iDim]; + TotalAreaNu += Area*Nu; + TotalAreaKine += Area*Kine; + TotalAreaOmega += Area*Omega; } } } @@ -8870,9 +8888,15 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon su2double MyTotalAreaDensity = TotalAreaDensity; su2double MyTotalAreaPressure = TotalAreaPressure; + su2double MyTotalAreaNu = TotalAreaNu; + su2double MyTotalAreaKine = TotalAreaKine; + su2double MyTotalAreaOmega = TotalAreaOmega; SU2_MPI::Allreduce(&MyTotalAreaDensity, &TotalAreaDensity, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); SU2_MPI::Allreduce(&MyTotalAreaPressure, &TotalAreaPressure, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&MyTotalAreaNu, &TotalAreaNu, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&MyTotalAreaKine, &TotalAreaKine, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&MyTotalAreaOmega, &TotalAreaOmega, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); auto* MyTotalAreaVelocity = new su2double[nDim]; @@ -8904,6 +8928,10 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon for (auto iDim = 0u; iDim < nDim; iDim++) AverageVelocity[iMarker][iSpan][iDim] = TotalAreaVelocity[iDim] / TotalArea; + AverageNu[iMarker][iSpan] = TotalAreaNu / TotalArea; + AverageKine[iMarker][iSpan] = TotalAreaKine / TotalArea; + AverageOmega[iMarker][iSpan] = TotalAreaOmega / TotalArea; + /* --- compute static averaged quantities ---*/ ComputeTurboVelocity(AverageVelocity[iMarker][iSpan], AverageTurboNormal , AverageTurboVelocity[iMarker][iSpan], marker_flag, config->GetKind_TurboMachinery(iZone)); @@ -8934,6 +8962,10 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon for (auto iDim = 0u; iDim < nDim; iDim++) AverageVelocity[iMarker][nSpanWiseSections][iDim] = AverageVelocity[iMarker][nSpanWiseSections/2][iDim]; + AverageNu[iMarker][nSpanWiseSections] = AverageNu[iMarker][nSpanWiseSections/2]; + AverageKine[iMarker][nSpanWiseSections] = AverageKine[iMarker][nSpanWiseSections/2]; + AverageOmega[iMarker][nSpanWiseSections] = AverageOmega[iMarker][nSpanWiseSections/2]; + /* --- compute static averaged quantities ---*/ ComputeTurboVelocity(AverageVelocity[iMarker][nSpanWiseSections], AverageTurboNormal , AverageTurboVelocity[iMarker][nSpanWiseSections], marker_flag, config->GetKind_TurboMachinery(iZone)); From af78550377389345e1f804966bfeac2ec0d40a5b Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 13 Nov 2025 02:11:32 +0000 Subject: [PATCH 13/79] Initial reformat of mixing plane implementation --- .../interface_interpolation/CInterpolator.hpp | 15 + .../CInterpolatorFactory.hpp | 2 +- .../interface_interpolation/CMixingPlane.hpp | 43 +++ .../CInterpolatorFactory.cpp | 60 ++-- .../interface_interpolation/CMixingPlane.cpp | 172 ++++++++++++ .../src/interface_interpolation/meson.build | 3 +- SU2_CFD/include/drivers/CDriver.hpp | 3 + SU2_CFD/include/interfaces/CInterface.hpp | 21 ++ .../interfaces/cfd/CMixingPlaneInterface.hpp | 30 ++ .../numerics/scalar/scalar_diffusion.hpp | 2 + SU2_CFD/include/solvers/CEulerSolver.hpp | 262 +++++++++++------- SU2_CFD/include/solvers/CSolver.hpp | 189 ++++++++----- SU2_CFD/src/drivers/CDriver.cpp | 37 ++- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 26 +- SU2_CFD/src/interfaces/CInterface.cpp | 1 - .../interfaces/cfd/CMixingPlaneInterface.cpp | 167 ++++++++--- SU2_CFD/src/solvers/CEulerSolver.cpp | 94 +++++-- SU2_CFD/src/solvers/CTurbSASolver.cpp | 5 +- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 7 +- 19 files changed, 862 insertions(+), 277 deletions(-) create mode 100644 Common/include/interface_interpolation/CMixingPlane.hpp create mode 100644 Common/src/interface_interpolation/CMixingPlane.cpp diff --git a/Common/include/interface_interpolation/CInterpolator.hpp b/Common/include/interface_interpolation/CInterpolator.hpp index ae8535540853..dd4f54ed1a4a 100644 --- a/Common/include/interface_interpolation/CInterpolator.hpp +++ b/Common/include/interface_interpolation/CInterpolator.hpp @@ -101,6 +101,21 @@ class CInterpolator { }; vector > targetVertices; /*! \brief Donor information per marker per vertex of the target. */ + struct CSpanDonorInfo { + vector processor; + vector globalSpan; + vector coefficient; + + unsigned long nDonor() const { return processor.size(); } + + void resize(size_t nDonor) { + processor.resize(nDonor); + globalSpan.resize(nDonor); // Refers to the donor span + coefficient.resize(nDonor); // Refers to the coefficient + } + }; + vector targetSpans; + /*! * \brief Constructor of the class. * \param[in] geometry_container - Geometrical definition of the problem. diff --git a/Common/include/interface_interpolation/CInterpolatorFactory.hpp b/Common/include/interface_interpolation/CInterpolatorFactory.hpp index 63c5eaf23e2e..89172dc40e58 100644 --- a/Common/include/interface_interpolation/CInterpolatorFactory.hpp +++ b/Common/include/interface_interpolation/CInterpolatorFactory.hpp @@ -43,5 +43,5 @@ namespace CInterpolatorFactory { */ CInterpolator* CreateInterpolator(CGeometry**** geometry_container, const CConfig* const* config, const CInterpolator* transpInterpolator, unsigned iZone, unsigned jZone, - bool verbose = true); + bool mixing_plane, bool verbose = true); } // namespace CInterpolatorFactory diff --git a/Common/include/interface_interpolation/CMixingPlane.hpp b/Common/include/interface_interpolation/CMixingPlane.hpp new file mode 100644 index 000000000000..e396de0fd841 --- /dev/null +++ b/Common/include/interface_interpolation/CMixingPlane.hpp @@ -0,0 +1,43 @@ +/*! + * \file CMixingPlane.hpp + * \brief Header of mixing plane interpolation methods. + * \author J. Kelly + * \version 8.3.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2025, 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 "CInterpolator.hpp" + +/*! + * \brief Mixing plane interpolation. + * \note This contains several interpolation methods used in the mixing plane interpolation + * and enables the mixing state class structure for proper recording in AD mode + * \ingroup Interfaces + */ +class CMixingPlane final : public CInterpolator { + public: + CMixingPlane(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, + unsigned int jZone); + + void SetTransferCoeff(const CConfig* const* config) override; +}; \ No newline at end of file diff --git a/Common/src/interface_interpolation/CInterpolatorFactory.cpp b/Common/src/interface_interpolation/CInterpolatorFactory.cpp index f1e1490b8d9c..fc816c8efc92 100644 --- a/Common/src/interface_interpolation/CInterpolatorFactory.cpp +++ b/Common/src/interface_interpolation/CInterpolatorFactory.cpp @@ -32,11 +32,12 @@ #include "../../include/interface_interpolation/CNearestNeighbor.hpp" #include "../../include/interface_interpolation/CRadialBasisFunction.hpp" #include "../../include/interface_interpolation/CSlidingMesh.hpp" +#include "../../include/interface_interpolation/CMixingPlane.hpp" namespace CInterpolatorFactory { CInterpolator* CreateInterpolator(CGeometry**** geometry_container, const CConfig* const* config, const CInterpolator* transpInterpolator, unsigned iZone, unsigned jZone, - bool verbose) { + bool mixing_plane, bool verbose) { CInterpolator* interpolator = nullptr; /*--- Only print information on master node. ---*/ @@ -47,36 +48,41 @@ CInterpolator* CreateInterpolator(CGeometry**** geometry_container, const CConfi if (verbose) cout << " Setting coupling "; - /*--- Conservative interpolation is not applicable to the sliding - * mesh approach so that case is handled first. Then we either - * return a CMirror if the target requires conservative inter- - * polation, or the type of interpolator defined by "type". ---*/ + if (mixing_plane) { + if (verbose) cout << "using a mixing plane interpolation." << endl; + interpolator = new CMixingPlane(geometry_container, config, iZone, jZone); + } else { // Really awful thing to do + /*--- Conservative interpolation is not applicable to the sliding + * mesh approach so that case is handled first. Then we either + * return a CMirror if the target requires conservative inter- + * polation, or the type of interpolator defined by "type". ---*/ - if (type == INTERFACE_INTERPOLATOR::WEIGHTED_AVERAGE) { - if (verbose) cout << "using a sliding mesh approach." << endl; - interpolator = new CSlidingMesh(geometry_container, config, iZone, jZone); - } else if (config[jZone]->GetConservativeInterpolation()) { - if (verbose) cout << "using the mirror approach, \"transposing\" coefficients from opposite mesh." << endl; - interpolator = new CMirror(geometry_container, config, transpInterpolator, iZone, jZone); - } else { - switch (type) { - case INTERFACE_INTERPOLATOR::ISOPARAMETRIC: - if (verbose) cout << "using the isoparametric approach." << endl; - interpolator = new CIsoparametric(geometry_container, config, iZone, jZone); - break; + if (type == INTERFACE_INTERPOLATOR::WEIGHTED_AVERAGE) { + if (verbose) cout << "using a sliding mesh approach." << endl; + interpolator = new CSlidingMesh(geometry_container, config, iZone, jZone); + } else if (config[jZone]->GetConservativeInterpolation()) { + if (verbose) cout << "using the mirror approach, \"transposing\" coefficients from opposite mesh." << endl; + interpolator = new CMirror(geometry_container, config, transpInterpolator, iZone, jZone); + } else { + switch (type) { + case INTERFACE_INTERPOLATOR::ISOPARAMETRIC: + if (verbose) cout << "using the isoparametric approach." << endl; + interpolator = new CIsoparametric(geometry_container, config, iZone, jZone); + break; - case INTERFACE_INTERPOLATOR::NEAREST_NEIGHBOR: - if (verbose) cout << "using a nearest neighbor approach." << endl; - interpolator = new CNearestNeighbor(geometry_container, config, iZone, jZone); - break; + case INTERFACE_INTERPOLATOR::NEAREST_NEIGHBOR: + if (verbose) cout << "using a nearest neighbor approach." << endl; + interpolator = new CNearestNeighbor(geometry_container, config, iZone, jZone); + break; - case INTERFACE_INTERPOLATOR::RADIAL_BASIS_FUNCTION: - if (verbose) cout << "using a radial basis function approach." << endl; - interpolator = new CRadialBasisFunction(geometry_container, config, iZone, jZone); - break; + case INTERFACE_INTERPOLATOR::RADIAL_BASIS_FUNCTION: + if (verbose) cout << "using a radial basis function approach." << endl; + interpolator = new CRadialBasisFunction(geometry_container, config, iZone, jZone); + break; - default: - SU2_MPI::Error("Unknown type of interpolation.", CURRENT_FUNCTION); + default: + SU2_MPI::Error("Unknown type of interpolation.", CURRENT_FUNCTION); + } } } diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp new file mode 100644 index 000000000000..158f1bce78ea --- /dev/null +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -0,0 +1,172 @@ +/*! + * \file CMixingPlane.cpp + * \brief Implementation of mixing plane interpolation methods. + * \author J. Kelly + * \version 8.3.0 "Harrier" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2025, 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/interface_interpolation/CMixingPlane.hpp" +#include "../../include/CConfig.hpp" +#include "../../include/geometry/CGeometry.hpp" +#include "../../include/toolboxes/geometry_toolbox.hpp" + +CMixingPlane::CMixingPlane(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, + unsigned int jZone) + : CInterpolator(geometry_container, config, iZone, jZone) { + SetTransferCoeff(config); +} + +void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { + const auto nMarkerInt = config[donorZone]->GetnMarker_MixingPlaneInterface() / 2; + const auto nDim = donor_geometry->GetnDim(); + + const auto donor_config = config[donorZone]; + const auto target_config = config[targetZone]; + + const auto nMarkerDonor = donor_geometry->GetnMarker(); // Number of markers on the interfacce + const auto nMarkerTarget = target_geometry->GetnMarker(); + //TODO turbo this approach only works if all the turboamchinery marker + // of all zones have the same amount of span wise sections. + //TODO turbo initialization needed for the MPI routine should be place somewhere else. + auto nSpanDonor = donor_config->GetnSpanWiseSections(); + auto nSpanTarget = target_config->GetnSpanWiseSections(); + + targetSpans.resize(nMarkerInt); + + /*--- On the donor side ---*/ + for (auto iMarkerInt = 0u; iMarkerInt < nMarkerInt; iMarkerInt++){ + const auto markDonor = donor_config->FindInterfaceMarker(iMarkerInt); + const auto markTarget = target_config->FindInterfaceMarker(iMarkerInt); + + // Spans are defined on one processor only, check to see if other processors have interface +#ifdef HAVE_MPI + auto buffMarkDonor = new int[size]; + auto buffMarkTarget = new int[size]; + for (int iSize = 0; iSizeGetnSpanWiseSections(); + if (markTarget != -1) nSpanTarget = target_config->GetnSpanWiseSections(); + + if (nSpanTarget) targetSpans[markTarget].resize(nSpanTarget); + + const auto spanValuesDonor = donor_geometry->GetSpanWiseValue(markDonor); + const auto spanValuesTarget = target_geometry->GetSpanWiseValue(markTarget); + + /*--- Interpolation of values at hub & shroud ---*/ + targetSpans[iMarkerInt].globalSpan[0] = 0; + targetSpans[iMarkerInt].coefficient[0] = 0.0; + targetSpans[iMarkerInt].globalSpan[nSpanTarget] = nSpanTarget; + targetSpans[iMarkerInt].coefficient[nSpanTarget] = 0.0; + + for(auto iSpanTarget = 1; iSpanTarget < nSpanTarget - 2; iSpanTarget++){ + auto tSpan = 0; // Nearest donor span index + auto kSpan = 0; // Lower bound donor span for interpolation + su2double coeff = 0.0; // Interpolation coefficient + su2double minDist = 10E+06; + + switch(donor_config->GetKind_MixingPlaneInterface()){ + case MATCHING: + targetSpans[iMarkerInt].globalSpan[iSpanTarget] = iSpanTarget; + targetSpans[iMarkerInt].coefficient[iSpanTarget] = 0.0; + break; + + case NEAREST_SPAN: + // Find the nearest donor span + for (auto iSpanDonor = 0; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { + const auto dist = abs(spanValuesTarget[iSpanTarget] - spanValuesDonor[iSpanDonor]); + if(dist < minDist){ + minDist = dist; + tSpan = iSpanDonor; + } + } + targetSpans[iMarkerInt].globalSpan[iSpanTarget] = tSpan; + targetSpans[iMarkerInt].coefficient[iSpanTarget] = 0.0; + break; + + case LINEAR_INTERPOLATION: + // Find the donor span interval that brackets the target span + for (auto iSpanDonor = 1; iSpanDonor < nSpanDonor - 2; iSpanDonor++) { + if(spanValuesTarget[iSpanTarget] >= spanValuesDonor[iSpanDonor] && + spanValuesTarget[iSpanTarget] <= spanValuesDonor[iSpanDonor + 1]){ + kSpan = iSpanDonor; + break; + } + } + // Calculate interpolation coefficient + coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan]) / + (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); + targetSpans[iMarkerInt].globalSpan[iSpanTarget] = kSpan; + targetSpans[iMarkerInt].coefficient[iSpanTarget] = coeff; + break; + + default: + SU2_MPI::Error("MixingPlane interface option not implemented yet", CURRENT_FUNCTION); + break; + } + + + // for (auto iSpanDonor = 1; iSpanDonor < nSpanDonor - 2; iSpanDonor++) { + // const auto test = abs(SpanValuesTarget[iSpanTarget] - SpanValuesDonor[iSpanDonor]); + // const auto test2 = abs(SpanValuesTarget[iSpanTarget] - SpanValuesDonor[iSpanDonor]); + // if(test < dist && SpanValuesTarget[iSpanTarget] > SpanValuesDonor[iSpanDonor]){ + // dist = test; + // kSpan = iSpanDonor; + // } + // if(test2 < dist2){ + // dist2 = test2; + // tSpan = iSpanDonor; + // } + // } + // switch(donor_config->GetKind_MixingPlaneInterface()){ + // case MATCHING: + // targetSpans.globalSpan[iSpanTarget] = iSpanTarget; + // targetSpans.coefficent[iSpanTarget] = 0.0; + // break; + // case NEAREST_SPAN: + // targetSpans.globalSpan[iSpanTarget] = tSpan; + // targetSpans.coefficent[iSpanTarget] = 0.0; + // break; + // case LINEAR_INTERPOLATION: + // targetSpans.globalSpan[iSpanTarget] = kSpan; + // targetSpans.coefficent[iSpanTarget] = (SpanValuesTarget[iSpanTarget] - SpanValuesDonor[kSpan]) + // /(SpanValuesDonor[kSpan + 1] - SpanValuesDonor[kSpan]); + // break; + // default: + // SU2_MPI::Error("MixingPlane interface option not implemented yet", CURRENT_FUNCTION); + // break; + // } + } +} +} \ No newline at end of file diff --git a/Common/src/interface_interpolation/meson.build b/Common/src/interface_interpolation/meson.build index 8624b3ad4fa8..6cd185ef873c 100644 --- a/Common/src/interface_interpolation/meson.build +++ b/Common/src/interface_interpolation/meson.build @@ -4,4 +4,5 @@ common_src += files(['CInterpolatorFactory.cpp', 'CSlidingMesh.cpp', 'CIsoparametric.cpp', 'CNearestNeighbor.cpp', - 'CRadialBasisFunction.cpp']) + 'CRadialBasisFunction.cpp', + 'CMixingPlane.cpp']) diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index da73aa177319..7b4eb7946167 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -296,6 +296,9 @@ class CDriver : public CDriverBase { void PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, CSolver***** solver, CInterface*** interface, CIteration*** iteration, bool dummy); + void PreprocessTurboVertex(CConfig** config, CGeometry**** geometry, CSolver***** solver, + CInterface*** interface, CIteration*** iteration, bool dummy); + /*! * \brief A virtual member. * \param[in] donorZone - zone in which the displacements will be predicted. diff --git a/SU2_CFD/include/interfaces/CInterface.hpp b/SU2_CFD/include/interfaces/CInterface.hpp index d0c942b43d78..5b17b9dbf8b7 100644 --- a/SU2_CFD/include/interfaces/CInterface.hpp +++ b/SU2_CFD/include/interfaces/CInterface.hpp @@ -148,6 +148,12 @@ class CInterface { for (auto iVar = 0u; iVar < nVar; iVar++) Target_Variable[iVar] += donorCoeff * bcastVariable[iVar]; } + inline virtual void RecoverTarget_Variable(const su2double *bcastVariable) { } + + inline virtual void RecoverTarget_Variable(const su2double *bcastVariable, const su2double *next_bcastVariable, su2double donorCoeff) { } + + + /*! * \brief A virtual member. * \param[in] target_solution - Solution from the target mesh. @@ -187,6 +193,21 @@ class CInterface { inline virtual void SetAverageValues(CSolver *donor_solution, CSolver *target_solution, unsigned short donorZone) { } + /*! + * \brief Interpolate data and broadcast it into all processors, for nonmatching meshes. + * \param[in] interpolator - Object defining the interpolation. + * \param[in] donor_solution - Solution from the donor mesh. + * \param[in] target_solution - Solution from the target mesh. + * \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. + */ + inline virtual void BroadcastData_MixingPlane(const CInterpolator& interpolator, + CSolver *donor_solution, CSolver *target_solution, + CGeometry *donor_geometry, CGeometry *target_geometry, + const CConfig *donor_config, const CConfig *target_config) { }; + /*! * \brief Transfer pre-processing for the mixing plane inteface. * \param[in] donor_geometry - Geometry of the donor mesh. diff --git a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp index 2abd9be5d600..ff01e68a1c34 100644 --- a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp +++ b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp @@ -49,6 +49,21 @@ class CMixingPlaneInterface : public CInterface { */ void SetSpanWiseLevels(const CConfig *donor_config, const CConfig *target_config) override; + /*! + * \brief Interpolate data and broadcast it into all processors, for nonmatching meshes. + * \param[in] interpolator - Object defining the interpolation. + * \param[in] donor_solution - Solution from the donor mesh. + * \param[in] target_solution - Solution from the target mesh. + * \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 BroadcastData_MixingPlane(const CInterpolator& interpolator, + CSolver *donor_solution, CSolver *target_solution, + CGeometry *donor_geometry, CGeometry *target_geometry, + const CConfig *donor_config, const CConfig *target_config) override; + /*! * \brief Retrieve the variable that will be sent from donor mesh to target mesh. * \param[in] donor_solution - Solution from the donor mesh. @@ -61,6 +76,9 @@ class CMixingPlaneInterface : public CInterface { void GetDonor_Variable(CSolver *donor_solution, CGeometry *donor_geometry, const CConfig *donor_config, unsigned long Marker_Donor, unsigned long val_Span, unsigned long Point_Donor) override; + void InitializeTarget_Variable(CSolver *target_solution, unsigned long Marker_Target, + unsigned long Span_Target, unsigned short nDonorPoints) override; + /*! * \brief Set the variable that has been received from the target mesh into the target mesh. * \param[in] target_solution - Solution from the target mesh. @@ -73,6 +91,18 @@ class CMixingPlaneInterface : public CInterface { void SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry, const CConfig *target_config, unsigned long Marker_Target, unsigned long val_Span, unsigned long Point_Target) override; + inline void RecoverTarget_Variable(const su2double *bcastVariable) override{ + for (auto iVar = 0u; iVar < 8; iVar++) { + Target_Variable[iVar] = bcastVariable[iVar]; + } + } + + inline void RecoverTarget_Variable(const su2double *bcastVariable, const su2double *next_bcastVariable, su2double donorCoeff) override { + for (auto iVar = 0u; iVar < 8; iVar++) { + Target_Variable[iVar] = (1 - donorCoeff)*bcastVariable[iVar] + donorCoeff * next_bcastVariable[iVar]; + } + } + /*! * \brief Store all the turboperformance in the solver in ZONE_0. * \param[in] donor_solution - Solution from the donor mesh. diff --git a/SU2_CFD/include/numerics/scalar/scalar_diffusion.hpp b/SU2_CFD/include/numerics/scalar/scalar_diffusion.hpp index 13ee01f7eda6..d79108704b1d 100644 --- a/SU2_CFD/include/numerics/scalar/scalar_diffusion.hpp +++ b/SU2_CFD/include/numerics/scalar/scalar_diffusion.hpp @@ -148,6 +148,8 @@ class CAvgGrad_Scalar : public CNumerics { FinishResidualCalc(config); AD::SetPreaccOut(Flux, nVar); + AD::SetPreaccOut(Jacobian_i, nVar, nVar); + AD::SetPreaccOut(Jacobian_j, nVar, nVar); AD::EndPreacc(); return ResidualType<>(Flux, Jacobian_i, Jacobian_j); diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 6d33286f4533..d7a584dcc485 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -124,20 +124,20 @@ class CEulerSolver : public CFVMFlowSolverBase AverageVelocity; vector AverageTurboVelocity; vector OldAverageTurboVelocity; - vector ExtAverageTurboVelocity; + // vector ExtAverageTurboVelocity; su2activematrix AveragePressure; su2activematrix OldAveragePressure; su2activematrix RadialEquilibriumPressure; - su2activematrix ExtAveragePressure; + // su2activematrix ExtAveragePressure; su2activematrix AverageDensity; su2activematrix OldAverageDensity; - su2activematrix ExtAverageDensity; + // su2activematrix ExtAverageDensity; su2activematrix AverageNu; su2activematrix AverageKine; su2activematrix AverageOmega; - su2activematrix ExtAverageNu; - su2activematrix ExtAverageKine; - su2activematrix ExtAverageOmega; + // su2activematrix ExtAverageNu; + // su2activematrix ExtAverageKine; + // su2activematrix ExtAverageOmega; su2activevector AverageMassFlowRate; su2activematrix DensityIn; @@ -161,6 +161,70 @@ class CEulerSolver : public CFVMFlowSolverBase> MixingState; // vector of vector of pointers... inner dim alloc'd elsewhere (welcome, to the night zone) + vector> MixingStateNodes; + + /*! + * \brief Get the outer state for mixing plane interface nodes. + * \param[in] val_marker - marker index + * \param[in] val_span - vertex index + * \param[in] val_state - requested state component + // * \param[in] donor_index- index of the donor node to get + */ + inline su2double GetMixingState(unsigned short val_marker, + unsigned long val_span, + unsigned short val_state + // unsigned long donor_index + ) const final { + return MixingState[val_marker][val_span][val_state]; + } + + /*! + * \brief Allocates the final pointer of MixingState depending on how many donor spans donate to it. That number is stored in MixingStateSpans[val_marker][val_Span]. + * \param[in] val_marker - marker index + * \param[in] val_span - vertex index + */ + inline void SetMixingStateStructure(unsigned short val_marker, unsigned long val_span) final { + if( MixingState[val_marker][val_span] != nullptr ) delete [] MixingState[val_marker][val_span]; + + for( int iVar = 0; iVar < 8; iVar++) MixingState[val_marker][val_span] = new su2double[iVar]; + } + + /*! + * \brief Set the outer state for mixing plane interface nodes. + * \param[in] val_marker - marker index + * \param[in] val_span - vertex index + * \param[in] val_state - requested state component + // * \param[in] donor_index - index of the donor node to set + * \param[in] component - set value + */ + inline void SetMixingState(unsigned short val_marker, + unsigned long val_span, + unsigned short val_state, + // unsigned long donor_index, + su2double component) final { + MixingState[val_marker][val_span][val_state] = component; + } + + /*! + * \brief Set the number of outer state for mixing plane interface nodes. + * \param[in] val_marker - marker index + * \param[in] val_span - vertex index + * \param[in] value - number of outer states + */ + inline void SetnMixingStates(unsigned short val_marker, + unsigned long val_span, + int value) final { MixingStateNodes[val_marker][val_span] = value; } + + /*! + * \brief Get the number of outer state for mixing plane interface nodes. + * \param[in] val_marker - marker index + * \param[in] val_vertex - vertex index + */ + inline int GetnMixingStates(unsigned short val_marker, unsigned long val_span) const final { + return MixingStateNodes[val_marker][val_span]; + } + /*! * \brief Preprocessing actions common to the Euler and NS solvers. * \param[in] geometry - Geometrical definition of the problem. @@ -1272,99 +1336,99 @@ class CEulerSolver : public CFVMFlowSolverBaseval_marker. */ - inline su2double GetExtAverageNu(unsigned short valMarker, unsigned short valSpan) const final { - return ExtAverageNu[valMarker][valSpan]; - } - - /*! - * \brief Provide the average density at the boundary of interest. - * \param[in] val_marker - bound marker. - * \return Value of the Average turbulent Kine on the surface val_marker. - */ - inline su2double GetExtAverageKine(unsigned short valMarker, unsigned short valSpan) const final { - return ExtAverageKine[valMarker][valSpan]; - } - - /*! - * \brief Provide the average density at the boundary of interest. - * \param[in] val_marker - bound marker. - * \return Value of the Average turbulent Omega on the surface val_marker. - */ - inline su2double GetExtAverageOmega(unsigned short valMarker, unsigned short valSpan) const final { - return ExtAverageOmega[valMarker][valSpan]; - } - - /*! - * \brief Set the external average density at the boundary of interest. - * \param[in] val_marker - bound marker. - * \param[in] val_Span - value of the Span. - * \param[in] valDensity - value to set. - */ - inline void SetExtAverageDensity(unsigned short valMarker, - unsigned short valSpan, - su2double valDensity) final { - ExtAverageDensity[valMarker][valSpan] = valDensity; - } - - /*! - * \brief Set the external average density at the boundary of interest. - * \param[in] val_marker - bound marker. - * \param[in] val_Span - value of the Span. - * \param[in] valPressure - value to set. - */ - inline void SetExtAveragePressure(unsigned short valMarker, - unsigned short valSpan, - su2double valPressure) final { - ExtAveragePressure[valMarker][valSpan] = valPressure; - } - - /*! - * \brief Set the external the average turbo velocity average at the boundary of interest. - * \param[in] val_marker - bound marker. - * \return Value of the Average Total Pressure on the surface val_marker. - */ - inline void SetExtAverageTurboVelocity(unsigned short valMarker, - unsigned short valSpan, - unsigned short valIndex, - su2double valTurboVelocity) final { - ExtAverageTurboVelocity[valMarker][valSpan][valIndex] = valTurboVelocity; - } - - /*! - * \brief Set the external average turbulent Nu at the boundary of interest. - * \param[in] val_marker - bound marker. - * \param[in] val_Span - value of the Span. - * \param[in] valNu - value to set. - */ - inline void SetExtAverageNu(unsigned short valMarker, - unsigned short valSpan, - su2double valNu) final { - ExtAverageNu[valMarker][valSpan] = valNu; - } - - /*! - * \brief Set the external average turbulent Kine at the boundary of interest. - * \param[in] val_marker - bound marker. - * \param[in] val_Span - value of the Span. - * \param[in] valKine - value to set. - */ - inline void SetExtAverageKine(unsigned short valMarker, - unsigned short valSpan, - su2double valKine) final { - ExtAverageKine[valMarker][valSpan] = valKine; - } - - /*! - * \brief Set the external average turbulent Omega at the boundary of interest. - * \param[in] val_marker - bound marker. - * \param[in] val_Span - value of the Span. - * \param[in] valOmega - value to set. - */ - inline void SetExtAverageOmega(unsigned short valMarker, - unsigned short valSpan, - su2double valOmega) final { - ExtAverageOmega[valMarker][valSpan] = valOmega; - } + // inline su2double GetExtAverageNu(unsigned short valMarker, unsigned short valSpan) const final { + // return ExtAverageNu[valMarker][valSpan]; + // } + + // /*! + // * \brief Provide the average density at the boundary of interest. + // * \param[in] val_marker - bound marker. + // * \return Value of the Average turbulent Kine on the surface val_marker. + // */ + // inline su2double GetExtAverageKine(unsigned short valMarker, unsigned short valSpan) const final { + // return ExtAverageKine[valMarker][valSpan]; + // } + + // /*! + // * \brief Provide the average density at the boundary of interest. + // * \param[in] val_marker - bound marker. + // * \return Value of the Average turbulent Omega on the surface val_marker. + // */ + // inline su2double GetExtAverageOmega(unsigned short valMarker, unsigned short valSpan) const final { + // return ExtAverageOmega[valMarker][valSpan]; + // } + + // /*! + // * \brief Set the external average density at the boundary of interest. + // * \param[in] val_marker - bound marker. + // * \param[in] val_Span - value of the Span. + // * \param[in] valDensity - value to set. + // */ + // inline void SetExtAverageDensity(unsigned short valMarker, + // unsigned short valSpan, + // su2double valDensity) final { + // ExtAverageDensity[valMarker][valSpan] = valDensity; + // } + + // /*! + // * \brief Set the external average density at the boundary of interest. + // * \param[in] val_marker - bound marker. + // * \param[in] val_Span - value of the Span. + // * \param[in] valPressure - value to set. + // */ + // inline void SetExtAveragePressure(unsigned short valMarker, + // unsigned short valSpan, + // su2double valPressure) final { + // ExtAveragePressure[valMarker][valSpan] = valPressure; + // } + + // /*! + // * \brief Set the external the average turbo velocity average at the boundary of interest. + // * \param[in] val_marker - bound marker. + // * \return Value of the Average Total Pressure on the surface val_marker. + // */ + // inline void SetExtAverageTurboVelocity(unsigned short valMarker, + // unsigned short valSpan, + // unsigned short valIndex, + // su2double valTurboVelocity) final { + // ExtAverageTurboVelocity[valMarker][valSpan][valIndex] = valTurboVelocity; + // } + + // /*! + // * \brief Set the external average turbulent Nu at the boundary of interest. + // * \param[in] val_marker - bound marker. + // * \param[in] val_Span - value of the Span. + // * \param[in] valNu - value to set. + // */ + // inline void SetExtAverageNu(unsigned short valMarker, + // unsigned short valSpan, + // su2double valNu) final { + // ExtAverageNu[valMarker][valSpan] = valNu; + // } + + // /*! + // * \brief Set the external average turbulent Kine at the boundary of interest. + // * \param[in] val_marker - bound marker. + // * \param[in] val_Span - value of the Span. + // * \param[in] valKine - value to set. + // */ + // inline void SetExtAverageKine(unsigned short valMarker, + // unsigned short valSpan, + // su2double valKine) final { + // ExtAverageKine[valMarker][valSpan] = valKine; + // } + + // /*! + // * \brief Set the external average turbulent Omega at the boundary of interest. + // * \param[in] val_marker - bound marker. + // * \param[in] val_Span - value of the Span. + // * \param[in] valOmega - value to set. + // */ + // inline void SetExtAverageOmega(unsigned short valMarker, + // unsigned short valSpan, + // su2double valOmega) final { + // ExtAverageOmega[valMarker][valSpan] = valOmega; + // } /*! * \brief Provide the inlet density to check convergence of conservative mixing-plane. diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index d2959d0449e8..7faa1c1bc1a1 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -1280,6 +1280,55 @@ class CSolver { */ virtual void Impose_Fixed_Values(const CGeometry *geometry, const CConfig *config) { } + /*! + * \brief Get the outer state for mixing plane interface nodes. + * \param[in] val_marker - marker index + * \param[in] val_span - vertex index + * \param[in] val_state - requested state component + * \param[in] donor_span - index of the donor span to get + */ + inline virtual su2double GetMixingState(unsigned short val_marker, + unsigned long val_span, + unsigned short val_state) const { return 0; } + + /*! + * \brief Allocates the final pointer of MixingState depending on how many donor vertex donate to it. That number is stored in MixingStateNodes[val_marker][val_vertex]. + * \param[in] val_marker - marker index + * \param[in] val_span - span index + */ + inline virtual void SetMixingStateStructure(unsigned short val_marker, unsigned long val_vertex) { } + + /*! + * \brief Set the outer state for mixing plane interface nodes. + * \param[in] val_marker - marker index + * \param[in] val_span - vertex index + * \param[in] val_state - requested state component + * \param[in] donor_index - index of the donor node to set + * \param[in] component - set value + */ + inline virtual void SetMixingState(unsigned short val_marker, + unsigned long val_span, + unsigned short val_state, + // unsigned long donor_span, // Do I care about where it comes from? + su2double component) { } + + /*! + * \brief Set the number of outer state for mixing plane interface nodes. + * \param[in] val_marker - marker index + * \param[in] val_span - span index + * \param[in] value - number of outer states + */ + inline virtual void SetnMixingStates(unsigned short val_marker, + unsigned long val_span, + int value) { } + + /*! + * \brief Get the number of outer state for mixing plane interface nodes. + * \param[in] val_marker - marker index + * \param[in] val_span - vertex index + */ + inline virtual int GetnMixingStates(unsigned short val_marker, unsigned long val_span) const { return 0; } + /*! * \brief Get the outer state for fluid interface nodes. * \param[in] val_marker - marker index @@ -3865,76 +3914,76 @@ class CSolver { * \param[in] val_marker - bound marker. * \return Value of the Average Nu on the surface val_marker. */ - inline virtual su2double GetExtAverageNu(unsigned short valMarker, unsigned short valSpan) const { return 0.0; } - - /*! - * \brief A virtual member. - * \param[in] val_marker - bound marker. - * \return Value of the Average Kine on the surface val_marker. - */ - inline virtual su2double GetExtAverageKine(unsigned short valMarker, unsigned short valSpan) const { return 0.0; } - - /*! - * \brief A virtual member. - * \param[in] val_marker - bound marker. - * \return Value of the Average Omega on the surface val_marker. - */ - inline virtual su2double GetExtAverageOmega(unsigned short valMarker, unsigned short valSpan) const { return 0.0; } - - /*! - * \brief A virtual member. - * \param[in] val_marker - bound marker. - * \return Value of the Average Density on the surface val_marker. - */ - inline virtual void SetExtAverageDensity(unsigned short valMarker, - unsigned short valSpan, - su2double valDensity) { } - - /*! - * \brief A virtual member. - * \param[in] val_marker - bound marker. - * \return Value of the Average Pressure on the surface val_marker. - */ - inline virtual void SetExtAveragePressure(unsigned short valMarker, - unsigned short valSpan, - su2double valPressure) { } - - /*! - * \brief A virtual member. - * \param[in] val_marker - bound marker. - * \return Value of the Average Total Pressure on the surface val_marker. - */ - inline virtual void SetExtAverageTurboVelocity(unsigned short valMarker, - unsigned short valSpan, - unsigned short valIndex, - su2double valTurboVelocity) { } - - /*! - * \brief A virtual member. - * \param[in] val_marker - bound marker. - * \return Value of the Average Nu on the surface val_marker. - */ - inline virtual void SetExtAverageNu(unsigned short valMarker, - unsigned short valSpan, - su2double valNu) { } - - /*! - * \brief A virtual member. - * \param[in] val_marker - bound marker. - * \return Value of the Average Kine on the surface val_marker. - */ - inline virtual void SetExtAverageKine(unsigned short valMarker, - unsigned short valSpan, - su2double valKine) { } - - /*! - * \brief A virtual member. - * \param[in] val_marker - bound marker. - * \return Value of the Average Omega on the surface val_marker. - */ - inline virtual void SetExtAverageOmega(unsigned short valMarker, - unsigned short valSpan, - su2double valOmega) { } + // inline virtual su2double GetExtAverageNu(unsigned short valMarker, unsigned short valSpan) const { return 0.0; } + + // /*! + // * \brief A virtual member. + // * \param[in] val_marker - bound marker. + // * \return Value of the Average Kine on the surface val_marker. + // */ + // inline virtual su2double GetExtAverageKine(unsigned short valMarker, unsigned short valSpan) const { return 0.0; } + + // /*! + // * \brief A virtual member. + // * \param[in] val_marker - bound marker. + // * \return Value of the Average Omega on the surface val_marker. + // */ + // inline virtual su2double GetExtAverageOmega(unsigned short valMarker, unsigned short valSpan) const { return 0.0; } + + // /*! + // * \brief A virtual member. + // * \param[in] val_marker - bound marker. + // * \return Value of the Average Density on the surface val_marker. + // */ + // inline virtual void SetExtAverageDensity(unsigned short valMarker, + // unsigned short valSpan, + // su2double valDensity) { } + + // /*! + // * \brief A virtual member. + // * \param[in] val_marker - bound marker. + // * \return Value of the Average Pressure on the surface val_marker. + // */ + // inline virtual void SetExtAveragePressure(unsigned short valMarker, + // unsigned short valSpan, + // su2double valPressure) { } + + // /*! + // * \brief A virtual member. + // * \param[in] val_marker - bound marker. + // * \return Value of the Average Total Pressure on the surface val_marker. + // */ + // inline virtual void SetExtAverageTurboVelocity(unsigned short valMarker, + // unsigned short valSpan, + // unsigned short valIndex, + // su2double valTurboVelocity) { } + + // /*! + // * \brief A virtual member. + // * \param[in] val_marker - bound marker. + // * \return Value of the Average Nu on the surface val_marker. + // */ + // inline virtual void SetExtAverageNu(unsigned short valMarker, + // unsigned short valSpan, + // su2double valNu) { } + + // /*! + // * \brief A virtual member. + // * \param[in] val_marker - bound marker. + // * \return Value of the Average Kine on the surface val_marker. + // */ + // inline virtual void SetExtAverageKine(unsigned short valMarker, + // unsigned short valSpan, + // su2double valKine) { } + + // /*! + // * \brief A virtual member. + // * \param[in] val_marker - bound marker. + // * \return Value of the Average Omega on the surface val_marker. + // */ + // inline virtual void SetExtAverageOmega(unsigned short valMarker, + // unsigned short valSpan, + // su2double valOmega) { } /*! * \brief A virtual member. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 346deb34b9c5..c408577b6976 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -226,6 +226,13 @@ CDriverBase(confFile, val_nZone, MPICommunicator), StopCalc(false), fsi(false), CGeometry::ComputeWallDistance(config_container, geometry_container); } + if (config_container[ZONE_0]->GetBoolTurbomachinery()){ + if (rank == MASTER_NODE) + cout << endl <<"---------------------- Turbo-Vertex Preprocessing ---------------------" << endl; + + PreprocessTurboVertex(config_container, geometry_container, solver_container, interface_container, iteration_container, dummy_geo); + } + /*--- Definition of the interface and transfer conditions between different zones. ---*/ if (nZone > 1) { @@ -250,11 +257,8 @@ CDriverBase(confFile, val_nZone, MPICommunicator), StopCalc(false), fsi(false), cout << endl <<"---------------------- Turbomachinery Preprocessing ---------------------" << endl; PreprocessTurbomachinery(config_container, geometry_container, solver_container, interface_container, iteration_container, dummy_geo); - } else { - mixingplane = false; } - PreprocessPythonInterface(config_container, geometry_container, solver_container); @@ -2417,8 +2421,11 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet /*--- Setup the interpolation. ---*/ - interpolation[donor][target] = unique_ptr(CInterpolatorFactory::CreateInterpolator( - geometry, config, interpolation[target][donor].get(), donor, target)); + if (!config[donor]->GetBoolTurbomachinery()) { + interpolation[donor][target] = unique_ptr(CInterpolatorFactory::CreateInterpolator( + geometry, config, interpolation[target][donor].get(), donor, target, false)); + if (rank == MASTER_NODE) cout << " Transferring "; + } /*--- The type of variables transferred depends on the donor/target physics. ---*/ @@ -2432,8 +2439,6 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet /*--- Initialize the appropriate transfer strategy. ---*/ - if (rank == MASTER_NODE) cout << " Transferring "; - if (fluid_donor && structural_target) { auto nConst = 2; @@ -2460,12 +2465,18 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet auto interfaceIndex = donor+target; // Here we assume that the interfaces at each side are the same kind switch (config[donor]->GetKind_TurboInterface(interfaceIndex)) { case TURBO_INTERFACE_KIND::MIXING_PLANE: { + interpolation[donor][target] = unique_ptr(CInterpolatorFactory::CreateInterpolator( + geometry, config, interpolation[target][donor].get(), donor, target, true)); + if (rank == MASTER_NODE) cout << " Transferring "; auto nVar = solver[donor][INST_0][MESH_0][FLOW_SOL]->GetnVar(); interface[donor][target] = new CMixingPlaneInterface(nVar, 0); if (rank == MASTER_NODE) cout << "using a mixing-plane interface from donor zone " << donor << " to target zone " << target << "." << endl; break; } case TURBO_INTERFACE_KIND::FROZEN_ROTOR: { + interpolation[donor][target] = unique_ptr(CInterpolatorFactory::CreateInterpolator( + geometry, config, interpolation[target][donor].get(), donor, target, false)); + if (rank == MASTER_NODE) cout << " Transferring "; auto nVar = solver[donor][INST_0][MESH_0][FLOW_SOL]->GetnPrimVar(); interface[donor][target] = new CSlidingInterface(nVar, 0); if (rank == MASTER_NODE) cout << "using a fluid interface interface from donor zone " << donor << " to target zone " << target << "." << endl; @@ -2604,7 +2615,7 @@ void CDriver::PreprocessOutput(CConfig **config, CConfig *driver_config, COutput } -void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, CSolver***** solver, +void CDriver::PreprocessTurboVertex(CConfig** config, CGeometry**** geometry, CSolver***** solver, CInterface*** interface, CIteration*** iteration, bool dummy){ unsigned short donorZone,targetZone, nMarkerInt, iMarkerInt; @@ -2639,6 +2650,16 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, } } if (rank == MASTER_NODE) cout<<"Max number of span-wise sections among all zones: "<< nSpanMax<<"."<< endl; +} + +void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, CSolver***** solver, + CInterface*** interface, CIteration*** iteration, bool dummy){ + unsigned short donorZone,targetZone, nMarkerInt, iMarkerInt; + unsigned short nSpanMax = 0; + bool restart = (config[ZONE_0]->GetRestart() || config[ZONE_0]->GetRestart_Flow()); + mixingplane = config[ZONE_0]->GetBoolMixingPlaneInterface(); + bool discrete_adjoint = config[ZONE_0]->GetDiscrete_Adjoint(); + su2double areaIn, areaOut, nBlades, flowAngleIn, flowAngleOut; // TODO(turbo): make it general for turbo HB if (rank == MASTER_NODE) cout<<"Compute inflow and outflow average geometric quantities." << endl; diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 4e1a87aebdf8..4802d02a57e7 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -593,16 +593,24 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar break; case MIXING_PLANE: { - const auto nMarkerInt = config_container[donorZone]->GetnMarker_MixingPlaneInterface() / 2; - - /*--- Transfer the average value from the donorZone to the targetZone ---*/ - /*--- Loops over the mixing planes defined in the config file to find the correct mixing plane for the donor-target combination ---*/ - 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 ); - } + interface_container[donorZone][targetZone]->BroadcastData_MixingPlane(*interpolator_container[donorZone][targetZone].get(), + 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]); break; + // const auto nMarkerInt = config_container[donorZone]->GetnMarker_MixingPlaneInterface() / 2; + + // /*--- Transfer the average value from the donorZone to the targetZone ---*/ + // /*--- Loops over the mixing planes defined in the config file to find the correct mixing plane for the donor-target combination ---*/ + // 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 ); + // } + // break; } default: if(rank == MASTER_NODE) diff --git a/SU2_CFD/src/interfaces/CInterface.cpp b/SU2_CFD/src/interfaces/CInterface.cpp index 95b95b4a18a3..7e5a09333853 100644 --- a/SU2_CFD/src/interfaces/CInterface.cpp +++ b/SU2_CFD/src/interfaces/CInterface.cpp @@ -325,7 +325,6 @@ void CInterface::PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_ } } } - } diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 0cbfca978152..369e12f4d1e4 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -27,6 +27,7 @@ */ #include "../../../include/interfaces/cfd/CMixingPlaneInterface.hpp" +#include "../../../Common/include/interface_interpolation/CInterpolator.hpp" #include "../../../../Common/include/CConfig.hpp" #include "../../../../Common/include/geometry/CGeometry.hpp" #include "../../../include/solvers/CSolver.hpp" @@ -54,64 +55,164 @@ void CMixingPlaneInterface::SetSpanWiseLevels(const CConfig *donor_config, const } } -void CMixingPlaneInterface::GetDonor_Variable(CSolver *donor_solution, CGeometry *donor_geometry, - const CConfig *donor_config, unsigned long Marker_Donor, - unsigned long iSpan, unsigned long rank) { +void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& interpolator, + CSolver *donor_solution, CSolver *target_solution, + CGeometry *donor_geometry, CGeometry *target_geometry, + const CConfig *donor_config, const CConfig *target_config) { + static_assert(su2activematrix::Storage == StorageType::RowMajor,""); + + /*--- Loop over interface markers. ---*/ + + for (auto iMarkerInt = 0u; iMarkerInt < donor_config->GetMarker_n_ZoneInterface()/2; iMarkerInt++) { + + /*--- Check if this interface connects the two zones, if not continue. ---*/ + + const auto markDonor = donor_config->FindInterfaceMarker(iMarkerInt); + const auto markTarget = target_config->FindInterfaceMarker(iMarkerInt); + + if(!CInterpolator::CheckInterfaceBoundary(markDonor, markTarget)) continue; + + /*--- Count donor spans on this rank. ---*/ + unsigned short nLocalSpanDonor = donor_config->GetnSpanWiseSections(); + const auto nSpanDonor = donor_config->GetnSpanWiseSections(); + + /*--- Gather donor counts and compute total sizes, and displacements (cumulative + * sums) to perform an Allgatherv of donor indices and variables. ---*/ + + vector nAllSpanDonor(size), nAllVarCounts(size), spanIdx(size,0), spanVar(size); + SU2_MPI::Allgather(&nLocalSpanDonor, 1, MPI_INT, nAllSpanDonor.data(), 1, MPI_INT, SU2_MPI::GetComm()); + + for (int i = 0; i < size; ++i) { + nAllVarCounts[i] = nAllSpanDonor[i] * 8; + if(i) spanIdx[i] = spanIdx[i-1] + nAllSpanDonor[i-1]; + spanVar[i] = spanIdx[i] * 8; + } + + /*--- Fill send buffers. ---*/ + + vector sendDonorIdx(nLocalSpanDonor); + su2activematrix sendDonorVar(nLocalSpanDonor, 8); + + if (markDonor >= 0) { + for (auto iSpan = 0ul, iSend = 0ul; iSpan < nSpanDonor; iSpan++) { + GetDonor_Variable(donor_solution, donor_geometry, donor_config, markDonor, iSpan, 0); + for (auto iVar = 0u; iVar < nVar; iVar++) sendDonorVar(iSend, iVar) = Donor_Variable[iVar]; + + sendDonorIdx[iSend] = iSpan; + ++iSend; + } + } + /*--- Gather data. ---*/ + const int nGlobalSpanDonor = spanIdx.back() + nAllSpanDonor.back(); + + vector donorIdx(nGlobalSpanDonor); + su2activematrix donorVar(nGlobalSpanDonor, 8); + int nSpanSize = nSpanDonor*size; + + SU2_MPI::Allgatherv(sendDonorIdx.data(), sendDonorIdx.size(), MPI_UNSIGNED_LONG, donorIdx.data(), + nAllSpanDonor.data(), spanIdx.data(), MPI_UNSIGNED_LONG, SU2_MPI::GetComm()); + + SU2_MPI::Allgatherv(sendDonorVar.data(), sendDonorVar.size(), MPI_DOUBLE, donorVar.data(), + nAllVarCounts.data(), spanVar.data(), MPI_DOUBLE, SU2_MPI::GetComm()); + + /*--- This rank does not need to do more work. ---*/ + if (markTarget < 0) continue; + + /*--- Loop over target spans. ---*/ + auto nTargetSpan = target_config->GetnSpanWiseSections() + 1; - unsigned short nDim = nVar - 2; - bool turbulent = (donor_config->GetKind_Turb_Model() != TURB_MODEL::NONE); + for (auto iTargetSpan = 0ul; iTargetSpan < nTargetSpan; iTargetSpan++) { + auto& targetSpan = interpolator.targetSpans[markTarget]; + const auto nDonorSpan = targetSpan.nDonor(); + InitializeTarget_Variable(target_solution, markTarget, iTargetSpan, nDonorSpan); - Donor_Variable[0] = donor_solution->GetAverageDensity(Marker_Donor, iSpan); - Donor_Variable[1] = donor_solution->GetAveragePressure(Marker_Donor, iSpan); - Donor_Variable[2] = donor_solution->GetAverageTurboVelocity(Marker_Donor, iSpan)[0]; - Donor_Variable[3] = donor_solution->GetAverageTurboVelocity(Marker_Donor, iSpan)[1]; + if ((iTargetSpan == 0) || (iTargetSpan < nTargetSpan - 3)) { + /*--- Transfer values at hub, shroud and 1D values ---*/ + unsigned long iDonorSpan; + if (iTargetSpan == 0) iDonorSpan = 0; + else if (iTargetSpan == nTargetSpan - 2) iDonorSpan = nDonorSpan - 2; + else if (iTargetSpan == nTargetSpan - 1) iDonorSpan = nDonorSpan - 1; - if(nDim == 3){ - Donor_Variable[4] = donor_solution->GetAverageTurboVelocity(Marker_Donor, iSpan)[2]; + const auto idx = lower_bound(donorIdx.begin(), donorIdx.end(), iDonorSpan) - donorIdx.begin(); + assert(idx < static_cast(donorIdx.size())); + + RecoverTarget_Variable(donorVar[idx]); + + SetTarget_Variable(target_solution, target_geometry, target_config, markTarget, iTargetSpan, 0); + } + else { + /*--- Get the global index of the donor and the interpolation coefficient. ---*/ + + const auto donorSpan = targetSpan.globalSpan[iTargetSpan]; + const auto donorCoeff = targetSpan.coefficient[iTargetSpan]; + + /*--- Find the index of the global donor point in the donor data. ---*/ + + const auto idx = lower_bound(donorIdx.begin(), donorIdx.end(), donorSpan) - donorIdx.begin(); + assert(idx < static_cast(donorIdx.size())); + + /*--- Recover the Target_Variable from the buffer of variables. ---*/ + RecoverTarget_Variable(donorVar[idx], donorVar[idx+1], donorCoeff); + + SetTarget_Variable(target_solution, target_geometry, target_config, markTarget, iTargetSpan, 0); + } + } + } +} + +void CMixingPlaneInterface::GetDonor_Variable(CSolver *donor_solution, CGeometry *donor_geometry, + const CConfig *donor_config, unsigned long Marker_Donor, + unsigned long Span_Donor, unsigned long Point_Donor) { + + Donor_Variable[0] = donor_solution->GetAverageDensity(Marker_Donor, Span_Donor); + Donor_Variable[1] = donor_solution->GetAveragePressure(Marker_Donor, Span_Donor); + Donor_Variable[2] = donor_solution->GetAverageTurboVelocity(Marker_Donor, Span_Donor)[0]; + Donor_Variable[3] = donor_solution->GetAverageTurboVelocity(Marker_Donor, Span_Donor)[1]; + + if(donor_geometry->GetnDim() == 3){ + Donor_Variable[4] = donor_solution->GetAverageTurboVelocity(Marker_Donor, Span_Donor)[2]; } else{ Donor_Variable[4] = -1.0; } - if(turbulent){ - Donor_Variable[5] = donor_solution->GetAverageNu(Marker_Donor, iSpan); - Donor_Variable[6] = donor_solution->GetAverageKine(Marker_Donor, iSpan); - Donor_Variable[7] = donor_solution->GetAverageOmega(Marker_Donor, iSpan); + if(donor_config->GetKind_Turb_Model() != TURB_MODEL::NONE){ + Donor_Variable[5] = donor_solution->GetAverageNu(Marker_Donor, Span_Donor); + Donor_Variable[6] = donor_solution->GetAverageKine(Marker_Donor, Span_Donor); + Donor_Variable[7] = donor_solution->GetAverageOmega(Marker_Donor, Span_Donor); } else{ Donor_Variable[5] = -1.0; Donor_Variable[6] = -1.0; Donor_Variable[7] = -1.0; } - } +void CMixingPlaneInterface::InitializeTarget_Variable(CSolver *target_solution, unsigned long Marker_Target, + unsigned long Span_Target, unsigned short nSpanDonor) { -void CMixingPlaneInterface::SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry, - const CConfig *target_config, unsigned long Marker_Target, - unsigned long iSpan, unsigned long rank) { + target_solution->SetnMixingStates(Marker_Target, Span_Target, nSpanDonor); // This is to allocate + target_solution->SetMixingStateStructure(Marker_Target, Span_Target); + target_solution->SetnMixingStates(Marker_Target, Span_Target, 0); // Reset counter to 0 - unsigned short nDim = nVar - 2; - bool turbulent = (target_config->GetKind_Turb_Model() != TURB_MODEL::NONE); +} +void CMixingPlaneInterface::SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry, + const CConfig *target_config, unsigned long Marker_Target, + unsigned long Span_Target, unsigned long Point_Target) { - target_solution->SetExtAverageDensity(Marker_Target, iSpan, Target_Variable[0]); - target_solution->SetExtAveragePressure(Marker_Target, iSpan, Target_Variable[1]); - target_solution->SetExtAverageTurboVelocity(Marker_Target, iSpan, 0, Target_Variable[2]); - target_solution->SetExtAverageTurboVelocity(Marker_Target, iSpan, 1, Target_Variable[3]); + unsigned short iVar, iDonorSpan, nTargetVar; + nTargetVar = 8; + /*--- Set the mixing plane solution with the value of the Target Variable ---*/ - if(nDim == 3){ - target_solution->SetExtAverageTurboVelocity(Marker_Target, iSpan, 2, Target_Variable[4]); - } + iDonorSpan = target_solution->GetnMixingStates(Marker_Target, Span_Target); - if(turbulent){ - target_solution->SetExtAverageNu(Marker_Target, iSpan, Target_Variable[5]); - target_solution->SetExtAverageKine(Marker_Target, iSpan, Target_Variable[6]); - target_solution->SetExtAverageOmega(Marker_Target, iSpan, Target_Variable[7]); - } + for (iVar = 0; iVar < nTargetVar+1; iVar++) + target_solution->SetMixingState(Marker_Target, Span_Target, iVar, Target_Variable[iVar]); + target_solution->SetnMixingStates( Marker_Target, Span_Target, iDonorSpan + 1 ); } void CMixingPlaneInterface::SetAverageValues(CSolver *donor_solution, CSolver *target_solution, diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 5354277c190a..fbce817e0ff8 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -359,7 +359,9 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, } CEulerSolver::~CEulerSolver() { - + for (auto& vec : MixingState) { + for (auto ptr : vec) delete [] ptr; + } for(auto& model : FluidModel) delete model; } @@ -394,28 +396,28 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig **config_con AverageVelocity.resize(nMarker); AverageTurboVelocity.resize(nMarker); OldAverageTurboVelocity.resize(nMarker); - ExtAverageTurboVelocity.resize(nMarker); + // ExtAverageTurboVelocity.resize(nMarker); AverageFlux.resize(nMarker); SpanTotalFlux.resize(nMarker); AveragePressure.resize(nMarker,nSpanWiseSections+1) = su2double(0.0); OldAveragePressure = AveragePressure; RadialEquilibriumPressure = AveragePressure; - ExtAveragePressure = AveragePressure; + // ExtAveragePressure = AveragePressure; AverageDensity = AveragePressure; OldAverageDensity = AveragePressure; - ExtAverageDensity = AveragePressure; + // ExtAverageDensity = AveragePressure; AverageNu = AveragePressure; AverageKine = AveragePressure; AverageOmega = AveragePressure; - ExtAverageNu = AveragePressure; - ExtAverageKine = AveragePressure; - ExtAverageOmega = AveragePressure; + // ExtAverageNu = AveragePressure; + // ExtAverageKine = AveragePressure; + // ExtAverageOmega = AveragePressure; for (unsigned long iMarker = 0; iMarker < nMarker; iMarker++) { AverageVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0); AverageTurboVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0); OldAverageTurboVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0); - ExtAverageTurboVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0); + // ExtAverageTurboVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0); AverageFlux[iMarker].resize(nSpanWiseSections+1,nVar) = su2double(0.0); SpanTotalFlux[iMarker].resize(nSpanWiseSections+1,nVar) = su2double(0.0); } @@ -458,6 +460,16 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig **config_con } } + MixingState.resize(nMarker); + MixingStateNodes.resize(nMarker); + + for (unsigned long iMarker = 0; iMarker < nMarker; iMarker++) { + if (config->GetMarker_All_KindBC(iMarker) == GILES_BOUNDARY) { + MixingState[iMarker].resize(nSpanWiseSections); + MixingStateNodes[iMarker].resize(nSpanWiseSections); + } + } + TurbomachineryPerformance = std::make_shared(config_container, *geometry, *GetFluidModel(), iZone); } @@ -5582,6 +5594,18 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain for (iDim = 0; iDim < nDim; iDim++) ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + auto nDonorSpan = GetnMixingStates(val_marker, iSpan); + su2double donorAverages[8] = {0.0}; + for (auto iVar = 0u; iVar < 8; iVar++) { + donorAverages[iVar] = GetMixingState(val_marker, iSpan, iVar); + } + const auto ExtAverageDensity = donorAverages[0]; + const auto ExtAveragePressure = donorAverages[1]; + su2double ExtAverageTurboVelocity[3] = {0.0}; + ExtAverageTurboVelocity[0] = donorAverages[2]; + ExtAverageTurboVelocity[1] = donorAverages[3]; + ExtAverageTurboVelocity[2] = donorAverages[4]; + /*--- Build the external state u_e from boundary data and internal node ---*/ switch(config->GetKind_Data_Riemann(Marker_Tag)) @@ -5622,15 +5646,15 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain case MIXING_IN: /* --- compute total averaged quantities ---*/ - GetFluidModel()->SetTDState_Prho(ExtAveragePressure[val_marker][iSpan], ExtAverageDensity[val_marker][iSpan]); - AverageEnthalpy = GetFluidModel()->GetStaticEnergy() + ExtAveragePressure[val_marker][iSpan]/ExtAverageDensity[val_marker][iSpan]; + GetFluidModel()->SetTDState_Prho(ExtAveragePressure, ExtAverageDensity); + AverageEnthalpy = GetFluidModel()->GetStaticEnergy() + ExtAveragePressure/ExtAverageDensity; AverageEntropy = GetFluidModel()->GetEntropy(); FlowDirMixMag = 0; for (iDim = 0; iDim < nDim; iDim++) - FlowDirMixMag += ExtAverageTurboVelocity[val_marker][iSpan][iDim]*ExtAverageTurboVelocity[val_marker][iSpan][iDim]; + FlowDirMixMag += ExtAverageTurboVelocity[iDim]*ExtAverageTurboVelocity[iDim]; for (iDim = 0; iDim < nDim; iDim++){ - FlowDirMix[iDim] = ExtAverageTurboVelocity[val_marker][iSpan][iDim]/sqrt(FlowDirMixMag); + FlowDirMix[iDim] = ExtAverageTurboVelocity[iDim]/sqrt(FlowDirMixMag); } @@ -5658,7 +5682,7 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain case MIXING_OUT: /*--- Retrieve the static pressure for this boundary. ---*/ - Pressure_e = ExtAveragePressure[val_marker][iSpan]; + Pressure_e = ExtAveragePressure; Density_e = Density_i; /* --- Compute the boundary state u_e --- */ @@ -6268,6 +6292,26 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu kend_max = geometry->GetnFreqSpanMax(config->GetMarker_All_TurbomachineryFlag(val_marker)); conv_numerics->GetRMatrix(AverageSoundSpeed, AverageDensity[val_marker][iSpan], R_Matrix); + su2double ExtAverageDensity, ExtAveragePressure; + su2double ExtAverageTurboVelocity[3] = {0.0}; + su2double donorAverages[8] = {0.0}; + int nDonorSpan; + switch (config->GetKind_Data_Giles(Marker_Tag)){ + case MIXING_IN: case MIXING_IN_1D: case MIXING_OUT: case MIXING_OUT_1D: + nDonorSpan = GetnMixingStates(val_marker, iSpan); + for (auto iVar = 0u; iVar < 8; iVar++) { + donorAverages[iVar] = GetMixingState(val_marker, iSpan, iVar); + } + ExtAverageDensity = donorAverages[0]; + ExtAveragePressure = donorAverages[1]; + ExtAverageTurboVelocity[0] = donorAverages[2]; + ExtAverageTurboVelocity[1] = donorAverages[3]; + ExtAverageTurboVelocity[2] = donorAverages[4]; + break; + default: + break; + } + switch(config->GetKind_Data_Giles(Marker_Tag)){ case TOTAL_CONDITIONS_PT: @@ -6385,16 +6429,16 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu case MIXING_IN: case MIXING_OUT: /* --- Compute average jump of primitive at the mixing-plane interface--- */ - deltaprim[0] = ExtAverageDensity[val_marker][iSpan] - AverageDensity[val_marker][iSpan]; - deltaprim[1] = ExtAverageTurboVelocity[val_marker][iSpan][0] - AverageTurboVelocity[val_marker][iSpan][0]; - deltaprim[2] = ExtAverageTurboVelocity[val_marker][iSpan][1] - AverageTurboVelocity[val_marker][iSpan][1]; + deltaprim[0] = ExtAverageDensity - AverageDensity[val_marker][iSpan]; + deltaprim[1] = ExtAverageTurboVelocity[0] - AverageTurboVelocity[val_marker][iSpan][0]; + deltaprim[2] = ExtAverageTurboVelocity[1] - AverageTurboVelocity[val_marker][iSpan][1]; if (nDim == 2){ - deltaprim[3] = ExtAveragePressure[val_marker][iSpan] - AveragePressure[val_marker][iSpan]; + deltaprim[3] = ExtAveragePressure - AveragePressure[val_marker][iSpan]; } else { - deltaprim[3] = ExtAverageTurboVelocity[val_marker][iSpan][2] - AverageTurboVelocity[val_marker][iSpan][2]; - deltaprim[4] = ExtAveragePressure[val_marker][iSpan] - AveragePressure[val_marker][iSpan]; + deltaprim[3] = ExtAverageTurboVelocity[2] - AverageTurboVelocity[val_marker][iSpan][2]; + deltaprim[4] = ExtAveragePressure - AveragePressure[val_marker][iSpan]; } @@ -6407,16 +6451,16 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu case MIXING_IN_1D: case MIXING_OUT_1D: /* --- Compute average jump of primitive at the mixing-plane interface--- */ - deltaprim[0] = ExtAverageDensity[val_marker][nSpanWiseSections] - AverageDensity[val_marker][nSpanWiseSections]; - deltaprim[1] = ExtAverageTurboVelocity[val_marker][nSpanWiseSections][0] - AverageTurboVelocity[val_marker][nSpanWiseSections][0]; - deltaprim[2] = ExtAverageTurboVelocity[val_marker][nSpanWiseSections][1] - AverageTurboVelocity[val_marker][nSpanWiseSections][1]; + deltaprim[0] = ExtAverageDensity - AverageDensity[val_marker][nSpanWiseSections]; + deltaprim[1] = ExtAverageTurboVelocity[0] - AverageTurboVelocity[val_marker][nSpanWiseSections][0]; + deltaprim[2] = ExtAverageTurboVelocity[1] - AverageTurboVelocity[val_marker][nSpanWiseSections][1]; if (nDim == 2){ - deltaprim[3] = ExtAveragePressure[val_marker][nSpanWiseSections] - AveragePressure[val_marker][nSpanWiseSections]; + deltaprim[3] = ExtAveragePressure - AveragePressure[val_marker][nSpanWiseSections]; } else { - deltaprim[3] = ExtAverageTurboVelocity[val_marker][nSpanWiseSections][2] - AverageTurboVelocity[val_marker][nSpanWiseSections][2]; - deltaprim[4] = ExtAveragePressure[val_marker][nSpanWiseSections] - AveragePressure[val_marker][nSpanWiseSections]; + deltaprim[3] = ExtAverageTurboVelocity[2] - AverageTurboVelocity[val_marker][nSpanWiseSections][2]; + deltaprim[4] = ExtAveragePressure - AveragePressure[val_marker][nSpanWiseSections]; } /* --- Compute average jump of charachteristic variable at the mixing-plane interface--- */ diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index 7649165d0be3..a1e17b0d276a 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -1075,7 +1075,10 @@ void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_c /*--- Loop over all the vertices on this boundary marker ---*/ for (auto iSpan = 0u; iSpan < nSpanWiseSections ; iSpan++){ - su2double extAverageNu = solver_container[FLOW_SOL]->GetExtAverageNu(val_marker, iSpan); + auto nDonorSpan = solver_container[FLOW_SOL]->GetnMixingStates(val_marker, iSpan); + const auto extAverageNu = solver_container[FLOW_SOL]->GetMixingState(val_marker, iSpan, 5); + + // su2double extAverageNu = solver_container[FLOW_SOL]->GetExtAverageNu(val_marker, iSpan); /*--- Loop over all the vertices on this boundary marker ---*/ diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index b36f5c2b8765..7f279b45a905 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -803,8 +803,11 @@ void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_ for (auto iSpan = 0u; iSpan < nSpanWiseSections ; iSpan++){ - su2double extAverageKine = solver_container[FLOW_SOL]->GetExtAverageKine(val_marker, iSpan); - su2double extAverageOmega = solver_container[FLOW_SOL]->GetExtAverageOmega(val_marker, iSpan); + auto nDonorSpan = solver_container[FLOW_SOL]->GetnMixingStates(val_marker, iSpan); + const auto extAverageKine = solver_container[FLOW_SOL]->GetMixingState(val_marker, iSpan, 6); + const auto extAverageOmega = solver_container[FLOW_SOL]->GetMixingState(val_marker, iSpan, 7); + // su2double extAverageKine = solver_container[FLOW_SOL]->GetExtAverageKine(val_marker, iSpan); + // su2double extAverageOmega = solver_container[FLOW_SOL]->GetExtAverageOmega(val_marker, iSpan); su2double solution_j[] = {extAverageKine, extAverageOmega}; /*--- Loop over all the vertices on this boundary marker ---*/ From 2c8bf7663e1c3fe3cb5a12e6e6c0050702c72d36 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 13 Nov 2025 16:03:39 +0000 Subject: [PATCH 14/79] Fixes --- .../interface_interpolation/CMixingPlane.cpp | 27 ++++++++++++++----- SU2_CFD/include/solvers/CEulerSolver.hpp | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index 158f1bce78ea..f58a3156a4da 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -58,6 +58,15 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { const auto markDonor = donor_config->FindInterfaceMarker(iMarkerInt); const auto markTarget = target_config->FindInterfaceMarker(iMarkerInt); + unsigned short turboMarkDonor, turboMarkTarget; + if (donorZone > targetZone){ + turboMarkDonor = TURBO_MARKER_TYPE::INFLOW; + turboMarkTarget = TURBO_MARKER_TYPE::OUTFLOW; + } else { + turboMarkDonor = TURBO_MARKER_TYPE::OUTFLOW; + turboMarkTarget = TURBO_MARKER_TYPE::INFLOW; + } + // Spans are defined on one processor only, check to see if other processors have interface #ifdef HAVE_MPI auto buffMarkDonor = new int[size]; @@ -76,19 +85,23 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { if (!CheckInterfaceBoundary(markDonor, markTarget)) continue; - if (markDonor != -1) nSpanDonor = donor_config->GetnSpanWiseSections(); - if (markTarget != -1) nSpanTarget = target_config->GetnSpanWiseSections(); + nSpanDonor = donor_config->GetnSpanWiseSections(); + nSpanTarget = target_config->GetnSpanWiseSections(); if (nSpanTarget) targetSpans[markTarget].resize(nSpanTarget); - const auto spanValuesDonor = donor_geometry->GetSpanWiseValue(markDonor); - const auto spanValuesTarget = target_geometry->GetSpanWiseValue(markTarget); + const auto spanValuesDonor = donor_geometry->GetSpanWiseValue(turboMarkDonor); + const auto spanValuesTarget = target_geometry->GetSpanWiseValue(turboMarkTarget); - /*--- Interpolation of values at hub & shroud ---*/ + /*--- Interpolation at hub, shroud & 1D values ---*/ targetSpans[iMarkerInt].globalSpan[0] = 0; targetSpans[iMarkerInt].coefficient[0] = 0.0; - targetSpans[iMarkerInt].globalSpan[nSpanTarget] = nSpanTarget; - targetSpans[iMarkerInt].coefficient[nSpanTarget] = 0.0; + if (nDim > 2) { + targetSpans[iMarkerInt].globalSpan[nSpanTarget-1] = nSpanTarget-1; + targetSpans[iMarkerInt].coefficient[nSpanTarget-1] = 0.0; + targetSpans[iMarkerInt].globalSpan[nSpanTarget] = nSpanTarget; + targetSpans[iMarkerInt].coefficient[nSpanTarget] = 0.0; + } for(auto iSpanTarget = 1; iSpanTarget < nSpanTarget - 2; iSpanTarget++){ auto tSpan = 0; // Nearest donor span index diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index d7a584dcc485..71957b19b6b0 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -187,7 +187,7 @@ class CEulerSolver : public CFVMFlowSolverBase Date: Thu, 13 Nov 2025 16:47:26 +0000 Subject: [PATCH 15/79] Fixing mixing state data structure --- SU2_CFD/include/solvers/CEulerSolver.hpp | 2 ++ SU2_CFD/src/solvers/CEulerSolver.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 71957b19b6b0..b4dd8a3c1003 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -185,6 +185,8 @@ class CEulerSolver : public CFVMFlowSolverBaseGetMarker_All_KindBC(iMarker) == GILES_BOUNDARY) { - MixingState[iMarker].resize(nSpanWiseSections); - MixingStateNodes[iMarker].resize(nSpanWiseSections); + MixingState[iMarker].resize(nSpanWiseSections+1); + MixingStateNodes[iMarker].resize(nSpanWiseSections+1); } } From 542e3cbe29ea4d58c785c67d7aa2adcf758d78fd Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 13 Nov 2025 16:53:28 +0000 Subject: [PATCH 16/79] Correct targetVars --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 369e12f4d1e4..230eb7827d04 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -209,7 +209,7 @@ void CMixingPlaneInterface::SetTarget_Variable(CSolver *target_solution, CGeomet iDonorSpan = target_solution->GetnMixingStates(Marker_Target, Span_Target); - for (iVar = 0; iVar < nTargetVar+1; iVar++) + for (iVar = 0; iVar < nTargetVar; iVar++) target_solution->SetMixingState(Marker_Target, Span_Target, iVar, Target_Variable[iVar]); target_solution->SetnMixingStates( Marker_Target, Span_Target, iDonorSpan + 1 ); From 9a201acfba09663da89ebd7e41bbfb868cd5e6e3 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sat, 15 Nov 2025 04:23:43 +0000 Subject: [PATCH 17/79] Fixes + working MPI MP interface --- .../interface_interpolation/CInterpolator.hpp | 8 +- .../interface_interpolation/CMixingPlane.cpp | 146 +++++++++--------- .../interfaces/cfd/CMixingPlaneInterface.cpp | 46 +++--- SU2_CFD/src/solvers/CEulerSolver.cpp | 8 +- 4 files changed, 103 insertions(+), 105 deletions(-) diff --git a/Common/include/interface_interpolation/CInterpolator.hpp b/Common/include/interface_interpolation/CInterpolator.hpp index dd4f54ed1a4a..56b5b94b5f0f 100644 --- a/Common/include/interface_interpolation/CInterpolator.hpp +++ b/Common/include/interface_interpolation/CInterpolator.hpp @@ -109,12 +109,12 @@ class CInterpolator { unsigned long nDonor() const { return processor.size(); } void resize(size_t nDonor) { - processor.resize(nDonor); - globalSpan.resize(nDonor); // Refers to the donor span - coefficient.resize(nDonor); // Refers to the coefficient + processor.resize(nDonor); + globalSpan.resize(nDonor); // Refers to the donor span + coefficient.resize(nDonor); // Refers to the coefficient } }; - vector targetSpans; + vector> targetSpans; // > /*! * \brief Constructor of the class. diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index f58a3156a4da..a3b2a2baa3bc 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -51,59 +51,97 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { auto nSpanDonor = donor_config->GetnSpanWiseSections(); auto nSpanTarget = target_config->GetnSpanWiseSections(); - targetSpans.resize(nMarkerInt); + targetSpans.resize(config[donorZone]->GetnMarker_MixingPlaneInterface()); /*--- On the donor side ---*/ for (auto iMarkerInt = 0u; iMarkerInt < nMarkerInt; iMarkerInt++){ - const auto markDonor = donor_config->FindInterfaceMarker(iMarkerInt); - const auto markTarget = target_config->FindInterfaceMarker(iMarkerInt); - - unsigned short turboMarkDonor, turboMarkTarget; - if (donorZone > targetZone){ - turboMarkDonor = TURBO_MARKER_TYPE::INFLOW; - turboMarkTarget = TURBO_MARKER_TYPE::OUTFLOW; - } else { - turboMarkDonor = TURBO_MARKER_TYPE::OUTFLOW; - turboMarkTarget = TURBO_MARKER_TYPE::INFLOW; + int markDonor = -1, markTarget = -1; + unsigned short donorFlag = 0, targetFlag = 0; + + /*--- On the donor side ---*/ + for (auto iMarkerDonor = 0; iMarkerDonor < nMarkerDonor; iMarkerDonor++){ + /*--- If the tag GetMarker_All_MixingPlaneInterface equals the index we are looping at ---*/ + if ( donor_config->GetMarker_All_MixingPlaneInterface(iMarkerDonor) == iMarkerInt ){ + /*--- We have identified the local index of the Donor marker ---*/ + /*--- Now we are going to store the average values that belong to Marker_Donor on each processor ---*/ + /*--- Store the identifier for the structural marker ---*/ + markDonor = iMarkerDonor; + donorFlag = donor_config->GetMarker_All_TurbomachineryFlag(iMarkerDonor); + /*--- Exit the for loop: we have found the local index for Mixing-Plane interface ---*/ + break; + } + /*--- If the tag hasn't matched any tag within the donor markers ---*/ + markDonor = -1; + donorFlag = -1; } - // Spans are defined on one processor only, check to see if other processors have interface #ifdef HAVE_MPI - auto buffMarkDonor = new int[size]; - auto buffMarkTarget = new int[size]; - for (int iSize = 0; iSize= 0.0) { + markDonor = buffMarkerDonor[iSize]; + donorFlag = buffDonorFlag[iSize]; + break; + } + } + delete [] buffMarkerDonor; + delete [] buffDonorFlag; #endif - if (!CheckInterfaceBoundary(markDonor, markTarget)) continue; + /*--- On the target side we have to identify the marker as well ---*/ + for (auto iMarkerTarget = 0; iMarkerTarget < nMarkerTarget; iMarkerTarget++){ + /*--- If the tag GetMarker_All_MixingPlaneInterface(iMarkerTarget) equals the index we are looping at ---*/ + if ( target_config->GetMarker_All_MixingPlaneInterface(iMarkerTarget) == iMarkerInt ){ + /*--- Store the identifier for the fluid marker ---*/ + markTarget = iMarkerTarget; + targetFlag = target_config->GetMarker_All_TurbomachineryFlag(iMarkerTarget); + /*--- Exit the for loop: we have found the local index for iMarkerFSI on the FEA side ---*/ + break; + } + /*--- If the tag hasn't matched any tag within the Flow markers ---*/ + markTarget = -1; + targetFlag = -1; + } + + if (markTarget == -1 || markDonor == -1) continue; nSpanDonor = donor_config->GetnSpanWiseSections(); nSpanTarget = target_config->GetnSpanWiseSections(); - if (nSpanTarget) targetSpans[markTarget].resize(nSpanTarget); + targetSpans[iMarkerInt].resize(nSpanTarget+1); - const auto spanValuesDonor = donor_geometry->GetSpanWiseValue(turboMarkDonor); - const auto spanValuesTarget = target_geometry->GetSpanWiseValue(turboMarkTarget); + for (auto iSpanTarget = 0u; iSpanTarget < nSpanTarget; iSpanTarget++){ + targetSpans[iMarkerInt][iSpanTarget].resize(nSpanTarget); + } + + const auto spanValuesDonor = donor_geometry->GetSpanWiseValue(donorFlag); + const auto spanValuesTarget = target_geometry->GetSpanWiseValue(targetFlag); /*--- Interpolation at hub, shroud & 1D values ---*/ - targetSpans[iMarkerInt].globalSpan[0] = 0; - targetSpans[iMarkerInt].coefficient[0] = 0.0; + targetSpans[iMarkerInt][0].globalSpan[0] = 0; + targetSpans[iMarkerInt][0].coefficient[0] = 0.0; if (nDim > 2) { - targetSpans[iMarkerInt].globalSpan[nSpanTarget-1] = nSpanTarget-1; - targetSpans[iMarkerInt].coefficient[nSpanTarget-1] = 0.0; - targetSpans[iMarkerInt].globalSpan[nSpanTarget] = nSpanTarget; - targetSpans[iMarkerInt].coefficient[nSpanTarget] = 0.0; + targetSpans[iMarkerInt][nSpanTarget-2].globalSpan[nSpanDonor-2] = nSpanDonor-2; + targetSpans[iMarkerInt][nSpanTarget-2].coefficient[nSpanTarget-2] = 0.0; + targetSpans[iMarkerInt][nSpanTarget-1].globalSpan[nSpanTarget-1] = nSpanDonor-1; + targetSpans[iMarkerInt][nSpanTarget-1].coefficient[nSpanTarget-1] = 0.0; } for(auto iSpanTarget = 1; iSpanTarget < nSpanTarget - 2; iSpanTarget++){ + auto &targetSpan = targetSpans[iMarkerInt][iSpanTarget]; + auto tSpan = 0; // Nearest donor span index auto kSpan = 0; // Lower bound donor span for interpolation su2double coeff = 0.0; // Interpolation coefficient @@ -111,8 +149,8 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { switch(donor_config->GetKind_MixingPlaneInterface()){ case MATCHING: - targetSpans[iMarkerInt].globalSpan[iSpanTarget] = iSpanTarget; - targetSpans[iMarkerInt].coefficient[iSpanTarget] = 0.0; + targetSpan.globalSpan[iSpanTarget] = iSpanTarget; + targetSpan.coefficient[iSpanTarget] = 0.0; break; case NEAREST_SPAN: @@ -124,8 +162,8 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { tSpan = iSpanDonor; } } - targetSpans[iMarkerInt].globalSpan[iSpanTarget] = tSpan; - targetSpans[iMarkerInt].coefficient[iSpanTarget] = 0.0; + targetSpan.globalSpan[iSpanTarget] = tSpan; + targetSpan.coefficient[iSpanTarget] = 0.0; break; case LINEAR_INTERPOLATION: @@ -140,46 +178,14 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { // Calculate interpolation coefficient coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan]) / (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); - targetSpans[iMarkerInt].globalSpan[iSpanTarget] = kSpan; - targetSpans[iMarkerInt].coefficient[iSpanTarget] = coeff; + targetSpan.globalSpan[iSpanTarget] = kSpan; + targetSpan.coefficient[iSpanTarget] = coeff; break; default: SU2_MPI::Error("MixingPlane interface option not implemented yet", CURRENT_FUNCTION); break; } - - - // for (auto iSpanDonor = 1; iSpanDonor < nSpanDonor - 2; iSpanDonor++) { - // const auto test = abs(SpanValuesTarget[iSpanTarget] - SpanValuesDonor[iSpanDonor]); - // const auto test2 = abs(SpanValuesTarget[iSpanTarget] - SpanValuesDonor[iSpanDonor]); - // if(test < dist && SpanValuesTarget[iSpanTarget] > SpanValuesDonor[iSpanDonor]){ - // dist = test; - // kSpan = iSpanDonor; - // } - // if(test2 < dist2){ - // dist2 = test2; - // tSpan = iSpanDonor; - // } - // } - // switch(donor_config->GetKind_MixingPlaneInterface()){ - // case MATCHING: - // targetSpans.globalSpan[iSpanTarget] = iSpanTarget; - // targetSpans.coefficent[iSpanTarget] = 0.0; - // break; - // case NEAREST_SPAN: - // targetSpans.globalSpan[iSpanTarget] = tSpan; - // targetSpans.coefficent[iSpanTarget] = 0.0; - // break; - // case LINEAR_INTERPOLATION: - // targetSpans.globalSpan[iSpanTarget] = kSpan; - // targetSpans.coefficent[iSpanTarget] = (SpanValuesTarget[iSpanTarget] - SpanValuesDonor[kSpan]) - // /(SpanValuesDonor[kSpan + 1] - SpanValuesDonor[kSpan]); - // break; - // default: - // SU2_MPI::Error("MixingPlane interface option not implemented yet", CURRENT_FUNCTION); - // break; - // } + } } -} } \ No newline at end of file diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 230eb7827d04..5901857e14ea 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -72,48 +72,38 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter if(!CInterpolator::CheckInterfaceBoundary(markDonor, markTarget)) continue; - /*--- Count donor spans on this rank. ---*/ - unsigned short nLocalSpanDonor = donor_config->GetnSpanWiseSections(); + // The number of spans is available on every rank const auto nSpanDonor = donor_config->GetnSpanWiseSections(); - /*--- Gather donor counts and compute total sizes, and displacements (cumulative - * sums) to perform an Allgatherv of donor indices and variables. ---*/ - - vector nAllSpanDonor(size), nAllVarCounts(size), spanIdx(size,0), spanVar(size); - SU2_MPI::Allgather(&nLocalSpanDonor, 1, MPI_INT, nAllSpanDonor.data(), 1, MPI_INT, SU2_MPI::GetComm()); - - for (int i = 0; i < size; ++i) { - nAllVarCounts[i] = nAllSpanDonor[i] * 8; - if(i) spanIdx[i] = spanIdx[i-1] + nAllSpanDonor[i-1]; - spanVar[i] = spanIdx[i] * 8; - } - /*--- Fill send buffers. ---*/ - vector sendDonorIdx(nLocalSpanDonor); - su2activematrix sendDonorVar(nLocalSpanDonor, 8); + vector sendDonorIdx(nSpanDonor); + su2activematrix sendDonorVar(nSpanDonor, 8); if (markDonor >= 0) { for (auto iSpan = 0ul, iSend = 0ul; iSpan < nSpanDonor; iSpan++) { GetDonor_Variable(donor_solution, donor_geometry, donor_config, markDonor, iSpan, 0); - for (auto iVar = 0u; iVar < nVar; iVar++) sendDonorVar(iSend, iVar) = Donor_Variable[iVar]; - + for (auto iVar = 0u; iVar < nVar; iVar++) { + if (AD::IsActive(Donor_Variable[iVar]) != 0) cout << "Donor var " << iVar << " is active " << endl; + sendDonorVar(iSend, iVar) = Donor_Variable[iVar]; + } sendDonorIdx[iSend] = iSpan; ++iSend; } } /*--- Gather data. ---*/ - const int nGlobalSpanDonor = spanIdx.back() + nAllSpanDonor.back(); - - vector donorIdx(nGlobalSpanDonor); - su2activematrix donorVar(nGlobalSpanDonor, 8); - int nSpanSize = nSpanDonor*size; + const int nTotalDonors = nSpanDonor * size; + const int nSpanDonorVars = nSpanDonor * 8; + vector donorIdx(nTotalDonors); + su2activematrix donorVar(nTotalDonors, 8); - SU2_MPI::Allgatherv(sendDonorIdx.data(), sendDonorIdx.size(), MPI_UNSIGNED_LONG, donorIdx.data(), - nAllSpanDonor.data(), spanIdx.data(), MPI_UNSIGNED_LONG, SU2_MPI::GetComm()); + SU2_MPI::Allgather(sendDonorIdx.data(), nSpanDonor, MPI_UNSIGNED_LONG, + donorIdx.data(), nSpanDonor, MPI_UNSIGNED_LONG, + SU2_MPI::GetComm()); - SU2_MPI::Allgatherv(sendDonorVar.data(), sendDonorVar.size(), MPI_DOUBLE, donorVar.data(), - nAllVarCounts.data(), spanVar.data(), MPI_DOUBLE, SU2_MPI::GetComm()); + SU2_MPI::Allgather(sendDonorVar.data(), nSpanDonorVars, MPI_DOUBLE, + donorVar.data(), nSpanDonorVars, MPI_DOUBLE, + SU2_MPI::GetComm()); /*--- This rank does not need to do more work. ---*/ if (markTarget < 0) continue; @@ -123,7 +113,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter for (auto iTargetSpan = 0ul; iTargetSpan < nTargetSpan; iTargetSpan++) { - auto& targetSpan = interpolator.targetSpans[markTarget]; + auto& targetSpan = interpolator.targetSpans[iMarkerInt][markTarget]; const auto nDonorSpan = targetSpan.nDonor(); InitializeTarget_Variable(target_solution, markTarget, iTargetSpan, nDonorSpan); diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 62e7d350c799..f62e941eca11 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -460,10 +460,12 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig **config_con } } - MixingState.resize(nMarker); - MixingStateNodes.resize(nMarker); + auto nMarkerMixingPlane = config->GetnMarker_MixingPlaneInterface(); - for (unsigned long iMarker = 0; iMarker < nMarker; iMarker++) { + MixingState.resize(nMarkerMixingPlane); + MixingStateNodes.resize(nMarkerMixingPlane); + + for (unsigned long iMarker = 0; iMarker < nMarkerMixingPlane; iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == GILES_BOUNDARY) { MixingState[iMarker].resize(nSpanWiseSections+1); MixingStateNodes[iMarker].resize(nSpanWiseSections+1); From 43f729f02e5139420251cec472cfa62c6c8a0b69 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sat, 15 Nov 2025 04:33:49 +0000 Subject: [PATCH 18/79] remove test --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 5901857e14ea..4d5d54062d3c 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -83,10 +83,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter if (markDonor >= 0) { for (auto iSpan = 0ul, iSend = 0ul; iSpan < nSpanDonor; iSpan++) { GetDonor_Variable(donor_solution, donor_geometry, donor_config, markDonor, iSpan, 0); - for (auto iVar = 0u; iVar < nVar; iVar++) { - if (AD::IsActive(Donor_Variable[iVar]) != 0) cout << "Donor var " << iVar << " is active " << endl; - sendDonorVar(iSend, iVar) = Donor_Variable[iVar]; - } + for (auto iVar = 0u; iVar < nVar; iVar++) sendDonorVar(iSend, iVar) = Donor_Variable[iVar]; sendDonorIdx[iSend] = iSpan; ++iSend; } From f5566b8eb6681494d5e09861bc0eb64a0296b9ac Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sun, 16 Nov 2025 00:16:56 +0000 Subject: [PATCH 19/79] Working RANS mixing-plane 2D (3D tbc) --- SU2_CFD/include/solvers/CEulerSolver.hpp | 105 ------------------ SU2_CFD/include/solvers/CSolver.hpp | 76 ------------- SU2_CFD/src/drivers/CDriver.cpp | 4 - .../src/iteration/CDiscAdjFluidIteration.cpp | 2 + SU2_CFD/src/solvers/CEulerSolver.cpp | 11 +- 5 files changed, 4 insertions(+), 194 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index b4dd8a3c1003..97e8a55268c6 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -124,20 +124,14 @@ class CEulerSolver : public CFVMFlowSolverBase AverageVelocity; vector AverageTurboVelocity; vector OldAverageTurboVelocity; - // vector ExtAverageTurboVelocity; su2activematrix AveragePressure; su2activematrix OldAveragePressure; su2activematrix RadialEquilibriumPressure; - // su2activematrix ExtAveragePressure; su2activematrix AverageDensity; su2activematrix OldAverageDensity; - // su2activematrix ExtAverageDensity; su2activematrix AverageNu; su2activematrix AverageKine; su2activematrix AverageOmega; - // su2activematrix ExtAverageNu; - // su2activematrix ExtAverageKine; - // su2activematrix ExtAverageOmega; su2activevector AverageMassFlowRate; su2activematrix DensityIn; @@ -1333,105 +1327,6 @@ class CEulerSolver : public CFVMFlowSolverBaseval_marker. - */ - // inline su2double GetExtAverageNu(unsigned short valMarker, unsigned short valSpan) const final { - // return ExtAverageNu[valMarker][valSpan]; - // } - - // /*! - // * \brief Provide the average density at the boundary of interest. - // * \param[in] val_marker - bound marker. - // * \return Value of the Average turbulent Kine on the surface val_marker. - // */ - // inline su2double GetExtAverageKine(unsigned short valMarker, unsigned short valSpan) const final { - // return ExtAverageKine[valMarker][valSpan]; - // } - - // /*! - // * \brief Provide the average density at the boundary of interest. - // * \param[in] val_marker - bound marker. - // * \return Value of the Average turbulent Omega on the surface val_marker. - // */ - // inline su2double GetExtAverageOmega(unsigned short valMarker, unsigned short valSpan) const final { - // return ExtAverageOmega[valMarker][valSpan]; - // } - - // /*! - // * \brief Set the external average density at the boundary of interest. - // * \param[in] val_marker - bound marker. - // * \param[in] val_Span - value of the Span. - // * \param[in] valDensity - value to set. - // */ - // inline void SetExtAverageDensity(unsigned short valMarker, - // unsigned short valSpan, - // su2double valDensity) final { - // ExtAverageDensity[valMarker][valSpan] = valDensity; - // } - - // /*! - // * \brief Set the external average density at the boundary of interest. - // * \param[in] val_marker - bound marker. - // * \param[in] val_Span - value of the Span. - // * \param[in] valPressure - value to set. - // */ - // inline void SetExtAveragePressure(unsigned short valMarker, - // unsigned short valSpan, - // su2double valPressure) final { - // ExtAveragePressure[valMarker][valSpan] = valPressure; - // } - - // /*! - // * \brief Set the external the average turbo velocity average at the boundary of interest. - // * \param[in] val_marker - bound marker. - // * \return Value of the Average Total Pressure on the surface val_marker. - // */ - // inline void SetExtAverageTurboVelocity(unsigned short valMarker, - // unsigned short valSpan, - // unsigned short valIndex, - // su2double valTurboVelocity) final { - // ExtAverageTurboVelocity[valMarker][valSpan][valIndex] = valTurboVelocity; - // } - - // /*! - // * \brief Set the external average turbulent Nu at the boundary of interest. - // * \param[in] val_marker - bound marker. - // * \param[in] val_Span - value of the Span. - // * \param[in] valNu - value to set. - // */ - // inline void SetExtAverageNu(unsigned short valMarker, - // unsigned short valSpan, - // su2double valNu) final { - // ExtAverageNu[valMarker][valSpan] = valNu; - // } - - // /*! - // * \brief Set the external average turbulent Kine at the boundary of interest. - // * \param[in] val_marker - bound marker. - // * \param[in] val_Span - value of the Span. - // * \param[in] valKine - value to set. - // */ - // inline void SetExtAverageKine(unsigned short valMarker, - // unsigned short valSpan, - // su2double valKine) final { - // ExtAverageKine[valMarker][valSpan] = valKine; - // } - - // /*! - // * \brief Set the external average turbulent Omega at the boundary of interest. - // * \param[in] val_marker - bound marker. - // * \param[in] val_Span - value of the Span. - // * \param[in] valOmega - value to set. - // */ - // inline void SetExtAverageOmega(unsigned short valMarker, - // unsigned short valSpan, - // su2double valOmega) final { - // ExtAverageOmega[valMarker][valSpan] = valOmega; - // } - /*! * \brief Provide the inlet density to check convergence of conservative mixing-plane. * \param[in] inMarkerTP - bound marker. diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 7faa1c1bc1a1..134e2ebe1095 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -3909,82 +3909,6 @@ class CSolver { */ inline virtual su2double GetAverageOmega(unsigned short valMarker, unsigned short valSpan) const { return 0.0; } - /*! - * \brief A virtual member. - * \param[in] val_marker - bound marker. - * \return Value of the Average Nu on the surface val_marker. - */ - // inline virtual su2double GetExtAverageNu(unsigned short valMarker, unsigned short valSpan) const { return 0.0; } - - // /*! - // * \brief A virtual member. - // * \param[in] val_marker - bound marker. - // * \return Value of the Average Kine on the surface val_marker. - // */ - // inline virtual su2double GetExtAverageKine(unsigned short valMarker, unsigned short valSpan) const { return 0.0; } - - // /*! - // * \brief A virtual member. - // * \param[in] val_marker - bound marker. - // * \return Value of the Average Omega on the surface val_marker. - // */ - // inline virtual su2double GetExtAverageOmega(unsigned short valMarker, unsigned short valSpan) const { return 0.0; } - - // /*! - // * \brief A virtual member. - // * \param[in] val_marker - bound marker. - // * \return Value of the Average Density on the surface val_marker. - // */ - // inline virtual void SetExtAverageDensity(unsigned short valMarker, - // unsigned short valSpan, - // su2double valDensity) { } - - // /*! - // * \brief A virtual member. - // * \param[in] val_marker - bound marker. - // * \return Value of the Average Pressure on the surface val_marker. - // */ - // inline virtual void SetExtAveragePressure(unsigned short valMarker, - // unsigned short valSpan, - // su2double valPressure) { } - - // /*! - // * \brief A virtual member. - // * \param[in] val_marker - bound marker. - // * \return Value of the Average Total Pressure on the surface val_marker. - // */ - // inline virtual void SetExtAverageTurboVelocity(unsigned short valMarker, - // unsigned short valSpan, - // unsigned short valIndex, - // su2double valTurboVelocity) { } - - // /*! - // * \brief A virtual member. - // * \param[in] val_marker - bound marker. - // * \return Value of the Average Nu on the surface val_marker. - // */ - // inline virtual void SetExtAverageNu(unsigned short valMarker, - // unsigned short valSpan, - // su2double valNu) { } - - // /*! - // * \brief A virtual member. - // * \param[in] val_marker - bound marker. - // * \return Value of the Average Kine on the surface val_marker. - // */ - // inline virtual void SetExtAverageKine(unsigned short valMarker, - // unsigned short valSpan, - // su2double valKine) { } - - // /*! - // * \brief A virtual member. - // * \param[in] val_marker - bound marker. - // * \return Value of the Average Omega on the surface val_marker. - // */ - // inline virtual void SetExtAverageOmega(unsigned short valMarker, - // unsigned short valSpan, - // su2double valOmega) { } - /*! * \brief A virtual member. * \param[in] inMarkerTP - bound marker. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index c408577b6976..491618e8b2d8 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2685,10 +2685,6 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, } } - 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---*/ for (iZone = 1; iZone < nZone; iZone++) { nBlades = config[iZone]->GetnBlades(iZone); diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 47690ea779b3..43616306056b 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -497,6 +497,8 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** if (config[iZone]->GetBoolTurbomachinery()) { solvers0[FLOW_SOL]->PreprocessAverage(solvers0, geometry0, config[iZone], INFLOW); solvers0[FLOW_SOL]->PreprocessAverage(solvers0, geometry0, config[iZone], OUTFLOW); + solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], INFLOW); + solvers0[FLOW_SOL]->TurboAverageProcess(solvers0, geometry0, config[iZone], OUTFLOW); if (config[iZone]->GetBoolGiles() && config[iZone]->GetSpatialFourier()){ auto conv_bound_numerics = numerics[iZone][iInst][MESH_0][FLOW_SOL][CONV_BOUND_TERM + omp_get_thread_num()*MAX_TERMS]; solvers0[FLOW_SOL]->PreprocessBC_Giles(geometry0, config[iZone], conv_bound_numerics, INFLOW); diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index f62e941eca11..16f4a2463f2c 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -396,28 +396,21 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig **config_con AverageVelocity.resize(nMarker); AverageTurboVelocity.resize(nMarker); OldAverageTurboVelocity.resize(nMarker); - // ExtAverageTurboVelocity.resize(nMarker); AverageFlux.resize(nMarker); SpanTotalFlux.resize(nMarker); AveragePressure.resize(nMarker,nSpanWiseSections+1) = su2double(0.0); OldAveragePressure = AveragePressure; RadialEquilibriumPressure = AveragePressure; - // ExtAveragePressure = AveragePressure; AverageDensity = AveragePressure; OldAverageDensity = AveragePressure; - // ExtAverageDensity = AveragePressure; AverageNu = AveragePressure; AverageKine = AveragePressure; AverageOmega = AveragePressure; - // ExtAverageNu = AveragePressure; - // ExtAverageKine = AveragePressure; - // ExtAverageOmega = AveragePressure; for (unsigned long iMarker = 0; iMarker < nMarker; iMarker++) { AverageVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0); AverageTurboVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0); OldAverageTurboVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0); - // ExtAverageTurboVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0); AverageFlux[iMarker].resize(nSpanWiseSections+1,nVar) = su2double(0.0); SpanTotalFlux[iMarker].resize(nSpanWiseSections+1,nVar) = su2double(0.0); } @@ -6255,7 +6248,7 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu deltaSpan = SpanWiseValues[nSpanWiseSections-1]*spanPercent; coeffrelfacAvg = (relfacAvgCfg - extrarelfacAvg)/deltaSpan; } - + SU2_OMP_FOR_STAT(OMP_MIN_SIZE) for (iSpan= 0; iSpan < nSpanWiseSections ; iSpan++){ /*--- Compute under relaxation for the Hub and Shroud Avg and Fourier Coefficient---*/ if(nDim == 3){ @@ -6522,7 +6515,7 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu /*--- Loop over all the vertices on this boundary marker ---*/ - SU2_OMP_FOR_DYN(OMP_MIN_SIZE) + //SU2_OMP_FOR_DYN(OMP_MIN_SIZE) for (iVertex = 0; iVertex < geometry->GetnVertexSpan(val_marker,iSpan); iVertex++) { /*--- using the other vertex information for retrieving some information ---*/ From 674545af54343e6157d10584c5a87526f7391567 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 17 Nov 2025 08:30:28 +0000 Subject: [PATCH 20/79] MPI + Various Bug Fixes --- Common/include/CConfig.hpp | 7 + .../interface_interpolation/CInterpolator.hpp | 13 +- Common/src/CConfig.cpp | 17 + .../interface_interpolation/CMixingPlane.cpp | 62 +-- SU2_CFD/include/interfaces/CInterface.hpp | 4 +- .../interfaces/cfd/CMixingPlaneInterface.hpp | 13 +- SU2_CFD/include/iteration/CFluidIteration.hpp | 2 +- SU2_CFD/src/drivers/CDriver.cpp | 20 - SU2_CFD/src/drivers/CMultizoneDriver.cpp | 25 +- SU2_CFD/src/interfaces/CInterface.cpp | 439 ------------------ .../interfaces/cfd/CMixingPlaneInterface.cpp | 86 ++-- SU2_CFD/src/iteration/CFluidIteration.cpp | 1 + SU2_CFD/src/solvers/CEulerSolver.cpp | 16 +- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 2 - 14 files changed, 113 insertions(+), 594 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 2f68d9b012f9..4d8eb2ba2bbc 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -10052,6 +10052,13 @@ class CConfig { */ short FindInterfaceMarker(unsigned short iInterface) const; + /*! + * \brief Find the marker index (if any) that is part of a mixing plane interface pair. + * \param[in] nMarker - Number of the marker in a zone being tested, starting at 0. + * \return value > 1 if (on this mpi rank) the zone defined by config is part of the mixing plane. + */ + short FindMixingPlaneInterfaceMarker(unsigned short nMarker) const; + /*! * \brief Get whether or not to save solution data to libROM. * \return True if specified in config file. diff --git a/Common/include/interface_interpolation/CInterpolator.hpp b/Common/include/interface_interpolation/CInterpolator.hpp index 56b5b94b5f0f..3a4a0c3a84c4 100644 --- a/Common/include/interface_interpolation/CInterpolator.hpp +++ b/Common/include/interface_interpolation/CInterpolator.hpp @@ -102,17 +102,8 @@ class CInterpolator { vector > targetVertices; /*! \brief Donor information per marker per vertex of the target. */ struct CSpanDonorInfo { - vector processor; - vector globalSpan; - vector coefficient; - - unsigned long nDonor() const { return processor.size(); } - - void resize(size_t nDonor) { - processor.resize(nDonor); - globalSpan.resize(nDonor); // Refers to the donor span - coefficient.resize(nDonor); // Refers to the coefficient - } + unsigned long donorSpan; // Refers to donor span + su2double coefficient; // Refers to coefficient }; vector> targetSpans; // > diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index bb1cf192f5ae..da9597e8f4b1 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -9934,6 +9934,23 @@ short CConfig::FindInterfaceMarker(unsigned short iInterface) const { return -1; } +short CConfig::FindMixingPlaneInterfaceMarker(unsigned short iMarkerInt, unsigned short nMarker) const { + short mark; + for (auto iMarker = 0; iMarker < nMarker; iMarker++){ + /*--- If the tag GetMarker_All_MixingPlaneInterface equals the index we are looping at ---*/ + if (GetMarker_All_MixingPlaneInterface(iMarker)){ + /*--- We have identified the local index of the marker ---*/ + /*--- Store the identifier for the marker ---*/ + mark = iMarker; + /*--- Exit the for loop: we have found the local index for Mixing-Plane interface ---*/ + return mark; + } + /*--- If the tag hasn't matched any tag within the donor markers ---*/ + mark = -1; + } + return mark; +} + void CConfig::Tick(double *val_start_time) { #ifdef PROFILE diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index a3b2a2baa3bc..81f886386681 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -58,22 +58,8 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { int markDonor = -1, markTarget = -1; unsigned short donorFlag = 0, targetFlag = 0; - /*--- On the donor side ---*/ - for (auto iMarkerDonor = 0; iMarkerDonor < nMarkerDonor; iMarkerDonor++){ - /*--- If the tag GetMarker_All_MixingPlaneInterface equals the index we are looping at ---*/ - if ( donor_config->GetMarker_All_MixingPlaneInterface(iMarkerDonor) == iMarkerInt ){ - /*--- We have identified the local index of the Donor marker ---*/ - /*--- Now we are going to store the average values that belong to Marker_Donor on each processor ---*/ - /*--- Store the identifier for the structural marker ---*/ - markDonor = iMarkerDonor; - donorFlag = donor_config->GetMarker_All_TurbomachineryFlag(iMarkerDonor); - /*--- Exit the for loop: we have found the local index for Mixing-Plane interface ---*/ - break; - } - /*--- If the tag hasn't matched any tag within the donor markers ---*/ - markDonor = -1; - donorFlag = -1; - } + markDonor = donor_config->FindMixingPlaneInterfaceMarker(iMarkerInt, donor_config->GetnMarker_All()); + donorFlag = (markDonor != -1) ? donor_config->GetMarker_All_MixingPlaneInterface(markDonor) : -1; #ifdef HAVE_MPI auto buffMarkerDonor = new int[size]; @@ -100,20 +86,8 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { delete [] buffDonorFlag; #endif - /*--- On the target side we have to identify the marker as well ---*/ - for (auto iMarkerTarget = 0; iMarkerTarget < nMarkerTarget; iMarkerTarget++){ - /*--- If the tag GetMarker_All_MixingPlaneInterface(iMarkerTarget) equals the index we are looping at ---*/ - if ( target_config->GetMarker_All_MixingPlaneInterface(iMarkerTarget) == iMarkerInt ){ - /*--- Store the identifier for the fluid marker ---*/ - markTarget = iMarkerTarget; - targetFlag = target_config->GetMarker_All_TurbomachineryFlag(iMarkerTarget); - /*--- Exit the for loop: we have found the local index for iMarkerFSI on the FEA side ---*/ - break; - } - /*--- If the tag hasn't matched any tag within the Flow markers ---*/ - markTarget = -1; - targetFlag = -1; - } + markTarget = target_config->FindMixingPlaneInterfaceMarker(iMarkerInt, target_config->GetnMarker_All()); + targetFlag = (markTarget != -1) ? target_config->GetMarker_All_MixingPlaneInterface(markTarget) : -1; if (markTarget == -1 || markDonor == -1) continue; @@ -122,21 +96,17 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { targetSpans[iMarkerInt].resize(nSpanTarget+1); - for (auto iSpanTarget = 0u; iSpanTarget < nSpanTarget; iSpanTarget++){ - targetSpans[iMarkerInt][iSpanTarget].resize(nSpanTarget); - } - const auto spanValuesDonor = donor_geometry->GetSpanWiseValue(donorFlag); const auto spanValuesTarget = target_geometry->GetSpanWiseValue(targetFlag); /*--- Interpolation at hub, shroud & 1D values ---*/ - targetSpans[iMarkerInt][0].globalSpan[0] = 0; - targetSpans[iMarkerInt][0].coefficient[0] = 0.0; + targetSpans[iMarkerInt][0].donorSpan = 0; + targetSpans[iMarkerInt][0].coefficient = 0.0; if (nDim > 2) { - targetSpans[iMarkerInt][nSpanTarget-2].globalSpan[nSpanDonor-2] = nSpanDonor-2; - targetSpans[iMarkerInt][nSpanTarget-2].coefficient[nSpanTarget-2] = 0.0; - targetSpans[iMarkerInt][nSpanTarget-1].globalSpan[nSpanTarget-1] = nSpanDonor-1; - targetSpans[iMarkerInt][nSpanTarget-1].coefficient[nSpanTarget-1] = 0.0; + targetSpans[iMarkerInt][nSpanTarget-2].donorSpan = nSpanDonor-2; + targetSpans[iMarkerInt][nSpanTarget-2].coefficient = 0.0; + targetSpans[iMarkerInt][nSpanTarget-1].donorSpan = nSpanDonor-1; + targetSpans[iMarkerInt][nSpanTarget-1].coefficient = 0.0; } for(auto iSpanTarget = 1; iSpanTarget < nSpanTarget - 2; iSpanTarget++){ @@ -149,8 +119,8 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { switch(donor_config->GetKind_MixingPlaneInterface()){ case MATCHING: - targetSpan.globalSpan[iSpanTarget] = iSpanTarget; - targetSpan.coefficient[iSpanTarget] = 0.0; + targetSpan.donorSpan = iSpanTarget; + targetSpan.coefficient = 0.0; break; case NEAREST_SPAN: @@ -162,8 +132,8 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { tSpan = iSpanDonor; } } - targetSpan.globalSpan[iSpanTarget] = tSpan; - targetSpan.coefficient[iSpanTarget] = 0.0; + targetSpan.donorSpan = tSpan; + targetSpan.coefficient = 0.0; break; case LINEAR_INTERPOLATION: @@ -178,8 +148,8 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { // Calculate interpolation coefficient coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan]) / (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); - targetSpan.globalSpan[iSpanTarget] = kSpan; - targetSpan.coefficient[iSpanTarget] = coeff; + targetSpan.donorSpan = kSpan; + targetSpan.coefficient = coeff; break; default: diff --git a/SU2_CFD/include/interfaces/CInterface.hpp b/SU2_CFD/include/interfaces/CInterface.hpp index 5b17b9dbf8b7..8a741b2c7cbc 100644 --- a/SU2_CFD/include/interfaces/CInterface.hpp +++ b/SU2_CFD/include/interfaces/CInterface.hpp @@ -148,9 +148,9 @@ class CInterface { for (auto iVar = 0u; iVar < nVar; iVar++) Target_Variable[iVar] += donorCoeff * bcastVariable[iVar]; } - inline virtual void RecoverTarget_Variable(const su2double *bcastVariable) { } + inline virtual void RecoverTarget_Variable(const vector bcastVariable, unsigned long idx) { } - inline virtual void RecoverTarget_Variable(const su2double *bcastVariable, const su2double *next_bcastVariable, su2double donorCoeff) { } + inline virtual void RecoverTarget_Variable(const vector bcastVariable, unsigned long idx, su2double donorCoeff) { } diff --git a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp index ff01e68a1c34..5ce053e3ba72 100644 --- a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp +++ b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp @@ -36,6 +36,7 @@ */ class CMixingPlaneInterface : public CInterface { public: + unsigned int nMixingVars; /*! * \overload * \param[in] val_nVar - Number of variables that need to be transferred. @@ -91,15 +92,15 @@ class CMixingPlaneInterface : public CInterface { void SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry, const CConfig *target_config, unsigned long Marker_Target, unsigned long val_Span, unsigned long Point_Target) override; - inline void RecoverTarget_Variable(const su2double *bcastVariable) override{ - for (auto iVar = 0u; iVar < 8; iVar++) { - Target_Variable[iVar] = bcastVariable[iVar]; + inline void RecoverTarget_Variable(const vector bcastVariable, unsigned long iSpan) override{ + for (auto iVar = 0u; iVar < nMixingVars; iVar++) { + Target_Variable[iVar] = bcastVariable[iSpan * nMixingVars + iVar]; } } - inline void RecoverTarget_Variable(const su2double *bcastVariable, const su2double *next_bcastVariable, su2double donorCoeff) override { - for (auto iVar = 0u; iVar < 8; iVar++) { - Target_Variable[iVar] = (1 - donorCoeff)*bcastVariable[iVar] + donorCoeff * next_bcastVariable[iVar]; + inline void RecoverTarget_Variable(const vector bcastVariable, unsigned long iSpan, su2double donorCoeff) override { + for (auto iVar = 0u; iVar < nMixingVars; iVar++) { + Target_Variable[iVar] = (1 - donorCoeff)*bcastVariable[iSpan * nMixingVars + iVar] + donorCoeff * bcastVariable[(iSpan + 1) * nMixingVars + iVar]; } } diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index b6ff154273ca..ca472eda61e2 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -120,7 +120,7 @@ class CFluidIteration : public CIteration { /*! * \brief Computes turboperformance. */ - void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter); + // void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container); /*! * \brief Postprocesses the fluid system before heading to another physics system or the next iteration. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 491618e8b2d8..85d509697afd 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2702,24 +2702,6 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, } } - - if(mixingplane){ - if (rank == MASTER_NODE) cout<<"Preprocessing of the Mixing-Plane Interface." << endl; - for (donorZone = 0; donorZone < nZone; donorZone++) { - nMarkerInt = config_container[donorZone]->GetnMarker_MixingPlaneInterface()/2; - for (iMarkerInt = 1; iMarkerInt <= nMarkerInt; iMarkerInt++){ - for (targetZone = 0; targetZone < nZone; targetZone++) { - if (donorZone == targetZone) continue; - if (interface[donorZone][targetZone]->GetInterfaceType()==MIXING_PLANE){ - interface[donorZone][targetZone]->PreprocessAverage(geometry[donorZone][INST_0][MESH_0], geometry[targetZone][INST_0][MESH_0], - config[donorZone], config[targetZone], - iMarkerInt); - } - } - } - } - } - if(!restart && !discrete_adjoint){ if (rank == MASTER_NODE) cout<<"Initialize turbomachinery solution quantities." << endl; for(iZone = 0; iZone < nZone; iZone++) { @@ -2746,8 +2728,6 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, } } - - //TurbomachineryStagePerformance = std::make_shared(solver[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetFluidModel()); } CDriver::~CDriver() = default; diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 4802d02a57e7..cbfc4576df0e 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -593,24 +593,15 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar break; case MIXING_PLANE: { - interface_container[donorZone][targetZone]->BroadcastData_MixingPlane(*interpolator_container[donorZone][targetZone].get(), - 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]); + interface_container[donorZone][targetZone]->BroadcastData_MixingPlane( + *interpolator_container[donorZone][targetZone].get(), + 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]); break; - // const auto nMarkerInt = config_container[donorZone]->GetnMarker_MixingPlaneInterface() / 2; - - // /*--- Transfer the average value from the donorZone to the targetZone ---*/ - // /*--- Loops over the mixing planes defined in the config file to find the correct mixing plane for the donor-target combination ---*/ - // 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 ); - // } - // break; } default: if(rank == MASTER_NODE) diff --git a/SU2_CFD/src/interfaces/CInterface.cpp b/SU2_CFD/src/interfaces/CInterface.cpp index 7e5a09333853..1fa0d1d87556 100644 --- a/SU2_CFD/src/interfaces/CInterface.cpp +++ b/SU2_CFD/src/interfaces/CInterface.cpp @@ -199,442 +199,3 @@ void CInterface::BroadcastData(const CInterpolator& interpolator, } } } - -void CInterface::PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_geometry, - const CConfig *donor_config, const CConfig *target_config, - unsigned short iMarkerInt){ - - unsigned short nMarkerDonor, nMarkerTarget; // Number of markers on the interface, donor and target side - unsigned short iMarkerDonor, iMarkerTarget; // Variables for iteration over markers - unsigned short iSpan,jSpan, tSpan = 0, kSpan = 0, nSpanDonor, nSpanTarget, Donor_Flag = 0, Target_Flag = 0; - int Marker_Donor = -1, Marker_Target = -1; - - const su2double *SpanValuesDonor, *SpanValuesTarget; - su2double dist, test, dist2, test2; - - nMarkerDonor = donor_geometry->GetnMarker(); - nMarkerTarget = target_geometry->GetnMarker(); - //TODO turbo this approach only works if all the turboamchinery marker - // of all zones have the same amount of span wise sections. - //TODO turbo initialization needed for the MPI routine should be place somewhere else. - nSpanDonor = donor_config->GetnSpanWiseSections(); - nSpanTarget = target_config->GetnSpanWiseSections(); - - /*--- On the donor side ---*/ - for (iMarkerDonor = 0; iMarkerDonor < nMarkerDonor; iMarkerDonor++){ - /*--- If the tag GetMarker_All_MixingPlaneInterface equals the index we are looping at ---*/ - if ( donor_config->GetMarker_All_MixingPlaneInterface(iMarkerDonor) == iMarkerInt ){ - /*--- We have identified the local index of the Donor marker ---*/ - /*--- Now we are going to store the average values that belong to Marker_Donor on each processor ---*/ - /*--- Store the identifier for the structural marker ---*/ - Marker_Donor = iMarkerDonor; - Donor_Flag = donor_config->GetMarker_All_TurbomachineryFlag(iMarkerDonor); - /*--- Exit the for loop: we have found the local index for Mixing-Plane interface ---*/ - break; - } - /*--- If the tag hasn't matched any tag within the donor markers ---*/ - Marker_Donor = -1; - Donor_Flag = -1; - - } - -#ifdef HAVE_MPI - auto BuffMarkerDonor = new int[size]; - auto BuffDonorFlag = new int[size]; - for (int iSize=0; iSize= 0.0){ - Marker_Donor = BuffMarkerDonor[iSize]; - Donor_Flag = BuffDonorFlag[iSize]; - break; - } - } - delete [] BuffMarkerDonor; - delete [] BuffDonorFlag; -#endif - - /*--- On the target side we have to identify the marker as well ---*/ - - for (iMarkerTarget = 0; iMarkerTarget < nMarkerTarget; iMarkerTarget++){ - /*--- If the tag GetMarker_All_MixingPlaneInterface(iMarkerTarget) equals the index we are looping at ---*/ - if ( target_config->GetMarker_All_MixingPlaneInterface(iMarkerTarget) == iMarkerInt ){ - /*--- Store the identifier for the fluid marker ---*/ - - // here i should then store it in the target zone - - Marker_Target = iMarkerTarget; - Target_Flag = target_config->GetMarker_All_TurbomachineryFlag(iMarkerTarget); - /*--- Exit the for loop: we have found the local index for iMarkerFSI on the FEA side ---*/ - break; - } - /*--- If the tag hasn't matched any tag within the Flow markers ---*/ - Marker_Target = -1; - Target_Flag = -1; - } - - if (Marker_Target != -1 && Marker_Donor != -1){ - - SpanValuesDonor = donor_geometry->GetSpanWiseValue(Donor_Flag); - SpanValuesTarget = target_geometry->GetSpanWiseValue(Target_Flag); - - - for(iSpan = 1; iSpan SpanValuesDonor[jSpan]){ - dist = test; - kSpan = jSpan; - } - if(test2 < dist2){ - dist2 = test2; - tSpan = jSpan; - } - - } - switch(donor_config->GetKind_MixingPlaneInterface()){ - case MATCHING: - SpanLevelDonor[iSpan] = iSpan; - SpanValueCoeffTarget[iSpan] = 0.0; - break; - case NEAREST_SPAN: - SpanLevelDonor[iSpan] = tSpan; - SpanValueCoeffTarget[iSpan] = 0.0; - break; - case LINEAR_INTERPOLATION: - SpanLevelDonor[iSpan] = kSpan; - SpanValueCoeffTarget[iSpan] = (SpanValuesTarget[iSpan] - SpanValuesDonor[kSpan]) - /(SpanValuesDonor[kSpan + 1] - SpanValuesDonor[kSpan]); - break; - default: - SU2_MPI::Error("MixingPlane interface option not implemented yet", CURRENT_FUNCTION); - break; - - } - } - } -} - - -void CInterface::AllgatherAverage(CSolver *donor_solution, CSolver *target_solution, - CGeometry *donor_geometry, CGeometry *target_geometry, - const CConfig *donor_config, const CConfig *target_config, unsigned short iMarkerInt){ - - unsigned short nMarkerDonor, nMarkerTarget; // Number of markers on the interface, donor and target side - unsigned short iMarkerDonor, iMarkerTarget; // Variables for iteration over markers - unsigned short iSpan, nSpanDonor, nSpanTarget; - int Marker_Donor = -1, Marker_Target = -1; - su2double *avgPressureDonor = nullptr, *avgDensityDonor = nullptr, *avgNormalVelDonor = nullptr, - *avgTangVelDonor = nullptr, *avg3DVelDonor = nullptr, *avgNuDonor = nullptr, - *avgOmegaDonor = nullptr, *avgKineDonor = nullptr; - su2double *avgPressureTarget = nullptr, *avgDensityTarget = nullptr, *avgNormalVelTarget = nullptr, - *avg3DVelTarget = nullptr, *avgTangVelTarget = nullptr, *avgNuTarget = nullptr, - *avgOmegaTarget = nullptr, *avgKineTarget = nullptr; - -#ifdef HAVE_MPI - int iSize; - su2double *BuffAvgPressureDonor = nullptr, *BuffAvgDensityDonor = nullptr, *BuffAvgNormalVelDonor = nullptr, - *BuffAvg3DVelDonor = nullptr, *BuffAvgTangVelDonor = nullptr, *BuffAvgNuDonor = nullptr, - *BuffAvgKineDonor = nullptr, *BuffAvgOmegaDonor = nullptr; - int nSpanSize, *BuffMarkerDonor; -#endif - - - nMarkerTarget = target_geometry->GetnMarker(); - nMarkerDonor = donor_geometry->GetnMarker(); - nSpanDonor = donor_config->GetnSpanWiseSections() +1; - nSpanTarget = target_config->GetnSpanWiseSections() +1; - - - avgDensityDonor = new su2double[nSpanDonor]; - avgPressureDonor = new su2double[nSpanDonor]; - avgNormalVelDonor = new su2double[nSpanDonor]; - avgTangVelDonor = new su2double[nSpanDonor]; - avg3DVelDonor = new su2double[nSpanDonor]; - avgNuDonor = new su2double[nSpanDonor]; - avgKineDonor = new su2double[nSpanDonor]; - avgOmegaDonor = new su2double[nSpanDonor]; - - for (iSpan = 0; iSpan < nSpanDonor; iSpan++){ - avgDensityDonor[iSpan] = -1.0; - avgPressureDonor[iSpan] = -1.0; - avgNormalVelDonor[iSpan] = -1.0; - avgTangVelDonor[iSpan] = -1.0; - avg3DVelDonor[iSpan] = -1.0; - avgNuDonor[iSpan] = -1.0; - avgKineDonor[iSpan] = -1.0; - avgOmegaDonor[iSpan] = -1.0; - } - - avgDensityTarget = new su2double[nSpanTarget]; - avgPressureTarget = new su2double[nSpanTarget]; - avgNormalVelTarget = new su2double[nSpanTarget]; - avgTangVelTarget = new su2double[nSpanTarget]; - avg3DVelTarget = new su2double[nSpanTarget]; - avgNuTarget = new su2double[nSpanTarget]; - avgKineTarget = new su2double[nSpanTarget]; - avgOmegaTarget = new su2double[nSpanTarget]; - - - for (iSpan = 0; iSpan < nSpanTarget; iSpan++){ - avgDensityTarget[iSpan] = -1.0; - avgPressureTarget[iSpan] = -1.0; - avgNormalVelTarget[iSpan] = -1.0; - avgTangVelTarget[iSpan] = -1.0; - avg3DVelTarget[iSpan] = -1.0; - avgNuTarget[iSpan] = -1.0; - avgKineTarget[iSpan] = -1.0; - avgOmegaTarget[iSpan] = -1.0; - } - - /*--- Outer loop over the markers on the Mixing-Plane interface: compute one by one ---*/ - /*--- The tags are always an integer greater than 1: loop from 1 to nMarkerMixingPlane ---*/ - Marker_Donor = -1; - Marker_Target = -1; - - /*--- The donor and target markers are tagged with the same index. - *--- This is independent of the MPI domain decomposition. - *--- We need to loop over all markers on both sides ---*/ - - /*--- On the donor side ---*/ - - for (iMarkerDonor = 0; iMarkerDonor < nMarkerDonor; iMarkerDonor++){ - /*--- If the tag GetMarker_All_MixingPlaneInterface equals the index we are looping at ---*/ - if ( donor_config->GetMarker_All_MixingPlaneInterface(iMarkerDonor) == iMarkerInt ){ - /*--- We have identified the local index of the Donor marker ---*/ - /*--- Now we are going to store the average values that belong to Marker_Donor on each processor ---*/ - /*--- Store the identifier for the structural marker ---*/ - Marker_Donor = iMarkerDonor; - /*--- Exit the for loop: we have found the local index for Mixing-Plane interface ---*/ - break; - } - /*--- If the tag hasn't matched any tag within the donor markers ---*/ - Marker_Donor = -1; - - } - /*--- Here we want to make available the quantities for all the processors and collect them in a buffer - * for each span of the donor the span-wise height vector also so - * that then we can interpolate on the target side ---*/ - if (Marker_Donor != -1){ - for(iSpan = 0; iSpan < nSpanDonor; iSpan++){ - GetDonor_Variable(donor_solution, donor_geometry, donor_config, Marker_Donor, iSpan, rank); - avgDensityDonor[iSpan] = Donor_Variable[0]; - avgPressureDonor[iSpan] = Donor_Variable[1]; - avgNormalVelDonor[iSpan] = Donor_Variable[2]; - avgTangVelDonor[iSpan] = Donor_Variable[3]; - avg3DVelDonor[iSpan] = Donor_Variable[4]; - avgNuDonor[iSpan] = Donor_Variable[5]; - avgKineDonor[iSpan] = Donor_Variable[6]; - avgOmegaDonor[iSpan] = Donor_Variable[7]; - } - } - -#ifdef HAVE_MPI - nSpanSize = size*nSpanDonor; - BuffAvgDensityDonor = new su2double[nSpanSize]; - BuffAvgPressureDonor = new su2double[nSpanSize]; - BuffAvgNormalVelDonor = new su2double[nSpanSize]; - BuffAvgTangVelDonor = new su2double[nSpanSize]; - BuffAvg3DVelDonor = new su2double[nSpanSize]; - BuffAvgNuDonor = new su2double[nSpanSize]; - BuffAvgKineDonor = new su2double[nSpanSize]; - BuffAvgOmegaDonor = new su2double[nSpanSize]; - BuffMarkerDonor = new int[size]; - - for (iSpan=0;iSpan 0.0){ - for (iSpan = 0; iSpan < nSpanDonor; iSpan++){ - avgDensityDonor[iSpan] = BuffAvgDensityDonor[nSpanDonor*iSize + iSpan]; - avgPressureDonor[iSpan] = BuffAvgPressureDonor[nSpanDonor*iSize + iSpan]; - avgNormalVelDonor[iSpan] = BuffAvgNormalVelDonor[nSpanDonor*iSize + iSpan]; - avgTangVelDonor[iSpan] = BuffAvgTangVelDonor[nSpanDonor*iSize + iSpan]; - avg3DVelDonor[iSpan] = BuffAvg3DVelDonor[nSpanDonor*iSize + iSpan]; - avgNuDonor[iSpan] = BuffAvgNuDonor[nSpanDonor*iSize + iSpan]; - avgKineDonor[iSpan] = BuffAvgKineDonor[nSpanDonor*iSize + iSpan]; - avgOmegaDonor[iSpan] = BuffAvgOmegaDonor[nSpanDonor*iSize + iSpan]; - } - Marker_Donor = BuffMarkerDonor[iSize]; - break; - } - } - delete [] BuffAvgDensityDonor; - delete [] BuffAvgPressureDonor; - delete [] BuffAvgNormalVelDonor; - delete [] BuffAvgTangVelDonor; - delete [] BuffAvg3DVelDonor; - delete [] BuffAvgNuDonor; - delete [] BuffAvgKineDonor; - delete [] BuffAvgOmegaDonor; - delete [] BuffMarkerDonor; -#endif - - /*--- On the target side we have to identify the marker as well ---*/ - for (iMarkerTarget = 0; iMarkerTarget < nMarkerTarget; iMarkerTarget++){ - /*--- If the tag GetMarker_All_MixingPlaneInterface(iMarkerTarget) equals the index we are looping at ---*/ - if ( target_config->GetMarker_All_MixingPlaneInterface(iMarkerTarget) == iMarkerInt ){ - /*--- Store the identifier for the fluid marker ---*/ - Marker_Target = iMarkerTarget; - /*--- Exit the for loop: we have found the local index for iMarkerFSI on the FEA side ---*/ - break; - } - /*--- If the tag hasn't matched any tag within the Flow markers ---*/ - Marker_Target = -1; - - } - - - if (Marker_Target != -1 && Marker_Donor != -1){ - - /*--- linear interpolation of the average value of for the internal span-wise levels ---*/ - for(iSpan = 1; iSpan < nSpanTarget -2 ; iSpan++){ - avgDensityTarget[iSpan] = SpanValueCoeffTarget[iSpan]*(avgDensityDonor[SpanLevelDonor[iSpan] + 1] - - avgDensityDonor[SpanLevelDonor[iSpan]]); - avgDensityTarget[iSpan] += avgDensityDonor[SpanLevelDonor[iSpan]]; - avgPressureTarget[iSpan] = SpanValueCoeffTarget[iSpan]*(avgPressureDonor[SpanLevelDonor[iSpan] + 1] - - avgPressureDonor[SpanLevelDonor[iSpan]]); - avgPressureTarget[iSpan] += avgPressureDonor[SpanLevelDonor[iSpan]]; - avgNormalVelTarget[iSpan] = SpanValueCoeffTarget[iSpan]*(avgNormalVelDonor[SpanLevelDonor[iSpan] + 1] - - avgNormalVelDonor[SpanLevelDonor[iSpan]]); - avgNormalVelTarget[iSpan] += avgNormalVelDonor[SpanLevelDonor[iSpan]]; - avgTangVelTarget[iSpan] = SpanValueCoeffTarget[iSpan]*(avgTangVelDonor[SpanLevelDonor[iSpan] + 1] - - avgTangVelDonor[SpanLevelDonor[iSpan]]); - avgTangVelTarget[iSpan] += avgTangVelDonor[SpanLevelDonor[iSpan]]; - avg3DVelTarget[iSpan] = SpanValueCoeffTarget[iSpan]*(avg3DVelDonor[SpanLevelDonor[iSpan] + 1] - - avg3DVelDonor[SpanLevelDonor[iSpan]]); - avg3DVelTarget[iSpan] += avg3DVelDonor[SpanLevelDonor[iSpan]]; - avgNuTarget[iSpan] = SpanValueCoeffTarget[iSpan]*(avgNuDonor[SpanLevelDonor[iSpan] + 1] - - avgNuDonor[SpanLevelDonor[iSpan]]); - avgNuTarget[iSpan] += avgNuDonor[SpanLevelDonor[iSpan]]; - avgKineTarget[iSpan] = SpanValueCoeffTarget[iSpan]*(avgKineDonor[SpanLevelDonor[iSpan] + 1] - - avgKineDonor[SpanLevelDonor[iSpan]]); - avgKineTarget[iSpan] += avgKineDonor[SpanLevelDonor[iSpan]]; - avgOmegaTarget[iSpan] = SpanValueCoeffTarget[iSpan]*(avgOmegaDonor[SpanLevelDonor[iSpan] + 1] - - avgOmegaDonor[SpanLevelDonor[iSpan] ]); - avgOmegaTarget[iSpan] += avgOmegaDonor[SpanLevelDonor[iSpan]]; - } - - - /*--- transfer values at the hub ---*/ - avgDensityTarget[0] = avgDensityDonor[0]; - avgPressureTarget[0] = avgPressureDonor[0]; - avgNormalVelTarget[0] = avgNormalVelDonor[0]; - avgTangVelTarget[0] = avgTangVelDonor[0]; - avg3DVelTarget[0] = avg3DVelDonor[0]; - avgNuTarget[0] = avgNuDonor[0]; - avgKineTarget[0] = avgKineDonor[0]; - avgOmegaTarget[0] = avgOmegaDonor[0]; - - /*--- transfer values at the shroud ---*/ - avgDensityTarget[nSpanTarget - 2] = avgDensityDonor[nSpanDonor - 2]; - avgPressureTarget[nSpanTarget - 2] = avgPressureDonor[nSpanDonor - 2]; - avgNormalVelTarget[nSpanTarget - 2] = avgNormalVelDonor[nSpanDonor - 2]; - avgTangVelTarget[nSpanTarget - 2] = avgTangVelDonor[nSpanDonor - 2]; - avg3DVelTarget[nSpanTarget - 2] = avg3DVelDonor[nSpanDonor - 2]; - avgNuTarget[nSpanTarget - 2] = avgNuDonor[nSpanDonor - 2]; - avgKineTarget[nSpanTarget - 2] = avgKineDonor[nSpanDonor - 2]; - avgOmegaTarget[nSpanTarget - 2] = avgOmegaDonor[nSpanDonor - 2]; - - /*--- transfer 1D values ---*/ - avgDensityTarget[nSpanTarget - 1] = avgDensityDonor[nSpanDonor - 1]; - avgPressureTarget[nSpanTarget - 1] = avgPressureDonor[nSpanDonor - 1]; - avgNormalVelTarget[nSpanTarget - 1] = avgNormalVelDonor[nSpanDonor - 1]; - avgTangVelTarget[nSpanTarget - 1] = avgTangVelDonor[nSpanDonor - 1]; - avg3DVelTarget[nSpanTarget - 1] = avg3DVelDonor[nSpanDonor - 1]; - avgNuTarget[nSpanTarget - 1] = avgNuDonor[nSpanDonor - 1]; - avgKineTarget[nSpanTarget - 1] = avgKineDonor[nSpanDonor - 1]; - avgOmegaTarget[nSpanTarget - 1] = avgOmegaDonor[nSpanDonor - 1]; - - - /*---finally, the interpolated value is sent to the target zone ---*/ - for(iSpan = 0; iSpan < nSpanTarget ; iSpan++){ - Target_Variable[0] = avgDensityTarget[iSpan]; - Target_Variable[1] = avgPressureTarget[iSpan]; - Target_Variable[2] = avgNormalVelTarget[iSpan]; - Target_Variable[3] = avgTangVelTarget[iSpan]; - Target_Variable[4] = avg3DVelTarget[iSpan]; - Target_Variable[5] = avgNuTarget[iSpan]; - Target_Variable[6] = avgKineTarget[iSpan]; - Target_Variable[7] = avgOmegaTarget[iSpan]; - - - SetTarget_Variable(target_solution, target_geometry, target_config, Marker_Target, iSpan, rank); - } - } - - delete [] avgDensityDonor; - delete [] avgPressureDonor; - delete [] avgNormalVelDonor; - delete [] avgTangVelDonor; - delete [] avg3DVelDonor; - delete [] avgNuDonor; - delete [] avgKineDonor; - delete [] avgOmegaDonor; - - - delete [] avgDensityTarget; - delete [] avgPressureTarget; - delete [] avgNormalVelTarget; - delete [] avgTangVelTarget; - delete [] avg3DVelTarget; - delete [] avgNuTarget; - delete [] avgKineTarget; - delete [] avgOmegaTarget; -} diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 4d5d54062d3c..51b06b195620 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -33,9 +33,10 @@ #include "../../../include/solvers/CSolver.hpp" CMixingPlaneInterface::CMixingPlaneInterface(unsigned short val_nVar, unsigned short val_nConst){ - nVar = val_nVar; - Donor_Variable = new su2double[nVar + 5](); - Target_Variable = new su2double[nVar + 5](); + nVar = val_nVar; // Solver vars + nMixingVars = 8; // Always 8 vars in turbo MP + Donor_Variable = new su2double[nMixingVars](); + Target_Variable = new su2double[nMixingVars](); InterfaceType = ENUM_TRANSFER::MIXING_PLANE; } @@ -65,11 +66,11 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter for (auto iMarkerInt = 0u; iMarkerInt < donor_config->GetMarker_n_ZoneInterface()/2; iMarkerInt++) { - /*--- Check if this interface connects the two zones, if not continue. ---*/ - - const auto markDonor = donor_config->FindInterfaceMarker(iMarkerInt); - const auto markTarget = target_config->FindInterfaceMarker(iMarkerInt); + /*--- Find the markers containing the interface ---*/ + short markDonor = donor_config->FindMixingPlaneInterfaceMarker(iMarkerInt, donor_geometry->GetnMarker()); + short markTarget= target_config->FindMixingPlaneInterfaceMarker(iMarkerInt, target_geometry->GetnMarker()); + /*--- Check if this interface connects the two zones, if not continue. ---*/ if(!CInterpolator::CheckInterfaceBoundary(markDonor, markTarget)) continue; // The number of spans is available on every rank @@ -77,33 +78,44 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter /*--- Fill send buffers. ---*/ - vector sendDonorIdx(nSpanDonor); - su2activematrix sendDonorVar(nSpanDonor, 8); + vector sendDonorMarker(nSpanDonor); + vector sendDonorVar(nSpanDonor * nMixingVars); - if (markDonor >= 0) { - for (auto iSpan = 0ul, iSend = 0ul; iSpan < nSpanDonor; iSpan++) { + if (markDonor != -1) { + // cout << "markDonor Identified!" << endl; + for (auto iSpan = 0ul; iSpan < nSpanDonor; iSpan++) { GetDonor_Variable(donor_solution, donor_geometry, donor_config, markDonor, iSpan, 0); - for (auto iVar = 0u; iVar < nVar; iVar++) sendDonorVar(iSend, iVar) = Donor_Variable[iVar]; - sendDonorIdx[iSend] = iSpan; - ++iSend; + for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = Donor_Variable[iVar]; + sendDonorMarker[iSpan] = markDonor; } } +#ifdef HAVE_MPI /*--- Gather data. ---*/ const int nTotalDonors = nSpanDonor * size; - const int nSpanDonorVars = nSpanDonor * 8; - vector donorIdx(nTotalDonors); - su2activematrix donorVar(nTotalDonors, 8); + const int nSpanDonorVars = nSpanDonor * nMixingVars; + vector buffDonorMarker(nTotalDonors); + vector buffDonorVar(nTotalDonors * nMixingVars); - SU2_MPI::Allgather(sendDonorIdx.data(), nSpanDonor, MPI_UNSIGNED_LONG, - donorIdx.data(), nSpanDonor, MPI_UNSIGNED_LONG, + SU2_MPI::Allgather(sendDonorMarker.data(), nSpanDonor, MPI_UNSIGNED_SHORT, + buffDonorMarker.data(), nSpanDonor, MPI_UNSIGNED_SHORT, SU2_MPI::GetComm()); SU2_MPI::Allgather(sendDonorVar.data(), nSpanDonorVars, MPI_DOUBLE, - donorVar.data(), nSpanDonorVars, MPI_DOUBLE, + buffDonorVar.data(), nSpanDonorVars, MPI_DOUBLE, SU2_MPI::GetComm()); + for (auto iSize = 0; iSize < size; iSize++){ + if (buffDonorVar[nSpanDonorVars * iSize] > 0.0) { + for (auto iSpan = 0ul; iSpan < nSpanDonor; iSpan++){ + for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = buffDonorVar[iSize * nSpanDonorVars + iVar]; // This could be wrong in 3D + } + markDonor = buffDonorMarker[iSize * nSpanDonor]; + } + } +#endif + /*--- This rank does not need to do more work. ---*/ - if (markTarget < 0) continue; + if (!(markTarget != -1 && markDonor != -1)) continue; /*--- Loop over target spans. ---*/ auto nTargetSpan = target_config->GetnSpanWiseSections() + 1; @@ -111,37 +123,28 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter for (auto iTargetSpan = 0ul; iTargetSpan < nTargetSpan; iTargetSpan++) { auto& targetSpan = interpolator.targetSpans[iMarkerInt][markTarget]; - const auto nDonorSpan = targetSpan.nDonor(); - InitializeTarget_Variable(target_solution, markTarget, iTargetSpan, nDonorSpan); + InitializeTarget_Variable(target_solution, markTarget, iTargetSpan, nSpanDonor); if ((iTargetSpan == 0) || (iTargetSpan < nTargetSpan - 3)) { /*--- Transfer values at hub, shroud and 1D values ---*/ - unsigned long iDonorSpan; - if (iTargetSpan == 0) iDonorSpan = 0; - else if (iTargetSpan == nTargetSpan - 2) iDonorSpan = nDonorSpan - 2; - else if (iTargetSpan == nTargetSpan - 1) iDonorSpan = nDonorSpan - 1; - - const auto idx = lower_bound(donorIdx.begin(), donorIdx.end(), iDonorSpan) - donorIdx.begin(); - assert(idx < static_cast(donorIdx.size())); + unsigned long donorSpan; + if (iTargetSpan == 0) donorSpan = 0; + else if (iTargetSpan == nTargetSpan - 2) donorSpan = nSpanDonor - 2; + else if (iTargetSpan == nTargetSpan - 1) donorSpan = nSpanDonor - 1; - RecoverTarget_Variable(donorVar[idx]); + RecoverTarget_Variable(sendDonorVar, donorSpan); SetTarget_Variable(target_solution, target_geometry, target_config, markTarget, iTargetSpan, 0); } else { /*--- Get the global index of the donor and the interpolation coefficient. ---*/ - const auto donorSpan = targetSpan.globalSpan[iTargetSpan]; - const auto donorCoeff = targetSpan.coefficient[iTargetSpan]; - - /*--- Find the index of the global donor point in the donor data. ---*/ - - const auto idx = lower_bound(donorIdx.begin(), donorIdx.end(), donorSpan) - donorIdx.begin(); - assert(idx < static_cast(donorIdx.size())); + const auto donorSpan = targetSpan.donorSpan; + const auto donorCoeff = targetSpan.coefficient; /*--- Recover the Target_Variable from the buffer of variables. ---*/ - RecoverTarget_Variable(donorVar[idx], donorVar[idx+1], donorCoeff); + RecoverTarget_Variable(sendDonorVar, donorSpan, donorCoeff); SetTarget_Variable(target_solution, target_geometry, target_config, markTarget, iTargetSpan, 0); } @@ -190,13 +193,12 @@ void CMixingPlaneInterface::SetTarget_Variable(CSolver *target_solution, CGeomet const CConfig *target_config, unsigned long Marker_Target, unsigned long Span_Target, unsigned long Point_Target) { - unsigned short iVar, iDonorSpan, nTargetVar; - nTargetVar = 8; + unsigned short iVar, iDonorSpan; /*--- Set the mixing plane solution with the value of the Target Variable ---*/ iDonorSpan = target_solution->GetnMixingStates(Marker_Target, Span_Target); - for (iVar = 0; iVar < nTargetVar; iVar++) + for (iVar = 0; iVar < nMixingVars; iVar++) target_solution->SetMixingState(Marker_Target, Span_Target, iVar, Target_Variable[iVar]); target_solution->SetnMixingStates( Marker_Target, Span_Target, iDonorSpan + 1 ); diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 0e83b640d6e0..92dc60c408ae 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -226,6 +226,7 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe /*--- Turbomachinery Specific Montior ---*/ if (config[ZONE_0]->GetBoolTurbomachinery()){ if (val_iZone == config[ZONE_0]->GetnZone()-1) { + ComputeTurboPerformance(solver, geometry, config); auto TurbomachineryBladePerformances = GetBladesPerformanceVector(solver, config[val_iZone]->GetnZone()); output->SetHistoryOutput(geometry, solver, config, TurbomachineryStagePerformance, TurbomachineryBladePerformances, diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 16f4a2463f2c..e3e48e00932a 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -5591,8 +5591,8 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain auto nDonorSpan = GetnMixingStates(val_marker, iSpan); su2double donorAverages[8] = {0.0}; - for (auto iVar = 0u; iVar < 8; iVar++) { - donorAverages[iVar] = GetMixingState(val_marker, iSpan, iVar); + for (auto mixVar = 0u; mixVar < 8; mixVar++) { + donorAverages[mixVar] = GetMixingState(val_marker, iSpan, mixVar); } const auto ExtAverageDensity = donorAverages[0]; const auto ExtAveragePressure = donorAverages[1]; @@ -6248,7 +6248,6 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu deltaSpan = SpanWiseValues[nSpanWiseSections-1]*spanPercent; coeffrelfacAvg = (relfacAvgCfg - extrarelfacAvg)/deltaSpan; } - SU2_OMP_FOR_STAT(OMP_MIN_SIZE) for (iSpan= 0; iSpan < nSpanWiseSections ; iSpan++){ /*--- Compute under relaxation for the Hub and Shroud Avg and Fourier Coefficient---*/ if(nDim == 3){ @@ -6290,12 +6289,13 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu su2double ExtAverageDensity, ExtAveragePressure; su2double ExtAverageTurboVelocity[3] = {0.0}; su2double donorAverages[8] = {0.0}; - int nDonorSpan; switch (config->GetKind_Data_Giles(Marker_Tag)){ case MIXING_IN: case MIXING_IN_1D: case MIXING_OUT: case MIXING_OUT_1D: - nDonorSpan = GetnMixingStates(val_marker, iSpan); - for (auto iVar = 0u; iVar < 8; iVar++) { - donorAverages[iVar] = GetMixingState(val_marker, iSpan, iVar); + // for (auto iMarkerGeo = 0u; iMarkeGeo < geometry->GetnMarker(); iMarkerGeo++){ + // if (config->Get) + // } + for (auto mixVar = 0u; mixVar < 8; mixVar++) { + donorAverages[mixVar] = GetMixingState(val_marker, iSpan, mixVar); } ExtAverageDensity = donorAverages[0]; ExtAveragePressure = donorAverages[1]; @@ -6515,7 +6515,7 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu /*--- Loop over all the vertices on this boundary marker ---*/ - //SU2_OMP_FOR_DYN(OMP_MIN_SIZE) + SU2_OMP_FOR_DYN(OMP_MIN_SIZE) for (iVertex = 0; iVertex < geometry->GetnVertexSpan(val_marker,iSpan); iVertex++) { /*--- using the other vertex information for retrieving some information ---*/ diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 7f279b45a905..3b18c17b49f1 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -806,8 +806,6 @@ void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_ auto nDonorSpan = solver_container[FLOW_SOL]->GetnMixingStates(val_marker, iSpan); const auto extAverageKine = solver_container[FLOW_SOL]->GetMixingState(val_marker, iSpan, 6); const auto extAverageOmega = solver_container[FLOW_SOL]->GetMixingState(val_marker, iSpan, 7); - // su2double extAverageKine = solver_container[FLOW_SOL]->GetExtAverageKine(val_marker, iSpan); - // su2double extAverageOmega = solver_container[FLOW_SOL]->GetExtAverageOmega(val_marker, iSpan); su2double solution_j[] = {extAverageKine, extAverageOmega}; /*--- Loop over all the vertices on this boundary marker ---*/ From 63022176166f90efc2b3157310a6390b464e63f0 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 17 Nov 2025 08:45:14 +0000 Subject: [PATCH 21/79] config fix --- Common/src/CConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 1e5d9d77be50..956d01dfdac4 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -9964,7 +9964,7 @@ short CConfig::FindInterfaceMarker(unsigned short iInterface) const { return -1; } -short CConfig::FindMixingPlaneInterfaceMarker(unsigned short iMarkerInt, unsigned short nMarker) const { +short CConfig::FindMixingPlaneInterfaceMarker(unsigned short nMarker) const { short mark; for (auto iMarker = 0; iMarker < nMarker; iMarker++){ /*--- If the tag GetMarker_All_MixingPlaneInterface equals the index we are looping at ---*/ From 408cda4fbb73ea85a7f1ef572e96aea6425d1221 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 17 Nov 2025 12:08:40 +0000 Subject: [PATCH 22/79] fix --- Common/src/interface_interpolation/CMixingPlane.cpp | 4 ++-- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index 81f886386681..cbae8e6987a2 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -58,7 +58,7 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { int markDonor = -1, markTarget = -1; unsigned short donorFlag = 0, targetFlag = 0; - markDonor = donor_config->FindMixingPlaneInterfaceMarker(iMarkerInt, donor_config->GetnMarker_All()); + markDonor = donor_config->FindMixingPlaneInterfaceMarker(donor_config->GetnMarker_All()); donorFlag = (markDonor != -1) ? donor_config->GetMarker_All_MixingPlaneInterface(markDonor) : -1; #ifdef HAVE_MPI @@ -86,7 +86,7 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { delete [] buffDonorFlag; #endif - markTarget = target_config->FindMixingPlaneInterfaceMarker(iMarkerInt, target_config->GetnMarker_All()); + markTarget = target_config->FindMixingPlaneInterfaceMarker(target_config->GetnMarker_All()); targetFlag = (markTarget != -1) ? target_config->GetMarker_All_MixingPlaneInterface(markTarget) : -1; if (markTarget == -1 || markDonor == -1) continue; diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 51b06b195620..5e0e79fff12d 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -67,8 +67,8 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter for (auto iMarkerInt = 0u; iMarkerInt < donor_config->GetMarker_n_ZoneInterface()/2; iMarkerInt++) { /*--- Find the markers containing the interface ---*/ - short markDonor = donor_config->FindMixingPlaneInterfaceMarker(iMarkerInt, donor_geometry->GetnMarker()); - short markTarget= target_config->FindMixingPlaneInterfaceMarker(iMarkerInt, target_geometry->GetnMarker()); + short markDonor = donor_config->FindMixingPlaneInterfaceMarker(donor_geometry->GetnMarker()); + short markTarget= target_config->FindMixingPlaneInterfaceMarker(target_geometry->GetnMarker()); /*--- Check if this interface connects the two zones, if not continue. ---*/ if(!CInterpolator::CheckInterfaceBoundary(markDonor, markTarget)) continue; From 23d0a6e85a3e7eb53bcd44b68f73d5815c27e8b0 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 26 Nov 2025 04:34:13 +0000 Subject: [PATCH 23/79] bug fixes for 3D MP --- .../src/interfaces/cfd/CMixingPlaneInterface.cpp | 4 ++-- SU2_CFD/src/solvers/CEulerSolver.cpp | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 5e0e79fff12d..309a01ba70f4 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -64,7 +64,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter /*--- Loop over interface markers. ---*/ - for (auto iMarkerInt = 0u; iMarkerInt < donor_config->GetMarker_n_ZoneInterface()/2; iMarkerInt++) { + for (auto iMarkerInt = 0u; iMarkerInt < donor_config->GetnMarker_MixingPlaneInterface()/2; iMarkerInt++) { /*--- Find the markers containing the interface ---*/ short markDonor = donor_config->FindMixingPlaneInterfaceMarker(donor_geometry->GetnMarker()); @@ -126,7 +126,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter InitializeTarget_Variable(target_solution, markTarget, iTargetSpan, nSpanDonor); - if ((iTargetSpan == 0) || (iTargetSpan < nTargetSpan - 3)) { + if ((iTargetSpan == 0) || (iTargetSpan > nTargetSpan - 3)) { /*--- Transfer values at hub, shroud and 1D values ---*/ unsigned long donorSpan; if (iTargetSpan == 0) donorSpan = 0; diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index badcdf21b43a..c6984afac554 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -453,12 +453,12 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig **config_con } } - auto nMarkerMixingPlane = config->GetnMarker_MixingPlaneInterface(); + auto nMarkerInterface = config->GetnMarker_ZoneInterface(); - MixingState.resize(nMarkerMixingPlane); - MixingStateNodes.resize(nMarkerMixingPlane); + MixingState.resize(nMarkerInterface); + MixingStateNodes.resize(nMarkerInterface); - for (unsigned long iMarker = 0; iMarker < nMarkerMixingPlane; iMarker++) { + for (unsigned long iMarker = 0; iMarker < nMarkerInterface; iMarker++) { if (config->GetMarker_All_KindBC(iMarker) == GILES_BOUNDARY) { MixingState[iMarker].resize(nSpanWiseSections+1); MixingStateNodes[iMarker].resize(nSpanWiseSections+1); @@ -9642,4 +9642,8 @@ void CEulerSolver::ComputeTurboBladePerformance(CGeometry* geometry, CConfig* co TotalPressureLoss = BladePerf->GetTotalPressureLoss(); KineticEnergyLoss = BladePerf->GetKineticEnergyLoss(); } -} \ No newline at end of file +} + +// void CEulerSolver::RegisterSolutionExtra(bool input, CConfig* config) { +// nodes->RegisterGridVelocity(); +// } \ No newline at end of file From 744d823cf9eb60f3e8b205e76d92f6c44bd02c07 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sat, 29 Nov 2025 01:26:42 +0000 Subject: [PATCH 24/79] Overload compile issues --- SU2_CFD/include/interfaces/CInterface.hpp | 4 ++-- SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp | 4 ++-- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 4 ++-- SU2_CFD/src/iteration/CFluidIteration.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SU2_CFD/include/interfaces/CInterface.hpp b/SU2_CFD/include/interfaces/CInterface.hpp index 8a741b2c7cbc..9e6fdb4d42c4 100644 --- a/SU2_CFD/include/interfaces/CInterface.hpp +++ b/SU2_CFD/include/interfaces/CInterface.hpp @@ -148,9 +148,9 @@ class CInterface { for (auto iVar = 0u; iVar < nVar; iVar++) Target_Variable[iVar] += donorCoeff * bcastVariable[iVar]; } - inline virtual void RecoverTarget_Variable(const vector bcastVariable, unsigned long idx) { } + inline virtual void RecoverTarget_Span_Endwall(const vector bcastVariable, unsigned long idx) { } - inline virtual void RecoverTarget_Variable(const vector bcastVariable, unsigned long idx, su2double donorCoeff) { } + inline virtual void RecoverTarget_Span(const vector bcastVariable, unsigned long idx, su2double donorCoeff) { } diff --git a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp index 5ce053e3ba72..00e3690c5fc7 100644 --- a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp +++ b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp @@ -92,13 +92,13 @@ class CMixingPlaneInterface : public CInterface { void SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry, const CConfig *target_config, unsigned long Marker_Target, unsigned long val_Span, unsigned long Point_Target) override; - inline void RecoverTarget_Variable(const vector bcastVariable, unsigned long iSpan) override{ + inline void RecoverTarget_Span_Endwall(const vector bcastVariable, unsigned long iSpan) override{ for (auto iVar = 0u; iVar < nMixingVars; iVar++) { Target_Variable[iVar] = bcastVariable[iSpan * nMixingVars + iVar]; } } - inline void RecoverTarget_Variable(const vector bcastVariable, unsigned long iSpan, su2double donorCoeff) override { + inline void RecoverTarget_Span(const vector bcastVariable, unsigned long iSpan, su2double donorCoeff) override { for (auto iVar = 0u; iVar < nMixingVars; iVar++) { Target_Variable[iVar] = (1 - donorCoeff)*bcastVariable[iSpan * nMixingVars + iVar] + donorCoeff * bcastVariable[(iSpan + 1) * nMixingVars + iVar]; } diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 309a01ba70f4..9802d7708c2d 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -133,7 +133,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter else if (iTargetSpan == nTargetSpan - 2) donorSpan = nSpanDonor - 2; else if (iTargetSpan == nTargetSpan - 1) donorSpan = nSpanDonor - 1; - RecoverTarget_Variable(sendDonorVar, donorSpan); + RecoverTarget_Span_Endwall(sendDonorVar, donorSpan); SetTarget_Variable(target_solution, target_geometry, target_config, markTarget, iTargetSpan, 0); } @@ -144,7 +144,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter const auto donorCoeff = targetSpan.coefficient; /*--- Recover the Target_Variable from the buffer of variables. ---*/ - RecoverTarget_Variable(sendDonorVar, donorSpan, donorCoeff); + RecoverTarget_Span(sendDonorVar, donorSpan, donorCoeff); SetTarget_Variable(target_solution, target_geometry, target_config, markTarget, iTargetSpan, 0); } diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 92dc60c408ae..850a37c983ac 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -377,7 +377,7 @@ void CFluidIteration::Solve(COutput* output, CIntegration**** integration, CGeom INST_0); /*--- Postprocessing Step ---*/ - Postprocess(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, val_iZone, val_iInst); + // Postprocess(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, val_iZone, val_iInst); /*--- Monitor the pseudo-time ---*/ StopCalc = Monitor(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, From a0659543bd6714a2dde7a3e97457a9ce5da49b90 Mon Sep 17 00:00:00 2001 From: Joshua Kelly Date: Sat, 29 Nov 2025 02:12:53 +0000 Subject: [PATCH 25/79] compiler warnings --- SU2_CFD/include/interfaces/CInterface.hpp | 5 +++-- SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/include/interfaces/CInterface.hpp b/SU2_CFD/include/interfaces/CInterface.hpp index 9e6fdb4d42c4..b809878ef168 100644 --- a/SU2_CFD/include/interfaces/CInterface.hpp +++ b/SU2_CFD/include/interfaces/CInterface.hpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -148,9 +149,9 @@ class CInterface { for (auto iVar = 0u; iVar < nVar; iVar++) Target_Variable[iVar] += donorCoeff * bcastVariable[iVar]; } - inline virtual void RecoverTarget_Span_Endwall(const vector bcastVariable, unsigned long idx) { } + inline virtual void RecoverTarget_Span_Endwall(const vector &bcastVariable, unsigned long idx) { } - inline virtual void RecoverTarget_Span(const vector bcastVariable, unsigned long idx, su2double donorCoeff) { } + inline virtual void RecoverTarget_Span(const vector &bcastVariable, unsigned long idx, su2double donorCoeff) { } diff --git a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp index 00e3690c5fc7..70613cfa5229 100644 --- a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp +++ b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp @@ -29,6 +29,7 @@ #pragma once #include "../CInterface.hpp" +#include /*! * \brief Mixing plane interface for turbomachinery. @@ -92,13 +93,13 @@ class CMixingPlaneInterface : public CInterface { void SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry, const CConfig *target_config, unsigned long Marker_Target, unsigned long val_Span, unsigned long Point_Target) override; - inline void RecoverTarget_Span_Endwall(const vector bcastVariable, unsigned long iSpan) override{ + inline void RecoverTarget_Span_Endwall(const vector &bcastVariable, unsigned long iSpan) override { for (auto iVar = 0u; iVar < nMixingVars; iVar++) { Target_Variable[iVar] = bcastVariable[iSpan * nMixingVars + iVar]; } } - inline void RecoverTarget_Span(const vector bcastVariable, unsigned long iSpan, su2double donorCoeff) override { + inline void RecoverTarget_Span(const vector &bcastVariable, unsigned long iSpan, su2double donorCoeff) override { for (auto iVar = 0u; iVar < nMixingVars; iVar++) { Target_Variable[iVar] = (1 - donorCoeff)*bcastVariable[iSpan * nMixingVars + iVar] + donorCoeff * bcastVariable[(iSpan + 1) * nMixingVars + iVar]; } From 3616b151533d022a9a46869301a08aff8ef3e8f1 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sat, 29 Nov 2025 02:36:52 +0000 Subject: [PATCH 26/79] compiler warnings --- Common/src/interface_interpolation/CMixingPlane.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index cbae8e6987a2..3b7c5f68d7b3 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -43,8 +43,6 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { const auto donor_config = config[donorZone]; const auto target_config = config[targetZone]; - const auto nMarkerDonor = donor_geometry->GetnMarker(); // Number of markers on the interfacce - const auto nMarkerTarget = target_geometry->GetnMarker(); //TODO turbo this approach only works if all the turboamchinery marker // of all zones have the same amount of span wise sections. //TODO turbo initialization needed for the MPI routine should be place somewhere else. @@ -54,7 +52,7 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { targetSpans.resize(config[donorZone]->GetnMarker_MixingPlaneInterface()); /*--- On the donor side ---*/ - for (auto iMarkerInt = 0u; iMarkerInt < nMarkerInt; iMarkerInt++){ + for (auto iMarkerInt = 0; iMarkerInt < nMarkerInt; iMarkerInt++){ int markDonor = -1, markTarget = -1; unsigned short donorFlag = 0, targetFlag = 0; From ea537963b0de9048ce500a15b7286b80382cf9e6 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sat, 29 Nov 2025 19:06:52 +0000 Subject: [PATCH 27/79] compiler warnings + unused code --- SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp | 3 --- SU2_CFD/src/solvers/CEulerSolver.cpp | 4 ---- 2 files changed, 7 deletions(-) diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 43616306056b..ad2c1ca8ac71 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -543,9 +543,6 @@ void CDiscAdjFluidIteration::RegisterOutput(CSolver***** solver, CGeometry**** g if (turbulent && !config[iZone]->GetFrozen_Visc_Disc()) { solvers0[ADJTURB_SOL]->RegisterOutput(geometry0, config[iZone]); } - if (config[iZone]->GetBoolTurbomachinery()) { - solvers0[ADJFLOW_SOL]->Register_VertexNormals(geometry0, config[iZone], false); - } if (config[iZone]->GetKind_Species_Model() != SPECIES_MODEL::NONE) { solvers0[ADJSPECIES_SOL]->RegisterOutput(geometry0, config[iZone]); } diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index c6984afac554..a36b94da073f 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -5581,7 +5581,6 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain for (iDim = 0; iDim < nDim; iDim++) ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - auto nDonorSpan = GetnMixingStates(val_marker, iSpan); su2double donorAverages[8] = {0.0}; for (auto mixVar = 0u; mixVar < 8; mixVar++) { donorAverages[mixVar] = GetMixingState(val_marker, iSpan, mixVar); @@ -6283,9 +6282,6 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu su2double donorAverages[8] = {0.0}; switch (config->GetKind_Data_Giles(Marker_Tag)){ case MIXING_IN: case MIXING_IN_1D: case MIXING_OUT: case MIXING_OUT_1D: - // for (auto iMarkerGeo = 0u; iMarkeGeo < geometry->GetnMarker(); iMarkerGeo++){ - // if (config->Get) - // } for (auto mixVar = 0u; mixVar < 8; mixVar++) { donorAverages[mixVar] = GetMixingState(val_marker, iSpan, mixVar); } From c3d8fb53650f1de4009d151941fdb342df00e282 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sun, 30 Nov 2025 21:34:02 +0000 Subject: [PATCH 28/79] Grid Velocity fixes for fluid-fluid interfaces --- SU2_CFD/include/solvers/CEulerSolver.hpp | 11 +++++ SU2_CFD/src/drivers/CDriver.cpp | 2 +- .../interfaces/cfd/CMixingPlaneInterface.cpp | 11 +++-- SU2_CFD/src/iteration/CFluidIteration.cpp | 6 +-- SU2_CFD/src/numerics/flow/convection/roe.cpp | 2 - SU2_CFD/src/solvers/CEulerSolver.cpp | 45 ++++++++++++++----- 6 files changed, 52 insertions(+), 25 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 97e8a55268c6..0d8f90026361 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -133,6 +133,7 @@ class CEulerSolver : public CFVMFlowSolverBase > > CkInflow, CkOutflow1, CkOutflow2; @@ -158,6 +161,14 @@ class CEulerSolver : public CFVMFlowSolverBase> MixingState; // vector of vector of pointers... inner dim alloc'd elsewhere (welcome, to the night zone) vector> MixingStateNodes; + inline su2double GetTangGridVelIn(unsigned short val_blade, unsigned long val_span) { + return TurboVelocityIn[val_blade][val_span][1] - RelTangVelocityIn[val_blade][val_span]; + } + + inline su2double GetTangGridVelOut(unsigned short val_blade, unsigned long val_span) { + return TurboVelocityOut[val_blade][val_span][1] - RelTangVelocityOut[val_blade][val_span]; + } + /*! * \brief Get the outer state for mixing plane interface nodes. * \param[in] val_marker - marker index diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 85d509697afd..76d01ff2e9c9 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2665,7 +2665,7 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, if (rank == MASTER_NODE) cout<<"Compute inflow and outflow average geometric quantities." << endl; for (iZone = 0; iZone < nZone; iZone++) { geometry[iZone][INST_0][MESH_0]->SetAvgTurboValue(config[iZone], iZone, INFLOW, true); - geometry[iZone][INST_0][MESH_0]->SetAvgTurboValue(config[iZone],iZone, OUTFLOW, true); + geometry[iZone][INST_0][MESH_0]->SetAvgTurboValue(config[iZone], iZone, OUTFLOW, true); geometry[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config[iZone], true); } diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 9802d7708c2d..199c6913c5b5 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -1,8 +1,8 @@ /*! * \file CMixingPlaneInterface.cpp - * \brief Declaration and inlines of the class to transfer average variables + * \brief Declaration and inlines of the class to transfer average solver variables * needed for MixingPlane computation from a generic zone into another one. - * \author S. Vitale + * \author J. Kelly, S. Vitale * \version 8.3.0 "Harrier" * * SU2 Project Website: https://su2code.github.io @@ -34,7 +34,7 @@ CMixingPlaneInterface::CMixingPlaneInterface(unsigned short val_nVar, unsigned short val_nConst){ nVar = val_nVar; // Solver vars - nMixingVars = 8; // Always 8 vars in turbo MP + nMixingVars = 8; // 8 solver vars in turbo MP Donor_Variable = new su2double[nMixingVars](); Target_Variable = new su2double[nMixingVars](); InterfaceType = ENUM_TRANSFER::MIXING_PLANE; @@ -82,7 +82,6 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter vector sendDonorVar(nSpanDonor * nMixingVars); if (markDonor != -1) { - // cout << "markDonor Identified!" << endl; for (auto iSpan = 0ul; iSpan < nSpanDonor; iSpan++) { GetDonor_Variable(donor_solution, donor_geometry, donor_config, markDonor, iSpan, 0); for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = Donor_Variable[iVar]; @@ -118,7 +117,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter if (!(markTarget != -1 && markDonor != -1)) continue; /*--- Loop over target spans. ---*/ - auto nTargetSpan = target_config->GetnSpanWiseSections() + 1; + unsigned long nTargetSpan = target_config->GetnSpanWiseSections() + 1; for (auto iTargetSpan = 0ul; iTargetSpan < nTargetSpan; iTargetSpan++) { @@ -126,7 +125,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter InitializeTarget_Variable(target_solution, markTarget, iTargetSpan, nSpanDonor); - if ((iTargetSpan == 0) || (iTargetSpan > nTargetSpan - 3)) { + if ((iTargetSpan == 0) || (iTargetSpan == nTargetSpan - 1) || (iTargetSpan == nTargetSpan - 2)) { /*--- Transfer values at hub, shroud and 1D values ---*/ unsigned long donorSpan; if (iTargetSpan == 0) donorSpan = 0; diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 850a37c983ac..6e8baec932f4 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -291,10 +291,6 @@ void CFluidIteration::UpdateRamps(CGeometry**** geometry_container, CConfig** co geometry->SetAvgTurboValue(config, iZone, INFLOW, false); geometry->SetAvgTurboValue(config, iZone, OUTFLOW, false); geometry->GatherInOutAverageValues(config, false); - - if (iZone < nZone - 1) { - geometry_container[nZone-1][INST_0][MESH_0]->SetAvgTurboGeoValues(config ,geometry_container[iZone][INST_0][MESH_0], iZone); - } } } @@ -377,7 +373,7 @@ void CFluidIteration::Solve(COutput* output, CIntegration**** integration, CGeom INST_0); /*--- Postprocessing Step ---*/ - // Postprocess(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, val_iZone, val_iInst); + Postprocess(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, val_iZone, val_iInst); /*--- Monitor the pseudo-time ---*/ StopCalc = Monitor(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, diff --git a/SU2_CFD/src/numerics/flow/convection/roe.cpp b/SU2_CFD/src/numerics/flow/convection/roe.cpp index 6a6266d1c8d1..324b13c87756 100644 --- a/SU2_CFD/src/numerics/flow/convection/roe.cpp +++ b/SU2_CFD/src/numerics/flow/convection/roe.cpp @@ -244,8 +244,6 @@ CNumerics::ResidualType<> CUpwRoeBase_Flow::ComputeResidual(const CConfig* confi } AD::SetPreaccOut(Flux, nVar); - AD::SetPreaccOut(Jacobian_i, nVar, nVar); - AD::SetPreaccOut(Jacobian_j, nVar, nVar); AD::EndPreacc(); return ResidualType<>(Flux, Jacobian_i, Jacobian_j); diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index a36b94da073f..05bb70115d2c 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -406,6 +406,7 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig **config_con AverageNu = AveragePressure; AverageKine = AveragePressure; AverageOmega = AveragePressure; + AverageRelTangVelocity = AveragePressure; for (unsigned long iMarker = 0; iMarker < nMarker; iMarker++) { AverageVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0); @@ -432,6 +433,8 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig **config_con KineOut = DensityIn; OmegaOut = DensityIn; NuOut = DensityIn; + RelTangVelocityIn = DensityIn; + RelTangVelocityOut = DensityIn; for (unsigned long iMarker = 0; iMarker < nMarkerTurboPerf; iMarker++) { TurboVelocityIn[iMarker].resize(nSpanMax+1,nDim) = su2double(0.0); @@ -6268,7 +6271,7 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu AverageTurboMach[1] = AverageTurboVelocity[val_marker][iSpan][1]/AverageSoundSpeed; if(dynamic_grid){ - AverageTurboMach[1] -= geometry->GetAverageTangGridVel(val_marker,iSpan)/AverageSoundSpeed; + AverageTurboMach[1] = AverageRelTangVelocity[val_marker][iSpan]/AverageSoundSpeed; } AvgMach = AverageTurboMach[0]*AverageTurboMach[0] + AverageTurboMach[1]*AverageTurboMach[1]; @@ -9021,7 +9024,8 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC for (auto iSpan= 0; iSpan < nSpanWiseSections + 1; iSpan++){ su2double TotalDensity{0}, TotalPressure{0}, TotalNu{0}, TotalOmega{0}, TotalKine{0}, TotalVelocity[MAXNDIM], TotalAreaDensity{0}, TotalAreaPressure{0}, TotalAreaNu{0}, TotalAreaOmega{0}, TotalAreaKine{0}, TotalAreaVelocity[MAXNDIM], - TotalMassDensity{0}, TotalMassPressure{0}, TotalMassNu{0}, TotalMassOmega{0}, TotalMassKine{0}, TotalMassVelocity[MAXNDIM]; + TotalMassDensity{0}, TotalMassPressure{0}, TotalMassNu{0}, TotalMassOmega{0}, TotalMassKine{0}, TotalMassVelocity[MAXNDIM], + TotalRelTangVel{0}, TotalTangFlux{0}, TotalAreaRelTangVel{0}; su2double TotalFluxes[MAXNVAR]; /*--- Forces initialization for contenitors ---*/ @@ -9043,7 +9047,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC const auto Density = nodes->GetDensity(iPoint); const auto Enthalpy = nodes->GetEnthalpy(iPoint); - su2double Velocity[MAXNDIM] = {0}, UnitNormal[MAXNDIM] = {0}, TurboNormal[MAXNDIM] = {0}, TurboVelocity[MAXNDIM] = {0}; + su2double Velocity[MAXNDIM] = {0}, UnitNormal[MAXNDIM] = {0}, TurboNormal[MAXNDIM] = {0}, TurboVelocity[MAXNDIM] = {0}, TurboGridVelocity[MAXNDIM] = {0}; geometry->turbovertex[iMarker][iSpan][iVertex]->GetNormal(UnitNormal); geometry->turbovertex[iMarker][iSpan][iVertex]->GetTurboNormal(TurboNormal); const auto Area = geometry->turbovertex[iMarker][iSpan][iVertex]->GetArea(); @@ -9074,6 +9078,16 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC TotalFluxes[iDim] += Area*(Density*TurboVelocity[0]*TurboVelocity[iDim -1]); TotalFluxes[nDim+1] += Area*(Density*TurboVelocity[0]*Enthalpy); + /*--- Compute relative tangential velocity ---*/ + if (dynamic_grid) { + auto GridVel = geometry->nodes->GetGridVel(iPoint); + ComputeTurboVelocity(GridVel, TurboNormal, TurboGridVelocity, marker_flag, config->GetKind_TurboMachinery(iZone)); + } + + TotalRelTangVel += (TurboVelocity[1] - TurboGridVelocity[1]); + TotalAreaRelTangVel += Area*(TurboVelocity[1] - TurboGridVelocity[1]); + TotalTangFlux += Area*Density*TurboVelocity[0]*(TurboVelocity[1] - TurboGridVelocity[1]); + /*--- Compute turbulent integral quantities for the boundary of interest ---*/ if(turbulent){ @@ -9151,6 +9165,10 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC TotalMassKine = Allreduce(TotalMassKine); TotalMassOmega = Allreduce(TotalMassOmega); + TotalRelTangVel = Allreduce(TotalRelTangVel); + TotalAreaRelTangVel = Allreduce(TotalAreaRelTangVel); + TotalTangFlux = Allreduce(TotalTangFlux); + auto* buffer = new su2double[max(nVar,nDim)]; auto Allreduce_inplace = [buffer](int size, su2double* x) { @@ -9185,7 +9203,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC /*--- Compute the averaged value for the boundary of interest for the span of interest ---*/ const bool belowMachLimit = (abs(MachTest)< config->GetAverageMachLimit()); - su2double avgDensity{0}, avgPressure{0}, avgKine{0}, avgOmega{0}, avgNu{0}, avgVelocity[MAXNDIM] = {0}; + su2double avgDensity{0}, avgPressure{0}, avgKine{0}, avgOmega{0}, avgNu{0}, avgVelocity[MAXNDIM] = {0}, avgRelTangVel{0}; for (auto iVar = 0u; iVarGetTangGridVelIn(iBlade, iSpan)); - auto spanOutletPrimitive = CTurbomachineryPrimitiveState(TurboPrimitiveOut, nDim, geometry->GetTangGridVelOut(iBlade, iSpan)); + auto spanInletPrimitive = CTurbomachineryPrimitiveState(TurboPrimitiveIn, nDim, GetTangGridVelIn(iBlade, iSpan)); + auto spanOutletPrimitive = CTurbomachineryPrimitiveState(TurboPrimitiveOut, nDim, GetTangGridVelOut(iBlade, iSpan)); auto spanCombinedPrimitive = CTurbomachineryCombinedPrimitiveStates(spanInletPrimitive, spanOutletPrimitive); bladePrimitives.push_back(spanCombinedPrimitive); } @@ -9638,8 +9665,4 @@ void CEulerSolver::ComputeTurboBladePerformance(CGeometry* geometry, CConfig* co TotalPressureLoss = BladePerf->GetTotalPressureLoss(); KineticEnergyLoss = BladePerf->GetKineticEnergyLoss(); } -} - -// void CEulerSolver::RegisterSolutionExtra(bool input, CConfig* config) { -// nodes->RegisterGridVelocity(); -// } \ No newline at end of file +} \ No newline at end of file From 0e331f876e0ecf010feb9c9e62edea88111322ca Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sun, 30 Nov 2025 21:50:25 +0000 Subject: [PATCH 29/79] CodeQL Comments --- SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp | 2 +- SU2_CFD/include/iteration/CFluidIteration.hpp | 5 ----- SU2_CFD/src/drivers/CDriver.cpp | 3 +-- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 4 ++-- SU2_CFD/src/solvers/CTurbSASolver.cpp | 3 --- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 1 - 6 files changed, 4 insertions(+), 14 deletions(-) diff --git a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp index 70613cfa5229..2e52f9dba1c3 100644 --- a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp +++ b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp @@ -37,7 +37,7 @@ */ class CMixingPlaneInterface : public CInterface { public: - unsigned int nMixingVars; + unsigned short nMixingVars; /*! * \overload * \param[in] val_nVar - Number of variables that need to be transferred. diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index ca472eda61e2..13718c75afb4 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -117,11 +117,6 @@ class CFluidIteration : public CIteration { */ void UpdateRamps(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, RAMP_TYPE ramp_flag); - /*! - * \brief Computes turboperformance. - */ - // void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container); - /*! * \brief Postprocesses the fluid system before heading to another physics system or the next iteration. * \param[in] solver - Container vector with all the solutions. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 76d01ff2e9c9..3b513a874002 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2654,8 +2654,7 @@ void CDriver::PreprocessTurboVertex(CConfig** config, CGeometry**** geometry, CS void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, CSolver***** solver, CInterface*** interface, CIteration*** iteration, bool dummy){ - unsigned short donorZone,targetZone, nMarkerInt, iMarkerInt; - unsigned short nSpanMax = 0; + unsigned short donorZone,targetZone; bool restart = (config[ZONE_0]->GetRestart() || config[ZONE_0]->GetRestart_Flow()); mixingplane = config[ZONE_0]->GetBoolMixingPlaneInterface(); bool discrete_adjoint = config[ZONE_0]->GetDiscrete_Adjoint(); diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 199c6913c5b5..0b26beaa0c26 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -90,8 +90,8 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter } #ifdef HAVE_MPI /*--- Gather data. ---*/ - const int nTotalDonors = nSpanDonor * size; - const int nSpanDonorVars = nSpanDonor * nMixingVars; + const auto nTotalDonors = nSpanDonor * size; + const auto nSpanDonorVars = nSpanDonor * nMixingVars; vector buffDonorMarker(nTotalDonors); vector buffDonorVar(nTotalDonors * nMixingVars); diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index a1e17b0d276a..14f433b6f3bb 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -1074,11 +1074,8 @@ void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_c /*--- Loop over all the vertices on this boundary marker ---*/ for (auto iSpan = 0u; iSpan < nSpanWiseSections ; iSpan++){ - - auto nDonorSpan = solver_container[FLOW_SOL]->GetnMixingStates(val_marker, iSpan); const auto extAverageNu = solver_container[FLOW_SOL]->GetMixingState(val_marker, iSpan, 5); - // su2double extAverageNu = solver_container[FLOW_SOL]->GetExtAverageNu(val_marker, iSpan); /*--- Loop over all the vertices on this boundary marker ---*/ diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 3b18c17b49f1..a9bb155fc3bf 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -803,7 +803,6 @@ void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_ for (auto iSpan = 0u; iSpan < nSpanWiseSections ; iSpan++){ - auto nDonorSpan = solver_container[FLOW_SOL]->GetnMixingStates(val_marker, iSpan); const auto extAverageKine = solver_container[FLOW_SOL]->GetMixingState(val_marker, iSpan, 6); const auto extAverageOmega = solver_container[FLOW_SOL]->GetMixingState(val_marker, iSpan, 7); su2double solution_j[] = {extAverageKine, extAverageOmega}; From 75a71602110869a0ac1987d6f2ac93c6bde1de87 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sun, 30 Nov 2025 22:04:42 +0000 Subject: [PATCH 30/79] Compiler warning --- SU2_CFD/src/solvers/CEulerSolver.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 05bb70115d2c..02ead3f7dc28 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -6285,18 +6285,16 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu su2double donorAverages[8] = {0.0}; switch (config->GetKind_Data_Giles(Marker_Tag)){ case MIXING_IN: case MIXING_IN_1D: case MIXING_OUT: case MIXING_OUT_1D: - for (auto mixVar = 0u; mixVar < 8; mixVar++) { - donorAverages[mixVar] = GetMixingState(val_marker, iSpan, mixVar); - } - ExtAverageDensity = donorAverages[0]; - ExtAveragePressure = donorAverages[1]; - ExtAverageTurboVelocity[0] = donorAverages[2]; - ExtAverageTurboVelocity[1] = donorAverages[3]; - ExtAverageTurboVelocity[2] = donorAverages[4]; + for (auto mixVar = 0u; mixVar < 8; mixVar++) donorAverages[mixVar] = GetMixingState(val_marker, iSpan, mixVar); break; default: break; } + ExtAverageDensity = donorAverages[0]; + ExtAveragePressure = donorAverages[1]; + ExtAverageTurboVelocity[0] = donorAverages[2]; + ExtAverageTurboVelocity[1] = donorAverages[3]; + ExtAverageTurboVelocity[2] = donorAverages[4]; switch(config->GetKind_Data_Giles(Marker_Tag)){ From cdc4bd69e4c643f25aa9ea836b65cfb9555a00ed Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Sun, 30 Nov 2025 22:06:33 +0000 Subject: [PATCH 31/79] formatting --- SU2_CFD/src/solvers/CEulerSolver.cpp | 4 ++-- SU2_CFD/src/solvers/CTurbSASolver.cpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 02ead3f7dc28..2bdaa78d067b 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -6282,10 +6282,10 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu su2double ExtAverageDensity, ExtAveragePressure; su2double ExtAverageTurboVelocity[3] = {0.0}; - su2double donorAverages[8] = {0.0}; + su2double donorAverages[5] = {0.0}; switch (config->GetKind_Data_Giles(Marker_Tag)){ case MIXING_IN: case MIXING_IN_1D: case MIXING_OUT: case MIXING_OUT_1D: - for (auto mixVar = 0u; mixVar < 8; mixVar++) donorAverages[mixVar] = GetMixingState(val_marker, iSpan, mixVar); + for (auto mixVar = 0u; mixVar < 5; mixVar++) donorAverages[mixVar] = GetMixingState(val_marker, iSpan, mixVar); break; default: break; diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index 14f433b6f3bb..76970e5c96ae 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -1076,7 +1076,6 @@ void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_c for (auto iSpan = 0u; iSpan < nSpanWiseSections ; iSpan++){ const auto extAverageNu = solver_container[FLOW_SOL]->GetMixingState(val_marker, iSpan, 5); - /*--- Loop over all the vertices on this boundary marker ---*/ SU2_OMP_FOR_STAT(OMP_MIN_SIZE) From 4b25e222c1073dc0d9438eb23454352b8b7835b0 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 1 Dec 2025 05:58:44 +0000 Subject: [PATCH 32/79] Compiler warnings --- SU2_CFD/include/solvers/CEulerSolver.hpp | 4 ++++ SU2_CFD/src/solvers/CEulerSolver.cpp | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 0d8f90026361..ed49b08439de 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -150,6 +150,10 @@ class CEulerSolver : public CFVMFlowSolverBase > > CkInflow, CkOutflow1, CkOutflow2; su2double EntropyGeneration; diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 2bdaa78d067b..787c3f5e9cf4 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -456,6 +456,12 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig **config_con } } + /*--- Initialise donor quantities ---*/ + ExtAverageDensity = su2double(0.0); + ExtAveragePressure = su2double(0.0); + ExtAverageTurboVelocity.resize(nDim); + for (auto iDim = 0u; iDim < nDim; iDim++) ExtAverageTurboVelocity[iDim] = su2double(0.0); + auto nMarkerInterface = config->GetnMarker_ZoneInterface(); MixingState.resize(nMarkerInterface); @@ -5584,13 +5590,16 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain for (iDim = 0; iDim < nDim; iDim++) ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; - su2double donorAverages[8] = {0.0}; - for (auto mixVar = 0u; mixVar < 8; mixVar++) { - donorAverages[mixVar] = GetMixingState(val_marker, iSpan, mixVar); + su2double donorAverages[5] = {0.0}; + switch (config->GetKind_Data_Giles(Marker_Tag)){ + case MIXING_IN: case MIXING_IN_1D: case MIXING_OUT: case MIXING_OUT_1D: + for (auto mixVar = 0u; mixVar < 5; mixVar++) donorAverages[mixVar] = GetMixingState(val_marker, iSpan, mixVar); + break; + default: + break; } - const auto ExtAverageDensity = donorAverages[0]; - const auto ExtAveragePressure = donorAverages[1]; - su2double ExtAverageTurboVelocity[3] = {0.0}; + ExtAverageDensity = donorAverages[0]; + ExtAveragePressure = donorAverages[1]; ExtAverageTurboVelocity[0] = donorAverages[2]; ExtAverageTurboVelocity[1] = donorAverages[3]; ExtAverageTurboVelocity[2] = donorAverages[4]; @@ -6280,8 +6289,6 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu kend_max = geometry->GetnFreqSpanMax(config->GetMarker_All_TurbomachineryFlag(val_marker)); conv_numerics->GetRMatrix(AverageSoundSpeed, AverageDensity[val_marker][iSpan], R_Matrix); - su2double ExtAverageDensity, ExtAveragePressure; - su2double ExtAverageTurboVelocity[3] = {0.0}; su2double donorAverages[5] = {0.0}; switch (config->GetKind_Data_Giles(Marker_Tag)){ case MIXING_IN: case MIXING_IN_1D: case MIXING_OUT: case MIXING_OUT_1D: From 8f361bf097bc763fbb3803c2a82a917c3d947522 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 1 Dec 2025 06:06:44 +0000 Subject: [PATCH 33/79] Resolve casting complaints --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 0b26beaa0c26..862e509f0dbe 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -79,7 +79,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter /*--- Fill send buffers. ---*/ vector sendDonorMarker(nSpanDonor); - vector sendDonorVar(nSpanDonor * nMixingVars); + vector sendDonorVar(static_cast(nSpanDonor) * nMixingVars); if (markDonor != -1) { for (auto iSpan = 0ul; iSpan < nSpanDonor; iSpan++) { @@ -104,11 +104,11 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter SU2_MPI::GetComm()); for (auto iSize = 0; iSize < size; iSize++){ - if (buffDonorVar[nSpanDonorVars * iSize] > 0.0) { + if (buffDonorVar[static_cast(nSpanDonorVars) * iSize] > 0.0) { for (auto iSpan = 0ul; iSpan < nSpanDonor; iSpan++){ - for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = buffDonorVar[iSize * nSpanDonorVars + iVar]; // This could be wrong in 3D + for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = buffDonorVar[static_cast(iSize) * nSpanDonorVars + iVar]; // This could be wrong in 3D } - markDonor = buffDonorMarker[iSize * nSpanDonor]; + markDonor = buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor)]; } } #endif From fac7b3c5fa4ae02a49901e2791cdf198a698bcfd Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 1 Dec 2025 06:23:46 +0000 Subject: [PATCH 34/79] Unused var --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 2 +- SU2_CFD/src/iteration/CIteration.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 862e509f0dbe..63ecd872ecd1 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -93,7 +93,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter const auto nTotalDonors = nSpanDonor * size; const auto nSpanDonorVars = nSpanDonor * nMixingVars; vector buffDonorMarker(nTotalDonors); - vector buffDonorVar(nTotalDonors * nMixingVars); + vector buffDonorVar(static_cast(nTotalDonors) * nMixingVars); SU2_MPI::Allgather(sendDonorMarker.data(), nSpanDonor, MPI_UNSIGNED_SHORT, buffDonorMarker.data(), nSpanDonor, MPI_UNSIGNED_SHORT, diff --git a/SU2_CFD/src/iteration/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index 08e27fb190b5..a29111da3775 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -216,8 +216,6 @@ void CIteration::InitTurboPerformance(CGeometry* geometry, CConfig** config, CFl void CIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container) { // Computes the turboperformance per blade in zone iBlade - const auto nDim = geometry_container[ZONE_0][INST_0][MESH_0]->GetnDim(); - const auto nBladesRow = config_container[ZONE_0]->GetnMarker_Turbomachinery(); const auto nZone = config_container[ZONE_0]->GetnZone(); auto TurbomachineryBladePerformances = GetBladesPerformanceVector(solver, nZone); From f3daa3dd3ea8eb349cf3e37fa50c80dee985cfb8 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 1 Dec 2025 06:31:32 +0000 Subject: [PATCH 35/79] Added fluid interface testcases --- .../disc_adj_ffi/mixing_plane/circles.cfg | 223 ++++++++++++++++++ .../disc_adj_ffi/mixing_plane/zone_1.cfg | 16 ++ .../disc_adj_ffi/mixing_plane/zone_2.cfg | 16 ++ .../sliding_interface/circles.cfg | 206 ++++++++++++++++ 4 files changed, 461 insertions(+) create mode 100755 TestCases/disc_adj_ffi/mixing_plane/circles.cfg create mode 100644 TestCases/disc_adj_ffi/mixing_plane/zone_1.cfg create mode 100644 TestCases/disc_adj_ffi/mixing_plane/zone_2.cfg create mode 100755 TestCases/disc_adj_ffi/sliding_interface/circles.cfg diff --git a/TestCases/disc_adj_ffi/mixing_plane/circles.cfg b/TestCases/disc_adj_ffi/mixing_plane/circles.cfg new file mode 100755 index 000000000000..2bfd24a29f33 --- /dev/null +++ b/TestCases/disc_adj_ffi/mixing_plane/circles.cfg @@ -0,0 +1,223 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: 2D Cylinder Interface (Mixing Plane) % +% Author: J. Kelly % +% Institution: University of Liverpool % +% Date: Dec 1st, 2025 % +% File Version 8.3.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +MULTIZONE= YES +CONFIG_LIST= (zone_1.cfg, zone_2.cfg) +% +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= RANS +KIND_TURB_MODEL= SA +READ_BINARY_RESTART=NO +MATH_PROBLEM= DISCRETE_ADJOINT +% +% -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% +% +MACH_NUMBER= 0.05 +AOA= 0.0 +FREESTREAM_PRESSURE= 1E6 +FREESTREAM_TEMPERATURE= 300.0 +FREESTREAM_DENSITY= 1.7418 +FREESTREAM_OPTION= TEMPERATURE_FS +FREESTREAM_TURBULENCEINTENSITY = 0.03 +FREESTREAM_TURB2LAMVISCRATIO = 100.0 +INIT_OPTION= TD_CONDITIONS +% +% ---------------------- 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 +REF_DIMENSIONALIZATION= DIMENSIONAL +% +% ------------------------------ EQUATION OF STATE ----------------------------% +% +FLUID_MODEL= IDEAL_GAS +GAMMA_VALUE= 1.4 +GAS_CONSTANT= 287.058 +% +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +VISCOSITY_MODEL= CONSTANT_VISCOSITY +MU_REF= 1.716E-5 +MU_T_REF= 273.15 +SUTHERLAND_CONSTANT= 110.4 +% +% --------------------------- THERMAL CONDUCTIVITY MODEL ----------------------% +% +CONDUCTIVITY_MODEL= CONSTANT_PRANDTL +% +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +%MARKER_EULER = (INFLOW, INMIX, OUTMIX, OUTFLOW, CIRC1, CIRC2) +MARKER_HEATFLUX= ( CIRC1, 0.0, CIRC2, 0.0) +% +MARKER_PERIODIC= ( PER1, PER2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, PER3, PER4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0) +% +%-------- INFLOW/OUTFLOW BOUNDARY CONDITION SPECIFIC FOR TURBOMACHINERY --------% +% +% Inflow and Outflow markers must be specified, for each blade (zone), following the natural groth of the machine (i.e, from the first blade to the last) +MARKER_TURBOMACHINERY= (INFLOW, OUTMIX, INMIX, 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) +% +MARKER_GILES= (INFLOW, TOTAL_CONDITIONS_PT, 1E6, 300, 1.0, 0.0, 0.0,1.0,1.0, OUTMIX, MIXING_OUT, 0.0, 0.0, 0.0, 0.0, 0.0,1.0,1.0, INMIX, MIXING_IN, 0.0, 0.0, 0.0, 0.0, 0.0,1.0, 1.0, OUTFLOW, STATIC_PRESSURE, 9E5, 0.0, 0.0, 0.0, 0.0,1.0,1.0) +SPATIAL_FOURIER= YES +% +% +%---------------------------- TURBOMACHINERY SIMULATION -----------------------------% +% +TURBOMACHINERY_KIND= AXIAL AXIAL +TURBO_PERF_KIND = TURBINE TURBINE +TURBULENT_MIXINGPLANE= YES +AVERAGE_PROCESS_KIND= MIXEDOUT +PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT +MIXEDOUT_COEFF= (1.0, 1.0E-05, 15) +AVERAGE_MACH_LIMIT= 0.05 +% +% ------------------------ SURFACES IDENTIFICATION ----------------------------% +% +MARKER_PLOTTING= CIRC1, CIRC2 +MARKER_MONITORING= CIRC1, CIRC2 +MARKER_DESIGNING= CIRC1, CIRC2 +MARKER_ANALYZE= CIRC1, CIRC2 +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +CFL_NUMBER= 10.0 +CFL_ADAPT= NO +CFL_ADAPT_PARAM= ( 1.3, 1.2, 1.0, 10.0) +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= LU_SGS +LINEAR_SOLVER_ERROR= 1E-4 +LINEAR_SOLVER_ITER= 20 +% +% ---------- NOT WORKING WITH PERIODIC BOUNDARY CONDITIONS !!!!! --------------% +% +% +% ----------------------- SLOPE LIMITER DEFINITION ----------------------------% +% +VENKAT_LIMITER_COEFF= 0.05 +LIMITER_ITER= 999999 +% +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= ROE +MUSCL_FLOW= NO +SLOPE_LIMITER_FLOW= VAN_ALBADA_EDGE +ENTROPY_FIX_COEFF= 0.1 +JST_SENSOR_COEFF= ( 0.5, 0.02 ) +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% +% +CONV_NUM_METHOD_TURB= SCALAR_UPWIND +MUSCL_TURB= NO +SLOPE_LIMITER_TURB= VENKATAKRISHNAN +TIME_DISCRE_TURB= EULER_IMPLICIT +CFL_REDUCTION_TURB= 1.0 +% +% ----------------------- DESIGN VARIABLE PARAMETERS --------------------------% +% +%DV_KIND= FFD_SETTING +%DV_MARKER= (CIRC1, CIRC2) +%DV_PARAM= ( CIRC1, 1, 0, 0, 0.0, 1.0, 0.0 ) +%DV_VALUE= 0.001 +% +DV_KIND= FFD_CONTROL_POINT_2D, FFD_CONTROL_POINT_2D, FFD_CONTROL_POINT_2D, FFD_CONTROL_POINT_2D +DV_MARKER= ( CIRC1, CIRC2 ) +DV_PARAM=( CIRCLE1, 0, 0, 1.0, 0.0 );( CIRCLE2, 0, 0, 1.0, 0.0 );( CIRCLE1, 1, 1, 1.0, 0.0 );( CIRCLE2, 1, 1, 1.0, 0.0 ) +DV_VALUE=0.0,0.0,0.0,0.0 +% +% ------------------------ GRID DEFORMATION PARAMETERS ------------------------% +% +% Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) +DEFORM_LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (ILU, LU_SGS, JACOBI) +DEFORM_LINEAR_SOLVER_PREC= ILU +% +% Number of smoothing iterations for mesh deformation +DEFORM_LINEAR_SOLVER_ITER= 1000 +% +% Number of nonlinear deformation iterations (surface deformation increments) +DEFORM_NONLINEAR_ITER= 1 +% +% Minimum residual criteria for the linear solver convergence of grid deformation +DEFORM_LINEAR_SOLVER_ERROR= 1E-14 +% +% Print the residuals during mesh deformation to the console (YES, NO) +DEFORM_CONSOLE_OUTPUT= YES +% +% Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, +% WALL_DISTANCE, CONSTANT_STIFFNESS) +DEFORM_STIFFNESS_TYPE= WALL_DISTANCE +% +% +% -------------------- FREE-FORM DEFORMATION PARAMETERS -----------------------% +% +FFD_TOLERANCE= 1E-10 +FFD_ITERATIONS= 500 +FFD_DEFINITION= (CIRCLE1, -2.0, -2.0, 0.0, 2.0, -2.0, 0.0, 2.0, 2.0, 0.0, -2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); (CIRCLE2, 18.0, -2.0, 0.0, 22.0, -2.0, 0.0, 22.0, 2.0, 0.0, 18.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) +FFD_DEGREE= ( 2 , 2 , 0 ); (2, 2, 0) +FFD_CONTINUITY= 2ND_DERIVATIVE +% +% --------------------- OPTIMAL SHAPE DESIGN DEFINITION -----------------------% +% +% FFD_CONTROL_POINT_2D +DEFINITION_DV= ( 19, 1.0 | CIRC1 | CIRCLE1, 0, 0, 1.0, 0.0 ); ( 19, 1.0 | CIRC2 | CIRCLE2, 0, 0, 1.0, 0.0 ); ( 19, 1.0 | CIRC1 | CIRCLE1, 1, 1, 1.0, 0.0 ); ( 19, 1.0 | CIRC2 | CIRCLE2, 1, 1, 1.0, 0.0 ); +OPT_OBJECTIVE= ENTROPY_GENERATION* 0.0001 +OPT_ITERATIONS= 19 +OPT_ACCURACY= 1E-10 +% +% --------------------- OBJECTIVE FUNCTION DEFINITION -----------------------% +% +OBJECTIVE_FUNCTION= ENTROPY_GENERATION +% +% ------------------------- CONVERGENCE PARAMETERS --------------------------% +% +OUTER_ITER= 201 +CONV_RESIDUAL_MINVAL= -16 +CONV_STARTITER= 10 +CONV_CAUCHY_ELEMS= 100 +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], COMBO +HISTORY_OUTPUT= ITER, RMS_RES, COMBO +MESH_FILENAME= circ_out.su2 +MESH_FORMAT= SU2 +MESH_OUT_FILENAME= mesh_out.su2 +SOLUTION_FILENAME= solution_flow +SOLUTION_ADJ_FILENAME= solution_adj +TABULAR_FORMAT= CSV +OUTPUT_FILES= RESTART_ASCII, TECPLOT, SURFACE_TECPLOT +CONV_FILENAME= history +RESTART_FILENAME= restart_flow +RESTART_ADJ_FILENAME= restart_adj +VOLUME_FILENAME= flow +VOLUME_ADJ_FILENAME= adjoint +GRAD_OBJFUNC_FILENAME= of_grad.dat +SURFACE_FILENAME= surface_flow +SURFACE_ADJ_FILENAME= surface_adjoint +SURFACE_SENS_FILENAME= surface_sens +WRT_ZONE_CONV= NO +WRT_ZONE_HIST= YES +OUTPUT_PRECISION= 16 diff --git a/TestCases/disc_adj_ffi/mixing_plane/zone_1.cfg b/TestCases/disc_adj_ffi/mixing_plane/zone_1.cfg new file mode 100644 index 000000000000..3f03e0d7f2e0 --- /dev/null +++ b/TestCases/disc_adj_ffi/mixing_plane/zone_1.cfg @@ -0,0 +1,16 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: 2D Cylinder Interface (Mixing Plane) % +% Author: J. Kelly % +% Institution: University of Liverpool % +% Date: Dec 1st, 2025 % +% File Version 8.3.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ----------------------- DYNAMIC MESH DEFINITION -----------------------------% +% +GRID_MOVEMENT= STEADY_TRANSLATION +MACH_MOTION= 0.35 +TRANSLATION_RATE= 0.0 0.0 0.0 diff --git a/TestCases/disc_adj_ffi/mixing_plane/zone_2.cfg b/TestCases/disc_adj_ffi/mixing_plane/zone_2.cfg new file mode 100644 index 000000000000..3f03e0d7f2e0 --- /dev/null +++ b/TestCases/disc_adj_ffi/mixing_plane/zone_2.cfg @@ -0,0 +1,16 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: 2D Cylinder Interface (Mixing Plane) % +% Author: J. Kelly % +% Institution: University of Liverpool % +% Date: Dec 1st, 2025 % +% File Version 8.3.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ----------------------- DYNAMIC MESH DEFINITION -----------------------------% +% +GRID_MOVEMENT= STEADY_TRANSLATION +MACH_MOTION= 0.35 +TRANSLATION_RATE= 0.0 0.0 0.0 diff --git a/TestCases/disc_adj_ffi/sliding_interface/circles.cfg b/TestCases/disc_adj_ffi/sliding_interface/circles.cfg new file mode 100755 index 000000000000..928267a6b84a --- /dev/null +++ b/TestCases/disc_adj_ffi/sliding_interface/circles.cfg @@ -0,0 +1,206 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: 2D Cylinder Interface (Sliding Interface) % +% Author: J. Kelly % +% Institution: University of Liverpool % +% Date: Dec 1st, 2025 % +% File Version 8.3.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +MULTIZONE= YES +% +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= RANS +KIND_TURB_MODEL= SA +READ_BINARY_RESTART=NO +MATH_PROBLEM= DISCRETE_ADJOINT +% +% -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% +% +MACH_NUMBER= 0.05 +AOA= 0.0 +FREESTREAM_PRESSURE= 1E6 +FREESTREAM_TEMPERATURE= 300.0 +FREESTREAM_DENSITY= 1.7418 +FREESTREAM_OPTION= TEMPERATURE_FS +FREESTREAM_TURBULENCEINTENSITY = 0.03 +FREESTREAM_TURB2LAMVISCRATIO = 100.0 +INIT_OPTION= TD_CONDITIONS +% +% ---------------------- 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 +REF_DIMENSIONALIZATION= DIMENSIONAL +% +% ------------------------------ EQUATION OF STATE ----------------------------% +% +FLUID_MODEL= IDEAL_GAS +GAMMA_VALUE= 1.4 +GAS_CONSTANT= 287.058 +% +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +VISCOSITY_MODEL= CONSTANT_VISCOSITY +MU_REF= 1.716E-5 +MU_T_REF= 273.15 +SUTHERLAND_CONSTANT= 110.4 +%FROZEN_VISC_DISC= YES +% +% --------------------------- THERMAL CONDUCTIVITY MODEL ----------------------% +% +CONDUCTIVITY_MODEL= CONSTANT_PRANDTL +% +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +%MARKER_EULER = (INFLOW, INMIX, OUTMIX, OUTFLOW, CIRC1, CIRC2) +MARKER_HEATFLUX= ( CIRC1, 0.0, CIRC2, 0.0) +% +MARKER_PERIODIC= ( PER1, PER2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0, PER3, PER4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 0.0) +% +%-------- INFLOW/OUTFLOW BOUNDARY CONDITION SPECIFIC FOR TURBOMACHINERY --------% +% +% +MARKER_ZONE_INTERFACE= (OUTMIX, INMIX) +% Mixing-plane interface markers must be specified to activate the transfer of information between zones +MARKER_FLUID_INTERFACE= (OUTMIX, INMIX) +% +% +INLET_TYPE= TOTAL_CONDITIONS +MARKER_INLET= (INFLOW, 300.0, 1E6, 1.0, 0.0, 0.0) +MARKER_OUTLET= (OUTFLOW, 9E5) +% +%---------------------------- TURBOMACHINERY SIMULATION -----------------------------% +% +% ------------------------ SURFACES IDENTIFICATION ----------------------------% +% +MARKER_PLOTTING= CIRC1, CIRC2 +MARKER_MONITORING= CIRC1, CIRC2 +MARKER_DESIGNING= CIRC1, CIRC2 +MARKER_ANALYZE= CIRC1, CIRC2 +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +CFL_NUMBER= 10.0 +CFL_ADAPT= NO +CFL_ADAPT_PARAM= ( 1.3, 1.2, 1.0, 10.0) +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= LU_SGS +LINEAR_SOLVER_ERROR= 1E-4 +LINEAR_SOLVER_ITER= 20 +% +% ----------------------- SLOPE LIMITER DEFINITION ----------------------------% +% +VENKAT_LIMITER_COEFF= 0.05 +LIMITER_ITER= 999999 +% +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= ROE +MUSCL_FLOW= NO +SLOPE_LIMITER_FLOW= VAN_ALBADA_EDGE +ENTROPY_FIX_COEFF= 0.1 +JST_SENSOR_COEFF= ( 0.5, 0.02 ) +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% +% +CONV_NUM_METHOD_TURB= SCALAR_UPWIND +MUSCL_TURB= NO +SLOPE_LIMITER_TURB= VENKATAKRISHNAN +TIME_DISCRE_TURB= EULER_IMPLICIT +CFL_REDUCTION_TURB= 1.0 +% +% ----------------------- DESIGN VARIABLE PARAMETERS --------------------------% +% +DV_KIND= FFD_CONTROL_POINT_2D, FFD_CONTROL_POINT_2D, FFD_CONTROL_POINT_2D, FFD_CONTROL_POINT_2D +DV_MARKER= ( CIRC1, CIRC2 ) +DV_PARAM=( CIRCLE1, 0, 0, 1.0, 0.0 );( CIRCLE2, 0, 0, 1.0, 0.0 );( CIRCLE1, 1, 1, 1.0, 0.0 );( CIRCLE2, 1, 1, 1.0, 0.0 ) +DV_VALUE=0.0,0.0,0.0,0.0 +% +% ------------------------ GRID DEFORMATION PARAMETERS ------------------------% +% +% Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) +DEFORM_LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (ILU, LU_SGS, JACOBI) +DEFORM_LINEAR_SOLVER_PREC= ILU +% +% Number of smoothing iterations for mesh deformation +DEFORM_LINEAR_SOLVER_ITER= 1000 +% +% Number of nonlinear deformation iterations (surface deformation increments) +DEFORM_NONLINEAR_ITER= 1 +% +% Minimum residual criteria for the linear solver convergence of grid deformation +DEFORM_LINEAR_SOLVER_ERROR= 1E-14 +% +% Print the residuals during mesh deformation to the console (YES, NO) +DEFORM_CONSOLE_OUTPUT= YES +% +% +% Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, +% WALL_DISTANCE, CONSTANT_STIFFNESS) +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +% +% -------------------- FREE-FORM DEFORMATION PARAMETERS -----------------------% +% +FFD_TOLERANCE= 1E-10 +FFD_ITERATIONS= 500 +FFD_DEFINITION= (CIRCLE1, -2.0, -2.0, 0.0, 2.0, -2.0, 0.0, 2.0, 2.0, 0.0, -2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); (CIRCLE2, 18.0, -2.0, 0.0, 22.0, -2.0, 0.0, 22.0, 2.0, 0.0, 18.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) +FFD_DEGREE= ( 2 , 2 , 0 ); (2, 2, 0) +FFD_CONTINUITY= 2ND_DERIVATIVE +% +% --------------------- OPTIMAL SHAPE DESIGN DEFINITION -----------------------% +% +% FFD_CONTROL_POINT_2D +DEFINITION_DV= ( 19, 1.0 | CIRC1 | CIRCLE1, 0, 0, 1.0, 0.0 ); ( 19, 1.0 | CIRC2 | CIRCLE2, 0, 0, 1.0, 0.0 ); ( 19, 1.0 | CIRC1 | CIRCLE1, 1, 1, 1.0, 0.0 ); ( 19, 1.0 | CIRC2 | CIRCLE2, 1, 1, 1.0, 0.0 ); +OPT_OBJECTIVE= ENTROPY_GENERATION* 0.0001 +OPT_ITERATIONS= 19 +OPT_ACCURACY= 1E-10 +% +% --------------------- OBJECTIVE FUNCTION DEFINITION -----------------------% +% +OBJECTIVE_FUNCTION= DRAG +% +% ------------------------- CONVERGENCE PARAMETERS --------------------------% +% +OUTER_ITER= 201 +CONV_RESIDUAL_MINVAL= -16 +CONV_STARTITER= 10 +CONV_CAUCHY_ELEMS= 100 +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], COMBO +HISTORY_OUTPUT= ITER, RMS_RES, COMBO +MESH_FILENAME= circle_rans_ffd.su2 +MESH_FORMAT= SU2 +MESH_OUT_FILENAME= mesh_out.su2 +SOLUTION_FILENAME= solution_flow +SOLUTION_ADJ_FILENAME= solution_adj +TABULAR_FORMAT= CSV +OUTPUT_FILES= RESTART_ASCII, TECPLOT, SURFACE_TECPLOT +CONV_FILENAME= history +RESTART_FILENAME= restart_flow +RESTART_ADJ_FILENAME= restart_adj +VOLUME_FILENAME= flow +VOLUME_ADJ_FILENAME= adjoint +GRAD_OBJFUNC_FILENAME= of_grad.dat +SURFACE_FILENAME= surface_flow +SURFACE_ADJ_FILENAME= surface_adjoint +SURFACE_SENS_FILENAME= surface_sens +WRT_ZONE_CONV= NO +WRT_ZONE_HIST= YES +OUTPUT_PRECISION= 16 From 030b1b3203747b49fadcd0c6d25b053d07532b8f Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 1 Dec 2025 06:49:04 +0000 Subject: [PATCH 36/79] Unused var --- SU2_CFD/src/drivers/CDriver.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 3b513a874002..5f718b839156 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2618,12 +2618,8 @@ void CDriver::PreprocessOutput(CConfig **config, CConfig *driver_config, COutput void CDriver::PreprocessTurboVertex(CConfig** config, CGeometry**** geometry, CSolver***** solver, CInterface*** interface, CIteration*** iteration, bool dummy){ - unsigned short donorZone,targetZone, nMarkerInt, iMarkerInt; unsigned short nSpanMax = 0; - bool restart = (config[ZONE_0]->GetRestart() || config[ZONE_0]->GetRestart_Flow()); mixingplane = config[ZONE_0]->GetBoolMixingPlaneInterface(); - bool discrete_adjoint = config[ZONE_0]->GetDiscrete_Adjoint(); - su2double areaIn, areaOut, nBlades, flowAngleIn, flowAngleOut; /*--- Create turbovertex structure ---*/ if (rank == MASTER_NODE) cout< Date: Sun, 7 Dec 2025 18:13:08 +0000 Subject: [PATCH 37/79] Added writing of mixing plane interpolator to file + interpolation fixes --- .../interface_interpolation/CInterpolator.hpp | 5 + .../interface_interpolation/CMixingPlane.hpp | 7 ++ .../interface_interpolation/CMixingPlane.cpp | 105 ++++++++++++++++-- SU2_CFD/src/drivers/CDriver.cpp | 2 + .../interfaces/cfd/CMixingPlaneInterface.cpp | 4 +- SU2_CFD/src/iteration/CIteration.cpp | 18 +-- SU2_CFD/src/output/CFlowCompOutput.cpp | 8 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 4 +- 8 files changed, 131 insertions(+), 22 deletions(-) diff --git a/Common/include/interface_interpolation/CInterpolator.hpp b/Common/include/interface_interpolation/CInterpolator.hpp index 3a4a0c3a84c4..6702990b2ec9 100644 --- a/Common/include/interface_interpolation/CInterpolator.hpp +++ b/Common/include/interface_interpolation/CInterpolator.hpp @@ -138,6 +138,11 @@ class CInterpolator { */ virtual void PrintStatistics(void) const {} + /*! + * \brief Write mixing plane interpolation details to file + */ + inline virtual void WriteInterpolationDetails(const string& filename, const CConfig* const* config) {}; + /*! * \brief Check whether an interface should be processed or not, i.e. if it is part of the zones. * \param[in] val_markDonor - Marker tag from donor zone. diff --git a/Common/include/interface_interpolation/CMixingPlane.hpp b/Common/include/interface_interpolation/CMixingPlane.hpp index e396de0fd841..2a0a09f9f8fa 100644 --- a/Common/include/interface_interpolation/CMixingPlane.hpp +++ b/Common/include/interface_interpolation/CMixingPlane.hpp @@ -40,4 +40,11 @@ class CMixingPlane final : public CInterpolator { unsigned int jZone); void SetTransferCoeff(const CConfig* const* config) override; + + /*! + * \brief Write interpolation details to file. + * \param[in] filename - Name of output file. + * \param[in] config - Configuration for all zones. + */ + void WriteInterpolationDetails(const string& filename, const CConfig* const* config) override; }; \ No newline at end of file diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index 3b7c5f68d7b3..5a43f55303ef 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -101,13 +101,13 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { targetSpans[iMarkerInt][0].donorSpan = 0; targetSpans[iMarkerInt][0].coefficient = 0.0; if (nDim > 2) { - targetSpans[iMarkerInt][nSpanTarget-2].donorSpan = nSpanDonor-2; - targetSpans[iMarkerInt][nSpanTarget-2].coefficient = 0.0; targetSpans[iMarkerInt][nSpanTarget-1].donorSpan = nSpanDonor-1; targetSpans[iMarkerInt][nSpanTarget-1].coefficient = 0.0; + targetSpans[iMarkerInt][nSpanTarget].donorSpan = nSpanDonor; + targetSpans[iMarkerInt][nSpanTarget].coefficient = 0.0; } - for(auto iSpanTarget = 1; iSpanTarget < nSpanTarget - 2; iSpanTarget++){ + for(auto iSpanTarget = 1; iSpanTarget < nSpanTarget - 1; iSpanTarget++){ auto &targetSpan = targetSpans[iMarkerInt][iSpanTarget]; auto tSpan = 0; // Nearest donor span index @@ -136,16 +136,17 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { case LINEAR_INTERPOLATION: // Find the donor span interval that brackets the target span - for (auto iSpanDonor = 1; iSpanDonor < nSpanDonor - 2; iSpanDonor++) { - if(spanValuesTarget[iSpanTarget] >= spanValuesDonor[iSpanDonor] && - spanValuesTarget[iSpanTarget] <= spanValuesDonor[iSpanDonor + 1]){ + for (auto iSpanDonor = 1; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { + const auto test = abs(spanValuesTarget[iSpanTarget] - spanValuesDonor[iSpanDonor]); + if(test < minDist && spanValuesTarget[iSpanTarget] > spanValuesDonor[iSpanDonor]){ kSpan = iSpanDonor; - break; + minDist = test; } } // Calculate interpolation coefficient coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan]) / (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); + if (((coeff < 0) || (coeff > 1)) && (rank == MASTER_NODE)) cout << "Warning! Target spans exist outside the bounds of donor spans!" << endl; targetSpan.donorSpan = kSpan; targetSpan.coefficient = coeff; break; @@ -156,4 +157,94 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { } } } +} + +void CMixingPlane::WriteInterpolationDetails(const std::string& filename, const CConfig* const* config) { + // Only write from master process in MPI + if (rank != MASTER_NODE) return; + + std::ofstream outFile(filename); + + if (!outFile.is_open()) { + cout << "Error: Could not open file " << filename << ". Abandoning interpolator writing..." << endl; + return; + } + + const auto donor_config = config[donorZone]; + const auto target_config = config[targetZone]; + const auto nMarkerInt = config[donorZone]->GetnMarker_MixingPlaneInterface() / 2; + + outFile << "Mixing-Plane Interpolator Details. Donor Zone = " << donorZone << " Target Zone = " << targetZone << ". Interpolation Method = "; + switch(donor_config->GetKind_MixingPlaneInterface()) { + case MATCHING: + outFile << "MATCHING\n"; + break; + case NEAREST_SPAN: + outFile << "NEAREST_SPAN\n"; + break; + case LINEAR_INTERPOLATION: + outFile << "LINEAR_INTERPOLATION\n"; + break; + default: + outFile << "UNKNOWN\n"; + } + outFile << "\n"; + outFile << "===============================================================" << endl; + + // Loop through each marker interface + for (auto iMarkerInt = 0; iMarkerInt < nMarkerInt; iMarkerInt++) { + if (targetSpans[iMarkerInt].empty()) continue; + + outFile << "Marker Interface " << iMarkerInt << "\n"; + outFile << "---------------------\n"; + outFile << "Target Span, Donor Span, Interpolation Coefficient\n"; + + for (size_t iSpanTarget = 0; iSpanTarget < targetSpans[iMarkerInt].size(); iSpanTarget++) { + const auto& targetSpan = targetSpans[iMarkerInt][iSpanTarget]; + outFile << iSpanTarget << ", " + << targetSpan.donorSpan << ", " + << targetSpan.coefficient << "\n"; + } + outFile << "\n"; + } + + // Optional: Write grouped by donor span + outFile << "\n\nGrouped by Donor Span\n"; + outFile << "=====================\n\n"; + + for (auto iMarkerInt = 0; iMarkerInt < nMarkerInt; iMarkerInt++) { + if (targetSpans[iMarkerInt].empty()) continue; + + outFile << "Marker Interface " << iMarkerInt << "\n"; + outFile << "---------------------\n"; + + // Find max donor span + unsigned long maxDonorSpan = 0; + for (const auto& ts : targetSpans[iMarkerInt]) { + maxDonorSpan = std::max(maxDonorSpan, ts.donorSpan); + } + + // Group by donor span + for (unsigned long iDonor = 0; iDonor <= maxDonorSpan; iDonor++) { + bool hasTargets = false; + std::ostringstream targets; + + for (size_t iSpanTarget = 0; iSpanTarget < targetSpans[iMarkerInt].size(); iSpanTarget++) { + if (targetSpans[iMarkerInt][iSpanTarget].donorSpan == iDonor) { + if (hasTargets) targets << ", "; + targets << "Target " << iSpanTarget + << " (coeff=" << targetSpans[iMarkerInt][iSpanTarget].coefficient << ")"; + hasTargets = true; + } + } + + if (hasTargets) { + outFile << "Donor Span " << iDonor << ": " << targets.str() << "\n"; + } + } + outFile << "\n"; + } + + outFile.close(); + cout << "Interpolation details written to " << filename << endl; } \ No newline at end of file diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 5f718b839156..474705f3e33e 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2467,6 +2467,8 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet case TURBO_INTERFACE_KIND::MIXING_PLANE: { interpolation[donor][target] = unique_ptr(CInterpolatorFactory::CreateInterpolator( geometry, config, interpolation[target][donor].get(), donor, target, true)); + string fname = "TURBOMACHINERY/Mixing_Plane_Interpolator_Donor_" + to_string(donor) + "_Target_" + to_string(target) + ".dat"; + interpolation[donor][target]->WriteInterpolationDetails(fname, config); if (rank == MASTER_NODE) cout << " Transferring "; auto nVar = solver[donor][INST_0][MESH_0][FLOW_SOL]->GetnVar(); interface[donor][target] = new CMixingPlaneInterface(nVar, 0); diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 63ecd872ecd1..866400ee2f32 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -125,12 +125,12 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter InitializeTarget_Variable(target_solution, markTarget, iTargetSpan, nSpanDonor); - if ((iTargetSpan == 0) || (iTargetSpan == nTargetSpan - 1) || (iTargetSpan == nTargetSpan - 2)) { + if ((iTargetSpan == 0) || (iTargetSpan == nTargetSpan) || (iTargetSpan == nTargetSpan - 1)) { /*--- Transfer values at hub, shroud and 1D values ---*/ unsigned long donorSpan; if (iTargetSpan == 0) donorSpan = 0; - else if (iTargetSpan == nTargetSpan - 2) donorSpan = nSpanDonor - 2; else if (iTargetSpan == nTargetSpan - 1) donorSpan = nSpanDonor - 1; + else if (iTargetSpan == nTargetSpan) donorSpan = nSpanDonor; RecoverTarget_Span_Endwall(sendDonorVar, donorSpan); diff --git a/SU2_CFD/src/iteration/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index a29111da3775..aa572bf01d97 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -218,12 +218,14 @@ void CIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geom // Computes the turboperformance per blade in zone iBlade const auto nZone = config_container[ZONE_0]->GetnZone(); - auto TurbomachineryBladePerformances = GetBladesPerformanceVector(solver, nZone); - - auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); - auto InState = TurbomachineryBladePerformances.at(ZONE_0)->GetBladesPerformances().at(nSpan)->GetInletState(); - nSpan = config_container[nZone-1]->GetnSpanWiseSections(); - auto OutState = TurbomachineryBladePerformances.at(nZone-1)->GetBladesPerformances().at(nSpan)->GetOutletState(); - - TurbomachineryStagePerformance->ComputePerformanceStage(InState, OutState, config_container[nZone-1]); + if (rank == MASTER_NODE) { + auto TurbomachineryBladePerformances = GetBladesPerformanceVector(solver, nZone); + + auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); + auto InState = TurbomachineryBladePerformances.at(ZONE_0)->GetBladesPerformances().at(nSpan)->GetInletState(); + nSpan = config_container[nZone-1]->GetnSpanWiseSections(); + auto OutState = TurbomachineryBladePerformances.at(nZone-1)->GetBladesPerformances().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 aba523129cbc..321c23347489 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -639,7 +639,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::vectorGetSpanWiseValue(OUTFLOW); /*--- Writing Span wise inflow thermodynamic quantities. ---*/ - spanwise_performance_filename = "TURBOMACHINERY/inflow_spanwise_thermodynamic_values.dat"; + spanwise_performance_filename = "TURBOMACHINERY/inflow_spanwise_thermodynamic_values"; if (nZone > 1) { spanwise_performance_filename.append("_" + std::to_string(val_iZone) + ".dat"); } else { @@ -677,12 +677,13 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::vectorGetInletState().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 << endl; } file.close(); /*--- Writing Span wise outflow thermodynamic quantities. ---*/ - spanwise_performance_filename = "TURBOMACHINERY/outflow_spanwise_thermodynamic_values.dat"; + spanwise_performance_filename = "TURBOMACHINERY/outflow_spanwise_thermodynamic_values"; if (nZone > 1) { spanwise_performance_filename.append("_" + std::to_string(val_iZone) + ".dat"); } else { @@ -721,12 +722,13 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::vectorGetOutletState().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 << endl; } file.close(); /*--- Writing Span wise inflow kinematic quantities. ---*/ - spanwise_performance_filename = "TURBOMACHINERY/inflow_spanwise_kinematic_values.dat"; + spanwise_performance_filename = "TURBOMACHINERY/inflow_spanwise_kinematic_values"; if (nZone > 1) { spanwise_performance_filename.append("_" + std::to_string(val_iZone) + ".dat"); } else { diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 787c3f5e9cf4..4585cf83ff1c 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -5602,7 +5602,7 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain ExtAveragePressure = donorAverages[1]; ExtAverageTurboVelocity[0] = donorAverages[2]; ExtAverageTurboVelocity[1] = donorAverages[3]; - ExtAverageTurboVelocity[2] = donorAverages[4]; + if (nDim == 3) ExtAverageTurboVelocity[2] = donorAverages[4]; /*--- Build the external state u_e from boundary data and internal node ---*/ @@ -6301,7 +6301,7 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu ExtAveragePressure = donorAverages[1]; ExtAverageTurboVelocity[0] = donorAverages[2]; ExtAverageTurboVelocity[1] = donorAverages[3]; - ExtAverageTurboVelocity[2] = donorAverages[4]; + if (nDim == 3) ExtAverageTurboVelocity[2] = donorAverages[4]; switch(config->GetKind_Data_Giles(Marker_Tag)){ From ed89e9dac6c368ab0993805a88c202627c6f37cb Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 8 Dec 2025 10:29:55 +0000 Subject: [PATCH 38/79] MP bug fix and additional interpolation warning details --- Common/src/interface_interpolation/CMixingPlane.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index 5a43f55303ef..5807bbe7af60 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -146,7 +146,14 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { // Calculate interpolation coefficient coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan]) / (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); - if (((coeff < 0) || (coeff > 1)) && (rank == MASTER_NODE)) cout << "Warning! Target spans exist outside the bounds of donor spans!" << endl; + if (((coeff < 0) || (coeff > 1)) && (rank == MASTER_NODE)){ + cout << "Warning! Target spans exist outside the bounds of donor spans!" << endl; + cout << "Target span " << iSpanTarget << " <- " << kSpan << " coeff = " << coeff << endl; + if (iSpanTarget < nSpanTarget/2) cout << "This is likely an issue at the hub." << endl; + if (iSpanTarget > nSpanTarget/2) cout << "This is likely an issue at the shroud." << endl; + cout << "Setting coeff = 0.0" << endl; + coeff = 0.0; + } targetSpan.donorSpan = kSpan; targetSpan.coefficient = coeff; break; From e440f9cc9dda93fb895771436ecca0b7e3e0da34 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 8 Dec 2025 10:32:21 +0000 Subject: [PATCH 39/79] MPI correction --- .../src/interface_interpolation/CMixingPlane.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index 5807bbe7af60..7cb4d0d7b7c0 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -146,12 +146,14 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { // Calculate interpolation coefficient coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan]) / (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); - if (((coeff < 0) || (coeff > 1)) && (rank == MASTER_NODE)){ - cout << "Warning! Target spans exist outside the bounds of donor spans!" << endl; - cout << "Target span " << iSpanTarget << " <- " << kSpan << " coeff = " << coeff << endl; - if (iSpanTarget < nSpanTarget/2) cout << "This is likely an issue at the hub." << endl; - if (iSpanTarget > nSpanTarget/2) cout << "This is likely an issue at the shroud." << endl; - cout << "Setting coeff = 0.0" << endl; + if ((coeff < 0) || (coeff > 1)) { + if (rank == MASTER_NODE) { + cout << "Warning! Target spans exist outside the bounds of donor spans!" << endl; + cout << "Target span " << iSpanTarget << " <- " << kSpan << " coeff = " << coeff << endl; + if (iSpanTarget < nSpanTarget/2) cout << "This is likely an issue at the hub." << endl; + if (iSpanTarget > nSpanTarget/2) cout << "This is likely an issue at the shroud." << endl; + cout << "Setting coeff = 0.0" << endl; + } coeff = 0.0; } targetSpan.donorSpan = kSpan; From ce08ca6e0b8a8b113b504a5015a58e1945298d7c Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 8 Dec 2025 10:45:52 +0000 Subject: [PATCH 40/79] Proper identification of MP boundaries w/ MPI + filename fix --- Common/src/geometry/CPhysicalGeometry.cpp | 4 ++-- .../interface_interpolation/CMixingPlane.cpp | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index 9430f8f1dfcf..865005f1909b 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -5686,9 +5686,9 @@ void CPhysicalGeometry::SetTurboVertex(CConfig* config, unsigned short val_iZone } } if (marker_flag == INFLOW) { - multizone_filename = "TURBOMACHINERY/spanwise_division_inflow.dat"; + multizone_filename = "TURBOMACHINERY/spanwise_division_inflow"; } else { - multizone_filename = "TURBOMACHINERY/spanwise_division_outflow.dat"; + multizone_filename = "TURBOMACHINERY/spanwise_division_outflow"; } char buffer[50]; diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index 7cb4d0d7b7c0..80c023b0cbe3 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -59,34 +59,46 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { markDonor = donor_config->FindMixingPlaneInterfaceMarker(donor_config->GetnMarker_All()); donorFlag = (markDonor != -1) ? donor_config->GetMarker_All_MixingPlaneInterface(markDonor) : -1; + markTarget = target_config->FindMixingPlaneInterfaceMarker(target_config->GetnMarker_All()); + targetFlag = (markTarget != -1) ? target_config->GetMarker_All_MixingPlaneInterface(markTarget) : -1; + #ifdef HAVE_MPI auto buffMarkerDonor = new int[size]; auto buffDonorFlag = new int[size]; + auto buffMarkerTarget = new int[size]; + auto buffTargetFlag = new int[size]; for (int iSize=0; iSize= 0.0) { markDonor = buffMarkerDonor[iSize]; donorFlag = buffDonorFlag[iSize]; + markTarget = buffMarkerDonor[iSize]; + targetFlag = buffDonorFlag[iSize]; break; } } delete [] buffMarkerDonor; delete [] buffDonorFlag; + delete [] buffMarkerTarget; + delete [] buffTargetFlag; #endif - markTarget = target_config->FindMixingPlaneInterfaceMarker(target_config->GetnMarker_All()); - targetFlag = (markTarget != -1) ? target_config->GetMarker_All_MixingPlaneInterface(markTarget) : -1; - if (markTarget == -1 || markDonor == -1) continue; nSpanDonor = donor_config->GetnSpanWiseSections(); From 771c098084c908ab0f28183cf316b24505d3b954 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 8 Dec 2025 12:34:43 +0000 Subject: [PATCH 41/79] Interpolator correction --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 866400ee2f32..c2720e04fded 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -121,7 +121,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter for (auto iTargetSpan = 0ul; iTargetSpan < nTargetSpan; iTargetSpan++) { - auto& targetSpan = interpolator.targetSpans[iMarkerInt][markTarget]; + auto& targetSpan = interpolator.targetSpans[iMarkerInt][iTargetSpan]; InitializeTarget_Variable(target_solution, markTarget, iTargetSpan, nSpanDonor); From 3150c51685ec3f9523122b9bcf14fc4cd40a3bfc Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 8 Dec 2025 16:47:59 +0000 Subject: [PATCH 42/79] MPI fixes --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index c2720e04fded..afa1b122c697 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -90,10 +90,10 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter } #ifdef HAVE_MPI /*--- Gather data. ---*/ - const auto nTotalDonors = nSpanDonor * size; - const auto nSpanDonorVars = nSpanDonor * nMixingVars; + const auto nTotalDonors = nSpanDonor * size; // Number of donor spans across all ranks + const auto nSpanDonorVars = nSpanDonor * nMixingVars; // Number of variables to be transferred on each rank vector buffDonorMarker(nTotalDonors); - vector buffDonorVar(static_cast(nTotalDonors) * nMixingVars); + vector buffDonorVar(static_cast(nTotalDonors) * nMixingVars); // Total number of variables to be transferred on all ranks SU2_MPI::Allgather(sendDonorMarker.data(), nSpanDonor, MPI_UNSIGNED_SHORT, buffDonorMarker.data(), nSpanDonor, MPI_UNSIGNED_SHORT, @@ -106,7 +106,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter for (auto iSize = 0; iSize < size; iSize++){ if (buffDonorVar[static_cast(nSpanDonorVars) * iSize] > 0.0) { for (auto iSpan = 0ul; iSpan < nSpanDonor; iSpan++){ - for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = buffDonorVar[static_cast(iSize) * nSpanDonorVars + iVar]; // This could be wrong in 3D + for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = buffDonorVar[static_cast(iSize) * nSpanDonorVars + iSpan * nMixingVars + iVar]; } markDonor = buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor)]; } @@ -197,8 +197,9 @@ void CMixingPlaneInterface::SetTarget_Variable(CSolver *target_solution, CGeomet iDonorSpan = target_solution->GetnMixingStates(Marker_Target, Span_Target); - for (iVar = 0; iVar < nMixingVars; iVar++) + for (iVar = 0; iVar < nMixingVars; iVar++) { target_solution->SetMixingState(Marker_Target, Span_Target, iVar, Target_Variable[iVar]); + } target_solution->SetnMixingStates( Marker_Target, Span_Target, iDonorSpan + 1 ); } From 96e830f1d3fd11db25502e410417b6e00924bc43 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 8 Dec 2025 19:40:29 +0000 Subject: [PATCH 43/79] MPI issues --- .../interfaces/cfd/CMixingPlaneInterface.cpp | 29 ++----------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index afa1b122c697..de1ec1071c41 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -92,7 +92,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter /*--- Gather data. ---*/ const auto nTotalDonors = nSpanDonor * size; // Number of donor spans across all ranks const auto nSpanDonorVars = nSpanDonor * nMixingVars; // Number of variables to be transferred on each rank - vector buffDonorMarker(nTotalDonors); + vector buffDonorMarker(nTotalDonors); vector buffDonorVar(static_cast(nTotalDonors) * nMixingVars); // Total number of variables to be transferred on all ranks SU2_MPI::Allgather(sendDonorMarker.data(), nSpanDonor, MPI_UNSIGNED_SHORT, @@ -104,7 +104,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter SU2_MPI::GetComm()); for (auto iSize = 0; iSize < size; iSize++){ - if (buffDonorVar[static_cast(nSpanDonorVars) * iSize] > 0.0) { + if (buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor)] != -1) { for (auto iSpan = 0ul; iSpan < nSpanDonor; iSpan++){ for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = buffDonorVar[static_cast(iSize) * nSpanDonorVars + iSpan * nMixingVars + iVar]; } @@ -203,28 +203,3 @@ void CMixingPlaneInterface::SetTarget_Variable(CSolver *target_solution, CGeomet target_solution->SetnMixingStates( Marker_Target, Span_Target, iDonorSpan + 1 ); } - -void CMixingPlaneInterface::SetAverageValues(CSolver *donor_solution, CSolver *target_solution, - unsigned short donorZone){ - - unsigned short iSpan; - - for(iSpan = 0; iSpanSetDensityIn(donor_solution->GetDensityIn(donorZone, iSpan), donorZone, iSpan); - target_solution->SetPressureIn(donor_solution->GetPressureIn(donorZone, iSpan), donorZone, iSpan); - target_solution->SetTurboVelocityIn(donor_solution->GetTurboVelocityIn(donorZone, iSpan), donorZone, iSpan); - target_solution->SetDensityOut(donor_solution->GetDensityOut(donorZone, iSpan), donorZone, iSpan); - target_solution->SetPressureOut(donor_solution->GetPressureOut(donorZone, iSpan), donorZone, iSpan); - target_solution->SetTurboVelocityOut(donor_solution->GetTurboVelocityOut(donorZone, iSpan), donorZone, iSpan); - - /*--- transfer turbulent quantities ---*/ - target_solution->SetKineIn(donor_solution->GetKineIn(donorZone, iSpan), donorZone, iSpan); - target_solution->SetOmegaIn(donor_solution->GetOmegaIn(donorZone, iSpan), donorZone, iSpan); - target_solution->SetNuIn(donor_solution->GetNuIn(donorZone, iSpan), donorZone, iSpan); - target_solution->SetKineOut(donor_solution->GetKineOut(donorZone, iSpan), donorZone, iSpan); - target_solution->SetOmegaOut(donor_solution->GetOmegaOut(donorZone, iSpan), donorZone, iSpan); - target_solution->SetNuOut(donor_solution->GetNuOut(donorZone, iSpan), donorZone, iSpan); - - } -} From 51a1a865836e0a826b0eae51b353c32f5c2a52f8 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 8 Dec 2025 19:42:08 +0000 Subject: [PATCH 44/79] Remove SetAverageValues --- SU2_CFD/include/interfaces/CInterface.hpp | 9 --------- .../include/interfaces/cfd/CMixingPlaneInterface.hpp | 11 ----------- 2 files changed, 20 deletions(-) diff --git a/SU2_CFD/include/interfaces/CInterface.hpp b/SU2_CFD/include/interfaces/CInterface.hpp index b809878ef168..bd565c9241c6 100644 --- a/SU2_CFD/include/interfaces/CInterface.hpp +++ b/SU2_CFD/include/interfaces/CInterface.hpp @@ -185,15 +185,6 @@ class CInterface { */ inline virtual void SetSpanWiseLevels(const CConfig *donor_config, const CConfig *target_config) { } - /*! - * \brief A virtual member. - * \param[in] target_solution - Solution from the target mesh. - * \param[in] target_solution - Solution from the target mesh. - * \param[in] donor_zone - Index of the donorZone. - */ - inline virtual void SetAverageValues(CSolver *donor_solution, CSolver *target_solution, - unsigned short donorZone) { } - /*! * \brief Interpolate data and broadcast it into all processors, for nonmatching meshes. * \param[in] interpolator - Object defining the interpolation. diff --git a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp index 2e52f9dba1c3..1a5b3a865b4d 100644 --- a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp +++ b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp @@ -104,15 +104,4 @@ class CMixingPlaneInterface : public CInterface { Target_Variable[iVar] = (1 - donorCoeff)*bcastVariable[iSpan * nMixingVars + iVar] + donorCoeff * bcastVariable[(iSpan + 1) * nMixingVars + iVar]; } } - - /*! - * \brief Store all the turboperformance in the solver in ZONE_0. - * \param[in] donor_solution - Solution from the donor mesh. - * \param[in] target_solution - Solution from the target mesh. - * \param[in] donorZone - counter of the donor solution - */ - void SetAverageValues(CSolver *donor_solution, CSolver *target_solution, unsigned short donorZone) override; - - - }; From 0d1ac6d48a2bf1f3d5a42ab4810c770057d2a8ab Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Mon, 8 Dec 2025 19:44:10 +0000 Subject: [PATCH 45/79] Fix type definition of marker buffer --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index de1ec1071c41..0b63de378bf7 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -92,11 +92,11 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter /*--- Gather data. ---*/ const auto nTotalDonors = nSpanDonor * size; // Number of donor spans across all ranks const auto nSpanDonorVars = nSpanDonor * nMixingVars; // Number of variables to be transferred on each rank - vector buffDonorMarker(nTotalDonors); + vector buffDonorMarker(nTotalDonors); vector buffDonorVar(static_cast(nTotalDonors) * nMixingVars); // Total number of variables to be transferred on all ranks - SU2_MPI::Allgather(sendDonorMarker.data(), nSpanDonor, MPI_UNSIGNED_SHORT, - buffDonorMarker.data(), nSpanDonor, MPI_UNSIGNED_SHORT, + SU2_MPI::Allgather(sendDonorMarker.data(), nSpanDonor, MPI_SHORT, + buffDonorMarker.data(), nSpanDonor, MPI_SHORT, SU2_MPI::GetComm()); SU2_MPI::Allgather(sendDonorVar.data(), nSpanDonorVars, MPI_DOUBLE, From fd206572e495cf91fbff2f313da2e47d37c7a59c Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 9 Dec 2025 16:24:46 +0000 Subject: [PATCH 46/79] Assorted MPI Fixes and updates of interpolation classes to account for MP. --- .../interface_interpolation/CInterpolator.hpp | 2 +- .../CIsoparametric.hpp | 2 +- .../interface_interpolation/CMirror.hpp | 2 +- .../interface_interpolation/CMixingPlane.hpp | 2 +- .../CNearestNeighbor.hpp | 2 +- .../CRadialBasisFunction.hpp | 2 +- .../interface_interpolation/CSlidingMesh.hpp | 2 +- .../CIsoparametric.cpp | 4 +- .../src/interface_interpolation/CMirror.cpp | 4 +- .../interface_interpolation/CMixingPlane.cpp | 85 ++++++++++++------- .../CNearestNeighbor.cpp | 4 +- .../CRadialBasisFunction.cpp | 4 +- .../interface_interpolation/CSlidingMesh.cpp | 4 +- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 2 +- .../interfaces/cfd/CMixingPlaneInterface.cpp | 27 +++--- 15 files changed, 86 insertions(+), 62 deletions(-) diff --git a/Common/include/interface_interpolation/CInterpolator.hpp b/Common/include/interface_interpolation/CInterpolator.hpp index 6702990b2ec9..46e6d53f8c84 100644 --- a/Common/include/interface_interpolation/CInterpolator.hpp +++ b/Common/include/interface_interpolation/CInterpolator.hpp @@ -131,7 +131,7 @@ class CInterpolator { * \note Main method that derived classes must implement. * \param[in] config - Definition of the particular problem. */ - virtual void SetTransferCoeff(const CConfig* const* config) = 0; + virtual void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) = 0; /*! * \brief Print information about the interpolation. diff --git a/Common/include/interface_interpolation/CIsoparametric.hpp b/Common/include/interface_interpolation/CIsoparametric.hpp index cb2cbc0a0914..8ae18007c544 100644 --- a/Common/include/interface_interpolation/CIsoparametric.hpp +++ b/Common/include/interface_interpolation/CIsoparametric.hpp @@ -64,7 +64,7 @@ class CIsoparametric final : public CInterpolator { * \brief Set up transfer matrix defining relation between two meshes * \param[in] config - Definition of the particular problem. */ - void SetTransferCoeff(const CConfig* const* config) override; + void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override; /*! * \brief Print information about the interpolation. diff --git a/Common/include/interface_interpolation/CMirror.hpp b/Common/include/interface_interpolation/CMirror.hpp index 3c15056ccbaa..4c9a0c87bbd1 100644 --- a/Common/include/interface_interpolation/CMirror.hpp +++ b/Common/include/interface_interpolation/CMirror.hpp @@ -54,5 +54,5 @@ class CMirror final : public CInterpolator { * \brief Set up transfer matrix defining relation between two meshes * \param[in] config - Definition of the particular problem. */ - void SetTransferCoeff(const CConfig* const* config) override; + void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override; }; diff --git a/Common/include/interface_interpolation/CMixingPlane.hpp b/Common/include/interface_interpolation/CMixingPlane.hpp index 2a0a09f9f8fa..4ed028f98ac4 100644 --- a/Common/include/interface_interpolation/CMixingPlane.hpp +++ b/Common/include/interface_interpolation/CMixingPlane.hpp @@ -39,7 +39,7 @@ class CMixingPlane final : public CInterpolator { CMixingPlane(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, unsigned int jZone); - void SetTransferCoeff(const CConfig* const* config) override; + void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override; /*! * \brief Write interpolation details to file. diff --git a/Common/include/interface_interpolation/CNearestNeighbor.hpp b/Common/include/interface_interpolation/CNearestNeighbor.hpp index c1ca63a6b475..f3665688d27b 100644 --- a/Common/include/interface_interpolation/CNearestNeighbor.hpp +++ b/Common/include/interface_interpolation/CNearestNeighbor.hpp @@ -63,7 +63,7 @@ class CNearestNeighbor final : public CInterpolator { * \brief Set up transfer matrix defining relation between two meshes. * \param[in] config - Definition of the particular problem. */ - void SetTransferCoeff(const CConfig* const* config) override; + void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override; /*! * \brief Print interpolation statistics. diff --git a/Common/include/interface_interpolation/CRadialBasisFunction.hpp b/Common/include/interface_interpolation/CRadialBasisFunction.hpp index 990fecfec0fc..45b0a5df8984 100644 --- a/Common/include/interface_interpolation/CRadialBasisFunction.hpp +++ b/Common/include/interface_interpolation/CRadialBasisFunction.hpp @@ -56,7 +56,7 @@ class CRadialBasisFunction final : public CInterpolator { * \brief Set up transfer matrix defining relation between two meshes * \param[in] config - Definition of the particular problem. */ - void SetTransferCoeff(const CConfig* const* config) override; + void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override; /*! * \brief Print information about the interpolation. diff --git a/Common/include/interface_interpolation/CSlidingMesh.hpp b/Common/include/interface_interpolation/CSlidingMesh.hpp index 36c7fa229e56..f640f5169297 100644 --- a/Common/include/interface_interpolation/CSlidingMesh.hpp +++ b/Common/include/interface_interpolation/CSlidingMesh.hpp @@ -49,7 +49,7 @@ class CSlidingMesh final : public CInterpolator { * \brief Set up transfer matrix defining relation between two meshes * \param[in] config - Definition of the particular problem. */ - void SetTransferCoeff(const CConfig* const* config) override; + void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override; private: /*! diff --git a/Common/src/interface_interpolation/CIsoparametric.cpp b/Common/src/interface_interpolation/CIsoparametric.cpp index b5351e3639ac..54b1758b4ffc 100644 --- a/Common/src/interface_interpolation/CIsoparametric.cpp +++ b/Common/src/interface_interpolation/CIsoparametric.cpp @@ -37,7 +37,7 @@ using namespace GeometryToolbox; CIsoparametric::CIsoparametric(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, unsigned int jZone) : CInterpolator(geometry_container, config, iZone, jZone) { - SetTransferCoeff(config); + SetTransferCoeff(geometry_container, config); } void CIsoparametric::PrintStatistics() const { @@ -46,7 +46,7 @@ void CIsoparametric::PrintStatistics() const { << " Interpolation clipped for " << ErrorCounter << " (" << ErrorRate << "%) target vertices." << endl; } -void CIsoparametric::SetTransferCoeff(const CConfig* const* config) { +void CIsoparametric::SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) { const su2double matchingVertexTol = 1e-12; // 1um^2 const int nProcessor = size; diff --git a/Common/src/interface_interpolation/CMirror.cpp b/Common/src/interface_interpolation/CMirror.cpp index a172b523144c..692fcd9c9ad2 100644 --- a/Common/src/interface_interpolation/CMirror.cpp +++ b/Common/src/interface_interpolation/CMirror.cpp @@ -40,10 +40,10 @@ CMirror::CMirror(CGeometry**** geometry_container, const CConfig* const* config, to_string(iZone) + string(" and ") + to_string(jZone) + string("."), CURRENT_FUNCTION); } - SetTransferCoeff(config); + SetTransferCoeff(geometry_container, config); } -void CMirror::SetTransferCoeff(const CConfig* const* config) { +void CMirror::SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) { const int nProcessor = size; vector allNumVertexTarget(nProcessor); diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index 80c023b0cbe3..d960e00dc0e8 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -33,16 +33,19 @@ CMixingPlane::CMixingPlane(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, unsigned int jZone) : CInterpolator(geometry_container, config, iZone, jZone) { - SetTransferCoeff(config); + SetTransferCoeff(geometry_container, config); } -void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { +void CMixingPlane::SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) { const auto nMarkerInt = config[donorZone]->GetnMarker_MixingPlaneInterface() / 2; const auto nDim = donor_geometry->GetnDim(); const auto donor_config = config[donorZone]; const auto target_config = config[targetZone]; + const auto donor_geometry = geometry[donorZone][INST_0][MESH_0]; + const auto target_geometry = geometry[targetZone][INST_0][MESH_0]; + //TODO turbo this approach only works if all the turboamchinery marker // of all zones have the same amount of span wise sections. //TODO turbo initialization needed for the MPI routine should be place somewhere else. @@ -52,14 +55,14 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { targetSpans.resize(config[donorZone]->GetnMarker_MixingPlaneInterface()); /*--- On the donor side ---*/ - for (auto iMarkerInt = 0; iMarkerInt < nMarkerInt; iMarkerInt++){ + for (auto iMarkerInt = 1; iMarkerInt < nMarkerInt + 1; iMarkerInt++){ int markDonor = -1, markTarget = -1; - unsigned short donorFlag = 0, targetFlag = 0; + short donorFlag = 0, targetFlag = 0; - markDonor = donor_config->FindMixingPlaneInterfaceMarker(donor_config->GetnMarker_All()); + markDonor = donor_config->FindMixingPlaneInterfaceMarker(donor_geometry->GetnMarker(), iMarkerInt); donorFlag = (markDonor != -1) ? donor_config->GetMarker_All_MixingPlaneInterface(markDonor) : -1; - markTarget = target_config->FindMixingPlaneInterfaceMarker(target_config->GetnMarker_All()); + markTarget = target_config->FindMixingPlaneInterfaceMarker(target_geometry->GetnMarker(), iMarkerInt); targetFlag = (markTarget != -1) ? target_config->GetMarker_All_MixingPlaneInterface(markTarget) : -1; #ifdef HAVE_MPI @@ -85,11 +88,17 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { targetFlag= -1; for (int iSize=0; iSize= 0.0) { + if(buffMarkerDonor[iSize] != -1) { markDonor = buffMarkerDonor[iSize]; donorFlag = buffDonorFlag[iSize]; - markTarget = buffMarkerDonor[iSize]; - targetFlag = buffDonorFlag[iSize]; + break; + } + } + + for (int iSize=0; iSizeGetnSpanWiseSections(); @@ -115,9 +123,9 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { if (nDim > 2) { targetSpans[iMarkerInt][nSpanTarget-1].donorSpan = nSpanDonor-1; targetSpans[iMarkerInt][nSpanTarget-1].coefficient = 0.0; - targetSpans[iMarkerInt][nSpanTarget].donorSpan = nSpanDonor; - targetSpans[iMarkerInt][nSpanTarget].coefficient = 0.0; } + targetSpans[iMarkerInt][nSpanTarget].donorSpan = nSpanDonor; + targetSpans[iMarkerInt][nSpanTarget].coefficient = 0.0; for(auto iSpanTarget = 1; iSpanTarget < nSpanTarget - 1; iSpanTarget++){ auto &targetSpan = targetSpans[iMarkerInt][iSpanTarget]; @@ -147,31 +155,46 @@ void CMixingPlane::SetTransferCoeff(const CConfig* const* config) { break; case LINEAR_INTERPOLATION: - // Find the donor span interval that brackets the target span - for (auto iSpanDonor = 1; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { - const auto test = abs(spanValuesTarget[iSpanTarget] - spanValuesDonor[iSpanDonor]); - if(test < minDist && spanValuesTarget[iSpanTarget] > spanValuesDonor[iSpanDonor]){ - kSpan = iSpanDonor; - minDist = test; + { + bool printWarning = false; + // Check if target span is within donor bound + if (spanValuesTarget[iSpanTarget] <= spanValuesDonor[0]) { + // Below hub - use hub value + targetSpan.donorSpan = 0; + targetSpan.coefficient = 0.0; + printWarning = true; + } + else if (spanValuesTarget[iSpanTarget] >= spanValuesDonor[nSpanDonor - 1]) { + // Above shroud - use shroud value + targetSpan.donorSpan = nSpanDonor - 1; + targetSpan.coefficient = 0.0; + printWarning = true; + } + else { + // Find the donor span interval that brackets the target span + for (auto iSpanDonor = 0; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { + const auto test = abs(spanValuesTarget[iSpanTarget] - spanValuesDonor[iSpanDonor]); + if(test < minDist && spanValuesTarget[iSpanTarget] > spanValuesDonor[iSpanDonor]){ + kSpan = iSpanDonor; + minDist = test; + } } + // Calculate interpolation coefficient + coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan]) / + (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); + targetSpan.donorSpan = kSpan; + targetSpan.coefficient = coeff; } - // Calculate interpolation coefficient - coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan]) / - (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); - if ((coeff < 0) || (coeff > 1)) { + if (printWarning) { if (rank == MASTER_NODE) { - cout << "Warning! Target spans exist outside the bounds of donor spans!" << endl; - cout << "Target span " << iSpanTarget << " <- " << kSpan << " coeff = " << coeff << endl; - if (iSpanTarget < nSpanTarget/2) cout << "This is likely an issue at the hub." << endl; - if (iSpanTarget > nSpanTarget/2) cout << "This is likely an issue at the shroud." << endl; - cout << "Setting coeff = 0.0" << endl; + cout << "Warning! Target spans exist outside the bounds of donor spans! Clamping interpolator..." << endl; + if (spanValuesTarget[iSpanTarget] <= spanValuesDonor[0]) cout << "This is an issue at the hub." << endl; + if (spanValuesTarget[iSpanTarget] >= spanValuesDonor[nSpanDonor - 1]) cout << "This is an issue at the shroud." << endl; + cout << "Setting coeff = 0.0 and transferring endwall value!" << endl; } - coeff = 0.0; } - targetSpan.donorSpan = kSpan; - targetSpan.coefficient = coeff; break; - + } default: SU2_MPI::Error("MixingPlane interface option not implemented yet", CURRENT_FUNCTION); break; diff --git a/Common/src/interface_interpolation/CNearestNeighbor.cpp b/Common/src/interface_interpolation/CNearestNeighbor.cpp index 493ff1765312..542e086ebbde 100644 --- a/Common/src/interface_interpolation/CNearestNeighbor.cpp +++ b/Common/src/interface_interpolation/CNearestNeighbor.cpp @@ -33,7 +33,7 @@ CNearestNeighbor::CNearestNeighbor(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, unsigned int jZone) : CInterpolator(geometry_container, config, iZone, jZone) { - SetTransferCoeff(config); + SetTransferCoeff(geometry_container, config); } void CNearestNeighbor::PrintStatistics() const { @@ -41,7 +41,7 @@ void CNearestNeighbor::PrintStatistics() const { cout << " Avg/max distance to closest donor point: " << AvgDistance << "/" << MaxDistance << endl; } -void CNearestNeighbor::SetTransferCoeff(const CConfig* const* config) { +void CNearestNeighbor::SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) { /*--- Desired number of donor points. ---*/ const auto nDonor = max(config[donorZone]->GetNumNearestNeighbors(), 1); diff --git a/Common/src/interface_interpolation/CRadialBasisFunction.cpp b/Common/src/interface_interpolation/CRadialBasisFunction.cpp index 1851955f2c39..d9332b6842e0 100644 --- a/Common/src/interface_interpolation/CRadialBasisFunction.cpp +++ b/Common/src/interface_interpolation/CRadialBasisFunction.cpp @@ -47,7 +47,7 @@ extern "C" void dgemm_(const char*, const char*, const int*, const int*, const i CRadialBasisFunction::CRadialBasisFunction(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, unsigned int jZone) : CInterpolator(geometry_container, config, iZone, jZone) { - SetTransferCoeff(config); + SetTransferCoeff(geometry_container, config); } void CRadialBasisFunction::PrintStatistics() const { @@ -98,7 +98,7 @@ su2double CRadialBasisFunction::Get_RadialBasisValue(RADIAL_BASIS type, const su return rbf; } -void CRadialBasisFunction::SetTransferCoeff(const CConfig* const* config) { +void CRadialBasisFunction::SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) { /*--- RBF options. ---*/ const auto kindRBF = config[donorZone]->GetKindRadialBasisFunction(); const bool usePolynomial = config[donorZone]->GetRadialBasisFunctionPolynomialOption(); diff --git a/Common/src/interface_interpolation/CSlidingMesh.cpp b/Common/src/interface_interpolation/CSlidingMesh.cpp index bcf3db986dbe..457951d5e856 100644 --- a/Common/src/interface_interpolation/CSlidingMesh.cpp +++ b/Common/src/interface_interpolation/CSlidingMesh.cpp @@ -33,10 +33,10 @@ CSlidingMesh::CSlidingMesh(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, unsigned int jZone) : CInterpolator(geometry_container, config, iZone, jZone) { - SetTransferCoeff(config); + SetTransferCoeff(geometry_container, config); } -void CSlidingMesh::SetTransferCoeff(const CConfig* const* config) { +void CSlidingMesh::SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) { /* 0 - Variable declaration */ /* --- General variables --- */ diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index cbfc4576df0e..bda1d3ff2bfa 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -270,7 +270,7 @@ void CMultizoneDriver::Preprocess(unsigned long TimeIter) { for (iZone = 0; iZone < nZone; iZone++) { for (unsigned short jZone = 0; jZone < nZone; jZone++){ if(jZone != iZone && interpolator_container[iZone][jZone] != nullptr && prefixed_motion[iZone]) - interpolator_container[iZone][jZone]->SetTransferCoeff(config_container); + interpolator_container[iZone][jZone]->SetTransferCoeff(geometry_container, config_container); } } } diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 0b63de378bf7..a715c679aa29 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -64,11 +64,11 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter /*--- Loop over interface markers. ---*/ - for (auto iMarkerInt = 0u; iMarkerInt < donor_config->GetnMarker_MixingPlaneInterface()/2; iMarkerInt++) { + for (auto iMarkerInt = 1u; iMarkerInt < donor_config->GetnMarker_MixingPlaneInterface()/2 + 1; iMarkerInt++) { /*--- Find the markers containing the interface ---*/ - short markDonor = donor_config->FindMixingPlaneInterfaceMarker(donor_geometry->GetnMarker()); - short markTarget= target_config->FindMixingPlaneInterfaceMarker(target_geometry->GetnMarker()); + short markDonor = donor_config->FindMixingPlaneInterfaceMarker(donor_geometry->GetnMarker(), iMarkerInt); + short markTarget= target_config->FindMixingPlaneInterfaceMarker(target_geometry->GetnMarker(), iMarkerInt); /*--- Check if this interface connects the two zones, if not continue. ---*/ if(!CInterpolator::CheckInterfaceBoundary(markDonor, markTarget)) continue; @@ -78,11 +78,11 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter /*--- Fill send buffers. ---*/ - vector sendDonorMarker(nSpanDonor); - vector sendDonorVar(static_cast(nSpanDonor) * nMixingVars); + vector sendDonorMarker(nSpanDonor + 1); + vector sendDonorVar(static_cast(nSpanDonor + 1) * nMixingVars); if (markDonor != -1) { - for (auto iSpan = 0ul; iSpan < nSpanDonor; iSpan++) { + for (auto iSpan = 0ul; iSpan < nSpanDonor + 1; iSpan++) { GetDonor_Variable(donor_solution, donor_geometry, donor_config, markDonor, iSpan, 0); for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = Donor_Variable[iVar]; sendDonorMarker[iSpan] = markDonor; @@ -90,13 +90,13 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter } #ifdef HAVE_MPI /*--- Gather data. ---*/ - const auto nTotalDonors = nSpanDonor * size; // Number of donor spans across all ranks - const auto nSpanDonorVars = nSpanDonor * nMixingVars; // Number of variables to be transferred on each rank + const auto nTotalDonors = (nSpanDonor + 1) * size; // Number of donor spans across all ranks + const auto nSpanDonorVars = (nSpanDonor + 1) * nMixingVars; // Number of variables to be transferred on each rank vector buffDonorMarker(nTotalDonors); vector buffDonorVar(static_cast(nTotalDonors) * nMixingVars); // Total number of variables to be transferred on all ranks - SU2_MPI::Allgather(sendDonorMarker.data(), nSpanDonor, MPI_SHORT, - buffDonorMarker.data(), nSpanDonor, MPI_SHORT, + SU2_MPI::Allgather(sendDonorMarker.data(), nSpanDonor + 1, MPI_SHORT, + buffDonorMarker.data(), nSpanDonor + 1, MPI_SHORT, SU2_MPI::GetComm()); SU2_MPI::Allgather(sendDonorVar.data(), nSpanDonorVars, MPI_DOUBLE, @@ -104,11 +104,12 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter SU2_MPI::GetComm()); for (auto iSize = 0; iSize < size; iSize++){ - if (buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor)] != -1) { - for (auto iSpan = 0ul; iSpan < nSpanDonor; iSpan++){ + if (buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor + 1)] != -1) { + for (auto iSpan = 0ul; iSpan < nSpanDonor + 1; iSpan++){ for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = buffDonorVar[static_cast(iSize) * nSpanDonorVars + iSpan * nMixingVars + iVar]; } - markDonor = buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor)]; + markDonor = buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor + 1)]; + break; // Avoid overwriting } } #endif From 7b78f0626b888d2fbd95e90f5c0e015c4808f1e9 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 9 Dec 2025 18:47:43 +0000 Subject: [PATCH 47/79] Fix identification of marker boundaries at mixing plane interface --- Common/include/CConfig.hpp | 2 +- Common/src/CConfig.cpp | 4 ++-- .../src/interface_interpolation/CMixingPlane.cpp | 4 ++-- SU2_CFD/src/drivers/CDriver.cpp | 2 +- .../src/interfaces/cfd/CMixingPlaneInterface.cpp | 14 +++++--------- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 7becae809174..07a78adf8b2a 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -10040,7 +10040,7 @@ class CConfig { * \param[in] nMarker - Number of the marker in a zone being tested, starting at 0. * \return value > 1 if (on this mpi rank) the zone defined by config is part of the mixing plane. */ - short FindMixingPlaneInterfaceMarker(unsigned short nMarker) const; + short FindMixingPlaneInterfaceMarker(unsigned short nMarker, unsigned short iMarkerInt) const; /*! * \brief Get whether or not to save solution data to libROM. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 00020812c3f1..58f4de2ed778 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -9964,11 +9964,11 @@ short CConfig::FindInterfaceMarker(unsigned short iInterface) const { return -1; } -short CConfig::FindMixingPlaneInterfaceMarker(unsigned short nMarker) const { +short CConfig::FindMixingPlaneInterfaceMarker(unsigned short nMarker, unsigned short iMarkerInt) const { short mark; for (auto iMarker = 0; iMarker < nMarker; iMarker++){ /*--- If the tag GetMarker_All_MixingPlaneInterface equals the index we are looping at ---*/ - if (GetMarker_All_MixingPlaneInterface(iMarker)){ + if (GetMarker_All_MixingPlaneInterface(iMarker) == iMarkerInt){ /*--- We have identified the local index of the marker ---*/ /*--- Store the identifier for the marker ---*/ mark = iMarker; diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index d960e00dc0e8..ad18fcd9493c 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -236,7 +236,7 @@ void CMixingPlane::WriteInterpolationDetails(const std::string& filename, const outFile << "===============================================================" << endl; // Loop through each marker interface - for (auto iMarkerInt = 0; iMarkerInt < nMarkerInt; iMarkerInt++) { + for (auto iMarkerInt = 0; iMarkerInt < nMarkerInt + 1; iMarkerInt++) { if (targetSpans[iMarkerInt].empty()) continue; outFile << "Marker Interface " << iMarkerInt << "\n"; @@ -256,7 +256,7 @@ void CMixingPlane::WriteInterpolationDetails(const std::string& filename, const outFile << "\n\nGrouped by Donor Span\n"; outFile << "=====================\n\n"; - for (auto iMarkerInt = 0; iMarkerInt < nMarkerInt; iMarkerInt++) { + for (auto iMarkerInt = 0; iMarkerInt < nMarkerInt + 1; iMarkerInt++) { if (targetSpans[iMarkerInt].empty()) continue; outFile << "Marker Interface " << iMarkerInt << "\n"; diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 474705f3e33e..4abbcd1b1e92 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2963,7 +2963,7 @@ void CFluidDriver::Run() { for (iZone = 0; iZone < nZone; iZone++) { for (jZone = 0; jZone < nZone; jZone++) if(jZone != iZone && interpolator_container[iZone][jZone] != nullptr) - interpolator_container[iZone][jZone]->SetTransferCoeff(config_container); + interpolator_container[iZone][jZone]->SetTransferCoeff(geometry_container, config_container); } } diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index a715c679aa29..8478bf6e8401 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -78,7 +78,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter /*--- Fill send buffers. ---*/ - vector sendDonorMarker(nSpanDonor + 1); + vector sendDonorMarker(nSpanDonor + 1, -1); vector sendDonorVar(static_cast(nSpanDonor + 1) * nMixingVars); if (markDonor != -1) { @@ -124,23 +124,19 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter auto& targetSpan = interpolator.targetSpans[iMarkerInt][iTargetSpan]; + /*--- Get the global index of the donor span. ---*/ + const auto donorSpan = targetSpan.donorSpan; + InitializeTarget_Variable(target_solution, markTarget, iTargetSpan, nSpanDonor); if ((iTargetSpan == 0) || (iTargetSpan == nTargetSpan) || (iTargetSpan == nTargetSpan - 1)) { /*--- Transfer values at hub, shroud and 1D values ---*/ - unsigned long donorSpan; - if (iTargetSpan == 0) donorSpan = 0; - else if (iTargetSpan == nTargetSpan - 1) donorSpan = nSpanDonor - 1; - else if (iTargetSpan == nTargetSpan) donorSpan = nSpanDonor; - RecoverTarget_Span_Endwall(sendDonorVar, donorSpan); SetTarget_Variable(target_solution, target_geometry, target_config, markTarget, iTargetSpan, 0); } else { - /*--- Get the global index of the donor and the interpolation coefficient. ---*/ - - const auto donorSpan = targetSpan.donorSpan; + /*--- Get the global index of interpolation coefficient. ---*/ const auto donorCoeff = targetSpan.coefficient; /*--- Recover the Target_Variable from the buffer of variables. ---*/ From 49de8bb8792eccbb5171c205b11e5c2b30d55950 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 30 Dec 2025 22:56:19 +0000 Subject: [PATCH 48/79] Fix dummy run --- SU2_CFD/src/drivers/CDriver.cpp | 42 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 4abbcd1b1e92..6d27a7aa0696 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2666,9 +2666,11 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, geometry[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config[iZone], true); } - 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); + if (rank == MASTER_NODE && !dummy) { + 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); + } } if(mixingplane){ @@ -2706,23 +2708,25 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, } } - if (rank == MASTER_NODE) cout<<"Initialize inflow and outflow average solution quantities." << endl; - for(iZone = 0; iZone < nZone; iZone++) { - solver[iZone][INST_0][MESH_0][FLOW_SOL]->PreprocessAverage(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],INFLOW); - solver[iZone][INST_0][MESH_0][FLOW_SOL]->PreprocessAverage(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],OUTFLOW); - solver[iZone][INST_0][MESH_0][FLOW_SOL]->TurboAverageProcess(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],INFLOW); - solver[iZone][INST_0][MESH_0][FLOW_SOL]->TurboAverageProcess(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],OUTFLOW); - solver[iZone][INST_0][MESH_0][FLOW_SOL]->GatherInOutAverageValues(config[iZone], geometry[iZone][INST_0][MESH_0]); - if (rank == MASTER_NODE){ - flowAngleIn = solver[iZone][INST_0][MESH_0][FLOW_SOL]->GetTurboVelocityIn(iZone, config[iZone]->GetnSpanWiseSections())[1]; - flowAngleIn /= solver[iZone][INST_0][MESH_0][FLOW_SOL]->GetTurboVelocityIn(iZone, config[iZone]->GetnSpanWiseSections())[0]; - flowAngleIn = atan(flowAngleIn)*180.0/PI_NUMBER; - cout << "Inlet flow angle for Row "<< iZone + 1<< ": "<< flowAngleIn <<"°." <GetTurboVelocityOut(iZone, config[iZone]->GetnSpanWiseSections())[1]; - flowAngleOut /= solver[iZone][INST_0][MESH_0][FLOW_SOL]->GetTurboVelocityOut(iZone, config[iZone]->GetnSpanWiseSections())[0]; - flowAngleOut = atan(flowAngleOut)*180.0/PI_NUMBER; - cout << "Outlet flow angle for Row "<< iZone + 1<< ": "<< flowAngleOut <<"°." <PreprocessAverage(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],INFLOW); + solver[iZone][INST_0][MESH_0][FLOW_SOL]->PreprocessAverage(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],OUTFLOW); + solver[iZone][INST_0][MESH_0][FLOW_SOL]->TurboAverageProcess(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],INFLOW); + solver[iZone][INST_0][MESH_0][FLOW_SOL]->TurboAverageProcess(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],OUTFLOW); + solver[iZone][INST_0][MESH_0][FLOW_SOL]->GatherInOutAverageValues(config[iZone], geometry[iZone][INST_0][MESH_0]); + if (rank == MASTER_NODE){ + flowAngleIn = solver[iZone][INST_0][MESH_0][FLOW_SOL]->GetTurboVelocityIn(iZone, config[iZone]->GetnSpanWiseSections())[1]; + flowAngleIn /= solver[iZone][INST_0][MESH_0][FLOW_SOL]->GetTurboVelocityIn(iZone, config[iZone]->GetnSpanWiseSections())[0]; + flowAngleIn = atan(flowAngleIn)*180.0/PI_NUMBER; + cout << "Inlet flow angle for Row "<< iZone + 1<< ": "<< flowAngleIn <<"°." <GetTurboVelocityOut(iZone, config[iZone]->GetnSpanWiseSections())[1]; + flowAngleOut /= solver[iZone][INST_0][MESH_0][FLOW_SOL]->GetTurboVelocityOut(iZone, config[iZone]->GetnSpanWiseSections())[0]; + flowAngleOut = atan(flowAngleOut)*180.0/PI_NUMBER; + cout << "Outlet flow angle for Row "<< iZone + 1<< ": "<< flowAngleOut <<"°." < Date: Fri, 9 Jan 2026 23:34:54 +0000 Subject: [PATCH 49/79] Improve readability of direct residual in adjoint problems --- SU2_CFD/src/drivers/CDriver.cpp | 164 ++++++++++++++++---------------- 1 file changed, 80 insertions(+), 84 deletions(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 6d27a7aa0696..1fd44b47bf3b 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2738,112 +2738,108 @@ void CDriver::PrintDirectResidual(RECORDING kind_recording) { if (rank != MASTER_NODE || kind_recording != RECORDING::SOLUTION_VARIABLES) return; const bool multizone = config_container[ZONE_0]->GetMultizone_Problem(); + const unsigned short fieldWidth = 25; - /*--- Helper lambda func to return lenghty [iVar][iZone] string. ---*/ - auto iVar_iZone2string = [&](unsigned short ivar, unsigned short izone) { - if (multizone) - return "[" + std::to_string(ivar) + "][" + std::to_string(izone) + "]"; - return "[" + std::to_string(ivar) + "]"; - }; - - /*--- Print residuals in the first iteration ---*/ + /*--- Table for Residual Values ---*/ + PrintingToolbox::CTablePrinter ResidualTable(&std::cout); + ResidualTable.SetPrecision(config_container[ZONE_0]->GetOutput_Precision()); + ResidualTable.SetAlign(PrintingToolbox::CTablePrinter::RIGHT); - const unsigned short fieldWidth = 15; - PrintingToolbox::CTablePrinter RMSTable(&std::cout); - RMSTable.SetPrecision(config_container[ZONE_0]->GetOutput_Precision()); + std::cout << "\n-- Direct Residual Summary:" << std::endl; - /*--- The CTablePrinter requires two sweeps: - *--- 0. Add the colum names (addVals=0=false) plus CTablePrinter.PrintHeader() - *--- 1. Add the RMS-residual values (addVals=1=true) plus CTablePrinter.PrintFooter() ---*/ - for (int addVals = 0; addVals < 2; addVals++) { + /*--- Setup table columns ---*/ + ResidualTable.AddColumn("Residual", fieldWidth); + ResidualTable.AddColumn("log10(RMS)", fieldWidth); + ResidualTable.PrintHeader(); - for (unsigned short iZone = 0; iZone < nZone; iZone++) { + /*--- Loop through each zone ---*/ + for (unsigned short iZone = 0; iZone < nZone; iZone++) { - auto solvers = solver_container[iZone][INST_0][MESH_0]; - auto configs = config_container[iZone]; + auto solvers = solver_container[iZone][INST_0][MESH_0]; + auto configs = config_container[iZone]; - /*--- Note: the FEM-Flow solvers are availalbe for disc. adjoint runs only for SingleZone. ---*/ - if (configs->GetFluidProblem() || configs->GetFEMSolver()) { + /*--- Print zone header ---*/ + if (multizone) { + ResidualTable << "ZONE " + std::to_string(iZone) << ""; + ResidualTable.PrintFooter(); + } - for (unsigned short iVar = 0; iVar < solvers[FLOW_SOL]->GetnVar(); iVar++) { - if (!addVals) - RMSTable.AddColumn("rms_Flow" + iVar_iZone2string(iVar, iZone), fieldWidth); - else - RMSTable << log10(solvers[FLOW_SOL]->GetRes_RMS(iVar)); - } + /*--- Fluid or FEM-Flow Problems ---*/ + if (configs->GetFluidProblem() || configs->GetFEMSolver()) { - if (configs->GetKind_Turb_Model() != TURB_MODEL::NONE && !configs->GetFrozen_Visc_Disc()) { - for (unsigned short iVar = 0; iVar < solvers[TURB_SOL]->GetnVar(); iVar++) { - if (!addVals) - RMSTable.AddColumn("rms_Turb" + iVar_iZone2string(iVar, iZone), fieldWidth); - else - RMSTable << log10(solvers[TURB_SOL]->GetRes_RMS(iVar)); - } - } + /*--- Flow residuals ---*/ + for (unsigned short iVar = 0; iVar < solvers[FLOW_SOL]->GetnVar(); iVar++) { + std::string varName = "rms_Flow[" + std::to_string(iVar) + "]"; + ResidualTable << varName << log10(solvers[FLOW_SOL]->GetRes_RMS(iVar)); + } - if (configs->GetKind_Species_Model() != SPECIES_MODEL::NONE) { - for (unsigned short iVar = 0; iVar < solvers[SPECIES_SOL]->GetnVar(); iVar++) { - if (!addVals) - RMSTable.AddColumn("rms_Spec" + iVar_iZone2string(iVar, iZone), fieldWidth); - else - RMSTable << log10(solvers[SPECIES_SOL]->GetRes_RMS(iVar)); - } + /*--- Turbulence residuals ---*/ + if (configs->GetKind_Turb_Model() != TURB_MODEL::NONE && !configs->GetFrozen_Visc_Disc()) { + for (unsigned short iVar = 0; iVar < solvers[TURB_SOL]->GetnVar(); iVar++) { + std::string varName = "rms_Turb[" + std::to_string(iVar) + "]"; + ResidualTable << varName << log10(solvers[TURB_SOL]->GetRes_RMS(iVar)); } + } - if (!multizone && configs->GetWeakly_Coupled_Heat()){ - if (!addVals) RMSTable.AddColumn("rms_Heat" + iVar_iZone2string(0, iZone), fieldWidth); - else RMSTable << log10(solvers[HEAT_SOL]->GetRes_RMS(0)); + /*--- Species residuals ---*/ + if (configs->GetKind_Species_Model() != SPECIES_MODEL::NONE) { + for (unsigned short iVar = 0; iVar < solvers[SPECIES_SOL]->GetnVar(); iVar++) { + std::string varName = "rms_Spec[" + std::to_string(iVar) + "]"; + ResidualTable << varName << log10(solvers[SPECIES_SOL]->GetRes_RMS(iVar)); } + } - if (configs->AddRadiation()) { - if (!addVals) RMSTable.AddColumn("rms_Rad" + iVar_iZone2string(0, iZone), fieldWidth); - else RMSTable << log10(solvers[RAD_SOL]->GetRes_RMS(0)); - } + /*--- Heat residuals (weakly coupled) ---*/ + if (!multizone && configs->GetWeakly_Coupled_Heat()) { + ResidualTable << "rms_Heat[0]" << log10(solvers[HEAT_SOL]->GetRes_RMS(0)); + } + /*--- Radiation residuals ---*/ + if (configs->AddRadiation()) { + ResidualTable << "rms_Rad[0]" << log10(solvers[RAD_SOL]->GetRes_RMS(0)); } - else if (configs->GetStructuralProblem()) { - if (configs->GetGeometricConditions() == STRUCT_DEFORMATION::LARGE){ - if (!addVals) { - RMSTable.AddColumn("UTOL-A", fieldWidth); - RMSTable.AddColumn("RTOL-A", fieldWidth); - RMSTable.AddColumn("ETOL-A", fieldWidth); - } - else { - RMSTable << log10(solvers[FEA_SOL]->GetRes_FEM(0)) - << log10(solvers[FEA_SOL]->GetRes_FEM(1)) - << log10(solvers[FEA_SOL]->GetRes_FEM(2)); - } - } - else{ - if (!addVals) { - RMSTable.AddColumn("log10[RMS Ux]", fieldWidth); - RMSTable.AddColumn("log10[RMS Uy]", fieldWidth); - if (nDim == 3) RMSTable.AddColumn("log10[RMS Uz]", fieldWidth); - } - else { - RMSTable << log10(solvers[FEA_SOL]->GetRes_FEM(0)) - << log10(solvers[FEA_SOL]->GetRes_FEM(1)); - if (nDim == 3) RMSTable << log10(solvers[FEA_SOL]->GetRes_FEM(2)); - } - } + } + /*--- Structural Problems ---*/ + else if (configs->GetStructuralProblem()) { + if (configs->GetGeometricConditions() == STRUCT_DEFORMATION::LARGE) { + ResidualTable << "UTOL-A" << log10(solvers[FEA_SOL]->GetRes_FEM(0)); + ResidualTable << "RTOL-A" << log10(solvers[FEA_SOL]->GetRes_FEM(1)); + ResidualTable << "ETOL-A" << log10(solvers[FEA_SOL]->GetRes_FEM(2)); } - else if (configs->GetHeatProblem()) { - - if (!addVals) RMSTable.AddColumn("rms_Heat" + iVar_iZone2string(0, iZone), fieldWidth); - else RMSTable << log10(solvers[HEAT_SOL]->GetRes_RMS(0)); - } else { - SU2_MPI::Error("Invalid KindSolver for CDiscAdj-MultiZone/SingleZone-Driver.", CURRENT_FUNCTION); + else { + ResidualTable << "RMS Ux" << log10(solvers[FEA_SOL]->GetRes_FEM(0)); + ResidualTable << "RMS Uy" << log10(solvers[FEA_SOL]->GetRes_FEM(1)); + if (nDim == 3) { + ResidualTable << "RMS Uz" << log10(solvers[FEA_SOL]->GetRes_FEM(2)); + } } - } // loop iZone - if (!addVals) RMSTable.PrintHeader(); - else RMSTable.PrintFooter(); + } + /*--- Heat Problems ---*/ + else if (configs->GetHeatProblem()) { + + ResidualTable << "rms_Heat[0]" << log10(solvers[HEAT_SOL]->GetRes_RMS(0)); - } // for addVals + } + else { + SU2_MPI::Error("Invalid KindSolver for CDiscAdj-MultiZone/SingleZone-Driver.", CURRENT_FUNCTION); + } + + /*--- Print zone footer ---*/ + if (multizone) { + ResidualTable.PrintFooter(); + } + + } + + /*--- Print final footer for single zone ---*/ + if (!multizone) { + ResidualTable.PrintFooter(); + } - cout << "\n-------------------------------------------------------------------------\n" << endl; + std::cout << "\n-------------------------------------------------------------------------\n" << std::endl; } From e59859710d076f3ce0a18794379f2b0425ecdc1e Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 30 Jan 2026 05:21:40 +0000 Subject: [PATCH 50/79] Remove deprecated functions, fix MPI in MP preprocessing --- SU2_CFD/include/interfaces/CInterface.hpp | 33 ------------ SU2_CFD/src/drivers/CDriver.cpp | 40 +++++++------- SU2_CFD/src/numerics/flow/convection/roe.cpp | 2 + SU2_CFD/src/output/CFlowCompOutput.cpp | 3 ++ SU2_CFD/src/output/CFlowOutput.cpp | 2 + SU2_CFD/src/solvers/CEulerSolver.cpp | 56 ++++++++++---------- 6 files changed, 53 insertions(+), 83 deletions(-) diff --git a/SU2_CFD/include/interfaces/CInterface.hpp b/SU2_CFD/include/interfaces/CInterface.hpp index bd565c9241c6..a83e8392d3e2 100644 --- a/SU2_CFD/include/interfaces/CInterface.hpp +++ b/SU2_CFD/include/interfaces/CInterface.hpp @@ -200,39 +200,6 @@ class CInterface { CGeometry *donor_geometry, CGeometry *target_geometry, const CConfig *donor_config, const CConfig *target_config) { }; - /*! - * \brief Transfer pre-processing for the mixing plane inteface. - * \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 PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_geometry, - const CConfig *donor_config, const CConfig *target_config, unsigned short iMarkerInt); - - /*! - * \brief Interpolate data and scatter it into different processors, for matching meshes. - * \param[in] donor_solution - Solution from the donor mesh. - * \param[in] target_solution - Solution from the target mesh. - * \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 AllgatherAverage(CSolver *donor_solution, CSolver *target_solution, - CGeometry *donor_geometry, CGeometry *target_geometry, - const CConfig *donor_config, const CConfig *target_config, unsigned short iMarkerInt); - - /*! - * \brief Interpolate data and scatter it into different processors, for matching meshes. - * \param[in] donor_solution - Solution from the donor mesh. - * \param[in] target_solution - Solution from the target mesh. - * \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 GatherAverageValues(CSolver *donor_solution, CSolver *target_solution, unsigned short donorZone); /*! * \brief Set the contact resistance value for the solid-to-solid heat transfer interface. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 1fd44b47bf3b..6eacb4cd22d6 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2666,8 +2666,8 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, geometry[iZone][INST_0][MESH_0]->GatherInOutAverageValues(config[iZone], true); } - if (rank == MASTER_NODE && !dummy) { - cout<<"Initialize solver containers for average quantities." << endl; + if (rank == MASTER_NODE) cout<<"Initialize solver containers for average quantities." << endl; + if (!dummy){ for (iZone = 0; iZone < nZone; iZone++) { solver[iZone][INST_0][MESH_0][FLOW_SOL]->InitTurboContainers(geometry[iZone][INST_0][MESH_0],config, iZone); } @@ -2708,25 +2708,23 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, } } - if (rank == MASTER_NODE && !dummy){ - cout<<"Initialize inflow and outflow average solution quantities." << endl; - for(iZone = 0; iZone < nZone; iZone++) { - solver[iZone][INST_0][MESH_0][FLOW_SOL]->PreprocessAverage(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],INFLOW); - solver[iZone][INST_0][MESH_0][FLOW_SOL]->PreprocessAverage(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],OUTFLOW); - solver[iZone][INST_0][MESH_0][FLOW_SOL]->TurboAverageProcess(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],INFLOW); - solver[iZone][INST_0][MESH_0][FLOW_SOL]->TurboAverageProcess(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],OUTFLOW); - solver[iZone][INST_0][MESH_0][FLOW_SOL]->GatherInOutAverageValues(config[iZone], geometry[iZone][INST_0][MESH_0]); - if (rank == MASTER_NODE){ - flowAngleIn = solver[iZone][INST_0][MESH_0][FLOW_SOL]->GetTurboVelocityIn(iZone, config[iZone]->GetnSpanWiseSections())[1]; - flowAngleIn /= solver[iZone][INST_0][MESH_0][FLOW_SOL]->GetTurboVelocityIn(iZone, config[iZone]->GetnSpanWiseSections())[0]; - flowAngleIn = atan(flowAngleIn)*180.0/PI_NUMBER; - cout << "Inlet flow angle for Row "<< iZone + 1<< ": "<< flowAngleIn <<"°." <GetTurboVelocityOut(iZone, config[iZone]->GetnSpanWiseSections())[1]; - flowAngleOut /= solver[iZone][INST_0][MESH_0][FLOW_SOL]->GetTurboVelocityOut(iZone, config[iZone]->GetnSpanWiseSections())[0]; - flowAngleOut = atan(flowAngleOut)*180.0/PI_NUMBER; - cout << "Outlet flow angle for Row "<< iZone + 1<< ": "<< flowAngleOut <<"°." <PreprocessAverage(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],INFLOW); + solver[iZone][INST_0][MESH_0][FLOW_SOL]->PreprocessAverage(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],OUTFLOW); + solver[iZone][INST_0][MESH_0][FLOW_SOL]->TurboAverageProcess(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],INFLOW); + solver[iZone][INST_0][MESH_0][FLOW_SOL]->TurboAverageProcess(solver[iZone][INST_0][MESH_0], geometry[iZone][INST_0][MESH_0],config[iZone],OUTFLOW); + solver[iZone][INST_0][MESH_0][FLOW_SOL]->GatherInOutAverageValues(config[iZone], geometry[iZone][INST_0][MESH_0]); + if (rank == MASTER_NODE){ + flowAngleIn = solver[iZone][INST_0][MESH_0][FLOW_SOL]->GetTurboVelocityIn(iZone, config[iZone]->GetnSpanWiseSections())[1]; + flowAngleIn /= solver[iZone][INST_0][MESH_0][FLOW_SOL]->GetTurboVelocityIn(iZone, config[iZone]->GetnSpanWiseSections())[0]; + flowAngleIn = atan(flowAngleIn)*180.0/PI_NUMBER; + cout << "Inlet flow angle for Row "<< iZone + 1<< ": "<< flowAngleIn <<"°." <GetTurboVelocityOut(iZone, config[iZone]->GetnSpanWiseSections())[1]; + flowAngleOut /= solver[iZone][INST_0][MESH_0][FLOW_SOL]->GetTurboVelocityOut(iZone, config[iZone]->GetnSpanWiseSections())[0]; + flowAngleOut = atan(flowAngleOut)*180.0/PI_NUMBER; + cout << "Outlet flow angle for Row "<< iZone + 1<< ": "<< flowAngleOut <<"°." < CUpwRoeBase_Flow::ComputeResidual(const CConfig* confi } AD::SetPreaccOut(Flux, nVar); + AD::SetPreaccOut(Jacobian_i, nVar, nVar); + AD::SetPreaccOut(Jacobian_j, nVar, nVar); AD::EndPreacc(); return ResidualType<>(Flux, Jacobian_i, Jacobian_j); diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 321c23347489..33ff8287bb76 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -542,6 +542,7 @@ void CFlowCompOutput::SetTurboPerformance_Output(std::vectorGetInletState().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 << "Rel Flow Angle " << BladePerf->GetInletState().GetFlowAngle()*180/PI_NUMBER << BladePerf->GetOutletState().GetFlowAngle()*180/PI_NUMBER; TurboInOut.PrintFooter(); } cout<GetOutletState().GetMachValue()); SetHistoryOutputValue("AbsFlowAngleIn_" + tag.str(), BladePerf->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER); SetHistoryOutputValue("AbsFlowAngleOut_" + tag.str(), BladePerf->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER); + SetHistoryOutputValue("RelFlowAngleIn_" + tag.str(), BladePerf->GetInletState().GetFlowAngle()*180/PI_NUMBER); + SetHistoryOutputValue("RelFlowAngleOut_" + tag.str(), BladePerf->GetOutletState().GetFlowAngle()*180/PI_NUMBER); SetHistoryOutputValue("KineticEnergyLoss_" + tag.str(), BladePerf->GetKineticEnergyLoss()); SetHistoryOutputValue("TotPressureLoss_" + tag.str(), BladePerf->GetTotalPressureLoss()); } diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index b355c0698afb..863145e0c402 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -4096,6 +4096,8 @@ void CFlowOutput::AddTurboOutput(unsigned short nZone){ 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); + AddHistoryOutput("RelFlowAngleIn_" + tag, "RelFlowAngleIn_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Relative flow angle in " + tag, HistoryFieldType::DEFAULT); + AddHistoryOutput("RelFlowAngleOut_" + tag, "RelFlowAngleOut_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Relative flow angle out " + tag, HistoryFieldType::DEFAULT); AddHistoryOutput("KineticEnergyLoss_" + tag, "KELC_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Blade Kinetic Energy Loss Coefficient", HistoryFieldType::DEFAULT); AddHistoryOutput("TotPressureLoss_" + tag, "TPLC_" + tag, ScreenOutputFormat::SCIENTIFIC, "TURBO_PERF", "Blade Pressure Loss Coefficient", HistoryFieldType::DEFAULT); } diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 4585cf83ff1c..908ae3890706 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -462,15 +462,14 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig **config_con ExtAverageTurboVelocity.resize(nDim); for (auto iDim = 0u; iDim < nDim; iDim++) ExtAverageTurboVelocity[iDim] = su2double(0.0); - auto nMarkerInterface = config->GetnMarker_ZoneInterface(); - - MixingState.resize(nMarkerInterface); - MixingStateNodes.resize(nMarkerInterface); - - for (unsigned long iMarker = 0; iMarker < nMarkerInterface; iMarker++) { - if (config->GetMarker_All_KindBC(iMarker) == GILES_BOUNDARY) { - MixingState[iMarker].resize(nSpanWiseSections+1); - MixingStateNodes[iMarker].resize(nSpanWiseSections+1); + MixingState.resize(nMarker); + MixingStateNodes.resize(nMarker); + + for (auto iMarkerInt = 1u; iMarkerInt < config->GetnMarker_MixingPlaneInterface()/2 + 1; iMarkerInt++) { + auto iMarkerMP = config->FindMixingPlaneInterfaceMarker(geometry->GetnMarker(), iMarkerInt); + if (iMarkerMP != -1) { + MixingState[iMarkerMP].resize(nSpanWiseSections+1); + MixingStateNodes[iMarkerMP].resize(nSpanWiseSections+1); } } @@ -8919,35 +8918,34 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon #ifdef HAVE_MPI - /*--- Add information using all the nodes ---*/ - - su2double MyTotalAreaDensity = TotalAreaDensity; - su2double MyTotalAreaPressure = TotalAreaPressure; - su2double MyTotalAreaNu = TotalAreaNu; - su2double MyTotalAreaKine = TotalAreaKine; - su2double MyTotalAreaOmega = TotalAreaOmega; + auto Allreduce = [](su2double x) { + su2double tmp = x; x = 0.0; + SU2_MPI::Allreduce(&tmp, &x, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + return x; + }; - SU2_MPI::Allreduce(&MyTotalAreaDensity, &TotalAreaDensity, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&MyTotalAreaPressure, &TotalAreaPressure, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&MyTotalAreaNu, &TotalAreaNu, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&MyTotalAreaKine, &TotalAreaKine, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); - SU2_MPI::Allreduce(&MyTotalAreaOmega, &TotalAreaOmega, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + /*--- Add information using all the nodes ---*/ - auto* MyTotalAreaVelocity = new su2double[nDim]; + TotalAreaDensity = Allreduce(TotalAreaDensity); + TotalAreaPressure = Allreduce(TotalAreaPressure); + TotalAreaNu = Allreduce(TotalAreaNu); + TotalAreaKine = Allreduce(TotalAreaKine); + TotalAreaOmega = Allreduce(TotalAreaOmega); - for (auto iDim = 0u; iDim < nDim; iDim++) { - MyTotalAreaVelocity[iDim] = TotalAreaVelocity[iDim]; - } + auto* buffer = new su2double[nDim]; - SU2_MPI::Allreduce(MyTotalAreaVelocity, TotalAreaVelocity, nDim, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + auto Allreduce_inplace = [buffer](int size, su2double* x) { + SU2_MPI::Allreduce(x, buffer, size, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); + for(int i=0; iGetnMarker_All(); iMarker++){ for (auto iMarkerTP=1; iMarkerTP < config->GetnMarker_Turbomachinery()+1; iMarkerTP++){ if (config->GetMarker_All_Turbomachinery(iMarker) == iMarkerTP){ From 061a0b5f2543ddae2e84d6b07dbfd35fc2c5524b Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 30 Jan 2026 08:31:05 +0000 Subject: [PATCH 51/79] unused vars --- Common/src/interface_interpolation/CMixingPlane.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index ad18fcd9493c..91739f560b53 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -215,7 +215,6 @@ void CMixingPlane::WriteInterpolationDetails(const std::string& filename, const } const auto donor_config = config[donorZone]; - const auto target_config = config[targetZone]; const auto nMarkerInt = config[donorZone]->GetnMarker_MixingPlaneInterface() / 2; outFile << "Mixing-Plane Interpolator Details. Donor Zone = " << donorZone << " Target Zone = " << targetZone << ". Interpolation Method = "; From 98301d93ecd1d55bbc81b31dd498047c0b7ceb90 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 30 Jan 2026 08:40:26 +0000 Subject: [PATCH 52/79] type comaprison warning --- 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 f6234dc7ae8c..74122c092261 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -465,7 +465,7 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig **config_con MixingState.resize(nMarker); MixingStateNodes.resize(nMarker); - for (auto iMarkerInt = 1u; iMarkerInt < config->GetnMarker_MixingPlaneInterface()/2 + 1; iMarkerInt++) { + for (auto iMarkerInt = 1; iMarkerInt < config->GetnMarker_MixingPlaneInterface()/2 + 1; iMarkerInt++) { auto iMarkerMP = config->FindMixingPlaneInterfaceMarker(geometry->GetnMarker(), iMarkerInt); if (iMarkerMP != -1) { MixingState[iMarkerMP].resize(nSpanWiseSections+1); From 46a4332dfe175ab4ab93706465e816291b8c7a56 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 30 Jan 2026 10:13:13 +0000 Subject: [PATCH 53/79] spelling --- SU2_CFD/src/iteration/CFluidIteration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 4e0f81c66dc1..762165ce81b9 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -243,7 +243,7 @@ bool CFluidIteration::Monitor(COutput* output, CIntegration**** integration, CGe UpdateRamps(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::BOUNDARY); if (config[val_iZone]->GetMUSCLRamp()) - UpdateRamp(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::MUSCL); + UpdateRamps(geometry, config, config[val_iZone]->GetInnerIter(), val_iZone, RAMP_TYPE::MUSCL); 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(), From 4924347b75ba85e5be72ebf2eb9e6256bbfa90cb Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 30 Jan 2026 11:08:06 +0000 Subject: [PATCH 54/79] type compare --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 01c44fc54fd9..0a4dc2d1e53f 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -64,7 +64,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter /*--- Loop over interface markers. ---*/ - for (auto iMarkerInt = 1u; iMarkerInt < donor_config->GetnMarker_MixingPlaneInterface()/2 + 1; iMarkerInt++) { + for (auto iMarkerInt = 1; iMarkerInt < donor_config->GetnMarker_MixingPlaneInterface()/2 + 1; iMarkerInt++) { /*--- Find the markers containing the interface ---*/ short markDonor = donor_config->FindMixingPlaneInterfaceMarker(donor_geometry->GetnMarker(), iMarkerInt); @@ -82,7 +82,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter vector sendDonorVar(static_cast(nSpanDonor + 1) * nMixingVars); if (markDonor != -1) { - for (auto iSpan = 0ul; iSpan < nSpanDonor + 1; iSpan++) { + for (auto iSpan = 0; iSpan < nSpanDonor + 1; iSpan++) { GetDonor_Variable(donor_solution, donor_geometry, donor_config, markDonor, iSpan, 0); for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = Donor_Variable[iVar]; sendDonorMarker[iSpan] = markDonor; From 136daa78ab30414d6ed545ea5f04f10fe6fccd94 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 30 Jan 2026 11:46:43 +0000 Subject: [PATCH 55/79] types --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 0a4dc2d1e53f..40c0ecbd5fc5 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -105,7 +105,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter for (auto iSize = 0; iSize < size; iSize++){ if (buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor + 1)] != -1) { - for (auto iSpan = 0ul; iSpan < nSpanDonor + 1; iSpan++){ + for (auto iSpan = 0; iSpan < nSpanDonor + 1; iSpan++){ for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = buffDonorVar[static_cast(iSize) * nSpanDonorVars + iSpan * nMixingVars + iVar]; } markDonor = buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor + 1)]; From b9b34ba0dc9d6371c977ffdcab7d9ec28df950f8 Mon Sep 17 00:00:00 2001 From: Ole Burghardt Date: Wed, 4 Feb 2026 14:49:35 +0100 Subject: [PATCH 56/79] Changes to the tape debug mode, improving the detection of errors when recording wrt mesh coordinates. The tape debug mode code is currently also reworked in #2721. The changes in this commit could already be useful for the current turbo discrete adjoint development. --- Common/include/option_structure.hpp | 8 ++--- SU2_CFD/include/output/CFlowOutput.hpp | 2 +- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 35 ++++++++----------- .../src/iteration/CDiscAdjFluidIteration.cpp | 21 ++++++----- 4 files changed, 28 insertions(+), 38 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 83e498d27587..0a6555095da7 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -2624,7 +2624,7 @@ enum class CHECK_TAPE_VARIABLES { }; static const MapType CheckTapeVariables_Map = { MakePair("SOLVER_VARIABLES", CHECK_TAPE_VARIABLES::SOLVER_VARIABLES) - MakePair("SOLVER_VARIABLES_AND_MESH_COORDINATES", CHECK_TAPE_VARIABLES::MESH_COORDINATES) + MakePair("MESH_COORDINATES", CHECK_TAPE_VARIABLES::MESH_COORDINATES) }; enum class RECORDING { @@ -2632,11 +2632,7 @@ enum class RECORDING { SOLUTION_VARIABLES, MESH_COORDS, MESH_DEFORM, - SOLUTION_AND_MESH, - TAG_INIT_SOLVER_VARIABLES, - TAG_CHECK_SOLVER_VARIABLES, - TAG_INIT_SOLVER_AND_MESH, - TAG_CHECK_SOLVER_AND_MESH + SOLUTION_AND_MESH }; /*! diff --git a/SU2_CFD/include/output/CFlowOutput.hpp b/SU2_CFD/include/output/CFlowOutput.hpp index 6a9984a6f0a9..22362ddf584f 100644 --- a/SU2_CFD/include/output/CFlowOutput.hpp +++ b/SU2_CFD/include/output/CFlowOutput.hpp @@ -44,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/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 826a3a5a4393..fa0e96ddb266 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -246,25 +246,26 @@ void CDiscAdjMultizoneDriver::TapeTest() { /*--- This recording will assign the initial (same) tag to each registered variable. * During the recording, each dependent variable will be assigned the same tag. ---*/ + AD::SetTag(1); if(driver_config->GetAD_CheckTapeType() == CHECK_TAPE_TYPE::OBJECTIVE_FUNCTION) { if(driver_config->GetAD_CheckTapeVariables() == CHECK_TAPE_VARIABLES::MESH_COORDINATES) { - if (rank == MASTER_NODE) cout << "\nChecking OBJECTIVE_FUNCTION_TAPE for SOLVER_VARIABLES_AND_MESH_COORDINATES." << endl; - SetRecording(RECORDING::TAG_INIT_SOLVER_AND_MESH, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); + if (rank == MASTER_NODE) cout << "\nChecking OBJECTIVE_FUNCTION_TAPE for MESH_COORDINATES." << endl; + SetRecording(RECORDING::MESH_COORDS, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); } else { - if (rank == MASTER_NODE) cout << "\nChecking OBJECTIVE_FUNCTION_TAPE for SOLVER_VARIABLES." << endl; - SetRecording(RECORDING::TAG_INIT_SOLVER_VARIABLES, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); + if (rank == MASTER_NODE) cout << "\nChecking OBJECTIVE_FUNCTION_TAPE for SOLUTION_VARIABLES." << endl; + SetRecording(RECORDING::SOLUTION_VARIABLES, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); } } else { if(driver_config->GetAD_CheckTapeVariables() == CHECK_TAPE_VARIABLES::MESH_COORDINATES) { - if (rank == MASTER_NODE) cout << "\nChecking FULL_SOLVER_TAPE for SOLVER_VARIABLES_AND_MESH_COORDINATES." << endl; - SetRecording(RECORDING::TAG_INIT_SOLVER_AND_MESH, Kind_Tape::FULL_SOLVER_TAPE, ZONE_0); + if (rank == MASTER_NODE) cout << "\nChecking FULL_SOLVER_TAPE for MESH_COORDINATES." << endl; + SetRecording(RECORDING::MESH_COORDS, Kind_Tape::FULL_SOLVER_TAPE, ZONE_0); } else { - if (rank == MASTER_NODE) cout << "\nChecking FULL_SOLVER_TAPE for SOLVER_VARIABLES." << endl; - SetRecording(RECORDING::TAG_INIT_SOLVER_VARIABLES, Kind_Tape::FULL_SOLVER_TAPE, ZONE_0); + if (rank == MASTER_NODE) cout << "\nChecking FULL_SOLVER_TAPE for SOLUTION_VARIABLES." << endl; + SetRecording(RECORDING::SOLUTION_VARIABLES, Kind_Tape::FULL_SOLVER_TAPE, ZONE_0); } } total_errors = TapeTestGatherErrors(error_report); @@ -277,18 +278,19 @@ void CDiscAdjMultizoneDriver::TapeTest() { * from the initial recording and a mismatch with the "check" recording tag will throw an error. * In such a case, a possible reason could be that such a variable is set by a post-processing routine while * for a mathematically correct recording this dependency must be included earlier. ---*/ + AD::SetTag(2); if(driver_config->GetAD_CheckTapeType() == CHECK_TAPE_TYPE::OBJECTIVE_FUNCTION) { if(driver_config->GetAD_CheckTapeVariables() == CHECK_TAPE_VARIABLES::MESH_COORDINATES) - SetRecording(RECORDING::TAG_CHECK_SOLVER_AND_MESH, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); + SetRecording(RECORDING::MESH_COORDS, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); else - SetRecording(RECORDING::TAG_CHECK_SOLVER_VARIABLES, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); + SetRecording(RECORDING::SOLUTION_VARIABLES, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); } else { if(driver_config->GetAD_CheckTapeVariables() == CHECK_TAPE_VARIABLES::MESH_COORDINATES) - SetRecording(RECORDING::TAG_CHECK_SOLVER_AND_MESH, Kind_Tape::FULL_SOLVER_TAPE, ZONE_0); + SetRecording(RECORDING::MESH_COORDS, Kind_Tape::FULL_SOLVER_TAPE, ZONE_0); else - SetRecording(RECORDING::TAG_CHECK_SOLVER_VARIABLES, Kind_Tape::FULL_SOLVER_TAPE, ZONE_0); + SetRecording(RECORDING::SOLUTION_VARIABLES, Kind_Tape::FULL_SOLVER_TAPE, ZONE_0); } total_errors += TapeTestGatherErrors(error_report); @@ -706,10 +708,6 @@ void CDiscAdjMultizoneDriver::SetRecording(RECORDING kind_recording, Kind_Tape t case RECORDING::CLEAR_INDICES: cout << "Clearing the computational graph." << endl; break; case RECORDING::MESH_COORDS: cout << "Storing computational graph wrt MESH COORDINATES." << endl; break; case RECORDING::SOLUTION_VARIABLES: cout << "Storing computational graph wrt CONSERVATIVE VARIABLES." << endl; break; - case RECORDING::TAG_INIT_SOLVER_VARIABLES: cout << "Simulating recording with tag 1 on conservative variables." << endl; AD::SetTag(1); break; - case RECORDING::TAG_CHECK_SOLVER_VARIABLES: cout << "Checking first recording with tag 2 on conservative variables." << endl; AD::SetTag(2); break; - case RECORDING::TAG_INIT_SOLVER_AND_MESH: cout << "Simulating recording with tag 1 on conservative variables and mesh coordinates." << endl; AD::SetTag(1); break; - case RECORDING::TAG_CHECK_SOLVER_AND_MESH: cout << "Checking first recording with tag 2 on conservative variables and mesh coordinates." << endl; AD::SetTag(2); break; default: break; } } @@ -872,10 +870,7 @@ void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) { AD::RegisterOutput(ObjFunc); AD::SetIndex(ObjFunc_Index, ObjFunc); if (kind_recording == RECORDING::SOLUTION_VARIABLES || - kind_recording == RECORDING::TAG_INIT_SOLVER_VARIABLES || - kind_recording == RECORDING::TAG_CHECK_SOLVER_VARIABLES || - kind_recording == RECORDING::TAG_INIT_SOLVER_AND_MESH || - kind_recording == RECORDING::TAG_CHECK_SOLVER_AND_MESH) { + kind_recording == RECORDING::MESH_COORDS) { cout << " Objective function : " << ObjFunc << endl; } } diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index d55baeb40e76..4102b7333105 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -405,12 +405,15 @@ void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** ge SU2_OMP_PARALLEL_(if(solvers0[ADJFLOW_SOL]->GetHasHybridParallel())) { + bool AD_debug_mesh_coordinates = false; + if (config[iZone]->GetAD_CheckTapeVariables() == CHECK_TAPE_VARIABLES::MESH_COORDINATES) { + cout << "Register additional SOLUTION VARIABLES for tag debug mode (zone " << iZone << ")." << endl; + AD_debug_mesh_coordinates = true; + } + if (kind_recording == RECORDING::SOLUTION_VARIABLES || - kind_recording == RECORDING::TAG_INIT_SOLVER_VARIABLES || - kind_recording == RECORDING::TAG_CHECK_SOLVER_VARIABLES || - kind_recording == RECORDING::TAG_INIT_SOLVER_AND_MESH || - kind_recording == RECORDING::TAG_CHECK_SOLVER_AND_MESH || - kind_recording == RECORDING::SOLUTION_AND_MESH) { + kind_recording == RECORDING::SOLUTION_AND_MESH || + AD_debug_mesh_coordinates) { /*--- Register flow and turbulent variables as input ---*/ @@ -441,9 +444,7 @@ void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** ge } if (kind_recording == RECORDING::MESH_COORDS || - kind_recording == RECORDING::SOLUTION_AND_MESH || - kind_recording == RECORDING::TAG_INIT_SOLVER_AND_MESH || - kind_recording == RECORDING::TAG_CHECK_SOLVER_AND_MESH) { + kind_recording == RECORDING::SOLUTION_AND_MESH) { /*--- Register node coordinates as input ---*/ geometry0->RegisterCoordinates(); @@ -469,9 +470,7 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** if ((kind_recording == RECORDING::MESH_COORDS) || (kind_recording == RECORDING::CLEAR_INDICES) || - (kind_recording == RECORDING::SOLUTION_AND_MESH) || - (kind_recording == RECORDING::TAG_INIT_SOLVER_AND_MESH) || - (kind_recording == RECORDING::TAG_CHECK_SOLVER_AND_MESH)) { + (kind_recording == RECORDING::SOLUTION_AND_MESH)) { /*--- Update geometry to get the influence on other geometry variables (normals, volume etc) ---*/ SU2_OMP_PARALLEL From db1d77ada5ed3d3718a4665c4c8c34d6dbd925f1 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 6 Mar 2026 22:55:21 +0000 Subject: [PATCH 57/79] Clean tape for cross-zone geometry --- Common/include/geometry/CGeometry.hpp | 2 +- Common/src/geometry/CGeometry.cpp | 7 ++++++- Common/src/geometry/CPhysicalGeometry.cpp | 1 - .../src/iteration/CDiscAdjFluidIteration.cpp | 6 +----- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 18 ------------------ 5 files changed, 8 insertions(+), 26 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index c9afec0e46c5..4a452936f99f 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1862,7 +1862,7 @@ class CGeometry { * \param[in] config_container - Definition of the particular problem. * \param[in] geometry_container - Geometrical definition of the problem. */ - static void ComputeWallDistance(const CConfig* const* config_container, CGeometry**** geometry_container); + static void ComputeWallDistance(const CConfig* const* config_container, CGeometry**** geometry_container, const int record_zone = -1); /*! * \brief Set the amount of nonconvex elements in the mesh. diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 770c68f6066a..f5783efe37e6 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -4153,7 +4153,7 @@ su2double NearestNeighborDistance(CGeometry* geometry, const CConfig* config, co } } // namespace -void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeometry**** geometry_container) { +void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeometry**** geometry_container, const int record_zone) { int nZone = config_container[ZONE_0]->GetnZone(); bool allEmpty = true; vector wallDistanceNeeded(nZone, false); @@ -4221,6 +4221,11 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo } for (int iZone = 0; iZone < nZone; iZone++) { + /*--- When recording for a specific zone, only compute nearest-neighbor distances (which read vertex + * normals) for that zone. Reading normals from other zones at this tape position would create + * cross-zone AD dependencies before those zones have had their geometry updated. ---*/ + if (record_zone >= 0 && iZone != record_zone) continue; + /*--- For the FEM solver, we use a different mesh structure ---*/ MAIN_SOLVER kindSolver = config_container[iZone]->GetKind_Solver(); if (!wallDistanceNeeded[iZone] || kindSolver == MAIN_SOLVER::FEM_LES || kindSolver == MAIN_SOLVER::FEM_RANS) { diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index ba8f51a9d975..26aecb8b9bfd 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -10550,7 +10550,6 @@ void CPhysicalGeometry::SetWallDistance(CADTElemClass* WallADT, const CConfig* c if (!WallADT->IsEmpty()) { /*--- Solid wall boundary nodes are present. Compute the wall distance for all nodes. ---*/ - SU2_OMP_PARALLEL { CPHYSGEO_PARFOR for (unsigned long iPoint = 0; iPoint < GetnPoint(); ++iPoint) { diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 4102b7333105..f6c4933b35e4 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -426,10 +426,6 @@ void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** ge if (turbulent && !config[iZone]->GetFrozen_Visc_Disc()) { solvers0[ADJTURB_SOL]->RegisterSolution(geometry0, config[iZone]); } - if (config[iZone]->GetBoolTurbomachinery()) { - geometry0->RegisterCoordinates(); - solvers0[ADJFLOW_SOL]->Register_VertexNormals(geometry0, config[iZone], true); - } if (config[iZone]->GetKind_Species_Model() != SPECIES_MODEL::NONE) { solvers0[ADJSPECIES_SOL]->RegisterSolution(geometry0, config[iZone]); } @@ -477,7 +473,7 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** CGeometry::UpdateGeometry(geometry[iZone][iInst], config[iZone]); END_SU2_OMP_PARALLEL - CGeometry::ComputeWallDistance(config, geometry); + CGeometry::ComputeWallDistance(config, geometry, iZone); } SU2_OMP_PARALLEL_(if(solvers0[ADJFLOW_SOL]->GetHasHybridParallel())) { diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 810fbf9d620d..b1e165717462 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -304,24 +304,6 @@ void CDiscAdjSolver::RegisterOutput(CGeometry *geometry, CConfig *config) { direct_solver->RegisterSolutionExtra(false, config); } -void CDiscAdjSolver::Register_VertexNormals(CGeometry *geometry, CConfig *config, bool input) { - // Only need vertex normals for boundaries declared as turbomachinery markers? - - for (auto iMarker=0ul; iMarker < nMarker; iMarker++) { - for (auto iMarkerTP = 1; iMarkerTP < config->GetnMarker_Turbomachinery() + 1; iMarkerTP++) { - if (config->GetMarker_All_Turbomachinery(iMarker) == iMarkerTP) { - for (auto iVertex = 0ul; iVertex < geometry->GetnVertex(iMarker); iVertex++) { - const auto Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - for (auto iDim = 0u; iDim < nDim; iDim++) { - if (input) AD::RegisterInput(Normal[iDim]); - else AD::RegisterOutput(Normal[iDim]); - } - } - } - } - } -} - void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm) { const bool time_n1_needed = config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND; From 7033568951a9e94c8a9d1e5b2d2fc53a0ecf0e39 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 10 Mar 2026 21:35:35 +0000 Subject: [PATCH 58/79] Generic interface for turbomachinery objectives, remove unused functions --- SU2_CFD/include/output/CTurboOutput.hpp | 14 +++++++++ SU2_CFD/include/solvers/CDiscAdjSolver.hpp | 9 ------ SU2_CFD/include/solvers/CEulerSolver.hpp | 33 ---------------------- SU2_CFD/include/solvers/CSolver.hpp | 12 -------- SU2_CFD/src/output/CTurboOutput.cpp | 16 +++++++++++ SU2_CFD/src/solvers/CEulerSolver.cpp | 23 ++++++--------- 6 files changed, 38 insertions(+), 69 deletions(-) diff --git a/SU2_CFD/include/output/CTurboOutput.hpp b/SU2_CFD/include/output/CTurboOutput.hpp index 099598b2bf4e..6a25745590d8 100644 --- a/SU2_CFD/include/output/CTurboOutput.hpp +++ b/SU2_CFD/include/output/CTurboOutput.hpp @@ -264,4 +264,18 @@ class CTurboOutput { const vector>& GetBladesPerformances() const { return BladesPerformances; } void ComputeTurbomachineryPerformance(vector const primitives, unsigned short iBladeRow); + + /*! + * \brief Returns true if the given objective function kind is a turbomachinery objective + * that can be evaluated via GetObjectiveValue. + * \param[in] kind - Objective function kind (ENUM_OBJECTIVE value). + */ + static bool IsTurboObjective(unsigned short kind); + + /*! + * \brief Get the value of a turbomachinery objective function from the tip span performance. + * \param[in] kind - Objective function kind (ENUM_OBJECTIVE value). + * \return The objective function value, or 0.0 for unrecognised kinds. + */ + su2double GetObjectiveValue(unsigned short kind) const; }; \ No newline at end of file diff --git a/SU2_CFD/include/solvers/CDiscAdjSolver.hpp b/SU2_CFD/include/solvers/CDiscAdjSolver.hpp index 9418602ff7f8..5d0ae10580c5 100644 --- a/SU2_CFD/include/solvers/CDiscAdjSolver.hpp +++ b/SU2_CFD/include/solvers/CDiscAdjSolver.hpp @@ -106,15 +106,6 @@ class CDiscAdjSolver final : public CSolver { */ void RegisterOutput(CGeometry *geometry, CConfig *config) override; - /*! - * \brief performs the preprocessing of the adjoint AD-based solver. - * Registers the normals at turbomachinery boundaries of interest on the tape - * Called while tape is active. - * \param[in] geometry - the geometrical definition of the problem - * \param[in] config - the particular config - */ - void Register_VertexNormals(CGeometry *geometry, CConfig *config, bool input) override; - /*! * \brief Sets the adjoint values of the output of the flow (+turb.) iteration * before evaluation of the tape. diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index cb2ab57a1a46..e271e0e1ed36 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -156,10 +156,6 @@ class CEulerSolver : public CFVMFlowSolverBase > > CkInflow, CkOutflow1, CkOutflow2; - su2double EntropyGeneration; - su2double TotalPressureLoss; - su2double KineticEnergyLoss; - /*--- End of Turbomachinery Solver Variables ---*/ vector> MixingState; // vector of vector of pointers... inner dim alloc'd elsewhere (welcome, to the night zone) @@ -1226,35 +1222,6 @@ class CEulerSolver : public CFVMFlowSolverBase GetTurboBladePerformance() const final { return TurbomachineryPerformance; } /*! diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 7e68a7aa24ed..ef3ab4d4f80d 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -1111,10 +1111,6 @@ class CSolver { CConfig *config, unsigned short val_marker) { } - inline virtual void SetTurboObjectiveFunction(short unsigned int ObjFunc, su2double val) { } - - inline virtual su2double GetTurboObjectiveFunction(short unsigned int ObjFunc, int bladeRow) const { return 0.0; } - inline virtual std::shared_ptr GetTurboBladePerformance() const { return std::shared_ptr(nullptr); } /*! @@ -3599,14 +3595,6 @@ class CSolver { */ inline virtual void RegisterOutput(CGeometry *geometry_container, CConfig *config) { } - /*! - * \brief A vritual member - * \param[in] geometry - the geometrical definition of the problem - * \param[in] config - the particular config - * \param[in] input - Boolean whether In- or Output should be registered - */ - inline virtual void Register_VertexNormals(CGeometry *geometry, CConfig *config, bool input) { }; - /*! * \brief A virtual member. * \param[in] geometry - The geometrical definition of the problem. diff --git a/SU2_CFD/src/output/CTurboOutput.cpp b/SU2_CFD/src/output/CTurboOutput.cpp index ca13ee5d4c31..7da13db0fcb9 100644 --- a/SU2_CFD/src/output/CTurboOutput.cpp +++ b/SU2_CFD/src/output/CTurboOutput.cpp @@ -213,6 +213,22 @@ void CTurboOutput::ComputePerSpan(shared_ptr co spanPerformances->ComputePerformance(spanPrimitives); } +bool CTurboOutput::IsTurboObjective(unsigned short kind) { + return kind == ENTROPY_GENERATION || kind == TOTAL_PRESSURE_LOSS || kind == KINETIC_ENERGY_LOSS; +} + +su2double CTurboOutput::GetObjectiveValue(unsigned short kind) const { + /*--- Use the tip-span (last element) performance, consistent with how ComputeTurboBladePerformance + * selects the representative blade performance for objective function evaluation. ---*/ + const auto& perf = BladesPerformances.back(); + switch (kind) { + case ENTROPY_GENERATION: return perf->GetEntropyGen(); + case TOTAL_PRESSURE_LOSS: return perf->GetTotalPressureLoss(); + case KINETIC_ENERGY_LOSS: return perf->GetKineticEnergyLoss(); + default: return 0.0; + } +} + CTurbomachineryStagePerformance::CTurbomachineryStagePerformance(CFluidModel& fluid) : fluidModel(fluid) {} void CTurbomachineryStagePerformance::ComputePerformanceStage(const CTurbomachineryState& InState, diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 74122c092261..a94c5e3ca005 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4784,6 +4784,10 @@ void CEulerSolver::Evaluate_ObjFunc(const CConfig *config, CSolver**) { Weight_ObjFunc = config->GetWeight_ObjFunc(0); Kind_ObjFunc = config->GetKind_ObjFunc(0); + /*--- Turbomachinery specific objective functions ---*/ + if (TurbomachineryPerformance && CTurboOutput::IsTurboObjective(Kind_ObjFunc)) + Total_ComboObj += Weight_ObjFunc * TurbomachineryPerformance->GetObjectiveValue(Kind_ObjFunc); + switch(Kind_ObjFunc) { case NEARFIELD_PRESSURE: Total_ComboObj+=Weight_ObjFunc*Total_CNearFieldOF; @@ -4791,9 +4795,6 @@ void CEulerSolver::Evaluate_ObjFunc(const CConfig *config, CSolver**) { case SURFACE_MACH: Total_ComboObj+=Weight_ObjFunc*config->GetSurface_Mach(0); break; - case ENTROPY_GENERATION: - Total_ComboObj+=Weight_ObjFunc*EntropyGeneration; - break; default: break; } @@ -9650,27 +9651,19 @@ void CEulerSolver::GatherInOutAverageValues(CConfig *config, CGeometry *geometry } void CEulerSolver::ComputeTurboBladePerformance(CGeometry* geometry, CConfig* config, unsigned short iBlade) { - // Computes the turboperformance per blade in zone iBlade + // Computes the turboperformance per blade in zone iBlade and stores the results in TurbomachineryPerformance. const auto nDim = geometry->GetnDim(); vector TurboPrimitiveIn, TurboPrimitiveOut; if (rank == MASTER_NODE) { - /* Blade Primitive initialized per blade */ std::vector bladePrimitives; auto nSpan = config->GetnSpanWiseSections(); for (auto iSpan = 0; iSpan < nSpan + 1; iSpan++) { - TurboPrimitiveIn= GetTurboPrimitive(iBlade, iSpan, true); - TurboPrimitiveOut= GetTurboPrimitive(iBlade, iSpan, false); + TurboPrimitiveIn = GetTurboPrimitive(iBlade, iSpan, true); + TurboPrimitiveOut = GetTurboPrimitive(iBlade, iSpan, false); auto spanInletPrimitive = CTurbomachineryPrimitiveState(TurboPrimitiveIn, nDim, GetTangGridVelIn(iBlade, iSpan)); auto spanOutletPrimitive = CTurbomachineryPrimitiveState(TurboPrimitiveOut, nDim, GetTangGridVelOut(iBlade, iSpan)); - auto spanCombinedPrimitive = CTurbomachineryCombinedPrimitiveStates(spanInletPrimitive, spanOutletPrimitive); - bladePrimitives.push_back(spanCombinedPrimitive); + bladePrimitives.push_back(CTurbomachineryCombinedPrimitiveStates(spanInletPrimitive, spanOutletPrimitive)); } TurbomachineryPerformance->ComputeTurbomachineryPerformance(bladePrimitives, iBlade); - - auto BladePerf = TurbomachineryPerformance->GetBladesPerformances().at(nSpan); - - EntropyGeneration = BladePerf->GetEntropyGen(); - TotalPressureLoss = BladePerf->GetTotalPressureLoss(); - KineticEnergyLoss = BladePerf->GetKineticEnergyLoss(); } } \ No newline at end of file From e3b77718f32304adcaa34a58051c392c9e9eeb2f Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 10 Mar 2026 21:50:08 +0000 Subject: [PATCH 59/79] Remove unused functions --- SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index fa0e96ddb266..3d0415a9ccd7 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -837,9 +837,6 @@ void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) { } if(config->GetBoolTurbomachinery()){ - solvers[FLOW_SOL]->TurboAverageProcess(solvers, geometry, config, INFLOW); - solvers[FLOW_SOL]->TurboAverageProcess(solvers, geometry, config, OUTFLOW); - /*--- Gather Inflow and Outflow quantities on the Master Node to compute performance ---*/ solvers[FLOW_SOL]->GatherInOutAverageValues(config, geometry); solvers[FLOW_SOL]->ComputeTurboBladePerformance(geometry, config, iZone); From 7d5dd952eb8a9c067d43733050f5495acec3a3ad Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 10 Mar 2026 22:04:48 +0000 Subject: [PATCH 60/79] Formatting of new methods --- Common/include/CConfig.hpp | 2 +- Common/include/geometry/CGeometry.hpp | 3 +- .../interface_interpolation/CInterpolator.hpp | 10 +- .../interface_interpolation/CMixingPlane.hpp | 25 +- Common/src/geometry/CGeometry.cpp | 3 +- Common/src/geometry/CPhysicalGeometry.cpp | 1 - .../CInterpolatorFactory.cpp | 8 +- .../interface_interpolation/CMixingPlane.cpp | 436 +++++++++--------- 8 files changed, 242 insertions(+), 246 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 71309f65c271..a486c90a5145 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -8238,7 +8238,7 @@ class CConfig { * \param[in] val_surface_species_variance - Value of the species variance. */ void SetSurface_Species_Variance(unsigned short val_marker, su2double val_surface_species_variance) { Surface_Species_Variance[val_marker] = val_surface_species_variance; } - + /*! * \brief Set entropy generation for a turbomachinery zone * \param[in] val_iZone - zone index diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 4a452936f99f..d6353da7f7d8 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1862,7 +1862,8 @@ class CGeometry { * \param[in] config_container - Definition of the particular problem. * \param[in] geometry_container - Geometrical definition of the problem. */ - static void ComputeWallDistance(const CConfig* const* config_container, CGeometry**** geometry_container, const int record_zone = -1); + static void ComputeWallDistance(const CConfig* const* config_container, CGeometry**** geometry_container, + const int record_zone = -1); /*! * \brief Set the amount of nonconvex elements in the mesh. diff --git a/Common/include/interface_interpolation/CInterpolator.hpp b/Common/include/interface_interpolation/CInterpolator.hpp index 457305a24a27..5f4643c339dd 100644 --- a/Common/include/interface_interpolation/CInterpolator.hpp +++ b/Common/include/interface_interpolation/CInterpolator.hpp @@ -99,13 +99,13 @@ class CInterpolator { coefficient.resize(nDonor); } }; - vector > targetVertices; /*! \brief Donor information per marker per vertex of the target. */ + vector> targetVertices; /*! \brief Donor information per marker per vertex of the target. */ struct CSpanDonorInfo { - unsigned long donorSpan; // Refers to donor span - su2double coefficient; // Refers to coefficient + unsigned long donorSpan; // Refers to donor span + su2double coefficient; // Refers to coefficient }; - vector> targetSpans; // > + vector> targetSpans; // > /*! * \brief Constructor of the class. @@ -141,7 +141,7 @@ class CInterpolator { /*! * \brief Write mixing plane interpolation details to file */ - inline virtual void WriteInterpolationDetails(const string& filename, const CConfig* const* config) {}; + inline virtual void WriteInterpolationDetails(const string& filename, const CConfig* const* config){}; /*! * \brief Check whether an interface should be processed or not, i.e. if it is part of the zones. diff --git a/Common/include/interface_interpolation/CMixingPlane.hpp b/Common/include/interface_interpolation/CMixingPlane.hpp index 4ed028f98ac4..148c6ef0e752 100644 --- a/Common/include/interface_interpolation/CMixingPlane.hpp +++ b/Common/include/interface_interpolation/CMixingPlane.hpp @@ -25,8 +25,8 @@ * License along with SU2. If not, see . */ - #pragma once - #include "CInterpolator.hpp" +#pragma once +#include "CInterpolator.hpp" /*! * \brief Mixing plane interpolation. @@ -35,16 +35,15 @@ * \ingroup Interfaces */ class CMixingPlane final : public CInterpolator { - public: - CMixingPlane(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, - unsigned int jZone); + public: + CMixingPlane(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, unsigned int jZone); - void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override; + void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override; - /*! - * \brief Write interpolation details to file. - * \param[in] filename - Name of output file. - * \param[in] config - Configuration for all zones. - */ - void WriteInterpolationDetails(const string& filename, const CConfig* const* config) override; -}; \ No newline at end of file + /*! + * \brief Write interpolation details to file. + * \param[in] filename - Name of output file. + * \param[in] config - Configuration for all zones. + */ + void WriteInterpolationDetails(const string& filename, const CConfig* const* config) override; +}; diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index f5783efe37e6..fc6a029fa707 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -4153,7 +4153,8 @@ su2double NearestNeighborDistance(CGeometry* geometry, const CConfig* config, co } } // namespace -void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeometry**** geometry_container, const int record_zone) { +void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeometry**** geometry_container, + const int record_zone) { int nZone = config_container[ZONE_0]->GetnZone(); bool allEmpty = true; vector wallDistanceNeeded(nZone, false); diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index 26aecb8b9bfd..73e0a903bd54 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -6326,7 +6326,6 @@ void CPhysicalGeometry::GatherInOutAverageValues(CConfig* config, bool allocate) void CPhysicalGeometry::SetAvgTurboGeoValues(const CConfig* donor_config, CGeometry* donor_geometry, unsigned short donorZone) { - unsigned short iSpan; unsigned short nSpanMaxAllZones = donor_config->GetnSpanMaxAllZones(); diff --git a/Common/src/interface_interpolation/CInterpolatorFactory.cpp b/Common/src/interface_interpolation/CInterpolatorFactory.cpp index 3ea52870343b..34b6aa723fbf 100644 --- a/Common/src/interface_interpolation/CInterpolatorFactory.cpp +++ b/Common/src/interface_interpolation/CInterpolatorFactory.cpp @@ -51,11 +51,11 @@ CInterpolator* CreateInterpolator(CGeometry**** geometry_container, const CConfi if (mixing_plane) { if (verbose) cout << "using a mixing plane interpolation." << endl; interpolator = new CMixingPlane(geometry_container, config, iZone, jZone); - } else { // Really awful thing to do + } else { // Really awful thing to do /*--- Conservative interpolation is not applicable to the sliding - * mesh approach so that case is handled first. Then we either - * return a CMirror if the target requires conservative inter- - * polation, or the type of interpolator defined by "type". ---*/ + * mesh approach so that case is handled first. Then we either + * return a CMirror if the target requires conservative inter- + * polation, or the type of interpolator defined by "type". ---*/ if (type == INTERFACE_INTERPOLATOR::WEIGHTED_AVERAGE) { if (verbose) cout << "using a sliding mesh approach." << endl; diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index 91739f560b53..e17568f37683 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -31,263 +31,259 @@ #include "../../include/toolboxes/geometry_toolbox.hpp" CMixingPlane::CMixingPlane(CGeometry**** geometry_container, const CConfig* const* config, unsigned int iZone, - unsigned int jZone) + unsigned int jZone) : CInterpolator(geometry_container, config, iZone, jZone) { SetTransferCoeff(geometry_container, config); } void CMixingPlane::SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) { - const auto nMarkerInt = config[donorZone]->GetnMarker_MixingPlaneInterface() / 2; - const auto nDim = donor_geometry->GetnDim(); + const auto nMarkerInt = config[donorZone]->GetnMarker_MixingPlaneInterface() / 2; + const auto nDim = donor_geometry->GetnDim(); - const auto donor_config = config[donorZone]; - const auto target_config = config[targetZone]; + const auto donor_config = config[donorZone]; + const auto target_config = config[targetZone]; - const auto donor_geometry = geometry[donorZone][INST_0][MESH_0]; - const auto target_geometry = geometry[targetZone][INST_0][MESH_0]; + const auto donor_geometry = geometry[donorZone][INST_0][MESH_0]; + const auto target_geometry = geometry[targetZone][INST_0][MESH_0]; - //TODO turbo this approach only works if all the turboamchinery marker - // of all zones have the same amount of span wise sections. - //TODO turbo initialization needed for the MPI routine should be place somewhere else. - auto nSpanDonor = donor_config->GetnSpanWiseSections(); - auto nSpanTarget = target_config->GetnSpanWiseSections(); + // TODO turbo this approach only works if all the turboamchinery marker + // of all zones have the same amount of span wise sections. + // TODO turbo initialization needed for the MPI routine should be place somewhere else. + auto nSpanDonor = donor_config->GetnSpanWiseSections(); + auto nSpanTarget = target_config->GetnSpanWiseSections(); - targetSpans.resize(config[donorZone]->GetnMarker_MixingPlaneInterface()); + targetSpans.resize(config[donorZone]->GetnMarker_MixingPlaneInterface()); - /*--- On the donor side ---*/ - for (auto iMarkerInt = 1; iMarkerInt < nMarkerInt + 1; iMarkerInt++){ - int markDonor = -1, markTarget = -1; - short donorFlag = 0, targetFlag = 0; + /*--- On the donor side ---*/ + for (auto iMarkerInt = 1; iMarkerInt < nMarkerInt + 1; iMarkerInt++) { + int markDonor = -1, markTarget = -1; + short donorFlag = 0, targetFlag = 0; - markDonor = donor_config->FindMixingPlaneInterfaceMarker(donor_geometry->GetnMarker(), iMarkerInt); - donorFlag = (markDonor != -1) ? donor_config->GetMarker_All_MixingPlaneInterface(markDonor) : -1; + markDonor = donor_config->FindMixingPlaneInterfaceMarker(donor_geometry->GetnMarker(), iMarkerInt); + donorFlag = (markDonor != -1) ? donor_config->GetMarker_All_MixingPlaneInterface(markDonor) : -1; - markTarget = target_config->FindMixingPlaneInterfaceMarker(target_geometry->GetnMarker(), iMarkerInt); - targetFlag = (markTarget != -1) ? target_config->GetMarker_All_MixingPlaneInterface(markTarget) : -1; + markTarget = target_config->FindMixingPlaneInterfaceMarker(target_geometry->GetnMarker(), iMarkerInt); + targetFlag = (markTarget != -1) ? target_config->GetMarker_All_MixingPlaneInterface(markTarget) : -1; #ifdef HAVE_MPI auto buffMarkerDonor = new int[size]; auto buffDonorFlag = new int[size]; auto buffMarkerTarget = new int[size]; auto buffTargetFlag = new int[size]; - for (int iSize=0; iSizeGetnSpanWiseSections(); - nSpanTarget = target_config->GetnSpanWiseSections(); + nSpanDonor = donor_config->GetnSpanWiseSections(); + nSpanTarget = target_config->GetnSpanWiseSections(); - targetSpans[iMarkerInt].resize(nSpanTarget+1); + targetSpans[iMarkerInt].resize(nSpanTarget + 1); - const auto spanValuesDonor = donor_geometry->GetSpanWiseValue(donorFlag); - const auto spanValuesTarget = target_geometry->GetSpanWiseValue(targetFlag); + const auto spanValuesDonor = donor_geometry->GetSpanWiseValue(donorFlag); + const auto spanValuesTarget = target_geometry->GetSpanWiseValue(targetFlag); - /*--- Interpolation at hub, shroud & 1D values ---*/ - targetSpans[iMarkerInt][0].donorSpan = 0; - targetSpans[iMarkerInt][0].coefficient = 0.0; - if (nDim > 2) { - targetSpans[iMarkerInt][nSpanTarget-1].donorSpan = nSpanDonor-1; - targetSpans[iMarkerInt][nSpanTarget-1].coefficient = 0.0; - } - targetSpans[iMarkerInt][nSpanTarget].donorSpan = nSpanDonor; - targetSpans[iMarkerInt][nSpanTarget].coefficient = 0.0; - - for(auto iSpanTarget = 1; iSpanTarget < nSpanTarget - 1; iSpanTarget++){ - auto &targetSpan = targetSpans[iMarkerInt][iSpanTarget]; - - auto tSpan = 0; // Nearest donor span index - auto kSpan = 0; // Lower bound donor span for interpolation - su2double coeff = 0.0; // Interpolation coefficient - su2double minDist = 10E+06; - - switch(donor_config->GetKind_MixingPlaneInterface()){ - case MATCHING: - targetSpan.donorSpan = iSpanTarget; - targetSpan.coefficient = 0.0; - break; - - case NEAREST_SPAN: - // Find the nearest donor span - for (auto iSpanDonor = 0; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { - const auto dist = abs(spanValuesTarget[iSpanTarget] - spanValuesDonor[iSpanDonor]); - if(dist < minDist){ - minDist = dist; - tSpan = iSpanDonor; - } - } - targetSpan.donorSpan = tSpan; - targetSpan.coefficient = 0.0; - break; - - case LINEAR_INTERPOLATION: - { - bool printWarning = false; - // Check if target span is within donor bound - if (spanValuesTarget[iSpanTarget] <= spanValuesDonor[0]) { - // Below hub - use hub value - targetSpan.donorSpan = 0; - targetSpan.coefficient = 0.0; - printWarning = true; - } - else if (spanValuesTarget[iSpanTarget] >= spanValuesDonor[nSpanDonor - 1]) { - // Above shroud - use shroud value - targetSpan.donorSpan = nSpanDonor - 1; - targetSpan.coefficient = 0.0; - printWarning = true; - } - else { - // Find the donor span interval that brackets the target span - for (auto iSpanDonor = 0; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { - const auto test = abs(spanValuesTarget[iSpanTarget] - spanValuesDonor[iSpanDonor]); - if(test < minDist && spanValuesTarget[iSpanTarget] > spanValuesDonor[iSpanDonor]){ - kSpan = iSpanDonor; - minDist = test; - } - } - // Calculate interpolation coefficient - coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan]) / - (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); - targetSpan.donorSpan = kSpan; - targetSpan.coefficient = coeff; - } - if (printWarning) { - if (rank == MASTER_NODE) { - cout << "Warning! Target spans exist outside the bounds of donor spans! Clamping interpolator..." << endl; - if (spanValuesTarget[iSpanTarget] <= spanValuesDonor[0]) cout << "This is an issue at the hub." << endl; - if (spanValuesTarget[iSpanTarget] >= spanValuesDonor[nSpanDonor - 1]) cout << "This is an issue at the shroud." << endl; - cout << "Setting coeff = 0.0 and transferring endwall value!" << endl; - } - } - break; - } - default: - SU2_MPI::Error("MixingPlane interface option not implemented yet", CURRENT_FUNCTION); - break; + /*--- Interpolation at hub, shroud & 1D values ---*/ + targetSpans[iMarkerInt][0].donorSpan = 0; + targetSpans[iMarkerInt][0].coefficient = 0.0; + if (nDim > 2) { + targetSpans[iMarkerInt][nSpanTarget - 1].donorSpan = nSpanDonor - 1; + targetSpans[iMarkerInt][nSpanTarget - 1].coefficient = 0.0; + } + targetSpans[iMarkerInt][nSpanTarget].donorSpan = nSpanDonor; + targetSpans[iMarkerInt][nSpanTarget].coefficient = 0.0; + + for (auto iSpanTarget = 1; iSpanTarget < nSpanTarget - 1; iSpanTarget++) { + auto& targetSpan = targetSpans[iMarkerInt][iSpanTarget]; + + auto tSpan = 0; // Nearest donor span index + auto kSpan = 0; // Lower bound donor span for interpolation + su2double coeff = 0.0; // Interpolation coefficient + su2double minDist = 10E+06; + + switch (donor_config->GetKind_MixingPlaneInterface()) { + case MATCHING: + targetSpan.donorSpan = iSpanTarget; + targetSpan.coefficient = 0.0; + break; + + case NEAREST_SPAN: + // Find the nearest donor span + for (auto iSpanDonor = 0; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { + const auto dist = abs(spanValuesTarget[iSpanTarget] - spanValuesDonor[iSpanDonor]); + if (dist < minDist) { + minDist = dist; + tSpan = iSpanDonor; + } + } + targetSpan.donorSpan = tSpan; + targetSpan.coefficient = 0.0; + break; + + case LINEAR_INTERPOLATION: { + bool printWarning = false; + // Check if target span is within donor bound + if (spanValuesTarget[iSpanTarget] <= spanValuesDonor[0]) { + // Below hub - use hub value + targetSpan.donorSpan = 0; + targetSpan.coefficient = 0.0; + printWarning = true; + } else if (spanValuesTarget[iSpanTarget] >= spanValuesDonor[nSpanDonor - 1]) { + // Above shroud - use shroud value + targetSpan.donorSpan = nSpanDonor - 1; + targetSpan.coefficient = 0.0; + printWarning = true; + } else { + // Find the donor span interval that brackets the target span + for (auto iSpanDonor = 0; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { + const auto test = abs(spanValuesTarget[iSpanTarget] - spanValuesDonor[iSpanDonor]); + if (test < minDist && spanValuesTarget[iSpanTarget] > spanValuesDonor[iSpanDonor]) { + kSpan = iSpanDonor; + minDist = test; + } + } + // Calculate interpolation coefficient + coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan]) / + (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); + targetSpan.donorSpan = kSpan; + targetSpan.coefficient = coeff; + } + if (printWarning) { + if (rank == MASTER_NODE) { + cout << "Warning! Target spans exist outside the bounds of donor spans! Clamping interpolator..." << endl; + if (spanValuesTarget[iSpanTarget] <= spanValuesDonor[0]) cout << "This is an issue at the hub." << endl; + if (spanValuesTarget[iSpanTarget] >= spanValuesDonor[nSpanDonor - 1]) + cout << "This is an issue at the shroud." << endl; + cout << "Setting coeff = 0.0 and transferring endwall value!" << endl; } + } + break; } + default: + SU2_MPI::Error("MixingPlane interface option not implemented yet", CURRENT_FUNCTION); + break; + } } + } } void CMixingPlane::WriteInterpolationDetails(const std::string& filename, const CConfig* const* config) { - // Only write from master process in MPI - if (rank != MASTER_NODE) return; - - std::ofstream outFile(filename); - - if (!outFile.is_open()) { - cout << "Error: Could not open file " << filename << ". Abandoning interpolator writing..." << endl; - return; - } - - const auto donor_config = config[donorZone]; - const auto nMarkerInt = config[donorZone]->GetnMarker_MixingPlaneInterface() / 2; + // Only write from master process in MPI + if (rank != MASTER_NODE) return; - outFile << "Mixing-Plane Interpolator Details. Donor Zone = " << donorZone << " Target Zone = " << targetZone << ". Interpolation Method = "; - switch(donor_config->GetKind_MixingPlaneInterface()) { - case MATCHING: - outFile << "MATCHING\n"; - break; - case NEAREST_SPAN: - outFile << "NEAREST_SPAN\n"; - break; - case LINEAR_INTERPOLATION: - outFile << "LINEAR_INTERPOLATION\n"; - break; - default: - outFile << "UNKNOWN\n"; + std::ofstream outFile(filename); + + if (!outFile.is_open()) { + cout << "Error: Could not open file " << filename << ". Abandoning interpolator writing..." << endl; + return; + } + + const auto donor_config = config[donorZone]; + const auto nMarkerInt = config[donorZone]->GetnMarker_MixingPlaneInterface() / 2; + + outFile << "Mixing-Plane Interpolator Details. Donor Zone = " << donorZone << " Target Zone = " << targetZone + << ". Interpolation Method = "; + switch (donor_config->GetKind_MixingPlaneInterface()) { + case MATCHING: + outFile << "MATCHING\n"; + break; + case NEAREST_SPAN: + outFile << "NEAREST_SPAN\n"; + break; + case LINEAR_INTERPOLATION: + outFile << "LINEAR_INTERPOLATION\n"; + break; + default: + outFile << "UNKNOWN\n"; + } + outFile << "\n"; + outFile << "===============================================================" << endl; + + // Loop through each marker interface + for (auto iMarkerInt = 0; iMarkerInt < nMarkerInt + 1; iMarkerInt++) { + if (targetSpans[iMarkerInt].empty()) continue; + + outFile << "Marker Interface " << iMarkerInt << "\n"; + outFile << "---------------------\n"; + outFile << "Target Span, Donor Span, Interpolation Coefficient\n"; + + for (size_t iSpanTarget = 0; iSpanTarget < targetSpans[iMarkerInt].size(); iSpanTarget++) { + const auto& targetSpan = targetSpans[iMarkerInt][iSpanTarget]; + outFile << iSpanTarget << ", " << targetSpan.donorSpan << ", " << targetSpan.coefficient << "\n"; } outFile << "\n"; - outFile << "===============================================================" << endl; - - // Loop through each marker interface - for (auto iMarkerInt = 0; iMarkerInt < nMarkerInt + 1; iMarkerInt++) { - if (targetSpans[iMarkerInt].empty()) continue; - - outFile << "Marker Interface " << iMarkerInt << "\n"; - outFile << "---------------------\n"; - outFile << "Target Span, Donor Span, Interpolation Coefficient\n"; - - for (size_t iSpanTarget = 0; iSpanTarget < targetSpans[iMarkerInt].size(); iSpanTarget++) { - const auto& targetSpan = targetSpans[iMarkerInt][iSpanTarget]; - outFile << iSpanTarget << ", " - << targetSpan.donorSpan << ", " - << targetSpan.coefficient << "\n"; - } - outFile << "\n"; + } + + // Optional: Write grouped by donor span + outFile << "\n\nGrouped by Donor Span\n"; + outFile << "=====================\n\n"; + + for (auto iMarkerInt = 0; iMarkerInt < nMarkerInt + 1; iMarkerInt++) { + if (targetSpans[iMarkerInt].empty()) continue; + + outFile << "Marker Interface " << iMarkerInt << "\n"; + outFile << "---------------------\n"; + + // Find max donor span + unsigned long maxDonorSpan = 0; + for (const auto& ts : targetSpans[iMarkerInt]) { + maxDonorSpan = std::max(maxDonorSpan, ts.donorSpan); } - - // Optional: Write grouped by donor span - outFile << "\n\nGrouped by Donor Span\n"; - outFile << "=====================\n\n"; - - for (auto iMarkerInt = 0; iMarkerInt < nMarkerInt + 1; iMarkerInt++) { - if (targetSpans[iMarkerInt].empty()) continue; - - outFile << "Marker Interface " << iMarkerInt << "\n"; - outFile << "---------------------\n"; - - // Find max donor span - unsigned long maxDonorSpan = 0; - for (const auto& ts : targetSpans[iMarkerInt]) { - maxDonorSpan = std::max(maxDonorSpan, ts.donorSpan); - } - - // Group by donor span - for (unsigned long iDonor = 0; iDonor <= maxDonorSpan; iDonor++) { - bool hasTargets = false; - std::ostringstream targets; - - for (size_t iSpanTarget = 0; iSpanTarget < targetSpans[iMarkerInt].size(); iSpanTarget++) { - if (targetSpans[iMarkerInt][iSpanTarget].donorSpan == iDonor) { - if (hasTargets) targets << ", "; - targets << "Target " << iSpanTarget - << " (coeff=" << targetSpans[iMarkerInt][iSpanTarget].coefficient << ")"; - hasTargets = true; - } - } - - if (hasTargets) { - outFile << "Donor Span " << iDonor << ": " << targets.str() << "\n"; - } + + // Group by donor span + for (unsigned long iDonor = 0; iDonor <= maxDonorSpan; iDonor++) { + bool hasTargets = false; + std::ostringstream targets; + + for (size_t iSpanTarget = 0; iSpanTarget < targetSpans[iMarkerInt].size(); iSpanTarget++) { + if (targetSpans[iMarkerInt][iSpanTarget].donorSpan == iDonor) { + if (hasTargets) targets << ", "; + targets << "Target " << iSpanTarget << " (coeff=" << targetSpans[iMarkerInt][iSpanTarget].coefficient << ")"; + hasTargets = true; } - outFile << "\n"; + } + + if (hasTargets) { + outFile << "Donor Span " << iDonor << ": " << targets.str() << "\n"; + } } - - outFile.close(); - cout << "Interpolation details written to " << filename << endl; -} \ No newline at end of file + outFile << "\n"; + } + + outFile.close(); + cout << "Interpolation details written to " << filename << endl; +} From d571714b0f8c2c4b627756923d8d24186cb39e05 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 24 Mar 2026 15:23:29 +0100 Subject: [PATCH 61/79] Fix data race in mixing plane donor communication --- SU2_CFD/src/solvers/CEulerSolver.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index df5400fa8460..9b827f693294 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -6019,7 +6019,7 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain } void CEulerSolver::PreprocessBC_Giles(CGeometry *geometry, CConfig *config, CNumerics *conv_numerics, unsigned short marker_flag) { - /* Implementation of Fuorier Transformations for non-regfelcting BC will come soon */ + /* Implementation of Fourier Transformations for non-reflecting BC will come soon */ su2double cj_inf,cj_out1, cj_out2, Density_i, Pressure_i, *turboNormal, *turboVelocity, *Velocity_i, AverageSoundSpeed; su2double *deltaprim, *cj, TwoPiThetaFreq_Pitch, pitch, theta, deltaTheta; unsigned short iMarker, iSpan, iMarkerTP, iDim; @@ -6306,11 +6306,13 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu default: break; } - ExtAverageDensity = donorAverages[0]; - ExtAveragePressure = donorAverages[1]; - ExtAverageTurboVelocity[0] = donorAverages[2]; - ExtAverageTurboVelocity[1] = donorAverages[3]; - if (nDim == 3) ExtAverageTurboVelocity[2] = donorAverages[4]; + BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS { + ExtAverageDensity = donorAverages[0]; + ExtAveragePressure = donorAverages[1]; + ExtAverageTurboVelocity[0] = donorAverages[2]; + ExtAverageTurboVelocity[1] = donorAverages[3]; + if (nDim == 3) ExtAverageTurboVelocity[2] = donorAverages[4]; + } END_SU2_OMP_SAFE_GLOBAL_ACCESS switch(config->GetKind_Data_Giles(Marker_Tag)){ From 42c18c118ab5f6d334a92ec908e1db69fae91d46 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 24 Mar 2026 15:26:47 +0100 Subject: [PATCH 62/79] Remove OUTPUT_WRT_FREQ option for mz disc adj test --- .../cont_adj_euler/naca0012/inv_NACA0012_discadj_multizone.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/TestCases/cont_adj_euler/naca0012/inv_NACA0012_discadj_multizone.cfg b/TestCases/cont_adj_euler/naca0012/inv_NACA0012_discadj_multizone.cfg index 12ba608c5feb..967c7b49985d 100644 --- a/TestCases/cont_adj_euler/naca0012/inv_NACA0012_discadj_multizone.cfg +++ b/TestCases/cont_adj_euler/naca0012/inv_NACA0012_discadj_multizone.cfg @@ -101,7 +101,6 @@ VOLUME_ADJ_FILENAME= adjoint GRAD_OBJFUNC_FILENAME= of_grad.dat SURFACE_FILENAME= surface_flow SURFACE_ADJ_FILENAME= surface_adjoint -OUTPUT_WRT_FREQ= 250 SCREEN_OUTPUT= (OUTER_ITER, BGS_RES[0]) OUTPUT_FILES=(RESTART_ASCII) From 38604f7d6c610d857c617862f6590d0053a4bb62 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 24 Mar 2026 18:41:31 +0100 Subject: [PATCH 63/79] Update regression workflows --- .github/workflows/regression.yml | 2 +- TestCases/hybrid_regression.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index cb7d6cca23ce..c09b41cc08cf 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -211,7 +211,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:250717-1402 with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t develop -c feature_mz_turbomachinery_adjoint -s ${{matrix.testscript}} - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:250717-1402 with: diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index a2970e2782b9..625a2445ef76 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -564,7 +564,7 @@ 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.167176, 1.598838, -2.928275, 2.573906, -2.526637, 3.017140, 106370.000000, 106370.000000, 5.726800, 64.383000] + axial_stage2D.test_vals = [1.167505, 1.598838, -2.928277, 2.573904, -2.526637, 3.017140, 106370.000000, 106370.000000, 5.726800, 64.383000] test_list.append(axial_stage2D) # 2D transonic stator restart From f0e769847c363488c4a6306738fbc40563d2c7fc Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 25 Mar 2026 16:47:32 +0100 Subject: [PATCH 64/79] Refactor mixing-plane interpolator for conciseness + remove unused vars & functions --- Common/include/CConfig.hpp | 26 ---------- .../interface_interpolation/CInterpolator.hpp | 2 +- .../interface_interpolation/CMixingPlane.hpp | 52 +++++++++++++++++++ Common/src/CConfig.cpp | 13 ----- .../interface_interpolation/CMixingPlane.cpp | 51 ++---------------- 5 files changed, 56 insertions(+), 88 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index e6f5620f7d0a..6d5a68226f8a 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -454,11 +454,6 @@ class CConfig { TURBOMACHINERY_TYPE *Kind_TurboMachinery; su2vector Kind_TurboInterface; - /* Turbomachinery objective functions */ - su2double *EntropyGeneration; - su2double *TotalPressureLoss; - su2double *KineticEnergyLoss; - /* 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. */ @@ -8246,27 +8241,6 @@ class CConfig { */ void SetSurface_Species_Variance(unsigned short val_marker, su2double val_surface_species_variance) { Surface_Species_Variance[val_marker] = val_surface_species_variance; } - /*! - * \brief Set entropy generation for a turbomachinery zone - * \param[in] val_iZone - zone index - * \param[in] val_entropy_generation - value of entropy generation - */ - void SetEntropyGeneration(unsigned short val_iZone, su2double val_entropy_generation) { EntropyGeneration[val_iZone] = val_entropy_generation; } - - /*! - * \brief Get total pressure loss for a turbomachinery zone - * \param[in] val_iZone - zone index - * \param[in] val_total_pressure_loss - value of total pressure loss - */ - void SetTotalPressureLoss(unsigned short val_iZone, su2double val_total_pressure_loss) { TotalPressureLoss[val_iZone] = val_total_pressure_loss; } - - /*! - * \brief Get kinetic energy loss for a turbomachinery zone - * \param[in] val_iZone - zone index - * \param[in] val_kinetic_energy_loss - value of kinetic energy loss - */ - void SetKineticEnergyLoss(unsigned short val_iZone, su2double val_kinetic_energy_loss) { KineticEnergyLoss[val_iZone] = val_kinetic_energy_loss; } - /*! * \brief Get the back pressure (static) at an outlet boundary. * \param[in] val_index - Index corresponding to the outlet boundary. diff --git a/Common/include/interface_interpolation/CInterpolator.hpp b/Common/include/interface_interpolation/CInterpolator.hpp index 5f4643c339dd..a7614fc17cd2 100644 --- a/Common/include/interface_interpolation/CInterpolator.hpp +++ b/Common/include/interface_interpolation/CInterpolator.hpp @@ -102,7 +102,7 @@ class CInterpolator { vector> targetVertices; /*! \brief Donor information per marker per vertex of the target. */ struct CSpanDonorInfo { - unsigned long donorSpan; // Refers to donor span + size_t donorSpan; // Refers to donor span su2double coefficient; // Refers to coefficient }; vector> targetSpans; // > diff --git a/Common/include/interface_interpolation/CMixingPlane.hpp b/Common/include/interface_interpolation/CMixingPlane.hpp index 148c6ef0e752..b7333a8fbf7f 100644 --- a/Common/include/interface_interpolation/CMixingPlane.hpp +++ b/Common/include/interface_interpolation/CMixingPlane.hpp @@ -27,6 +27,7 @@ #pragma once #include "CInterpolator.hpp" +#include "../option_structure.hpp" /*! * \brief Mixing plane interpolation. @@ -40,6 +41,57 @@ class CMixingPlane final : public CInterpolator { void SetTransferCoeff(CGeometry**** geometry, const CConfig* const* config) override; + inline CSpanDonorInfo MapMatchingSpan(unsigned short iSpanTarget) { return {iSpanTarget, 0.0}; } + + inline CSpanDonorInfo MapNearestSpan(const su2double iSpanTargetValue, const su2double* spanValuesDonor, unsigned long nSpanDonor) { + unsigned short tSpan = 0; // Nearest donor span index + auto minDist = std::numeric_limits::max(); + + for (auto iSpanDonor = 0u; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { + const auto dist = abs(iSpanTargetValue - spanValuesDonor[iSpanDonor]); + if (dist < minDist) { + minDist = dist; + tSpan = iSpanDonor; + } + } + return {tSpan, 0.0}; + }; + + inline CSpanDonorInfo MapLinearInterpolationSpan(const su2double iSpanTargetValue, const su2double* spanValuesDonor, unsigned long nSpanDonor, int rank) { + unsigned short kSpan = 0; // Lower bound donor span for interpolation + auto minDist = std::numeric_limits::max(); + su2double coeff = 0.0; // Interpolation coefficient + + if (iSpanTargetValue < spanValuesDonor[0]) { + PrintClampingWarning(rank, true); + return {0, 0.0}; + } + + if (iSpanTargetValue > spanValuesDonor[nSpanDonor - 1]) { + PrintClampingWarning(rank, false); + return {nSpanDonor - 1, 0.0}; + } + + for (auto iSpanDonor = 0u; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { + const auto dist = abs(iSpanTargetValue - spanValuesDonor[iSpanDonor]); + if (dist < minDist && iSpanTargetValue > spanValuesDonor[iSpanDonor]) { + kSpan = iSpanDonor; + minDist = dist; + break; + } + } + coeff = (iSpanTargetValue - spanValuesDonor[kSpan]) / + (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); + return {kSpan, coeff}; + }; + + inline void PrintClampingWarning(int rank, bool atHub) { + if (rank != MASTER_NODE) return; + cout << "Warning! Target spans exist outside the bounds of donor spans! Clamping interpolator..." << endl; + cout << (atHub ? "This is an issue at the hub." : "This is an issue at the shroud.") << endl; + cout << "Setting coeff = 0.0 and transferring endwall value!" << endl; + }; + /*! * \brief Write interpolation details to file. * \param[in] filename - Name of output file. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 0ac5d5ff588d..06e1739ea597 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -1066,11 +1066,6 @@ void CConfig::SetPointersNull() { nBlades = nullptr; FreeStreamTurboNormal = nullptr; - /*--- Turbomachinery Objective Functions ---*/ - EntropyGeneration = nullptr; - TotalPressureLoss = nullptr; - KineticEnergyLoss = nullptr; - top_optim_kernels = nullptr; top_optim_kernel_params = nullptr; top_optim_filter_radius = nullptr; @@ -6227,11 +6222,6 @@ void CConfig::SetMarkers(SU2_COMPONENT val_software) { Marker_CfgFile_ZoneInterface[iMarker_CfgFile] = YES; } - /*--- Allocate memory for turbomachinery objective functions ---*/ - EntropyGeneration = new su2double[nZone] (); - TotalPressureLoss = new su2double[nZone] (); - KineticEnergyLoss = new su2double[nZone] (); - /*--- Identification of Turbomachinery markers and flag them---*/ for (iMarker_CfgFile = 0; iMarker_CfgFile < nMarker_CfgFile; iMarker_CfgFile++) { @@ -8611,9 +8601,6 @@ CConfig::~CConfig() { delete [] nBlades; delete [] FreeStreamTurboNormal; - delete [] EntropyGeneration; - delete [] TotalPressureLoss; - delete [] KineticEnergyLoss; } /*--- Input is the filename base, output is the completed filename. ---*/ diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index e17568f37683..c3fb250fc67f 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -137,60 +137,15 @@ void CMixingPlane::SetTransferCoeff(CGeometry**** geometry, const CConfig* const switch (donor_config->GetKind_MixingPlaneInterface()) { case MATCHING: - targetSpan.donorSpan = iSpanTarget; - targetSpan.coefficient = 0.0; + targetSpan = MapMatchingSpan(iSpanTarget); break; case NEAREST_SPAN: - // Find the nearest donor span - for (auto iSpanDonor = 0; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { - const auto dist = abs(spanValuesTarget[iSpanTarget] - spanValuesDonor[iSpanDonor]); - if (dist < minDist) { - minDist = dist; - tSpan = iSpanDonor; - } - } - targetSpan.donorSpan = tSpan; - targetSpan.coefficient = 0.0; + targetSpan = MapNearestSpan(spanValuesTarget[iSpanTarget], spanValuesDonor, nSpanDonor); break; case LINEAR_INTERPOLATION: { - bool printWarning = false; - // Check if target span is within donor bound - if (spanValuesTarget[iSpanTarget] <= spanValuesDonor[0]) { - // Below hub - use hub value - targetSpan.donorSpan = 0; - targetSpan.coefficient = 0.0; - printWarning = true; - } else if (spanValuesTarget[iSpanTarget] >= spanValuesDonor[nSpanDonor - 1]) { - // Above shroud - use shroud value - targetSpan.donorSpan = nSpanDonor - 1; - targetSpan.coefficient = 0.0; - printWarning = true; - } else { - // Find the donor span interval that brackets the target span - for (auto iSpanDonor = 0; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { - const auto test = abs(spanValuesTarget[iSpanTarget] - spanValuesDonor[iSpanDonor]); - if (test < minDist && spanValuesTarget[iSpanTarget] > spanValuesDonor[iSpanDonor]) { - kSpan = iSpanDonor; - minDist = test; - } - } - // Calculate interpolation coefficient - coeff = (spanValuesTarget[iSpanTarget] - spanValuesDonor[kSpan]) / - (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); - targetSpan.donorSpan = kSpan; - targetSpan.coefficient = coeff; - } - if (printWarning) { - if (rank == MASTER_NODE) { - cout << "Warning! Target spans exist outside the bounds of donor spans! Clamping interpolator..." << endl; - if (spanValuesTarget[iSpanTarget] <= spanValuesDonor[0]) cout << "This is an issue at the hub." << endl; - if (spanValuesTarget[iSpanTarget] >= spanValuesDonor[nSpanDonor - 1]) - cout << "This is an issue at the shroud." << endl; - cout << "Setting coeff = 0.0 and transferring endwall value!" << endl; - } - } + targetSpan = MapLinearInterpolationSpan(spanValuesTarget[iSpanTarget], spanValuesDonor, nSpanDonor, rank); break; } default: From cecebab338c42221948b04703e3ca0eb7504b98d Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 25 Mar 2026 17:27:15 +0100 Subject: [PATCH 65/79] Remove unused vars --- Common/src/interface_interpolation/CMixingPlane.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Common/src/interface_interpolation/CMixingPlane.cpp b/Common/src/interface_interpolation/CMixingPlane.cpp index c3fb250fc67f..d96013c7d26e 100644 --- a/Common/src/interface_interpolation/CMixingPlane.cpp +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -130,11 +130,6 @@ void CMixingPlane::SetTransferCoeff(CGeometry**** geometry, const CConfig* const for (auto iSpanTarget = 1; iSpanTarget < nSpanTarget - 1; iSpanTarget++) { auto& targetSpan = targetSpans[iMarkerInt][iSpanTarget]; - auto tSpan = 0; // Nearest donor span index - auto kSpan = 0; // Lower bound donor span for interpolation - su2double coeff = 0.0; // Interpolation coefficient - su2double minDist = 10E+06; - switch (donor_config->GetKind_MixingPlaneInterface()) { case MATCHING: targetSpan = MapMatchingSpan(iSpanTarget); From 15dda500783f4eca70a883227773e3fe345fb380 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 25 Mar 2026 18:28:49 +0100 Subject: [PATCH 66/79] Changes for comments --- .../interface_interpolation/CInterpolator.hpp | 4 ++-- .../interface_interpolation/CMixingPlane.hpp | 19 +++++++-------- SU2_CFD/include/interfaces/CInterface.hpp | 5 ++-- .../interfaces/cfd/CMixingPlaneInterface.hpp | 6 ++--- SU2_CFD/include/iteration/CIteration.hpp | 14 +++++------ SU2_CFD/include/output/CFlowCompOutput.hpp | 8 +++---- SU2_CFD/include/output/COutput.hpp | 10 ++++---- .../interfaces/cfd/CMixingPlaneInterface.cpp | 23 ++++++++++--------- SU2_CFD/src/iteration/CIteration.cpp | 4 ++-- SU2_CFD/src/output/CFlowCompOutput.cpp | 20 ++++++++-------- SU2_CFD/src/output/COutput.cpp | 2 +- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 6 ++--- 12 files changed, 61 insertions(+), 60 deletions(-) diff --git a/Common/include/interface_interpolation/CInterpolator.hpp b/Common/include/interface_interpolation/CInterpolator.hpp index a7614fc17cd2..91ef8e3796e9 100644 --- a/Common/include/interface_interpolation/CInterpolator.hpp +++ b/Common/include/interface_interpolation/CInterpolator.hpp @@ -102,8 +102,8 @@ class CInterpolator { vector> targetVertices; /*! \brief Donor information per marker per vertex of the target. */ struct CSpanDonorInfo { - size_t donorSpan; // Refers to donor span - su2double coefficient; // Refers to coefficient + size_t donorSpan; // Refers to donor span + su2double coefficient; // Refers to coefficient }; vector> targetSpans; // > diff --git a/Common/include/interface_interpolation/CMixingPlane.hpp b/Common/include/interface_interpolation/CMixingPlane.hpp index b7333a8fbf7f..97dd1259b21d 100644 --- a/Common/include/interface_interpolation/CMixingPlane.hpp +++ b/Common/include/interface_interpolation/CMixingPlane.hpp @@ -43,8 +43,9 @@ class CMixingPlane final : public CInterpolator { inline CSpanDonorInfo MapMatchingSpan(unsigned short iSpanTarget) { return {iSpanTarget, 0.0}; } - inline CSpanDonorInfo MapNearestSpan(const su2double iSpanTargetValue, const su2double* spanValuesDonor, unsigned long nSpanDonor) { - unsigned short tSpan = 0; // Nearest donor span index + inline CSpanDonorInfo MapNearestSpan(const su2double iSpanTargetValue, const su2double* spanValuesDonor, + unsigned long nSpanDonor) { + unsigned short tSpan = 0; // Nearest donor span index auto minDist = std::numeric_limits::max(); for (auto iSpanDonor = 0u; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { @@ -57,16 +58,17 @@ class CMixingPlane final : public CInterpolator { return {tSpan, 0.0}; }; - inline CSpanDonorInfo MapLinearInterpolationSpan(const su2double iSpanTargetValue, const su2double* spanValuesDonor, unsigned long nSpanDonor, int rank) { - unsigned short kSpan = 0; // Lower bound donor span for interpolation + inline CSpanDonorInfo MapLinearInterpolationSpan(const su2double iSpanTargetValue, const su2double* spanValuesDonor, + unsigned long nSpanDonor, int rank) { + unsigned short kSpan = 0; // Lower bound donor span for interpolation auto minDist = std::numeric_limits::max(); su2double coeff = 0.0; // Interpolation coefficient if (iSpanTargetValue < spanValuesDonor[0]) { PrintClampingWarning(rank, true); return {0, 0.0}; - } - + } + if (iSpanTargetValue > spanValuesDonor[nSpanDonor - 1]) { PrintClampingWarning(rank, false); return {nSpanDonor - 1, 0.0}; @@ -80,11 +82,10 @@ class CMixingPlane final : public CInterpolator { break; } } - coeff = (iSpanTargetValue - spanValuesDonor[kSpan]) / - (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); + coeff = (iSpanTargetValue - spanValuesDonor[kSpan]) / (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); return {kSpan, coeff}; }; - + inline void PrintClampingWarning(int rank, bool atHub) { if (rank != MASTER_NODE) return; cout << "Warning! Target spans exist outside the bounds of donor spans! Clamping interpolator..." << endl; diff --git a/SU2_CFD/include/interfaces/CInterface.hpp b/SU2_CFD/include/interfaces/CInterface.hpp index b0797e5df1c9..adc9889a10c2 100644 --- a/SU2_CFD/include/interfaces/CInterface.hpp +++ b/SU2_CFD/include/interfaces/CInterface.hpp @@ -29,6 +29,7 @@ #pragma once #include "../../../Common/include/parallelization/mpi_structure.hpp" +#include "../../../Common/include/containers/C2DContainer.hpp" #include #include @@ -149,9 +150,9 @@ class CInterface { for (auto iVar = 0u; iVar < nVar; iVar++) Target_Variable[iVar] += donorCoeff * bcastVariable[iVar]; } - inline virtual void RecoverTarget_Span_Endwall(const vector &bcastVariable, unsigned long idx) { } + inline virtual void RecoverTarget_Span_Endwall(const su2activevector &bcastVariable, unsigned long idx) { } - inline virtual void RecoverTarget_Span(const vector &bcastVariable, unsigned long idx, su2double donorCoeff) { } + inline virtual void RecoverTarget_Span(const su2activevector &bcastVariable, unsigned long idx, su2double donorCoeff) { } diff --git a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp index 6b3e4e658d14..fa6ad9cdea18 100644 --- a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp +++ b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp @@ -29,7 +29,7 @@ #pragma once #include "../CInterface.hpp" -#include +#include "../../../Common/include/containers/C2DContainer.hpp" /*! * \brief Mixing plane interface for turbomachinery. @@ -93,13 +93,13 @@ class CMixingPlaneInterface : public CInterface { void SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry, const CConfig *target_config, unsigned long Marker_Target, unsigned long val_Span, unsigned long Point_Target) override; - inline void RecoverTarget_Span_Endwall(const vector &bcastVariable, unsigned long iSpan) override { + inline void RecoverTarget_Span_Endwall(const su2activevector &bcastVariable, unsigned long iSpan) override { for (auto iVar = 0u; iVar < nMixingVars; iVar++) { Target_Variable[iVar] = bcastVariable[iSpan * nMixingVars + iVar]; } } - inline void RecoverTarget_Span(const vector &bcastVariable, unsigned long iSpan, su2double donorCoeff) override { + inline void RecoverTarget_Span(const su2activevector &bcastVariable, unsigned long iSpan, su2double donorCoeff) override { for (auto iVar = 0u; iVar < nMixingVars; iVar++) { Target_Variable[iVar] = (1 - donorCoeff)*bcastVariable[iSpan * nMixingVars + iVar] + donorCoeff * bcastVariable[(iSpan + 1) * nMixingVars + iVar]; } diff --git a/SU2_CFD/include/iteration/CIteration.hpp b/SU2_CFD/include/iteration/CIteration.hpp index 56f7e24f279d..ac007143ced3 100644 --- a/SU2_CFD/include/iteration/CIteration.hpp +++ b/SU2_CFD/include/iteration/CIteration.hpp @@ -304,13 +304,11 @@ class CIteration { */ void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid, unsigned short val_iZone); - inline vector> GetBladesPerformanceVector(CSolver***** solver, unsigned short nBladeRow){ - vector> bladePerformances; - bladePerformances.reserve(nBladeRow); - for (auto iBladeRow = 0u; iBladeRow < nBladeRow; iBladeRow++) { - auto const turboPerf = solver[iBladeRow][INST_0][MESH_0][FLOW_SOL]->GetTurboBladePerformance(); - bladePerformances.push_back(turboPerf); + inline su2vector> GetBladesPerformanceVector(CSolver***** solver, unsigned short nBladeRow){ + su2vector> bladePerformances(nBladeRow); + for (auto iBladeRow = 0u; iBladeRow < nBladeRow; iBladeRow++) { + bladePerformances[iBladeRow] = solver[iBladeRow][INST_0][MESH_0][FLOW_SOL]->GetTurboBladePerformance(); + } + return bladePerformances; } - return bladePerformances; - } }; diff --git a/SU2_CFD/include/output/CFlowCompOutput.hpp b/SU2_CFD/include/output/CFlowCompOutput.hpp index 53dcada4d6b4..4582633c0904 100644 --- a/SU2_CFD/include/output/CFlowCompOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompOutput.hpp @@ -105,7 +105,7 @@ class CFlowCompOutput final: public CFlowOutput { * \param[in] OuterIter - Index of current outer iteration * \param[in] InnerIter - Index of current inner iteration */ - void SetTurboPerformance_Output(std::vector> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) override; + void SetTurboPerformance_Output(su2vector> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) override; /*! * \brief Sets the multizone turboperformacne screen output @@ -113,7 +113,7 @@ class CFlowCompOutput final: public CFlowOutput { * \param[in] TurboPerf - Turboperformance class * \param[in] config - Definition of the particular problem */ - void SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, std::vector> TurboBladePerfs, CConfig *config) override; + void SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, su2vector> TurboBladePerfs, CConfig *config) override; /*! * \brief Loads the turboperformacne history data @@ -121,7 +121,7 @@ class CFlowCompOutput final: public CFlowOutput { * \param[in] TurboPerf - Turboperformance class * \param[in] config - Definition of the particular problem */ - void LoadTurboHistoryData(std::shared_ptr TurboStagePerf, std::vector> TurboBladePerfs, CConfig *config) override; + void LoadTurboHistoryData(std::shared_ptr TurboStagePerf, su2vector> TurboBladePerfs, CConfig *config) override; /*! * \brief Write the kinematic and thermodynamic variables at each spanwise division @@ -130,6 +130,6 @@ class CFlowCompOutput final: public CFlowOutput { * \param[in] config - Descripiton of the particular problem * \param[in] val_iZone - Idientifier of current zone */ - void WriteTurboSpanwisePerformance(std::vector> TurboBladePerfs, CGeometry *geometry, CConfig **config, + void WriteTurboSpanwisePerformance(su2vector> TurboBladePerfs, 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 91ebdcd48eb3..37f08bf6faad 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -409,7 +409,7 @@ class COutput { */ void SetHistoryOutput(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, std::shared_ptr TurboStagePerf, - std::vector> TurboBladePerfs, unsigned short val_iZone, + su2vector> TurboBladePerfs, unsigned short val_iZone, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iInst); /*! @@ -980,7 +980,7 @@ class COutput { * \param[in] OuterIter - Index of current outer iteration * \param[in] InnerIter - Index of current inner iteration */ - inline virtual void SetTurboPerformance_Output(std::vector> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) {} + inline virtual void SetTurboPerformance_Output(su2vector> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) {} /*! * \brief Sets the multizone turboperformacne screen output @@ -988,7 +988,7 @@ class COutput { * \param[in] TurboPerf - Turboperformance class * \param[in] config - Definition of the particular problem */ - inline virtual void SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, std::vector> TurboPerf, CConfig *config) {} + inline virtual void SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, su2vector> TurboPerf, CConfig *config) {} /*! * \brief Loads the turboperformacne history data @@ -996,7 +996,7 @@ class COutput { * \param[in] TurboPerf - Turboperformance class * \param[in] config - Definition of the particular problem */ - inline virtual void LoadTurboHistoryData(std::shared_ptr TurboStagePerf, std::vector> TurboPerf, CConfig *config) {} + inline virtual void LoadTurboHistoryData(std::shared_ptr TurboStagePerf, su2vector> TurboPerf, CConfig *config) {} /*! * \brief Write the kinematic and thermodynamic variables at each spanwise division @@ -1005,7 +1005,7 @@ class COutput { * \param[in] config - Descripiton of the particular problem * \param[in] val_iZone - Idientifier of current zone */ - inline virtual void WriteTurboSpanwisePerformance(std::vector> TurboBladePerfs, CGeometry *geometry, CConfig **config, + inline virtual void WriteTurboSpanwisePerformance(su2vector> TurboBladePerfs, CGeometry *geometry, CConfig **config, unsigned short val_iZone) {}; /*! diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 40c0ecbd5fc5..a4c6d626f9eb 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -63,8 +63,8 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter static_assert(su2activematrix::Storage == StorageType::RowMajor,""); /*--- Loop over interface markers. ---*/ - - for (auto iMarkerInt = 1; iMarkerInt < donor_config->GetnMarker_MixingPlaneInterface()/2 + 1; iMarkerInt++) { + const auto nMarkerInt = donor_config->GetnMarker_MixingPlaneInterface() / 2; + for (auto iMarkerInt = 1; iMarkerInt < nMarkerInt + 1; iMarkerInt++) { /*--- Find the markers containing the interface ---*/ short markDonor = donor_config->FindMixingPlaneInterfaceMarker(donor_geometry->GetnMarker(), iMarkerInt); @@ -78,11 +78,12 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter /*--- Fill send buffers. ---*/ - vector sendDonorMarker(nSpanDonor + 1, -1); - vector sendDonorVar(static_cast(nSpanDonor + 1) * nMixingVars); + su2vector sendDonorMarker(nSpanDonor + 1); + sendDonorMarker.setConstant(-1); // Initialize to -1 to identify ranks that do not have the marker + su2activevector sendDonorVar(static_cast(nSpanDonor + 1) * nMixingVars); if (markDonor != -1) { - for (auto iSpan = 0; iSpan < nSpanDonor + 1; iSpan++) { + for (auto iSpan = 0u; iSpan < nSpanDonor + 1; iSpan++) { GetDonor_Variable(donor_solution, donor_geometry, donor_config, markDonor, iSpan, 0); for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = Donor_Variable[iVar]; sendDonorMarker[iSpan] = markDonor; @@ -90,10 +91,10 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter } #ifdef HAVE_MPI /*--- Gather data. ---*/ - const auto nTotalDonors = (nSpanDonor + 1) * size; // Number of donor spans across all ranks - const auto nSpanDonorVars = (nSpanDonor + 1) * nMixingVars; // Number of variables to be transferred on each rank - vector buffDonorMarker(nTotalDonors); - vector buffDonorVar(static_cast(nTotalDonors) * nMixingVars); // Total number of variables to be transferred on all ranks + const size_t nTotalDonors = (nSpanDonor + 1) * size; // Number of donor spans across all ranks + const size_t nSpanDonorVars = (nSpanDonor + 1) * nMixingVars; // Number of variables to be transferred on each rank + su2vector buffDonorMarker(nTotalDonors); + su2activevector buffDonorVar(static_cast(nTotalDonors) * nMixingVars); // Total number of variables to be transferred on all ranks SU2_MPI::Allgather(sendDonorMarker.data(), nSpanDonor + 1, MPI_SHORT, buffDonorMarker.data(), nSpanDonor + 1, MPI_SHORT, @@ -105,8 +106,8 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter for (auto iSize = 0; iSize < size; iSize++){ if (buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor + 1)] != -1) { - for (auto iSpan = 0; iSpan < nSpanDonor + 1; iSpan++){ - for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = buffDonorVar[static_cast(iSize) * nSpanDonorVars + iSpan * nMixingVars + iVar]; + for (size_t iSpan = 0; iSpan < nSpanDonor + 1; iSpan++){ + for (size_t iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = buffDonorVar[static_cast(iSize) * nSpanDonorVars + iSpan * nMixingVars + iVar]; } markDonor = buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor + 1)]; break; // Avoid overwriting diff --git a/SU2_CFD/src/iteration/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index dcc4cf1f2583..061d0c7d2070 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -222,9 +222,9 @@ void CIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geom auto TurbomachineryBladePerformances = GetBladesPerformanceVector(solver, nZone); auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); - auto InState = TurbomachineryBladePerformances.at(ZONE_0)->GetBladesPerformances().at(nSpan)->GetInletState(); + auto InState = TurbomachineryBladePerformances[ZONE_0]->GetBladesPerformances().at(nSpan)->GetInletState(); nSpan = config_container[nZone-1]->GetnSpanWiseSections(); - auto OutState = TurbomachineryBladePerformances.at(nZone-1)->GetBladesPerformances().at(nSpan)->GetOutletState(); + auto OutState = TurbomachineryBladePerformances[nZone-1]->GetBladesPerformances().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 61db95a3d085..df3e23991350 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -511,7 +511,7 @@ bool CFlowCompOutput::WriteHistoryFileOutput(const CConfig *config) { return !config->GetFinite_Difference_Mode() && COutput::WriteHistoryFileOutput(config); } -void CFlowCompOutput::SetTurboPerformance_Output(std::vector> TurboBladePerfs, +void CFlowCompOutput::SetTurboPerformance_Output(su2vector> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, @@ -535,7 +535,7 @@ void CFlowCompOutput::SetTurboPerformance_Output(std::vectorGetnZone()-1; iZone++) { auto nSpan = config->GetnSpan_iZones(iZone); - const auto& BladePerf = TurboBladePerfs.at(iZone)->GetBladesPerformances().at(nSpan); + const auto& BladePerf = TurboBladePerfs[iZone]->GetBladesPerformances().at(nSpan); TurboInOut<<" BLADE ROW INDEX "< TurboStagePerf, std::vector> TurboPerf, CConfig *config) { +void CFlowCompOutput::SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, su2vector> TurboPerf, CConfig *config) { stringstream TurboMZPerf; @@ -586,10 +586,10 @@ void CFlowCompOutput::SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, std::vector> TurboBladePerfs, CConfig *config) { +void CFlowCompOutput::LoadTurboHistoryData(std::shared_ptr TurboStagePerf, su2vector> TurboBladePerfs, CConfig *config) { for (unsigned short iZone = 0; iZone <= config->GetnZone()-1; iZone++) { auto nSpan = config->GetnSpan_iZones(iZone); - const auto& BladePerf = TurboBladePerfs.at(iZone)->GetBladesPerformances().at(nSpan); + const auto& BladePerf = TurboBladePerfs[iZone]->GetBladesPerformances().at(nSpan); stringstream tag; tag << iZone + 1; @@ -633,7 +633,7 @@ void CFlowCompOutput::LoadTurboHistoryData(std::shared_ptrGetTotalPressureLoss()); } -void CFlowCompOutput::WriteTurboSpanwisePerformance(std::vector> TurboBladePerfs, CGeometry *geometry, CConfig **config, unsigned short val_iZone) { +void CFlowCompOutput::WriteTurboSpanwisePerformance(su2vector> TurboBladePerfs, CGeometry *geometry, CConfig **config, unsigned short val_iZone) { string inMarker_Tag, outMarker_Tag, inMarkerTag_Mix; unsigned short nZone = config[val_iZone]->GetnZone(); @@ -676,7 +676,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::vectorGetnSpanWiseSections(); iSpan++){ - const auto& BladePerf = TurboBladePerfs.at(val_iZone)->GetBladesPerformances().at(iSpan); + const auto& BladePerf = TurboBladePerfs[val_iZone]->GetBladesPerformances().at(iSpan); file.width(30); file << SpanWiseValuesIn[iSpan]; file.width(15); file << iSpan; @@ -721,7 +721,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::vectorGetnSpanWiseSections(); iSpan++){ - const auto& BladePerf = TurboBladePerfs.at(val_iZone)->GetBladesPerformances().at(iSpan); + const auto& BladePerf = TurboBladePerfs[val_iZone]->GetBladesPerformances().at(iSpan); file.width(30); file << SpanWiseValuesOut[iSpan]; file.width(15); file << iSpan; @@ -772,7 +772,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::vectorGetnSpanWiseSections(); iSpan++){ - const auto& BladePerf = TurboBladePerfs.at(val_iZone)->GetBladesPerformances().at(iSpan); + const auto& BladePerf = TurboBladePerfs[val_iZone]->GetBladesPerformances().at(iSpan); file.width(30); file << SpanWiseValuesIn[iSpan]; file.width(15); file << iSpan; @@ -836,7 +836,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::vectorGetnSpanWiseSections(); iSpan++){ - const auto& BladePerf = TurboBladePerfs.at(val_iZone)->GetBladesPerformances().at(iSpan); + const auto& BladePerf = TurboBladePerfs[val_iZone]->GetBladesPerformances().at(iSpan); file.width(30); file << SpanWiseValuesOut[iSpan]; file.width(15); file << iSpan; diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 3021df0848ca..4de3f0dc1906 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -229,7 +229,7 @@ void COutput::SetHistoryOutput(CGeometry *geometry, } -void COutput::SetHistoryOutput(CGeometry ****geometry, CSolver *****solver, CConfig **config, std::shared_ptr(TurboStagePerf), std::vector> TurboBladePerfs, 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, std::shared_ptr(TurboStagePerf), su2vector> TurboBladePerfs, unsigned short val_iZone, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iInst){ unsigned long Iter= InnerIter; diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index b1e165717462..5f6d8beecac9 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -221,14 +221,14 @@ void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, boo if ((config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE) && (KindDirect_Solver == RUNTIME_FLOW_SYS) && config->GetBoolTurbomachinery()){ + BPressure = config->GetPressureOut_BC(); + Temperature = config->GetTotalTemperatureIn_BC(); + if (!reset){ AD::RegisterInput(BPressure); AD::RegisterInput(Temperature); } - BPressure = config->GetPressureOut_BC(); - Temperature = config->GetTotalTemperatureIn_BC(); - config->SetPressureOut_BC(BPressure); config->SetTotalTemperatureIn_BC(Temperature); } From 07e5e3f61946b1f5167ffb9831e198955912fbc0 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 26 Mar 2026 13:21:05 +0100 Subject: [PATCH 67/79] Integral promotion sign correction --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index a4c6d626f9eb..830a0bcf33d7 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -83,7 +83,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter su2activevector sendDonorVar(static_cast(nSpanDonor + 1) * nMixingVars); if (markDonor != -1) { - for (auto iSpan = 0u; iSpan < nSpanDonor + 1; iSpan++) { + for (auto iSpan = 0; iSpan < nSpanDonor + 1; iSpan++) { GetDonor_Variable(donor_solution, donor_geometry, donor_config, markDonor, iSpan, 0); for (auto iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = Donor_Variable[iVar]; sendDonorMarker[iSpan] = markDonor; From 03834ccc7e359ac14043ea79c3df4f6e5ab48c8e Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 26 Mar 2026 13:43:24 +0100 Subject: [PATCH 68/79] Integral promotion --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 830a0bcf33d7..cf9fecf8b130 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -106,7 +106,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter for (auto iSize = 0; iSize < size; iSize++){ if (buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor + 1)] != -1) { - for (size_t iSpan = 0; iSpan < nSpanDonor + 1; iSpan++){ + for (auto iSpan = 0; iSpan < nSpanDonor + 1; iSpan++){ for (size_t iVar = 0u; iVar < nMixingVars; iVar++) sendDonorVar[iSpan * nMixingVars + iVar] = buffDonorVar[static_cast(iSize) * nSpanDonorVars + iSpan * nMixingVars + iVar]; } markDonor = buffDonorMarker[static_cast(iSize) * static_cast(nSpanDonor + 1)]; From 9d60e63084b7ec96a012cef2063779a12ba25665 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 26 Mar 2026 13:52:44 +0100 Subject: [PATCH 69/79] Casting before multiplication --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index cf9fecf8b130..bafc1c5515f9 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -92,7 +92,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter #ifdef HAVE_MPI /*--- Gather data. ---*/ const size_t nTotalDonors = (nSpanDonor + 1) * size; // Number of donor spans across all ranks - const size_t nSpanDonorVars = (nSpanDonor + 1) * nMixingVars; // Number of variables to be transferred on each rank + const size_t nSpanDonorVars = static_cast(nSpanDonor + 1) * nMixingVars; // Number of variables to be transferred on each rank su2vector buffDonorMarker(nTotalDonors); su2activevector buffDonorVar(static_cast(nTotalDonors) * nMixingVars); // Total number of variables to be transferred on all ranks From 24773b008806cd3ccd3b3e2633af930b967cb512 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 26 Mar 2026 13:55:54 +0100 Subject: [PATCH 70/79] Casting before multiplication --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index bafc1c5515f9..87debfd00fd9 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -91,7 +91,7 @@ void CMixingPlaneInterface::BroadcastData_MixingPlane(const CInterpolator& inter } #ifdef HAVE_MPI /*--- Gather data. ---*/ - const size_t nTotalDonors = (nSpanDonor + 1) * size; // Number of donor spans across all ranks + const size_t nTotalDonors = static_cast(nSpanDonor + 1) * size; // Number of donor spans across all ranks const size_t nSpanDonorVars = static_cast(nSpanDonor + 1) * nMixingVars; // Number of variables to be transferred on each rank su2vector buffDonorMarker(nTotalDonors); su2activevector buffDonorVar(static_cast(nTotalDonors) * nMixingVars); // Total number of variables to be transferred on all ranks From 3fad1e24e2d7e246a48605ac0da3b365b59a516b Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Thu, 26 Mar 2026 13:58:27 +0100 Subject: [PATCH 71/79] More commments --- SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp index 87debfd00fd9..902d1f37bbeb 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -189,13 +189,11 @@ void CMixingPlaneInterface::InitializeTarget_Variable(CSolver *target_solution, void CMixingPlaneInterface::SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry, const CConfig *target_config, unsigned long Marker_Target, unsigned long Span_Target, unsigned long Point_Target) { - - unsigned short iVar, iDonorSpan; /*--- Set the mixing plane solution with the value of the Target Variable ---*/ - iDonorSpan = target_solution->GetnMixingStates(Marker_Target, Span_Target); + unsigned short iDonorSpan = target_solution->GetnMixingStates(Marker_Target, Span_Target); - for (iVar = 0; iVar < nMixingVars; iVar++) { + for (unsigned short iVar = 0; iVar < nMixingVars; iVar++) { target_solution->SetMixingState(Marker_Target, Span_Target, iVar, Target_Variable[iVar]); } From 67def4e80ad9d55426ca635c676aef9eaef299c2 Mon Sep 17 00:00:00 2001 From: Ole Burghardt Date: Thu, 26 Mar 2026 18:47:38 +0100 Subject: [PATCH 72/79] Somewhat clunky but transferable fix for proper registration in RegisterVariables. --- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 5f6d8beecac9..84614230ccbd 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -221,8 +221,17 @@ void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, boo if ((config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE) && (KindDirect_Solver == RUNTIME_FLOW_SYS) && config->GetBoolTurbomachinery()){ - BPressure = config->GetPressureOut_BC(); - Temperature = config->GetTotalTemperatureIn_BC(); + static int value_is_set = false; + static double BPressureValue = 0.0, TemperatureValue = 0.0; + if (!value_is_set) { + BPressureValue = SU2_TYPE::GetValue(config->GetPressureOut_BC()); + TemperatureValue = SU2_TYPE::GetValue(config->GetTotalTemperatureIn_BC()); + value_is_set = true; + } + + /*--- Temporary fix that allows us to use the local variables BPressure and Temperature to track derivatives from here on via the config class. ---*/ + BPressure = BPressureValue; + Temperature = TemperatureValue; if (!reset){ AD::RegisterInput(BPressure); From fe952a0b1b71ae7a8e536afd76d24821f07df398 Mon Sep 17 00:00:00 2001 From: Ole Burghardt Date: Fri, 27 Mar 2026 00:18:55 +0100 Subject: [PATCH 73/79] Make AD registration in RegisterVariables consistent. --- Common/include/CConfig.hpp | 12 ---- SU2_CFD/include/solvers/CDiscAdjSolver.hpp | 2 +- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 78 ++++++++++++++-------- 3 files changed, 53 insertions(+), 39 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 6d5a68226f8a..df29be335b2f 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1973,12 +1973,6 @@ class CConfig { */ su2double GetPressure_FreeStreamND(void) const { return Pressure_FreeStreamND; } - /*! - * \brief Get a reference to the non-dimensionalized freestream pressure (used for AD tracking). - * \return Reference to non-dimensionalized freestream pressure. - */ - su2double& GetPressure_FreeStreamND(void) { return Pressure_FreeStreamND; } - /*! * \brief Get the value of the thermodynamic pressure. * \return Thermodynamic pressure. @@ -2004,12 +1998,6 @@ class CConfig { */ su2double GetTemperature_FreeStreamND(void) const { return Temperature_FreeStreamND; } - /*! - * \brief Get a reference to the non-dimensionalized freestream temperature (used for AD tracking). - * \return Reference to non-dimensionalized freestream temperature. - */ - su2double& GetTemperature_FreeStreamND(void) { return Temperature_FreeStreamND; } - /*! * \brief Get the value of the non-dimensionalized vibrational-electronic freestream temperature. * \return Non-dimensionalized vibrational-electronic freestream temperature. diff --git a/SU2_CFD/include/solvers/CDiscAdjSolver.hpp b/SU2_CFD/include/solvers/CDiscAdjSolver.hpp index 5d0ae10580c5..c79258caacac 100644 --- a/SU2_CFD/include/solvers/CDiscAdjSolver.hpp +++ b/SU2_CFD/include/solvers/CDiscAdjSolver.hpp @@ -57,7 +57,7 @@ class CDiscAdjSolver final : public CSolver { su2double Total_Sens_BPress; /*!< \brief Total sensitivity to outlet pressure. */ su2double Total_Sens_Density; /*!< \brief Total sensitivity to initial density (incompressible). */ su2double Total_Sens_ModVel; /*!< \brief Total sensitivity to inlet velocity (incompressible). */ - su2double Mach, Alpha, Beta, Temperature, BPressure, ModVel; + su2double Mach, Alpha, Beta, Pressure, Temperature, BPressure, ModVel; su2double TemperatureRad, Total_Sens_Temp_Rad; CDiscAdjVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 84614230ccbd..d81f9968af3c 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -180,21 +180,30 @@ void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, boo if((config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE) && (KindDirect_Solver == RUNTIME_FLOW_SYS && !config->GetBoolTurbomachinery())){ - su2double Velocity_Ref = config->GetVelocity_Ref(); - Alpha = config->GetAoA()*PI_NUMBER/180.0; - Beta = config->GetAoS()*PI_NUMBER/180.0; - Mach = config->GetMach(); - /*--- Pressure and Temperature can be registered directly via their config file value - * (no further treatment required here). ---*/ - su2double& Pressure = config->GetPressure_FreeStreamND(); - su2double& Temperature = config->GetTemperature_FreeStreamND(); - - su2double SoundSpeed = 0.0; - - // Treat Velocity_FreeStreamND config value as non-dependent (in debug mode) - AD::ClearTagOnVariable(config->GetVelocity_FreeStreamND()[0]); - if (nDim == 2) { SoundSpeed = config->GetVelocity_FreeStreamND()[0]*Velocity_Ref/(cos(Alpha)*Mach); } - if (nDim == 3) { SoundSpeed = config->GetVelocity_FreeStreamND()[0]*Velocity_Ref/(cos(Alpha)*cos(Beta)*Mach); } + static bool value_is_set = false; + static double Velocity_Ref = 0.0, Velocity_FreeStreamND = 0.0, AlphaValue = 0.0, BetaValue = 0.0, MachValue = 0.0, TemperatureValue = 0.0, PressureValue = 0.0; + if (!value_is_set) { + Velocity_Ref = SU2_TYPE::GetValue(config->GetVelocity_Ref()); + Velocity_FreeStreamND = SU2_TYPE::GetValue(config->GetVelocity_FreeStreamND()[0]); + AlphaValue = SU2_TYPE::GetValue(config->GetAoA())*PI_NUMBER/180.0; + BetaValue = SU2_TYPE::GetValue(config->GetAoS())*PI_NUMBER/180.0; + MachValue = SU2_TYPE::GetValue(config->GetMach()); + TemperatureValue = SU2_TYPE::GetValue(config->GetTemperature_FreeStreamND()); + PressureValue = SU2_TYPE::GetValue(config->GetPressure_FreeStreamND()); + value_is_set = true; + } + + Alpha = AlphaValue; + Beta = BetaValue; + Mach = MachValue; + Pressure = PressureValue; + Temperature = TemperatureValue; + + double SoundSpeed = 0.0; + if (nDim == 2) { SoundSpeed = Velocity_FreeStreamND*Velocity_Ref/(cos(AlphaValue)*MachValue); } + if (nDim == 3) { SoundSpeed = Velocity_FreeStreamND*Velocity_Ref/(cos(AlphaValue)*cos(BetaValue)*MachValue); } + + /*--- Register the variables for AD. ---*/ if (!reset) { AD::RegisterInput(Mach); @@ -203,7 +212,7 @@ void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, boo AD::RegisterInput(Pressure); } - /*--- Recompute the free stream velocity ---*/ + /*--- Set the free stream velocity (now using the registered values for Alpha, Beta and Mach). ---*/ if (nDim == 2) { config->GetVelocity_FreeStreamND()[0] = cos(Alpha)*Mach*SoundSpeed/Velocity_Ref; @@ -215,13 +224,15 @@ void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, boo config->GetVelocity_FreeStreamND()[2] = sin(Alpha)*cos(Beta)*Mach*SoundSpeed/Velocity_Ref; } + /*--- Set the freestream values in the direct solver (now using the registered values for Temperature and Pressure). ---*/ + direct_solver->SetTemperature_Inf(Temperature); direct_solver->SetPressure_Inf(Pressure); } if ((config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE) && (KindDirect_Solver == RUNTIME_FLOW_SYS) && config->GetBoolTurbomachinery()){ - static int value_is_set = false; + static bool value_is_set = false; static double BPressureValue = 0.0, TemperatureValue = 0.0; if (!value_is_set) { BPressureValue = SU2_TYPE::GetValue(config->GetPressureOut_BC()); @@ -229,10 +240,11 @@ void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, boo value_is_set = true; } - /*--- Temporary fix that allows us to use the local variables BPressure and Temperature to track derivatives from here on via the config class. ---*/ BPressure = BPressureValue; Temperature = TemperatureValue; + /*--- Register the variables for AD. ---*/ + if (!reset){ AD::RegisterInput(BPressure); AD::RegisterInput(Temperature); @@ -248,15 +260,25 @@ void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, boo ((KindDirect_Solver == RUNTIME_FLOW_SYS && (!config->GetBoolTurbomachinery())))) { - /*--- Access the velocity (or pressure) and temperature at the + static bool value_is_set = false; + static double ModVelValue = 0.0, BPressureValue = 0.0, TemperatureValue = 0.0; + + /*--- Access the velocity (or pressure) and temperature at the inlet BC and the back pressure at the outlet. Note that we are assuming that have internal flow, which will be true for the majority of cases. External flows with far-field BCs will report zero for these sensitivities. ---*/ - ModVel = config->GetIncInlet_BC(); - BPressure = config->GetIncPressureOut_BC(); - Temperature = config->GetIncTemperature_BC(); + if (!value_is_set) { + ModVelValue = SU2_TYPE::GetValue(config->GetIncInlet_BC()); + BPressureValue = SU2_TYPE::GetValue(config->GetIncPressureOut_BC()); + TemperatureValue = SU2_TYPE::GetValue(config->GetIncTemperature_BC()); + value_is_set = true; + } + + ModVel = ModVelValue; + BPressure = BPressureValue; + Temperature = TemperatureValue; /*--- Register the variables for AD. ---*/ @@ -282,7 +304,14 @@ void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, boo /*--- Access the nondimensional freestream temperature. ---*/ - TemperatureRad = config->GetTemperature_FreeStreamND(); + static bool value_is_set = false; + static double TemperatureRadValue = 0.0; + if (!value_is_set) { + TemperatureRadValue = SU2_TYPE::GetValue(config->GetTemperature_FreeStreamND()); + value_is_set = true; + } + TemperatureRad = TemperatureRadValue; + /*--- Register the variables for AD. ---*/ @@ -409,9 +438,6 @@ void CDiscAdjSolver::ExtractAdjoint_Variables(CGeometry *geometry, CConfig *conf if ((config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE) && (KindDirect_Solver == RUNTIME_FLOW_SYS) && !config->GetBoolTurbomachinery()) { su2double Local_Sens_Press, Local_Sens_Temp, Local_Sens_AoA, Local_Sens_Mach; - su2double& Pressure = config->GetPressure_FreeStreamND(); - su2double& Temperature = config->GetTemperature_FreeStreamND(); - Local_Sens_Mach = SU2_TYPE::GetDerivative(Mach); Local_Sens_AoA = SU2_TYPE::GetDerivative(Alpha); Local_Sens_Temp = SU2_TYPE::GetDerivative(Temperature); From 505bef407094c852d3eed85ef22a552f8607f261 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Tue, 31 Mar 2026 17:10:30 +0200 Subject: [PATCH 74/79] Fix MP bug & update flamelet testcase to remove OUTPUT_WRT_FREQ for adj --- Common/include/interface_interpolation/CMixingPlane.hpp | 7 +++---- .../lam_prem_ch4_hx_ad.cfg | 2 +- .../lam_prem_ch4_hx_dot.cfg | 2 +- .../lam_prem_ch4_cht_ad_master.cfg | 2 +- .../lam_prem_ch4_cht_dot_master.cfg | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Common/include/interface_interpolation/CMixingPlane.hpp b/Common/include/interface_interpolation/CMixingPlane.hpp index 97dd1259b21d..2eab028c26a2 100644 --- a/Common/include/interface_interpolation/CMixingPlane.hpp +++ b/Common/include/interface_interpolation/CMixingPlane.hpp @@ -64,22 +64,21 @@ class CMixingPlane final : public CInterpolator { auto minDist = std::numeric_limits::max(); su2double coeff = 0.0; // Interpolation coefficient - if (iSpanTargetValue < spanValuesDonor[0]) { + if (iSpanTargetValue <= spanValuesDonor[0]) { PrintClampingWarning(rank, true); return {0, 0.0}; } - if (iSpanTargetValue > spanValuesDonor[nSpanDonor - 1]) { + if (iSpanTargetValue >= spanValuesDonor[nSpanDonor - 1]) { PrintClampingWarning(rank, false); return {nSpanDonor - 1, 0.0}; } for (auto iSpanDonor = 0u; iSpanDonor < nSpanDonor - 1; iSpanDonor++) { const auto dist = abs(iSpanTargetValue - spanValuesDonor[iSpanDonor]); - if (dist < minDist && iSpanTargetValue > spanValuesDonor[iSpanDonor]) { + if (dist < minDist && iSpanTargetValue >= spanValuesDonor[iSpanDonor]) { kSpan = iSpanDonor; minDist = dist; - break; } } coeff = (iSpanTargetValue - spanValuesDonor[kSpan]) / (spanValuesDonor[kSpan + 1] - spanValuesDonor[kSpan]); diff --git a/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_ad.cfg b/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_ad.cfg index 2c8724cafd46..9c95559abf8c 100644 --- a/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_ad.cfg +++ b/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_ad.cfg @@ -129,7 +129,7 @@ OUTPUT_FILES= RESTART, RESTART_ASCII, PARAVIEW VOLUME_OUTPUT= RESIDUAL, PRIMITIVE VOLUME_ADJ_FILENAME= ch4_flame_hx_ad WRT_RESTART_COMPACT = NO -OUTPUT_WRT_FREQ= 100 +# OUTPUT_WRT_FREQ= 100 % GRAD_OBJFUNC_FILENAME= of_grad.csv % diff --git a/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_dot.cfg b/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_dot.cfg index 120171d8e27c..1bf728e6a064 100644 --- a/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_dot.cfg +++ b/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_dot.cfg @@ -128,7 +128,7 @@ OUTPUT_FILES= RESTART VOLUME_OUTPUT= RESIDUAL, PRIMITIVE VOLUME_ADJ_FILENAME= ch4_flame_hx_ad -OUTPUT_WRT_FREQ= 100 +# OUTPUT_WRT_FREQ= 100 % GRAD_OBJFUNC_FILENAME= of_grad.csv % diff --git a/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_master.cfg b/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_master.cfg index 7a9eb7debc38..86d3ad0d4961 100644 --- a/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_master.cfg +++ b/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_master.cfg @@ -41,7 +41,7 @@ CHT_COUPLING_METHOD= DIRECT_TEMPERATURE_ROBIN_HEATFLUX TIME_DOMAIN= NO OUTER_ITER = 1100 -OUTPUT_WRT_FREQ= 50 +# OUTPUT_WRT_FREQ= 50 SCREEN_WRT_FREQ_INNER= 1 SCREEN_WRT_FREQ_OUTER= 1 SCREEN_OUTPUT= OUTER_ITER, BGS_RES[0], BGS_RES[1] LINSOL_RESIDUAL[1] LINSOL_ITER[1] diff --git a/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_dot_master.cfg b/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_dot_master.cfg index 4a3e831b6c63..ecefea3e7323 100644 --- a/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_dot_master.cfg +++ b/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_dot_master.cfg @@ -41,7 +41,7 @@ CHT_COUPLING_METHOD= DIRECT_TEMPERATURE_ROBIN_HEATFLUX TIME_DOMAIN= NO OUTER_ITER = 11 -OUTPUT_WRT_FREQ= 500 +# OUTPUT_WRT_FREQ= 500 SCREEN_WRT_FREQ_INNER= 1 SCREEN_WRT_FREQ_OUTER= 1 From f3de17de1cd1e8d4f7e952918aa1fc4729c42c75 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Wed, 1 Apr 2026 17:44:14 +0200 Subject: [PATCH 75/79] update reg-tests --- .../chtMaster.cfg | 2 +- .../axial_stage_2D/Axial_stage2D.cfg | 4 +-- .../lam_prem_ch4_hx_ad.cfg | 2 +- .../lam_prem_ch4_hx_dot.cfg | 2 +- .../lam_prem_ch4_cht_ad_master.cfg | 2 +- .../lam_prem_ch4_cht_dot_master.cfg | 2 +- TestCases/parallel_regression.py | 10 +++---- TestCases/serial_regression.py | 10 +++---- TestCases/serial_regression_AD.py | 30 ++++++++++++++++--- 9 files changed, 43 insertions(+), 21 deletions(-) diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg index b41f4517df01..7a5bdc924c45 100644 --- a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg @@ -38,7 +38,7 @@ HISTORY_OUTPUT= ( ITER, BGS_RES[0], RMS_RES[0], BGS_RES[1], RMS_RES[1],\ FLOW_COEFF[0], HEAT[0], AERO_COEFF[0], HEAT[1],\ LINSOL[0], LINSOL[1], TAVG_HEAT[1]) OUTPUT_FILES= (RESTART, PARAVIEW) -OUTPUT_WRT_FREQ= 1 +%OUTPUT_WRT_FREQ= 1 VOLUME_FILENAME= flow WRT_PERFORMANCE= YES SOLUTION_ADJ_FILENAME= solution_adj diff --git a/TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg b/TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg index d87f092e6a72..c2b3c4c99724 100755 --- a/TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg +++ b/TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg @@ -82,8 +82,8 @@ SPATIAL_FOURIER= YES 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) +RAMP_OUTLET= NO +RAMP_OUTLET_COEFF= (140000.0, 10.0, 2000) AVERAGE_PROCESS_KIND= MIXEDOUT PERFORMANCE_AVERAGE_PROCESS_KIND= MIXEDOUT MIXEDOUT_COEFF= (1.0, 1.0E-05, 15) diff --git a/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_ad.cfg b/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_ad.cfg index 9c95559abf8c..dcd3447a147f 100644 --- a/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_ad.cfg +++ b/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_ad.cfg @@ -129,7 +129,7 @@ OUTPUT_FILES= RESTART, RESTART_ASCII, PARAVIEW VOLUME_OUTPUT= RESIDUAL, PRIMITIVE VOLUME_ADJ_FILENAME= ch4_flame_hx_ad WRT_RESTART_COMPACT = NO -# OUTPUT_WRT_FREQ= 100 +%OUTPUT_WRT_FREQ= 100 % GRAD_OBJFUNC_FILENAME= of_grad.csv % diff --git a/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_dot.cfg b/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_dot.cfg index 1bf728e6a064..27cef607d0fa 100644 --- a/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_dot.cfg +++ b/TestCases/flamelet/02_laminar_premixed_ch4_flame_hx_ad/lam_prem_ch4_hx_dot.cfg @@ -128,7 +128,7 @@ OUTPUT_FILES= RESTART VOLUME_OUTPUT= RESIDUAL, PRIMITIVE VOLUME_ADJ_FILENAME= ch4_flame_hx_ad -# OUTPUT_WRT_FREQ= 100 +%OUTPUT_WRT_FREQ= 100 % GRAD_OBJFUNC_FILENAME= of_grad.csv % diff --git a/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_master.cfg b/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_master.cfg index 86d3ad0d4961..2de99ba1c85e 100644 --- a/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_master.cfg +++ b/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_ad_master.cfg @@ -41,7 +41,7 @@ CHT_COUPLING_METHOD= DIRECT_TEMPERATURE_ROBIN_HEATFLUX TIME_DOMAIN= NO OUTER_ITER = 1100 -# OUTPUT_WRT_FREQ= 50 +%OUTPUT_WRT_FREQ= 50 SCREEN_WRT_FREQ_INNER= 1 SCREEN_WRT_FREQ_OUTER= 1 SCREEN_OUTPUT= OUTER_ITER, BGS_RES[0], BGS_RES[1] LINSOL_RESIDUAL[1] LINSOL_ITER[1] diff --git a/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_dot_master.cfg b/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_dot_master.cfg index ecefea3e7323..76aef008a9d1 100644 --- a/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_dot_master.cfg +++ b/TestCases/flamelet/04_laminar_premixed_ch4_flame_cht_ad/lam_prem_ch4_cht_dot_master.cfg @@ -41,7 +41,7 @@ CHT_COUPLING_METHOD= DIRECT_TEMPERATURE_ROBIN_HEATFLUX TIME_DOMAIN= NO OUTER_ITER = 11 -# OUTPUT_WRT_FREQ= 500 +%OUTPUT_WRT_FREQ= 500 SCREEN_WRT_FREQ_INNER= 1 SCREEN_WRT_FREQ_OUTER= 1 diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 5dbfde3f381e..18f6de001f23 100755 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1132,7 +1132,7 @@ def main(): Aachen_3D_restart.cfg_file = "aachen_3D_MP_restart.cfg" Aachen_3D_restart.test_iter = 5 Aachen_3D_restart.tol = 0.00001 - Aachen_3D_restart.test_vals = [-7.701448, -8.512355, -6.014939, -6.468419, -5.801738, -4.607179, -5.550692, -5.300771, -3.804188, -5.256009, -5.765048, -3.609605, -2.229276, -2.883895, -0.563469] + Aachen_3D_restart.test_vals = [-7.701420, -8.504728, -6.014939, -6.468223, -5.801124, -4.607179, -5.550665, -5.300778, -3.804188, -5.255983, -5.763060, -3.609605, -2.229249, -2.880453, -0.563469] test_list.append(Aachen_3D_restart) # Jones APU Turbocharger restart @@ -1148,7 +1148,7 @@ 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.167155, 1.598851, -2.928273, 2.573908, -2.526641, 3.017138, 106370.000000, 106370.000000, 5.726800, 64.383000] + axial_stage2D.test_vals = [1.167485, 1.598851, -2.928275, 2.573906, -2.526641, 3.017138, 106370.000000, 106370.000000, 5.726800, 64.383000] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -1165,8 +1165,8 @@ def main(): multi_interface.cfg_dir = "turbomachinery/multi_interface" multi_interface.cfg_file = "multi_interface_rst.cfg" multi_interface.test_iter = 5 - multi_interface.test_vals = [-8.632229, -8.894737, -9.348730] - multi_interface.test_vals_aarch64 = [-8.632229, -8.894737, -9.348730] + multi_interface.test_vals = [-8.632227, -8.894736, -9.348706] + multi_interface.test_vals_aarch64 = [-8.632227, -8.894736, -9.348706] test_list.append(multi_interface) ###################################### @@ -1765,7 +1765,7 @@ def main(): species3_multizone_restart.cfg_dir = "species_transport/multizone" species3_multizone_restart.cfg_file = "configMaster.cfg" species3_multizone_restart.test_iter = 5 - species3_multizone_restart.test_vals = [-4.634484, -4.515504] + species3_multizone_restart.test_vals = [-4.634924, -4.516692] species3_multizone_restart.multizone = True test_list.append(species3_multizone_restart) diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 088dc2086ac1..00aa6bb9ed73 100755 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -867,7 +867,7 @@ def main(): Aachen_3D_restart.cfg_dir = "turbomachinery/Aachen_turbine" Aachen_3D_restart.cfg_file = "aachen_3D_MP_restart.cfg" Aachen_3D_restart.test_iter = 5 - Aachen_3D_restart.test_vals = [-7.701448, -8.512353, -6.014939, -6.468417, -5.801739, -4.607173, -5.550692, -5.300771, -3.804187, -5.256008, -5.765048, -3.609601, -2.229277, -2.883894, -0.563470] + Aachen_3D_restart.test_vals = [-7.701421, -8.504727, -6.014939, -6.468221, -5.801125, -4.607173, -5.550665, -5.300779, -3.804187, -5.255982, -5.763060, -3.609601, -2.229250, -2.880453, -0.563470] test_list.append(Aachen_3D_restart) # Jones APU Turbocharger restart @@ -883,7 +883,7 @@ 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.167176, 1.598840, -2.928275, 2.573906, -2.526639, 3.017139, 106370.000000, 106370.000000, 5.726800, 64.383000] + axial_stage2D.test_vals = [1.167506, 1.598841, -2.928278, 2.573904, -2.526639, 3.017139, 106370.000000, 106370.000000, 5.726800, 64.383000] test_list.append(axial_stage2D) # 2D transonic stator restart @@ -891,7 +891,7 @@ 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 = [-4.367851, -2.492866, -2.082422, 1.727424, -1.466963, 3.224518, -471620.000000, 94.839000, -0.052025] + transonic_stator_restart.test_vals = [-4.367854, -2.492860, -2.082426, 1.727421, -1.466963, 3.224515, -471620.000000, 94.839000, -0.052024] transonic_stator_restart.test_vals_aarch64 = [-4.443401, -2.566759, -2.169302, 1.651815, -1.356398, 3.172527, -471620.000000, 94.843000, -0.044669] test_list.append(transonic_stator_restart) @@ -900,8 +900,8 @@ def main(): multi_interface.cfg_dir = "turbomachinery/multi_interface" multi_interface.cfg_file = "multi_interface_rst.cfg" multi_interface.test_iter = 5 - multi_interface.test_vals = [-8.632229, -8.894737, -9.348730] - multi_interface.test_vals_aarch64 = [-8.632229, -8.894737, -9.348730] + multi_interface.test_vals = [-8.632227, -8.894736, -9.348706] + multi_interface.test_vals_aarch64 = [-8.632227, -8.894736, -9.348706] test_list.append(multi_interface) diff --git a/TestCases/serial_regression_AD.py b/TestCases/serial_regression_AD.py index 1feaa7cfa105..da4960286d1c 100644 --- a/TestCases/serial_regression_AD.py +++ b/TestCases/serial_regression_AD.py @@ -158,7 +158,7 @@ def main(): discadj_pitchingNACA0012.cfg_dir = "disc_adj_euler/naca0012_pitching" discadj_pitchingNACA0012.cfg_file = "inv_NACA0012_pitching.cfg" discadj_pitchingNACA0012.test_iter = 4 - discadj_pitchingNACA0012.test_vals = [-1.223517, -1.653450, -0.004178, -0.000004] + discadj_pitchingNACA0012.test_vals = [-1.223321, -1.653264, -0.004175, -0.000004] discadj_pitchingNACA0012.unsteady = True test_list.append(discadj_pitchingNACA0012) @@ -167,10 +167,32 @@ def main(): unst_deforming_naca0012.cfg_dir = "disc_adj_euler/naca0012_pitching_def" unst_deforming_naca0012.cfg_file = "inv_NACA0012_pitching_deform_ad.cfg" unst_deforming_naca0012.test_iter = 4 - unst_deforming_naca0012.test_vals = [-1.965747, -1.848881, 2961.700000, 0.000000] + unst_deforming_naca0012.test_vals = [-1.965554, -1.848652, 2967.200000, 0.000000] unst_deforming_naca0012.unsteady = True test_list.append(unst_deforming_naca0012) + ####################################################### + ### Disc. adj. turbomachinery ### + ####################################################### + + # Transonic Stator 2D + discadj_trans_stator = TestCase('transonic_stator') + 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.000000, 0.667037, 0.483920, 0.518405, -1.013536] + discadj_trans_stator.test_vals_aarch64 = [79.000000, 0.696755, 0.485950, 0.569475, -0.990065] + test_list.append(discadj_trans_stator) + + # Axial stage 2D + discadj_axial_stage = TestCase('axial_stage_2D') + discadj_axial_stage.cfg_dir = "disc_adj_turbomachinery/axial_stage_2D" + discadj_axial_stage.cfg_file = "Axial_stage2D.cfg" + discadj_axial_stage.test_iter = 79 + discadj_axial_stage.test_vals = [79, 0.668058, 0.483608, 0.518789, -1.013227] + discadj_axial_stage.test_vals_aarch64 = [79, 0.668058, 0.483608, 0.518789, -1.013227] + test_list.append(discadj_axial_stage) + ################################### ### Structural Adjoint ### ################################### @@ -206,8 +228,8 @@ def main(): discadj_fsi.cfg_dir = "disc_adj_fsi" discadj_fsi.cfg_file = "config.cfg" discadj_fsi.test_iter = 6 - discadj_fsi.test_vals = [6, -8.928820, -10.067497, 3.1052e-11, -1.7613e-06] - discadj_fsi.test_vals_aarch64 = [6, -8.928820, -10.067497, 3.0979e-11, -1.7585e-06] + discadj_fsi.test_vals = [6.000000, -8.928041, -10.069135, 0.000000, -0.000002] + discadj_fsi.test_vals_aarch64 = [6.000000, -8.928041, -10.069135, 0.000000, -0.000002] test_list.append(discadj_fsi) ################################### From 19425601b7930aa40954d745338e143390bab476 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 3 Apr 2026 14:06:02 +0200 Subject: [PATCH 76/79] Init axial stage adj reg test --- TestCases/parallel_regression_AD.py | 4 ++-- TestCases/serial_regression_AD.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 3a9b551d9b2f..aa1e00c3f1b4 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -240,8 +240,8 @@ def main(): discadj_axial_stage.cfg_dir = "disc_adj_turbomachinery/axial_stage_2D" discadj_axial_stage.cfg_file = "Axial_stage2D.cfg" discadj_axial_stage.test_iter = 79 - discadj_axial_stage.test_vals = [79, 0.668058, 0.483608, 0.518789, -1.013227] - discadj_axial_stage.test_vals_aarch64 = [79, 0.668058, 0.483608, 0.518789, -1.013227] + discadj_axial_stage.test_vals = [79, -7.205880, -7.864736] + discadj_axial_stage.test_vals_aarch64 = [79, -7.205880, -7.864736] test_list.append(discadj_axial_stage) ################################### diff --git a/TestCases/serial_regression_AD.py b/TestCases/serial_regression_AD.py index da4960286d1c..2c5bfd6fea6a 100644 --- a/TestCases/serial_regression_AD.py +++ b/TestCases/serial_regression_AD.py @@ -189,8 +189,8 @@ def main(): discadj_axial_stage.cfg_dir = "disc_adj_turbomachinery/axial_stage_2D" discadj_axial_stage.cfg_file = "Axial_stage2D.cfg" discadj_axial_stage.test_iter = 79 - discadj_axial_stage.test_vals = [79, 0.668058, 0.483608, 0.518789, -1.013227] - discadj_axial_stage.test_vals_aarch64 = [79, 0.668058, 0.483608, 0.518789, -1.013227] + discadj_axial_stage.test_vals = [79, -7.205880, -7.864736] + discadj_axial_stage.test_vals_aarch64 = [79, -7.205880, -7.864736] test_list.append(discadj_axial_stage) ################################### From 00e07b2a26f12fb46433a74156a535f9cd0664e8 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 3 Apr 2026 16:20:55 +0200 Subject: [PATCH 77/79] Format disc_adj_turbo/axial_stage_2d cfg --- .../axial_stage_2D/Axial_stage2D.cfg | 29 ++----------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg b/TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg index c2b3c4c99724..ecb25309f668 100755 --- a/TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg +++ b/TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg @@ -5,7 +5,7 @@ % Author: J. Kelly % % Institution: University of Liverpool. % % Date: Oct 11th, 2025 % -% File Version 8.3.0 "Harrier" % +% File Version 8.4.0 "Harrier" % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -17,7 +17,7 @@ CONFIG_LIST= (zone_1.cfg, zone_2.cfg) SOLVER= RANS KIND_TURB_MODEL= SST READ_BINARY_RESTART=NO -RESTART_SOL= NO +RESTART_SOL= YES % % -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% % @@ -60,23 +60,16 @@ CONDUCTIVITY_MODEL= CONSTANT_PRANDTL % -------------------- BOUNDARY CONDITION DEFINITION --------------------------% % MARKER_HEATFLUX= ( wall1, 0.0, wall2, 0.0) -% MARKER_PERIODIC= ( periodic1, periodic2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.04463756775, 0.0, periodic3, periodic4, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.04463756775, 0.0) % %-------- INFLOW/OUTFLOW BOUNDARY CONDITION SPECIFIC FOR TURBOMACHINERY --------% % -% Inflow and Outflow markers must be specified, for each blade (zone), following the natural groth of the machine (i.e, from the first blade to the last) MARKER_TURBOMACHINERY= (inflow, outmix, inmix, 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) -% MARKER_GILES= (inflow, TOTAL_CONDITIONS_PT, 169623.33, 305.76, 1.0, 0.0, 0.0,1.0,1.0, outmix, MIXING_OUT, 0.0, 0.0, 0.0, 0.0, 0.0,1.0,1.0, inmix, MIXING_IN, 0.0, 0.0, 0.0, 0.0, 0.0,1.0, 1.0 outflow, STATIC_PRESSURE, 99741.00, 0.0, 0.0, 0.0, 0.0,1.0,1.0) -% SPATIAL_FOURIER= YES % -% %---------------------------- TURBOMACHINERY SIMULATION -----------------------------% % TURBOMACHINERY_KIND= AXIAL AXIAL @@ -138,32 +131,16 @@ DV_KIND= FFD_CONTROL_POINT_2D, FFD_CONTROL_POINT_2D DV_MARKER= ( wall1, wall2 ) DV_PARAM=( STATOR, 0, 0, 1.0, 0.0 ); ( ROTOR, 2, 2, 1.0, 0.0 ) DV_VALUE=0.0,0.0 -% -% FFD_CONTROL_POINT_2D DEFINITION_DV= ( 19, 1.0 | wall1 | STATOR, 0, 0, 1.0, 0.0 ); ( 19, 1.0 | wall2 | ROTOR, 2, 2, 1.0, 0.0 ); % % ------------------------ GRID DEFORMATION PARAMETERS ------------------------% % -% Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) DEFORM_LINEAR_SOLVER= FGMRES -% -% Preconditioner of the Krylov linear solver (ILU, LU_SGS, JACOBI) DEFORM_LINEAR_SOLVER_PREC= ILU -% -% Number of smoothing iterations for mesh deformation DEFORM_LINEAR_SOLVER_ITER= 1000 -% -% Number of nonlinear deformation iterations (surface deformation increments) DEFORM_NONLINEAR_ITER= 1 -% -% Minimum residual criteria for the linear solver convergence of grid deformation DEFORM_LINEAR_SOLVER_ERROR= 1E-14 -% -% Print the residuals during mesh deformation to the console (YES, NO) DEFORM_CONSOLE_OUTPUT= YES -% -% Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, -% WALL_DISTANCE, CONSTANT_STIFFNESS) DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME % % -------------------- FREE-FORM DEFORMATION PARAMETERS -----------------------% @@ -188,7 +165,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], COMBO +SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], AVG_BGS_RES[1] HISTORY_OUTPUT= COMBO MESH_FILENAME= axial_stage_2D.su2 MESH_FORMAT= SU2 From 8986e77047013031ec9ccb93856456146ada4388 Mon Sep 17 00:00:00 2001 From: Josh Kelly Date: Fri, 3 Apr 2026 19:17:39 +0200 Subject: [PATCH 78/79] Update reg-tests --- TestCases/disc_adj_fsi/Airfoil_2d/config.cfg | 2 +- TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg | 2 +- TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg | 2 +- .../streamwise_periodic/chtPinArray_2d/configMaster.cfg | 2 +- .../dp-adjoint_chtPinArray_2d/configMaster.cfg | 2 +- TestCases/parallel_regression_AD.py | 8 ++++---- TestCases/serial_regression_AD.py | 6 +++--- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg b/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg index c35de2da2633..54b13cfeb8e8 100755 --- a/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg +++ b/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg @@ -7,7 +7,7 @@ MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side CONSERVATIVE_INTERPOLATION= NO OUTER_ITER= 9 -OUTPUT_WRT_FREQ= 5 +%OUTPUT_WRT_FREQ= 5 MESH_FILENAME= mesh.su2 diff --git a/TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg b/TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg index 4a1e1e30f592..bb75382f59d6 100644 --- a/TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg +++ b/TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg @@ -50,7 +50,7 @@ MESH_FORMAT= SU2 SOLUTION_FILENAME= solution_solid SOLUTION_ADJ_FILENAME= adjoint_solid -OUTPUT_WRT_FREQ= 1 +%OUTPUT_WRT_FREQ= 1 RESTART_FILENAME= solution_solid RESTART_ADJ_FILENAME= adjoint_solid TABULAR_FORMAT= CSV diff --git a/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg b/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg index f5c233ec9ccc..fe50163a3df3 100644 --- a/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg +++ b/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg @@ -87,7 +87,7 @@ MESH_FORMAT= SU2 % SOLUTION_FILENAME= solution_fluid SOLUTION_ADJ_FILENAME= adjoint_fluid -OUTPUT_WRT_FREQ= 1 +%OUTPUT_WRT_FREQ= 1 RESTART_FILENAME= solution_fluid RESTART_ADJ_FILENAME= adjoint_fluid TABULAR_FORMAT= CSV diff --git a/TestCases/incomp_navierstokes/streamwise_periodic/chtPinArray_2d/configMaster.cfg b/TestCases/incomp_navierstokes/streamwise_periodic/chtPinArray_2d/configMaster.cfg index 94e05f206f22..9293a0dda996 100644 --- a/TestCases/incomp_navierstokes/streamwise_periodic/chtPinArray_2d/configMaster.cfg +++ b/TestCases/incomp_navierstokes/streamwise_periodic/chtPinArray_2d/configMaster.cfg @@ -27,7 +27,7 @@ SCREEN_WRT_FREQ_OUTER= 100 HISTORY_OUTPUT= ( ITER, BGS_RES[0], BGS_RES[1], RMS_RES[0], RMS_RES[1], STREAMWISE_PERIODIC[0], FLOW_COEFF[0], FLOW_COEFF_SURF[0], HEAT[1], LINSOL[0], LINSOL[1], HEAT[0] ) % OUTPUT_FILES= ( RESTART, PARAVIEW_MULTIBLOCK ) -OUTPUT_WRT_FREQ= 1000 +%OUTPUT_WRT_FREQ= 1000 % MESH_FILENAME= 2D-PinArray_FFD.su2 MESH_FORMAT= SU2 diff --git a/TestCases/incomp_navierstokes/streamwise_periodic/dp-adjoint_chtPinArray_2d/configMaster.cfg b/TestCases/incomp_navierstokes/streamwise_periodic/dp-adjoint_chtPinArray_2d/configMaster.cfg index b39203de2fa1..d2c8e2dd1227 100644 --- a/TestCases/incomp_navierstokes/streamwise_periodic/dp-adjoint_chtPinArray_2d/configMaster.cfg +++ b/TestCases/incomp_navierstokes/streamwise_periodic/dp-adjoint_chtPinArray_2d/configMaster.cfg @@ -38,7 +38,7 @@ HISTORY_OUTPUT= ITER, BGS_RES[0], BGS_RES[1], RMS_RES[0], RMS_RES[1], ADJOINT_SO OUTPUT_PRECISION= 16 % OUTPUT_FILES= RESTART, PARAVIEW_MULTIBLOCK -OUTPUT_WRT_FREQ= 10000 +%OUTPUT_WRT_FREQ= 10000 % SOLUTION_FILENAME= restart SOLUTION_ADJ_FILENAME= restart_adj diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index aa1e00c3f1b4..465b4092af8b 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -231,8 +231,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.000000, 0.667037, 0.483920, 0.518405, -1.013536] - discadj_trans_stator.test_vals_aarch64 = [79.000000, 0.696755, 0.485950, 0.569475, -0.990065] + discadj_trans_stator.test_vals = [79.000000, 0.666993, 0.483927, 0.518392, -1.013549] + discadj_trans_stator.test_vals_aarch64 = [79.000000, 0.666993, 0.483927, 0.518392, -1.013549] test_list.append(discadj_trans_stator) # Axial stage 2D @@ -240,8 +240,8 @@ def main(): discadj_axial_stage.cfg_dir = "disc_adj_turbomachinery/axial_stage_2D" discadj_axial_stage.cfg_file = "Axial_stage2D.cfg" discadj_axial_stage.test_iter = 79 - discadj_axial_stage.test_vals = [79, -7.205880, -7.864736] - discadj_axial_stage.test_vals_aarch64 = [79, -7.205880, -7.864736] + discadj_axial_stage.test_vals = [79.000000, -6.606323, -7.139638] + discadj_axial_stage.test_vals_aarch64 = [79.000000, -6.606323, -7.139638] test_list.append(discadj_axial_stage) ################################### diff --git a/TestCases/serial_regression_AD.py b/TestCases/serial_regression_AD.py index 2c5bfd6fea6a..6e6ca8e906d1 100644 --- a/TestCases/serial_regression_AD.py +++ b/TestCases/serial_regression_AD.py @@ -180,8 +180,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.000000, 0.667037, 0.483920, 0.518405, -1.013536] - discadj_trans_stator.test_vals_aarch64 = [79.000000, 0.696755, 0.485950, 0.569475, -0.990065] + discadj_trans_stator.test_vals = [79.000000, 0.670541, 0.472964, 0.495932, -1.012264] + discadj_trans_stator.test_vals_aarch64 = [79.000000, 0.670541, 0.472964, 0.495932, -1.012264] test_list.append(discadj_trans_stator) # Axial stage 2D @@ -190,7 +190,7 @@ def main(): discadj_axial_stage.cfg_file = "Axial_stage2D.cfg" discadj_axial_stage.test_iter = 79 discadj_axial_stage.test_vals = [79, -7.205880, -7.864736] - discadj_axial_stage.test_vals_aarch64 = [79, -7.205880, -7.864736] + discadj_axial_stage.test_vals_aarch64 = [79.000000, -6.605594, -7.138121] test_list.append(discadj_axial_stage) ################################### From 6c4a0454e4651a4111ed1d7871d55a2bb4de602b Mon Sep 17 00:00:00 2001 From: Ole Burghardt Date: Sat, 4 Apr 2026 21:14:03 +0200 Subject: [PATCH 79/79] Remove discrete adjoint multizone restart error. --- Common/src/CConfig.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 06e1739ea597..06b6a9d6a1ab 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -3514,17 +3514,8 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i /*--- Using default frequency of 250 for all files when steady, and 1 for unsteady. ---*/ for (auto iVolumeFreq = 0; iVolumeFreq < nVolumeOutputFrequencies; iVolumeFreq++){ - if (Multizone_Problem && DiscreteAdjoint) { - VolumeOutputFrequencies[iVolumeFreq] = Time_Domain ? 1 : nOuterIter; - } - else { - VolumeOutputFrequencies[iVolumeFreq] = Time_Domain ? 1 : 250; - } + VolumeOutputFrequencies[iVolumeFreq] = Time_Domain ? 1 : nOuterIter; } - } else if (Multizone_Problem && DiscreteAdjoint) { - SU2_MPI::Error(string("OUTPUT_WRT_FREQ cannot be specified for this solver " - "(writing of restart and sensitivity files not possible for multizone discrete adjoint during runtime yet).\n" - "Please remove this option from the config file, output files will be written when solver finalizes.\n"), CURRENT_FUNCTION); } else if (nVolumeOutputFrequencies < nVolumeOutputFiles) { /*--- If there are fewer frequencies than files, repeat the last frequency. * This is useful to define 1 frequency for the restart file and 1 frequency for all the visualization files. ---*/