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 131 commits into
base: develop
Choose a base branch
from

Conversation

patelha57
Copy link
Contributor

@patelha57 patelha57 commented Sep 5, 2022

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:

  1. Implementation of residual-based discrete adjoint solver as CDiscAdjResidualSolver
    a. New config option: KIND_DISC_ADJ

  2. 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

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

WallyMaier and others added 30 commits May 7, 2020 14:20
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.

}

CopiedJacobian.TransposeInPlace();
PrimalJacobian = new CSysMatrixVectorProduct<Scalar>(CopiedJacobian, geometry, config);

Check warning

Code scanning / CodeQL

Resource not released in destructor

Resource PrimalJacobian is acquired by class CDiscAdjSinglezoneDriver but not released anywhere in this class.
@patelha57
Copy link
Contributor Author

All the regression and unit tests are passing now!

@patelha57
Copy link
Contributor Author

The following functions in python_wrapper_structure.cpp could be implemented as CPyWrapperMatrixView:

Adjoints

- GetMarkerAdjointForces()

Sensitivities

- GetCoordinatesCoordinatesSensitivities()
- GetMarkerCoordinatesDisplacementsSensitivities()
- GetObjectiveFarfieldVariablesSensitivities()
- GetResidualsFarfieldVariablesSensitivities()
- GetObjectiveStatesSensitivities()
- GetResidualsStatesSensitivities()
- GetForcesStatesSensitivities()
- GetObjectiveCoordinatesSensitivities()
- GetResidualsCoordinatesSensitivities()
- GetForcesCoordinatesSensitivities()
- GetMarkerObjectiveDisplacementsSensitivities()
- GetMarkerResidualsDisplacementsSensitivities()
- GetMarkerForcesDisplacementsSensitivities()
- GetMarkerForceSensitivities()

Flow solution

- GetHeatFluxes()
- GetMarkerHeatFluxes()
- GetNonequilibriumMassFractions()
- GetVibrationalTemperatures()

SU2_CFD/include/drivers/CDiscAdjSinglezoneDriver.hpp Outdated Show resolved Hide resolved
SU2_CFD/include/drivers/CDriver.hpp Show resolved Hide resolved
SU2_CFD/include/drivers/CDriver.hpp Outdated Show resolved Hide resolved
SU2_CFD/include/drivers/CDriver.hpp Outdated Show resolved Hide resolved
SU2_CFD/include/drivers/CDriver.hpp Outdated Show resolved Hide resolved
SU2_CFD/src/python_wrapper_structure.cpp Outdated Show resolved Hide resolved
SU2_CFD/src/python_wrapper_structure.cpp Outdated Show resolved Hide resolved
SU2_CFD/src/python_wrapper_structure.cpp Outdated Show resolved Hide resolved
@HahsFilip
Copy link
Contributor

Hi, are there any updates on this feature? Or maybe some simple example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants