From 594c388a6afc701f0dc1ef1bb84b427a54e37c0d Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 15 Apr 2026 16:57:44 +0200 Subject: [PATCH 1/2] Change nested classes to friend classes --- .../drivers/CDiscAdjMultizoneDriver.hpp | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp index 784fae55a85d..544adaae61cd 100644 --- a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp +++ b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp @@ -36,38 +36,19 @@ * \brief Block Gauss-Seidel driver for multizone / multiphysics discrete adjoint problems. * \ingroup DiscAdj */ -class CDiscAdjMultizoneDriver : public CMultizoneDriver { - -protected: #ifdef CODI_FORWARD_TYPE using Scalar = su2double; #else using Scalar = passivedouble; #endif - class AdjointProduct : public CMatrixVectorProduct { - public: - CDiscAdjMultizoneDriver* const driver; - const unsigned short iZone = 0; - mutable unsigned long iInnerIter = 0; - - AdjointProduct(CDiscAdjMultizoneDriver* d, unsigned short i) : driver(d), iZone(i) {} - - inline void operator()(const CSysVector & u, CSysVector & v) const override { - driver->SetAllSolutions(iZone, true, u); - driver->Iterate(iZone, iInnerIter, true); - driver->GetAllSolutions(iZone, true, v); - v -= u; - ++iInnerIter; - } - }; +class CDiscAdjMultizoneDriver : public CMultizoneDriver { - class Identity : public CPreconditioner { - public: - inline bool IsIdentity() const override { return true; } - inline void operator()(const CSysVector & u, CSysVector & v) const override { v = u; } - }; +protected: + friend class AdjointProduct; + friend class Identity; + /*! * \brief Kinds of recordings. */ @@ -304,3 +285,26 @@ class CDiscAdjMultizoneDriver : public CMultizoneDriver { } }; + +class AdjointProduct : public CMatrixVectorProduct { +public: + CDiscAdjMultizoneDriver* const driver; + const unsigned short iZone = 0; + mutable unsigned long iInnerIter = 0; + + AdjointProduct(CDiscAdjMultizoneDriver* d, unsigned short i) : driver(d), iZone(i) {} + + inline void operator()(const CSysVector & u, CSysVector & v) const override { + driver->SetAllSolutions(iZone, true, u); + driver->Iterate(iZone, iInnerIter, true); + driver->GetAllSolutions(iZone, true, v); + v -= u; + ++iInnerIter; + } +}; + +class Identity : public CPreconditioner { +public: + inline bool IsIdentity() const override { return true; } + inline void operator()(const CSysVector & u, CSysVector & v) const override { v = u; } +}; \ No newline at end of file From 2821ba1325e34c748b61e1564d52068bdf53e22a Mon Sep 17 00:00:00 2001 From: EvertBunschoten Date: Wed, 15 Apr 2026 16:58:13 +0200 Subject: [PATCH 2/2] Include discrete adjoint multizone driver in python wrapper --- SU2_PY/pySU2/pySU2ad.i | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SU2_PY/pySU2/pySU2ad.i b/SU2_PY/pySU2/pySU2ad.i index 65ddbfe30369..d0b15fe5cee7 100644 --- a/SU2_PY/pySU2/pySU2ad.i +++ b/SU2_PY/pySU2/pySU2ad.i @@ -39,6 +39,7 @@ threads="1" %{ #include "../../Common/include/containers/CPyWrapperMatrixView.hpp" #include "../../SU2_CFD/include/drivers/CDiscAdjSinglezoneDriver.hpp" +#include "../../SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp" #include "../../SU2_CFD/include/drivers/CDriver.hpp" #include "../../SU2_CFD/include/drivers/CDriverBase.hpp" #include "../../SU2_CFD/include/drivers/CMultizoneDriver.hpp" @@ -98,4 +99,5 @@ const unsigned int ZONE_1 = 1; /*!< \brief Definition of the first grid domain. %include "../../SU2_CFD/include/drivers/CSinglezoneDriver.hpp" %include "../../SU2_CFD/include/drivers/CMultizoneDriver.hpp" %include "../../SU2_CFD/include/drivers/CDiscAdjSinglezoneDriver.hpp" +%include "../../SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp" %include "../../SU2_DEF/include/drivers/CDiscAdjDeformationDriver.hpp"