Pygmsh Tutorial?

FEniCS does not support direct import from msh, so you have to rewrite the mesh data. As I pointed out in the last post, if you are using the latest version of meshio, you need to use the following syntax:

import meshio
msh ="mesh.msh")
for cell in msh.cells:
    if cell.type == "triangle":
        triangle_cells =
    elif  cell.type == "tetra":
        tetra_cells =

for key in msh.cell_data_dict["gmsh:physical"].keys():
    if key == "triangle":
        triangle_data = msh.cell_data_dict["gmsh:physical"][key]
    elif key == "tetra":
        tetra_data = msh.cell_data_dict["gmsh:physical"][key]
tetra_mesh = meshio.Mesh(points=msh.points, cells={"tetra": tetra_cells})
triangle_mesh =meshio.Mesh(points=msh.points,
                           cells=[("triangle", triangle_cells)],
meshio.write("mesh.xdmf", tetra_mesh)

meshio.write("mf.xdmf", triangle_mesh)

as meshio changed its user interface recently.