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

Fix name of parameter poly_data to edge_source #8

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions pvgmsh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
from pvgmsh._version import __version__ # noqa: F401


def delaunay_2d(poly_data, size=1e-2):
def delaunay_2d(edge_source, size=1e-2):
"""
Parameters
----------
poly_data : pv.PolyData
Poly data to generate delaunay 2d mesh.
edge_source : pyvista.PolyData
Specify the source object used to specify constrained
edges and loops. If set, and lines/polygons are defined, a
constrained triangulation is created. The lines/polygons
are assumed to reference points in the input point set
(i.e. point ids are identical in the input and
source).


size : float, optional
Target mesh size close to the point.
Expand All @@ -33,8 +39,8 @@ def delaunay_2d(poly_data, size=1e-2):

>>> vertices = np.array([[0, 0, 0], [0.1, 0, 0], [0.1, 0.3, 0], [0, 0.3, 0]])
>>> faces = np.hstack([[4, 0, 1, 2, 3]])
>>> poly_data = pv.PolyData(vertices, faces)
>>> poly_data
>>> edge_source = pv.PolyData(vertices, faces)
>>> edge_source
PolyData (...)
N Cells: 1
N Points: 4
Expand All @@ -46,7 +52,7 @@ def delaunay_2d(poly_data, size=1e-2):

Generate mesh using gmsh.

>>> mesh = pvgmsh.delaunay_2d(poly_data)
>>> mesh = pvgmsh.delaunay_2d(edge_source)
<BLANKLINE>
>>> mesh
UnstructuredGrid (...)
Expand All @@ -58,7 +64,7 @@ def delaunay_2d(poly_data, size=1e-2):
N Arrays: 2
"""
meshes = []
for cell in poly_data.cell:
for cell in edge_source.cell:
if cell.type == pv.CellType.QUAD:
gmsh.initialize()
for i, point in enumerate(cell.points):
Expand All @@ -76,7 +82,7 @@ def delaunay_2d(poly_data, size=1e-2):
) as fp:
gmsh.write(fp.name)
mesh = pv.read(fp.name)
if poly_data.number_of_cells == 1:
if edge_source.number_of_cells == 1:
gmsh.clear()
gmsh.finalize()
return mesh
Expand Down