Skip to main content
Log in

Flexible framework for fluid topology optimization with OpenFOAM® and finite element-based high-level discrete adjoint method (FEniCS/dolfin-adjoint)

  • Educational Paper
  • Published:
Structural and Multidisciplinary Optimization Aims and scope Submit manuscript

Abstract

In order to implement the topology optimization method, it is necessary to simulate the fluid flow dynamics and also obtain the sensitivities with respect to the design variable (such as through the adjoint method). However, more complex fluid flows, such as turbulent, non-Newtonian, and compressible flows, may turn the implementation of these two aspects difficult and non-intuitive. In order to solve this deadlock, this work proposes the combination of two well-known and established open-source softwares: OpenFOAM® and FEniCS/dolfin-adjoint. OpenFOAM® already provides efficient implementations for various fluid flow models, while FEniCS, when combined with the dolfin-adjoint library, provides an efficient and automatic high-level discrete adjoint model. There have been various attempts for obtaining the adjoint model directly in OpenFOAM® , but they mostly rely on the following: (1) manually deducing the adjoint equations, which may become a hard and cumbersome task for complex models; (2) C++ automatic differentiation tools, which are generally computationally inefficient; and (3) finite differences, which have been developed for shape optimization (not topology optimization, where there are many more design variable values). Nonetheless, these approaches generally do not provide an easy setup, and may be fairly complex to consider. The FEniCS platform does not provide any fluid flow model out of the box, but makes it fairly simple to “simplistically” define them. The main problem of the FEniCS implementation and even implementations “by hand” (such as in C++, Matlab® or Python) is the convergence of the simulation, which would possibly require fairly complex adjustments in the implementation in order to reach convergence. Therefore, the combination proposed in this work (OpenFOAM® and FEniCS/dolfin-adjoint) is a simpler but efficient approach to consider more complex fluid flows, countering the difficult adjoint model implementation in OpenFOAM® and also the convergence issues in FEniCS. The implemented framework, referred as “FEniCS TopOpt Foam”, can perform the coupling between the two softwares. Numerical examples are presented considering laminar and turbulent flows (Spalart-Allmaras model) for 2D, 2D axisymmetric, and 3D domains.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Fig. 11
Fig. 12
Fig. 13
Fig. 14
Fig. 15
Fig. 16
Fig. 17
Fig. 18
Fig. 19
Fig. 20
Fig. 21
Fig. 22
Fig. 23
Fig. 24
Fig. 25
Fig. 26
Fig. 27

Notes

  1. https://github.com/diego-hayashi/fenics_topopt_foam.

  2. https://github.com/diego-hayashi/fenics_topopt_foam.

References

Download references

Funding

This research was partly supported by CNPq (Brazilian Research Council) and FAPESP (São Paulo Research Foundation). The authors thank the supporting institutions. The first author thanks the financial support of FAPESP under Grant 2017/27049-0. The second author thanks the financial support of CAPES. The third author thanks the financial support of CNPq (National Council for Research and Development) under grant 302658/2018-1 and of FAPESP under Grant 2013/24434-0. The authors also acknowledge the support of the RCGI (Research Centre for Gas Innovation), hosted by the University of São Paulo (USP) and sponsored by FAPESP (2014/50279-4) and Shell Brazil.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Emílio Carlos Nelli Silva.

Ethics declarations

Conflict of interest

The authors declare that they have no conflict of interest.

Additional information

Responsible Editor: Qing Li

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Appendix A: Comparison of sensitivities with finite differences

Appendix A: Comparison of sensitivities with finite differences

In this appendix, a comparison of the computed sensitivities from dolfin-adjoint with finite differences is presented. The comparison is performed for the initial guess of the 2D axisymmetric nozzle (Sect. 7.3). A set of points is selected in the computational domain for comparison with finite differences (see Fig. 28): one near the inlet, one near the symmetry axis, one near the middle of the computational domain, one near the outlet, and a last one inside the solid material. The comparison is performed for the same configurations considered for laminar and turbulent flows in Sect. 7.3, by restricting the simulation to 6000 SIMPLE iterations. The finite differences are considered through the backward difference approximation (for \(\alpha = 1\)): \(\frac{{\text{d}}J}{{\text{d}}\alpha } = \frac{J(\alpha ) - J(\alpha - {\Delta }\alpha )}{{\Delta }\alpha }\), where \(J = {\Phi }\). The finite difference approximation is changed to forward difference approximation for point number 5 (\(\alpha = 0\)): \(\frac{{\text{d}}J}{{\text{d}}\alpha } = \frac{J(\alpha + {\Delta }\alpha ) - J(\alpha )}{{\Delta }\alpha }\), where \(J = {\Phi }\). A better approximation would be the use of a central finite difference approximation (\(\frac{{\text{d}}J}{{\text{d}}\alpha } = \frac{J(\alpha + {\Delta }\alpha ) - J(\alpha - {\Delta }\alpha )}{2{\Delta }\alpha }\)), which is, however, inadequate for \(\alpha = 0\) and \(\alpha = 1\) (bounds of \(\alpha\)). The computed sensitivities are shown in Fig. 29, for a step size of \(10^{-3}\). As can be seen, the computed sensitivities for the “FEniCS TopOpt Foam” approach (from dolfin-adjoint) and finite differences are close to each other. In order to get a better insight about the differences between the two sensitivities, Fig. 30 shows the relative differences as defined below, which resulted small.

$$\begin{aligned}&\left. r_d\right| _\text{laminar} = \left. \frac{\left. \frac{dJ}{d\alpha }\right| _\text{FD} - \left. \frac{dJ}{d\alpha }\right| _\text{FTF}}{\mathrm {max}\left| \frac{dJ}{d\alpha }\right| _\text{FTF,\ all\ points}}\right| _\text{laminar} \end{aligned}$$
(32)
$$\begin{aligned}&\left. r_d\right| _\text{turbulent} = \left. \frac{\left. \frac{dJ}{d\alpha }\right| _\text{FD} - \left. \frac{dJ}{d\alpha }\right| _\text{FTF}}{\mathrm {max}\left| \frac{dJ}{d\alpha }\right| _\text{FTF,\ all\ points}}\right| _\text{turbulent} \end{aligned}$$
(33)

where the subscript “FTF” indicates the “FEniCS TopOpt Foam” approach (from dolfin-adjoint) and “FD” indicates “Finite Differences”.

Fig. 28
figure 28

Topology considered for the finite differences comparison

Fig. 29
figure 29

Sensitivity values computed with the “FEniCS TopOpt Foam” approach (from dolfin-adjoint) and from finite differences, for laminar and turbulent flows

Fig. 30
figure 30

Relative differences for the cases shown in Fig. 29

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Alonso, D.H., Garcia Rodriguez, L.F. & Silva, E.C.N. Flexible framework for fluid topology optimization with OpenFOAM® and finite element-based high-level discrete adjoint method (FEniCS/dolfin-adjoint). Struct Multidisc Optim 64, 4409–4440 (2021). https://doi.org/10.1007/s00158-021-03061-4

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00158-021-03061-4

Keywords

Navigation