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

Importing Marked Mesh for parallel use

+2 votes

Hi,

Is it possible to import mesh with marked facets and subdomains in a parallel-friendly format?

Currently I do this

 mesh = Mesh("cube.xml")                                                  
 subdomains = MeshFunction("size_t", mesh, "cube_physical_region.xml")    
 boundaries = MeshFunction("size_t", mesh, "cube_facet_region.xml")

But this results in an error when run in parallel: Cannot read old-style MeshFunction XML files as a MeshValueCollection"

I know that a HDF5 format is required, but will this format preserve the labels marking the different subdomains? My xml files are converted from .msh files using dolfin-convert.

Thanks

asked Sep 7, 2014 by sixtysymbols FEniCS User (2,280 points)

1 Answer

+7 votes
 
Best answer

I think it should work with HDF5. Try doing this, in serial:

mesh = Mesh("cube.xml")                                                  
subdomains = MeshFunction("size_t", mesh, "cube_physical_region.xml")    
boundaries = MeshFunction("size_t", mesh, "cube_facet_region.xml")
hdf = HDF5File(mesh.mpi_comm(), "file.h5", "w")
hdf.write(mesh, "/mesh")
hdf.write(subdomains, "/subdomains")
hdf.write(boundaries, "/boundaries")

Then in parallel, to read it back in:

mesh = Mesh()
hdf = HDF5File(mesh.mpi_comm(), "file.h5", "r")
hdf.read(mesh, "/mesh", False)
subdomains = CellFunction("size_t", mesh)
hdf.read(subdomains, "/subdomains")
boundaries = FacetFunction("size_t", mesh)
hdf.read(boundaries, "/boundaries")
answered Sep 8, 2014 by chris_richardson FEniCS Expert (31,740 points)
edited Sep 18, 2014 by chris_richardson

Thanks for the reply. I'll try this and get back to you.

Hi,

This worked. The only correction I needed to make is the read line in part 2 should be

hdf.read(mesh, "/mesh",False)

Updated my answer to correct... thanks.

Cannot read old-style MeshFunction XML files as a MeshValueCollection: Multiple Materials
...