Skip to content

Commit

Permalink
Ensure 3d-data in Boundary.plot() for PyVista
Browse files Browse the repository at this point in the history
  • Loading branch information
adtzlr committed Dec 1, 2024
1 parent 849e7dc commit 5e627cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 3 additions & 4 deletions docs/tutorial/examples/extut03_building_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,13 @@ def W(C, mu, bulk):
f0 = lambda x: np.isclose(x, 0)
f1 = lambda x: np.isclose(x, 1)

boundaries = {}
boundaries = fem.BoundaryDict()

boundaries["left"] = fem.Boundary(displacement, fx=f0)
boundaries["right"] = fem.Boundary(displacement, fx=f1, skip=(1, 0, 0))
boundaries["move"] = fem.Boundary(displacement, fx=f1, skip=(0, 1, 1), value=0.5)

plotter = boundaries["left"].plot(color="green")
plotter = boundaries["right"].plot(plotter=plotter, color="red")
boundaries["move"].plot(plotter=plotter, color="blue", point_size=5).show()
boundaries.plot().show()

# %%
# Partition of deegrees of freedom
Expand Down
11 changes: 6 additions & 5 deletions src/felupe/dof/_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,21 +293,22 @@ def plot(
if label is None:
label = self.name

points = np.pad(mesh.points, ((0, 0), (0, 3 - mesh.dim)))
magnitude = min(mesh.points.max(axis=0) - mesh.points.min(axis=0)) * scale

_ = plotter.add_points(
mesh.points[self.points],
points[self.points],
color=color,
point_size=point_size,
label=label,
)

for skip, direction in zip(self.skip, np.eye(mesh.dim)):
for skip, direction in zip(self.skip, np.eye(3)):
if not skip:
end = mesh.points[self.points] + direction * magnitude
end = points[self.points] + direction * magnitude
_ = plotter.add_lines(
np.hstack([mesh.points[self.points], end]).reshape(
-1, mesh.dim
np.hstack([points[self.points], end]).reshape(
-1, 3
),
color=color,
width=width,
Expand Down

0 comments on commit 5e627cc

Please sign in to comment.