Skip to content

Commit f2775eb

Browse files
committed
Merge branch 'main' into release
2 parents b4c4a0c + 96fa05d commit f2775eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+998
-1024
lines changed

.github/workflows/book_stable.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ on:
44
workflow_dispatch:
55
workflow_call:
66
pull_request:
7-
branches: ["main"]
8-
7+
branches: ["release"]
8+
push:
9+
branches: ["release"]
910
env:
1011
HDF5_MPI: "ON"
1112
HDF5_DIR: "/usr/local/"
@@ -36,6 +37,7 @@ jobs:
3637
run: jupyter-book build . -W
3738

3839
- uses: actions/upload-artifact@v4
40+
if : always()
3941
with:
4042
name: webpage
4143
path: ./_build/html

.github/workflows/deploy.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Publish book
33
on:
44
push:
55
branches:
6-
- "main"
6+
- "release"
77
workflow_dispatch:
88

99
# Weekly build on Mondays at 8 am
@@ -19,12 +19,6 @@ concurrency:
1919
group: "pages"
2020
cancel-in-progress: true
2121

22-
env:
23-
HDF5_MPI: "ON"
24-
HDF5_DIR: "/usr/local/"
25-
DISPLAY: ":99.0"
26-
DEB_PYTHON_INSTALL_LAYOUT: deb_system
27-
2822
jobs:
2923
run-tests:
3024
uses: ./.github/workflows/test_stable.yml

.github/workflows/publish_docker.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
name: Publish tutorial docker image
12
on:
23
push:
34
branches:
@@ -41,8 +42,22 @@ jobs:
4142
with:
4243
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4344

44-
- name: Build and push Docker image
45+
- name: Build Docker image
4546
uses: docker/build-push-action@v5
47+
with:
48+
context: .
49+
load: true
50+
push: false
51+
file: docker/Dockerfile
52+
platforms: linux/amd64
53+
tags: ${{ steps.meta.outputs.tags }}
54+
labels: ${{ steps.meta.outputs.labels }}
55+
56+
57+
58+
- name: Build (arm) and push (amd/arm) Docker image
59+
uses: docker/build-push-action@v5
60+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
4661
with:
4762
context: .
4863
push: true

.github/workflows/test_nightly.yml

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ name: Test release branch against DOLFINx nightly build
44
on:
55
pull_request:
66
branches:
7-
- release
7+
- main
88

99
# Allows you to run this workflow manually from the Actions tab
1010
workflow_dispatch:
11-
11+
workflow_call:
1212
schedule:
1313
- cron: "0 9 * * *"
1414

@@ -25,18 +25,7 @@ jobs:
2525
DISPLAY: ":99.0"
2626
PYVISTA_JUPYTER_BACKEND: html
2727

28-
# Steps represent a sequence of tasks that will be executed as part of the job
2928
steps:
30-
# Checkout release branch to work on schedule
31-
- name: Checkout release branch
32-
uses: actions/checkout@v4
33-
if: ${{ github.event_name == 'schedule' }}
34-
with:
35-
ref: release
36-
37-
- name: Use current branch
38-
uses: actions/checkout@v4
39-
if: ${{ github.event_name != 'schedule' }}
4029

4130
- name: Special handling of some installation
4231
uses: ./.github/actions/install-dependencies
@@ -48,44 +37,54 @@ jobs:
4837
run: PYVISTA_OFF_SCREEN=false jupyter-book build -W .
4938

