Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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.

@tkoyama010 tkoyama010 added the enhancement New feature or request label Mar 6, 2025
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.

LGTM

@tkoyama010
Copy link
Member

@all-contributors please add @keurfonluu for ideas

Copy link
Contributor

@tkoyama010

I've put up a pull request to add @keurfonluu! 🎉

@tkoyama010 tkoyama010 enabled auto-merge (squash) March 10, 2025 21:40
@tkoyama010 tkoyama010 merged commit 7d41a90 into pyvista:main Mar 10, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants