Source-linked AI summary

DOLFIN: Automated Finite Element Computing

Anders Logg, Garth N. Wells

arXiv:1103.6248v1cs.MSmath.NA

TL;DR

Finite-element PDE software must balance flexibility, usability, and computational performance as problem diversity grows. DOLFIN addresses this by expressing variational forms near mathematical notation and automatically generating specialized code within a generic C++/Python environment. The paper concludes that this combination supports readable, rapid model development and efficient solution, while current support is limited to simplicial meshes and form compilers conforming to the UFC interface.

  • Problem

    Existing PDE libraries often lack flexibility as scientific and industrial differential equations become more complex and diverse, while high performance is commonly associated with specialization.

  • Method

    DOLFIN combines high-level variational-form abstractions with automated code generation and reusable interfaces for meshes, finite elements, and linear-algebra backends.

  • Results

    DOLFIN provides a general implementation independent of the variational problem, mesh, finite-element spaces, and linear-algebra backend while supporting efficient automated assembly.

  • Takeaways & Limitations

    The system allows new finite-element models to be implemented rapidly and solved efficiently using readable mathematical abstractions and generated code.

  • Takeaways & Limitations

    DOLFIN currently supports only simplicial meshes and may be used with form compilers conforming to the UFC interface.

Abstract

from arXiv · show

We describe here a library aimed at automating the solution of partial differential equations using the finite element method. By employing novel techniques for automated code generation, the library combines a high level of expressiveness with efficient computation. Finite element variational forms may be expressed in near mathematical notation, from which low-level code is automatically generated, compiled and seamlessly integrated with efficient implementations of computational meshes and high-performance linear algebra. Easy-to-use object-oriented interfaces to the library are provided in the form of a C++ library and a Python module. This paper discusses the mathematical abstractions and methods used in the design of the library and its implementation. A number of examples are presented to demonstrate the use of the library in application code.

1. INTRODUCTION

DOLFIN addresses the limited flexibility of specialized PDE libraries by combining automated generation of specialized finite-element code with a general library design. It targets broad variational-form, mesh, finite-element, and linear-algebra combinations while retaining readable, efficient application development.

  • Specialized code remains important for high performance, but automated generation can relieve programmers of time-consuming and error-prone implementation tasks.
  • DOLFIN targets automated solution of partial differential equations using the finite element method.
  • DOLFIN assembles arbitrary-rank tensors on simplex meshes in one, two, and three dimensions for broad classes of user-defined variational forms and finite elements.
  • The same assembly code supports combinations of computational mesh, variational form, finite element, and linear-algebra backend, with generated code designed to be efficient and compact.
  • The library is designed to coexist with other libraries and let users select components rather than commit to a rigid framework or entire package.

2. AUTOMATED FINITE ELEMENT COMPUTING

DOLFIN automates finite-element assembly by separating problem-specific information from reusable computational infrastructure. A form compiler generates specialized inner-loop code from high-level variational descriptions, while generic components handle meshes and linear algebra.

  • DOLFIN automates assembly of linear and nonlinear systems arising from variational finite-element discretizations.
  • Users can define variational forms and call assemble and solve to obtain a linear-system solution, as illustrated by a complete reaction–diffusion program.
  • 2.1 Automated code generation: The form compiler generates specialized code for the innermost assembly loop from a high-level mathematical description of a variational form.
  • 2.1 Automated code generation: The reusable library components include data structures and algorithms for linear algebra, meshes, functions, input/output, and plotting.
  • 2.1 Automated code generation: DOLFIN partitions input into problem-specific data handled by a form compiler and mesh-related data handled by general-purpose library components.
  • DOLFIN supports form compilers FFC and SyFi/SFC, with generated C++ code integrated into user programs through the DOLFIN library.

3. DESIGN CONSIDERATIONS

DOLFIN’s design combines technical innovation with application-driven generality, exposing mathematical abstractions through C++ and Python interfaces. It offers both minimal high-level use and lower-level control while delegating important functionality to interchangeable external libraries.

  • DOLFIN’s development was driven by technical innovation and by diverse applications demanding generic solutions for broad problem classes.
  • 3.1 Languages and language features: DOLFIN provides C++ and Python interfaces, with performance-critical operations implemented in C++ and Python extensions generated largely through SWIG.
  • 3.2 Interfaces: Users can solve many non-trivial PDE problems with less than 20 lines of code while retaining access to interfaces of varying complexity.
  • 3.2 Interfaces: The design uses mathematical abstractions such as Matrix, Vector, Mesh, FunctionSpace, Function, and VariationalProblem, together with assemble, solve, and plot.
  • External libraries provide important functionality such as linear-system solution, while simplified wrappers preserve a consistent interface and allow interchangeable backends.

4. DESIGN AND IMPLEMENTATION

