Continuing the discussion from Gmshio can't successfully read the msh file created by Gmsh:
When I exported the mesh as .xdmf using meshio, and used dolfin to read the file, it dosen’t work either when the xdmf could be opened with paraview. I tried to export only tetrahedra or wedge, and only the file contained tetraIs could be read. fenics couldn’t read the msh file that contains two and more kinds of mesh?
import meshio
import matplotlib.pyplot as pt
msh = meshio.read("msh_generate.msh")
#mesh
meshio.write("mesh.xdmf", meshio.Mesh(points=msh.points, cells={"tetra": msh.cells["tetra"],"wedge": msh.cells["wedge"]}))
#boundary face
meshio.write("mf.xdmf", meshio.Mesh(points=msh.points, cells={"triangle": msh.cells["triangle"],"quad": msh.cells["quad"]},cell_data={"triangle": {"name_to_read": msh.cell_data["triangle"]["gmsh:physical"]},"quad": {"name_to_read": msh.cell_data["quad"]["gmsh:physical"]}}))
#boundary cell
meshio.write("cf.xdmf", meshio.Mesh(points=msh.points, cells={"tetra": msh.cells["tetra"],"wedge": msh.cells["wedge"]},cell_data={"tetra": {"name_to_read":msh.cell_data["tetra"]["gmsh:physical"]},"wedge": {"name_to_read":msh.cell_data["wedge"]["gmsh:physical"]}}))
from dolfin import *
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)
boundary_markers=MeshFunction("size_t",mesh,mvc)
#print(boundaries.value())
mvc = MeshValueCollection("size_t", mesh, 3)
with XDMFFile("cf.xdmf") as infile:
infile.read(mvc, "name_to_read")
cf = cpp.mesh.MeshFunctionSizet(mesh, mvc)
The error is as follows:
Traceback (most recent call last):
File "meshfile.py", line 15, in <module>
infile.read(mesh)
RuntimeError:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to recognise cell type.
*** Reason: Unknown value "mixed".
*** Where: This error was encountered inside XDMFFile.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.1.0
*** Git changeset: 2e001bd1aae8e14d758264f77382245e6eed04b0
*** --------------------------------------------------------------