Gmshio read_from_mesh failed for 2D mesh

Hello, I am trying to use gmshio.read_from_mesh to input a 2D model from a .msh file (attachment) :

from dolfinx import *
from dolfinx import default_scalar_type
from dolfinx.fem.petsc import LinearProblem
from dolfinx.io import gmshio
from dolfinx.mesh import meshtags
from mpi4py import MPI
import gmsh
import ufl
import numpy as np
import ufl.measure
import genmodel
import dolfinx_mpc as mpc
import dolfinx_mpc.utils
from dolfinx_mpc import LinearProblem, MultiPointConstraint

comm = MPI.COMM_WORLD

rank = comm.Get_rank()
m = gmshio.read_from_msh('1111.msh', comm=comm, gdim=2)

But I encounter an error says:

Traceback (most recent call last):
  File "/home/zh9702/disk780/projectData/fenics/./energy_test_2D.py", line 75, in <module>
    m = gmshio.read_from_msh(mfile, comm=comm, gdim=2)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zh9702/miniconda3/envs/fenics-env/lib/python3.12/site-packages/dolfinx/io/gmshio.py", line 332, in read_from_msh
    msh = model_to_mesh(gmsh.model, comm, rank, gdim=gdim, partitioner=partitioner)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zh9702/miniconda3/envs/fenics-env/lib/python3.12/site-packages/dolfinx/io/gmshio.py", line 215, in model_to_mesh
    x = extract_geometry(model)
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zh9702/miniconda3/envs/fenics-env/lib/python3.12/site-packages/dolfinx/io/gmshio.py", line 176, in extract_geometry
    assert np.all(indices[perm_sort] == np.arange(len(indices)))
AssertionError

What’s the reason for this error? Is there any way fixing this?
1111.msh

Instead of providing the msh, do you have the geo file or Python script that generated the msh? It is easier to inspect

No, this model is generated from a stl file via the conversion by meshio tool. And the stl mesh is obtained by meshing a surface in Rhino. Here is the original Brep file https://file.io/eWJpjIeB4D5e

You seem to have removed the msh file and you haven’t provided the conversion script you use with meshio, so it is very hard to give any guidance.

Sorry dokken, my mistake. It turns out that the msh file I used was actually exported from gmsh GUI app, by importing a stl file and then exporting a msh file. In this case, the error arises might due to the redundant node data entries, which makes gmshio extract wrong node index.

So I just tried the meshio conversion by

meshio convert -o gmsh -a ./1111.stl 1111.msh

In this generated msh file, additional node data entries were removed but there is no physical group defined in it.
Therefore, gmshio still cannot extract the 2d meshes (This reason is just my guess).
To fix this, I tried

gmsh.initialize()
gmsh.merge('1111.msh')
# Remove all physical groups first
gmsh.model.removePhysicalGroups(gmsh.model.getPhysicalGroups())
# Then add 2d entity to group
element_types, element_tags, node_tags = gmsh.model.mesh.getElements(2)
ent = gmsh.model.getEntities(2)[0]
gmsh.model.addPhysicalGroup(2, [ent[1]], name = 'surf')
m = gmshio.model_to_mesh(gmsh.model, MPI.COMM_WORLD, 0, gdim = 2)

Now everything is fine.