Announcement: ufl_legacy and legacy dolfin

tl;dr: UFL is no longer compatible with legacy dolfin. A ufl_legacy package will be created to help keep old dolfin projects computing. Depending on how you use ufl, you might need to replace import ufl with import ufl_legacy as ufl.

Challenge: UFL continues to be developed alongside dolfinx (and ffcx/basix, and firedrake). The 2023 release of UFL broke compatibility with legacy dolfin (and old ffc).

The use-case requiring simultaneous installation of both dolfin and dolfinx might be, for instance, a research group running an Ubuntu cloud computing instance, with one student working with old dolfin code while another student develops new dolfinx code, both running their separate dolfin and dolfinx jobs on the same system.

Background: A software installation needs to maintain the correct set of compatible package versions in order to run successfully. Python via pip has a rudimentary sense of version management, but that is greatly complicated when binary python extensions written in C or C++ are involved. Essentially, you should never use pip to install packages. FEniCS has quite a long chain of package dependencies that needs to be maintained, ere ModuleNotFoundError be provoked. Python itself is only halfway along the chain.

libc - gcc - BLAS - MPI - SCOTCH - MUMPS - PETSc - Python3.y - pybind11 - UFL - dijitso - ffc - mpi4py - petsc4py - dolfin
libc - gcc - BLAS - MPI - SCOTCH - MUMPS - PETSc - Python3.y - pybind11 - UFL - Basix - ffcx - mpi4py - petsc4py - dolfinx

pip does not keep track of versions of the non-python libraries involved, which can lead to runtime failure.
When UFL becomes incompatible between dolfin and dolfinx, it means a system cannot run both dolfin and dolfinx projects from the same installation. There are a number of different approaches to managing package installations, each with advantages and disadvantages

  • virtual runtime environment (docker, spack). The package installation is managed in a separate environment, so different environments do not interfere with each other. Requires configuration (with version pinning if legacy dolfin is needed). Can’t install dolfin and dolfinx 0.6 at the same time with the same UFL (e.g. to compute different parts of a larger heterogenous job).
  • managed python environment (conda). conda uses python virtual environments to manage python package versions and also manages the required non-python C/C++ libraries. Requires configuration of virtual environments (with version pinning if legacy dolfin is needed). Can’t install dolfin and dolfinx 0.6 at the same time with the same UFL (e.g. to compute different parts of a larger heterogenous job).
  • Linux distribution (ubuntu/debian). The package management tool (apt) maintains compatible versions of dependent packages, both C/C++ and python. Minimal configuration needed (apt install fenics fenicsx). Allows** simultaneous installation of both dolfin and dolfinx 0.6 (e.g. to compute different parts of a larger heterogenous job combining results from old and new code).

** This announcement concerns the last statement. We are in the process of releasing the last dolfin-compatible version of UFL (ufl 2022), renamed as ufl_legacy [1] to avoid the name clash with the latest ufl. In due course ufl_legacy will be released to pypi and become accessible to docker and conda. New releases of ffc [2] and dolfin [3] will be made which use ufl_legacy. The process is less urgent for docker and conda installations, which can use version pinning of ufl 2022, at the cost of not enabling simultaneous installation of dolfin and dolfinx in the same virtual environment. The process of switching to ufl_legacy is more urgent for ubuntu/debian systems, where the design goal is to make `any" package (i.e. both dolfin and dolfinx) available to users, managed by a system administrator.

Package changes: The process of starting to switch old dolfin installations to ufl_legacy will therefore start with debian packaging, in debian unstable, which flows on to debian testing. Corresponding ubuntu packages will be provided on the FEniCS PPA. To enable time for communication about this change to propagate, I will start first with the current interim ubuntu release (23.03 lunar), and successively push to the other older and LTS ubuntu releases once we see that upgrades are going smoothly.

The legacy dolfin packages (and ffc) will start to depend on python3-ufl-legacy rather than python3-ufl. dolfinx 0.6 will become available (with python3-ufl 2023) at the same time.

Code changes: Depending on how you use legacy dolfin, it might be the case that no changes are required at all, e.g. if you use ufl classes from the dolfin namespace rather than the ufl namespace, for instance from dolfin import *; V=FunctionSpace(mesh,el) rather than import ufl; V=ufl.FunctionSpace(mesh,el). In this case no further action will be needed, apart from upgrading with apt update; apt upgrade; apt dist-upgrade.

If you have been using UFL explicitly with legacy dolfin, then the code change should be no more complex than replacing

import ufl


import ufl_legacy as ufl

or replacing

from ufl import FunctionSpace


from ufl_legacy import FunctionSpace

[1] ufl_legacy: GitHub - FEniCS/ufl-legacy: UFL - Unified Form Language (legacy)
[2] ffc/ufl_legacy: Bitbucket
[3] dolfin/ufl_legacy: Bitbucket


FEniCS packages offered by FEM on Colab and FEM on Kaggle now ship ufl_legacy instead of ufl. Users should handle as discussed above the transition from one to the other in their notebooks.

1 Like

FFC and DOLFIN with ufl legacy compatibility is now merged into the master branch of the respective repositories. A few minor patches for MeshView are planned to be merged soon before a final release of legacy DOLFIN

Dolfin-adjoint now supports ufl_legacy as of: Release 2023.1.0 · dolfin-adjoint/dolfin-adjoint · GitHub
A docker image with all packages pre-installed can be found at dolfin-adjoint versions · dolfin-adjoint · GitHub (for both amd and arm architecture).

There is also a 2023.0.0 release with compatible images to Dolfin master branch prior to the legacy release.