Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Aero-Structural Discrete Adjoint Sensitivities and Python Wrapper Developments #1750

Open
wants to merge 133 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 117 commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
9491e2b
adding GetStates() function
WallyMaier May 7, 2020
92ae46e
fixing output + adding GetAIP
WallyMaier May 19, 2020
5146f8d
adding in area extraction
WallyMaier Jul 1, 2020
e9408c7
clearing ninja/meson stuff
WallyMaier Sep 17, 2020
85ba068
adding HYBRID option for AIP averaging
WallyMaier Oct 22, 2020
d2db580
adding in Average normal velocity for DA
WallyMaier Dec 15, 2020
42d9d78
fixing function name
WallyMaier Dec 15, 2020
68eb015
Add methods to set AoA and AoS
patelha57 Jun 28, 2021
1c02df0
Add method to get conservative states
patelha57 Jun 28, 2021
b984e67
Add method to get surface coordinates
patelha57 Jun 28, 2021
2d37896
Add method to get fluid volume coordinates
patelha57 Jun 28, 2021
8b43265
Add method to get flow residuals
patelha57 Jun 28, 2021
7b4fcf0
Merge code from feature_QUAD and resolve conflicts
patelha57 Jun 29, 2021
4239d0c
Fix compilation errors, comment out GetAIP()
patelha57 Jun 29, 2021
1eb61de
Add method to get aero forces
patelha57 Jun 30, 2021
6167cf1
Generalize GetConservativeStates() and GetResiduals() for 2D cases
patelha57 Jul 19, 2021
363f288
Add method to set conservative states
patelha57 Jul 20, 2021
588fa38
Add methods to get flow states and flow residuals at marker, minor cl…
patelha57 Aug 11, 2021
1d1c062
Add methods to get aero moment coefficients
patelha57 Aug 24, 2021
9842113
Implement residual-based DA solver, add pysu2 methods for sensitivites
patelha57 Oct 15, 2021
7b3999c
Merge small changes
aa-g Oct 19, 2021
da2933b
[WIP] Implement dxadua sensitivity
aa-g Oct 21, 2021
eb64f51
Add pysu2 methods for dfa/dua and dxv/dua sens
patelha57 Oct 22, 2021
17c4cd7
Add new methods to CDeformationDriver
patelha57 Oct 27, 2021
5cc8301
[WIP] Consolidate and extend implementation of Python interface gette…
aa-g Nov 5, 2021
440710f
[WIP] Match implementation of getters/setters in CDeformationDriver w…
aa-g Nov 5, 2021
98440d5
Implement element ID and connectivities in Python API
aa-g Nov 5, 2021
099651d
[WIP] Corrections to the previous commit
aa-g Nov 6, 2021
0828142
Fix bugs introduced in previous commits
aa-g Nov 8, 2021
b2f6e1a
Reintroduce sensitivities w.r.t. mesh coordinates
aa-g Nov 18, 2021
6770bde
Add new pysu2 functions, minor code cleanup
patelha57 Dec 10, 2021
7f123c4
Add more pysu2 functions, minor code cleanup
patelha57 Dec 15, 2021
a280b00
Extend Python interface for MPI domain handling
aa-g Jan 17, 2022
eb3f5a3
More cleanup and standardization of pysu2
patelha57 Jan 27, 2022
d296e11
Even more cleanup and standardization of pysu2
patelha57 Jan 31, 2022
9d557c6
Merge 'develop' branch into 'feature_pysu2_fsi_adjoint'
patelha57 Feb 22, 2022
feeae81
Introduce CDriverBase, merge latest code from PR1300
patelha57 Feb 23, 2022
6d26bcb
Refactor residual-based discrete adjoints into CDiscAdjResidualSolver
aa-g Mar 2, 2022
b656b6d
Standardize and consolidate pysu2 methods
patelha57 Mar 8, 2022
fe08245
Update Python API, add overloaded getters/setters
patelha57 Mar 13, 2022
ba1275e
Fix Python wrapper regression tests, update external submodules
patelha57 Mar 13, 2022
e6e9d10
Update Python API, add CHT and viscosity pysu2 methods
patelha57 Mar 14, 2022
c1bac69
Small fix to SWIG templates
patelha57 Mar 15, 2022
9203686
Add pysu2 methods for nonequilibrium flow solver
patelha57 Mar 21, 2022
6472bdd
Add overloaded methods to Python API
aa-g Mar 22, 2022
333d486
Merge latest commit from hpatel
aa-g Mar 22, 2022
446287b
Rename some methods for consistency
aa-g Mar 28, 2022
221fa74
Revert "Rename some methods for consistency"
aa-g Mar 28, 2022
0255a46
Rename some methods for consistency
aa-g Mar 28, 2022
2984514
Apply clang-format
aa-g Mar 28, 2022
74e0814
Remove Vertex and Element Color getters/setters
aa-g Mar 28, 2022
135f70a
Fix bug in GetMarkerVertexNormals
aa-g Mar 28, 2022
fdff7c5
Let Get*ElementConnectivities return node indices before RCM sorting
aa-g Mar 29, 2022
d25381e
Fix a mistake in previous commit
aa-g Mar 29, 2022
2fce114
Rename additional methods for consistency
aa-g Mar 29, 2022
0261b59
Add getters for total sensitivities on CDiscAdjDeformationDriver
aa-g Apr 5, 2022
14e0f9d
Fix some inconsistent Getter/Setter names
aa-g Apr 11, 2022
f94801f
Fix CDiscAdjResidualSolver methods
aa-g Apr 14, 2022
b2ddd96
Fix issues in computation of total derivatives
aa-g Apr 21, 2022
03b6b66
Output pysu2/pysu2ad with .so extension on OSX
patelha57 Apr 23, 2022
3370e34
Fix behaviour of GetDV_Values when no DVs are defined
aa-g Apr 25, 2022
c816c55
Fix extraction of coordinate sensitivities using mesh solver
aa-g Apr 27, 2022
88d1149
Draft linear solver solution of residual-based adjoint system
aa-g Apr 29, 2022
17a036c
[WIP] Started implementing preconditioner for adjoint system
aa-g May 2, 2022
985884a
[WIP] Implement a working preconditioner for the residual-based formu…
aa-g May 4, 2022
0c3918f
Add pysu2 functions for FFD design variables
patelha57 Nov 19, 2022
3862eab
Cleanup Python wrapper structure
patelha57 Nov 23, 2022
07e1b20
Update CDriverBase
patelha57 Dec 12, 2022
68a2b35
Update SU2_DEF and SU2_DOT
patelha57 Dec 12, 2022
0ae3ba1
Update CDeformationDriver
patelha57 Dec 12, 2022
1e9255b
Update CDiscAdjDeformationDriver
patelha57 Dec 13, 2022
07707a2
Add SetAdjointSourceTerm(), apply clang format, cleanup code
patelha57 Dec 13, 2022
b846eca
Merge 'develop' into 'feature_pysu2_fsi_adjoint'
patelha57 Dec 14, 2022
4d8defa
Fix variable name errors, minor formatting updates
patelha57 Dec 14, 2022
2672ce6
Fix unused variable, OMP, and code block errors
patelha57 Dec 14, 2022
200eaa1
Fix include headers, OMP block errors, and code formatting
patelha57 Dec 14, 2022
07dd33c
Fix index in GetMarkerPrimitiveStates()
patelha57 Feb 16, 2023
334c8cb
Merge 'develop' branch into 'feature_pysu2_fsi_adjoint'
patelha57 May 27, 2023
c4af20a
Merge 'develop' branch into 'feature_pysu2_fsi_adjoint'
patelha57 Oct 23, 2023
062eb33
Remove CDriverBase from Common directory
patelha57 Oct 24, 2023
fd2484b
Revert format changes in CConfig.hpp
patelha57 Oct 24, 2023
73cf9d6
Revert format changes in option_structure.hpp
patelha57 Oct 24, 2023
d6e4191
Revert format changes in CDriver.hpp
patelha57 Oct 24, 2023
b025b37
Revert format changes in CDiscAdjSolver files
patelha57 Oct 24, 2023
a5905a8
Revert format changes in CSolver.hpp
patelha57 Oct 24, 2023
e092c6d
Revert format changes in CIntegration.cpp
patelha57 Oct 25, 2023
4a268bb
Update CDiscAdjSinglezoneDriver files
patelha57 Oct 25, 2023
3e04048
Remove functions to extract residuals from python_wrapper_structure.cpp
patelha57 Oct 25, 2023
3a493fa
Revert changes for aero-propulsion simulation outputs
patelha57 Oct 25, 2023
021b7dc
Revert changes to pySU2 meson.build
patelha57 Oct 25, 2023
1886282
Remove AMGIO external module
patelha57 Oct 25, 2023
b868478
Remove ILU matrix debug functions
patelha57 Oct 25, 2023
9c09e04
Convert ENUM_DISC_ADJ_TYPE to enum class
patelha57 Oct 25, 2023
1f40a25
Remove thermal conductivity and viscosity pysu2 functions
patelha57 Oct 26, 2023
c2402c6
Update documentation for new sensitivity functions in CSolver.hpp
patelha57 Oct 26, 2023
27d8848
Remove redundant GetAllSolutions() and SetAllSolutions() from CDiscAd…
patelha57 Oct 26, 2023
ef94155
Remove boilerplate functions in CDriver.hpp and python_wrapper_struct…
patelha57 Oct 26, 2023
ced4670
Add matrix view for Residuals and MarkerResiduals
patelha57 Oct 26, 2023
7916d53
Remove redundant GetTotalNumberOfVariables() from CDiscAdjSinglezoneD…
patelha57 Oct 26, 2023
add0fe4
Update function names and fix ENUM_DISC_ADJ_TYPE usage
patelha57 Oct 26, 2023
af113be
Add GetMarkerForceSensitivities() to CDriver.hpp
patelha57 Oct 26, 2023
dbfd39f
Small documentation fix for CDriver.hpp
patelha57 Oct 30, 2023
1467aab
Add name to AUTHORS.md
patelha57 Oct 30, 2023
918181f
Update documentation in CDriver.hpp
patelha57 Oct 30, 2023
62f2969
Revert 'Add matrix view for Residuals and MarkerResiduals'
patelha57 Nov 3, 2023
60f3328
Merge 'develop' branch into 'feature_pysu2_fsi_adjoint'
patelha57 Jan 18, 2024
1b52055
Cleanup CDiscAdjSinglezoneDriver.cpp
patelha57 Feb 2, 2024
ca15ae5
Fix uninitialized variable error in regression tests
patelha57 Feb 2, 2024
193d27a
Fix small errors with regression tests
patelha57 Feb 2, 2024
7f448c7
Merge 'develop' branch into 'feature_pysu2_fsi_adjoint'
patelha57 Feb 7, 2024
fe7f82c
Fix type conversion error in CDiscAdjSinglezoneDriver.hpp
patelha57 Feb 13, 2024
99f8def
Apply clang format
patelha57 Feb 13, 2024
8d59b45
Fix function names in Python regression tests
patelha57 Feb 13, 2024
b78601c
Fix UpdateBoundaryCondition() in Python regression test
patelha57 Feb 13, 2024
f50e216
Remove multiple spaces after operator in Python testcases
patelha57 Feb 13, 2024
96e45c7
Fix angle of attack sensitivity in regression tests
patelha57 Feb 13, 2024
d7c398e
Merge 'develop' branch into 'feature_pysu2_fsi_adjoint'
patelha57 Feb 27, 2024
57423b7
Merge 'develop' branch into 'feature_pysu2_fsi_adjoint'
patelha57 Mar 20, 2024
c446d44
Merge 'develop' branch into 'feature_pysu2_fsi_adjoint'
patelha57 Apr 14, 2024
c087e23
Merge branch 'develop' into feature_pysu2_fsi_adjoint
bigfooted Apr 24, 2024
36ca5fc
Merge 'develop' branch into 'feature_pysu2_fsi_adjoint'
patelha57 Jun 27, 2024
bb016de
Fix errors in python_wrapper_structure.cpp
patelha57 Jun 27, 2024
bd61083
Merge remote-tracking branch 'origin/develop' into feature_pysu2_fsi_…
patelha57 Jul 14, 2024
99458d8
Merge 'develop' into 'feature_pysu2_fsi_adjoint'
patelha57 Aug 2, 2024
a4d1b72
Merge branch 'develop' into 'feature_pysu2_fsi_adjoint'
patelha57 Aug 19, 2024
28fd5e9
Remove (void) from CDiscAdjSinglezoneDriver.hpp
patelha57 Aug 19, 2024
7d7f09a
Remove duplicate heat flux functions
patelha57 Aug 19, 2024
cedef9f
Remove NEMO solver functions
patelha57 Aug 19, 2024
42f03d0
Remove weird symbols from python_wrapper_structure.cpp
patelha57 Aug 22, 2024
c757a3e
Remove functions for speed of sound
patelha57 Aug 22, 2024
d85e07f
Remove duplicate SetMarkerAdjointForces()
patelha57 Aug 22, 2024
43d419a
Merge remote-tracking branch 'upstream/develop' into feature_pysu2_fs…
pcarruscag Jan 2, 2025
963ea60
Merge branch 'develop' into feature_pysu2_fsi_adjoint
bigfooted Jan 6, 2025
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
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Giacomo Baldan
Giulio Gori
Guillaume Bâty
Harichand M V
Harsh Patel
HL Kline
HL Zhi
IndianaStokes
Expand Down
7 changes: 7 additions & 0 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ class CConfig {
long ParMETIS_edgeWgt; /*!< \brief Load balancing weight given to edges. */
unsigned short DirectDiff; /*!< \brief Direct Differentation mode. */
bool DiscreteAdjoint; /*!< \brief AD-based discrete adjoint mode. */
ENUM_DISC_ADJ_TYPE Kind_DiscreteAdjoint; /*!< \brief AD-based discrete adjoint formulation. */
su2double Const_DES; /*!< \brief Detached Eddy Simulation Constant. */
WINDOW_FUNCTION Kind_WindowFct; /*!< \brief Type of window (weight) function for objective functional. */
unsigned short Kind_HybridRANSLES; /*!< \brief Kind of Hybrid RANS/LES. */
Expand Down Expand Up @@ -8798,6 +8799,12 @@ class CConfig {
*/
bool GetDiscrete_Adjoint(void) const { return DiscreteAdjoint; }

/*!
* \brief Get the kind of discrete adjoint solver formulation.
* \return the discrete adjoint indicator.
*/
ENUM_DISC_ADJ_TYPE GetKind_DiscreteAdjoint(void) const { return Kind_DiscreteAdjoint; }

/*!
* \brief Get the number of subiterations while a ramp is applied.
* \return Number of FSI subiters.
Expand Down
19 changes: 19 additions & 0 deletions Common/include/option_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2593,6 +2593,25 @@ static const MapType<std::string, ENUM_STREAMWISE_PERIODIC> Streamwise_Periodic_
MakePair("MASSFLOW", ENUM_STREAMWISE_PERIODIC::MASSFLOW)
};

/*!
* \brief Types of discrete adjoint solver formulations.
*/
enum class ENUM_DISC_ADJ_TYPE {
FIXED_POINT, /*!< \brief Fixed-point discrete-adjoint formulation. */
RESIDUALS /*!< \brief Residual-based discrete-adjoint formulation. */
};
static const MapType<std::string, ENUM_DISC_ADJ_TYPE> DiscreteAdjoint_Map = {
MakePair("FIXED_POINT", ENUM_DISC_ADJ_TYPE::FIXED_POINT)
MakePair("RESIDUALS", ENUM_DISC_ADJ_TYPE::RESIDUALS)
};

enum class ENUM_VARIABLE {
RESIDUALS,
OBJECTIVE,
TRACTIONS,
COORDINATES
};

/*!
* \brief Container to hold Variables for streamwise Periodic flow as they are often used together in places.
*/
Expand Down
2 changes: 2 additions & 0 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,8 @@ void CConfig::SetConfig_Options() {
#endif
/*!\brief MATH_PROBLEM \n DESCRIPTION: Mathematical problem \n Options: DIRECT, ADJOINT \ingroup Config*/
addMathProblemOption("MATH_PROBLEM", ContinuousAdjoint, false, DiscreteAdjoint, discAdjDefault, Restart_Flow, discAdjDefault);
/*!\brief DISC_ADJ_TYPE \n DESCRIPTION: Discrete adjoint problem formulation \n Options: FIXED_POINT, RESIDUALS \ingroup Config*/
addEnumOption("KIND_DISC_ADJ", Kind_DiscreteAdjoint, DiscreteAdjoint_Map, ENUM_DISC_ADJ_TYPE::FIXED_POINT);
/*!\brief KIND_TURB_MODEL \n DESCRIPTION: Specify turbulence model \n Options: see \link Turb_Model_Map \endlink \n DEFAULT: NONE \ingroup Config*/
addEnumOption("KIND_TURB_MODEL", Kind_Turb_Model, Turb_Model_Map, TURB_MODEL::NONE);
/*!\brief SST_OPTIONS \n DESCRIPTION: Specify SST turbulence model options/corrections. \n Options: see \link SST_Options_Map \endlink \n DEFAULT: NONE \ingroup Config*/
Expand Down
204 changes: 198 additions & 6 deletions SU2_CFD/include/drivers/CDiscAdjSinglezoneDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* \file CDiscAdjSinglezoneDriver.hpp
* \brief Headers of the main subroutines for driving single or multi-zone problems.
* The subroutines and functions are in the <i>driver_structure.cpp</i> file.
* \author T. Economon, H. Kline, R. Sanchez
* \author T. Economon, H. Kline, R. Sanchez, H. Patel, A. Gastaldi
* \version 8.0.1 "Harrier"
*
* SU2 Project Website: https://su2code.github.io
Expand All @@ -28,6 +28,10 @@

#pragma once
#include "CSinglezoneDriver.hpp"
#include "../../../Common/include/toolboxes/CQuasiNewtonInvLeastSquares.hpp"
#include "../../../Common/include/linear_algebra/CPreconditioner.hpp"
#include "../../../Common/include/linear_algebra/CMatrixVectorProduct.hpp"
#include "../../../Common/include/linear_algebra/CSysSolve.hpp"

/*!
* \class CDiscAdjSinglezoneDriver
Expand All @@ -38,6 +42,11 @@
*/
class CDiscAdjSinglezoneDriver : public CSinglezoneDriver {
protected:
#ifdef CODI_FORWARD_TYPE
using Scalar = su2double;
#else
using Scalar = su2mixedfloat;
#endif

unsigned long nAdjoint_Iter; /*!< \brief The number of adjoint iterations that are run on the fixed-point solver.*/
RECORDING RecordingState; /*!< \brief The kind of recording the tape currently holds.*/
Expand All @@ -55,6 +64,43 @@ class CDiscAdjSinglezoneDriver : public CSinglezoneDriver {
COutput *direct_output;
CNumerics ***numerics; /*!< \brief Container vector with all the numerics. */

/*!< \brief Fixed-Point corrector that can be applied to inner iterations of the residual-based formulation. */
CQuasiNewtonInvLeastSquares<passivedouble> Corrector;

/*!< \brief Members to use GMRES to drive inner iterations (alternative to quasi-Newton) of the residual-based formulation. */
static constexpr unsigned long KrylovMinIters = 3;
const Scalar KrylovSysTol = 0.00001;
const Scalar KrylovPreTol = 0.1;
bool KrylovSet = false;

CSysMatrix<Scalar> CopiedJacobian;
CSysSolve<Scalar> AdjSolver;
CSysVector<Scalar> AdjRHS;
CSysVector<Scalar> AdjSol;
CPreconditioner<Scalar>* PrimalPreconditioner = nullptr;
CSysMatrixVectorProduct<Scalar>* PrimalJacobian = nullptr;

class LinOperator : public CMatrixVectorProduct<Scalar> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A new compiler warning is generated...

[738/745] Generating 'SU2_PY/pySU2/_pysu2.so.p/pySU2.cxx'.
../SU2_PY/pySU2/../../SU2_CFD/include/drivers/CDiscAdjSinglezoneDriver.hpp:91: Warning 325: Nested class not currently supported (LinOperator ignored)
../SU2_PY/pySU2/../../SU2_CFD/include/drivers/CDiscAdjSinglezoneDriver.hpp:102: Warning 325: Nested class not currently supported (LinPreconditioner ignored)
[744/745] Installing files.

public:
CDiscAdjSinglezoneDriver* const driver;
LinOperator(CDiscAdjSinglezoneDriver* d) : driver(d) { }

inline void operator()(const CSysVector<Scalar> & u, CSysVector<Scalar> & v) const override {
driver->ApplyOperator(u, v);
}
};

class LinPreconditioner : public CPreconditioner<Scalar> {
public:
CDiscAdjSinglezoneDriver* const driver;

LinPreconditioner(CDiscAdjSinglezoneDriver* d): driver(d) { }

inline void operator()(const CSysVector<Scalar> & u, CSysVector<Scalar> & v) const override {
driver->ApplyPreconditioner(u, v);
}
};

/*!
* \brief Record one iteration of a flow iteration in within multiple zones.
* \param[in] kind_recording - Type of recording (full list in ENUM_RECORDING, option_structure.hpp)
Expand All @@ -65,17 +111,58 @@ class CDiscAdjSinglezoneDriver : public CSinglezoneDriver {
* \brief Run one iteration of the solver.
* \param[in] kind_recording - Type of recording (full list in ENUM_RECORDING, option_structure.hpp)
*/
void DirectRun(RECORDING kind_recording);
void DirectRunFixedPoint(RECORDING kind_recording);

/*!
* \brief Set the objective function.
* \brief Run one iteration of the solver.
* \param[in] kind_recording - Type of recording (full list in ENUM_RECORDING, option_structure.hpp)
*/
void SetObjFunction(void);
void DirectRunResidual(RECORDING kind_recording);

/*!
* \brief Run a single iteration of the main fixed-point discrete adjoint solver with a single zone.
*/
void RunFixedPoint(void);

/*!
* \brief Run the computation of the main residual-based discrete adjoint sensitivities with a single zone.
*/
void RunResidual(void);

/*!
* \brief Run a single iteration of the secondary fixed-point discrete adjoint solver with a single zone.
*/
void SecondaryRunFixedPoint(void);

/*!
* \brief Run the computation of the secondary residual-based discrete adjoint sensitivities with a single zone.
*/
void SecondaryRunResidual(void);

/*!
* \brief Update the fixed-point discrete adjoint solver with a single zone.
*/
void UpdateAdjointsFixedPoint(void);

/*!
* \brief Update the residual-based discrete adjoint solver with a single zone.
*/
void UpdateAdjointsResidual(void);

/*!
* \brief Adjoint problem Jacobian-vector product.
*/
void ApplyOperator(const CSysVector<Scalar>& u, CSysVector<Scalar>& v);

/*!
* \brief Adjoint problem preconditioner (based on the transpose approximate Jacobian of the primal problem).
*/
void ApplyPreconditioner(const CSysVector<Scalar>& u, CSysVector<Scalar>& v);

/*!
* \brief Initialize the adjoint value of the objective function.
*/
void SetAdjObjFunction(void);
void SetAdjointObjective(void);

/*!
* \brief Record the main computational path.
Expand All @@ -99,7 +186,6 @@ class CDiscAdjSinglezoneDriver : public CSinglezoneDriver {
* \brief Constructor of the class.
* \param[in] confFile - Configuration file name.
* \param[in] val_nZone - Total number of zones.
* \param[in] val_nDim - Total number of dimensions.
* \param[in] MPICommunicator - MPI communicator for SU2.
*/
CDiscAdjSinglezoneDriver(char* confFile,
Expand All @@ -122,8 +208,114 @@ class CDiscAdjSinglezoneDriver : public CSinglezoneDriver {
*/
void Run(void) override;

/*!
* \brief Update the discrete adjoint solution.
*/
void UpdateAdjoints(void);

/*!
* \brief Update the primal time iteration.
*/
void UpdateTimeIter(void);

/*!
* \brief Update the primal far-field variables.
*/
void UpdateFarfield(void);

/*!
* \brief Update the primal geometry (does not include mesh deformation).
*/
void UpdateGeometry(void);
patelha57 marked this conversation as resolved.
Show resolved Hide resolved

/*!
* \brief Deform the primal mesh.
*/
void DeformGeometry(void);

/*!
* \brief Update the primal states.
*/
void UpdateStates();

/*!
* \brief Update the primal residuals.
*/
void UpdateResiduals();

/*!
* \brief Update the primal tractions.
*/
void UpdateTractions();

/*!
* \brief Update the primal objective.
*/
void UpdateObjective();

/*!
* \brief Update the primal jacobian.
*/
void UpdateJacobians();

/*!
* \brief Postprocess the adjoint iteration for ZONE_0.
*/
void Postprocess(void) override;

/*!
* \brief Get the partial objective sensitivities from all solvers.
* \param[out] values - Values object with interface (iPoint, iVar).
*/
template <class Container>
void GetAllObjectiveStatesSensitivities(Container& values) const {
const auto nPoint = geometry_container[ZONE_0][INST_0][MESH_0]->GetnPoint();

/*--- Get all the partial sensitivities (dObjective/dStates) ---*/
unsigned short offset = 0;

for (auto iSol = 0u; iSol < MAX_SOLS; ++iSol) {
auto solver = solver_container[ZONE_0][INST_0][MESH_0][iSol];

if (!solver || !solver->GetAdjoint()) continue;

for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) {
for (auto iVar = 0ul; iVar < solver->GetnVar(); ++iVar) {
auto value = solver->GetSens_dObjective_dStates(iPoint, iVar);

values(iPoint, offset + iVar) = -SU2_TYPE::GetValue(value);
}
}

offset += solver->GetnVar();
}
}

/*!
* \brief Get the partial jacobian-adjoint products from all solvers.
* \param[out] values - Values object with interface (iPoint, iVar).
*/
template <class Container>
void GetAllResidualsStatesSensitivities(Container& values) const {
const auto nPoint = geometry_container[ZONE_0][INST_0][MESH_0]->GetnPoint();

/*--- Get all the partial jacobian-adjoint products (dResiduals/dStates) ---*/
unsigned short offset = 0;

for (auto iSol = 0u; iSol < MAX_SOLS; ++iSol) {
auto solver = solver_container[ZONE_0][INST_0][MESH_0][iSol];

if (!solver || !solver->GetAdjoint()) continue;

for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) {
for (auto iVar = 0ul; iVar < solver->GetnVar(); ++iVar) {
auto value = solver->GetProd_dResiduals_dStates(iPoint, iVar);

values(iPoint, offset + iVar) = SU2_TYPE::GetValue(value);
}
}

offset += solver->GetnVar();
}
}
};
Loading
Loading