So since you have a 2D mesh, you should not try to save a mesh with tetrahedrons.
You should change the keyword “tetra” to “triangle”, and similarly change “triangle” to “line” in the writing of “mf.xdmf”.
I would strongly encourage you to use the following function for writing a mesh given a cell type:
import numpy
def create_mesh(mesh, cell_type, prune_z=False):
cells = mesh.get_cells_type(cell_type)
cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
out_mesh = meshio.Mesh(points=mesh.points, cells={cell_type: cells}, cell_data={"name_to_read":[cell_data]})
if prune_z:
out_mesh.prune_z_0()
return out_mesh
whose explanation can be found at