Skip to content

Commit 22645a7

Browse files
authored
fix entities to geometry bug (#10)
Co-authored-by: nate-sime <>
1 parent db210ed commit 22645a7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

febug/plot.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ def plot_mesh(mesh: dolfinx.mesh.Mesh, tdim: int=None,
7575
grid = _to_pyvista_grid(mesh, tdim, entities=grp)
7676
plotter.add_mesh(grid, style="wireframe", line_width=2, color=color)
7777
else:
78-
point_cloud = pyvista.PolyData(mesh.geometry.x[grp])
78+
e2g = dolfinx.mesh.entities_to_geometry(mesh, 0, grp)
79+
assert e2g.shape[1] == 1
80+
e2g = e2g.ravel()
81+
point_cloud = pyvista.PolyData(mesh.geometry.x[e2g])
7982
plotter.add_mesh(point_cloud, point_size=8, color=color)
8083

8184
if len(ghost_entities) > 0 and show_owners:
@@ -152,7 +155,11 @@ def plot_meshtags(meshtags: dolfinx.mesh.MeshTags,
152155
entities.cell_data[meshtags.name] = meshtags.values
153156
entities.set_active_scalars(meshtags.name)
154157
else:
155-
x = mesh.geometry.x[meshtags.indices]
158+
e2g = dolfinx.mesh.entities_to_geometry(mesh, 0, meshtags.indices)
159+
# e2g dim 0 always shape (n, 1) so ravel
160+
assert e2g.shape[1] == 1
161+
e2g = e2g.ravel()
162+
x = mesh.geometry.x[e2g]
156163
entities = pyvista.PolyData(x)
157164
entities[meshtags.name] = meshtags.values
158165

0 commit comments

Comments
 (0)