Line mesh in a 2D space

Hi,
Please consider the following code:

import meshio
msh = meshio.read("tjhAB.msh")
meshio.write("mesh.xdmf", meshio.Mesh(points=msh.points[:,:2], cells={"line": msh.cells["line"]}))

from dolfin import *
mesh = Mesh()
filename = "mesh.xdmf"
f = XDMFFile(filename)
f.read(mesh)

outfile = XDMFFile("dolfin_mesh.xdmf").write(mesh)

Here I’ve used meshio’s python interface to save the mesh in a format that dolfin can handle.
For more info on that subject, with respect to markers etc. see: Transitioning from mesh.xml to mesh.xdmf, from dolfin-convert to meshio
Note that I’ve removed the z-coordinate from the points array, as you have to tell dolfin that this mesh is a “2D” mesh.

3 Likes