Abstract
We introduce Fireshape, an opensource and automated shape optimization toolbox for the finite element software Firedrake. Fireshape is based on the moving mesh method and allows users with minimal shape optimization knowledge to tackle with ease challenging shape optimization problems constrained to partial differential equations (PDEs).
Introduction
One of the ultimate goals of structural optimization is the development of fully automated software that allows users to tackle challenging structural optimization problems in the automotive, naval, and aerospace industries without requiring deep knowledge of structural optimization theory. The scientific community is working actively in this direction, and recent years have seen the publication of educational material that simplifies the understanding of structural optimization algorithms and guides the development of related optimization software. These resources are based on different models, such as moving mesh methods (Allaire and Pantz 2006; Dapogny et al. 2018; Courtais et al. 2019; Allaire 2007), levelsets (Laurain 2018; Allaire et al. 2002; Bernland et al. 2019), phase fields (Garcke et al. 2015; Dondl et al. 2019; Blank et al. 2014), and SIMP^{Footnote 1} (Sigmund 2001; Talischi et al. 2012; Bendsøe 1989; Bendsoe and Sigmund 2004), and are implemented in various software environments such as Matlab (Sigmund 2001; Talischi et al. 2012), FreeFem++ (Allaire and Pantz 2006; Dapogny et al. 2018; Allaire et al. 2002), OpenFOAM CFD (Courtais et al. 2019), FEMLAB (Liu et al. 2005), and FEniCS (Laurain 2018; Dokken et al. 2019), to mention just a few.
In this work, we introduce Fireshape: an automated shape optimization library based on the moving mesh approach that requires very limited input from the user. Shape optimization refers to the optimization of domain boundaries and plays an important role in structural design. For instance, shape optimization plays a crucial role in the design of airfoils (He et al. 2019; Wang et al. 2018; Schmidt et al. 2013) and boat hulls (Lombardi et al. 2012; MarinićKragić et al. 2016; Abramowski and Sugalski 2017). Shape optimization is also a useful refinement step to be employed after topology optimization (Bendsoe and Sigmund 2004, Ch. 1.4). Indeed, topology optimization allows more flexibility in geometric changes and it is a powerful tool to explore a large design space. However, topology optimization may return slightly blurred (greyscale) and/or staircase designs (Bendsoe and Sigmund 2004). By adding a final shape optimization step, it is possible to postprocess results computed with topology optimization and devise optimal designs with sharp boundaries and interfaces, when this is necessary.
Fireshape is based on the moving mesh shape optimization approach (Allaire 2007, Ch. 6). In this approach, geometries are parametrized with meshes that can be arbitrarily precise and possibly curvilinear. The mesh nodes and faces are then optimized (or “moved”) to minimize a chosen target function. Fireshape has been developed on the moving mesh approach because the latter has a very neat interpretation in terms of geometric transformations and is inherently compatible with standard finite element software, as it relies on the canonical construction of finite elements via pullbacks (Paganini et al. 2018). The main drawback of the moving mesh approach is that it does not allow topological changes in a straightforward and consistent fashion. However, Fireshape has been developed to facilitate shape optimization, and topology optimization is beyond its scope.
Fireshape couples the finite element library Firedrake (Rathgeber et al. 2016; Luporini et al. 2017; Homolya et al. 2018; Homolya et al. 2017; Gibson et al. 2020) with the Rapid Optimization Library (ROL) (Ridzal and Kouri 2014). Fireshape allows decoupled discretization of geometries and state constraints and it includes all necessary routines to perform shape optimization (geometry updates, regularization terms, geometric constraints, etc.). To solve a shape optimization problem in Fireshape, users must describe the objective function and the eventual constraints using the Unified Form Language (UFL) (Alnæs et al. 2014), a language embedded in Python to describe variational forms and their finite element discretizations that is very similar to standard mathematical notation. Once objective functions and constraints have been implemented with UFL, users need only to provide a mesh that describes the initial design and, finally, select their favorite optimization algorithm from the optimization library ROL, which contains algorithms for unconstrained, bound constrained, and (in)equality constrained optimisation problems. In particular, users do not need to spend time deriving shape derivative formulas and adjoint equations by hand, nor worry about their discretization, because Fireshape automates these tasks.
Typically the computational bottleneck of PDE constrained optimization code lies in the solution of the state and the adjoint equation. While Fireshape and Firedrake are both written in Python, to assemble the state and adjoint equations the Firedrake library automatically generates optimized kernels in the C programming language. The generated systems of equations are then passed to the PETSc library (also written in C) and can be solved using any of the many linear solvers and preconditioners accessible from PETSc (Balay et al. 2019; Balay et al. 1997; Dalcin et al. 2011; Chevalier and Pellegrini 2008; Amestoy et al. 2000; Hypre 2020). This combination of Python for user facing code and C for performance critical parts is well established in scientific computing as it provides highly performant code that is straightforward to develop and use. Finally, we mention that Fireshape, just as Firedrake, PETSc and ROL, supports MPI parallelization and hence can be used to solve even largescale threedimensional shape optimization problems. In particular, Firedrake has been used to solve systems with several billion degrees of freedom on supercomputers with tens of thousands of cores (see, e.g., Mitchell and Müller 2016; Farrell et al. 2019), and we emphasize that any PDE solver written in Firedrake can be used for shape optimization problems with Fireshape.
Fireshape is an opensource software licensed under the GNU Lesser General Public License v3.0. Fireshape can be downloaded at https://github.com/Fireshape/Fireshape .
Its documentation contains several tutorials and is available at https://fireshape.readthedocs.io/en/latest/. To illustrate Fireshape’s capabilities and ease of use, in Section 2 we provide a tutorial and solve a threedimensional shape optimization problem constrained by the nonlinear NavierStokes equations. The shape optimization knowledge required to understand this tutorial is minimal. In Section 3, we provide another tutorial based on a shape optimization problem constrained to the linear elasticity equation. In Section 4, we describe in detail the rich mathematical theory that underpins Fireshape. In Section 5, we describe Fireshape’s main classes and Fireshape’s extended functionality. Finally, in Section 6, we provide concluding remarks.
Example: shape optimization of a pipe
For this handson introduction to Fireshape, we first consider a viscous fluid flowing through a pipe Ω (see Fig. 1) and aim to minimize the kinetic energy dissipation into heat by optimizing the design of Ω. This is a standard test case (Zhou and Li 2008; Villanueva and Maute 2017; Feppon et al. 2020; Dilgen et al. 2018; Dapogny et al. 2017). To begin with, we need to describe this optimization problem with a mathematical model.
We assume that the fluid velocity u and the fluid pressure p satisfy the incompressible NavierStokes equations (Elman et al. 2014, Eq. (8.1)), which read
where ν denotes the fluid viscosity, \(\varepsilon {\mathbf {u}} = \varepsilon ({\mathbf {u}}) = \frac {1}{2}(\nabla {\mathbf {u}}+\nabla {\mathbf {u}}^{\top })\), ∇u is the derivative (Jacobian matrix) of u and ∇u^{⊤} is the derivative transposed, Γ denotes the outlet, and the function g is a Poiseuille flow velocity (Elman et al. 2014, p. 122) at the inlet and zero on the pipe walls. In our numerical experiment, the inlet is a disc of radius 0.5 in the xyplane, and g(x, y, z) = (0,0,1 − 4(x^{2} + y^{2}))^{⊤} on the inlet.
To model the kinetic energy dissipation, we consider the diffusion term in (1a) and introduce the function
where the colon symbol : denotes the Frobenius inner product, that is, εu : εu = trace((εu)^{⊤}εu).
Now, we can formulate the shape optimizations problem we are considering. This reads:
To make this test case more interesting, we further impose a volume equality constraint on Ω. Otherwise, without this volume constraint, the solution to this problem would be a pipe with arbitrarily large diameter.
In the next subsections, we explain step by step how to solve this shape optimization problem in Fireshape. To this end, we need to create: a mesh that approximates the initial guess Ω (Section 2.1), an object that describes the PDE constraint (1) (Section 2.2), an object that describes the objective function (2) (Section 2.3), and, finally, a “main file” to set up and solve the optimization problem (3) with the additional volume constraint (Section 2.4).
Step 1: Provide an initial guess
The first step is to provide a mesh that describes an initial guess of Ω. For this tutorial, we create this mesh using the software Gmsh (Geuzaine and Remacle 2009). The initial guess employed is sketched in Fig. 1. The only mesh detail necessary to understand this tutorial is that, in Listing 1, the number 10 corresponds to the inlet, wheres the boundary flags 12 and 13 refer to the pipe’s boundary. For the remaining geometric details, we refer to the code archived on Zenodo (2020).
Step 2: Implement the PDE constraint
The second step is to implement a finite element solver of the NavierStokes equations (1). To derive the weak formulation of (1a), we multiply (1a) with a test (velocity) function v that vanishes on ∂Ω ∖Γ, and (1b) with a test (pressure) function q. Then, we integrate over Ω, integrate by parts (Elman et al. 2014, Eq. (3.18)), and impose the boundary condition (1d). The resulting weak formulation of equations (1) reads:
To implement the finite element discretization of (4), we create a class NavierStokesSolver that inherits from the Fireshape’s class PdeConstraint, see Listing 1. To discretize (4), we employ P2P1 TaylorHood finite elements, that is, we discretize the trial and test velocity functions u and v with piecewise quadratic Lagrangian finite elements, and the trial and test pressure functions p and q with piecewise affine Lagrangian finite elements. It is well known that this is a stable discretization of the incompressible NavierStokes equations (Elman et al. 2014, pp. 136–137).
To address the nonlinearity in (4), we use PETSc’s Scalable Nonlinear Equations Solvers (SNES) (Balay et al. 2019; Balay et al. 1997; Dalcin et al. 2011; Chevalier and Pellegrini 2008; Amestoy et al. 2000; Hypre 2020). In each iteration, SNES linearizes (4) and solves the resulting system with a direct solver. In general, it is possible that the SNES solver fails to converge sufficiently quickly (in our code, we allow at most 100 SNES iterations). For instance, this happens if the finite element mesh selfintersects, or if the initial guess used to solve (4) is not sufficiently good. Most often, these situations happen when the optimization algorithm takes an optimization step that is too large. In these cases, we can address SNES’ failure to solve (4) by reducing the optimization step. In practice, we deal with these situations with Python’s try: ... except: ... block. If the SNES solver fails with a ConvergenceError, we catch this error and set the boolean flag self.failed_to_solve to True. This flag is used to adjust the output of the objective function J, see Section 2.3.
Step 3: Implement the objective function
The third step is to implement a code to evaluate the objective function J defined in (2). For this, we create a class EnergyDissipation that inherits from Fireshape’s class ShapeObjective (see Listing 2). Of course, evaluating J requires access to the fluid velocity u. This access is implemented by assigning the variable self.pde_solver. This variable gives access also to the variable NavierStokesSolver.failed_to_solve, which can be used to control the output of J when the NavierStokes’ solver fails to converge. Here, we decide that the value of J is NaN (“not a number”) if the NavierStokes’ solver fails to converge.
Final step: Set up and solve the problem
At this stage, we have all the necessary ingredients to tackle the shape optimization problem (3). The final step is to create a “main file” that loads the initial mesh, sets up the optimization problem, and solves it with an optimization algorithm. The rest of this section contains a linebyline description of the “main file”, which is listed in Listing 3.

