Skip to content

Commit b4c4a0c

Browse files
authored
Merge main into release (#189)
* Merge main into release * Apply suggestions from code review * Various fixes when reading through the diff * Further fixes
1 parent a36ae80 commit b4c4a0c

32 files changed

+1752
-313
lines changed

.github/workflows/book_stable.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ env:
1515
jobs:
1616
build-book:
1717
runs-on: ubuntu-latest
18-
container: ghcr.io/fenics/dolfinx/lab:v0.7.2
18+
container: ghcr.io/fenics/dolfinx/lab:v0.8.0
1919

2020
env:
2121
PYVISTA_TRAME_SERVER_PROXY_PREFIX: "/proxy/"
@@ -35,7 +35,7 @@ jobs:
3535
- name: Build the book
3636
run: jupyter-book build . -W
3737

38-
- uses: actions/upload-artifact@v3
38+
- uses: actions/upload-artifact@v4
3939
with:
4040
name: webpage
4141
path: ./_build/html

.github/workflows/deploy.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ jobs:
4747
uses: actions/configure-pages@v4
4848

4949
- name: Download docs artifact
50-
uses: actions/download-artifact@v3
50+
uses: actions/download-artifact@v4
5151
with:
5252
name: webpage
5353
path: "./public"
5454

5555
- name: Upload page artifact
56-
uses: actions/upload-pages-artifact@v2
56+
uses: actions/upload-pages-artifact@v3
5757
with:
5858
path: "./public"
5959

6060
- name: Deploy coverage report to GH Pages
6161
id: deployment
62-
uses: actions/deploy-pages@v3
62+
uses: actions/deploy-pages@v4

.github/workflows/publish_docker.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,26 @@ jobs:
2323
uses: actions/checkout@v4
2424

2525
- name: Set up QEMU
26-
uses: docker/setup-qemu-action@v2
26+
uses: docker/setup-qemu-action@v3
2727

2828
- name: Set up Docker Buildx
29-
uses: docker/setup-buildx-action@v2
29+
uses: docker/setup-buildx-action@v3
3030

3131
- name: Log in to the Container registry
32-
uses: docker/login-action@v2
32+
uses: docker/login-action@v3
3333
with:
3434
registry: ${{ env.REGISTRY }}
3535
username: ${{ github.actor }}
3636
password: ${{ secrets.GITHUB_TOKEN }}
3737

3838
- name: Extract metadata (tags, labels) for Docker
3939
id: meta
40-
uses: docker/metadata-action@v4
40+
uses: docker/metadata-action@v5
4141
with:
4242
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4343

4444
- name: Build and push Docker image
45-
uses: docker/build-push-action@v3
45+
uses: docker/build-push-action@v5
4646
with:
4747
context: .
4848
push: true

.github/workflows/test_nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
mpirun -n 2 python3 compiler_parameters.py
8686
mpirun -n 2 python3 newton-solver.py
8787
88-
- uses: actions/upload-artifact@v3
88+
- uses: actions/upload-artifact@v4
8989
with:
9090
name: webpage
9191
path: ./_build/html

.github/workflows/test_stable.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
mpirun -n 2 python3 compiler_parameters.py
7373
7474
- name: Upload Navier-Stokes DFG 2D 3 plots
75-
uses: actions/upload-artifact@v3
75+
uses: actions/upload-artifact@v4
7676
with:
7777
name: DFG2D-3
7878
path: chapter2/figures

Changelog.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# Changelog
22

3-
## Release
4-
- Replace all `ufl.FiniteElement` and `ufl.VectorElement` with the appropriate `basix.ufl.element`
5-
- Replace `dolfinx.fem.FunctionSpace` with `dolfinx.fem.functionspace`
3+
## v0.8.0
4+
5+
- Replace all `ufl.FiniteElement` and `ufl.VectorElement` with the appropriate `basix.ufl.element`
6+
- Replace `dolfinx.fem.FunctionSpace` with `dolfinx.fem.functionspace`
67

78
## v0.7.2
8-
- Change pyvista backend to `html`, using Pyvista main branch
9-
- Using DOLFINx v0.7.2 https://github.com/FEniCS/dolfinx/releases/tag/v0.7.2 as base
9+
10+
- Change pyvista backend to `html`, using Pyvista main branch
11+
- Using DOLFINx v0.7.2 https://github.com/FEniCS/dolfinx/releases/tag/v0.7.2 as base
1012

1113
## v0.7.1
12-
- No API changes, release due to various bug-fixes from the 0.7.0 release, see:
13-
https://github.com/FEniCS/dolfinx/releases/tag/v0.7.1 for more information
14+
15+
- No API changes, release due to various bug-fixes from the 0.7.0 release, see:
16+
https://github.com/FEniCS/dolfinx/releases/tag/v0.7.1 for more information
1417

1518
## v0.7.0
1619

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# The DOLFINx tutorial
2+
23
[![Test, build and publish](https://github.com/jorgensd/dolfinx-tutorial/actions/workflows/build-publish.yml/badge.svg)](https://github.com/jorgensd/dolfinx-tutorial/actions/workflows/build-publish.yml)
34
[![Test release branch against DOLFINx nightly build](https://github.com/jorgensd/dolfinx-tutorial/actions/workflows/nightly.yml/badge.svg)](https://github.com/jorgensd/dolfinx-tutorial/actions/workflows/nightly.yml)
45

@@ -8,35 +9,47 @@ This is the source code for the dolfinx-tutorial [webpage](https://jorgensd.gith
89
If you have any comments, corrections or questions, please submit an issue in the issue tracker.
910

1011
## Contributing
12+
1113
If you want to contribute to this tutorial, please make a fork of the repository, make your changes, and test that the CI passes. You can do this locally by downloading [act](https://github.com/nektos/act) and call
14+
1215
```bash
1316
act -j test-nightly
1417
```
18+
1519
Any code added to the tutorial should work in parallel.
1620

1721
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.
1822

1923
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.
2025

21-
## Dependencies
26+
```bash
27+
python3 -m jupytext --sync */*.ipynb
2228
It is adviced to use a pre-installed version of DOLFINx, for instance through conda or docker. Remaining dependencies can be installed with
29+
2330
```bash
2431
python3 -m pip install --no-binary=h5py -e .
2532
```
2633

2734
# Docker images
28-
Docker images for this tutorial can be found in the [packages tab](https://github.com/jorgensd/dolfinx-tutorial/pkgs/container/dolfinx-tutorial)
35+
36+
Docker images for this tutorial can be found in the [packages tab](https://github.com/jorgensd/dolfinx-tutorial/pkgs/container/dolfinx-tutorial)
2937

3038
Additional requirements on top of the `dolfinx/lab:nightly` images can be found at [Dockerfile](docker/Dockerfile) and [pyproject.toml](./pyproject.toml)
3139

3240
##
41+
3342
An image building DOLFINx, Basix, UFL and FFCx from source can be built using:
43+
3444
```bash
3545
cd docker
3646
docker build -f ./docker/Dockerfile -t local_lab_env .
3747
```
48+
3849
from the root of this repository, and run
50+
3951
```bash
4052
docker run --rm -ti -v $(pwd):/root/shared -w /root/shared --init -p 8888:8888 local_lab_env
41-
```
53+
```
54+
4255
from the main directory.

chapter1/complex_mode.ipynb

Lines changed: 20 additions & 41 deletions
Large diffs are not rendered by default.

chapter1/complex_mode.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
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,$$
25-
# $$ f = -1 - 2j \text{ in } \Omega,$$
25+
# $$ f = -1 - 2j \text{ in } \Omega,$$
2626
# $$ u = u_{exact} \text{ on } \partial\Omega,$$
2727
# $$u_{exact}(x, y) = \frac{1}{2}x^2 + 1j\cdot y^2,$$
2828
#
2929
# As in [Solving the Poisson equation](./fundamentals) we want to express our partial differential equation as a weak formulation.
3030
#
31-
# We start by defining our discrete function space $V_h$, such that $u_h\in V_h$ and $u_h = \sum_{i=1}^N c_i \phi_i(x, y)$ where $\phi_i$ are **real valued** global basis functions of our space $V_h$, $c_i \in \mathcal{C}$ are the **complex valued** degrees of freedom.
31+
# We start by defining our discrete function space $V_h$, such that $u_h\in V_h$ and $u_h = \sum_{i=1}^N c_i \phi_i(x, y)$ where $\phi_i$ are **real valued** global basis functions of our space $V_h$, and $c_i \in \mathcal{C}$ are the **complex valued** degrees of freedom.
3232
#
33-
# Next, we choose a test function $v\in \hat V_h$ where $\hat V_h\subset V_h$ such that $v\vert_{\partial\Omega}=0$, as done in the first tutorial.
34-
# We now need to define our inner product space. We choose the $L^2$ inner product spaces, which is a *[sesquilinear](https://en.wikipedia.org/wiki/Sesquilinear_form) 2-form*, Meaning that $\langle u, v\rangle$ is a map from $V_h\times V_h\mapsto K$, and $\langle u, v \rangle = \int_\Omega u \cdot \bar v ~\mathrm{d} x$. As it is sesquilinear, we have the following properties:
33+
# Next, we choose a test function $v\in \hat V_h$ where $\hat V_h\subset V_h$ such that $v\vert_{\partial\Omega}=0$, as done in the first tutorial.
34+
# We now need to define our inner product space. We choose the $L^2$ inner product spaces, which is a _[sesquilinear](https://en.wikipedia.org/wiki/Sesquilinear_form) 2-form_, meaning that $\langle u, v\rangle$ is a map from $V_h\times V_h\mapsto K$, and $\langle u, v \rangle = \int_\Omega u \cdot \bar v ~\mathrm{d} x$. As it is sesquilinear, we have the following properties:
3535
#
3636
# $$\langle u , v \rangle = \overline{\langle v, u \rangle},$$
3737
# $$\langle u , u \rangle \geq 0.$$
@@ -41,10 +41,12 @@
4141
# $$\int_\Omega \nabla u_h \cdot \nabla \overline{v}~ \mathrm{dx} = \int_{\Omega} f \cdot \overline{v} ~\mathrm{d} s \qquad \forall v \in \hat{V}_h.$$
4242
#
4343
# ## Installation of FEniCSx with complex number support
44-
# FEniCSx supports both real and complex numbers, meaning that we can create a function spaces with real valued or complex valued coefficients.
44+
#
45+
# FEniCSx supports both real and complex numbers, so we can create a function space with real valued or complex valued coefficients.
46+
#
4547

46-
import dolfinx
4748
from mpi4py import MPI
49+
import dolfinx
4850
import numpy as np
4951
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10)
5052
V = dolfinx.fem.functionspace(mesh, ("Lagrange", 1))
@@ -55,19 +57,22 @@
5557
print(u_r.x.array.dtype)
5658
print(u_c.x.array.dtype)
5759

58-
# However, as we would like to solve linear algebra problems on 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.
60+
# 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.
5961
#
6062
# 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).
6163
#
6264
# We check that we are using the correct installation of PETSc by inspecting the scalar type.
65+
#
6366

6467
from petsc4py import PETSc
6568
from dolfinx.fem.petsc import assemble_vector
6669
print(PETSc.ScalarType)
6770
assert np.dtype(PETSc.ScalarType).kind == 'c'
6871

6972
# ## Variational problem
73+
#
7074
# We are now ready to define our variational problem
75+
#
7176

7277
import ufl
7378
u = ufl.TrialFunction(V)
@@ -78,23 +83,27 @@
7883

7984
# Note that we have used the `PETSc.ScalarType` to wrap the constant source on the right hand side. This is because we want the integration kernels to assemble into the correct floating type.
8085
#
81-
# 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 manually
86+
# 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
8287
#
8388
# ### Inner-products and derivatives
89+
#
8490

8591
L2 = f * ufl.conj(v) * ufl.dx
8692
print(L)
8793
print(L2)
8894

89-
# 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 be able to use it to assemble vectors.
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.
96+
#
9097

9198
J = u_c**2 * ufl.dx
9299
F = ufl.derivative(J, u_c, ufl.conj(v))
93100
residual = assemble_vector(dolfinx.fem.form(F))
94101
print(residual.array)
95102

96103
# We define our Dirichlet condition and setup and solve the variational problem.
104+
#
97105
# ## Solve variational problem
106+
#
98107

99108
mesh.topology.create_connectivity(mesh.topology.dim-1, mesh.topology.dim)
100109
boundary_facets = dolfinx.mesh.exterior_facet_indices(mesh.topology)
@@ -103,8 +112,10 @@
103112
problem = dolfinx.fem.petsc.LinearProblem(a, L, bcs=[bc])
104113
uh = problem.solve()
105114

106-
# We compute the $L^2$ error and the max error
115+
# We compute the $L^2$ error and the max error.
116+
#
107117
# ## Error computation
118+
#
108119

109120
x = ufl.SpatialCoordinate(mesh)
110121
u_ex = 0.5 * x[0]**2 + 1j*x[1]**2
@@ -115,7 +126,9 @@
115126
print(global_error, max_error)
116127

117128
# ## Plotting
118-
# Finally, we plot the real and imaginary solution
129+
#
130+
# Finally, we plot the real and imaginary solutions.
131+
#
119132

120133
import pyvista
121134
pyvista.start_xvfb()

0 commit comments

Comments
 (0)