Skip to main content
Log in

HoneyTop90: A 90-line MATLAB code for topology optimization using honeycomb tessellation

  • Educational Article
  • Published:
Optimization and Engineering Aims and scope Submit manuscript

Abstract

This paper provides a simple, compact and efficient 90-line pedagogical MATLAB code for topology optimization using hexagonal elements (honeycomb tessellation). Hexagonal elements provide nonsingular connectivity between two juxtaposed elements and, thus, subdue checkerboard patterns and point connections inherently from the optimized designs. A novel approach to generate honeycomb tessellation is proposed. The element connectivity matrix and corresponding nodal coordinates array are determined in 5 (7) and 4 (6) lines, respectively. Two additional lines for the meshgrid generation are required for an even number of elements in the vertical direction. The code takes a fraction of a second to generate meshgrid information for the millions of hexagonal elements. Wachspress shape functions are employed for the finite element analysis, and compliance minimization is performed using the optimality criteria method. The provided MATLAB code and its extensions are explained in detail. Options to run the optimization with and without filtering techniques are provided. Steps to include different boundary conditions, multiple load cases, active and passive regions, and a Heaviside projection filter are also discussed. The code is provided in Appendix A, and it can also be downloaded along with supplementary materials from https://github.com/PrabhatIn/HoneyTop90.

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

Similar content being viewed by others

Notes

  1. Which is not trivial to generate.

  2. Coarse FEs are used for clear visibility.

  3. \(\eta _1^1=\cos (\frac{\pi }{6}),\,\eta _2^1=\sin (\frac{\pi }{6})\)

