An implementation of ufl.ExternalOperator for DOLFINx
Project description
dolfinx-external-operator
dolfinx-external-operator is a implementation of the external
operator concept in
DOLFINx.
It allows for the expression of operators/functions in FEniCS that cannot be easily written in the Unified Form Language.
Potential application areas include complex constitutive models in solid and fluid mechanics, neural network constitutive models, multiscale modelling and inverse problems.
Implementations of external operators can be written in any library that supports the array interface protocol e.g. NumPy, JAX and Numba.
When using a library that supports program level automatic differentiation (AD), such as JAX, it is possible to automatically derive derivatives for use in local first and second-order solvers. Just-in-time compilation, batching and accelerators (GPUs, TPUs) are also supported.
Installation
dolfinx-external-operator is a pure Python package that depends on the
DOLFINx Python interface and UFL. Version numbers match with compatible
releases of DOLFINx.
The latest release version can be installed with:
pip install dolfinx-external-operator
The latest development version can be installed for development with:
git clone https://github.com/a-latyshev/dolfinx-external-operator.git
cd dolfinx-external-operator
pip install -e .
Documentation
The documentation contains various examples focusing on complex constitutive behaviour in solid mechanics, including:
Introduction to External Operators — FEniCS 2024 Conference:
<iframe width="700" height="400" src="https://www.youtube.com/embed/y8goeapqfsw?si=BQwDcdwqS3EF5rwW" frameborder="0" allowfullscreen></iframe>Citations
If you use dolfinx-external-operator in your research we ask that you cite
the following references:
@article{jtcam:14449,
title = {Expressing general constitutive models in FEniCSx using external operators and algorithmic automatic differentiation},
author = {Andrey Latyshev and Jérémy Bleyer and Corrado Maurini and Jack Hale},
doi = {10.46298/jtcam.14449},
journal = {Journal of Theoretical, Computational and Applied Mechanics},
issn = {2726-6141},
year = {2025},
month = {Sep},
keywords = {automated finite element solvers, Numba, JAX, FEniCSx, external operators, algorithmic automatic differentiation, constitutive models}
}
@inproceedings{latyshev_2024_external_paper,
author = {Latyshev, Andrey and Bleyer, Jérémy and Hale, Jack and Maurini, Corrado},
title = {A framework for expressing general constitutive models in FEniCSx},
booktitle = {16ème Colloque National en Calcul de Structures},
year = {2024},
month = {May},
publisher = {CNRS, CSMA, ENS Paris-Saclay, CentraleSupélec},
address = {Giens, France},
url = {https://hal.science/hal-04610881}
}
@software{latyshev_2024_external_code,
title = {a-latyshev/dolfinx-external-operator},
author = {Latyshev, Andrey and Hale, Jack},
date = {2025},
doi = {10.5281/zenodo.10907417},
organization = {Zenodo}
}
Contributors
- Andrey Latyshev (University of Luxembourg, Sorbonne Université, andrey.latyshev@uni.lu)
- Jérémy Bleyer (École des Ponts ParisTech, Université Gustave Eiffel, jeremy.bleyer@enpc.fr)
- Jack S. Hale (University of Luxembourg, jack.hale@uni.lu)
- Corrado Maurini (Sorbonne Université, corrado.maurini@sorbonne-universite.fr)
- Jørgen S. Dokken (Simula Research Laboratory, dokken@simula.no)
If you wish to be added as a contributor after an accepted PR please ask via email.
License
dolfinx-external-operator is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
dolfinx-external-operator is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with dolfinx-external-operator. If not, see https://www.gnu.org/licenses/.
Acknowledgments
This research was funded in whole, or in part, by the Luxembourg National Research Fund (FNR), grant reference PRIDE/21/16747448/MATHCODA.
Developer notes
Docker container
docker run -ti -v $(pwd):/shared --entrypoint /bin/bash -w /shared docker.io/dolfinx/lab:nightly
pip install .
Building Documentation
pip install '.[doc]'
cd doc/
jupyter-book build .
and follow the instructions printed.
To continuously build and view the documentation in a web browser
pip install sphinx-autobuild
cd build/
jupyter-book config sphinx .
sphinx-autobuild . _build/html -b html
Linting
To lint and format
pip install '.[lint]'
ruff check .
ruff format .
Running tests
pip install '.[test]'
py.test -v test/
Releases
git pull
git checkout release
git merge --no-commit origin/main
git checkout --theirs . # files deleted on `main` must be manually git `rm`ed
vim pyproject.toml # Update version numbers
git diff origin/main # Check for mistakes
git tag v0.9.0 # for example
git push --tags origin
Then make a release using GitHub Releases.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file dolfinx_external_operator-0.10.1.tar.gz.
File metadata
- Download URL: dolfinx_external_operator-0.10.1.tar.gz
- Upload date:
- Size: 34.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6991e6f06ab1e9531398fa1bf6282a6b11ee6e6f1ca9de3a65c350c70e213f20
|
|
| MD5 |
842bd8acfa5b4c3aa27ffeca53a74c65
|
|
| BLAKE2b-256 |
240b8e192bcd24a18701705d6e03dc02153d31114ffaebd6de4bb86f84746ca6
|
Provenance
The following attestation bundles were made for dolfinx_external_operator-0.10.1.tar.gz:
Publisher:
pypi.yml on a-latyshev/dolfinx-external-operator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dolfinx_external_operator-0.10.1.tar.gz -
Subject digest:
6991e6f06ab1e9531398fa1bf6282a6b11ee6e6f1ca9de3a65c350c70e213f20 - Sigstore transparency entry: 1317150618
- Sigstore integration time:
-
Permalink:
a-latyshev/dolfinx-external-operator@0094f5047f7c7fe8af1fce5a33880c76393e1dfe -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/a-latyshev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@0094f5047f7c7fe8af1fce5a33880c76393e1dfe -
Trigger Event:
push
-
Statement type: