ECCOMAS 2024

Algorithmic Differentiation of the pythonOCC Geometric Modeling Library

  • Banovic, Mladen (German Aerospace Center (DLR))
  • Hafemann, Thomas (German Aerospace Center (DLR))
  • Stück, Arthur (German Aerospace Center (DLR))

Please login to view abstract download link

Many gradient-based optimization workflows in engineering rely on high-fidelity numerical simulations, involve CAD-based parametrizations and are (partly) implemented in the programming language Python. This scenario is addressed in this work by enabling the algorithmic differentiation (AD) support—that was developed earlier for the C++ CAD kernel OpenCascade Technology (OCCT)—for pythonOCC. pythonOCC is a library that provides Python wrappers for the widely-used C++ geometric kernel OCCT. Thus, it enables the usage of C++ OCCT to a broader audience, and in industrial workflows that require a Python interface to CAD tools and libraries. To perform a gradient-based shape optimization of a CAD-based model—in this case a geometry parametrized using pythonOCC—one requires the computation of the so-called geometric sensitivities, e.g. derivatives of surface point coordinates with respect to the design parameters. Here, these sensitivities are obtained by applying AD to the OCCT/pythonOCC sources. First, the OCCT kernel v7.6.2 is differentiated by integrating ADOL-C (Automatic Differentiation by Overloading in C++) into its source code. In this process, one replaces the declaration types of almost all real variables (e.g. float, double) with the adouble datatype of ADOL-C. Second, a Python wrapper of the adouble class is implemented using SWIG (Simplified Wrapper and Interface Generator). Finally, this wrapper is used to differentiate pythonOCC v7.6.2 sources, which are now linked against the AD-enabled OCCT. This mixed-language AD approach enables the propagation of derivatives from C++ to Python and vice-versa, thus allowing the utilization of pythonOCC in CAD-based shape optimization workflows. The suggested approach will be presented and discussed for selected CFD-coupled applications and workflows in the context of gradient-based and CAD-enabled shape optimizations for aeronautic applications.