Goal-oriented mesh adaptation for Firedrake



A goal-oriented adapted mesh for a tidal farm simulation. Here the QoI is the energy output of an array of tidal turbines positioned in a tidally reversing channel

Mesh adaptation can be a powerful tool for improving the accuracy and/or efficiency of numerical simulations. It does this by varying the level of resolution of a model over space (and possibly time). However, it is still not widely used. This is largely because traditional methods require the user to have knowledge and experience concerning the details of the problem at hand and the numerical model being used, as well as having an intuition for the type of “metric” that is suitable to guide the adaptation method.

Goal-oriented mesh adaptation is focused on optimising a simulation so as to most accurately evaluate an output of the model, known as the quantity of interest (QoI). This is a common “goal” in many areas of computational science and engineering: think of the drag on an aeroplane wing, the level of destruction due to a tsunami, or the power output of a turbine. Goal-oriented mesh adaptation reduces the above user requirements significantly because it automatically estimates errors associated with the QoI. The main contribution of this project is the development of a new module for goal-oriented error estimation called Pyroteus. All that is required from the user is a set of instructions for how to run the numerical model and compute the desired QoI, both of which are typically straightforward. With these, Pyroteus is able to perform mesh adaptation in a fully automated sense. In doing so, Pyroteus enables numerical modellers to use advanced techniques, without requiring expert knowledge.


Figure 1: A goal-oriented adapted mesh for a tidal farm simulation. Here the QoI is the energy output of an array of tidal turbines positioned in a tidally reversing channel [3].

To support the development of Pyroteus, this project also involved extending the mesh adaptation functionalities of the scientific software packages PETSc and Firedrake, upon which Pyroteus depends. This included coupling PETSc to the mesh adaptation toolkit Mmg and adding various tools to facilitate mesh adaptation, as documented in [1]. Firedrake is a high-level package, with a programming interface similar to how mathematics is written by hand. However, it leverages automatic code generation software to produce efficient low-level code. It also inherits many of the data structures and methods provided by PETSc. Using this interface, PETSc’s new adaptation functionality could be ported through to Firedrake.

The final phase of the project involved writing extensive documentation for the new functionality. In particular, the Pyroteus webpage includes a manual, API documentation and a set of demos for new users to get to grips with the package and the methods used.

[1] J. G. Wallwork, M. G. Knepley, N. Barral, M. D. Piggott, Parallel metric-based mesh adaptation in PETSc using ParMmg, 30th International Meshing Roundtable (2022), doi:10.48550/arXiv.2201.02806.

[2] J. G. Wallwork, N. Barral, D. A. Ham, M. D. Piggott, Goal-oriented error estimation and mesh adaptation for tracer transport modelling, Computer-Aided Design 145 (2022) 103187, doi:10.1016/j.cad.2021.103187.

[3] J. G. Wallwork, A. Angeloudis, N. Barral, L. Mackie, S. C. Kramer, M. D. Piggott, Tidal array modelling using goal-oriented mesh adaptation, Journal of Ocean Engineering and Marine Energy (under review), doi:10.31223/X5H06B.

Information about the code

PETSc can be accessed using “module load petsc”. Firedrake can be installed using spack, although this functionality is currently under development. With an activated Firedrake virtual environment, Pyroteus can be pip installed from its cloned repo.


This work was also presented in an ARCHER2 webinar. A recording of the webinar and the slides can be found on the event page

Technical Report

Download as PDF