'dolfin.cpp.mesh' has no attribute 'GhostMode'

In trying to run a modified version of the poisson-subdomain tutorial, I now get an error.

In trying to run

with XDMFFile(MPI.comm_world, "ps_mesh.xdmf") as xdmf_infile:
mesh = xdmf_infile.read(dolfin.cpp.mesh.GhostMode.none)
mvc_subdomain = xdmf_infile.read_mvc_size_t(mesh, "subdomain")
tag_info = xdmf_infile.read_information_int()

I get

Traceback (most recent call last):
  File "demo_poisson_subdomain.py", line 156, in <module>
mesh = xdmf_infile.read(dolfin.cpp.mesh.GhostMode.none)
AttributeError: module 'dolfin.cpp.mesh' has no attribute 'GhostMode'

as an error. Can someone shed light on how to fix this?

If it helps, the relevant packages in my pip3 list are

fenics-dijitso         2019.1.0
fenics-dolfin          2019.1.0
fenics-dolfinx         2019.2.0.dev0
fenics-ffc             2019.1.0.post0
fenics-ffcx            2019.2.0.dev0
fenics-fiat            2019.2.0.dev0
fenics-ufl             2019.2.0.dev0

See this test which highlight the change in interface

Noted. I’ve changed MPI to be imported from mpi4py as opposed to dolfin or dolfinx, and replaced MPI.comm_world by MPI.COMM_WORLD.

I still get the same error as before. Trying but importing dolfinx without dolfin (is dolfinx intended as a replacement of or as an extension to dolfin?), upon running

with XDMFFile(MPI.COMM_WORLD, "ps_mesh.xdmf") as xdmf_infile:
    mesh = xdmf_infile.read(dolfinx.cpp.mesh.GhostMode.none)
    mvc_subdomain = xdmf_infile.read_mvc_size_t(mesh, "subdomain")
    tag_info = xdmf_infile.read_information_int()

I get

Traceback (most recent call last):
  File "demo_poisson_subdomain.py", line 155, in <module>
    mesh = xdmf_infile.read(dolfinx.cpp.mesh.GhostMode.none)
TypeError: read(): incompatible function arguments. The following argument types are supported:
    1. (self: dolfin.cpp.io.XDMFFile, arg0: dolfin.cpp.mesh.Mesh) -> None
    2. (self: dolfin.cpp.io.XDMFFile, mf: dolfin.cpp.mesh.MeshFunctionBool, name: str = '') -> None
    3. (self: dolfin.cpp.io.XDMFFile, mf: dolfin.cpp.mesh.MeshFunctionSizet, name: str = '') -> None
    4. (self: dolfin.cpp.io.XDMFFile, mf: dolfin.cpp.mesh.MeshFunctionInt, name: str = '') -> None
    5. (self: dolfin.cpp.io.XDMFFile, mf: dolfin.cpp.mesh.MeshFunctionDouble, name: str = '') -> None
    6. (self: dolfin.cpp.io.XDMFFile, mvc: dolfin.cpp.mesh.MeshValueCollection_bool, name: str = '') -> None
    7. (self: dolfin.cpp.io.XDMFFile, mvc: dolfin.cpp.mesh.MeshValueCollection_sizet, name: str = '') -> None
    8. (self: dolfin.cpp.io.XDMFFile, mvc: dolfin.cpp.mesh.MeshValueCollection_int, name: str = '') -> None
    9. (self: dolfin.cpp.io.XDMFFile, mvc: dolfin.cpp.mesh.MeshValueCollection_double, name: str = '') -> None

Invoked with: <dolfin.cpp.io.XDMFFile object at 0x7f6d47149d70>, GhostMode.none

You should not mix dolfin and dolfinx. Dolfin is the stable release of the FEniCS project. Dolfinx is the development version, see https://fenicsproject.org/fenics-project-roadmap-2019/ .

As shown in the link in my previous reply, this is how you should load meshes in dolfinx

    with XDMFFile(MPI.COMM_WORLD, filename, 'r') as xdmf:
        mesh = xdmf.read_mesh(name="Grid")