Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add capsule as an example of a simple geometry #313

Merged
merged 14 commits into from
Sep 10, 2024
31 changes: 31 additions & 0 deletions examples/capsule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
r"""
Capsule geometry example
-------------------------

Capsule geometry example.

"""

# sphinx_gallery_thumbnail_number = 3 # noqa:ERA001

from __future__ import annotations

import pyvista as pv

import skgmsh as sg

edge_source = pv.Capsule(resolution=10)
edge_source.merge(pv.PolyData(edge_source.points), merge_points=True, inplace=True)
edge_source.plot(show_edges=True, color="white")

# %%
# Create a 3D mesh from the edge source.

alg = sg.Delaunay3D(edge_source)
alg.mesh.shrink(0.9).plot(show_edges=True, color="white")

# %%
# Change the cell size of the mesh.

alg.cell_size = 0.25
alg.mesh.plot(show_edges=True, color="white")