References

  • Andreassen E, Clausen A, Schevenels M, Lazarov BS, Sigmund O (2011) Efficient topology optimization in matlab using 88 lines of code. Structural and Multidisciplinary Optimization 43(1):1–16

    Article  MATH  Google Scholar 

  • Bourdin B (2001) Filters in topology optimization. International journal for numerical methods in engineering 50(9):2143–2158

    Article  MathSciNet  MATH  Google Scholar 

  • Bruns TE, Tortorelli DA (2001) Topology optimization of non-linear elastic structures and compliant mechanisms. Computer methods in applied mechanics and engineering 190(26–27):3443–3459

    Article  MATH  Google Scholar 

  • Challis VJ (2010) A discrete level-set topology optimization code written in matlab. Structural and multidisciplinary optimization 41(3):453–464

    Article  MathSciNet  MATH  Google Scholar 

  • Ferrari F, Sigmund O (2020) A new generation 99 line matlab code for compliance topology optimization and its extension to 3D. Structural and Multidisciplinary Optimization 62(4):2211–2228

    Article  MathSciNet  Google Scholar 

  • Giraldo-Londoño O, Paulino GH (2021) Polystress: a matlab implementation for local stress-constrained topology optimization using the augmented lagrangian method. Structural and Multidisciplinary Optimization 63(4):2065–2097

    Article  MathSciNet  Google Scholar 

  • Haber RB, Jog CS, Bendsøe MP (1996) A new approach to variable-topology shape design using a constraint on perimeter. Structural optimization 11(1):1–12

    Article  Google Scholar 

  • Han Y, Xu B, Liu Y (2021) An efficient 137-line matlab code for geometrically nonlinear topology optimization using bi-directional evolutionary structural optimization method. Structural and Multidisciplinary Optimization 63(5):2571–2588

    Article  MathSciNet  Google Scholar 

  • Han Y, Xu B, Wang Q, Liu Y, Duan Z (2021) Topology optimization of material nonlinear continuum structures under stress constraints. Computer Methods in Applied Mechanics and Engineering 378:113731

    Article  MathSciNet  MATH  Google Scholar 

  • Huang X, Xie M (2010) Evolutionary topology optimization of continuum structures: methods and applications. John Wiley & Sons

  • Kumar P (2017) Synthesis of large deformable contact-aided compliant mechanisms using hexagonal cells and negative circular masks. PhD thesis, Indian Institute of Technology Kanpur

  • Kumar P (2022) Topology optimization of stiff structures under self-weight for given volume using a smooth heaviside function. Structural and Multidisciplinary Optimization 65(4):1–17

    Article  MathSciNet  Google Scholar 

  • Kumar P, Saxena A (2015) On topology optimization with embedded boundary resolution and smoothing. Structural and Multidisciplinary Optimization 52(6):1135–1159

    Article  MathSciNet  Google Scholar 

  • Kumar P, Sauer RA, Saxena A (2016) Synthesis of c0 path-generating contact-aided compliant mechanisms using the material mask overlay method. Journal of Mechanical Design 138(6)

  • Kumar P, Saxena A, Sauer RA (2019) Computational synthesis of large deformation compliant mechanisms undergoing self and mutual contact. Journal of Mechanical Design 141(1)

  • Kumar P, Frouws J, Langelaar M (2020) Topology optimization of fluidic pressure-loaded structures and compliant mechanisms using the Darcy method. Structural and Multidisciplinary Optimization 61(4)

  • Kumar P, Sauer RA, Saxena A (2021) On topology optimization of large deformation contact-aided shape morphing compliant mechanisms. Mechanism and Machine Theory 156:104135

    Article  Google Scholar 

  • Langelaar M (2007) The use of convex uniform honeycomb tessellations in structural topology optimization. 7th world congress on structural and multidisciplinary optimization. Seoul, South Korea, pp 21–25

    Google Scholar 

  • Lyness J, Monegato G (1977) Quadrature rules for regions having regular hexagonal symmetry. SIAM Journal on Numerical Analysis 14(2):283–295

    Article  MathSciNet  MATH  Google Scholar 

  • Picelli R, Sivapuram R, Xie YM (2020) A 101-line matlab code for topology optimization using binary variables and integer programming. Structural and Multidisciplinary Optimization pp 1–20

  • Sanders ED, Pereira A, Aguiló MA, Paulino GH (2018) Polymat: an efficient matlab code for multi-material topology optimization. Structural and Multidisciplinary Optimization 58(6):2727–2759

    Article  MathSciNet  Google Scholar 

  • Saxena A (2011) Topology design with negative masks using gradient search. Structural and Multidisciplinary Optimization 44(5):629–649

    Article  Google Scholar 

  • Saxena A, Sauer RA (2013) Combined gradient-stochastic optimization with negative circular masks for large deformation topologies. International Journal for Numerical Methods in Engineering 93(6):635–663

    Article  MathSciNet  MATH  Google Scholar 

  • Saxena R, Saxena A (2003) On honeycomb parameterization for topology optimization of compliant mechanisms. International Design Engineering Technical Conferences and Computers and Information in Engineering Conference 37009:975–985

    Google Scholar 

  • Saxena R, Saxena A (2007) On honeycomb representation and sigmoid material assignment in optimal topology synthesis of compliant mechanisms. Finite Elements in Analysis and Design 43(14):1082–1098

    Article  Google Scholar 

  • Sigmund O (1997) On the design of compliant mechanisms using topology optimization. Journal of Structural Mechanics 25(4):493–524

    Google Scholar 

  • Sigmund O (2001) A 99 line topology optimization code written in matlab. Structural and multidisciplinary optimization 21(2):120–127

    Article  Google Scholar 

  • Sigmund O (2007) Morphology-based black and white filters for topology optimization. Structural and Multidisciplinary Optimization 33(4–5):401–424

    Article  Google Scholar 

  • Sigmund O, Maute K (2013) Topology optimization approaches. Structural and Multidisciplinary Optimization 48(6):1031–1055

    Article  MathSciNet  Google Scholar 

  • Singh N, Kumar P, Saxena A (2020) On topology optimization with elliptical masks and honeycomb tessellation with explicit length scale constraints. Structural and Multidisciplinary Optimization 62(3):1227–1251

    Article  MathSciNet  Google Scholar 

  • Sukumar N, Tabarraei A (2004) Conforming polygonal finite elements. International Journal for Numerical Methods in Engineering 61(12):2045–2066

    Article  MathSciNet  MATH  Google Scholar 

  • Suresh K (2010) A 199-line matlab code for pareto-optimal tracing in topology optimization. Structural and Multidisciplinary Optimization 42(5):665–679

    Article  MathSciNet  MATH  Google Scholar 

  • Svanberg K (1987) The method of moving asymptotes-a new method for structural optimization. International journal for numerical methods in engineering 24(2):359–373

    Article  MathSciNet  MATH  Google Scholar 

  • Tabarraei A, Sukumar N (2006) Application of polygonal finite elements in linear elasticity. International Journal of Computational Methods 3(04):503–520

    Article  MathSciNet  MATH  Google Scholar 

  • Talischi C, Paulino GH, Le CH (2009) Honeycomb wachspress finite elements for structural topology optimization. Structural and Multidisciplinary Optimization 37(6):569–583

    Article  MathSciNet  MATH  Google Scholar 

  • Talischi C, Paulino GH, Pereira A, Menezes IF (2012) Polymesher: a general-purpose mesh generator for polygonal elements written in matlab. Structural and Multidisciplinary Optimization 45(3):309–328

    Article  MathSciNet  MATH  Google Scholar 

  • Talischi C, Paulino GH, Pereira A, Menezes IF (2012) Polytop: a matlab implementation of a general topology optimization framework using unstructured polygonal finite element meshes. Structural and Multidisciplinary Optimization 45(3):329–357

    Article  MathSciNet  MATH  Google Scholar 

  • Wachspress EL (1975) A rational finite element basis

  • Wang C, Zhao Z, Zhou M, Sigmund O, Zhang XS (2021) A comprehensive review of educational articles on structural and multidisciplinary optimization. Structural and Multidisciplinary Optimization pp 1–54

  • Wang F, Lazarov BS, Sigmund O (2011) On projection methods, convergence and robust formulations in topology optimization. Structural and Multidisciplinary Optimization 43(6):767–784

    Article  MATH  Google Scholar 

  • Wei P, Li Z, Li X, Wang MY (2018) An 88-line matlab code for the parameterized level set method based topology optimization using radial basis functions. Structural and Multidisciplinary Optimization 58(2):831–849

    Article  MathSciNet  Google Scholar 

  • Xu B, Han Y, Zhao L (2020) Bi-directional evolutionary topology optimization of geometrically nonlinear continuum structures with stress constraints. Applied Mathematical Modelling 80:771–791

    Article  MathSciNet  MATH  Google Scholar 

