fast-aircraft-design / FAST-OAD

FAST-OAD: An open source framework for rapid Overall Aircraft Design
GNU General Public License v3.0
47 stars 25 forks source link

Avoiding unnecessary setup operations #503

Closed christophe-david closed 5 months ago

christophe-david commented 5 months ago

This PR fixes some performance problems of FAST-OAD.

To get knowledge of the structure of OpenMDAO problems, a setup operation is needed. Until now, due to the several changes that were done separately, this setup operation was done almost each time information was needed, which proved to be CPU costly.

Here the problem analysis is done in only one place, which allows to reduce to the minimum the number of setup calls. There is still one "additional" setup operation needed to analyze the problem, and possibly another one if dynamically shaped variables are inputs of the problem.

Also, write_needed_inputs implementation has been put back in FASTOADPoblem (while keeping the FASTOADProblemConfigurator method), which allows to spare 2 setup calls when called on the problem instance that will do the computation (when done from FASTOADProblemConfigurator, it is done on a separate instance).

As a result, the integration test test_oad_process uses now 2 setup calls, instead of 10 previously.

codecov[bot] commented 5 months ago

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (15b04af) 84.16% compared to head (4eeb488) 84.24%. Report is 1 commits behind head on master.

Files Patch % Lines
src/fastoad/io/configuration/configuration.py 50.00% 1 Missing and 1 partial :warning:
src/fastoad/openmdao/problem.py 98.71% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #503 +/- ## ========================================== + Coverage 84.16% 84.24% +0.08% ========================================== Files 132 132 Lines 6061 6081 +20 Branches 891 896 +5 ========================================== + Hits 5101 5123 +22 + Misses 804 803 -1 + Partials 156 155 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.