I have a minimal code below. I need to gather the function u to all processes and then interpolate it on the functionspaces in each process. From the print part you can see that the gathering is happening correctly. However, the interpolation gives me the error I have attached below.
from dolfin import *
from numpy import array
from mpi4py import MPI
mesh = UnitSquareMesh(2, 2)
V = FunctionSpace(mesh, "CG", 1)
u = interpolate(Expression("x[0]",degree=0), V)
u_vec = u.vector()
v_vec = Vector(MPI.COMM_SELF)
u_vec.gather(v_vec, array(range(V.dim())))
print(MPI.COMM_WORLD.Get_rank(), u_vec.get_local(),v_vec.get_local())
U = Function(V)
U = interpolate(v_vec,V)
An the error is:
'dolfin.cpp.la.Vector' object has no attribute '_cpp_object'
I am not certain I understand what you would like to achieve here. Note that the mesh is distributed over the set of processors. Therefore, there is only one function space (with global number of dofs=9) existing.
To create a mesh on each processor, see for instance:
Additionally, you should access the function vector directly, and not through interpolation, if getting arrays from another processor.