Transitioning from mesh.xml to mesh.xdmf, from dolfin-convert to meshio

Hi dokken,

I tried this but unfortunately it didn’t work for my case. My python script and the error message can be found below. What mistakes did I make?

from future import print_function
from fenics import *
from dolfin import *
from ufl import nabla_div
from mpi4py import MPI
import numpy as np
import meshio

Scaled variables

E = 2.5e11
nv = 0.27

lambda_ = E * nv / ((1 + nv) * (1 - 2 * nv))
mu = 0.5 * E / (1 + nv)

Create mesh and define function space

#mesh = BoxMesh(Point(-1, -1, -1), Point(1, 1, 1), 10, 10, 10)

msh = meshio.read(“S1_V8.msh”)
meshio.write(“mesh.xdmf”, meshio.Mesh(points=msh.points, cells={“tetra”: msh.cells[“tetra”]}))
meshio.write(“mf.xdmf”, meshio.Mesh(points=msh.points, cells={“triangle”: msh.cells[“triangle”]},
cell_data={“triangle”: {“name_to_read”: msh.cell_data[“triangle”][“gmsh:physical”]}}))

meshio.write(“cf.xdmf”, meshio.Mesh(
points=msh.points, cells={“tetra”: msh.cells[“tetra”]},
cell_data={“tetra”: {“name_to_read”: msh.cell_data[“tetra”][“gmsh:physical”]}}))

mesh = Mesh()
with XDMFFile(“mesh.xdmf”) as infile:
infile.read(mesh)
mvc = MeshValueCollection(“size_t”, mesh, 2)
with XDMFFile(“mf.xdmf”) as infile:
infile.read(mvc, “name_to_read”)
mf = cpp.mesh.MeshFunctionSizet(mesh, mvc)

#meshio.write(“S1_V8.xml”,msh)
#mesh = Mesh(“mesh.xdmf”)

V = VectorFunctionSpace(mesh, ‘P’, 1)