DOLFIN combines modular object-oriented components with interchangeable linear algebra backends and dimension-independent mesh abstractions. Its mesh library stores data efficiently while supporting iterators, refinement, coarsening, and smoothing.

  • Component design: DOLFIN organizes linear algebra, mesh, finite element, and function functionality into components that can coexist with external libraries.The design lets users select particular classes rather than committing to a rigid framework or complete package.
  • Linear algebra: Multiple linear algebra backends expose sparse and dense matrices, preconditioners, iterative solvers, and direct solvers through a uniform interface.Supported backends include PETSc, Trilinos/Epetra, uBLAS, MTL4, UMFPACK, and CHOLMOD.
  • Linear algebra: C++ polymorphism provides common GenericMatrix and GenericVector interfaces, with backend-specific subclasses wrapping native data structures.This separates finite element assembly from the implementation details of individual linear algebra packages.
  • Meshes: DOLFIN uses a dimension-independent mesh abstraction and one assembly algorithm for simplex meshes in one, two, and three dimensions.Only simplicial meshes are currently supported, although the design paradigm extends to non-simplicial meshes.
  • Meshes: Mesh entities are represented by topological dimension and index, while specialized iterators provide access to vertices, edges, faces, facets, and cells.The mesh library also defines MeshFunction objects on selected mesh entities and supports adaptive refinement, coarsening, and smoothing.
  • Meshes: Plain C/C++ arrays store mesh data, with MeshEntity views and iterator classes providing an object-oriented interface without storing vertex, edge, or face objects.This combines a simple user interface with efficient underlying storage.

4.3 Finite elements

DOLFIN supports several families of conforming and nonconforming finite elements, including arbitrary-degree elements and nested mixed-element constructions. A form compiler generates common-interface C++ code for supported element families and degrees.

  • Supported elements: DOLFIN supports arbitrary-degree continuous Lagrange, Raviart–Thomas, Brezzi–Douglas–Marini, Brezzi–Douglas–Fortin–Marini, Nédélec, discontinuous Lagrange, and Crouzeix–Raviart elements.These cover H1-, H(div)-, H(curl)-, and L2-conforming categories, with Crouzeix–Raviart elements described as C0-nonconforming.
  • Mixed elements: Arbitrary combinations of supported elements define mixed elements, including Taylor–Hood elements formed from vector-valued P2 and scalar P1 components.Arbitrary nesting permits mixed elements to serve as building blocks in coupled problems.
  • Code generation: FFC generates C++ finite-element code conforming to the common UFC interface for each supported element family and degree q.FFC relies on FIAT to tabulate basis functions on a reference element, so DOLFIN does not contain a fixed finite-element library.

4.4 Function spaces

DOLFIN represents finite element function spaces through meshes, finite elements, and degree-of-freedom maps, enabling shared structure across functions. Functions store basis coefficients as vectors and support evaluation, modeling, visualization, and coupling.

  • Function spaces: FunctionSpace defines a finite-dimensional space using a Mesh, FiniteElement, and DofMap.The mesh specifies the domain, the element supplies local cell bases, and the DofMap patches local spaces into a global space.
  • Function spaces: Quadrature function spaces represent functions only at discrete quadrature points, where derivatives cannot be computed.They are available for problems for which ordinary finite element spaces are inappropriate.
  • Function spaces: Several functions can share one function space and therefore share its mesh, finite element, and degree-of-freedom mapping.This provides transparent data sharing through the function-space abstraction.
  • Functions: A Function is a linear combination of basis functions whose degrees of freedom are stored in a GenericVector.Functions can be evaluated, used as variational-form coefficients, saved, plotted, projected, or interpolated.
  • Functions: Function evaluation locates the containing mesh cell, evaluates basis functions at the point, and combines them with coefficients selected through the DofMap.DOLFIN uses the GNU Triangulated Surface Library to locate the cell efficiently.

4.6 Expressions

DOLFIN lets users express variational forms in notation close to mathematics and uses UFL and FFC to generate executable assembly code. The system supports broad multilinear and nonlinear forms while excluding some non-facet line and surface integrals.

  • Variational forms: Users define general variational forms in a language that mimics mathematical notation, including multilinear forms of arbitrary arity.Linear and bilinear forms are central to finite element discretizations, while higher-arity forms are also supported.
  • UFL: UFL supports functional differentiation of general nonlinear forms and integrals over cells, interior facets, and exterior facets.Line and surface integrals that do not coincide with cell facets are not yet supported.
  • Compilation: FFC compiles form descriptions into C++ headers and classes that users instantiate and pass to DOLFIN assembly routines.C++ users typically invoke the form compiler before compilation, whereas Python users receive automatic form compilation.
  • Compilation: Python form compilation generates and compiles required C++ code automatically, then caches the object code for reuse.For repeated Stokes solves, code is generated and compiled only on the first run.

