Skip to content

Commit

Permalink
Fix parameter name from mesh_size to target_size (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkoyama010 authored Dec 24, 2023
1 parent 0629f2c commit d7c7dea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ We can then generate a 2D mesh.

.. code-block:: python
>>> mesh = pvgmsh.frontal_delaunay_2d(geometry, mesh_size=1.0)
>>> mesh = pvgmsh.frontal_delaunay_2d(geometry, target_size=1.0)
To visualize the model we can use PyVista.

Expand Down
26 changes: 20 additions & 6 deletions src/pvgmsh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import pyvista as pv
import tempfile
from pvgmsh._version import __version__ # noqa: F401
import numpy as np


def frontal_delaunay_2d(edge_source, mesh_size=1e-2):
def frontal_delaunay_2d(edge_source, target_size=None):
"""The Frontal-Delaunay 2D mesh algorithm.
Parameters
Expand All @@ -20,9 +21,9 @@ def frontal_delaunay_2d(edge_source, mesh_size=1e-2):
source).
mesh_size : float, optional
Target mesh mesh_size close to the point.
Defalut 1e-2.
target_size : float, optional
Target mesh size close to the points.
Defalut max size of edge_source in each direction.
Returns
-------
Expand Down Expand Up @@ -57,7 +58,7 @@ def frontal_delaunay_2d(edge_source, mesh_size=1e-2):
>>> geometry.lines
array([5, 0, 1, 2, 3, 0])
>>> mesh = pvgmsh.frontal_delaunay_2d(geometry, mesh_size=1.0)
>>> mesh = pvgmsh.frontal_delaunay_2d(geometry, target_size=1.0)
<BLANKLINE>
>>> mesh
Expand All @@ -81,7 +82,20 @@ def frontal_delaunay_2d(edge_source, mesh_size=1e-2):
gmsh.option.set_number("Mesh.Algorithm", 6)

for i, point in enumerate(edge_source.points):
gmsh.model.geo.add_point(point[0], point[1], point[2], mesh_size, i + 1)
if target_size is None:
gmsh.model.geo.add_point(
point[0],
point[1],
point[2],
np.max(
np.abs(geometry.bounds[1] - geometry.bounds[0]),
np.abs(geometry.bounds[3] - geometry.bounds[2]),
np.abs(geometry.bounds[5] - geometry.bounds[4]),
),
i + 1,
)
else:
gmsh.model.geo.add_point(point[0], point[1], point[2], target_size, i + 1)

lines = edge_source.lines
for i in range(lines[0] - 1):
Expand Down

0 comments on commit d7c7dea

Please sign in to comment.