I tried this with meshio-4.0.8:
import meshio
msh = meshio.read("Monopole2.msh")
for cell in msh.cells:
if cell.type == "tetra":
tet_cells = cell.data
for key in msh.cell_data_dict["gmsh:physical"].keys():
if key == "tetra":
tetra_data = msh.cell_data_dict["gmsh:physical"][key]
tet_mesh = meshio.Mesh(points=msh.points, cells={"tetra": tet_cells})
meshio.write("mesh.xdmf", tet_mesh)
and it dies with the following error message:
Traceback (most recent call last):
File "Monopole2.py", line 10, in <module>
meshio.write("mesh.xdmf", tet_mesh)
File "/home/bill/.local/lib/python3.6/site-packages/meshio/_helpers.py", line 119, in write
file_format = _filetype_from_path(path)
File "/home/bill/.local/lib/python3.6/site-packages/meshio/_helpers.py", line 33, in _filetype_from_path
raise ReadError("Could not deduce file format from extension '{}'.".format(ext))
meshio._exceptions.ReadError: Could not deduce file format from extension '.xdmf'.
How can I make this work?
My full 3D GMSH mesh file found here. It is a bit big to post as code for E-Z copy paste.
PS- Just tried this code posted by @dokken earlier. It gives the same error.
import meshio
msh = meshio.read("Monopole2.msh")
meshio.write("mesh.xdmf",
meshio.Mesh(points = msh.points,
cells = {'tetra': msh.cells_dict['tetra']}))