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
Lines changed: 1 addition & 8 deletions
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

Lines changed: 336 additions & 65 deletions
Large diffs are not rendered by default.

chapter1/complex_mode.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 383 additions & 74 deletions
Large diffs are not rendered by default.

chapter1/fundamentals_code.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 364 additions & 104 deletions
Large diffs are not rendered by default.

chapter1/membrane_code.py

Lines changed: 4 additions & 4 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.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

Lines changed: 723 additions & 7 deletions
Large diffs are not rendered by default.

chapter1/nitsche.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 18 deletions
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",

0 commit comments

Comments
 (0)