Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgensd committed Oct 14, 2024
2 parents adf0314 + d054ef7 commit aa4ef09
Show file tree
Hide file tree
Showing 26 changed files with 85 additions and 164 deletions.
9 changes: 4 additions & 5 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Install dependencies
runs:
using: composite
steps:
- name: Install apt dependencies and upgrade pip
shell: bash -el {0}
run: |
apt-get update && apt-get install -y libgl1-mesa-glx libxrender1 xvfb
python3 -m pip install -U pip
- name: Install apt dependencies and upgrade pip
shell: bash -el {0}
run: |
apt-get update && apt-get install -y libxrender1 xvfb
4 changes: 1 addition & 3 deletions .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ jobs:
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}



- name: Build (arm) and push (amd/arm) Docker image
uses: docker/build-push-action@v5
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
if: github.event_name == 'push'
with:
context: .
push: true
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/test_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ jobs:
uses: ./.github/actions/install-dependencies

- name: Install requirements
run: python3 -m pip install --no-cache-dir --no-binary=h5py . --upgrade
run: |
python3 -m pip install --break-system-packages -U pip setuptools pkgconfig
python3 -m pip install --no-build-isolation --break-system-packages --no-cache-dir --no-binary=h5py . --upgrade
- name: Test building the book
run: PYVISTA_OFF_SCREEN=false jupyter-book build -W .

- name: Test building the book
run: PYVISTA_OFF_SCREEN=false jupyter-book build -W .
Expand All @@ -42,30 +47,29 @@ jobs:
run: |
export PKG_CONFIG_PATH=/usr/local/dolfinx-complex/lib/pkgconfig:$PKG_CONFIG_PATH
export PETSC_ARCH=linux-gnu-complex128-32
export PYTHONPATH=/usr/local/dolfinx-complex/lib/python3.10/dist-packages:$PYTHONPATH
export PYTHONPATH=/usr/local/dolfinx-complex/lib/python3.12/dist-packages:$PYTHONPATH
export LD_LIBRARY_PATH=/usr/local/dolfinx-complex/lib:$LD_LIBRARY_PATH
python3 complex_mode.py
mpirun -n 2 python3 complex_mode.py
- name: Test chapter 1
working-directory: chapter1
run: |
python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"
mpirun -n 2 python3 fundamentals_code.py
mpirun -n 2 python3 nitsche.py
mpirun -n 2 python3 membrane_code.py
python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"
mpirun -n 2 python3 fundamentals_code.py
mpirun -n 2 python3 nitsche.py
mpirun -n 2 python3 membrane_code.py
- name: Test chapter 2
working-directory: chapter2
run: |
run: |
mpirun -n 2 python3 diffusion_code.py
mpirun -n 2 python3 heat_code.py
mpirun -n 2 python3 linearelasticity_code.py
mpirun -n 2 python3 hyperelasticity.py
mpirun -n 2 python3 nonlinpoisson_code.py
mpirun -n 2 python3 ns_code1.py
mpirun -n 2 python3 ns_code2.py
- name: Test chapter 3
working-directory: chapter3
run: |
Expand All @@ -75,7 +79,6 @@ jobs:
mpirun -n 2 python3 robin_neumann_dirichlet.py
mpirun -n 2 python3 component_bc.py
mpirun -n 2 python3 em.py
- name: Test chapter 4
working-directory: chapter4
run: |
Expand Down
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v0.9.0

- `scale` in `apply_lifting` has been renamed to `alpha`
- Use `dolfinx.fem.Function.x.petsc_vec` as opposed to `dolfinx.fem.Function.vector`

## v0.8.0

- Replace all `ufl.FiniteElement` and `ufl.VectorElement` with the appropriate `basix.ufl.element`
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/jorgensd/dolfinx-tutorial:v0.7.2
FROM ghcr.io/jorgensd/dolfinx-tutorial:release

