Reading .h5 file by dolfinx

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!

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

This has also been handled in Create mesh in fenicsx from point and element array - #12 by ampdes but the API has changed slightly.

1 Like

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