I need to convert my xdmf file to an xml file so that I can call Mesh() on the xml file. How do I convert from xdmf to xml? I started with a .geo file in gmsh that I created an msh file from. I then converted the msh file to xdmf using meshio convert.
Meshio can convert files from xdmf to xml. Why do you specifically need to have mesh=Mesh("file.xml"
and not use the syntax described here, which is recommended: Transitioning from mesh.xml to mesh.xdmf, from dolfin-convert to meshio - #3 by dokken
Ok. I tried both options.
First option
I ran the following lines:
os.system('meshio convert \\wsl.localhost\\Ubuntu\\usr\\share\\input2D.xdmf \\wsl.localhost\\Ubuntu\\usr\\share\\input2D.xml')
mesh = Mesh("\\wsl.localhost\\Ubuntu\\usr\\share\\input2D.xml")
This gives me an error saying that Mesh() was unable to read input2D.xml
Second Option
I run:
msh = meshio.read("input2D.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"]}}))
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)
This gives me this error: