[Python] Gmsh: “Wrong topology of boundary mesh for parametrization” or endless “Partitioning...

Discussão em 'Python' iniciado por Stack, Agosto 14, 2025.

  1. Stack

    Stack Membro Participativo

    I’m trying to turn a 3D STL surface (exported from ImageJ/Fiji segmentation) into a volume mesh in Gmsh using the typical workflow given by the official tutorial (t13). I’m running this with the Gmsh Python API:

    n_file = "Birch_745_746-1_Extract3.stl"

    gmsh.initialize()
    gmsh.clear()
    gmsh.model.add(n_file[:-4])
    gmsh.merge(n_file)

    angle = 40
    forceParametrizablePatches = True
    includeBoundary = True
    curveAngle = 180
    gmsh.model.mesh.classifySurfaces(
    angle * math.pi / 180.,
    includeBoundary,
    forceParametrizablePatches,
    curveAngle * math.pi / 180.
    )


    gmsh.model.mesh.createGeometry()

    s = gmsh.model.getEntities(2)
    l = gmsh.model.geo.addSurfaceLoop([e[1] for e in s])
    gmsh.model.geo.addVolume([l])

    gmsh.model.geo.synchronize()

    gmsh.model.mesh.generate(3)

    gmsh.write(f'{n_file[:-4]}.msh')

    gmsh.finalize()


    with forceParametrizablePatches = True, the method createGeometry raised the error:

    Info : [ 10%] Discrete surface 28 is planar, simplifying parametrization
    Error : Wrong topology of boundary mesh for parametrization
    Exception: Wrong topology of boundary mesh for parametrization


    with forceParametrizablePatches = False: tens of thousands of warnings like:

    Warning : Partitioning face 1 with 2 triangles that all have the same partition - changing tolerance to 30.55
    ...
    Warning : Tolerance too large - aborting partitioning
    Info : Level ... Poincaré characteristic ... not 0


    and it never seems to finish.

    My STL file comes from the Image/FidJ plugin BoneJ and is a small part of tomography.

    You can find the file in the GitHub repository: https://github.com/npistenon/Wood-tomogram.git

    What I tried:

    • Cleaned STL with various plugin in ImageJ/FidJ and MeshLab
    • Cleaning with trimesh package in Python
    • Several values for angles But without any improvement.
    • Tried gmsh.model.mesh.createTopology() instead of gmsh.model.mesh.createGeometry() and I have got the error:

    gmsh.model.mesh.generate(3)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^
    File "\gmsh.py", line 2060, in generate
    raise Exception(logger.getLastError())
    Exception: Invalid boundary mesh (overlapping facets) on surface 1 surface 1


    Question What exactly causes these “Wrong topology” / “changing tolerance” loops when creating geometry from a surface mesh? How can I get the 3D mesh from my STL file for use in finite element simulation?

    Continue reading...

Compartilhe esta Página