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.
References
Adept (2021) Adept—a combined automatic differentiation and array library for c++. http://www.met.reading.ac.uk/clouds/adept/. Accessdd May 2021
Alonso DH, de Sá LFN, Saenz JSR, Silva ECN (2018) Topology optimization applied to the design of 2d swirl flow devices. Struct Multidisc Optim 58(6):2341–2364. https://doi.org/10.1007/s00158-018-2078-0
Alonso DH, de Sá LFN, Saenz JSR, Silva ECN (2019) Topology optimization based on a two-dimensional swirl flow model of tesla-type pump devices. Comput Math Appl 77(9):2499–2533. https://doi.org/10.1016/j.camwa.2018.12.035
Alonso DH, Saenz JSR, Silva ECN (2020) Non-Newtonian laminar 2d swirl flow design by the topology optimization method. Struct Multidisc Optim 62(1):299–321. https://doi.org/10.1007/s00158-020-02499-2
Andreasen CS, Gersborg AR, Sigmund O (2009) Topology optimization of microfluidic mixers. Int J Numer Methods Fluid 61:498–513. https://doi.org/10.1002/fld.1964
Ansys I (2006) Modeling turbulent flows - introductory fluent training. www.southampton.ac.uk/~nwb/lectures/GoodPracticeCFD/Articles/Turbulence_Notes_Fluent-v6.3.06.pdf. Accessed Nov 2020
Arnold D, Brezzi F, Fortin M (1984) A stable finite element method for the stokes equations. Calcolo 21:337–344
Bardina JE, Huang PG, Coakley TJ (1997) Turbulence modeling validation, testing and development. Tech. rep, NASA Technical Memorandum, p 110446
Bendsøe MP, Sigmund O (2003) Topology optimization: theory, methods, and applications, 2nd edn. Springer, Berlin
Borrvall T, Petersson J (2003) Topology optimization of fluids in stokes flow. Int J Numer Methods Fluids 41(1):77–107. https://doi.org/10.1002/fld.426
Brezzi F, Fortin M (1991) Mixed and hybrid finite element methods. Springer, Berlin
Bueno-Orovio A, Castro C, Palacios F, Zuazua E (2012) Continuous adjoint approach for the spalart-allmaras model in aerodynamic optimization. AIAA J 50(3):631–646
Chen G, Xiong Q, Morris PJ, Paterson EG, Sergeev A, Wang Y (2014) Openfoam for computational fluid dynamics. Not AMS 61(4):354–363
Dai X, Zhang C, Zhang Y, Gulliksson M (2018) Topology optimization of steady Navier-Stokes flow via a piecewise constant level set method. Struct Multidisc Optim 57(6):2193–2203
De Chant LJ (2005) The venerable 1/7th power law turbulent velocity profile: a classical nonlinear boundary value problem solution and its relationship to stochastic processes. J Appl Math Comput Mech 161:463–474
Deng Y, Zhou T, Liu Z, Wu Y, Qian S, Korvink JG (2018) Topology optimization of electrode patterns for electroosmotic micromixer. Int J Heat Mass Transf 126:1299–1315
Dilgen CB, Dilgen SB, Fuhrman DR, Sigmund O, Lazarov BS (2018) Topology optimization of turbulent flows. Comput Methods Appl Mech Eng 331:363–393. https://doi.org/10.1016/j.cma.2017.11.029
Duan X, Li F, Qin X (2016) Topology optimization of incompressible Navier-Stokes problem by level set based adaptive mesh method. Comput Math Appl 72(4):1131–1141. https://doi.org/10.1016/j.camwa.2016.06.034
Elhanafy A, Guaily A, Elsaid A (2017) Pressure stabilized finite elements simulation for steady and unsteady Newtonian fluids. J Appl Math Comput Mech 16(3):17–26
Evgrafov A (2004) Topology optimization of navier-stokes equations. Nordic MPS 2004. The Ninth Meeting of the Nordic Section of the Mathematical Programming Society, vol 014. Linköping University Electronic Press, pp 37–55
Farrell PE, Ham DA, Funke SW, Rognes ME (2013) Automated derivation of the adjoint of high-level transient finite element programs. SIAM J Sci Comput 35(4):C369–C393
Franca LP (1992) Stabilized finite element methods: II. The incompressible Navier-Stokes equations. Comput Methods Appl Mech Eng 99(258):209–233
Funke S (2013) The automation of PDE-constrained optimisation and its applications. PhD thesis. Imperial College London
Gersborg-Hansen A (2003) Topology optimization of incompressible Newtonian flows at moderate Reynolds numbers. Master’s thesis, Technical University of Denmark
Guest JK, Prévost JH (2006) Topology optimization of creeping fluid flows using a Darcy-Stokes finite element. Int J Numer Methods Eng 66(3):461–484. https://doi.org/10.1002/nme.1560
Hasund KES (2017) Topology optimization for unsteady flow with applications in biomedical flows. Master’s thesis, NTNU
He P, Mader CA, Martins JRRA, Maki KJ (2018) An aerodynamic design optimization framework using a discrete adjoint approach with OpenFOAM. Comput Fluids 168:285–303. https://doi.org/10.1016/j.compfluid.2018.04.012
He P, Mader CA, Martins JRRA, Maki KJ (2020) DAFoam: an open-source adjoint framework for multidisciplinary design optimization with OpenFOAM. AIAA J 10(2514/1):J058853
Hyun J, Wang S, Yang S (2014) Topology optimization of the shear thinning non-Newtonian fluidic systems for minimizing wall shear stress. Comput Math Appl 67(5):1154–1170. https://doi.org/10.1016/j.camwa.2013.12.013
Jensen KE, Szabo P, Okkels F (2012) Topology optimizatin of viscoelastic rectifiers. Appl Phys Lett 100(23):234102
Kawamoto A, Matsumori T, Kondoh T (2013) Regularization in topology optimization. ROKS 2013, Leuven
Langtangen HP, Logg A (2016) Solving PDEs in minutes —The FEniCS Tutorial Volume I. https://fenicsproject.org/book/. Accessed Nov 2020
Langtangen HP, Mardal KA, Winther R (2002) Numerical methods for incompressible viscous flow. Adv water Resour 25(8–12):1125–1146
Lazarov BS, Sigmund O (2010) Filters in topology optimization based on Helmholtz-type differential equations. Int J Numer Methods Eng 86(6):765–781
Li BQ (2006) Discontinuous finite elements in fluid dynamics and heat transfer. Springer, London
Logg A, Mardal KA, Wells G (2012) Automated solution of differential equations by the finite element method: The FEniCS book, vol 84. Springer, https://fenicsproject.org/book/
Lv Y, Liu S (2018) Topology optimization and heat dissipation performance analysis of a micro-channel heat sink. Meccanica 53(15):3693–3708
Mangani L, Buchmayr M, Darwish M (2014) Development of a novel fully coupled solver in openfoam: Steady-state incompressible turbulent flows. Numer Heat Transf B 66(1):1–20. https://doi.org/10.1080/10407790.2014.894448
Meurer A, Smith CP, Paprocki M, Čertík O, Kirpichev SB, Rocklin M, Kumar A, Ivanov S, Moore JK, Singh S, Rathnayake T, Vig S, Granger BE, Muller RP, Bonazzi F, Gupta H, Vats S, Johansson F, Pedregosa F, Curry MJ, Terrel AR, Roučka Š, Saboo A, Fernando I, Kulal S, Cimrman R, Scopatz A (2017) Sympy: symbolic computing in python. Peer J Comput Sci. https://doi.org/10.7717/peerj-cs.103
Mitusch S, Funke S, Dokken J (2019) dolfin-adjoint 2018.1: automated adjoints for Fenics and Firedrake. J Open Sour Softw 4(38):1292. https://doi.org/10.21105/joss.01292
Mortensen M, Langtangen HP, Wells GN (2011) A Fenics-based programming framework for modeling turbulent flow by the Reynolds-averaged Navier-Stokes equations. Adv Water Resour 34(9):1082–1101. https://doi.org/10.1016/j.advwatres.2011.02.013
Munson BR, Young DF, Okiishi TH (2009) Fundamentals of fluid mechanics, 6th edn. Wiley, New York
NASA (2019) Turbulence modeling resource—the spalart-allmaras turbulence model . https://turbmodels.larc.nasa.gov/spalart.html
Nørgaard S, Sigmund O, Lazarov B (2016) Topology optimization of unsteady flow problems using the lattice Boltzmann method. J Comput Phys 307(C):291–307. https://doi.org/10.1016/j.jcp.2015.12.023
Olesen LH, Okkels F, Bruus H (2006) A high-level programming-language implementation of topology optimization applied to steady-state Navier-stokes flow. Int. J. Numer. Methods Eng. 65(7):975–1001
OpenFOAM Foundation (2020) Official openfoam repository. https://github.com/OpenFOAM
OpenFOAM Wiki (2014) Openfoam guide/the simple algorithm in openfoam. http://openfoamwiki.net/index.php/The_SIMPLE_algorithm_in_OpenFOAM
Papoutsis-Kiachagias E, Kontoleontos E, Zymaris A, Papadimitriou D, Giannakoglou K (2011) Constrained topology optimization for laminar and turbulent flows, including heat transfer. CIRA, editor, EUROGEN, Evolutionary and Deterministic Methods for Design, Optimization and Control, Capua, Italy
Papoutsis-Kiachagias E, Zymaris A, Kavvadias I, Papadimitriou D, Giannakoglou K (2015) The continuous adjoint approach to the k-\(\epsilon\) turbulence model for shape optimization and optimal active control of turbulent flows. Eng Optim 47(3):370–389. https://doi.org/10.1080/0305215X.2014.892595
Papoutsis-Kiachagias EM, Giannakoglou KC (2016) Continuous adjoint methods for turbulent flows, applied to shape and topology optimization: industrial applications. Arch Comput Methods Eng 23(2):255–299
Patankar SV (1980) Numerical heat transfer and fluid flow, 1st edn. McGraw-Hill, New York
Pingen G, Maute K (2010) Optimal design for non-Newtonian flows using a topology optimization approach. Comput Math Appl 59(7):2340–2350
Ramalingom D, Cocquet PH, Bastide A (2018) A new interpolation technique to deal with fluid-porous media interfaces for topology optimization of heat transfer. Comput Fluids 168:144–158. https://doi.org/10.1016/j.compfluid.2018.04.005
Reddy JN, Gartling DK (2010) The finite element method in heat transfer and fluid dynamics, 3rd edn. CRC Press, Boca Raton
Rempfer D (2006) On boundary conditions for incompressible Navier-Stokes problems. Appl Mech Rev 59(3):107–125. https://doi.org/10.1115/1.2177683
Romero J, Silva E (2014) A topology optimization approach applied to laminar flow machine rotor design. Comput Methods Appl Mech Eng 279(Supplement Supplement C):268–300. https://doi.org/10.1016/j.cma.2014.06.029
Romero JS, Silva ECN (2017) Non-Newtonian laminar flow machine rotor design by using topology optimization. Struct Multidisc Optim 55(5):1711–1732
Rozvany G (2001) Aims, scope, methods, history and unified terminology of computer-aided topology optimization in structural mechanics. Struct Multidisc Optim 21(2):90–108. https://doi.org/10.1007/s001580050174
Rozvany GIN, Zhou M, Birker T (1992) Generalized shape optimization without homogenization. Struct Optim 4(3):250–252. https://doi.org/10.1007/BF01742754
Sá LFN, Amigo RCR, Novotny AA, Silva ECN (2016) Topological derivatives applied to fluid flow channel design optimization problems. Struct Multidisc Optim 54(2):249–264. https://doi.org/10.1007/s00158-016-1399-0
Sá LFN, Okubo Jr CM, Silva ECN (2021) Topology optimization of subsonic compressible flows. Struct Multidisc Optim 64:1–22. https://doi.org/10.1007/s00158-021-02903-5
Sagebaum M, Albring T, Gauger NR (2018) Expression templates for primal value taping in the reverse mode of algorithmic differentiation. Optim Methods Softw 33(4–6):1207–1231. https://doi.org/10.1080/10556788.2018.1471140
Sato Y, Yaji K, Izui K, Yamada T, Nishiwaki S (2017) Topology optimization of a no-moving-part valve incorporating pareto frontier exploration. Struct Multidisc Optim 56(4):839–851. https://doi.org/10.1007/s00158-017-1690-8
Sato Y, Yaji K, Izui K, Yamada T, Nishiwaki S (2018) An optimum design method for a thermal-fluid device incorporating multiobjective topology optimization with an adaptive weighting scheme. J Mech Des 140(3):031402
Schlichting H (1979) Boundary-layer theory, 7th edn. McGraw-Hill, New York
Sigmund O (2007) Morphology-based black and white filters for topology optimization. Struct Multidisc Optim 33(4):401–424. https://doi.org/10.1007/s00158-006-0087-x
Sigmund O, Petersson J (1998) Numerical instabilities in topology optimization: a survey on procedures dealing with checkerboards, mesh-dependencies and local minima. Struct Optim 16(1):68–75
Sokolowski J, Zochowski A (1999) On the topological derivative in shape optimization. SIAM J Control Optim 37(4):1251–1272
Song XG, Wang L, Baek SH, Park YC (2009) Multidisciplinary optimization of a butterfly valve. ISA Trans 48(3):370–377
Spalart PRA, Allmaras S (1994) A one-equation turbulence model for aerodynamic flows. Cla Recherche Aérospatiale 1:5–21
Towara M, Naumann U (2013) A discrete adjoint model for openfoam. Proced Comput Sci 18:429–438. https://doi.org/10.1016/j.procs.2013.05.206
Wächter A, Biegler LT (2006) On the implementation of an interior-point filter line-search algorithm for large-scale nonlinear programming. Math Program 106(1):25–57
Weller HG, Tabor G, Jasak H, Fureby C (1998) A tensorial approach to computational continuum mechanics using object-oriented techniques. Comput Phys 12(6):620–631
White FM (2011) Fluid mechanics, 7th edn. McGraw-Hill, New York
Wiker N, Klarbring A, Borrvall T (2007) Topology optimization of regions of Darcy and Stokes flow. Int Jo Numer Methods Eng 69(7):1374–1404
Wilcox DC (2006) Turbulence modeling for CFD, 3rd edn. DCW Industries Inc., La Canada
Yoon GH (2016) Topology optimization for turbulent flow with Spalart-Allmaras model. Comput Methods Appl Mech Eng 303:288–311. https://doi.org/10.1016/j.cma.2016.01.014
Zauderer E (1989) Partial differential equations of applied mathematics, 2nd edn. Wiley, Hoboken
Zhang B, Liu X, Sun J (2016) Topology optimization design of non-Newtonian roller-type viscous micropumps. Struct Multidisc Optim 53(3):409–424
Zhou S, Li Q (2008) A variationals level set method for the topology optimization of steady-state Navier-Stokes flow. J Comput Phys 227(24):10178–10195
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
Corresponding author
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.
where the subscript “FTF” indicates the “FEniCS TopOpt Foam” approach (from dolfin-adjoint) and “FD” indicates “Finite Differences”.
Rights and permissions
About this article
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
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00158-021-03061-4