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 option constrain_edge_size for Delaunay2D #452

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

keurfonluu
Copy link
Contributor

@keurfonluu keurfonluu commented Feb 28, 2025

Overview

This PR adds an option that calculates cell size based on edge lengths.

Default behavior:

import pyvista as pv
import skgmsh as sg

edge_source = pv.Polygon(n_sides=16, radius=16)
mesh = sg.Delaunay2D(shell=edge_source.points).mesh

p = pv.Plotter()
p.add_mesh(mesh, show_edges=True)
p.add_mesh(pv.PolyData(edge_source.points), render_points_as_spheres=True, color="red", point_size=10)
p.view_xy()
p.show()

default

With option constrain_edge_size=True:

mesh = sg.Delaunay2D(shell=edge_source.points, constrain_edge_size=True).mesh

with_constraint

Works with holes too!

hole1 = pv.Polygon(n_sides=6, radius=4).translate([-4.0, -4.0, 0.0])
hole2 = pv.Polygon(n_sides=8, radius=2).translate([4.0, 4.0, 0.0])
mesh = sg.Delaunay2D(shell=edge_source.points, holes=[hole1.points, hole2.points], constrain_edge_size=True).mesh

with_holes_and_constraint

Which looks much better than if we simply forced Frontal Delaunay in the source code:

gmsh.option.set_number("Mesh.Algorithm", FRONTAL_DELAUNAY_2D)

frontal

@tkoyama010 tkoyama010 self-requested a review March 3, 2025 21:41
@tkoyama010 tkoyama010 enabled auto-merge (squash) March 3, 2025 21:54
@tkoyama010 tkoyama010 disabled auto-merge March 3, 2025 21:59
Copy link
Member

@tkoyama010 tkoyama010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m thinking of adding the wonderful examples you provided to the examples directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants