Skip to content

Circular mesh includes center as a point, but is not necessarily used as a vertex in the triangulation. #562

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

Open
jorgenriseth opened this issue Nov 25, 2022 · 2 comments

Comments

@jorgenriseth
Copy link

jorgenriseth commented Nov 25, 2022

Python 3.11.0 pacakged by conda-forge
pygmsh 7.1.17 (pypi_0 pypi)

import pygmsh
import gmsh

with pygmsh.geo.Geometry() as geom:
    geom.add_circle([0.0, 0.0], 1.0, mesh_size=0.1)
    gmsh.option.setNumber("Mesh.SaveAll", 0)
    mesh = geom.generate_mesh()

print("Mesh point list includes origin:")
print(mesh.points[:3])
print()
print("Num triangles including the origin:", (mesh.cells[1].data == 0).sum()) # Should be higher than 0

Expected behaviour: All points in a mesh should be used in at least 1 cell.
Actual behaviour: Origin is included in mesh independently of whether it is included in any cells.

@ribesstefano
Copy link

ribesstefano commented Dec 20, 2022

I'm also experiencing the same issue (origin included when it shoudn't) with the following code:

import pygmsh

with pygmsh.geo.Geometry() as geom:
    p0 = geom.add_point([0.0, 0.0], lcar)
    p1 = geom.add_point([1.0, 0.0], lcar)
    p2 = geom.add_point([2.0, 0.0], lcar)
    p3 = geom.add_point([2.0, 5.0], lcar)
    p4 = geom.add_point([0.0, 5.0], lcar)
    p5 = geom.add_point([0.0, 1.0], lcar)
    
    l0 = geom.add_line(p1, p2) 
    l1 = geom.add_line(p2, p3)
    l2 = geom.add_line(p3, p4)
    l3 = geom.add_line(p4, p5)
    
    ca1 = geom.add_circle_arc(p5, p0, p1)

    loop = geom.add_curve_loop([l0, l1, l2, l3, ca1])
    surface = geom.add_plane_surface(loop)
    geom.add_physical(l0, 'bottom')
    geom.add_physical(l2, 'top')
    geom.add_physical(l3, 'left')
    geom.add_physical(l1, 'right')
    geom.add_physical(ca1, 'hole')

    mesh = geom.generate_mesh(dim=2)

nodes = mesh.points[:, :2]
cells = mesh.cells_dict['triangle']

For now, I implemented a workaround, but it's not ideal:

nodes_to_remove = [np.array([0.0, 0.0])] # Containing the origin
unconnected_nodes = []
for i, node in enumerate(nodes):
    if node in nodes_to_remove:
        unconnected_nodes.append(i)
for i in unconnected_nodes:
    nodes = np.delete(nodes, i, axis=0) # Remove the node ID/index/pointer
    cells[cells >= i] -= 1 # Make subsequent nodes pointing to the previous node ID/index/pointer

@duhd1993
Copy link

duhd1993 commented Sep 4, 2023

This should be asked to Gmsh community. I'm having a different but related problem. I do not want the center point as it's a hole.

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

No branches or pull requests

3 participants