Skip to content

About

A reimplementation of the Springer book: https://github.com/hplgit/fenics-tutorial/, covering new topics as well as transitioning from dolfin to dolfinx

Topics

Resources

Stars

168 stars

Watchers

4 watching

Forks

Repository files navigation

The DOLFINx tutorial

Test, build and publish Test release branch against DOLFINx nightly build

Author: Jørgen S. Dokken

This is the source code for the dolfinx-tutorial webpage. If you have any comments, corrections or questions, please submit an issue in the issue tracker.

Versions of the webpage

The webpage has a version switcher, and a version of the tutorial for:

  • stable: the newest release, where the webpage (and any link from before it had versions) leads.
  • main: the main branch, built against DOLFINx nightly. It is rebuilt on every push to main.
  • vX.Y: each minor release from the one set in docs-versions.toml, built from its newest vX.Y.Z[.postN] tag.

A release is made by pushing a tag vX.Y.Z on main: the deploy workflow builds and tests it in the image ghcr.io/fenics/dolfinx/lab:vX.Y.0 (which can be overridden in docs-versions.toml), and stable moves to it. Every build is tested, and only published if its tests pass; otherwise the version keeps its previous build. Each version is built once, and its HTML is kept in the docs-archive release, which must not be deleted. A tag that fails to build or test gets a .failed mark there, and isn't built again until the mark is deleted (a build that didn't finish for other reasons, such as a cancelled job, is tried again on the next run). To rebuild a release, delete its tarball (or mark) from that release and run the deploy workflow.

Pull requests are tested against DOLFINx nightly, and also against the newest release (in its image), to show whether the change works there too.

Contributing

If you want to contribute to this tutorial, please make a fork of the repository, make your changes, and test that the CI passes.

Alternatively, if you want to add a separate chapter, a Jupyter notebook can be added to a pull request, without integrating it into the tutorial. If so, the notebook will be reviewed and modified to be included in the tutorial.

Any code added to the tutorial should work in parallel. If any changes are made to ipynb files, please ensure that these changes are reflected in the corresponding py files by using jupytext:

Building the book and running code

The book is built using jupyterbook. The following environment variables should be set if you want to build the book

PYVISTA_OFF_SCREEN=false
PYVISTA_JUPYTER_BACKEND="html"
JUPYTER_EXTENSION_ENABLED=true
LIBGL_ALWAYS_SOFTWARE=1

If you run the tutorial using jupyter-lab, for instance through conda, one should set the following environment variables

PYVISTA_OFF_SCREEN=false
PYVISTA_JUPYTER_BACKEND="trame"
JUPYTER_EXTENSION_ENABLED=true
LIBGL_ALWAYS_SOFTWARE=1

If you use docker to run your code, you should set the following variables:

docker run -ti -e DISPLAY=$DISPLAY -e LIBGL_ALWAYS_SOFTWARE=1 -e PYVISTA_OFF_SCREEN=false -e PYVISTA_JUPYTER_BACKEND="trame" -e JUPYTER_EXTENSION_ENABLED=true --network=host -v $(pwd):/root/shared -w /root/shared  ....

To run python scripts, either choose PYVISTA_OFF_SCREEN=True to get screenshots, or render interactive plots with PYVISTA_OFF_SCREEN=False

python3 -m jupytext --sync  */*.ipynb --set-formats ipynb,py:light

or

python3 -m jupytext --sync  */*.py --set-formats ipynb,py:light

Any code added to the tutorial should work in parallel.

To strip notebook output, one can use pre-commit.

pre-commit run --all-files

Dependencies

It is advised to use a pre-installed version of DOLFINx, for instance through conda or docker. Remaining dependencies can be installed with

python3 -m pip install --no-binary=h5py --no-build-isolation -e .

Docker images

Docker images for this tutorial can be found in the packages tab

Additional requirements on top of the dolfinx/lab:nightly images can be found at Dockerfile and pyproject.toml

An image building DOLFINx, Basix, UFL and FFCx from source can be built using:

docker build -f ./docker/Dockerfile -t local_lab_env .

from the root of this repository, and run

 docker run --rm -ti -v $(pwd):/root/shared -w /root/shared  --init -p 8888:8888 local_lab_env

from the main directory.

About

A reimplementation of the Springer book: https://github.com/hplgit/fenics-tutorial/, covering new topics as well as transitioning from dolfin to dolfinx

Topics

Resources

Stars

168 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages