Problem Reading XDMF with facet tags

I’m trying to read a xdmf file

with XDMFFile(MPI.COMM_WORLD, "mt.xdmf", "r") as xdmf:
    domain = xdmf.read_mesh(name="mesh")
    tdim=domain.topology.dim
    fdim =tdim-1
    domain.topology.connectivity(tdim,fdim)
    cell_tags = xdmf.read_meshtags(domain,name="Cell tags")
    facet_tags = xdmf.read_meshtags(domain,name="Facet tags")

It can read cell tags just fine but when I try to read facet tags it gives me the following error:
RuntimeError: Mesh entities of dimension 2have not been created.

I am able to see the tags in paraview without any issues.
The xdmf file is:

?xml version="1.0"?>
<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []>
<Xdmf Version="3.0" xmlns:xi="https://www.w3.org/2001/XInclude">
  <Domain>
    <Grid Name="mesh" GridType="Uniform">
      <Topology TopologyType="Tetrahedron" NumberOfElements="1730" NodesPerElement="4">
        <DataItem Dimensions="1730 4" NumberType="Int" Format="HDF">mt.h5:/Mesh/mesh/topology</DataItem>
      </Topology>
      <Geometry GeometryType="XYZ">
        <DataItem Dimensions="433 3" Format="HDF">mt.h5:/Mesh/mesh/geometry</DataItem>
      </Geometry>
    </Grid>
    <Grid Name="Facet tags" GridType="Uniform">
      <xi:include xpointer="xpointer(/Xdmf/Domain/Grid/Geometry)" />
      <Topology TopologyType="Triangle" NumberOfElements="878" NodesPerElement="3">
        <DataItem Dimensions="878 3" NumberType="Int" Format="HDF">mt.h5:/MeshTags/Facet tags/topology</DataItem>
      </Topology>
      <Attribute Name="Facet tags" AttributeType="Scalar" Center="Cell">
        <DataItem Dimensions="878 1" Format="HDF">mt.h5:/MeshTags/Facet tags/Values</DataItem>
      </Attribute>
    </Grid>
    <Grid Name="Cell tags" GridType="Uniform">
      <xi:include xpointer="xpointer(/Xdmf/Domain/Grid/Geometry)" />
      <Topology TopologyType="Tetrahedron" NumberOfElements="1730" NodesPerElement="4">
        <DataItem Dimensions="1730 4" NumberType="Int" Format="HDF">mt.h5:/MeshTags/Cell tags/topology</DataItem>
      </Topology>
      <Attribute Name="Cell tags" AttributeType="Scalar" Center="Cell">
        <DataItem Dimensions="1730 1" Format="HDF">mt.h5:/MeshTags/Cell tags/Values</DataItem>
      </Attribute>
    </Grid>
  </Domain>
</Xdmf>

Change this to

domain.topology.create_connectivity(tdim,fdim)
1 Like