petsc4py applies own typemap for MPI_Comm

Issue #195 resolved
Prof Garth Wells created an issue

The below code illustrates the issues:

from dolfin import *
mesh = UnitSquareMesh(8, 8)
comm0 = mesh.mpi_comm()
print type(comm0)
comm1 = mpi_comm_world()
print type(comm1)

The output is:

<type 'petsc4py.PETSc.Comm'>
<class 'dolfin.cpp.common.MPI_Comm'>

The problems that DOLFIN function expecting a MPI_Comm throw and error if the type is petsc4py.PETSc.Comm.

Comments (6)

  1. Johan Hake

    There are two easy ways we can fix this.

    1. Clear the greedy typemaps letting MPI_Comm just by a pointer stub.
    2. Move the inclusion of petscy4py.i to dolfin/swig/common/pre.i instead of dolfin/swig/la/pre.i.

    The latter will then turn all MPI_Comm objects into a a petsc4py object. It looks like both works. I vote for trying the latter and see if that just works. If so I think we then need a unit test for this functionality.

  2. Prof Garth Wells reporter

    I don't have a good grip on all the ins and outs of this, so I'm happy to go with whatever you recommend.

  3. Johan Hake

    I went with 2. So now basic attributes of the communicator can be accessed if DOLFIN is compiled with petsc4py.

  4. Log in to comment