Skip to content

Commit 10a4939

Browse files
authored
Fix bounding boxes and more (#135)
* Start fixing code for nightly build * rerun all files * Try fixing subdomains * Fix meshio
1 parent 8bcf5f9 commit 10a4939

Some content is hidden

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

44 files changed

+9742
-6113
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
name: Install dependencies
22

3-
43
runs:
54
using: composite
65
steps:
76
- name: Install apt dependencies and upgrade pip
87
shell: bash -el {0}
98
run: |
109
apt-get update && apt-get install -y libgl1-mesa-glx libxrender1 xvfb
11-
python3 -m pip install -U pip
12-
# Install `h5py` master branch
13-
# https://github.com/hl5py/h5py/issues/2222
14-
- name: Install h5py and pip requirements
15-
shell: bash -el {0}
16-
run: |
17-
python3 -m pip install --no-binary=h5py git+https://github.com/h5py/h5py@master
10+
python3 -m pip install -U pip

chapter1/complex_mode.ipynb

+336-65
Large diffs are not rendered by default.

chapter1/complex_mode.py

+1-1
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.14.4
9+
# jupytext_version: 1.14.6
1010
# kernelspec:
1111
# display_name: Python 3 (DOLFINx complex)
1212
# language: python

chapter1/fundamentals_code.ipynb

+383-74
Large diffs are not rendered by default.

chapter1/fundamentals_code.py

+1-1
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.14.5
9+
# jupytext_version: 1.14.6
1010
# kernelspec:
1111
# display_name: Python 3 (ipykernel)
1212
# language: python

chapter1/membrane_code.ipynb

+364-104
Large diffs are not rendered by default.

chapter1/membrane_code.py

+4-4
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.14.5
9+
# jupytext_version: 1.14.6
1010
# kernelspec:
1111
# display_name: Python 3 (ipykernel)
1212
# language: python
@@ -167,9 +167,9 @@ def on_boundary(x):
167167
# This is efficiently done by creating a bounding box tree of the cells of the mesh, allowing a quick recursive search through the mesh entities.
168168

169169
from dolfinx import geometry
170-
bb_tree = geometry.BoundingBoxTree(domain, domain.topology.dim)
170+
bb_tree = geometry.bb_tree(domain, domain.topology.dim)
171171

172-
# Now we can compute which cells the bounding box tree collides with using `dolfinx.geometry.compute_collisions_point`. 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)`.
172+
# 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)`.
173173
# 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
174174
# using `dolfinx.geometry.select_colliding_cells`, who measures the exact distance between the point and the cell (approximated as a convex hull for higher order geometries).
175175
# 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.
@@ -179,7 +179,7 @@ def on_boundary(x):
179179
cells = []
180180
points_on_proc = []
181181
# Find cells whose bounding-box collide with the the points
182-
cell_candidates = geometry.compute_collisions(bb_tree, points.T)
182+
cell_candidates = geometry.compute_collisions_points(bb_tree, points.T)
183183
# Choose one of the cells that contains the point
184184
colliding_cells = geometry.compute_colliding_cells(domain, cell_candidates, points.T)
185185
for i, point in enumerate(points.T):

chapter1/nitsche.ipynb

+723-7
Large diffs are not rendered by default.

chapter1/nitsche.py

+1-1
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.14.5
9+
# jupytext_version: 1.14.6
1010
# kernelspec:
1111
# display_name: Python 3 (ipykernel)
1212
# language: python

chapter2/diffusion_code.ipynb

+4-18
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,7 @@
134134
"cell_type": "code",
135135
"execution_count": 5,
136136
"metadata": {},
137-
"outputs": [
138-
{
139-
"name": "stderr",
140-
"output_type": "stream",
141-
"text": [
142-
"INFO:root:running build_ext\n",
143-
"INFO:root:building 'libffcx_forms_442e05267a595f45eac6a101af56222e5c3d2bb0' extension\n",
144-
"INFO:root:x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/local/lib/python3.10/dist-packages/ffcx/codegeneration -I/usr/include/python3.10 -c libffcx_forms_442e05267a595f45eac6a101af56222e5c3d2bb0.c -o ./libffcx_forms_442e05267a595f45eac6a101af56222e5c3d2bb0.o -O2\n",
145-
"INFO:root:x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 ./libffcx_forms_442e05267a595f45eac6a101af56222e5c3d2bb0.o -L/usr/lib/x86_64-linux-gnu -o ./libffcx_forms_442e05267a595f45eac6a101af56222e5c3d2bb0.cpython-310-x86_64-linux-gnu.so\n",
146-
"INFO:root:running build_ext\n",
147-
"INFO:root:building 'libffcx_forms_0a9ce6478cf28d3c30ef59bb7181b230b125b637' extension\n",
148-
"INFO:root:x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/local/lib/python3.10/dist-packages/ffcx/codegeneration -I/usr/include/python3.10 -c libffcx_forms_0a9ce6478cf28d3c30ef59bb7181b230b125b637.c -o ./libffcx_forms_0a9ce6478cf28d3c30ef59bb7181b230b125b637.o -O2\n",
149-
"INFO:root:x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 ./libffcx_forms_0a9ce6478cf28d3c30ef59bb7181b230b125b637.o -L/usr/lib/x86_64-linux-gnu -o ./libffcx_forms_0a9ce6478cf28d3c30ef59bb7181b230b125b637.cpython-310-x86_64-linux-gnu.so\n"
150-
]
151-
}
152-
],
137+
"outputs": [],
153138
"source": [
154139
"bilinear_form = fem.form(a)\n",
155140
"linear_form = fem.form(L)"
@@ -209,17 +194,18 @@
209194
},
210195
"outputs": [],
211196
"source": [
197+
"import matplotlib as mpl\n",
212198
"pyvista.start_xvfb()\n",
213199
"\n",
214200
"grid = pyvista.UnstructuredGrid(*plot.create_vtk_mesh(V))\n",
215201
"\n",
216202
"plotter = pyvista.Plotter()\n",
217-
"plotter.open_gif(\"u_time.gif\")\n",
203+
"plotter.open_gif(\"u_time.gif\", fps=10)\n",
218204
"\n",
219205
"grid.point_data[\"uh\"] = uh.x.array\n",
220206
"warped = grid.warp_by_scalar(\"uh\", factor=1)\n",
221207
"\n",
222-
"viridis = plt.cm.get_cmap(\"viridis\", 25)\n",
208+
"viridis = mpl.colormaps.get_cmap(\"viridis\").resampled(25)\n",
223209
"sargs = dict(title_font_size=25, label_font_size=20, fmt=\"%.2e\", color=\"black\",\n",
224210
" position_x=0.1, position_y=0.8, width=0.8, height=0.1)\n",
225211
"\n",

chapter2/diffusion_code.py

+4-3
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.14.5
9+
# jupytext_version: 1.14.6
1010
# kernelspec:
1111
# display_name: Python 3 (ipykernel)
1212
# language: python
@@ -119,17 +119,18 @@ def initial_condition(x, a=5):
119119
# We use the DOLFINx plotting functionality, which is based on pyvista to plot the solution at every $15$th time step. We would also like to visualize a colorbar reflecting the minimal and maximum value of $u$ at each time step. We use the following convenience function `plot_function` for this:
120120

121121
# +
122+
import matplotlib as mpl
122123
pyvista.start_xvfb()
123124

124125
grid = pyvista.UnstructuredGrid(*plot.create_vtk_mesh(V))
125126

126127
plotter = pyvista.Plotter()
127-
plotter.open_gif("u_time.gif")
128+
plotter.open_gif("u_time.gif", fps=10)
128129

129130
grid.point_data["uh"] = uh.x.array
130131
warped = grid.warp_by_scalar("uh", factor=1)
131132

132-
viridis = plt.cm.get_cmap("viridis", 25)
133+
viridis = mpl.colormaps.get_cmap("viridis").resampled(25)
133134
sargs = dict(title_font_size=25, label_font_size=20, fmt="%.2e", color="black",
134135
position_x=0.1, position_y=0.8, width=0.8, height=0.1)
135136

chapter2/heat_code.ipynb

+11-40
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
},
6868
{
6969
"cell_type": "code",
70-
"execution_count": null,
70+
"execution_count": 3,
7171
"metadata": {},
7272
"outputs": [],
7373
"source": [
@@ -83,7 +83,7 @@
8383
},
8484
{
8585
"cell_type": "code",
86-
"execution_count": 3,
86+
"execution_count": 4,
8787
"metadata": {},
8888
"outputs": [],
8989
"source": [
@@ -100,7 +100,7 @@
100100
},
101101
{
102102
"cell_type": "code",
103-
"execution_count": 4,
103+
"execution_count": 5,
104104
"metadata": {},
105105
"outputs": [],
106106
"source": [
@@ -123,7 +123,7 @@
123123
},
124124
{
125125
"cell_type": "code",
126-
"execution_count": 5,
126+
"execution_count": 6,
127127
"metadata": {},
128128
"outputs": [],
129129
"source": [
@@ -140,7 +140,7 @@
140140
},
141141
{
142142
"cell_type": "code",
143-
"execution_count": 6,
143+
"execution_count": 7,
144144
"metadata": {},
145145
"outputs": [],
146146
"source": [
@@ -156,24 +156,9 @@
156156
},
157157
{
158158
"cell_type": "code",
159-
"execution_count": 7,
159+
"execution_count": 8,
160160
"metadata": {},
161-
"outputs": [
162-
{
163-
"name": "stderr",
164-
"output_type": "stream",
165-
"text": [
166-
"INFO:root:running build_ext\n",
167-
"INFO:root:building 'libffcx_forms_e4be8749efa93928c798aea52468f3b42a95eb01' extension\n",
168-
"INFO:root:x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/local/lib/python3.10/dist-packages/ffcx/codegeneration -I/usr/include/python3.10 -c libffcx_forms_e4be8749efa93928c798aea52468f3b42a95eb01.c -o ./libffcx_forms_e4be8749efa93928c798aea52468f3b42a95eb01.o -O2\n",
169-
"INFO:root:x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 ./libffcx_forms_e4be8749efa93928c798aea52468f3b42a95eb01.o -L/usr/lib/x86_64-linux-gnu -o ./libffcx_forms_e4be8749efa93928c798aea52468f3b42a95eb01.cpython-310-x86_64-linux-gnu.so\n",
170-
"INFO:root:running build_ext\n",
171-
"INFO:root:building 'libffcx_forms_e20a45eb24fbe63a298451107733355af33d9552' extension\n",
172-
"INFO:root:x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/local/lib/python3.10/dist-packages/ffcx/codegeneration -I/usr/include/python3.10 -c libffcx_forms_e20a45eb24fbe63a298451107733355af33d9552.c -o ./libffcx_forms_e20a45eb24fbe63a298451107733355af33d9552.o -O2\n",
173-
"INFO:root:x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 ./libffcx_forms_e20a45eb24fbe63a298451107733355af33d9552.o -L/usr/lib/x86_64-linux-gnu -o ./libffcx_forms_e20a45eb24fbe63a298451107733355af33d9552.cpython-310-x86_64-linux-gnu.so\n"
174-
]
175-
}
176-
],
161+
"outputs": [],
177162
"source": [
178163
"u, v = ufl.TrialFunction(V), ufl.TestFunction(V)\n",
179164
"F = u * v * ufl.dx + dt * ufl.dot(ufl.grad(u), ufl.grad(v)) * ufl.dx - (u_n + dt * f) * v * ufl.dx\n",
@@ -191,7 +176,7 @@
191176
},
192177
{
193178
"cell_type": "code",
194-
"execution_count": 8,
179+
"execution_count": 9,
195180
"metadata": {},
196181
"outputs": [],
197182
"source": [
@@ -211,7 +196,7 @@
211196
},
212197
{
213198
"cell_type": "code",
214-
"execution_count": 9,
199+
"execution_count": 10,
215200
"metadata": {},
216201
"outputs": [],
217202
"source": [
@@ -236,7 +221,7 @@
236221
},
237222
{
238223
"cell_type": "code",
239-
"execution_count": 10,
224+
"execution_count": 11,
240225
"metadata": {},
241226
"outputs": [],
242227
"source": [
@@ -274,23 +259,9 @@
274259
},
275260
{
276261
"cell_type": "code",
277-
"execution_count": 11,
262+
"execution_count": 12,
278263
"metadata": {},
279264
"outputs": [
280-
{
281-
"name": "stderr",
282-
"output_type": "stream",
283-
"text": [
284-
"INFO:root:running build_ext\n",
285-
"INFO:root:building 'libffcx_elements_14e968db0d9fb7ed99f6b064170a5d08db11aac3' extension\n",
286-
"INFO:root:x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/local/lib/python3.10/dist-packages/ffcx/codegeneration -I/usr/include/python3.10 -c libffcx_elements_14e968db0d9fb7ed99f6b064170a5d08db11aac3.c -o ./libffcx_elements_14e968db0d9fb7ed99f6b064170a5d08db11aac3.o -O2\n",
287-
"INFO:root:x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 ./libffcx_elements_14e968db0d9fb7ed99f6b064170a5d08db11aac3.o -L/usr/lib/x86_64-linux-gnu -o ./libffcx_elements_14e968db0d9fb7ed99f6b064170a5d08db11aac3.cpython-310-x86_64-linux-gnu.so\n",
288-
"INFO:root:running build_ext\n",
289-
"INFO:root:building 'libffcx_forms_16bdd7596bdd2c0773a4e5e6bba97135bc4ce016' extension\n",
290-
"INFO:root:x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/local/lib/python3.10/dist-packages/ffcx/codegeneration -I/usr/include/python3.10 -c libffcx_forms_16bdd7596bdd2c0773a4e5e6bba97135bc4ce016.c -o ./libffcx_forms_16bdd7596bdd2c0773a4e5e6bba97135bc4ce016.o -O2\n",
291-
"INFO:root:x86_64-linux-gnu-gcc -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 ./libffcx_forms_16bdd7596bdd2c0773a4e5e6bba97135bc4ce016.o -L/usr/lib/x86_64-linux-gnu -o ./libffcx_forms_16bdd7596bdd2c0773a4e5e6bba97135bc4ce016.cpython-310-x86_64-linux-gnu.so\n"
292-
]
293-
},
294265
{
295266
"name": "stdout",
296267
"output_type": "stream",

chapter2/heat_code.py

+1-1
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.14.5
9+
# jupytext_version: 1.14.6
1010
# kernelspec:
1111
# display_name: Python 3 (ipykernel)
1212
# language: python

0 commit comments

Comments
 (0)