4.8 Finite element assembly

DOLFIN assembles global tensors by computing element contributions and inserting them into global data structures. Its generated element-tensor and degree-of-freedom-mapping code supports general variational forms while keeping user interaction simple.

  • The assemble function maps variational forms to global tensors, including matrices from bilinear forms, vectors from linear forms, and scalars from functionals.
  • A global tensor is assembled by computing each element tensor AK and inserting its entries into the global tensor A.Contributions may also be assembled over exterior and, when required, interior facets.
  • Generated code evaluates element tensors and degree-of-freedom mappings on each mesh cell, enabling a general assembly algorithm.
  • Users can assemble a form with assemble(A, a), with optional parameters for subdomains or tensor reuse.

4.9 Boundary conditions

DOLFIN supports weak and strong boundary-condition enforcement within variational and linear-algebra workflows. Dirichlet conditions can be defined on selected function spaces and boundary subsets, then applied globally or during assembly.

  • Natural boundary conditions are enforced weakly, while essential boundary conditions are typically enforced strongly at the linear-algebra level.DOLFIN supports Neumann, Robin, Dirichlet, and periodic boundary-condition specifications within the stated scope.
  • A Dirichlet condition is specified by a function space V, a function g, and a boundary subset Γ ⊆ ∂Ω.The boundary may alternatively be represented by a MeshFunction marking boundary facets.
  • The function space determines where the condition applies, including particular components of mixed or vector-valued problems.
  • Applying a Dirichlet condition to an assembled system zeros constrained rows, sets diagonal entries to one, and inserts boundary values into the right-hand side.The alternative assembler-level method modifies element matrices while preserving global-matrix symmetry.

4.10 Variational problems

DOLFIN exposes high-level objects for defining and solving variational problems, while allowing users to configure constraints and solver choices. The library also provides file input/output, format conversion, and plotting for central data objects.

  • Variational problems can be defined and solved through high-level objects representing the canonical problem form.Users may supply Dirichlet constraints, linear solvers, preconditioners, and linearity settings.
  • For nonlinear variational problems, the bilinear form is interpreted as the Gateaux derivative of the nonlinear form.
  • DOLFIN stores central container objects, including vectors, matrices, meshes, and mesh functions, in XML format.Meshes can be loaded from and written back to files through the File interface.
  • The dolfin-convert utility converts mesh data from Gmsh, Medit, Diffpack, ABAQUS, Exodus II, and StarCD formats.
  • Solution data can be exported in VTK XML format, and built-in plotting supports meshes, mesh functions, and functions.

5. APPLICATIONS

The applications demonstrate DOLFIN’s use for functionals, error evaluation, several Poisson discretizations, time-dependent convection–diffusion, and nonlinear equations. These examples express problems through variational forms and use generated or built-in solution mechanisms.

  • 5. APPLICATIONS: The examples cover finite-element PDE solutions and related computations, including functionals, Poisson equations, time-dependent problems, and nonlinear problems.The examples correspond to DOLFIN 0.9.5.
  • 5.1 Evaluating functionals: A form compiler generates C++ code for computing a lift functional from a computed pressure field.
  • 5.1 Evaluating functionals: DOLFIN supports evaluating L2, H1, H10, and Hdiv norms and errors through explicit functionals or built-in norm and errornorm functions.
  • 5.2 Solving linear partial differential equations: Poisson’s equation is illustrated with H1-conforming primal, H(div) × L2-conforming mixed, and discontinuous Galerkin discretizations.
  • 5.3 Solving time-dependent partial differential equations: Unsteady problems are solved by defining a variational problem at each time step, with convection–diffusion discretized using Crank–Nicolson.The time step is kn = tn − tn−1 and midpoint quantities satisfy x̄ = (xn + xn−1)/2.
  • 5.4 Solving nonlinear partial differential equations: Nonlinear problems can be built from assemble and solve or handled by a built-in Newton solver using Gateaux derivatives.UFL supports automatic differentiation for linearizing many problems.

6. CONCLUSIONS

DOLFIN largely automates finite element approximation by combining generic mathematical abstractions with generated code for problem-specific components. Its design aims to preserve readability, performance, and broad implementation independence while supporting evolving capabilities.

  • DOLFIN largely automates finite element approximation by generating code for differential-equation-specific parts and providing a generic library reflecting variational-problem structure.
  • High-level mathematical abstraction and automated code generation support both readable formulations and efficient solutions, enabling rapid implementation of new models.
  • The system provides a general implementation independent of the variational problem, mesh, discretizing finite element spaces, and linear algebra backend.
  • Efficient parallel computing has been added, while automated error estimation and adaptivity are under development.
Loading 1103.6248v1…