Download references

Acknowledgements

The author would like to thank Prof. Anupam Saxena, Indian Institute of Technology Kanpur, India, for fruitful discussions, and to acknowledge financial support from the Science & Engineering research board, Department of Science and Technology, Government of India under the project file number RJF/2020/000023.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to P. Kumar.

Ethics declarations

Conflict of interest

The author declares no conflict of interest.

Additional information

Publisher's Note

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

Supplementary Information

Below is the link to the electronic supplementary material.

Supplementary file 1 (m 2 KB)

Supplementary file 2 (m 6 KB)

Appendices

Appendix A: HoneyTop90 MATLAB code

figure ab

Appendix B: Sensitivity analysis

In this paper, the optimality criteria approach is employed for the optimization. Therefore, derivatives of the objective and constraint with respect to the design variables are required. Herein, the adjoint-variable method is used to determine the sensitivity of the objective, \(C({{\varvec{\rho }}}) = {\mathbf {u}}^\top {\mathbf {K}}({\varvec{\rho }}){\mathbf {u}}\). The overall performance function \({\mathcal {L}}\) in conjunction with the state equation, \({\mathbf {K}} {\mathbf {u}} - {\mathbf {F}} = {\mathbf {0}}\) is written as

$$\begin{aligned} {\mathcal {L}} = C + {\varvec{\lambda }}^\top ({\mathbf {K}} {\mathbf {u}} - {\mathbf {F}}), \end{aligned}$$
(B.1)

where \({\varvec{\lambda }}\) is the Lagrange multiplier vector. In view of (B.1), one finds derivative of \({\mathcal {L}}\) with respect to \({\varvec{\rho }}\) as

