# Reading .h5 file by dolfinx

**URL:** <https://fenicsproject.discourse.group/t/reading-h5-file-by-dolfinx/18363>\
**Category:** dolfinx\
**Created:** [November 12, 2025, 2:27pm UTC](https://fenicsproject.discourse.group/t/reading-h5-file-by-dolfinx/18363 "2025-11-12T14:27:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZhangQi](https://avatars.discourse-cdn.com/v4/letter/z/da6949/32.png) [@ZhangQi](https://fenicsproject.discourse.group/u/ZhangQi)\
**Post date:** [November 12, 2025, 2:27pm UTC](https://fenicsproject.discourse.group/t/reading-h5-file-by-dolfinx/18363/1 "2025-11-12T14:27:37Z")

</div>

Dear, Hello, this is about using Fenics program from `colin27_coarse_boundaries.h5` file to read the brain grid, but now I want to use fenicsx to read the grid data, how to do, can help me convert it? Thank you very much!

```auto
def create_mesh():
    # Read mesh
    file = HDF5File(MPI.comm_world, "colin27_coarse_boundaries.h5", "r")
    file.read(mesh, "/mesh", False)

    print("#cells = ", mesh.num_cells())
    print("#vertices = ", mesh.num_vertices())

    # Read white/gray markers
    D = mesh.topology().dim()

    # Read skull/ventricle markers
    boundaries = MeshFunction("size_t", mesh, D - 1)
    file.read(boundaries, "/boundaries")
    file.close()

    return mesh, boundaries

```

> ****
>
> This text will be hidden

---

<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:** [November 12, 2025, 9:32pm UTC](https://fenicsproject.discourse.group/t/reading-h5-file-by-dolfinx/18363/2 "2025-11-12T21:32:21Z")

</div>

This has also been handled in [Create mesh in fenicsx from point and element array - #12 by ampdes](https://fenicsproject.discourse.group/t/create-mesh-in-fenicsx-from-point-and-element-array/9092/12) but the API has changed slightly.

---

<div class="post-metadata">

**Author:** ![ZhangQi](https://avatars.discourse-cdn.com/v4/letter/z/da6949/32.png) [@ZhangQi](https://fenicsproject.discourse.group/u/ZhangQi)\
**Post date:** [November 13, 2025, 4:36am UTC](https://fenicsproject.discourse.group/t/reading-h5-file-by-dolfinx/18363/3 "2025-11-13T04:36:23Z")

</div>

Thank you very much for your guidance. I will learn it.