5039
- name: Test complex notebooks in parallel
40+
working-directory: chapter1
5141
run: |
5242
export PKG_CONFIG_PATH=/usr/local/dolfinx-complex/lib/pkgconfig:$PKG_CONFIG_PATH
5343
export PETSC_ARCH=linux-gnu-complex128-32
5444
export PYTHONPATH=/usr/local/dolfinx-complex/lib/python3.10/dist-packages:$PYTHONPATH
5545
export LD_LIBRARY_PATH=/usr/local/dolfinx-complex/lib:$LD_LIBRARY_PATH
56-
cd chapter1
5746
python3 complex_mode.py
5847
mpirun -n 2 python3 complex_mode.py
5948
60-
- name: Test real notebooks in parallel
49+
- name: Test chapter 1
50+
working-directory: chapter1
6151
run: |
62-
cd chapter1
63-
python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"
64-
mpirun -n 2 python3 fundamentals_code.py
65-
mpirun -n 2 python3 nitsche.py
66-
mpirun -n 2 python3 membrane_code.py
67-
cd ../chapter2
52+
python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"
53+
mpirun -n 2 python3 fundamentals_code.py
54+
mpirun -n 2 python3 nitsche.py
55+
mpirun -n 2 python3 membrane_code.py
56+
57+
- name: Test chapter 2
58+
working-directory: chapter2
59+
run: |
6860
mpirun -n 2 python3 diffusion_code.py
6961
mpirun -n 2 python3 heat_code.py
7062
mpirun -n 2 python3 linearelasticity_code.py
7163
mpirun -n 2 python3 hyperelasticity.py
7264
mpirun -n 2 python3 nonlinpoisson_code.py
7365
mpirun -n 2 python3 ns_code1.py
7466
mpirun -n 2 python3 ns_code2.py
75-
cd ../chapter3
67+
68+
- name: Test chapter 3
69+
working-directory: chapter3
70+
run: |
7671
mpirun -n 2 python3 neumann_dirichlet_code.py
7772
mpirun -n 2 python3 multiple_dirichlet.py
7873
mpirun -n 2 python3 subdomains.py
7974
mpirun -n 2 python3 robin_neumann_dirichlet.py
8075
mpirun -n 2 python3 component_bc.py
8176
mpirun -n 2 python3 em.py
82-
cd ../chapter4
77+
78+
- name: Test chapter 4
79+
working-directory: chapter4
80+
run: |
8381
mpirun -n 2 python3 solvers.py
8482
mpirun -n 2 python3 convergence.py
8583
mpirun -n 2 python3 compiler_parameters.py
8684
mpirun -n 2 python3 newton-solver.py
8785
8886
- uses: actions/upload-artifact@v4
87+
if: always()
8988
with:
9089
name: webpage
9190
path: ./_build/html

.github/workflows/test_stable.yml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
1-
name: Check that all python files run in parallel
1+
name: Test stable release
22

3-
# Controls when the action will run.
43
on:
5-
# Allows you to run this workflow manually from the Actions tab
64
workflow_dispatch:
75
workflow_call:
86
pull_request:
9-
branches: ["main"]
7+
branches: ["release"]
108
env:
11-
# Directory that will be published on github pages
129
HDF5_MPI: "ON"
1310
HDF5_DIR: "/usr/local/"
1411
DISPLAY: ":99.0"
1512
DEB_PYTHON_INSTALL_LAYOUT: deb_system
1613

17-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1814
jobs:
19-
# This workflow contains a single job called "build"
2015
test:
21-
# The type of runner that the job will run on
2216
runs-on: ubuntu-latest
23-
container: ghcr.io/fenics/dolfinx/lab:v0.7.2
17+
container: ghcr.io/fenics/dolfinx/lab:v0.8.0
2418
env:
2519
PYVISTA_OFF_SCREEN: true
2620

