This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How can I plot a function only once in parallel

0 votes

when running

mpirun -n 4 demo_poisson.py

the function u is plotted by each processes. How can I plot the whole function (only once) when running in parrallel?

asked Jul 12, 2013 by chaffra FEniCS User (1,830 points)
edited Jul 12, 2013 by chaffra

1 Answer

+1 vote
 
Best answer

You cannot.

There is at least one reason: off-process dofs (corresponding to some owned mesh entity) must be updated (passed from owner process to some other processes). In principle responsibility for this update could be delegated to user, hence something like this would be possible:

u.update()
if MPI.process_number() == 0:
    plot(u, update=False)

You can file a proposal to DOLFIN issues but I'm afraid that it will be rejected.

answered Jul 12, 2013 by Jan Blechta FEniCS Expert (51,420 points)
selected Jul 12, 2013 by johanhake

Really, Naively I tried

if MPI.process_number() == 0:
plot(u)

but nothing plots. Why is that and in general why is it not possible?

Why is that

It deadlocks because plot(u) is currently implemented as a collective operation (it must be executed by every process).

and in general why is not possible?

See updated answer.

...