# .xdmf mixed type - problem with generating mesh

**URL:** https://fenicsproject.discourse.group/t/xdmf-mixed-type-problem-with-generating-mesh/11923
**Category:** mesh
**Created:** [August 8, 2023, 12:30pm UTC](https://fenicsproject.discourse.group/t/xdmf-mixed-type-problem-with-generating-mesh/11923 "2023-08-08T12:30:20Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)
#### Post date: [August 8, 2023, 2:27pm UTC](https://fenicsproject.discourse.group/t/xdmf-mixed-type-problem-with-generating-mesh/11923/2 "2023-08-08T14:27:25Z")

</div>

There are plenty of other posts on the forum regarding this, see:

> [@Transitioning from mesh.xml to mesh.xdmf, from dolfin-convert to meshio](https://fenicsproject.discourse.group/t/transitioning-from-mesh-xml-to-mesh-xdmf-from-dolfin-convert-to-meshio/412/9):
>
> I dont really now how to help you further. If you use the docker to install fenics, and then run the following: docker run -ti --rm -v $(pwd):/home/fenics/shared quay.io/fenicsproject/stable:latest sudo pip install meshio lxml h5py I used gmsh 3.0.6 to generate the msh file. Then running the following script: import meshio msh = meshio.read("file.msh") meshio.write("mesh.xdmf", meshio.Mesh(points=msh.points, cells={"tetra": msh.cells["tetra"]})) meshio.write("mf.xdmf", meshio.Mesh(points=…

> [@Extracting mesh regions for gmsh mesh](https://fenicsproject.discourse.group/t/extracting-mesh-regions-for-gmsh-mesh/1125/16):
>
> As I said in the previous post, follow my newest tutorial. I copied your geo output and created an msh file (mesh2.msh), which I then converted with the following script from the tutorial: import meshio mesh\_from\_file = meshio.read("mesh2.msh") import numpy def create\_mesh(mesh, cell\_type, prune\_z=False): cells = numpy.vstack([cell.data for cell in mesh.cells if cell.type==cell\_type]) cell\_data = numpy.hstack([mesh.cell\_data\_dict["gmsh:physical"][key] for key …

> [@Gmsh import error](https://fenicsproject.discourse.group/t/gmsh-import-error/4995/5):
>
> It seems like you have not read the post I linked you to. You cannot use the meshio-convert script out of the box for XDMF, and you have to use the meshio python interface. See the second section of: [Mesh generation and conversion with GMSH and PYGMSH | Jørgen S. Dokken](https://jsdokken.com/converted_files/tutorial_pygmsh.html#second) where I read in a mesh: import meshio mesh\_from\_file = meshio.read("mesh.msh") extract data for a given cell type def create\_mesh(mesh, cell\_type, prune\_z=False): cells = numpy.vstack([cell.data for cell in mesh.cells if …

---

_[View the full topic](https://fenicsproject.discourse.group/t/xdmf-mixed-type-problem-with-generating-mesh/11923)._
