Loading domains from a mesh file fails when run in parallel

Issue #356 new
Matthias Liertzer created an issue

Loading a mesh file that also contains domain data fails to correctly load the domain data when running with MPI. The following test script creates and reloads both the mesh and the meshfunction perfectly when running it without MPI. However, when loading the mesh domains in parallel, it fails (Note, that mesh.domains().num_marked() shows that in fact not all cells are marked in parallel, hence the error occurs during loading, not when converting it into a MeshFunction).

Loading a MeshFunction directly from a file works in parallel as expected.

import os
from dolfin import *

meshfile = 'mesh.xml.gz'
subfile = 'sub.xml.gz'

if not (os.path.exists(meshfile) and
        os.path.exists(subfile)):
    mesh = UnitSquareMesh(10, 10)

    AutoSubDomain(lambda _: True).mark_cells(mesh, 1)
    AutoSubDomain(lambda x: x[0] >= 0.5).mark_cells(mesh, 2)

    subdomains = MeshFunction('size_t', mesh, 2, mesh.domains())
    File(meshfile) << mesh
    File(subfile) << subdomains

mesh = Mesh(meshfile)
sub_from_mesh = MeshFunction('size_t', mesh, 2, mesh.domains())
sub_from_file = MeshFunction('size_t', mesh, subfile)
plot(sub_from_mesh)
plot(sub_from_file)
interactive()

The bug occurs both 1.4, as well as in the master branch.

Comments (7)

  1. Prof Garth Wells
    • changed milestone to 1.7

    Bumping this to 1.7. My preferred fix is to not allow XML with domain data to be read in parallel, and use XDMF/HDF5 instead.

    It's too much work and too error prone to support two file formats in parallel.

  2. Log in to comment