In lines 1–6, we import all necessary Python libraries and modules.

In lines 8–13, we load the mesh of the initial design and we specify to discretize perturbations of the domain Ω using quadratic Bsplines with support in a box that does not include the inlet and the outlet. In this example, we also impose some boundary regularity on Bsplines and limit perturbations to be only in direction of the yaxis. Sections 5.1 and 5.2 provide more details about the Fireshape classes ControlSpace and InnerProduct.

In lines 15–16, we initiate the NavierStokes finite element solver.

In lines 18–19, we tell Fireshape to store the finite element solution to NavierStokes’ equations in the folder solution every time the domain Ω is updated. We can visualize the evolution of u along the optimization process by opening the file u.pvd with Paraview (Ahrens et al. 2005).

In lines 21–22, we initiate the objective function J and the associated reduced functional, which is used by Fireshape to define the appropriate Lagrange functionals to shape differentiate J. We refer to Section 4.2 for more details about shape differentiation using Lagrangians. We stress that Fireshape does not require users to derive (and implement) shape derivative formulas by hand. The whole shape differentiation process is automated using pyadjoint (Ham et al. 2019; Dokken et al. 2020), see Remark 1.

In lines 24–25, we add an additional regularization term to J to promote mesh quality of domain updates. This regularization term controls the pointwise maximum singular value of the geometric transformation used to update Ω (Wechsung 2019). See Section 4.2, Fig. 9, and Remark 3 for more information about the role of geometric transformations in Fireshape.

In lines 27–30, we set up an equality constraint to ensure that the volume of the initial and the optimized domains are equal.

In lines 32–43, we select an optimization algorithm from the optimization library ROL. More specifically, we use an augmented Lagrangian approach (Nocedal and Wright 2006, Ch. 17.3) with limitedmemory BFGS Hessian updates (Nocedal and Wright 2006, Ch. 6.1) to deal with the volume equality constraint, and a TrustRegion algorithm (Nocedal and Wright 2006, Ch. 4.1) to solve the intermediate models generated by the augmented Lagrangian algorithm.

