XDMFFile in DolfinX

I’m trying to migrate provided code from dolfin to dolfinx.

When exporting group meshes from FreeCAD I save them as .xdmf files
Using dolfin I can read .xdmf files using

meshfile = meshpath+"mesh.xdmf"
mesh = Mesh()
with XDMFFile(meshfile) as infile:
    infile.read(mesh)

In this tutorial there is this snippet

with XDMFFile(MPI.COMM_WORLD, "mesh.xdmf", "r") as xdmf:
    mesh = xdmf.read_mesh(name="Grid")
    ct = xdmf.read_meshtags(mesh, name="Grid")
mesh.topology.create_connectivity(mesh.topology.dim, mesh.topology.dim-1)
with XDMFFile(MPI.COMM_WORLD, "mt.xdmf", "r") as xdmf:
    ft = xdmf.read_meshtags(mesh, name="Grid")

But when I try to run this I get the traceback that there is a missing .h5 file.

    with XDMFFile(MPI.COMM_WORLD, meshfile, "r") as xdmf:
RuntimeError: Unable to open HDF5 file. File mesh.h5 does not exist.

Default encoding is HDF5, should I be changing that to ASCII or am I on the wrong track?

Regards
Ólafur Marteinsson

Could you share the content of your xdmf-file? Does it contain all the arrays in plain-text? If so you should read it with ascii encoding

Thank you for looking into my issue.
.xdmf file can be found here

Here are the first few lines of the .xdmf file

<?xml version="1.0"?>
<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []>
<Xdmf Version="3.0"><Domain><Grid Name="base_mesh" GridType="Uniform"><Topology TopologyType="Tetrahedron" NumberOfElements="6071" NodesPerElement="4"><DataItem NumberType="UInt" Dimensions="6071 4" Format="XML">667 1145 1013 1183
161 201 741 1090
995 590 1200 1379
995 1200 590 1425
1017 330 1190 1353
946 1020 1289 1347

MWE since I didn’t include it in my original post.

import numpy as np
from mpi4py import MPI
from petsc4py import PETSc
from dolfinx import geometry
from dolfinx.io import gmshio, XDMFFile
from dolfinx.fem import FunctionSpace, Function, Constant
from dolfinx.fem.petsc import LinearProblem
import ufl
from ufl import dx, grad, inner, ds, Measure


with XDMFFile(MPI.COMM_WORLD, "mesh.xdmf", "r") as xdmf:```

I would try to use the ascii encoding mode.

I have to ask since I can not figure it out by myself.
How do I change the encoding mode?

dolfinx.cpp.io.XDMFFile(comm: MPICommWrapper, filename: os.PathLike, file_mode: str, encoding: dolfinx.cpp.io.XDMFFile.Encoding = <Encoding.HDF5: 0>)

For instance with

with dolfinx.io.XDMFFile(mesh.comm, "mesh.xdmf", "r", encoding=dolfinx.io.XDMFFile.Encoding.ASCII) as infile:
    mesh = infile.read_mesh(name="base_mesh")