Version 2.0 - cashocs: A Computational, Adjoint-Based Shape Optimization and Optimal Control Software

In this paper, we present version 2.0 of cashocs. Our software automates the solution of PDE constrained optimization problems for design optimization and optimal control. Since its inception, many new features and useful tools have been added to cashocs, making it even more ﬂexible and eﬃcient. The most signiﬁcant additions are a framework for space mapping, the ability to solve topology optimization problems with a level-set approach, the support for parallelism via MPI, and the ability to handle additional (state) constraints. In this software update, we describe the key additions to cashocs, which is now even better-suited for solving complex PDE constrained optimization problems.


Description of the Software-Update
This articles serves as update to our software cashocs [1] and discusses some of the key additions, changes, and improvements to the software.We describe both new functionalities which have been added to cashocs to extend its capabilities as well as structural improvements which make the software more efficient and easier to apply.

New Functionalities
Since its inception, cashocs has received many new functionalities, which we present in the following.For a detailed description of all changes and additions to cashocs, we refer to the release notes at https://cashocs.readthedocs.io/en/stable/release_notes/.One of the most practical additions to cashocs are space mapping methods which enable the solution of highly complex problems in the following way: The space mapping technique utilizes a model hierarchy consisting of a fine (detailed, complex) and a coarse (approximate, cheap) model.It provides an efficient way to optimize the fine model by successively optimizing and correcting a sequence of coarse model approximations.Particularly, there is no need for a direct optimization of the fine model.This makes the technique particularly interesting for industrial applications, where often commercial solvers without optimization capabilities are used for simulation.For more details on the space mapping Figure 1: Example for the space mapping method for shape optimization from [4].The picture shows the evolution of the geometry, velocity field, and outlet flow rates over the space mapping iterations.
Whereas space mapping techniques for optimal control problems have already been investigated in the literature (see, e.g., [5,6,7]), space mapping methods for shape optimization have only been introduced very recently in [4].Moreover, to the best of our knowledge, cashocs is the only software providing a framework for implementing and solving general space mapping problems in the context of PDE constrained optimization for both shape optimization and optimal control problems.
As a reference, we briefly take a look at a problem from [4], which is solved with the space mapping methods for shape optimization and is depicted in Figure 1.The aim of the optimization problem is to achieve a uniform flow distribution over three outlet pipes.For the fine model, the Navier-Stokes equations with a Reynolds number of 1000 are used and solved with Ansys Fluent [8], whereas the coarse model is given by the linear Stokes system and is solved on a coarser grid with FEniCS [9,10,11].We see that the space mapping method converges really fast in about five iterations and that the optimized geometry yields a nearly perfect uniform flow distribution.For more details, we refer the reader to [4] and to the corresponding tutorial at https://cashocs.readthedocs.io/en/stable/user/demos/shape_optimization/demo_space_mapping_uniform_flow_distribution/, where the corresponding tutorial can be found.
Another major new feature for cashocs is its support for solving topology optimization problems with a level-set method.Our software provides several optimization algorithms for such problems, including state-of-theart algorithms for topology optimization [12] as well as novel quasi-Newton methods for topology optimization proposed in [13].Due to the inherent difficulty of deriving topological derivatives, the latter cannot yet be computed with automatic differentiation methods but have to be supplied by the user.However, the automatic derivation of adjoint systems is already implemented in cashocs.This feature extends the applicability of cashocs to the field of topology optimization with topological sensitivity information.For more details on how to solve topology optimization problems with cashocs, we refer the reader to the corresponding tutorials at https://cashocs.readthedocs.io/en/stable/user/demos/topology_optimization/.
Further, cashocs has received methods for the automatic treatment of additional constraints for optimization problems, such as state or control constraints.In particular we have implemented a quadratic penalty and an augmented Lagrangian method (see, e.g., [14]) for dealing with constraints other than PDEs.These methods are applicable for a wide variety of constraints, including state constraints, which opens up new problem classes for cashocs to solve.We refer the reader to https://cashocs.readthedocs.io/en/stable/user/demos/optimal_control/demo_constraints/, where a demo for using additional constraints with cashocs can be found.An overview over all types of optimization problems that can be solved with cashocs is given in Figure 2.
The new version of cashocs also comes with the ability to automatically scale individual terms of the cost functional based on their magnitude for the initial iteration.This makes it easier for users to weigh different parts of the cost functional according to their needs.Moreover, this also facilitates the solution of multi-criteria optimization problems with scalarization methods,  see, e.g., [15,16].We refer the reader to the corresponding cashocs tutorial at https://cashocs.readthedocs.io/en/stable/user/demos/shape_optimization/demo_scaling/.
With the new version of cashocs, users now have the possibility to define custom scalar products for the optimization, which is particularly useful for shape optimization, where the choice of the scalar product for computing the shape gradient is particularly important.The reader is referred to the cashocs tutorials at https://cashocs.readthedocs.io/en/stable/user/demos/shape_optimization/demo_scaling/ for more information.Moreover, the updated version of cashocs also supports computing the shape gradient with the p-Laplace equations, based on the approach presented in [17].This approach may preserve the mesh quality and can yield better optimized geometries for certain problems.For more details, the reader is referred to the corresponding demo at https://cashocs.readthedocs.io/en/stable/user/demos/shape_optimization/demo_p_laplacian/.
Finally, we have also added more sophisticated line search methods to cashocs, which make use of polynomial models to efficiently compute a suitable stepsize.During the line search, a quadratic or cubic model of the cost functional along the search direction is formed and minimized to obtain suitable stepsizes in fewer iterations compared to a classical Armijo backtracking search (see, e.g., [18]).

Structural Improvements
In addition to the new features described above, there have also been some major structural improvements to cashocs which we discuss in the following.
The most important structural improvement is the support for parallelism with MPI.In particular, most of the PDE constrained optimization problems that can be solved in serial can now also be solved in parallel without the need for any code modifications.Therefore, cashocs is now able to be run on high-performance-computing systems and, thus, can solve huge optimization problems which cannot be treated in serial.The MPI implementation builds on and leverages the MPI support of FEniCS, so that there are only minimal code changes necessary on the user's side.
Another structural improvement for cashocs is a new remeshing workflow which overcomes the limitations induced by the previous one.The benefit of the new workflow is that remeshing can now be applied also for the space mapping and constraint handling problems, which was not possible beforehand.As remeshing is of particular importance for solving shape optimization problems, this change greatly increases the applicability of cashocs.However, user's must now follow a slightly different, but still straightforward, syntax to solve shape optimization problems with remeshing.The corresponding tutorial can be found at https://cashocs.readthedocs.io/en/stable/user/demos/shape_optimization/demo_remeshing/.
Finally, we note that the remeshing workflow itself is not parallelized with MPI due to limitations of the used software tools Gmsh, which supports only OpenMP parallelism, and meshio, which does not support parallelism at all.This can potentially create bottlenecks when solving problems where lots of remeshing is required.However, as usually the solution of the state and adjoint systems is the most CPU and memory consuming task, the bottleneck of the remeshing is not too severe for many applications.

Conclusion and Outlook
With the update to version 2.0, our software cashocs has gained significant new features, such as a space mapping framework, support for parallelism via MPI, and the ability to treat topology optimization problems.These additions make cashocs even more flexible and relevant for solving PDE constrained optimization problems for practical and industrial applications.

Figure 2 :
Figure 2: Overview of the types of optimization problems that can be solved with cashocs.Items colored in blue are new additions to version 2.0.