@@ -35,41 +29,51 @@ jobs:
3529
python3 -m pip install --no-binary=h5py .
3630
3731
- name: Test complex notebooks in parallel
32+
working-directory: chapter1
3833
run: |
3934
export PKG_CONFIG_PATH=/usr/local/dolfinx-complex/lib/pkgconfig:$PKG_CONFIG_PATH
4035
export PETSC_ARCH=linux-gnu-complex128-32
4136
export PYTHONPATH=/usr/local/dolfinx-complex/lib/python3.10/dist-packages:$PYTHONPATH
4237
export LD_LIBRARY_PATH=/usr/local/dolfinx-complex/lib:$LD_LIBRARY_PATH
43-
python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"
44-
cd chapter1
4538
python3 complex_mode.py
4639
mpirun -n 2 python3 complex_mode.py
47-
48-
- name: Test notebooks in parallel
40+
41+
- name: Test chapter 1
42+
working-directory: chapter1
4943
run: |
50-
python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"
51-
cd chapter1
52-
mpirun -n 2 python3 fundamentals_code.py
53-
mpirun -n 2 python3 membrane_code.py
54-
cd ../chapter2
44+
python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"
45+
mpirun -n 2 python3 fundamentals_code.py
46+
mpirun -n 2 python3 nitsche.py
47+
mpirun -n 2 python3 membrane_code.py
48+
49+
- name: Test chapter 2
50+
working-directory: chapter2
51+
run: |
5552
mpirun -n 2 python3 diffusion_code.py
5653
mpirun -n 2 python3 heat_code.py
5754
mpirun -n 2 python3 linearelasticity_code.py
5855
mpirun -n 2 python3 hyperelasticity.py
5956
mpirun -n 2 python3 nonlinpoisson_code.py
6057
mpirun -n 2 python3 ns_code1.py
6158
mpirun -n 2 python3 ns_code2.py
62-
cd ../chapter3
59+
60+
- name: Test chapter 3
61+
working-directory: chapter3
62+
run: |
6363
mpirun -n 2 python3 neumann_dirichlet_code.py
6464
mpirun -n 2 python3 multiple_dirichlet.py
6565
mpirun -n 2 python3 subdomains.py
6666
mpirun -n 2 python3 robin_neumann_dirichlet.py
6767
mpirun -n 2 python3 component_bc.py
6868
mpirun -n 2 python3 em.py
69-
cd ../chapter4
69+
70+
- name: Test chapter 4
71+
working-directory: chapter4
72+
run: |
7073
mpirun -n 2 python3 solvers.py
7174
mpirun -n 2 python3 convergence.py
7275
mpirun -n 2 python3 compiler_parameters.py
76+
mpirun -n 2 python3 newton-solver.py
7377
7478
- name: Upload Navier-Stokes DFG 2D 3 plots
7579
uses: actions/upload-artifact@v4

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ If you want to contribute to this tutorial, please make a fork of the repository
1616
act -j test-nightly
1717
```
1818

19-
Any code added to the tutorial should work in parallel.
20-
2119
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.
2220

23-
Note that every chapter is written as an IPython notebook and a Python file. These are kept in sync by jupytext. See [their notes](https://jupytext.readthedocs.io/en/latest/install.html#jupytext-commands-in-jupyterlab) on how to keep them in sync.
24-
Also ensure that both Python file and notebook files are updated by using jupytext, i.e.
21+
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`](https://jupytext.readthedocs.io/en/latest/faq.html#can-i-use-jupytext-with-jupyterhub-binder-nteract-colab-saturn-or-azure):
2522

2623
```bash
2724
python3 -m jupytext --sync */*.ipynb
25+
```
26+
27+
Any code added to the tutorial should work in parallel.
28+
29+
## Dependencies
30+
2831
It is adviced to use a pre-installed version of DOLFINx, for instance through conda or docker. Remaining dependencies can be installed with
2932

3033
```bash

chapter1/complex_mode.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"source": [
7474
"However, as we would like to solve linear algebra problems of the form $Ax=b$, we need to be able to use matrices and vectors that support real and complex numbers. As [PETSc](https://petsc.org/release/) is one of the most popular interfaces to linear algebra packages, we need to be able to work with their matrix and vector structures.\n",
7575
"\n",
76-
"Unfortunately, PETSc only supports one floating type in their matrices, thus we need to install two versions of PETSc, one that supports `float64` and one that supports `complex128`. In the [docker images](https://hub.docker.com/r/dolfinx/dolfinx) for DOLFINx, both versions are installed, and one can switch between them by calling `source dolfinx-real-mode` or `source dolfinx-complex-mode`. For the `dolfinx/lab` images, one can change the Python kernel to be either the real or complex mode, by going to `Kernel->Change Kernel...` and choose `Python3 (ipykernel)` (for real mode) or `Python3 (DOLFINx complex)` (for complex mode).\n",
76+
"Unfortunately, PETSc only supports one floating type in their matrices, thus we need to install two versions of PETSc, one that supports `float64` and one that supports `complex128`. In the [docker images](https://hub.docker.com/r/dolfinx/dolfinx) for DOLFINx, both versions are installed, and one can switch between them by calling `source dolfinx-real-mode` or `source dolfinx-complex-mode`. For the `dolfinx/lab` images, one can change the Python kernel to be either the real or complex mode, by going to `Kernel->Change Kernel...` and choosing `Python3 (ipykernel)` (for real mode) or `Python3 (DOLFINx complex)` (for complex mode).\n",
7777
"\n",
7878
"We check that we are using the correct installation of PETSc by inspecting the scalar type."
7979
]
@@ -161,7 +161,7 @@
161161
"id": "9efe0968-bf32-4184-85f7-4e8cc3401cfb",
162162
"metadata": {},
163163
"source": [
164-
"Similarly, if we want to use the function `ufl.derivative` to take derivatives of functionals, we need to take some special care. As `derivative` inserts a `ufl.TestFunction` to represent the variation, we need to take the conjugate of this to in order to assemble vectors.\n"
164+
"Similarly, if we want to use the function `ufl.derivative` to take derivatives of functionals, we need to take some special care. As `ufl.derivative` inserts a `ufl.TestFunction` to represent the variation, we need to take the conjugate of this to be able to use it to assemble vectors.\n"
165165
]
166166
},
167167
{

chapter1/complex_mode.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# extension: .py
77
# format_name: light
88
# format_version: '1.5'
9-
# jupytext_version: 1.15.2
9+
# jupytext_version: 1.16.1
1010
# kernelspec:
1111
# display_name: Python 3 (DOLFINx complex)
1212
# language: python
@@ -19,7 +19,7 @@
1919
#
2020
# Many PDEs, such as the [Helmholtz equation](https://docs.fenicsproject.org/dolfinx/v0.4.1/python/demos/demo_helmholtz.html) require complex-valued fields.
2121
#
22-
# For simplicity, let us consider a Poisson equation of the form:
22+
# For simplicity, let us consider a Poisson equation of the form:
2323
#
2424
# $$-\Delta u = f \text{ in } \Omega,$$
2525
# $$ f = -1 - 2j \text{ in } \Omega,$$
@@ -59,20 +59,17 @@
5959

6060
# However, as we would like to solve linear algebra problems of the form $Ax=b$, we need to be able to use matrices and vectors that support real and complex numbers. As [PETSc](https://petsc.org/release/) is one of the most popular interfaces to linear algebra packages, we need to be able to work with their matrix and vector structures.
6161
#
62-
# Unfortunately, PETSc only supports one floating type in their matrices, thus we need to install two versions of PETSc, one that supports `float64` and one that supports `complex128`. In the [docker images](https://hub.docker.com/r/dolfinx/dolfinx) for DOLFINx, both versions are installed, and one can switch between them by calling `source dolfinx-real-mode` or `source dolfinx-complex-mode`. For the `dolfinx/lab` images, one can change the Python kernel to be either the real or complex mode, by going to `Kernel->Change Kernel...` and choose `Python3 (ipykernel)` (for real mode) or `Python3 (DOLFINx complex)` (for complex mode).
62+
# Unfortunately, PETSc only supports one floating type in their matrices, thus we need to install two versions of PETSc, one that supports `float64` and one that supports `complex128`. In the [docker images](https://hub.docker.com/r/dolfinx/dolfinx) for DOLFINx, both versions are installed, and one can switch between them by calling `source dolfinx-real-mode` or `source dolfinx-complex-mode`. For the `dolfinx/lab` images, one can change the Python kernel to be either the real or complex mode, by going to `Kernel->Change Kernel...` and choosing `Python3 (ipykernel)` (for real mode) or `Python3 (DOLFINx complex)` (for complex mode).
6363
#
6464
# We check that we are using the correct installation of PETSc by inspecting the scalar type.
65-
#
6665

6766
from petsc4py import PETSc
6867
from dolfinx.fem.petsc import assemble_vector
6968
print(PETSc.ScalarType)
7069
assert np.dtype(PETSc.ScalarType).kind == 'c'
7170

7271
# ## Variational problem
73-
#
7472
# We are now ready to define our variational problem
75-
#
7673

7774
import ufl
7875
u = ufl.TrialFunction(V)
@@ -86,13 +83,12 @@
8683
# Secondly, note that we are using `ufl.inner` to describe multiplication of $f$ and $v$, even if they are scalar values. This is because `ufl.inner` takes the conjugate of the second argument, as decribed by the $L^2$ inner product. One could alternatively write this out explicitly
8784
#
8885
# ### Inner-products and derivatives
89-
#
9086

9187
L2 = f * ufl.conj(v) * ufl.dx
9288
print(L)
9389
print(L2)
9490

95-
# Similarly, if we want to use the function `ufl.derivative` to take derivatives of functionals, we need to take some special care. As `derivative` inserts a `ufl.TestFunction` to represent the variation, we need to take the conjugate of this to in order to assemble vectors.
91+
# Similarly, if we want to use the function `ufl.derivative` to take derivatives of functionals, we need to take some special care. As `ufl.derivative` inserts a `ufl.TestFunction` to represent the variation, we need to take the conjugate of this to be able to use it to assemble vectors.
9692
#
9793

9894
J = u_c**2 * ufl.dx
@@ -101,9 +97,7 @@
10197
print(residual.array)
10298

10399
# We define our Dirichlet condition and setup and solve the variational problem.
104-
#
105100
# ## Solve variational problem
106-
#
107101

108102
mesh.topology.create_connectivity(mesh.topology.dim-1, mesh.topology.dim)
109103
boundary_facets = dolfinx.mesh.exterior_facet_indices(mesh.topology)

chapter1/fundamentals.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Authors: Hans Petter Langtangen, Anders Logg
44

55
Adapted to FEniCSx by Jørgen S. Dokken
66

7-
The goal of this tutorial is to solve one of the most basic PDEs, the Poisson equation, with a few lines of code in FEniCSx. We start by introducing some fundamental FEniCSx objects, such as `Function`, `functionspace`, `TrialFunction` and `TestFunction`, and learn how to write a basic PDE solver.
7+
The goal of this tutorial is to solve one of the most basic PDEs, the Poisson equation, with a few lines of code in FEniCSx.
8+
We start by introducing some fundamental FEniCSx objects, such as `Function`, `functionspace`, `TrialFunction` and `TestFunction`, and learn how to write a basic PDE solver.
89
This will include:
910

1011
- How to formulate a mathematical variational problem
@@ -19,7 +20,8 @@ u(\mathbf{x}) &= u_D(\mathbf{x})&& \mathbf{x} \in \partial\Omega
1920
\end{align}
2021

2122
Here, $u=u(\mathbf{x})$ is the unknown function, $f=f(\mathbf{x})$ a prescribed function, $\nabla^2$ the Laplace operator
22-
(often written as $\Delta$), $\Omega$ the spatial domain, and $\partial\Omega$ the boundary of $\Omega$. The Poisson problem, including both the PDE, $-\nabla^2 u = f$, and the boundary condition, $u=u_D$ on $\partial\Omega$, is an example of a _boundary-value problem_, which must be precisely stated before we can start solving it numerically with FEniCSx.
23+
(often written as $\Delta$), $\Omega$ the spatial domain, and $\partial\Omega$ the boundary of $\Omega$.
24+
The Poisson problem, including both the PDE, $-\nabla^2 u = f$, and the boundary condition, $u=u_D$ on $\partial\Omega$, is an example of a _boundary-value problem_, which must be precisely stated before we can start solving it numerically with FEniCSx.
2325

2426
In the two-dimensional space with coordinates $x$ and $y$, we can expand the Poisson equation as
2527

chapter1/fundamentals_code.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"\n",
3636
"Inserting $u_e$ in the original boundary problem, we find that \n",
3737
"\\begin{align}\n",
38-
" f(x,y)= -6,\\qquad u_d(x,y)=u_e(x,y)=1+x^2+2y^2,\n",
38+
" f(x,y)= -6,\\qquad u_D(x,y)=u_e(x,y)=1+x^2+2y^2,\n",
3939
"\\end{align}\n",
4040
"regardless of the shape of the domain as long as we prescribe \n",
4141
"$u_e$ on the boundary.\n",

0 commit comments

Comments
 (0)