Errors when gathering vector or array in parallel

Dear all,

solving a time dependent non-linear problem, I need to evaluate the values of the nodal degrees of freedom and the dof’s coordinates at the end of each time step.
To be more precise, I need to find the position of the dof, where the dof’s current value (scalar c_res) is lower than a constant and the dot product of the position vector with a constant vector is maximal.

That’s why I dealt with Dolfin’s MPI wrapper and tried to use one of the gather functions implemented in Dolfin. As a first step, I tried to gather the nodal dof vector c_res.
Later, I’d like to gather an array containing one nodal dof and its position per process.

  • Code snippet common for all the attempts:

#… mesh definition etc. …
meshcomm = mesh.mpi_comm()
#…
V = FunctionSpace(mesh,element)
c_res = Function(Vc)
#… boundary conditions etc. …
while t<totalTime
#… solve …
u_res,c_res = uc.split(True)

c_res_arr=c_res.get_local()
c_res_glob=meshcomm.gather(c_res_arr)

Resulting in the following error:

AttributeError: ‘dolfin.cpp.MPICommWrapper’ object has no attribute ‘gather’
srun: error: taurusi6336: tasks 0-1: Exited with exit code 1

  • Than, I tried to use the gather_on_zero function of the GenericVector class:

x=Vector()
c_res.vector().gather_on_zero(x)

This gave me an error I don’t really understand:
c_res.vector().gather_on_zero(x)
TypeError: GenericVector_gather_on_zero() takes exactly one argument (2 given)

I think I can explain the second error. Remember, whenever you use a member function, the first argument (conventionally called self) is the object of which the function is a member: c_res_vector() in this case. So, when the error message says “takes exactly one argument”, what that really means is that it takes no explicit arguments. I think what you need to write is:

x = c_res.vector().gather_on_zero()