# create user with a home directory
ARG NB_USER=jovyan
Expand Down
127 changes: 13 additions & 114 deletions chapter1/complex_mode.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "b52b39d9-260d-4c54-b62a-7440c3b92e5a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"float64\n",
"complex128\n"
]
}
],
"outputs": [],
"source": [
"from mpi4py import MPI\n",
"import dolfinx\n",
Expand Down Expand Up @@ -80,18 +71,10 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "4d5b03e3-4d7f-45b7-95eb-9130a5141f34",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'numpy.complex128'>\n"
]
}
],
"outputs": [],
"source": [
"from petsc4py import PETSc\n",
"from dolfinx.fem.petsc import assemble_vector\n",
Expand All @@ -110,7 +93,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "be8461a0-a089-4ff3-8bc8-61b016407e70",
"metadata": {},
"outputs": [],
Expand All @@ -137,19 +120,10 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "779ab267-4609-4628-9577-a280b9c18b6d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{ c_0 * (conj((v_0))) } * dx(<Mesh #0>[everywhere], {})\n",
"{ c_0 * (conj((v_0))) } * dx(<Mesh #0>[everywhere], {})\n"
]
}
],
"outputs": [],
"source": [
"L2 = f * ufl.conj(v) * ufl.dx\n",
"print(L)\n",
Expand All @@ -166,78 +140,10 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "d61c477a-d364-4a81-9362-42f1eb4cd8ee",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[4.21666667e-03+3.33333333e-05j 1.58750000e-03+8.33333333e-06j\n",
" 4.68333333e-03+1.00000000e-04j 8.13333333e-03+2.66666667e-04j\n",
" 3.35000000e-03+3.33333333e-05j 4.68333333e-03+3.66666667e-04j\n",
" 6.43333333e-03+2.66666667e-04j 8.13333333e-03+8.66666667e-04j\n",
" 2.58333333e-03+3.33333333e-05j 4.68333333e-03+8.33333333e-04j\n",
" 4.93333333e-03+2.66666667e-04j 6.43333333e-03+8.66666667e-04j\n",
" 8.13333333e-03+1.86666667e-03j 1.91666667e-03+3.33333333e-05j\n",
" 4.68333333e-03+1.50000000e-03j 3.63333333e-03+2.66666667e-04j\n",
" 4.93333333e-03+8.66666667e-04j 6.43333333e-03+1.86666667e-03j\n",
" 8.13333333e-03+3.26666667e-03j 1.35000000e-03+3.33333333e-05j\n",
" 4.68333333e-03+2.36666667e-03j 2.53333333e-03+2.66666667e-04j\n",
" 3.63333333e-03+8.66666667e-04j 4.93333333e-03+1.86666667e-03j\n",
" 6.43333333e-03+3.26666667e-03j 8.13333333e-03+5.06666667e-03j\n",
" 8.83333333e-04+3.33333333e-05j 4.68333333e-03+3.43333333e-03j\n",
" 1.63333333e-03+2.66666667e-04j 2.53333333e-03+8.66666667e-04j\n",
" 3.63333333e-03+1.86666667e-03j 4.93333333e-03+3.26666667e-03j\n",
" 6.43333333e-03+5.06666667e-03j 8.13333333e-03+7.26666667e-03j\n",
" 5.16666667e-04+3.33333333e-05j 4.68333333e-03+4.70000000e-03j\n",
" 9.33333333e-04+2.66666667e-04j 1.63333333e-03+8.66666667e-04j\n",
" 2.53333333e-03+1.86666667e-03j 3.63333333e-03+3.26666667e-03j\n",
" 4.93333333e-03+5.06666667e-03j 6.43333333e-03+7.26666667e-03j\n",
" 8.13333333e-03+9.86666667e-03j 2.50000000e-04+3.33333333e-05j\n",
" 4.68333333e-03+6.16666667e-03j 4.33333333e-04+2.66666667e-04j\n",
" 9.33333333e-04+8.66666667e-04j 1.63333333e-03+1.86666667e-03j\n",
" 2.53333333e-03+3.26666667e-03j 3.63333333e-03+5.06666667e-03j\n",
" 4.93333333e-03+7.26666667e-03j 6.43333333e-03+9.86666667e-03j\n",
" 8.13333333e-03+1.28666667e-02j 8.33333333e-05+3.33333333e-05j\n",
" 4.68333333e-03+7.83333333e-03j 1.33333333e-04+2.66666667e-04j\n",
" 4.33333333e-04+8.66666667e-04j 9.33333333e-04+1.86666667e-03j\n",
" 1.63333333e-03+3.26666667e-03j 2.53333333e-03+5.06666667e-03j\n",
" 3.63333333e-03+7.26666667e-03j 4.93333333e-03+9.86666667e-03j\n",
" 6.43333333e-03+1.28666667e-02j 8.13333333e-03+1.62666667e-02j\n",
" 1.25000000e-05+2.50000000e-05j 3.09583333e-03+6.19166667e-03j\n",
" 1.66666667e-05+1.66666667e-04j 1.33333333e-04+8.66666667e-04j\n",
" 4.33333333e-04+1.86666667e-03j 9.33333333e-04+3.26666667e-03j\n",
" 1.63333333e-03+5.06666667e-03j 2.53333333e-03+7.26666667e-03j\n",
" 3.63333333e-03+9.86666667e-03j 4.93333333e-03+1.28666667e-02j\n",
" 6.43333333e-03+1.62666667e-02j 3.91666667e-03+9.36666667e-03j\n",
" 1.66666667e-05+5.00000000e-04j 1.33333333e-04+1.86666667e-03j\n",
" 4.33333333e-04+3.26666667e-03j 9.33333333e-04+5.06666667e-03j\n",
" 1.63333333e-03+7.26666667e-03j 2.53333333e-03+9.86666667e-03j\n",
" 3.63333333e-03+1.28666667e-02j 4.93333333e-03+1.62666667e-02j\n",
" 3.08333333e-03+9.36666667e-03j 1.66666667e-05+1.03333333e-03j\n",
" 1.33333333e-04+3.26666667e-03j 4.33333333e-04+5.06666667e-03j\n",
" 9.33333333e-04+7.26666667e-03j 1.63333333e-03+9.86666667e-03j\n",
" 2.53333333e-03+1.28666667e-02j 3.63333333e-03+1.62666667e-02j\n",
" 2.35000000e-03+9.36666667e-03j 1.66666667e-05+1.76666667e-03j\n",
" 1.33333333e-04+5.06666667e-03j 4.33333333e-04+7.26666667e-03j\n",
" 9.33333333e-04+9.86666667e-03j 1.63333333e-03+1.28666667e-02j\n",
" 2.53333333e-03+1.62666667e-02j 1.71666667e-03+9.36666667e-03j\n",
" 1.66666667e-05+2.70000000e-03j 1.33333333e-04+7.26666667e-03j\n",
" 4.33333333e-04+9.86666667e-03j 9.33333333e-04+1.28666667e-02j\n",
" 1.63333333e-03+1.62666667e-02j 1.18333333e-03+9.36666667e-03j\n",
" 1.66666667e-05+3.83333333e-03j 1.33333333e-04+9.86666667e-03j\n",
" 4.33333333e-04+1.28666667e-02j 9.33333333e-04+1.62666667e-02j\n",
" 7.50000000e-04+9.36666667e-03j 1.66666667e-05+5.16666667e-03j\n",
" 1.33333333e-04+1.28666667e-02j 4.33333333e-04+1.62666667e-02j\n",
" 4.16666667e-04+9.36666667e-03j 1.66666667e-05+6.70000000e-03j\n",
" 1.33333333e-04+1.62666667e-02j 1.83333333e-04+9.36666667e-03j\n",
" 1.66666667e-05+8.43333333e-03j 5.00000000e-05+9.36666667e-03j\n",
" 4.16666667e-06+3.17500000e-03j]\n"
]
}
],
"outputs": [],
"source": [
"J = u_c**2 * ufl.dx\n",
"F = ufl.derivative(J, u_c, ufl.conj(v))\n",
Expand All @@ -256,7 +162,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "eb2357ae-ac71-4407-bf37-432f1b1e31d0",
"metadata": {},
"outputs": [],
Expand All @@ -281,18 +187,10 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "f51d9a7a-2cde-4d0f-8606-91f91c372c4b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(0.0007865435216227239+0.0017660156338113711j) 3.553078358632328e-06\n"
]
}
],
"outputs": [],
"source": [
"x = ufl.SpatialCoordinate(mesh)\n",
"u_ex = 0.5 * x[0]**2 + 1j*x[1]**2\n",
Expand Down Expand Up @@ -322,6 +220,7 @@
"source": [
"import pyvista\n",
"pyvista.start_xvfb()\n",
"mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim)\n",
"p_mesh = pyvista.UnstructuredGrid(*dolfinx.plot.vtk_mesh(mesh, mesh.topology.dim))\n",
"pyvista_cells, cell_types, geometry = dolfinx.plot.vtk_mesh(V)\n",
"grid = pyvista.UnstructuredGrid(pyvista_cells, cell_types, geometry)\n",
Expand Down
1 change: 1 addition & 0 deletions chapter1/complex_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@

import pyvista
pyvista.start_xvfb()
mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim)
p_mesh = pyvista.UnstructuredGrid(*dolfinx.plot.vtk_mesh(mesh, mesh.topology.dim))
pyvista_cells, cell_types, geometry = dolfinx.plot.vtk_mesh(V)
grid = pyvista.UnstructuredGrid(pyvista_cells, cell_types, geometry)
Expand Down
1 change: 1 addition & 0 deletions chapter1/fundamentals_code.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@
"source": [
"from dolfinx import plot\n",
"pyvista.start_xvfb()\n",
"domain.topology.create_connectivity(tdim, tdim)\n",
"topology, cell_types, geometry = plot.vtk_mesh(domain, tdim)\n",
"grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)"
]
Expand Down
1 change: 1 addition & 0 deletions chapter1/fundamentals_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
# + vscode={"languageId": "python"}
from dolfinx import plot
pyvista.start_xvfb()
domain.topology.create_connectivity(tdim, tdim)
topology, cell_types, geometry = plot.vtk_mesh(domain, tdim)
grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)
# -
Expand Down
2 changes: 1 addition & 1 deletion chapter1/membrane_code.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
"metadata": {},
"source": [
"Now we can compute which cells the bounding box tree collides with using `dolfinx.geometry.compute_collisions_points`. This function returns a list of cells whose bounding box collide for each input point. As different points might have different number of cells, the data is stored in `dolfinx.cpp.graph.AdjacencyList_int32`, where one can access the cells for the `i`th point by calling `links(i)`.\n",
"However, as the bounding box of a cell spans more of $\\mathbb{R}^n$ than the actual cell, we check that the actual cell collides with cell\n",
"However, as the bounding box of a cell spans more of $\\mathbb{R}^n$ than the actual cell, we check that the actual cell collides with the input point\n",
"using `dolfinx.geometry.select_colliding_cells`, which measures the exact distance between the point and the cell (approximated as a convex hull for higher order geometries).\n",
"This function also returns an adjacency-list, as the point might align with a facet, edge or vertex that is shared between multiple cells in the mesh.\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion chapter1/membrane_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def on_boundary(x):
bb_tree = geometry.bb_tree(domain, domain.topology.dim)

# Now we can compute which cells the bounding box tree collides with using `dolfinx.geometry.compute_collisions_points`. This function returns a list of cells whose bounding box collide for each input point. As different points might have different number of cells, the data is stored in `dolfinx.cpp.graph.AdjacencyList_int32`, where one can access the cells for the `i`th point by calling `links(i)`.
# However, as the bounding box of a cell spans more of $\mathbb{R}^n$ than the actual cell, we check that the actual cell collides with cell
# However, as the bounding box of a cell spans more of $\mathbb{R}^n$ than the actual cell, we check that the actual cell collides with the input point
# using `dolfinx.geometry.select_colliding_cells`, which measures the exact distance between the point and the cell (approximated as a convex hull for higher order geometries).
# This function also returns an adjacency-list, as the point might align with a facet, edge or vertex that is shared between multiple cells in the mesh.
#
Expand Down
1 change: 0 additions & 1 deletion chapter2/diffusion_code.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"outputs": [],
"source": [
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import pyvista\n",
"import ufl\n",
"import numpy as np\n",
Expand Down
1 change: 0 additions & 1 deletion chapter2/diffusion_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

# +
import matplotlib as mpl
import matplotlib.pyplot as plt
import pyvista
import ufl
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions chapter2/ns_code1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@
"glyphs = function_grid.glyph(orient=\"u\", factor=0.2)\n",
"\n",
"# Create a pyvista-grid for the mesh\n",
"mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim)\n",
"grid = pyvista.UnstructuredGrid(*vtk_mesh(mesh, mesh.topology.dim))\n",
"\n",
"# Create plotter\n",
Expand Down
1 change: 1 addition & 0 deletions chapter2/ns_code1.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def u_exact(x):
glyphs = function_grid.glyph(orient="u", factor=0.2)

# Create a pyvista-grid for the mesh
mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim)
grid = pyvista.UnstructuredGrid(*vtk_mesh(mesh, mesh.topology.dim))

# Create plotter
Expand Down
7 changes: 5 additions & 2 deletions chapter3/em.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1077,8 +1077,10 @@
"source": [
"pyvista.start_xvfb()\n",
"plotter = pyvista.Plotter()\n",
"grid = pyvista.UnstructuredGrid(*vtk_mesh(mesh, mesh.topology.dim))\n",
"num_local_cells = mesh.topology.index_map(mesh.topology.dim).size_local\n",
"tdim = mesh.topology.dim\n",
"mesh.topology.create_connectivity(tdim, tdim)\n",
"grid = pyvista.UnstructuredGrid(*vtk_mesh(mesh, tdim))\n",
"num_local_cells = mesh.topology.index_map(tdim).size_local\n",
"grid.cell_data[\"Marker\"] = ct.values[ct.indices < num_local_cells]\n",
"grid.set_active_scalars(\"Marker\")\n",
"actor = plotter.add_mesh(grid, show_edges=True)\n",
Expand Down Expand Up @@ -1288,6 +1290,7 @@
"# We include ghosts cells as we access all degrees of freedom (including ghosts) on each process\n",
"top_imap = mesh.topology.index_map(mesh.topology.dim)\n",
"num_cells = top_imap.size_local + top_imap.num_ghosts\n",
"mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim)\n",
"midpoints = compute_midpoints(mesh, mesh.topology.dim, np.arange(num_cells, dtype=np.int32))\n",
"\n",
"num_dofs = W.dofmap.index_map.size_local + W.dofmap.index_map.num_ghosts\n",
Expand Down
Loading

0 comments on commit aa4ef09

Please sign in to comment.