In lines 44–47, finally, we gather all information and solve the problem.
Remark 1
A reader may wonder why Fireshape does not require information about shape derivative formulas and adjoint equations to solve a PDEconstrained shape optimization problem. This is possible because Fireshape employs UFL’s and pyadjoint’s automated shape differentiation and adjoint derivation capabilities (Ham et al. 2019; Dokken et al. 2020). In particular, UFL combines the automated construction of finite element pullbacks with symbolic differentiation to automate the evaluation of directional shape derivatives along vector fields discretized by finite elements (Ham et al. 2019). This process mimics the analytical differentiation of shape functions and is equivalent to the “optimizethendiscretize” paradigm, i.e. it yields exact (up to floating point accuracy) derivatives.
Results
Running the code contained in Listing 3 optimizes the pipe design when the fluid viscosity ν is 0.1, which corresponds to Reynolds number R = 1./ν = 10. Of course, the resulting shape depends on the fluid viscosity. A natural question is how the optimized shape depends on this parameter. To answer this question, we can simply run Listing 3 for different Reynolds numbers (by modifying line 13 with the desired value) and inspect the results. Here we perform this comparison for R∈{1,250,500,750,1000}.^{Footnote 2}
In Fig. 2, we show the initial design and plot the magnitude of the fluid velocity on a cross section of the pipe for different Reynolds numbers.
In Fig. 3, we show the resulting optimized shapes, and in Fig. 4 the corresponding magnitudes of the fluid velocity. Qualitatively, we observe that, as the Reynolds number increase, we obtain increasingly Sshaped designs that avoid high curvature at the two fixed ends. Finally, we remark that the objective is reduced by approximately 6.9%, 9.5%, 10.8%, 11.7% and 12.1% in at most 10 augmented Lagrangian steps, respectively. Each numerical experiment was run in parallel on a server with 36 cores.
Example: shape optimization of a cantilever
In this second tutorial, we consider another shape optimization classic (Allaire and Pantz 2006; Allaire 2007): the minimization of the compliance of a cantilever Ω (see Fig. 5) subject to a dead surface load g. To make this example reproducible on a basic laptop we consider a two dimensional version of this problem. Adapting the code presented in this section to simulate a threedimensional cantilever is straightforward.
We model the cantilever elastic response using the linear elasticity equations (Braess 2007, Ch. VI, Sect. 3). More precisely, we consider the displacement formulation: the displacement field u satisfies the variational problem
where σ(u) = λ div (u)I + 2με(u), λ and μ are the Lamé constants, I is the identity matrix, \(\varepsilon ({\mathbf {u}}) = \frac {1}{2}(\nabla {\mathbf {u}}+\nabla {\mathbf {u}}^{\top })\), ∇u is the derivative (Jacobian matrix) of u and ∇u^{⊤} is the derivative transposed, the colon symbol : denotes the Frobenius inner product, that is σ(u) : ε(v) = trace(σ(u)^{⊤}ε(v)), and Γ_{2} denotes the part of the boundary that is subject to the surface load g. Additionally, although not explicitly indicated in (5), the displacement u vanishes on Γ_{1}, which is the part of the boundary ∂Ω that corresponds to the wall (see Fig. 5).
To model the compliance of the structure Ω, we consider the functional
where u is the displacement and satisfies (5).
As typical for this shape optimization test case, we also impose a volume equality constraint on Ω to prescribe the amount of material used to fabricate the cantilever.
Similarly to Section 2, in the following subsections we explain how to solve this shape optimization test case in Fireshape.
Step 1: Provide an initial guess
To create the mesh of the initial guess, we use again the software Gmsh (Geuzaine and Remacle 2009). The initial guess employed is sketched in Fig. 5. The only mesh detail necessary to understand this tutorial is that, in Listing 4, the number 1 corresponds to Γ_{1}, whereas the boundary flag 2 refers to Γ_{2}. For the remaining geometric details, we refer to the code archived on Zenodo (2020).
Step 2: Implement the PDE constraint
In this example, the PDE constraint (5) is already in weak form. To implement its finite element discretization, we create a class LinearElasticitySolver that inherits from Fireshape’s class PdeConstraint (see Listing 4). To discretize (5), we employ the standard piecewise affine Lagrangian finite elements (Braess 2007, Ch. II, Sect. 5). To solve the resulting linear system, we employ a direct solver. This is sufficiently fast for the current 2D example. For readers interested in creating a threedimensional version of this example, we suggest replacing the direct solver with a Krylov method preconditioned by one of the algebraic multigrid methods that can be accessed via PETSc.
Step 3: Implement the objective function
We implement the objective function J defined in (6) in a class Compliance that inherits from Fireshape’s class ShapeObjective (see Listing 5). This functional accesses the displacement field u via the variable self.pde_solver.
To verify that the domain used to compute u is feasible, that is, that the mesh is not tangled, we create a piecewise constant function detDT and interpolate the determinant of the derivative of the transformation T used to generated the updated domains (see Sections 4.2 and 4.3 for more details about the role of the transformation T in Fireshape). If the minimum of detDT is a small number, this indicates that the mesh has poor quality (see also Remark 3), and this negatively affects the accuracy of the finite element method. In this case, we decide that the value of J is NaN (“not a number”) to ensure that only trustworthy simulations are used.^{Footnote 3}
Final step: Set up and solve the problem
Finally, to shape optimize the initial desing we create a “main file” that loads the initial mesh, sets up the optimization problem, and solves it with an optimization algorithm. The rest of this section contains a linebyline description of the “main file”, which is listed in Listing 6.

In lines 1–6, we import all necessary Python libraries and modules.

In lines 8–11, we load the mesh of the initial design and we specify to discretize perturbations of the domain Ω using piecewise affine Lagrangian finite elements. We also employ a metric inspired by the linear elasticity equations and specify that the boundaries Γ_{1} and Γ_{2} cannot be modified. Sections 5.1 and 5.2 provide more details about the Fireshape classes ControlSpace and InnerProduct.

In line 13, we initiate the linear elasticity solver.

In lines 15–16, we tell Fireshape to store the finite element approximation of the displacement field u in the folder solution every time the domain Ω is updated. We can visualize the evolution of u along the optimization process by opening the file u.pvd with Paraview (Ahrens et al. 2005).

In lines 18–19, we initiate the objective function J and the associated reduced functional, which is used by Fireshape to define the appropriate Lagrange functionals to shape differentiate J. We refer to Section 4.2 for more details about shape differentiation using Lagrangians. Note that, as mentioned in Remark 1, Fireshape does not require users to derive (and implement) shape derivative formulas by hand. The whole shape differentiation process is automated using pyadjoint (Ham et al. 2019; Dokken et al. 2020).

In lines 21–22, we add an additional regularization term to J to promote mesh quality of domain updates. This regularization term controls the pointwise maximum singular value of the geometric transformation used to update Ω (Wechsung 2019). See Section 4.2, Fig. 9, and Remark 3 for more information about the role of geometric transformations in Fireshape.

In lines 24–27, we set up an equality constraint to ensure that the volume of the initial and the optimized domains are equal.

In lines 29–39, we select an optimization algorithm from the optimization library ROL. More specifically, we use an augmented Lagrangian approach (Nocedal and Wright 2006, Ch. 17.3) with limitedmemory BFGS Hessian updates (Nocedal and Wright 2006, Ch. 6.1) to deal with the volume equality constraint, and a TrustRegion algorithm (Nocedal and Wright 2006, Ch. 4.1) to solve the intermediate models generated by the augmented Lagrangian algorithm.

