# Parallel Processing

**URL:** <https://fenicsproject.discourse.group/t/parallel-processing/4366>\
**Category:** I/O\
**Created:** [October 20, 2020, 1:01pm UTC](https://fenicsproject.discourse.group/t/parallel-processing/4366 "2020-10-20T13:01:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akhil\_Muraleedharan](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@Akhil\_Muraleedharan](https://fenicsproject.discourse.group/u/Akhil_Muraleedharan)\
**Post date:** [October 20, 2020, 1:01pm UTC](https://fenicsproject.discourse.group/t/parallel-processing/4366/1 "2020-10-20T13:01:45Z")

</div>

```
from dolfin import *
import numpy
from mpi4py import MPI
import matplotlib.pyplot as plt
comm = MPI.COMM_WORLD
rank = comm.Get_rank()

parameters["allow_extrapolation"]=True
mesh=UnitSquareMesh(10,10)
V=FunctionSpace(mesh,'CG',1)
U = Function(V)

size = (U.vector().local_size())
print ( size)
vector = []

if rank ==0: 
    vector = [-20.0]*size;
else:
    vector = [-10.0]*size;

U.vector().set_local(numpy.array(vector))
plot(U)
plt.savefig("plotting_example.png")

```

While plotting the result after using the command  
` mpirun -np 2 python3 parallel_processing_plotting.py`

I am left with the following result ![plotting_example](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/2/2579de6cdd3c9c184618146e7336648ae97df970.png)  
`

which only plots half of the result. What is the mistake that has been committed in the code which has to be rectified to get the proper result which plots the whole figure ?

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [October 20, 2020, 1:35pm UTC](https://fenicsproject.discourse.group/t/parallel-processing/4366/2 "2020-10-20T13:35:50Z")

</div>

I would not use the matplotlib backend for plotting in parallel. I would suggest writing your function to either pvd (`File("output.pvd")<< u`) or using`XDMFFile`.

---

<div class="post-metadata">

**Author:** ![Akhil\_Muraleedharan](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@Akhil\_Muraleedharan](https://fenicsproject.discourse.group/u/Akhil_Muraleedharan)\
**Post date:** [October 21, 2020, 1:29pm UTC](https://fenicsproject.discourse.group/t/parallel-processing/4366/3 "2020-10-21T13:29:33Z")

</div>

Thank You  
It Works!!
