diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 02c94dd1198f..514f7aecf1dd 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -233,7 +233,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:260405-0054 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:260405-0054 with: @@ -282,7 +282,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2:260405-0054 with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--tapetests" + args: -b ${{github.ref}} -t develop -c feature_mz_turbomachinery_adjoint -s ${{matrix.testscript}} -a "--tapetests" - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2:260405-0054 with: @@ -330,7 +330,7 @@ jobs: PMIX_MCA_gds: hash with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--tsan" + args: -b ${{github.ref}} -t develop -c feature_mz_turbomachinery_adjoint -s ${{matrix.testscript}} -a "--tsan" - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2-tsan:260405-0054 with: @@ -375,7 +375,7 @@ jobs: uses: docker://ghcr.io/su2code/su2/test-su2-asan:260405-0054 with: # -t -c - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} -a "--asan" + args: -b ${{github.ref}} -t develop -c feature_mz_turbomachinery_adjoint -s ${{matrix.testscript}} -a "--asan" - name: Cleanup uses: docker://ghcr.io/su2code/su2/test-su2-asan:260405-0054 with: diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 71f780bbed07..0110086d543f 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1988,12 +1988,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. @@ -2019,12 +2013,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. @@ -10128,6 +10116,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, unsigned short iMarkerInt) const; + /*! * \brief Get whether or not to save solution data to libROM. * \return True if specified in config file. diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index 7958110fb23b..e3f1f13a5456 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -878,7 +878,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 @@ -1960,7 +1960,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); + 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 49d6841abe61..045e28c8d3fd 100644 --- a/Common/include/interface_interpolation/CInterpolator.hpp +++ b/Common/include/interface_interpolation/CInterpolator.hpp @@ -99,7 +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 { + size_t donorSpan; // Refers to donor span + su2double coefficient; // Refers to coefficient + }; + vector> targetSpans; // > /*! * \brief Constructor of the class. @@ -125,13 +131,18 @@ 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. */ 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/CInterpolatorFactory.hpp b/Common/include/interface_interpolation/CInterpolatorFactory.hpp index fdc76ceccf47..e3c86cff5a32 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/CIsoparametric.hpp b/Common/include/interface_interpolation/CIsoparametric.hpp index 0b540f4e66c0..6b05dc851be0 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 1b569483a802..0f0bb2af4f80 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 new file mode 100644 index 000000000000..2eab028c26a2 --- /dev/null +++ b/Common/include/interface_interpolation/CMixingPlane.hpp @@ -0,0 +1,101 @@ +/*! + * \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" +#include "../option_structure.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(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; + } + } + 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. + * \param[in] config - Configuration for all zones. + */ + void WriteInterpolationDetails(const string& filename, const CConfig* const* config) override; +}; diff --git a/Common/include/interface_interpolation/CNearestNeighbor.hpp b/Common/include/interface_interpolation/CNearestNeighbor.hpp index 12e5cafd73bd..f75507a6f4d9 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 97a3e8524548..b783b10d882d 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 328052bd167f..34474bad910a 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/include/option_structure.hpp b/Common/include/option_structure.hpp index 73266c7dacdb..fd11b803c5a8 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -2123,6 +2123,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) @@ -2165,6 +2168,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) }; /*! @@ -2639,7 +2645,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 { @@ -2647,11 +2653,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/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 0f7a5c6821fa..490252db9af5 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -3560,12 +3560,7 @@ 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 (nVolumeOutputFrequencies < nVolumeOutputFiles) { /*--- If there are fewer frequencies than files, repeat the last frequency. @@ -7034,6 +7029,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 { @@ -8636,6 +8632,7 @@ CConfig::~CConfig() { delete [] nBlades; delete [] FreeStreamTurboNormal; + } /*--- Input is the filename base, output is the completed filename. ---*/ @@ -8779,6 +8776,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{ @@ -10079,6 +10079,23 @@ short CConfig::FindInterfaceMarker(unsigned short iInterface) const { return -1; } +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) == iMarkerInt){ + /*--- 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::GEMM_Tick(double *val_start_time) const { #ifdef PROFILE diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 258e5612be89..439c5772845f 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -4540,7 +4540,8 @@ 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); @@ -4608,6 +4609,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 53720985fe26..cbf3a4e5e64a 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 @@ -5682,9 +5684,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]; @@ -10161,7 +10163,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/Common/src/interface_interpolation/CInterpolatorFactory.cpp b/Common/src/interface_interpolation/CInterpolatorFactory.cpp index f17d2d3af941..4364b44e16bc 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/CIsoparametric.cpp b/Common/src/interface_interpolation/CIsoparametric.cpp index 83e737e7a72a..797cbd0a9c7a 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 ed4236ce6a02..36f4b3ed64ae 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 new file mode 100644 index 000000000000..d96013c7d26e --- /dev/null +++ b/Common/src/interface_interpolation/CMixingPlane.cpp @@ -0,0 +1,239 @@ +/*! + * \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(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 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. + auto nSpanDonor = donor_config->GetnSpanWiseSections(); + auto nSpanTarget = target_config->GetnSpanWiseSections(); + + 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; + + 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; + +#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 < size; iSize++) { + buffMarkerDonor[iSize] = -1; + buffDonorFlag[iSize] = -1; + buffMarkerTarget[iSize] = -1; + buffTargetFlag[iSize] = -1; + } + + SU2_MPI::Allgather(&markDonor, 1, MPI_INT, buffMarkerDonor, 1, MPI_INT, SU2_MPI::GetComm()); + SU2_MPI::Allgather(&donorFlag, 1, MPI_INT, buffDonorFlag, 1, MPI_INT, SU2_MPI::GetComm()); + SU2_MPI::Allgather(&markTarget, 1, MPI_INT, buffMarkerTarget, 1, MPI_INT, SU2_MPI::GetComm()); + SU2_MPI::Allgather(&targetFlag, 1, MPI_INT, buffTargetFlag, 1, MPI_INT, SU2_MPI::GetComm()); + + markDonor = -1; + donorFlag = -1; + markTarget = -1; + targetFlag = -1; + + for (int iSize = 0; iSize < size; iSize++) { + if (buffMarkerDonor[iSize] != -1) { + markDonor = buffMarkerDonor[iSize]; + donorFlag = buffDonorFlag[iSize]; + break; + } + } + + for (int iSize = 0; iSize < size; iSize++) { + if (buffMarkerTarget[iSize] != -1) { + markTarget = buffMarkerTarget[iSize]; + targetFlag = buffTargetFlag[iSize]; + break; + } + } + delete[] buffMarkerDonor; + delete[] buffDonorFlag; + delete[] buffMarkerTarget; + delete[] buffTargetFlag; +#endif + if (markTarget == -1 || markDonor == -1) continue; + + nSpanDonor = donor_config->GetnSpanWiseSections(); + nSpanTarget = target_config->GetnSpanWiseSections(); + + targetSpans[iMarkerInt].resize(nSpanTarget + 1); + + 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]; + + switch (donor_config->GetKind_MixingPlaneInterface()) { + case MATCHING: + targetSpan = MapMatchingSpan(iSpanTarget); + break; + + case NEAREST_SPAN: + targetSpan = MapNearestSpan(spanValuesTarget[iSpanTarget], spanValuesDonor, nSpanDonor); + break; + + case LINEAR_INTERPOLATION: { + targetSpan = MapLinearInterpolationSpan(spanValuesTarget[iSpanTarget], spanValuesDonor, nSpanDonor, rank); + 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; + + 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"; + } + + // 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"; + } + } + outFile << "\n"; + } + + outFile.close(); + cout << "Interpolation details written to " << filename << endl; +} diff --git a/Common/src/interface_interpolation/CNearestNeighbor.cpp b/Common/src/interface_interpolation/CNearestNeighbor.cpp index 2c245e9fc554..33a99994ccdd 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 c1d932588f69..054cbe960931 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 a81ff98f31fb..7e287c12f998 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/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 0dc9dd2f604d..f6231a6b5293 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. @@ -290,17 +290,14 @@ class CDriver : public CDriverBase { * \param[in] geometry - Geometrical definition of the problem. * \param[in] solver - Container vector with all the solutions. * \param[in] interface - Class defining the physical transfer of information. + * \param[in] 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); + CInterface*** interface, CIteration*** iteration, 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); + void PreprocessTurboVertex(CConfig** config, CGeometry**** geometry, CSolver***** solver, + 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 ba3af37349fd..b9d9c74cb1f7 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 8d7fcd7e8838..d0b1ab976e36 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/interfaces/CInterface.hpp b/SU2_CFD/include/interfaces/CInterface.hpp index 7480f970ce4a..09439d82c6fe 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 @@ -36,6 +37,7 @@ #include #include #include +#include #include #include @@ -65,6 +67,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; @@ -146,6 +150,12 @@ class CInterface { for (auto iVar = 0u; iVar < nVar; iVar++) Target_Variable[iVar] += donorCoeff * bcastVariable[iVar]; } + inline virtual void RecoverTarget_Span_Endwall(const su2activevector &bcastVariable, unsigned long idx) { } + + inline virtual void RecoverTarget_Span(const su2activevector &bcastVariable, unsigned long idx, su2double donorCoeff) { } + + + /*! * \brief A virtual member. * \param[in] target_solution - Solution from the target mesh. @@ -177,51 +187,35 @@ 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. + * \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_zone - Index of the donorZone. - */ - inline virtual void SetAverageValues(CSolver *donor_solution, CSolver *target_solution, - unsigned short donorZone) { } - - /*! - * \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); + 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 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. + * \brief Set the contact resistance value for the solid-to-solid heat transfer interface. + * \param[in] val_contact_resistance - Contact resistance value in m^2/W */ - 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); + inline virtual void SetContactResistance(su2double val_contact_resistance) {}; /*! - * \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. + * \brief Set the type of an interface + * \param[in] interface_type - The type of interface */ - void GatherAverageValues(CSolver *donor_solution, CSolver *target_solution, unsigned short donorZone); + void SetInterfaceType(unsigned short interface_type) { InterfaceType = interface_type; } /*! - * \brief Set the contact resistance value for the solid-to-solid heat transfer interface. - * \param[in] val_contact_resistance - Contact resistance value in m^2/W + * \brief Get the type of an interface */ - inline virtual void SetContactResistance(su2double val_contact_resistance) {}; + unsigned short GetInterfaceType(void) const { return InterfaceType; } }; diff --git a/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp b/SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp index e57d7c61764c..36e13570b78d 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 "../../../Common/include/containers/C2DContainer.hpp" /*! * \brief Mixing plane interface for turbomachinery. @@ -36,6 +37,7 @@ */ class CMixingPlaneInterface : public CInterface { public: + unsigned short nMixingVars; /*! * \overload * \param[in] val_nVar - Number of variables that need to be transferred. @@ -49,6 +51,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 +78,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,14 +93,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; - /*! - * \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; - - + 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 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/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index 2a53eba538cb..024f88e7d432 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -115,12 +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); - - /*! - * \brief Computes turboperformance. - */ - void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter); + void UpdateRamps(CGeometry**** geometry_container, CConfig** config_container, unsigned long iter, unsigned short iZone, RAMP_TYPE ramp_flag); /*! * \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 b570d4b75ab4..06783c821f12 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. */ - public: /*! * \brief Constructor of the class. @@ -295,4 +293,22 @@ class CIteration { virtual void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, unsigned short iZone, unsigned short iInst) {} + + /*! + * \brief Computes turboperformance. + */ + void ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container); + + /*! + * \brief Initialises turboperformance classes. + */ + void InitTurboPerformance(CGeometry *geometry, CConfig** config, CFluidModel *fluid, unsigned short val_iZone); + + 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; + } }; diff --git a/SU2_CFD/include/numerics/scalar/scalar_diffusion.hpp b/SU2_CFD/include/numerics/scalar/scalar_diffusion.hpp index 580c0bedcefa..2e6e4fc76bc1 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/output/CFlowCompOutput.hpp b/SU2_CFD/include/output/CFlowCompOutput.hpp index ba1e289f8529..ad2dd0217317 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. @@ -74,6 +76,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. @@ -101,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(su2vector> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) override; /*! * \brief Sets the multizone turboperformacne screen output @@ -109,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, su2vector> TurboBladePerfs, CConfig *config) override; /*! * \brief Loads the turboperformacne history data @@ -117,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, su2vector> TurboBladePerfs, CConfig *config) override; /*! * \brief Write the kinematic and thermodynamic variables at each spanwise division @@ -126,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(su2vector> TurboBladePerfs, CGeometry *geometry, CConfig **config, unsigned short val_iZone) override; }; diff --git a/SU2_CFD/include/output/CFlowOutput.hpp b/SU2_CFD/include/output/CFlowOutput.hpp index e79067c79d9b..cf4b2c9f6aa6 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/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index f5df6d6272b7..11234880c507 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -411,7 +411,7 @@ class COutput { */ void SetHistoryOutput(CGeometry ****geometry, CSolver *****solver_container, CConfig **config, std::shared_ptr TurboStagePerf, - std::shared_ptr TurboPerf, unsigned short val_iZone, + su2vector> TurboBladePerfs, unsigned short val_iZone, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iInst); /*! @@ -982,7 +982,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(su2vector> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter) {} /*! * \brief Sets the multizone turboperformacne screen output @@ -990,7 +990,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, su2vector> TurboPerf, CConfig *config) {} /*! * \brief Loads the turboperformacne history data @@ -998,7 +998,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, su2vector> TurboPerf, CConfig *config) {} /*! * \brief Write the kinematic and thermodynamic variables at each spanwise division @@ -1007,7 +1007,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(su2vector> 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 21c69659e8f6..6a25745590d8 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; } @@ -247,16 +252,30 @@ 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; } + + void ComputeTurbomachineryPerformance(vector const primitives, unsigned short iBladeRow); - const vector>>& GetBladesPerformances() const { return BladesPerformances; } + /*! + * \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); - void ComputeTurbomachineryPerformance(vector> const primitives); + /*! + * \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 71758c0f43cf..81d325feaf5c 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/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 46eed006b049..408c5728e9ab 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 @@ -123,21 +124,16 @@ 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 AverageRelTangVelocity; su2activematrix DensityIn; su2activematrix PressureIn; @@ -151,11 +147,91 @@ class CEulerSolver : public CFVMFlowSolverBase > > CkInflow, CkOutflow1, CkOutflow2; /*--- End of Turbomachinery Solver Variables ---*/ + vector> 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 + * \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 { + assert(val_marker < MixingState.size()); + assert(val_span < MixingState[val_marker].size()); + if( MixingState[val_marker][val_span] != nullptr ) delete [] MixingState[val_marker][val_span]; + + MixingState[val_marker][val_span] = new su2double[8]; + } + + /*! + * \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. @@ -1036,7 +1112,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. @@ -1229,105 +1309,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 6161e2f0fc3b..bb01592d8e0f 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -59,6 +59,8 @@ #include "../limiters/CLimiterDetails.hpp" #include "../variables/CVariable.hpp" +#include "../output/CTurboOutput.hpp" + #ifdef HAVE_LIBROM #include "librom.h" #endif @@ -150,6 +152,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. */ /*! @@ -1106,6 +1110,8 @@ class CSolver { CConfig *config, unsigned short val_marker) { } + inline virtual std::shared_ptr GetTurboBladePerformance() const { return std::shared_ptr(nullptr); } + /*! * \brief A virtual member. * \param[in] geometry - Geometrical definition of the problem. @@ -1287,6 +1293,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 @@ -3778,7 +3833,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 @@ -3818,6 +3873,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. @@ -3867,82 +3924,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/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 61673bdad1b3..0d93b560edd4 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -251,25 +251,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); @@ -282,18 +283,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); @@ -720,10 +722,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; } } @@ -854,6 +852,12 @@ void CDiscAdjMultizoneDriver::SetObjFunction(RECORDING kind_recording) { solvers[HEAT_SOL]->Heat_Fluxes(geometry, solvers, config); } + if(config->GetBoolTurbomachinery()){ + /*--- 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); + } + direct_output[iZone]->SetHistoryOutput(geometry, solvers, config); ObjFunc += solvers[FLOW_SOL]->GetTotal_ComboObj(); break; @@ -879,10 +883,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/drivers/CDiscAdjSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp index ce6f7d93b10f..7696daaf5ed6 100644 --- a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp @@ -33,6 +33,7 @@ #include "../../include/iteration/CTurboIteration.hpp" #include "../../../Common/include/toolboxes/CQuasiNewtonInvLeastSquares.hpp" + CDiscAdjSinglezoneDriver::CDiscAdjSinglezoneDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunicator) : CSinglezoneDriver(confFile, diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 5bdeb9ce1af7..8bdcf4ce75c4 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -223,6 +223,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) { @@ -230,7 +237,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) { @@ -246,12 +253,9 @@ 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); - } else { - mixingplane = false; + PreprocessTurbomachinery(config_container, geometry_container, solver_container, interface_container, iteration_container, dummy_geo); } - PreprocessPythonInterface(config_container, geometry_container, solver_container); @@ -312,7 +316,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. ---*/ @@ -328,16 +331,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; } @@ -416,12 +415,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++){ @@ -1284,14 +1277,14 @@ 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) { 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); } } @@ -2409,8 +2402,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. ---*/ @@ -2419,19 +2411,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. ---*/ @@ -2440,8 +2422,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. ---*/ @@ -2455,10 +2440,8 @@ void CDriver::InitializeInterface(CConfig **config, CSolver***** solver, CGeomet /*--- Initialize the appropriate transfer strategy. ---*/ - 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()) { @@ -2473,7 +2456,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; @@ -2484,15 +2466,21 @@ 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; + 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); 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_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; } @@ -2500,30 +2488,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 { @@ -2535,7 +2524,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; } @@ -2632,16 +2620,11 @@ void CDriver::PreprocessOutput(CConfig **config, CConfig *driver_config, COutput } +void CDriver::PreprocessTurboVertex(CConfig** config, CGeometry**** geometry, CSolver***** solver, + CInterface*** interface, CIteration*** iteration, bool dummy){ -void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, CSolver***** solver, - CInterface*** interface, 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<InitTurboContainers(geometry[iZone][INST_0][MESH_0],config[iZone]); - } +void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, CSolver***** solver, + CInterface*** interface, CIteration*** iteration, bool dummy){ + 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(); + 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; 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); } + 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); + } + } if(mixingplane){ if (rank == MASTER_NODE) cout << "Set span-wise sections between zones on Mixing-Plane interface." << endl; @@ -2695,10 +2687,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); @@ -2716,23 +2704,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 (interface_types[donorZone][targetZone]==MIXING_PLANE){ - interface[donorZone][targetZone]->PreprocessAverage(geometry[donorZone][INST_0][MESH_0], geometry[targetZone][INST_0][MESH_0], - config[donorZone], config[targetZone], - iMarkerInt); - } - } - } - } - } - if(!restart && !discrete_adjoint){ if (rank == MASTER_NODE) cout<<"Initialize turbomachinery solution quantities." << endl; for(iZone = 0; iZone < nZone; iZone++) { @@ -2740,6 +2711,7 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, } } + if (dummy) return; // No need to go further for a dummy run 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); @@ -2756,10 +2728,8 @@ void CDriver::PreprocessTurbomachinery(CConfig** config, CGeometry**** geometry, 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 <<"°." <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) + "]"; - }; + /*--- Table for Residual Values ---*/ + PrintingToolbox::CTablePrinter ResidualTable(&std::cout); + ResidualTable.SetPrecision(config_container[ZONE_0]->GetOutput_Precision()); + ResidualTable.SetAlign(PrintingToolbox::CTablePrinter::RIGHT); - /*--- Print residuals in the first iteration ---*/ + std::cout << "\n-- Direct Residual Summary:" << std::endl; - const unsigned short fieldWidth = 15; - PrintingToolbox::CTablePrinter RMSTable(&std::cout); - RMSTable.SetPrecision(config_container[ZONE_0]->GetOutput_Precision()); + /*--- Setup table columns ---*/ + ResidualTable.AddColumn("Residual", fieldWidth); + ResidualTable.AddColumn("log10(RMS)", fieldWidth); + ResidualTable.PrintHeader(); - /*--- 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++) { + /*--- Loop through each zone ---*/ + for (unsigned short iZone = 0; iZone < nZone; iZone++) { - 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]; + /*--- Print zone header ---*/ + if (multizone) { + ResidualTable << "ZONE " + std::to_string(iZone) << ""; + ResidualTable.PrintFooter(); + } - /*--- Note: the FEM-Flow solvers are availalbe for disc. adjoint runs only for SingleZone. ---*/ - if (configs->GetFluidProblem() || configs->GetFEMSolver()) { + /*--- Fluid or FEM-Flow Problems ---*/ + if (configs->GetFluidProblem() || configs->GetFEMSolver()) { - 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)); - } + /*--- 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_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)); - } + /*--- 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 (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)); - } + /*--- 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 (!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)); - } + /*--- Heat residuals (weakly coupled) ---*/ + if (!multizone && configs->GetWeakly_Coupled_Heat()) { + ResidualTable << "rms_Heat[0]" << log10(solvers[HEAT_SOL]->GetRes_RMS(0)); + } - if (configs->AddRadiation()) { - if (!addVals) RMSTable.AddColumn("rms_Rad" + iVar_iZone2string(0, iZone), fieldWidth); - else RMSTable << 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)); - } - } - if (configs->GetWeakly_Coupled_Heat()){ - if (!addVals) RMSTable.AddColumn("rms_Heat", fieldWidth); - else RMSTable << log10(solvers[HEAT_SOL]->GetRes_RMS(0)); - } - } else if (configs->GetHeatProblem()) { + /*--- Radiation residuals ---*/ + if (configs->AddRadiation()) { + ResidualTable << "rms_Rad[0]" << log10(solvers[RAD_SOL]->GetRes_RMS(0)); + } - 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); + } + /*--- 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 { + 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)); + + } + else { + SU2_MPI::Error("Invalid KindSolver for CDiscAdj-MultiZone/SingleZone-Driver.", CURRENT_FUNCTION); + } - } // for addVals + /*--- 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; } @@ -2993,7 +2962,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/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index d6f68a6682f6..339b7a5908ad 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -274,7 +274,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); } } } @@ -560,14 +560,20 @@ 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); /*--- 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); } @@ -600,28 +606,16 @@ 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 ); - } - - /*--- 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]->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; } - 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 " @@ -632,17 +626,6 @@ bool CMultizoneDriver::TransferData(unsigned short donorZone, unsigned short tar return UpdateMesh; } - - -void CMultizoneDriver::SetTurboPerformance() { - SU2_ZONE_SCOPED - 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) { SU2_ZONE_SCOPED diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index 21024a317945..1e24f9768c4a 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -89,19 +89,9 @@ void CIntegration::Space_Integration(CGeometry *geometry, if (iMesh == MESH_0 && 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); } - BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS { - if (iMesh == MESH_0 && 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++) { diff --git a/SU2_CFD/src/integration/CMultiGridIntegration.cpp b/SU2_CFD/src/integration/CMultiGridIntegration.cpp index cf1bcd3b1ca5..69a13e467c4d 100644 --- a/SU2_CFD/src/integration/CMultiGridIntegration.cpp +++ b/SU2_CFD/src/integration/CMultiGridIntegration.cpp @@ -1134,21 +1134,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 (only on the fine grid; turbo - * geometry data is only available on MESH_0). ---*/ - if (config->GetBoolTurbomachinery() && FinestMesh == MESH_0){ - - /*--- 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]); - - } - break; case RUNTIME_ADJFLOW_SYS: diff --git a/SU2_CFD/src/interfaces/CInterface.cpp b/SU2_CFD/src/interfaces/CInterface.cpp index 293141079c49..76b59eb873bf 100644 --- a/SU2_CFD/src/interfaces/CInterface.cpp +++ b/SU2_CFD/src/interfaces/CInterface.cpp @@ -198,444 +198,4 @@ void CInterface::BroadcastData(const CInterpolator& interpolator, SetTarget_Variable(target_solution, target_geometry, target_config, markTarget, iVertex, iPoint); } } -} - -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; -} +} \ No newline at end of file diff --git a/SU2_CFD/src/interfaces/cfd/CConservativeVarsInterface.cpp b/SU2_CFD/src/interfaces/cfd/CConservativeVarsInterface.cpp index f9c7a0c10cce..120921c16232 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 49755cf285e2..902d1f37bbeb 100644 --- a/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp @@ -1,9 +1,9 @@ /*! * \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 - * \version 8.5.0 "Harrier" + * \author J. Kelly, S. Vitale + * \version 8.4.0 "Harrier" * * SU2 Project Website: https://su2code.github.io * @@ -27,14 +27,17 @@ */ #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" 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; // 8 solver vars in turbo MP + Donor_Variable = new su2double[nMixingVars](); + Target_Variable = new su2double[nMixingVars](); + InterfaceType = ENUM_TRANSFER::MIXING_PLANE; } void CMixingPlaneInterface::SetSpanWiseLevels(const CConfig *donor_config, const CConfig *target_config){ @@ -53,86 +56,146 @@ 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) { - - unsigned short nDim = nVar - 2; - bool turbulent = (donor_config->GetKind_Turb_Model() != TURB_MODEL::NONE); - +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. ---*/ + 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); + 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; + + // The number of spans is available on every rank + const auto nSpanDonor = donor_config->GetnSpanWiseSections(); + + /*--- Fill send buffers. ---*/ + + 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++) { + 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; + } + } +#ifdef HAVE_MPI + /*--- Gather data. ---*/ + 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 + + 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, + buffDonorVar.data(), nSpanDonorVars, MPI_DOUBLE, + SU2_MPI::GetComm()); + + 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 (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 + } + } +#endif + + /*--- This rank does not need to do more work. ---*/ + if (!(markTarget != -1 && markDonor != -1)) continue; + + /*--- Loop over target spans. ---*/ + unsigned long nTargetSpan = target_config->GetnSpanWiseSections() + 1; + + for (auto iTargetSpan = 0ul; iTargetSpan < nTargetSpan; iTargetSpan++) { + + 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 ---*/ + RecoverTarget_Span_Endwall(sendDonorVar, donorSpan); + + SetTarget_Variable(target_solution, target_geometry, target_config, markTarget, iTargetSpan, 0); + } + else { + /*--- Get the global index of interpolation coefficient. ---*/ + const auto donorCoeff = targetSpan.coefficient; + + /*--- Recover the Target_Variable from the buffer of variables. ---*/ + RecoverTarget_Span(sendDonorVar, donorSpan, 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, 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]; + 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(nDim == 3){ - Donor_Variable[4] = donor_solution->GetAverageTurboVelocity(Marker_Donor, iSpan)[2]; + 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) { - - unsigned short nDim = nVar - 2; - bool turbulent = (target_config->GetKind_Turb_Model() != TURB_MODEL::NONE); - - - 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]); - - if(nDim == 3){ - target_solution->SetExtAverageTurboVelocity(Marker_Target, iSpan, 2, Target_Variable[4]); - } - - 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]); - } + 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 } -void CMixingPlaneInterface::SetAverageValues(CSolver *donor_solution, CSolver *target_solution, - unsigned short donorZone){ - unsigned short iSpan; +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) { + /*--- Set the mixing plane solution with the value of the Target Variable ---*/ - 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); + unsigned short iDonorSpan = target_solution->GetnMixingStates(Marker_Target, Span_Target); + for (unsigned short 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/interfaces/cfd/CSlidingInterface.cpp b/SU2_CFD/src/interfaces/cfd/CSlidingInterface.cpp index a11725fdcfd2..835fb8f79b01 100644 --- a/SU2_CFD/src/interfaces/cfd/CSlidingInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CSlidingInterface.cpp @@ -40,6 +40,7 @@ CSlidingInterface::CSlidingInterface(unsigned short val_nVar, unsigned short val valAggregated = false; nVar = val_nVar; + InterfaceType = ENUM_TRANSFER::SLIDING_INTERFACE; } diff --git a/SU2_CFD/src/interfaces/fsi/CDiscAdjFlowTractionInterface.cpp b/SU2_CFD/src/interfaces/fsi/CDiscAdjFlowTractionInterface.cpp index 053ad71cc30b..a6484ac382ce 100644 --- a/SU2_CFD/src/interfaces/fsi/CDiscAdjFlowTractionInterface.cpp +++ b/SU2_CFD/src/interfaces/fsi/CDiscAdjFlowTractionInterface.cpp @@ -34,6 +34,7 @@ CDiscAdjFlowTractionInterface::CDiscAdjFlowTractionInterface(unsigned short val_nVar, unsigned short val_nConst, const CConfig *config, bool conservative_) : CFlowTractionInterface(val_nVar, val_nConst, config, conservative_) { + InterfaceType = ENUM_TRANSFER::FLOW_TRACTION; } void CDiscAdjFlowTractionInterface::GetPhysical_Constants(CSolver *flow_solution, CSolver *struct_solution, diff --git a/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp b/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp index 2ccaec971a00..52d9323c9efc 100644 --- a/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp +++ b/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp @@ -33,6 +33,7 @@ CDisplacementsInterface::CDisplacementsInterface(unsigned short val_nVar, unsigned short val_nConst) : CInterface(val_nVar, val_nConst) { + InterfaceType = ENUM_TRANSFER::BOUNDARY_DISPLACEMENTS; } void CDisplacementsInterface::GetDonor_Variable(CSolver *struct_solution, CGeometry *struct_geometry, diff --git a/SU2_CFD/src/interfaces/fsi/CFlowTractionInterface.cpp b/SU2_CFD/src/interfaces/fsi/CFlowTractionInterface.cpp index e42aabe73358..195716b34f42 100644 --- a/SU2_CFD/src/interfaces/fsi/CFlowTractionInterface.cpp +++ b/SU2_CFD/src/interfaces/fsi/CFlowTractionInterface.cpp @@ -38,6 +38,7 @@ CFlowTractionInterface::CFlowTractionInterface(unsigned short val_nVar, unsigned const CConfig *config, bool conservative_) : CInterface(val_nVar, val_nConst), conservative(conservative_) { + InterfaceType = ENUM_TRANSFER::FLOW_TRACTION; } void CFlowTractionInterface::Preprocess(const CConfig *flow_config, const CConfig *struct_config, diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 2482c0b4a476..b6074082c8cf 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -403,18 +403,21 @@ void CDiscAdjFluidIteration::InitializeAdjoint(CSolver***** solver, CGeometry*** void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** geometry, CConfig** config, unsigned short iZone, unsigned short iInst, RECORDING kind_recording) { - SU2_ZONE_SCOPED + auto solvers0 = solver[iZone][iInst][MESH_0]; auto geometry0 = geometry[iZone][iInst][MESH_0]; 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(); @@ -463,7 +464,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, RECORDING kind_recording) { - SU2_ZONE_SCOPED + auto solvers0 = solver[iZone][iInst][MESH_0]; auto geometry0 = geometry[iZone][iInst][MESH_0]; @@ -476,7 +477,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())) { @@ -486,16 +487,23 @@ 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()) { + 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); + } + } 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/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 35e2905a7c5e..f86f52586f7d 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -227,23 +227,24 @@ 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); + 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); 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(), @@ -261,9 +262,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) { - SU2_ZONE_SCOPED - +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]; @@ -296,10 +295,6 @@ void CFluidIteration::UpdateRamp(CGeometry**** geometry_container, CConfig** con 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); - } } } @@ -364,41 +359,6 @@ void CFluidIteration::UpdateRamp(CGeometry**** geometry_container, CConfig** con } } -void CFluidIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container, unsigned long ExtIter) { - SU2_ZONE_SCOPED - - 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, @@ -445,6 +405,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 eab360cb34be..e0ede7e9b4cf 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -213,3 +213,23 @@ 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, unsigned short val_iZone) { + TurbomachineryStagePerformance = std::make_shared(*fluid); +} + +void CIteration::ComputeTurboPerformance(CSolver***** solver, CGeometry**** geometry_container, CConfig** config_container) { + // Computes the turboperformance per blade in zone iBlade + const auto nZone = config_container[ZONE_0]->GetnZone(); + + if (rank == MASTER_NODE) { + auto TurbomachineryBladePerformances = GetBladesPerformanceVector(solver, nZone); + + auto nSpan = config_container[ZONE_0]->GetnSpanWiseSections(); + auto InState = TurbomachineryBladePerformances[ZONE_0]->GetBladesPerformances().at(nSpan)->GetInletState(); + nSpan = config_container[nZone-1]->GetnSpanWiseSections(); + auto OutState = TurbomachineryBladePerformances[nZone-1]->GetBladesPerformances().at(nSpan)->GetOutletState(); + + TurbomachineryStagePerformance->ComputePerformanceStage(InState, OutState, config_container[nZone-1]); + } +} diff --git a/SU2_CFD/src/iteration/CTurboIteration.cpp b/SU2_CFD/src/iteration/CTurboIteration.cpp index 482e4c053957..90f83995927b 100644 --- a/SU2_CFD/src/iteration/CTurboIteration.cpp +++ b/SU2_CFD/src/iteration/CTurboIteration.cpp @@ -33,37 +33,37 @@ void CTurboIteration::Preprocess(COutput* output, CIntegration**** integration, 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 - /*--- 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()); - } + /*--- 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()); + } 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) { - SU2_ZONE_SCOPED - /*--- 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); + /*--- 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); - /*--- 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]); } void CTurboIteration::InitTurboPerformance(CGeometry* geometry, CConfig** config, CFluidModel* fluid) { - SU2_ZONE_SCOPED - TurbomachineryPerformance = std::make_shared(config, *geometry, *fluid); - TurbomachineryStagePerformance = std::make_shared(*fluid); -} \ No newline at end of file + TurbomachineryStagePerformance = std::make_shared(*fluid); +} diff --git a/SU2_CFD/src/numerics/flow/convection/roe.cpp b/SU2_CFD/src/numerics/flow/convection/roe.cpp index d43b71ab4bcf..73114576d409 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/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index 1acce0660399..fc914796dac7 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -508,6 +508,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/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 0895ed560fc1..fd9bd5356b03 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -513,7 +513,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(su2vector> TurboBladePerfs, CConfig *config, unsigned long TimeIter, unsigned long OuterIter, @@ -525,8 +525,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); @@ -539,7 +537,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[iZone]->GetBladesPerformances().at(nSpan); TurboInOut<<" BLADE ROW INDEX "< T TurboInOut << "Mass Flow " << BladePerf->GetInletState().GetMassFlow() << BladePerf->GetOutletState().GetMassFlow(); TurboInOut << "Mach " << BladePerf->GetInletState().GetMachValue() << BladePerf->GetOutletState().GetMachValue(); TurboInOut << "Abs Flow Angle " << BladePerf->GetInletState().GetAbsFlowAngle()*180/PI_NUMBER << BladePerf->GetOutletState().GetAbsFlowAngle()*180/PI_NUMBER; + TurboInOut << "Rel Flow Angle " << BladePerf->GetInletState().GetFlowAngle()*180/PI_NUMBER << BladePerf->GetOutletState().GetFlowAngle()*180/PI_NUMBER; TurboInOut.PrintFooter(); } cout< TurboStagePerf, std::shared_ptr TurboPerf, CConfig *config) { +void CFlowCompOutput::SetTurboMultiZonePerformance_Output(std::shared_ptr TurboStagePerf, su2vector> TurboPerf, CConfig *config) { stringstream TurboMZPerf; @@ -589,11 +588,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, su2vector> 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[iZone]->GetBladesPerformances().at(nSpan); stringstream tag; tag << iZone + 1; @@ -622,6 +620,8 @@ void CFlowCompOutput::LoadTurboHistoryData(std::shared_ptrGetOutletState().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()); } @@ -635,7 +635,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(su2vector> TurboBladePerfs, CGeometry *geometry, CConfig **config, unsigned short val_iZone) { string inMarker_Tag, outMarker_Tag, inMarkerTag_Mix; unsigned short nZone = config[val_iZone]->GetnZone(); @@ -647,14 +647,12 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetBladesPerformances(); - /*--- Start of write file turboperformance spanwise ---*/ SpanWiseValuesIn = geometry->GetSpanWiseValue(INFLOW); SpanWiseValuesOut = geometry->GetSpanWiseValue(OUTFLOW); /*--- Writing Span wise inflow thermodynamic quantities. ---*/ - spanwise_performance_filename = "TURBOMACHINERY/inflow_spanwise_thermodynamic_values.dat"; + spanwise_performance_filename = "TURBOMACHINERY/inflow_spanwise_thermodynamic_values"; if (nZone > 1) { spanwise_performance_filename.append("_" + std::to_string(val_iZone) + ".dat"); } else { @@ -680,7 +678,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); iSpan++){ - const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan); + const auto& BladePerf = TurboBladePerfs[val_iZone]->GetBladesPerformances().at(iSpan); file.width(30); file << SpanWiseValuesIn[iSpan]; file.width(15); file << iSpan; @@ -692,12 +690,13 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetInletState().GetTotalEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); file.width(30); file << BladePerf->GetInletState().GetDensity()*config[ZONE_0]->GetDensity_Ref(); file.width(30); file << BladePerf->GetInletState().GetEntropy()*config[ZONE_0]->GetEnergy_Ref()/config[ZONE_0]->GetTemperature_Ref(); + 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 { @@ -724,7 +723,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); iSpan++){ - const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan); + const auto& BladePerf = TurboBladePerfs[val_iZone]->GetBladesPerformances().at(iSpan); file.width(30); file << SpanWiseValuesOut[iSpan]; file.width(15); file << iSpan; @@ -736,12 +735,13 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetOutletState().GetTotalEnthalpy()*config[ZONE_0]->GetEnergy_Ref(); file.width(30); file << BladePerf->GetOutletState().GetDensity()*config[ZONE_0]->GetDensity_Ref(); file.width(30); file << BladePerf->GetOutletState().GetEntropy()*config[ZONE_0]->GetEnergy_Ref()/config[ZONE_0]->GetTemperature_Ref(); + 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 { @@ -774,7 +774,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); iSpan++){ - const auto& BladePerf = BladePerformance.at(val_iZone).at(iSpan); + const auto& BladePerf = TurboBladePerfs[val_iZone]->GetBladesPerformances().at(iSpan); file.width(30); file << SpanWiseValuesIn[iSpan]; file.width(15); file << iSpan; @@ -838,7 +838,7 @@ void CFlowCompOutput::WriteTurboSpanwisePerformance(std::shared_ptrGetnSpanWiseSections(); iSpan++){ - const auto& BladePerf = BladePerformance.at(val_iZone).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/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index b0e16fedcc8d..06f0534e11af 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -4301,6 +4301,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/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 5cc9a1fdd208..1c0cb1fa219c 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -230,7 +230,7 @@ void COutput::SetHistoryOutput(CGeometry *geometry, } -void COutput::SetHistoryOutput(CGeometry ****geometry, CSolver *****solver, CConfig **config, 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), su2vector> TurboBladePerfs, unsigned short val_iZone, unsigned long TimeIter, unsigned long OuterIter, unsigned long InnerIter, unsigned short val_iInst){ unsigned long Iter= InnerIter; @@ -239,19 +239,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 2d7e0138ff48..9fc1f4d8d81b 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; } @@ -160,51 +159,46 @@ void CPropellorBladePerformance::ComputePerformance(const CTurbomachineryCombine // TODO: to be implemented } -CTurboOutput::CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel) { - unsigned short nBladesRow = config[ZONE_0]->GetnMarker_Turbomachinery(); +CTurboOutput::CTurboOutput(CConfig** config, const CGeometry& geometry, CFluidModel& fluidModel, unsigned short iBladeRow) { 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, @@ -219,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, @@ -265,6 +275,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 +285,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 diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 3194e28b6d37..d3111ef2290c 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -184,21 +184,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); @@ -207,7 +216,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; @@ -219,14 +228,26 @@ 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()){ - BPressure = config->GetPressureOut_BC(); - Temperature = config->GetTotalTemperatureIn_BC(); + 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()); + TemperatureValue = SU2_TYPE::GetValue(config->GetTotalTemperatureIn_BC()); + value_is_set = true; + } + + BPressure = BPressureValue; + Temperature = TemperatureValue; + + /*--- Register the variables for AD. ---*/ if (!reset){ AD::RegisterInput(BPressure); @@ -243,15 +264,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. ---*/ @@ -277,7 +308,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. ---*/ @@ -407,9 +445,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); diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index c58f96c3e4ef..ed1698757216 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -35,9 +35,10 @@ #include "../../include/fluid/CDataDrivenFluid.hpp" #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" - CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh, const bool navier_stokes) : CFVMFlowSolverBase(*geometry, *config) { @@ -358,8 +359,9 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, } CEulerSolver::~CEulerSolver() { - SU2_ZONE_SCOPED - + for (auto& vec : MixingState) { + for (auto ptr : vec) delete [] ptr; + } for(auto& model : FluidModel) delete model; } @@ -385,38 +387,32 @@ void CEulerSolver::InstantiateEdgeNumerics(const CSolver* const* solver_containe END_SU2_OMP_SAFE_GLOBAL_ACCESS } -void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ - SU2_ZONE_SCOPED +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); 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; + AverageRelTangVelocity = 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); } @@ -438,6 +434,8 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ 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); @@ -458,6 +456,25 @@ void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ CkOutflow2[iMarker] = CkOutflow1[iMarker]; } } + + /*--- 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); + + MixingState.resize(nMarker); + MixingStateNodes.resize(nMarker); + + 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); + MixingStateNodes[iMarkerMP].resize(nSpanWiseSections+1); + } + } + + TurbomachineryPerformance = std::make_shared(config_container, *geometry, *GetFluidModel(), iZone); } void CEulerSolver::Set_MPI_ActDisk(CSolver **solver_container, CGeometry *geometry, CConfig *config) { @@ -4807,6 +4824,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; @@ -5621,6 +5642,20 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain for (iDim = 0; iDim < nDim; iDim++) ProjVelocity_i += Velocity_i[iDim]*UnitNormal[iDim]; + 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; + } + ExtAverageDensity = donorAverages[0]; + ExtAveragePressure = donorAverages[1]; + ExtAverageTurboVelocity[0] = donorAverages[2]; + ExtAverageTurboVelocity[1] = donorAverages[3]; + if (nDim == 3) ExtAverageTurboVelocity[2] = donorAverages[4]; + /*--- Build the external state u_e from boundary data and internal node ---*/ switch(config->GetKind_Data_Riemann(Marker_Tag)) @@ -5661,15 +5696,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); } @@ -5697,7 +5732,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 --- */ @@ -6027,8 +6062,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) { - SU2_ZONE_SCOPED - /* 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; @@ -6272,7 +6306,6 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu deltaSpan = SpanWiseValues[nSpanWiseSections-1]*spanPercent; coeffrelfacAvg = (relfacAvgCfg - extrarelfacAvg)/deltaSpan; } - for (iSpan= 0; iSpan < nSpanWiseSections ; iSpan++){ /*--- Compute under relaxation for the Hub and Shroud Avg and Fourier Coefficient---*/ if(nDim == 3){ @@ -6302,7 +6335,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]; @@ -6311,6 +6344,22 @@ 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 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; + } + 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)){ case TOTAL_CONDITIONS_PT: @@ -6428,16 +6477,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]; } @@ -6450,16 +6499,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--- */ @@ -8883,11 +8932,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){ @@ -8904,6 +8958,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], @@ -8924,6 +8988,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; } } } @@ -8933,29 +9000,34 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon #ifdef HAVE_MPI - /*--- Add information using all the nodes ---*/ - - su2double MyTotalAreaDensity = TotalAreaDensity; - su2double MyTotalAreaPressure = TotalAreaPressure; + 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()); + /*--- 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){ @@ -8971,6 +9043,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)); @@ -9001,6 +9077,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)); @@ -9030,7 +9110,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 ---*/ @@ -9052,7 +9133,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(); @@ -9083,6 +9164,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){ @@ -9160,6 +9251,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) { @@ -9194,7 +9289,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; iVarGetnDim(); + vector TurboPrimitiveIn, TurboPrimitiveOut; + if (rank == MASTER_NODE) { + 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, GetTangGridVelIn(iBlade, iSpan)); + auto spanOutletPrimitive = CTurbomachineryPrimitiveState(TurboPrimitiveOut, nDim, GetTangGridVelOut(iBlade, iSpan)); + bladePrimitives.push_back(CTurbomachineryCombinedPrimitiveStates(spanInletPrimitive, spanOutletPrimitive)); + } + TurbomachineryPerformance->ComputeTurbomachineryPerformance(bladePrimitives, iBlade); + } +} \ No newline at end of file diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index fb8d2bf5d484..67efee254f46 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -1135,10 +1135,9 @@ void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_c const auto nSpanWiseSections = config->GetnSpanWiseSections(); /*--- Loop over all the vertices on this boundary marker ---*/ - for (auto iSpan = 0u; iSpan < nSpanWiseSections ; iSpan++){ - + for (auto iSpan = 0u; iSpan < nSpanWiseSections; iSpan++){ su2double extAverageNu[MAXNVAR] = {0.0}; - extAverageNu[0] = solver_container[FLOW_SOL]->GetExtAverageNu(val_marker, iSpan); + extAverageNu[0] = solver_container[FLOW_SOL]->GetMixingState(val_marker, iSpan, 5); /*--- 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 86f8bc06ad93..65d6cc3f8962 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -834,8 +834,8 @@ 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); + 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}; /*--- Loop over all the vertices on this boundary marker ---*/ 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 ef79eb900523..9aee12469fa9 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) 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 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..ecb25309f668 --- /dev/null +++ b/TestCases/disc_adj_turbomachinery/axial_stage_2D/Axial_stage2D.cfg @@ -0,0 +1,188 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: 2D Discrete Adjoint Axial stage % +% Author: J. Kelly % +% Institution: University of Liverpool. % +% Date: Oct 11th, 2025 % +% File Version 8.4.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= YES +% +% -------------------- 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 --------% +% +MARKER_TURBOMACHINERY= (inflow, outmix, inmix, outflow) +MARKER_ZONE_INTERFACE= (outmix, inmix) +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= 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) +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 +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 ------------------------% +% +DEFORM_LINEAR_SOLVER= FGMRES +DEFORM_LINEAR_SOLVER_PREC= ILU +DEFORM_LINEAR_SOLVER_ITER= 1000 +DEFORM_NONLINEAR_ITER= 1 +DEFORM_LINEAR_SOLVER_ERROR= 1E-14 +DEFORM_CONSOLE_OUTPUT= YES +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] +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/hybrid_regression.py b/TestCases/hybrid_regression.py index 57074e8ea998..55e6a9d45816 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -562,7 +562,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 diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 7f10753db6e3..961c82fdfbe0 100755 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1144,7 +1144,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 @@ -1160,7 +1160,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 @@ -1177,8 +1177,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) ###################################### @@ -1778,7 +1778,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/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 812c8aeb9dab..cdcb75b11229 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -231,10 +231,19 @@ 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, 2.599441, 2.336307, 2.140979, 0.786891] - 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 + 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.000000, -6.606323, -7.139638] + discadj_axial_stage.test_vals_aarch64 = [79.000000, -6.606323, -7.139638] + test_list.append(discadj_axial_stage) + ################################### ### Structural Adjoint ### ################################### diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 279923612d6b..d87799b04210 100755 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -891,7 +891,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 @@ -907,7 +907,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 @@ -915,7 +915,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) @@ -924,8 +924,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 6d0d424251ad..a767480f1f12 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.130532, -1.575494, -0.005113, 0.000007] + 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.885032, -1.775564, 3994.600000, 0.000002] + 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.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 + 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, -7.205880, -7.864736] + discadj_axial_stage.test_vals_aarch64 = [79.000000, -6.605594, -7.138121] + 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.931715, -10.103841, 3.0937e-11, -1.7573e-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) ###################################