In lines 44–47, finally, we gather all information and solve the problem.
Results
Figure 6 shows the initial design (top) and the design optimized using Listing 6 (middle). At first look, the result looks reasonable. However, after an inspection of ROL’s output, it becomes apparent that the optimization algorithm stops after 8 (augmented Lagrangian outer) steps because the optimization step lenght becomes too small. This is due to a triangle on the top left corner of the cantilever that becomes almost flat (see Fig. 7, left). This deterioration of the mesh quality is detected by the implementation of the objective function (Listing 5, line 21), which forces the trustregion optimization algorithm to reduce the trustregion radius. After 8 iterations, this leads to an optimization step length that is smaller than 10^{− 4}, and the optimization algorithm terminates. This is a positive result: the algorithm detects that something is wrong and stops the simulation. It is the task of the user to understand what originates the problem and provide a remedy. After a look at the iterates on Paraview, it becomes apparent that optimization algorithms tries to move a node above the boundary Γ_{1}, which is fixed, and this leads to the generation of an elongated triangle. A difficulty with this part of the design was already experienced in Allaire and Pantz (2006), where the authors suggest to “arbitrarily set the shape gradient to zero near the corners of the shape”. Here, we present an alternative solution.
As mentioned in the previous paragraph, the issue is that the shape updates lead to the creation of an elongated triangle. To overcome this problem, we can simply increase from 10 to 100 the coefficient of the regularization term in line 21 Listing 6. The increased regularization sufficiently penalizes this unwanted behavior, and the algorithm can further optimize the design (see Fig. 8).
Shape optimization via diffeomorphisms
In this section, we describe the theory that underpins Fireshape. We begin with a brief introduction to PDEconstrained optimization to set the notation and mention the main idea behind optimization algorithms (Section 4.1). Then, we continue with an introduction to shape calculus (Section 4.2). Finally, we conclude with a discussion about the link between shape optimization and parametric finite elements (Section 4.3).
Optimization with PDE constraints
The basic ingredients to formulate a PDEconstrained optimization problem are the following: a control variable q that lives in a control space Q, a state variable u that lives in a state space U and that solves a (possibly nonlinear) state equation A(q, u) = 0, and a real function \(\mathrm {J}:{\mathbf {Q}}\times {\mathbf {U}}\to \mathbb {R}\) to be minimized.
Example 1
Equation (3) is a PDEconstrained optimization problem. The control variable q corresponds to the domain Ω, the state variable u represents the pair velocitypressure (u,p), the nonlinear constraint A represents the NavierStokes equations (1), and J denotes the objective function (2). The state space U corresponds to the space of pairs (a,b) with weakly differentiable velocities a that satisfy a = g on ∂Ω ∖Γ and square integrable pressures b (Elman et al. 2014, Ch. 8.2). The control space Q is specified in Section 4.2 (see (7)).
Most^{Footnote 4} numerical methods for PDEconstrained optimization attempt to construct a sequence of controls \(\{{\mathbf {q}}^{(k)}\}_{k\in \mathbb {N}}\) and corresponding states \(\{{\mathbf {u}}^{(k)}\}_{k\in \mathbb {N}}\) such that
Often, the sequence \(\{{\mathbf {q}}^{(k)}\}_{k\in \mathbb {N}}\) is constructed using derivatives of the function J and of the constraint A. Common approaches are steepest descent algorithms and Newton methods (in their quasi, Krylov, or semismooth versions) (Hinze et al. 2009; Kelley 2003). These algorithms ensure that the sequence \(\{\mathrm {J}({\mathbf {q}}^{(k)},{\mathbf {u}}^{(k)})\}_{k\in \mathbb {N}}\) decreases. In special cases, it is even possible to show that the sequence \(\{{\mathbf {q}}^{(k)}\}_{k\in \mathbb {N}}\) converges (Hinze et al. 2009). Although it may be difficult to ensure these assumptions are met in industrial applications, these optimization algorithms are still powerful tools to improve stateoftheart designs and are widely used to perform shape optimization.
Shape optimization and shape calculus
Shape optimization with PDE constraints is a particular branch of PDEconstrained optimization where the control space Q is a set of domain shapes. The space of shapes is notoriously difficult to characterize uniquely. For instance, one could describe shapes through their boundary regularity, or as levelsets, or as local epigraphs (Delfour and Zolésio 2011, Ch. 2). The choice of the shapes’ space characterization plays an important role in the concrete implementation of a shape optimization algorithm, and it can also affect formulas that result by differentiating J with respect to perturbations of the shape q. To be more precise, different methods generally lead to the same first order shape derivative formula, but differ on shape derivatives of higher order (Delfour and Zolésio 2011, ch. 9)
In this work, we model the control space Q as the images of biLipschitz geometric transformations T applied to an initial set \({\Omega }\subset \mathbb {R}^{d}\) (Delfour and Zolésio 2011, ch. 3), that is,
see Fig. 9. We choose this model of Q because it provides an explicit description of the domain boundaries via ∂(T(Ω)) = T(∂Ω), and because it is compatible with higher order finite elements (Paganini et al. 2018), as explained in detail in the Section 4.3. Henceforth, we use the term differomorphism to indicate that a geometric transformation T is biLipschitz.
In this setting, the shape derivative of J corresponds to the classical Gâteaux derivative in the Sobolev space \(W^{1,\infty }(\mathbb {R}^{d},\mathbb {R}^{d})\) (Hinze et al. 2009, Def. 1.29). To see this, let us momentarily remove the PDE constraint, and only consider a shape functional of the form Ω↦J(Ω). The shape derivative of J at Ω is the linear and continuous operator \(\text {dJ}({\Omega }, \cdot ):W^{1,\infty }(\mathbb {R}^{d},\mathbb {R}^{d})\to \mathbb {R}\) defined by
where Ω_{t} is the set Ω_{t} = {x + tV(x) : x ∈Ω} (Allaire 2007, Def. 6.15). By replacing Ω with q = I(Ω), where I denotes the identity transformation defined by I(x) = x for any \({\mathbf {x}}\in \mathbb {R}^{d}\), (8) can be equivalently rewritten as
We highlight that this interpretation immediately generalizes to any q in Q and can be used to define higher order shape derivatives.
The same definition (8) of shape derivative holds in the presence of PDE constraints: the shape derivative at q of the function \(\mathrm {J}:{\mathbf {Q}}\times {\mathbf {U}}\to \mathbb {R}\) subject to A(q, u) = 0 is the linear and continuous operator defined by
where u_{t} is the solution to A(q + tV, u_{t}) = 0. Computing shape derivative formulas using (9) may present the difficulty of computing the shape derivative of u, which intuitively arises by the “chain rule” formula. The shape derivative of u, which is sometimes called “material derivative” of u, can be eliminated with the help of adjoint equations (Hinze et al. 2009, Section 1.6.2). This process can be automated by introducing the Lagrange functional (Hinze et al. 2009, Section 1.6.3)
The term 〈A(q, u),p〉 stems from testing the equation A(q, u) = 0 with a test function p in the same way it is usually done when writing a PDE in its weak form.
Example 2
If A denotes the NavierStokes (1), then 〈A(q, u),p〉 corresponds to the weak formulation (4).
The advantage of introducing the Lagrangian (10) is that, by choosing p as the solution to the adjoint equation
where ∂_{u} denotes the partial differentiation with respect to the variable u, the shape derivative of J can be computed as
where ∂_{q} denotes partial differentiation with respect to the variable q. This is advantageous because partial differentiation does not require computing the shape derivative of u.
The Lagrangian approach to compute derivatives of PDEconstrained functionals is well established (Ito and Kunisch 2008), and its steps can be replicated by symbolic computation software. Probably, the biggest success in this direction is the pyadjoint project (Farrell et al. 2013; Mitusch et al. 2019), which derives “the adjoint and tangentlinear equations and solves them using the existing solver methods in FEniCS/Firedrake” (Mitusch et al. 2019). Thanks to the shape differentiation capabilities of UFL introduced in Ham et al. (2019), pyadjoint is also capable of shape differentiating PDEconstrained functionals along directions discretized by finite elements (Dokken et al. 2020).
Remark 2
Optimization algorithms are usually based on steepest descent directions to update the control variable q. A steepest descent direction is a direction V^{∗} that minimizes the derivative dJ. Since dJ is linear, it is necessary to introduce a norm ∥⋅∥ on the space of possible perturbations {V} (the tangent space of Q at q), and to restrict the search of a steepest descent direction to directions V of length ∥V∥ = 1. A natural choice would be to select the \(W^{1,\infty }\)norm,^{Footnote 5} with respect to which a minimizer has been shown to exist for most functionals (Paganini et al. 2018, Prop. 3.1). However, in practice it is more convenient to employ a norm that is induced by an inner product, so that the steepest descent direction corresponds to the Riesz representative of dJ with respect to the inner product (Hinze et al. 2009, p. 98).
Geometric transformations, moving meshes, and parametric finite elements
To solve a PDEconstrained optimization problem iteratively, it is necessary to employ a numerical method that is capable of solving the constraint A(q, u) = 0 for any feasible control q. In shape optimization, this translates into the requirement of a numerical scheme that can solve a PDE on a domain that changes at each iteration of the optimization algorithm. There are several competing approaches to construct a numerical scheme with this feature, such as the levelset method (Allaire et al. 2002) or the phase field approach (Blank et al. 2014), among others.
In Fireshape, we employ the approach sometimes know as “moving mesh” method (Paganini et al. 2018; Allaire 2007). In its simplest version (see Fig. 10), this method replaces (or approximates) the initial domain Ω with a polygonal mesh Ω_{h}. On this mesh, the state and adjoint equations are solved with a standard finite element method, whose construction on polygonal meshes is immediate. For instance, depending on the nature of the state constraint, one may solve the state and adjoint equations using linear Lagrangian or P2P1 TaylorHood finite elements (see Section 2.2). With the state and adjoint solutions at hand, one employs shape derivatives (see Remark 2 and Section 5.2) to update the coordinates of mesh nodes while retaining the mesh connectivity of Ω_{h}. This leads to a new mesh that represents an improved design. This update process is repeated until some prescribed convergence criteria are met.
The moving mesh method we just described is a simple and yet powerful method. However, in its current formulation, it requires polyhedral meshes, which limits the search space Q to polyhedra. In the remaining part of this section, we describe an equivalent interpretation of the moving mesh method that generalizes to curved domains. Additionally, this alternative interpretation allows approximating state and adjoint variables with arbitrarily highorder finite elements without suffering from reduction of convergence order due to poor approximation of domain boundaries (Ciarlet 2002, Ch. 4.4).
We begin by recalling the standard construction of parametric finite elements. For more details, we refer to (Ciarlet2002, Sections 2.3 and 4.3). To construct a parametric finite element space, one begins by partitioning the domain Ω into simpler geometric elements {K_{i}} (usually triangles or tetrahedra, as depicted in the first row of Fig. 11). Then, one introduces a reference element \(\hat {K}\) and a collection of diffeomorphisms F_{i} that map the reference element \(\hat {K}\) to the various K_{i}s, that is, \({\mathbf {F}}_{i}(\hat {K}) = K_{i}\) for every value of the index i (as depicted in the second row of Fig. 11). Finally, one considers a set of local reference basis functions \(\{\hat {b}_{j}\}\) defined on the reference element \(\hat {K}\), and defines local basis functions \(\{{b_{j}^{i}}\}\) on each K_{i} via the pullback \({b_{j}^{i}}({\mathbf {x}}):= \hat {b}_{j}({\mathbf {F}}_{i}^{1}({\mathbf {x}}))\) for every x in K_{i}. These local basis functions are used to construct global basis functions that span the finite element space. An important property of this construction is that the diffeomorphisms F_{i} can be expressed in terms of local linear Lagrangian basis functions^{Footnote 6}\(\{\hat {\beta }_{m}\}\), that is, there are some coefficient vectors \(\{\boldsymbol {\mu }_{m}^{i}\}\) such that
Finite elements constructed following this procedure are usually called parametric, because they rely on the parametrization {F_{i}}. Note that the most common finite elements families, such as Lagrangian, Raviart–Thomas, or Nédélec finite elements, are indeed parametric.
Keeping this knowledge about parametric finite elements in mind, we can revisit the mesh method (see Fig. 10). There, the main idea was to update only nodes’ coordinates and keep the mesh connectivity unchanged, so that constructing finite elements on the new mesh is straightforward. In Paganini et al. (2018), it has been shown that the new finite element space can also be obtained by modifying the parametric construction of finite elements on the original domain Ω. In the next paragraphs, we give an extended explanation (with adapted notation) of the demonstration given in Paganini et al. (2018).
Let T denote the transformation employed to modify the mesh Ω_{h} on the left in Fig. 10 into the new and perturbed mesh T(Ω_{h}) on the right in Fig. 10. Additionally, let {T(K_{i})} denote the simple geometric elements that constitute the latter. Using the parametric approach, we can construct finite elements on the new mesh by introducing a collection of diffeomorphisms \(\tilde {\mathbf {F}}_{i}\) that map the reference element \(\hat {K}\) to the various T(K_{i})s, that is, \(\tilde {\mathbf {F}}_{i}(\hat {K}) = {\mathbf {T}}(K_{i})\) for every value of the index i; see Fig. 12.
The behavior of the transformation T in Fig. 10 is prescribed only the mesh nodes. Since its behavior on the interior of the mesh triangles can be chosen arbitrarily, we can decide that T is piecewise affine on each triangle. This convenient choice implies that T can be written as a linear combination of piecewise affine Lagrangian finite elements defined on the first mesh, that is, \({\mathbf {T}}({\mathbf {x}}) = {\sum }_{\ell } {\boldsymbol {\nu }}_{\ell } B_{\ell }({\mathbf {x}})\) for every x in Ω, where {ν_{ℓ}} are some coefficient vectors and {B_{ℓ}} are global basis functions of the space of piecewise affine Lagrangian finite elements defined on the partition {K_{i}}. Since Lagrangian finite elements are constructed via pullbacks to the reference element, for every element K_{i} there are coefficient vectors \(\{{\boldsymbol {\nu }}_{m}^{i}\}\) so that the restriction \({\mathbf {T}}\vert _{K_{i}}\) of T on K_{i} can be rewritten as
Therefore, the composition \({\mathbf {T}}\vert _{K_{i}}\circ {\mathbf {F}}_{i}\) is of the form
that is, of the same form of (11). This implies that, to construct finite elements on the perturbed geometry T(Ω_{h}), we only need to replace the original coefficients \(\{\boldsymbol {\mu }_{m}^{i}\}\) in (11) with the new coefficients \(\{\tilde {\boldsymbol {\nu }}_{m}^{i}\}\) from (12).
This alternative and equivalent viewpoint on the moving mesh method generalizes naturally to higher order finite element approximations of control and state (and adjoint) variables. Indeed, one of the key steps to ensure that higher order finite elements achieve higher order convergence on curved domains is to employ sufficiently accurate polynomial interpolation of domain boundaries (Ciarlet 2002, Ch. 4.4). This boundary interpolation can be encoded in the diffeomorphisms {F_{i}} by using higher order Lagrangian local basis functions. Therefore, simply employing higher order Lagrangian finite element transformations T leads to a natural extension of moving mesh method to higher order finite elements.
This alternative and equivalent viewpoint generalizes further to allow the use of any arbitrary discretization of the transformation T (for instance, using Bsplines (Höllig 2003), harmonic polynomials, or radial basis functions (Wendland 2005)). The only requirement to be fulfilled to ensure the desired order of convergence p is that the maps T ∘F_{i} : x↦T(F_{i}(x)) satisfy the asymptotic algebraic estimates
where \({\mathbf {D}}^{\alpha }({\mathbf {T}}\circ {\mathbf {F}}_{i})\) denotes the α^{th} derivative of T ∘F_{i}. Using a different discretization of the transformation T can give several advantages, like increasing the smoothness T (because finite elements are generally only Lipschitz continuous) or varying how shape updates are computed during the optimization process (Eigel and Sturm 2018).
Remark 3
An issue that can arise with the moving mesh method is that it can lead to poor quality (or even tangled) meshes. In terms of geometric transformations, a mesh with poor quality corresponds to a transformation T for which the value \(\max \limits _{\alpha }\Vert {\mathbf {D}}^{\alpha {\mathbf {T}}} \Vert \) is large (and a tangled mesh to a transformation T that is not a diffeomorphism). To a certain extent, it is possible to enforce moderate derivatives by employing suitable metrics to extract descent directions from shape derivatives (for instance, by using linear elasticity based inner products with a CauchyRiemann augmentation (Iglesias et al. 2018)) and/or by adding penalty terms to the functional J. For example, in Sections 2.4 and 3.4 we add a penalization term based on the spectral norm ∥D(T −I)∥_{2} of the Jacobian matrix D(T −I). We point out that if Ω is ζquasiconvex^{Footnote 7} and ∥D(T −I)∥_{2} < ζ, then \({\mathbf {T}}:{\Omega }\to \mathbb {R}^{d}\) is biLipschitz, and thus injective.
Anatomy of Fireshape
In this section, we give more details about Fireshape’s implementation and features. Fireshape is organized in a few core Python classes (and associated subclasses) that implement the control space Q, the metric to be employed by the optimization algorithm, and the (possibly PDEconstrained) objective function J. The following subsections describe these classes.
The class ControlSpace
Fireshape models the control space Q of admissible domains using geometric transformations T as in (7) (see also Fig. 9). From a theoretical perspective, the transformations T can be discretized in numerous different ways as long as certain minimal regularity requirements are met. In Fireshape, the class ControlSpace allows the following options: (i) Lagrangian finite elements defined on the same mesh employed to solve the state equation, (ii) Lagrangian finite elements defined on a mesh coarser than the mesh employed to solve the state equation, and (iii) tensorized Bsplines defined on a separate Cartesian grid (not to be confused with a spline or Bézier parametrization of the domain boundary, see Fig. 13). In this case, the user must specify the boundary and the refinement level of the Cartesian grid (bbox and level), as well as the order of the underlying univariate Bsplines. The user can also set the regulariy of Bsplines on the boundary of the Cartesian grid (boundary_regularities), or restrict pertubations to specific directions (fixed_dims).
If discretization (i) can be considered to be the default option, discretization (ii) allows introducing a regularization by discretizing the geometry more coarsely (socalled “regularization by discretization”), whereas Bsplines allow constructing transformation with higher regularity (Lagrangian finite elements are only Lipschitz continuous, whereas Bsplines can be continuously differentiable and more).
The class ControlSpace can be easily extended to include additional discretization options, such as radial basis functions and harmonic polynomials.
Remark 4
The current implementation of the control space Q includes geometric transformations that can leave the value of a shape function unchanged. For instance, if \(\mathrm {J}({\Omega }) = {\int \limits }_{{\Omega }} \mathrm {d}{\boldsymbol {x}}\), then any diffeomorphism T of the form T = I + V with V≠0 in Ω and V = 0 on ∂Ω satisfy T(Ω) = Ω, and thus J(T(Ω)) = J(Ω).
The presence of a shape function kernel in the control space Q does not represent a problem for steepest descent and quasi Newton optimization algorithms. However, this kernel leads to singular Hessians, and Newton’s method cannot be applied in a straightforward fashion. The development of control space descriptions that exclude shape function kernels and allow direct applications of shape Newton methods in the framework of finite element simulations is a highly active research field (Sturm 2016; Paganini and Sturm 2019; Etling et al. 2020). We predict these new control spaces will be included in Fireshape as soon as their description has been established.
The class InnerProduct
To formulate a continuous optimization algorithm, we need to specify how to compute lengths of vectors (and, possibly, how to compute the angle between two vectors). The class InnerProduct addresses this requirement and allows selecting an inner product \((\cdot , \cdot )_{{\mathscr{H}}}\) to endow the control space Q with.^{Footnote 8}
The choice of the inner product affects how steepestdescent directions are computed. Indeed, a steepestdescent direction is a direction V of length \(\Vert {\mathbf {V}}\Vert _{{\mathscr{H}}} = 1\) such that dJ(q, V) is minimal. Let α := ∥dJ(q,⋅)∥_{∗} denote the length of the operator dJ(q,⋅) measured with respect to the dual norm. Then, as explained Hinze et al. (2009, p. 103), the steepest descent direction V satisfies the equation
which clearly depends on the inner product \((\cdot , \cdot )_{{\mathscr{H}}}\).
The control space Q can be endowed with different inner products. In Fireshape, the class InnerProduct allows the following options: (i) an H^{1}(Ω) inner product based on standard Galerkin stiffness and mass matrices, (ii) a Laplace inner product based on the Galerkin stiffness matrix, and (iii) an elasticity inner product based on the linear elasticity mechanical model. These options can be complemented with additional homogeneous Dirichlet boundary conditions to specify parts of the boundary ∂Ω that are not to be modified during the shape optimization procedure.
Although all three options are equivalent from a theoretical perspective, in practice it has been observed that option (iii) generally leads to geometry updates that result in meshes of higher equality compared to options (i) and (ii). A thorough comparison is available in Iglesias et al. (2018), where the authors also suggest to consider complementing these inner products with terms stemming from CauchyRiemann equations to further increase mesh quality. This additional option is readily available in Fireshape.
The classes Objective and PdeConstraint
In the vast majority of cases, users who aim to solve a PDEconstrained shape optimization problem are only required to instantiate the two classes Objective and PdeConstraint, where they can specify the formula of the function J to be minimized and the weak formulation of its PDE constraint A(Ω,u) = 0 (see Sections 2.2 and 2.3, for instance). Since Fireshape is built on top of the finite element library Firedrake, these formulas must be written using the Unified Form Language (UFL). We refer to the tutorials on Firedrake’s website (Firedrakezenodo 2020) for more details about Firedrake and UFL.
Supplementary classes
Fireshape also includes a few extra classes to specify additional constraints, such as volume or perimeter constraints on the domain Ω, or spectral constraints to control the singular values of the transformation T. For more details about these extra options, we refer to Fireshape’s documentation and tutorials (Wechsung and Paganini 2020a).
Conclusions
We have introduced Fireshape: an opensource and automated shape optimization toolbox for the finite element software Firedrake. Fireshape is based on the moving mesh method and allows users with minimal shape optimization knowledge to tackle challenging shape optimization problems constrained to PDEs. In particular, Fireshape computes adjoint equations and shape derivatives in an automated fashion, allows decoupled discretizations of control and state variables, and gives full access to Firedrake’s and PETSc’s discretization and solver capabilities as well as to the extensive optimization library ROL.
Notes
 1.
