Cannot find facet_tag from gmsh

I make a gmsh model with a facet_tag. But when I read the model and want to find that tag, it is empty. I compared it with the example provided here and the only apparent difference is using occ instead of geo (so far). I appreciate any suggestions. Here is my code:

from mpi4py import MPI
from dolfinx import 
import gmsh
from dolfinx.io import gmshio

gmsh.initialize()
gmsh.model.add("Box")

# create the unit box
lc = 1e-2
gmsh.model.geo.addPoint(0, 0, 0, lc, 1)
gmsh.model.geo.addPoint(1, 0, 0, lc, 2)
gmsh.model.geo.addPoint(1, 1, 0, lc, 3)
gmsh.model.geo.addPoint(0, 1, 0, lc, 4)
gmsh.model.geo.addLine(1, 2, 1)
gmsh.model.geo.addLine(3, 2, 2)
gmsh.model.geo.addLine(3, 4, 3)
gmsh.model.geo.addLine(4, 1, 4)
gmsh.model.geo.addCurveLoop([4, 1, -2, 3], 1)
gmsh.model.geo.addPlaneSurface([1], 1)

# set the marker for two of edges
wall_marker0 = 1
gmsh.model.addPhysicalGroup(1, [1, 3], wall_marker0)

gmsh.model.geo.synchronize()
gmsh.model.mesh.generate(2)

domain, cell_tag, facet_tags = gmshio.model_to_mesh(gmsh.model, MPI.COMM_WORLD, 0, gdim=2)
print(facet_tags.find(1))

Hello

I find that adding a cell tag seems to solve the problem, refer to the following code:

from mpi4py import MPI
import gmsh
from dolfinx.io import gmshio

gmsh.initialize()
gmsh.model.add("Box")

# create the unit box
lc = 1e-2
gmsh.model.geo.addPoint(0, 0, 0, lc, 1)
gmsh.model.geo.addPoint(1, 0, 0, lc, 2)
gmsh.model.geo.addPoint(1, 1, 0, lc, 3)
gmsh.model.geo.addPoint(0, 1, 0, lc, 4)
gmsh.model.geo.addLine(1, 2, 1)
gmsh.model.geo.addLine(3, 2, 2)
gmsh.model.geo.addLine(3, 4, 3)
gmsh.model.geo.addLine(4, 1, 4)
gmsh.model.geo.addCurveLoop([4, 1, -2, 3], 1)
gmsh.model.geo.addPlaneSurface([1], 1)
gmsh.model.geo.synchronize()

# set the marker for two of edges
wall_marker0 = 1
gmsh.model.addPhysicalGroup(1, [1, 3], wall_marker0)

surface_marker = 1
gmsh.model.addPhysicalGroup(2, [1], surface_marker)

gmsh.model.geo.synchronize()
gmsh.model.mesh.generate(2)

domain, cell_tag, facet_tags = gmshio.model_to_mesh(gmsh.model, MPI.COMM_WORLD, 0, gdim=2)
print(facet_tags.find(1))
2 Likes