-
Notifications
You must be signed in to change notification settings - Fork 823
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
base: develop
Are you sure you want to change the base?
Conversation
That's exactly right. We started investigating the multizone driver a while back but we didn't get very far... It's been a while so i will need a refresher. Sure, there's broader interest in comparison with FP. Ole, Nico, and I talked about doing a detailed characterization last summer and we briefly brought it up in Varenna last week |
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
CPreconditioner<Scalar>* PrimalPreconditioner = nullptr; | ||
CSysMatrixVectorProduct<Scalar>* PrimalJacobian = nullptr; | ||
|
||
class LinOperator : public CMatrixVectorProduct<Scalar> { |
There was a problem hiding this comment.
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.
} | ||
|
||
CopiedJacobian.TransposeInPlace(); | ||
PrimalJacobian = new CSysMatrixVectorProduct<Scalar>(CopiedJacobian, geometry, config); |
Check warning
Code scanning / CodeQL
Resource not released in destructor Warning
All the regression and unit tests are passing now! |
The following functions in Adjoints
Sensitivities
Flow solution
|
/*! | ||
* \brief Update the primal geometry (does not include mesh deformation). | ||
*/ | ||
void UpdateGeometry(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the (voids) please.
void UpdateGeometry(void); | |
void UpdateGeometry(); |
vector<passivedouble> GetHeatFluxes(unsigned long iPoint) const; | ||
|
||
/*! | ||
* \brief Get the heat fluxes at a marker vertex. | ||
* \param[in] iMarker - Marker index. | ||
* \param[in] iVertex - Marker vertex index. | ||
* \return Vertex heat fluxes (nVertex, nDim). | ||
*/ | ||
vector<passivedouble> GetMarkerHeatFluxes(unsigned short iMarker, unsigned long iVertex) const; | ||
|
||
/*! | ||
* \brief Get the normal heat fluxes at a marker vertex. | ||
* \param[in] iMarker - Marker index. | ||
* \param[in] iVertex - Marker vertex index. | ||
* \return Vertex normal heat fluxes (nVertex, nDim). | ||
*/ | ||
passivedouble GetMarkerNormalHeatFluxes(unsigned short iMarker, unsigned long iVertex) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't these duplicating an existing function?
* \param[in] iVertex - Marker vertex index. | ||
* \param[in] values - Vertex normal heat flux. | ||
*/ | ||
void SetMarkerNormalHeatFluxes(unsigned short iMarker, unsigned long iVertex, passivedouble values); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplication?
unsigned long GetNumberNonequilibriumSpecies() const; | ||
|
||
/*! | ||
* \brief Get the number of nonequilibrium conservative state variables. | ||
* \return Number of nonequilibrium conservative state variables. | ||
*/ | ||
unsigned long GetNumberNonequilibriumStateVariables() const; | ||
|
||
/*! | ||
* \brief Get the number of nonequilibrium primitive state variables. | ||
* \return Number of nonequilibrium primitive state variables. | ||
*/ | ||
unsigned short GetNumberNonequilibriumPrimitiveVariables() const; | ||
|
||
/*! | ||
* \brief Get nonequilibrium chemical mass fractions. | ||
* \param[in] iPoint - Point index. | ||
* \return Nonequilibrium chemical mass fractions (nSpecies). | ||
*/ | ||
vector<passivedouble> GetNonequilibriumMassFractions(unsigned long iPoint) const; | ||
|
||
/*! | ||
* \brief Get nonequilibrium vibrational electronic temperatures. | ||
* \return Nonequilibrium vibrational electronic temperatures (nPoint). | ||
*/ | ||
vector<passivedouble> GetVibrationalTemperatures() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not available via the access to primitive variables?
@@ -58,24 +59,599 @@ void CDriver::PreprocessPythonInterface(CConfig** config, CGeometry**** geometry | |||
} | |||
} | |||
|
|||
///////////////////////////////////////////////////////////////////////////// | |||
/* Functions related to the far-field flow variables. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you have weird symbols here
SU2_MPI::Error("Vertex index exceeds mesh size.", CURRENT_FUNCTION); | ||
} | ||
|
||
return SU2_TYPE::GetValue(solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetSoundSpeed(iPoint)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this part of the primitives too?
return values; | ||
} | ||
|
||
void CDriver::SetMarkerAdjointForces(unsigned short iMarker, unsigned long iVertex, vector<passivedouble> values) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These also look duplicated
Motivation
Fundamental bottlenecks exist for industrial adoption of high-fidelity physics codes with fully coupled discrete adjoint sensitivity analysis. These bottlenecks include a lack of flexibility, modularity, and robustness of the computational tools, as well as the potential startup development costs needed to implement and verify the MDAO features. The purpose of this work is to facilitate the coupling of SU2 with external structural codes (e.g. NASTRAN, TACS, Airbus structural suite Lagrange) for gradient-based aerodynamic shape and structural sizing optimization using dedicated frameworks (e.g. OpenMDAO).
Startup development costs include the creation of modular tools that are designed to be driven by another framework like OpenMDAO, rather than to drive execution themselves. However, leveraging those MDAO frameworks assumes that software codes and modules to be coupled exist, have appropriate data structures, execution and query APIs, and are wrapped in Python for flexibility and ease of use. The proposed changes were motivated with the goal of making SU2 more modular and flexible, particularly to facilitate its integration into large-scale MDAO frameworks. For more details on the motivation, methodology, and verification & validation results, please refer to our paper from AIAA Aviation 2022.
Proposed Changes
@aa-g and I propose the following code updates:
Implementation of residual-based discrete adjoint solver as
CDiscAdjResidualSolver
a. New config option:
KIND_DISC_ADJ
Enhancements and standardization of SU2 Python API
a. Add pysu2/pysu2ad methods
b. Standardize Python API and function names
c. Overloaded getter/setter methods to make data handling more flexible
Related Work
These efforts are related to Issue #1262, Pull Request #1300, and Discussion #1325.
PR Checklist