The acronym SIMP stands for Solid Isotropic Material with Penalisation.
 2.
For this computation we extend the code in Listing 1 and include analytic continuation in the Reynolds number to recompute good initial guesses for the SNES solver when this fails to converge. This modification is necessary to solve (4) at high Reynolds numbers. The code used to obtain these results can be found on Zenodo (2020).
 3.
In Section 2.3, we did not include this extra test because the NavierStokes’ solver usually fails to converge on poor quality meshes.
 4.
An alternative approach is to employ socalled “oneshot” methods, where the optimality system of the problem is solved directly (Schulz and Gherman 2009). Note that, since the optimality system is often nonlinear, oneshot methods still involve iterative algorithms.
 5.
The norm \(\Vert {\mathbf {V}}\Vert _{1,\infty }\) is the maximum between the essential supremum of V and of its derivative DV.
 6.
For linear Lagrangian finite elements, the two set of reference local basis functions \(\{\hat {b}_{j}\}\) and \(\{\hat {\beta }_{m}\}\) coincide.
 7.
A domain Ω is ζquasiconvex if, for any x ∈Ω and y ∈Ω, the length ℓ of the shortest path in Ω that connects x to y satisfies ℓ ≤ ζ∥x −y∥.
 8.
Note that specifying a norm would suffice to formulate an optimization algorithm. However, as mention in Remark 2, it is computationally more convenient to restrict computations to inner product spaces.
References
Abramowski T, Sugalski K (2017) Energy saving procedures for fishing vessels by means of numerical optimization of hull resistance. Zeszyty Naukowe Akademii Morskiej w Szczecinie
Ahrens J, Geveci B, Law C (2005) 36  ParaView: an enduser tool for largedata visualization. In: Hansen CD, Johnson CR (eds) Visualization handbook. ButterworthHeinemann, Burlington, pp 717–731
Allaire G (2007) Conception optimale de structures, Mathematics & Applications, vol 58. Springer, Berlin
Allaire G, Jouve F, Toader AM (2002) A levelset method for shape optimization. C R Math Acad Sci Paris 334(12):1125–1130
Allaire G, Pantz O (2006) Structural optimization with FreeFem++. Struct Multidiscip Optim 32(3):173–181
Alnæs MS, Logg A, Ølgaard KB, Rognes ME, Wells GN (2014) Unified form language: a domainspecific language for weak formulations of partial differential equations. ACM Trans Math Softw 40(2):9:1–9:37
Amestoy PR, Duff IS, L’Excellent JY, Koster J (2000) MUMPS: a general purpose distributed memory sparse solver. In: International workshop on applied parallel computing. Springer, pp 121–130
Balay S, Abhyankar S, Adams MF, Brown J, Brune P, Buschelman K, Dalcin L, Eijkhout V, Gropp WD, Karpeyev D, Kaushik D, Knepley MG, May DA, McInnes LC, Mills RT, Munson T, Rupp K, Sanan P, Smith BF, Zampini S, Zhang H, Zhang H (2019) PETSC users manual. Tech. Rep. ANL95/11  Revision 3.11, Argonne National Laboratory
Balay S, Gropp WD, McInnes LC, Smith BF (1997) Efficient management of parallelism in object oriented numerical software libraries. In: Arge E, Bruaset AM, Langtangen HP (eds) Modern software tools in scientific computing. Birkhäuser Press, pp 163–202
Bendsøe MP (1989) Optimal shape design as a material distribution problem. Struct Optim 1 (4):193–202
Bendsoe MP, Sigmund O (2004) Topology optimization: theory, methods and applications. Springer, Berlin
Bernland A, Wadbro E, Berggren M (2019) Shape optimization of a compression driver phase plug. SIAM J Sci Comput 41(1):B181–B204
Blank L, Garcke H, FarshbafShaker MH, Styles V (2014) Relating phase field and sharp interface approaches to structural topology optimization. ESAIM Control Optim Calc Var 20(4):1025–1058
Braess D (2007) Finite elements, 3rd edn. Cambridge University Press, Cambridge
Chevalier C, Pellegrini F (2008) PTSCOTCH: a tool for efficient parallel graph ordering. Parallel Comput 34(6):318–331
Ciarlet PG (2002) The finite element method for elliptic problems. Society for Industrial and Applied Mathematics (SIAM), Philadelphia, PA
Courtais A, Lesage F, Privat Y, Frey P, razak Latifi A (2019) Adjoint system method in shape optimization of some typical fluid flow patterns. In: Kiss AA, Zondervan E, Lakerveld R, Özkan L (eds) 29th European symposium on computer aided process engineering, computer aided chemical engineering, vol 46. Elsevier, pp 871–876
Dalcin LD, Paz RR, Kler PA, Cosimo A (2011) Parallel distributed computing using Python. Adv Water Res 34(9):1124–1139. New Computational Methods and Software Tools
Dapogny C, Faure A, Michailidis G, Allaire G, Couvelas A, Estevez R (2017) Geometric constraints for shape and topology optimization in architectural design. Comput Mech 59(6):933–965
Dapogny C, Frey P, Omnès F, Privat Y (2018) Geometrical shape optimization in fluid mechanics using FreeFem++. Struct Multidiscip Optim 58(6):2761–2788
Delfour MC, Zolésio JP (2011) Shapes and geometries. Metrics, analysis, differential calculus, and optimization, Advances in Design and Control, vol 22, 2nd edn. Society for Industrial and Applied Mathematics (SIAM), Philadelphia
Dilgen CB, Dilgen SB, Fuhrman DR, Sigmund O, Lazarov BS (2018) Topology optimization of turbulent flows. Comput Methods Appl Mech Engrg 331:363–393
Dokken JS, Funke SW, Johansson A, Schmidt S (2019) Shape optimization using the finite element method on multiple meshes with nitsche coupling. SIAM J Sci Comput 41(3):A1923–A1948
Dokken JS, Mitusch SK, Funke SW (2020) Automatic shape derivatives for transient PDEs in FEniCS and Firedrake
Dondl P, Poh PSP, Rumpf M, Simon S (2019) Simultaneous elastic shape optimization for a domain splitting in bone tissue engineering. Proc A 475(2227):20180718, 17
Eigel M, Sturm K (2018) Reproducing kernel hilbert spaces and variable metric algorithms in pdeconstrained shape optimization. Opt Methods Softw 33(2):268–296
Elman HC, Silvester DJ, Wathen AJ (2014) Finite elements and fast iterative solvers: with applications in incompressible fluid dynamics, 2nd edn. Oxford University Press, Oxford
Etling T, Herzog R, Loayza E, Wachsmuth G (2020) First and second order shape optimization based on restricted mesh deformations. SIAM J Sci Comput 42(2):A1200–A1225
Farrell PE, Ham DA, Funke SW, Rognes ME (2013) Automated derivation of the adjoint of highlevel transient finite element programs. SIAM J Sci Comput 35(4):C369–C393
Farrell PE, Mitchell L, Wechsung F (2019) An augmented lagrangian preconditioner for the 3d stationary incompressible navier–stokes equations at high reynolds number. SIAM J Sci Comput 41(5):A3073–A3096
Feppon F, Allaire G, Dapogny C, Jolivet P (2020) Topology optimization of thermal fluidstructure systems using bodyfitted meshes and parallel computing. J Comput Phys 417(109574): 30
Firedrakezenodo (2020) Software used in ‘Fireshape: a shape optimization toolbox for Firedrake’ (Version Firedrake_20200918.0). Zenodo. https://doi.org/10.5281/zenodo.4036176. Accessed 18 Sept 2020
Garcke H, Hecht C, Hinze M, Kahle C (2015) Numerical approximation of phase field based shape and topology optimization for fluids. SIAM J Sci Comput 37(4):A1846– A1871
Geuzaine C, Remacle JF (2009) Gmsh: a 3d finite element mesh generator with builtin preand postprocessing facilities. Int J Numer Methods Eng 79(11):1309–1331
Gibson TH, Mitchell L, Ham DA, Cotter CJ (2020) Slate: extending Firedrake’s domainspecific abstraction to hybridized solvers for geoscience and beyond. Geosci Model Develop 13(2):735–761
Ham DA, Mitchell L, Paganini A, Wechsung F (2019) Automated shape differentiation in the Unified Form Language. Struct Multidiscip Optim 60(5):1813–1820
He X, Li J, Mader CA, Yildirim A, Martins JR (2019) Robust aerodynamic shape optimization—from a circle to an airfoil. Aerosp Sci Technol 87:48–61
Hinze M, Pinnau R, Ulbrich M, Ulbrich S (2009) Optimization with PDE constraints, Mathematical modelling: Theory and Applications, vol 23. Springer, New York
Höllig K (2003) Finite element methods with Bsplines. Society for Industrial and Applied Mathematics (SIAM), Philadelphia PA
Homolya M, Kirby RC, Ham DA (2017) Exposing and exploiting structure: optimal code generation for highorder finite element methods. arXiv:1711.02473
Homolya M, Mitchell L, Luporini F, Ham DA (2018) TSFC: a structurepreserving form compiler. SIAM J. Sci. Comput. 40(3):C401–C428
Hypre (2020) High performance preconditioners. Lawrence Livermore National Laboratory. https://computing.llnl.gov/projects/hyprescalablelinearsolversmultigridmethods. Accessed 25 Jan 2021
Iglesias JA, Sturm K, Wechsung F (2018) Twodimensional shape optimization with nearly conformal transformations. SIAM J Sci Comput 40(6):A3807–A3830
Ito K, Kunisch K (2008) Lagrange multiplier approach to variational problems and applications, Advances in Design and Control, vol 15. Society for Industrial and Applied Mathematics (SIAM), Philadelphia
Kelley CT (2003) Solving nonlinear equations with Newton’s method, Fundamentals of Algorithms, vol 1. Society for Industrial and Applied Mathematics (SIAM), Philadelphia
Laurain A (2018) A level setbased structural optimization code using FEniCS. Struct Multidiscip Optim 58(3):1311–1334
Liu Z, Korvink J, Huang R (2005) Structure topology optimization: fully coupled level set method via femlab. Struct Multidiscip Optim 29(6):407–417
Lombardi M, Parolini N, Quarteroni A, Rozza G (2012) Numerical simulation of sailing boats: dynamics, fsi, and shape optimization. In: Variational analysis and aerospace engineering: mathematical challenges for aerospace design. Springer, pp 339–377
Luporini F, Ham DA, Kelly PHJ (2017) An algorithm for the optimization of finite element integration loops. ACM Trans Math Softw 44:3:1–3:26
MarinićKragić I, Vučina D, Ćurković M (2016) Efficient shape parameterization method for multidisciplinary global optimization and application to integrated ship hull shape optimization workflow. ComputAided Des 80:61–75
Mitchell L, Müller EH (2016) High level implementation of geometric multigrid solvers for finite element problems: applications in atmospheric modelling. J Comput Phys 327:1–18
Mitusch SK, Funke SW, Dokken JS (2019) dolfinadjoint 2018.1: automated adjoints for FEniCS and Firedrake. J Open Source Softw 4(38):1292
Nocedal J, Wright SJ (2006) Numerical optimization, 2nd edn. Springer, New York
Paganini A, Sturm K (2019) Weakly normal basis vector fields in rkhs with an application to shape newton methods. SIAM J Numer Anal 57(1):1–26
Paganini A, Wechsung F, Farrell PE (2018) Higherorder moving mesh methods for PDEconstrained shape optimization. SIAM J Sci Comput 40(4):A2356–A2382
Rathgeber F, Ham DA, Mitchell L, Lange M, Luporini F, McRae ATT, Bercea GT, Markall GR, Kelly PHJ (2016) Firedrake: automating the finite element method by composing abstractions. ACM Trans Math Softw 43(3):24:1–24:27
Ridzal D, Kouri D (2014) Rapid optimization library, version 00. https://www.osti.gov//servlets/purl/1232084
Schmidt S, Ilic C, Schulz V, Gauger NR (2013) Threedimensional largescale aerodynamic shape optimization based on shape calculus. AIAA 51(11):2615–2627
Schulz V, Gherman I (2009) Oneshot methods for aerodynamic shape optimization. In: MEGADESIGN and megaoptgerman initiatives for aerodynamic simulation and optimization in aircraft design. Springer, pp 207–220
Sigmund O (2001) A 99 line topology optimization code written in matlab. Struct Multidiscip Optim 21(2):120–127
Sturm K (2016) Convergence of newton’s method in shape optimisation via approximate normal functions. arXiv:1608.02699
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. Struct Multidiscip Optim 45(3):329–357
Villanueva CH, Maute K (2017) CutFEM topology optimization of 3D laminar incompressible flow problems. Comput Methods Appl Mech Engrg 320:444–473
Wang H, Doherty J, Jin Y (2018) Hierarchical surrogateassisted evolutionary multiscenario airfoil shape optimization. In: 2018 IEEE congress on evolutionary computation (CEC), pp 1–8. IEEE
Wechsung F (2019) Shape optimisation and robust solvers for incompressible flow. Ph.D. thesis, University of Oxford
Wechsung F, Paganini A (2020a) Fireshape’s Documentation. Read the Docs. https://fireshape.readthedocs.io/en/latest/index.html. Accessed 18 Sept 2020
Wechsung F, Paganini A (2020b) Fireshape: a shape optimization toolbox for Firedrake (Version v0.3). Zenodo. https://doi.org/10.5281/zenodo.4036213. Accessed 18 Sept 2020
Wendland H (2005) Scattered data approximation. Cambridge University Press, Cambridge
Zenodo (2020) Software used in ’Fireshape: a shape optimization toolbox for Firedrake. https://doi.org/10.5281/zenodo.4036176
Zhou S, Li Q (2008) A variational level set method for the topology optimization of steadystate NavierStokes flow. J Comput Phys 227(24):10178–10195
Funding
The work of Florian Wechsung was partly supported by the EPSRC Centre For Doctoral Training in Industrially Focused Mathematical Modelling [grant number EP/L015803/1].
Author information
Affiliations
Contributions
Alberto Paganini and Florian Wechsung have contributed equally to the development of the software Fireshape and to this manuscript.
Corresponding author
Ethics declarations
Conflict of interest
The authors declare that they have no conflict of interest.
Replication of results
For reproducibility, we cite archives of the exact software versions used to produce the results in this paper. All major Firedrake components have been archived on Zenodo (2020). An installation of Firedrake with components matching those used to produce the results in this paper can by obtained following the instructions at https://www.firedrakeproject.org/download.html.
The exact version of the Fireshape library used for these results has also been archived at (Wechsung and Paganini 2020b). The latest version of the Fireshape library can be found at https://github.com/Fireshape/Fireshape.
Additional information
Publisher’s note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Responsible Editor: Gregoire Allaire
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Paganini, A., Wechsung, F. Fireshape: a shape optimization toolbox for Firedrake. Struct Multidisc Optim (2021). https://doi.org/10.1007/s0015802002813y
Received:
Revised:
Accepted:
Published:
Keywords
 Shape optimization
 Finite elements
 Opensource software