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

**URL:** <https://fenicsproject.discourse.group/t/transitioning-from-mesh-xml-to-mesh-xdmf-from-dolfin-convert-to-meshio/412>\
**Category:** mesh\
**Created:** [March 22, 2019, 9:01am UTC](https://fenicsproject.discourse.group/t/transitioning-from-mesh-xml-to-mesh-xdmf-from-dolfin-convert-to-meshio/412 "2019-03-22T09:01:33Z")\
**Posts on this page:** 1\
**Showing post:** 112

<div class="post-metadata">

**Author:** ![kates\_moods](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/kates_moods/32/903_2.png) [@kates\_moods](https://fenicsproject.discourse.group/u/kates_moods)\
**Post date:** [March 16, 2020, 1:26pm UTC](https://fenicsproject.discourse.group/t/transitioning-from-mesh-xml-to-mesh-xdmf-from-dolfin-convert-to-meshio/412/112 "2020-03-16T13:26:03Z")

</div>

I am currently trying to covert a simple a .msh to XDMF mesh with the following code from the tutorials above:

> ```
> msh = meshio.read("test_box.msh")
> for cell in msh.cells:
> if cell.type == "triangle":
> triangle_cells = cell.data
> elif cell.type == "tetra":
> tetra_cells = cell.data
> 
> ```

```
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},
                 cell_data={"name_to_read":[tetra_data]})
triangle_mesh = meshio.Mesh(points=msh.points,
                            cells=[("triangle", triangle_cells)],
                            cell_data={"name_to_read": [triangle_data]})
meshio.write("mesh.xdmf", tetra_mesh)

meshio.write("mf.xdmf", triangle_mesh)
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)

cf = cpp.mesh.MeshFunctionSizet(mesh, mvc)

```

but when it tries to read in the file in infield.read(mesh) I get a ValueError: vector. I cannot figure out why, as the same code works on my colleagues computer. I have attached the beginning of my mesh file! Any help would be appreciated.

mesh file:  
$MeshFormat  
2.2 0 8  
$EndMeshFormat  
$Nodes  
358  
1 0 0 1  
2 0 0 0  
3 0 1 1  
4 0 1 0  
5 1 0 1  
6 1 0 0  
7 1 1 1  
8 1 1 0  
9 0 0 0.1666666666666662  
10 0 0 0.3333333333333324  
11 0 0 0.4999999999999986  
12 0 0 0.6666666666666646  
13 0 0 0.8333333333333321  
14 0 0.1666666666666662 1  
15 0 0.3333333333333324 1  
16 0 0.4999999999999986 1  
17 0 0.6666666666666646 1  
18 0 0.8333333333333321 1  
19 0 1 0.1666666666666662  
20 0 1 0.3333333333333324  
21 0 1 0.4999999999999986  
22 0 1 0.6666666666666646  
23 0 1 0.8333333333333321  
24 0 0.1666666666666662 0  
25 0 0.3333333333333324 0  
26 0 0.4999999999999986 0  
27 0 0.6666666666666646 0  
28 0 0.8333333333333321 0  
29 1 0 0.1666666666666662  
30 1 0 0.3333333333333324  
31 1 0 0.4999999999999986  
32 1 0 0.6666666666666646  
33 1 0 0.8333333333333321  
34 1 0.1666666666666662 1  
35 1 0.3333333333333324 1  
36 1 0.4999999999999986 1  
37 1 0.6666666666666646 1  
38 1 0.8333333333333321 1  
39 1 1 0.1666666666666662  
40 1 1 0.3333333333333324  
41 1 1 0.4999999999999986  
42 1 1 0.6666666666666646  
43 1 1 0.8333333333333321  
44 1 0.1666666666666662 0  
45 1 0.3333333333333324 0  
46 1 0.4999999999999986 0  
47 1 0.6666666666666646 0

---

_[View the full topic](https://fenicsproject.discourse.group/t/transitioning-from-mesh-xml-to-mesh-xdmf-from-dolfin-convert-to-meshio/412)._
