This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Saving boundary-markers to HDF in FEniCS 2017.1

0 votes

Before upgrading to the 2017.1 version I was able to mark the mesh, and store the markers together with the mesh in an HDF file. After upgrading I am not able to load these markers anymore.

What is the proper way to save/load the markers in the new version?
Is it possible to load markers in the new version from files saved using the old version?

To be more specific. When running the following code

from dolfin import *

comm = mpi_comm_world()
mesh = UnitCubeMesh(2,2,2)
sub_domain = CompiledSubDomain("near(x[1], 0)")
ffun = MeshFunction("size_t", mesh, 2)
ffun.set_all(0)
sub_domain.mark(ffun, 1)

for facet in facets(mesh):
    mesh.domains().set_marker((facet.index(), ffun[facet]), 2)

print set(ffun.array())

# Save mesh
with HDF5File(comm, "test.h5", "w") as h5file:
    h5file.write(mesh, "mesh")

new_mesh = Mesh(comm)
# Load mesh
with HDF5File(comm, "test.h5", "r") as h5file:
    h5file.read(new_mesh, "mesh", True)

new_ffun = MeshFunction("size_t", new_mesh, 2, new_mesh.domains())
print set(new_ffun.array())

using version 2016.1 prints out

set([0,1])
set([0,1])

while version 2017.1 prints out

set([0, 1])
set([18446744073709551615])

Thanks.

asked May 14, 2017 by finsberg FEniCS User (2,360 points)
edited May 15, 2017 by finsberg
...