Skip to content

Commit 2a4ba7c

Browse files
authored
Merge pull request #168 from scientificcomputing/dokken/clarify_demo
Remove xvfb. Clarify try-except clause in demo on real spaces
2 parents d1e412b + 96c4d3e commit 2a4ba7c

8 files changed

Lines changed: 14 additions & 29 deletions

File tree

.github/workflows/build_docs.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,16 @@ env:
1111
DISPLAY: ":99.0"
1212

1313
jobs:
14-
1514
build:
1615
name: Test on ${{ matrix.label }}
1716
runs-on: ubuntu-24.04
1817
container: ghcr.io/fenics/dolfinx/dolfinx:${{ matrix.label }}
1918
strategy:
2019
fail-fast: false
2120
matrix:
22-
label: [
23-
"stable",
24-
"nightly"
25-
]
21+
label: ["stable", "nightly"]
2622
env:
2723
PUBLISH_DIR: ./_build/html
28-
DISPLAY: ":99.0"
29-
PYVISTA_TRAME_SERVER_PROXY_PREFIX: "/proxy/"
30-
PYVISTA_TRAME_SERVER_PROXY_ENABLED: "True"
3124
PYVISTA_OFF_SCREEN: false
3225
PYVISTA_JUPYTER_BACKEND: "html"
3326

@@ -36,7 +29,7 @@ jobs:
3629
uses: actions/checkout@v6
3730

3831
- name: Install dependencies for pyvista
39-
run: apt-get update && apt-get install -y libgl1-mesa-dev xvfb
32+
run: apt-get update && apt-get install -y libgl1-mesa-dev mesa-utils
4033

4134
- name: Install dependencies
4235
run: |

examples/blocked_solver.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ def post_solve(solver: scifem.NewtonSolver):
174174
# Finally, we can visualize the solution using `pyvista`
175175

176176
import pyvista
177-
pyvista.start_xvfb()
178177
p = pyvista.Plotter()
179178
topology, cell_types, geometry = dolfinx.plot.vtk_mesh(V)
180179
grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)

examples/mark_entities.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def inner(x):
4444

4545
import pyvista
4646

47-
pyvista.start_xvfb()
4847
vtk_grid = dolfinx.plot.vtk_mesh(mesh, cell_tag.dim, cell_tag.indices)
4948
grid = pyvista.UnstructuredGrid(*vtk_grid)
5049
grid.cell_data["Marker"] = cell_tag.values

examples/point_source.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@
122122

123123
import pyvista
124124

125-
pyvista.start_xvfb()
126125
topology, cell_types, geometry = dolfinx.plot.vtk_mesh(V)
127126
values = np.zeros((geometry.shape[0], 3), dtype=np.float64)
128127
values[:, :len(uh)] = uh.x.array.real.reshape((geometry.shape[0], len(uh)))

examples/real_function_space.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def u_exact(x):
133133
# and {py:func}`ufl.TestFunctions` as one would do with a {py:func}`basix.ufl.mixed_element`.
134134
# ```
135135

136-
if dolfinx.__version__ == "0.8.0":
136+
if Version(dolfinx.__version__) == Version("0.8.0"):
137137
u = ufl.TrialFunction(V)
138138
lmbda = ufl.TrialFunction(R)
139139
du = ufl.TestFunction(V)
@@ -169,24 +169,24 @@ def u_exact(x):
169169
# We can now assemble the matrix and vector usig {py:func}`dolfinx.fem.petsc.assemble_matrix`
170170
# and {py:func}`dolfinx.fem.petsc.assemble_vector`.
171171

172-
try:
172+
if Version(dolfinx.__version__) < Version("0.10.0"):
173173
A = dolfinx.fem.petsc.assemble_matrix_block(a_compiled)
174-
except AttributeError:
174+
else:
175175
A = dolfinx.fem.petsc.assemble_matrix(a_compiled)
176176
A.assemble()
177177

178178

179-
# On the main branch of DOLFINx, the `assemble_vector` function for blocked spaces has been rewritten to reflect how
179+
# In DOLFINx>=v0.10.0, the `assemble_vector` function for blocked spaces has been rewritten to reflect how
180180
# it works for standard assembly and `nest` assembly. This means that lifting is applied manually.
181181
# In this case, with no Dirichlet BC, we could skip those steps.
182182
# However, for clarity we include them here.
183183

184184
bcs = []
185-
main_assembly = False
186-
try:
185+
186+
187+
if Version(dolfinx.__version__) < Version("0.10.0"):
187188
b = dolfinx.fem.petsc.assemble_vector_block(L_compiled, a_compiled, bcs=bcs)
188-
except AttributeError:
189-
main_assembly = True
189+
else:
190190
b = dolfinx.fem.petsc.assemble_vector(L_compiled, kind="mpi")
191191
apply_lifting_and_set_bc(b, a_compiled, bcs=bcs)
192192

@@ -197,7 +197,7 @@ def u_exact(x):
197197
# +
198198
uh = dolfinx.fem.Function(V, name="u")
199199

200-
if main_assembly:
200+
if Version(dolfinx.__version__) >= Version("0.10.0"):
201201
# We start by inserting the value in the real space
202202
rh = dolfinx.fem.Function(R)
203203
rh.x.array[0] = h
@@ -239,7 +239,7 @@ def u_exact(x):
239239
pc.setType("lu")
240240
pc.setFactorSolverType("mumps")
241241

242-
if main_assembly:
242+
if Version(dolfinx.__version__) >= Version("0.10.0"):
243243
xh = b.duplicate()
244244
else:
245245
xh = dolfinx.fem.petsc.create_vector_block(L_compiled)
@@ -251,7 +251,7 @@ def u_exact(x):
251251
# Finally, we extract the solution u from the blocked system and compute the error
252252

253253
uh = dolfinx.fem.Function(V, name="u")
254-
if main_assembly:
254+
if Version(dolfinx.__version__) >= Version("0.10.0"):
255255
dolfinx.fem.petsc.assign(xh, [uh, rh])
256256
else:
257257
x_local = get_local_vectors(xh, maps)
@@ -280,7 +280,6 @@ def u_exact(x):
280280
# +
281281
vtk_mesh = dolfinx.plot.vtk_mesh(V)
282282

283-
pyvista.start_xvfb(1.0)
284283
grid = pyvista.UnstructuredGrid(*vtk_mesh)
285284
grid.point_data["u"] = uh.x.array.real
286285

examples/transfer_tags_to_submesh.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@
7373

7474
# + tags=["hide-input"]
7575

76-
if sys.platform == "linux" and (os.getenv("CI") or pyvista.OFF_SCREEN):
77-
pyvista.start_xvfb(0.05)
78-
7976

8077
def plot_mesh(mesh: dolfinx.mesh.Mesh, values=None):
8178
"""

examples/xdmf_point_cloud.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242
import pyvista
4343

44-
pyvista.start_xvfb()
4544
plotter = pyvista.Plotter()
4645
plotter.add_points(
4746
V.tabulate_dof_coordinates(),

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ adios2 = ["adios2"]
3030
docs = [
3131
"jupyter-book<2.0",
3232
"jupytext",
33-
"pyvista[jupyter]",
33+
"pyvista[all]>=0.45.0",
3434
"sphinxcontrib-bibtex",
3535
"sphinx-codeautolink",
3636
]

0 commit comments

Comments
 (0)