Skip to main content

A level set-based structural optimization code using FEniCS

Abstract

This paper presents an educational code written using FEniCS, based on the level set method, to perform compliance minimization in structural optimization. We use the concept of distributed shape derivative to compute a descent direction for the compliance, which is defined as a shape functional. The use of the distributed shape derivative is facilitated by FEniCS, which allows to handle complicated partial differential equations with a simple implementation. The code is written in the framework of linearized elasticity, and can be easily adapted to tackle other functionals and partial differential equations. We also provide an extension of the code for compliant mechanisms. We start by explaining how to compute shape derivatives, and briefly discuss the differences between the distributed and boundary expressions of the shape derivative. Then we describe the implementation in details, and show the application of this code to some classical benchmarks of topology optimization. The files are provided in Online Resource 1 to 3 and also available at http://antoinelaurain.com/compliance.htm. The main file is also given in the Appendix.

This is a preview of subscription content, access via your institution.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7

References

  1. Allaire G (2002) Shape optimization by the homogenization method, Applied Mathematical Sciences, vol 146. Springer-Verlag, New York. https://doi.org/10.1007/978-1-4684-9286-6

    Book  Google Scholar 

  2. Allaire G, Dapogny C, Delgado G, Michailidis G (2014) Multi-phase structural optimization via a level set method. ESAIM Control Optim Calc Var 20(2):576–611. https://doi.org/10.1051/cocv/2013076

    MathSciNet  Article  MATH  Google Scholar 

  3. Allaire G, Jouve F, Toader AM (2002) A level-set method for shape optimization. C R Math Acad Sci Paris 334(12):1125–1130. https://doi.org/10.1016/S1631-073X(02)02412-3

    MathSciNet  Article  MATH  Google Scholar 

  4. Allaire G, Jouve F, Toader AM (2004) Structural optimization using sensitivity analysis and a level-set method. J Comput Phys 194(1):363–393. https://doi.org/10.1016/j.jcp.2003.09.032

    MathSciNet  Article  MATH  Google Scholar 

  5. Allaire G, Pantz O (2006) Structural optimization with FreeFem++. Struct Multidiscip Optim 32(3):173–181. https://doi.org/10.1007/s00158-006-0017-y

    MathSciNet  Article  MATH  Google Scholar 

  6. Alnæs M, Blechta J, Hake J, Johansson A, Kehlet B, Logg A, Richardson C, Ring J, Rognes M, Wells G (2015) The fenics project version 1.5, vol 3. https://doi.org/10.11588/ans.2015.100.20553

  7. Amstutz S, Andrä H (2006) A new algorithm for topology optimization using a level-set method. J Comput Phys 216(2):573–588. https://doi.org/10.1016/j.jcp.2005.12.015

    MathSciNet  Article  MATH  Google Scholar 

  8. Andreassen E., Clausen A., Schevenels M., Lazarov B.S., Sigmund O. (2010) Efficient topology optimization in matlab using 88 lines of code. Struct Multidiscip Optim 43(1):1–16

    Article  MATH  Google Scholar 

  9. Belytschko T, Xiao SP, Parimi C (2003) Topology optimization with implicit functions and regularization. Int J Numer Methods Eng 57(8):1177–1196. https://doi.org/10.1002/nme.824

    Article  MATH  Google Scholar 

  10. Bendsøe MP (1989) Optimal shape design as a material distribution problem. Struct Optim 1(4):193–202. https://doi.org/10.1007/BF01650949

    Article  Google Scholar 

  11. Bendsøe MP, Sigmund O (2003) Topology optimization. Springer-Verlag, Berlin. Theory, methods and applications

    MATH  Google Scholar 

  12. Berggren M (2010) A unified discrete-continuous sensitivity analysis method for shape optimization. In: Applied and numerical partial differential equations, Comput. Methods Appl. Sci., vol. 15, pp. 25–39. Springer, New York. https://doi.org/10.1007/978-90-481-3239-3_4

  13. Burger M (2003) A framework for the construction of level set methods for shape optimization and reconstruction. Interfaces Free Bound 5(3):301–329. https://doi.org/10.4171/IFB/81

    MathSciNet  Article  MATH  Google Scholar 

  14. Challis VJ (2009) A discrete level-set topology optimization code written in matlab. Struct Multidiscip Optim 41(3):453–464

    MathSciNet  Article  MATH  Google Scholar 

  15. Chopp DL (1993) Computing minimal surfaces via level set curvature flow. J Comput Phys 106(1):77–91. https://doi.org/10.1006/jcph.1993.1092

    MathSciNet  Article  MATH  Google Scholar 

  16. Dambrine M, Kateb D (2010) On the ersatz material approximation in level-set methods. ESAIM Control Optim Calc Var 16(3):618–634. https://doi.org/10.1051/cocv/2009023

    MathSciNet  Article  MATH  Google Scholar 

  17. Delfour MC, Mghazli Z, Zolésio JP (1997) Computation of shape gradients for mixed finite element formulation. In: Partial differential equation methods in control and shape analysis (Pisa), Lecture Notes in Pure and Appl. Math., vol 188, pp 77–93. Dekker, New York

  18. Delfour MC, Zolésio JP (2011) Shapes and geometries, Advances in Design and Control, vol. 22, 2nd edn. Society for Industrial and Applied Mathematics (SIAM), Philadelphia, PA. https://doi.org/10.1137/1.9780898719826. Metrics, analysis, differential calculus, and optimization

  19. van Dijk NP, Maute K, Langelaar M, van Keulen F (2013) Level-set methods for structural topology optimization: a review. Struct Multidiscip Optim 48(3):437–472. https://doi.org/10.1007/s00158-013-0912-y

    MathSciNet  Article  Google Scholar 

  20. Fulmański P, Laurain A, Scheid JF, Sokołowski J (2007) A level set method in shape and topology optimization for variational inequalities. Int J Appl Math Comput Sci 17(3):413–430. https://doi.org/10.2478/v10006-007-0034-z

    MathSciNet  Article  MATH  Google Scholar 

  21. Fulmański P, Laurain A, Scheid JF, Sokołowski J (2008) Level set method with topological derivatives in shape optimization. Int J Comput Math 85(10):1491–1514. https://doi.org/10.1080/00207160802033350

    MathSciNet  Article  MATH  Google Scholar 

  22. Gain AL, Paulino GH (2013) A critical comparative assessment of differential equation-driven methods for structural topology optimization. Struct Multidiscip Optim 48(4):685–710. https://doi.org/10.1007/s00158-013-0935-4

    MathSciNet  Article  Google Scholar 

  23. Gangl P, Langer U, Laurain A, Meftahi H, Sturm K (2015) Shape optimization of an electric motor subject to nonlinear magnetostatics. SIAM J Sci Comput 37(6):B1002–B1025. https://doi.org/10.1137/15100477X

    MathSciNet  Article  MATH  Google Scholar 

  24. de Gournay F (2006) Velocity extension for the level-set method and multiple eigenvalues in shape optimization. SIAM J Control Optim 45(1):343–367. https://doi.org/10.1137/050624108

    MathSciNet  Article  MATH  Google Scholar 

  25. Hintermüller M, Laurain A (2009) Multiphase image segmentation and modulation recovery based on shape and topological sensitivity. J Math Imaging Vis 35(1):1–22

    MathSciNet  Article  Google Scholar 

  26. Hintermüller M, Laurain A, Yousept I (2015) Shape sensitivities for an inverse problem in magnetic induction tomography based on the eddy current model. Inverse Prob 31(6):065,006 25. https://doi.org/10.1088/0266-5611/31/6/065006

    MathSciNet  Article  MATH  Google Scholar 

  27. Hiptmair R, Paganini A, Sargheini S (2015) Comparison of approximate shape gradients. BIT 55 (2):459–485. https://doi.org/10.1007/s10543-014-0515-z

    MathSciNet  Article  MATH  Google Scholar 

  28. Langtangen H, Logg A (2017) Solving PDEs in Python: The FEniCS Tutorial I. Simula SpringerBriefs on Computing. Springer International Publishing, Berlin. https://books.google.com.br/books?id=tP71MAAACAAJ

    MATH  Google Scholar 

  29. Laurain A, Sturm K (2016) Distributed shape derivative via averaged adjoint method and applications. ESAIM: M2AN 50(4):1241–1267. https://doi.org/10.1051/m2an/2015075

    MathSciNet  Article  MATH  Google Scholar 

  30. Liu Z, Korvink J, Huang R (2005) Structure topology optimization: fully coupled level set method via femlab. Struct Multidiscip Optim 29(6):407–417

    MathSciNet  Article  MATH  Google Scholar 

  31. Logg A, Mardal KA, Wells GN (eds) (2012) Automated Solution of Differential Equations by the Finite Element Method, Lecture Notes in Computational Science and Engineering, vol 84. Springer, Berlin. https://doi.org/10.1007/978-3-642-23099-8

    Google Scholar 

  32. Luo J, Luo Z, Chen L, Tong L, Wang MY (2008) A semi-implicit level set method for structural shape and topology optimization. J Comput Phys 227(11):5561–5581. https://doi.org/10.1016/j.jcp.2008.02.003

    MathSciNet  Article  MATH  Google Scholar 

  33. Novotny AA, Sokołowski J (2013) Topological derivatives in shape optimization. Interaction of Mechanics and Mathematics. Springer, Heidelberg. https://doi.org/10.1007/978-3-642-35245-4

    Book  MATH  Google Scholar 

  34. Osher S, Fedkiw R (2003) Level set methods and dynamic implicit surfaces, Applied Mathematical Sciences, vol 153. Springer-Verlag, New York

    Book  MATH  Google Scholar 

  35. Osher S, Sethian JA (1988) Fronts propagating with curvature-dependent speed: algorithms based on Hamilton-Jacobi formulations. J Comput Phys 79(1):12–49

    MathSciNet  Article  MATH  Google Scholar 

  36. Osher S, Shu CW (1991) High-order essentially nonoscillatory schemes for Hamilton-Jacobi equations. SIAM J Numer Anal 28(4):907–922. https://doi.org/10.1137/0728049

    MathSciNet  Article  MATH  Google Scholar 

  37. Osher SJ, Santosa F (2001) Level set methods for optimization problems involving geometry and constraints. I. Frequencies of a two-density inhomogeneous drum. J Comput Phys 171(1):272–288. https://doi.org/10.1006/jcph.2001.6789

    MathSciNet  Article  MATH  Google Scholar 

  38. Otomori M, Yamada T, Izui K, Nishiwaki S (2014) Matlab code for a level set-based topology optimization method using a reaction diffusion equation. Struct Multidiscip Optim 51(5):1159–1172. https://doi.org/10.1007/s00158-014-1190-z

    MathSciNet  Article  Google Scholar 

  39. Peng D, Merriman B, Osher S, Zhao H, Kang M (1999) A PDE-based fast local level set method. J Comput Phys 155(2):410–438

    MathSciNet  Article  MATH  Google Scholar 

  40. Sethian JA (1999) Level set methods and fast marching methods, Cambridge Monographs on Applied and Computational Mathematics, vol 3, 2nd edn. Cambridge University Press, Cambridge. Evolving interfaces in computational geometry, fluid mechanics, computer vision, and materials science

    Google Scholar 

  41. Sethian JA, Wiegmann A (2000) Structural boundary design via level set and immersed interface methods. J Comput Phys 163(2):489–528. https://doi.org/10.1006/jcph.2000.6581

    MathSciNet  Article  MATH  Google Scholar 

  42. Sigmund O (2014) A 99 line topology optimization code written in matlab. Struct Multidiscip Optim 21 (2):120–127

    Article  Google Scholar 

  43. Sokołowski J, Zolésio JP (1992) Introduction to shape optimization, Springer Series in Computational Mathematics, vol 16. Springer-Verlag, Berlin. https://doi.org/10.1007/978-3-642-58106-9. Shape sensitivity analysis

    Book  Google Scholar 

  44. Sturm K (2015) Minimax Lagrangian approach to the differentiability of nonlinear PDE constrained shape functions without saddle point assumption. SIAM J Control Optim 53(4):2017–2039. https://doi.org/10.1137/130930807

    MathSciNet  Article  MATH  Google Scholar 

  45. Sturm K, Hintermüller M, Hömberg D (2016) Distortion compensation as a shape optimisation problem for a sharp interface model. Comput Optim Appl 64(2):557–588. https://doi.org/10.1007/s10589-015-9816-7

    MathSciNet  Article  MATH  Google Scholar 

  46. Talischi C, Paulino GH, Pereira A, Menezes IFM (2012) Polymesher: a general-purpose mesh generator for polygonal elements written in matlab. Struct Multidiscip Optim 45(3):309– 328

    MathSciNet  Article  MATH  Google Scholar 

  47. Talischi C, Paulino GH, Pereira A, Menezes IFM (2012) Polytop: a matlab implementation of a general topology optimization framework using unstructured polygonal finite element meshes. Struct Multidiscip Optim 45(3):329–357. https://doi.org/10.1007/s00158-011-0696-x

    MathSciNet  Article  MATH  Google Scholar 

  48. Wang MY, Wang X, Guo D (2003) A level set method for structural topology optimization. Comput Methods Appl Mech Engrg 192(1-2):227–246. https://doi.org/10.1016/S0045-7825(02)00559-5

    MathSciNet  Article  MATH  Google Scholar 

  49. Wang MY, Zhou S (2004) Phase field: a variational method for structural topology optimization. CMES Comput Model Eng Sci 6(6):547–566

    MathSciNet  MATH  Google Scholar 

  50. Zhao H (2005) A fast sweeping method for eikonal equations. Math Comp 74(250):603–627. https://doi.org/10.1090/S0025-5718-04-01678-3

    MathSciNet  Article  MATH  Google Scholar 

  51. Zhou M, Rozvany G (1991) The COC algorithm, part II: Topological, geometrical and generalized shape optimization. Comput Methods Appl Mech Eng 89(1):309–336. Second World Congress on Computational Mechanics

    Article  Google Scholar 

Download references

Acknowledgments

The author would like to thank the anonymous reviewers for their detailed comments and suggestions which have helped improve this paper significantly. The author acknowledges the support of FAPESP, process: 2016/24776-6, and of the Brazilian National Council for Scientific and Technological Development (Conselho Nacional de Desenvolvimento Científico e Tecnológico - CNPq), through the program “Bolsa de Produtividade em Pesquisa - PQ 2015”, process: 302493/2015-8.

Author information

Affiliations

Authors

Corresponding author

Correspondence to Antoine Laurain.

Additional information

Publisher’s Note

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

Responsible Editor: Gregoire Allaire

Electronic supplementary material

Below is the link to the electronic supplementary material.

(PY 9.55 KB)

(PY 8.54 KB)

(PY 11.0 KB)

(PDF 112 KB)

Appendix: FEniCS code compliance.py

Appendix: FEniCS code compliance.py

figurea
figureb
figurec

Rights and permissions

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Laurain, A. A level set-based structural optimization code using FEniCS. Struct Multidisc Optim 58, 1311–1334 (2018). https://doi.org/10.1007/s00158-018-1950-2

Download citation

Keywords

  • Level set method
  • Shape sensitivity analysis
  • FEniCS code
  • Education