$$\begin{aligned} \frac{\partial {\mathcal {L}}}{\partial {\varvec{\rho }}}= & {} \frac{\partial C}{\partial {\varvec{\rho }}} + \frac{\partial C}{\partial {\mathbf {u}}}\frac{\partial {\mathbf {u}}}{\partial {\varvec{\rho }}} + {\varvec{\lambda }}^\top \left( \frac{\partial {\mathbf {K}}}{\partial {\varvec{\rho }}} {\mathbf {u}}+ {\mathbf {K}} \frac{\partial {\mathbf {u}}}{\partial {\varvec{\rho }}}\right) \nonumber \\= & {} {\mathbf {u}}^\top \frac{\partial {\mathbf {K}}}{\partial {\varvec{\rho }}}{\mathbf {u}} + 2{\mathbf {u}}^\top {\mathbf {K}}\frac{\partial {\mathbf {u}}}{\partial {\varvec{\rho }}} + {\varvec{\lambda }}^\top \frac{\partial {\mathbf {K}}}{\partial {\varvec{\rho }}}{\mathbf {u}} + {\varvec{\lambda }}^\top {\mathbf {K}} \frac{\partial {\mathbf {u}}}{\partial {\varvec{\rho }}} \qquad \left( \text {using},\, C({{\varvec{\rho }}}) = {\mathbf {u}}^\top {\mathbf {K}} ({\varvec{\rho }}){\mathbf {u}}\right) \nonumber \\= & {} {\mathbf {u}}^\top \frac{\partial {\mathbf {K}}}{\partial {\varvec{\rho }}}{\mathbf {u}} + {\varvec{\lambda }}^\top \frac{\partial {\mathbf {K}}}{\partial {\varvec{\rho }}}{\mathbf {u}} + \underbrace{\left( 2{\mathbf {u}}^\top {\mathbf {K}} + {\varvec{\lambda }}^\top {\mathbf {K}}\right) }_{\Theta }\frac{\partial {\mathbf {u}}}{\partial {\varvec{\rho }}} \end{aligned}$$
(B.2)

In (B.2), \(\Theta = 0\), the adjoint equation, yields \({\varvec{\lambda }} = -2{\mathbf {u}}\) and thus, one writes (B.1) as

$$\begin{aligned} \begin{aligned} \frac{\partial {\mathcal {L}}}{\partial {\varvec{\rho }}}&= {\mathbf {u}}^\top \frac{\partial {\mathbf {K}}}{\partial {\varvec{\rho }}}{\mathbf {u}} -2{\mathbf {u}}^\top \frac{\partial {\mathbf {K}}}{\partial {\varvec{\rho }}}{\mathbf {u}} \\&= - {\mathbf {u}}^\top \frac{\partial {\mathbf {K}}}{\partial {\varvec{\rho }}}{\mathbf {u}} \end{aligned} \end{aligned}$$
(B.3)

Therefore, in view of (B.3), the derivative of objective C with respect to design variable \(\rho _j\) can be written as

$$\begin{aligned} \frac{\partial C}{\partial \rho _j} = -{\mathbf {u}}_j^\top \frac{\partial {\mathbf {k}}_j}{\partial \rho _j} {\mathbf {u}}_j \end{aligned}$$
(B.4)

where \({\mathbf {u}}_j\) and \({\mathbf {k}}_j\) are the displacement vector and the stiffness matrix of element j, respectively.

Fig. 13
figure 13

A regular hexagonal element with vertices \(\hbox {V}_i|_{i = 1,\,2,\,\cdots ,\,6}\) and circumscribing circle \({C}_\text {c}\) with radius 1 unit. Coordinates of vertex \(\hbox {V}_i\) are \(\left( (\eta _1^i,\,\eta _2^i) \equiv \left( \cos (\frac{(2i-1)\pi }{6}),\,\sin (\frac{(2i-1)\pi }{6})\right) \right) \). Straight lines \(l_i\) pass through vertices \(\hbox {V}_i\) and \(\hbox {V}_{i-1}\). \(\hbox {P}_{i\,{i+2}}\) are the intersection points of straight lines \(l_i\) and \(l_{i+2}\). Circle \({C}_\text {s}\) with radius \(\sqrt{3}\) unit is drawn that passes through points \(\hbox {P}_{i\,{i+2}}\)

Appendix C: Wachspress shape functions

