Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these no longer protected?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Scalar type needs to be visible to the AdjointProduct and Identity class headers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do it this way instead 38cddb7

I don't want typedefs in header files, which will then propagate to anything that includes the same header, possibly aliasing or coliding with other stuff, also the helper classes can be hidden.


class AdjointProduct : public CMatrixVectorProduct<Scalar> {
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<Scalar> & u, CSysVector<Scalar> & 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<Scalar> {
public:
inline bool IsIdentity() const override { return true; }
inline void operator()(const CSysVector<Scalar> & u, CSysVector<Scalar> & v) const override { v = u; }
};
protected:

friend class AdjointProduct;
friend class Identity;

/*!
* \brief Kinds of recordings.
*/
Expand Down Expand Up @@ -304,3 +285,26 @@ class CDiscAdjMultizoneDriver : public CMultizoneDriver {
}

};

class AdjointProduct : public CMatrixVectorProduct<Scalar> {
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<Scalar> & u, CSysVector<Scalar> & 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<Scalar> {
public:
inline bool IsIdentity() const override { return true; }
inline void operator()(const CSysVector<Scalar> & u, CSysVector<Scalar> & v) const override { v = u; }
};
2 changes: 2 additions & 0 deletions SU2_PY/pySU2/pySU2ad.i
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Loading