Figure 13 depicts a hexagonal element with vertices \(\hbox {V}_i|_{i = 1,\,2,\,3,\,\cdots ,\,6}\) in \({\varvec{\eta }}\) co-ordinates system. Coordinates of vertex \(\hbox {V}_i\) are \(\left( (\eta _1^i,\,\eta _2^i) \equiv \left( \cos (\frac{(2i-1)\pi }{6}),\,\sin (\frac{(2i-1)\pi }{6})\right) \right) \). The circumscribing circle with radius 1 unit is represented via \({C}_\text {c}\). Let Wachspress shape function for vertex \(\hbox {V}_i\) (Fig. 13) be \(N_i\). Using the fundamentals of coordinate geometry and in view of coordinates of \(\hbox {V}_i\), the equations of straight lines \(l_i\) (Fig. 13) can be written as

(C.1)

and likewise, the equation of circle \({C}_\text {s}\) (cf. Fig. 13, passing through \(\hbox {P}_{i i+2}\)) can be written as

$$\begin{aligned} {C}_\text {s}({\varvec{\eta }}) \equiv \eta _1^2 + \eta _2^2 - 3 = 0. \end{aligned}$$
(C.2)

Straight lines \(l_i\) and \(l_{i+2}\) intersect at points \(\hbox {P}_{i\,{i+2}}\) (Fig. 13). The shape function of node 1, i.e., \(N_1\) is determined as (Wachspress 1975)

$$\begin{aligned} N_1 = s_1\frac{l_2({\varvec{\eta }}) l_3({\varvec{\eta }}) l_4({\varvec{\eta }}) l_5({\varvec{\eta }})}{{C}_\text {s}({\varvec{\eta }})}, \end{aligned}$$
(C.3)

where \(s_1\), a constant, is calculated using the Kronecker-delta property of a shape function, which is defined as

$$\begin{aligned} N_i({\varvec{\eta }}_j) = \delta _{ij} = {\left\{ \begin{aligned} 1, \quad \text {if}\,\, i = j\\ 0, \quad \text {if}\,\,i\ne j\\ \end{aligned}\right. }. \end{aligned}$$
(C.4)

Now, in view of coordinatesFootnote 3 of node 1, i.e., \(\left( \eta _1^1,\,\eta _2^1\right) \) and (C.4), (C.3) yields

$$\begin{aligned} s_1 = \frac{{C}_\text {s}(\eta _1^1,\,\eta _2^1)}{l_2(\eta _1^1,\,\eta _2^1) l_3(\eta _1^1,\,\eta _2^1) l_4(\eta _1^1,\,\eta _2^1) l_5(\eta _1^1,\,\eta _2^1)} = \frac{1}{18}. \end{aligned}$$
(C.5)

Likewise, one can determine Wachspress shape functions for all other nodes with their respective constants. The final expressions of the shape functions are:

(C.6)

Appendix D: Numerical Integration

To evaluate stiffness matrix of an element, numerical integration approach using the quadrature points is employed. As per (Lyness and Monegato 1977), quadrature points for a hexagonal element are given in Table 4, and a function \(f\left( \eta _1,\,\eta _2\right) \) can be integrated as

$$\begin{aligned} \int _{A_6}f\left( \eta _1,\,\eta _2\right) \text {d}\Omega \approx A_6\left( w_o f(0,\,0) + \sum _{k=2}^{k_\text {max}}\sum _{i=1}^{6} w_k f\left( r_k,\,\alpha _k + \frac{\pi i}{3}\right) \right) . \end{aligned}$$
(D.1)

where \(A_6\) is the area of a regular hexagonal element. Table 4 notes the quadrature points N with coordinates \(\left( \eta _1^a,\,\eta _2^a\right) \) \( = \left( r_k\cos (\alpha _k + \frac{i\pi }{3}),r_k\sin (\alpha _k + \frac{i\pi }{3})\right) \). \(w_k\) indicate the weights for these points. \(i =1,\,2,\,3,\,\cdots ,\,6\), if \(k>1\), and \( i =1,\,\text {if}\, k=1\), corresponds to single integration point at center \((0,\,0)\). For \(k>1\), six integration points lie on the a circle with center at (0, 0) and radius \(r_k\). Note that the quadrature rule is invariant under a rotation of \(60^o\) for a hexagonal element.

Table 4 Quadrature points for a hexagonal element

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Kumar, P. HoneyTop90: A 90-line MATLAB code for topology optimization using honeycomb tessellation. Optim Eng 24, 1433–1460 (2023). https://doi.org/10.1007/s11081-022-09715-6

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11081-022-09715-6

Keywords

Navigation