Sorry, I am a beginner with paraview. I want to parallelize the clipping of my square domain like this :

```
def clipCellsMPI(self):
# Slice the domain into NbCell^2 cells
# set cell centres, boundaries, and the attributes
from mpi4py import MPI
comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()
N = self.__Par.getNbCell() # number of cells along each axis, ie: NbCell**2 cells in the domain
Pts = self.__PtsL[0]
dl = (np.max(Pts[:,0])-np.min(Pts[:,0]))*(1.0/N) # cell length
XRawData = self.__XRawDataL[0]
YRawData = self.__YRawDataL[0]
# synchronize processes before deleting
comm.Barrier()
# set the job for each process
if rank ==0:
del(self.__PtsL[0])
del(self.__XRawDataL[0])
del(self.__YRawDataL[0])
del(self.__nbPtsL[0])
del(self.__XPL[0])
del(self.__YPL[0])
del(self.__XVelocityL[0])
del(self.__YVelocityL[0])
nwork = N//size # number of job per process when N is divisible by size
shape_sub_arrays = np.ones(size,dtype=int)*(nwork) # final number of job per process
start_ind = np.zeros(size,dtype=int) # index to know cells to slice per process (in linear mapping)
# set shape_sub_arrays and start_ind arrays
if(nwork*size != N):
for i in range(N-nwork*size):
shape_sub_arrays[i] += 1
for i in range(size):
start_ind[i] = np.sum(shape_sub_arrays[:i])
print("shape of sub arrays :",shape_sub_arrays)
print("start indice :",start_ind)
else :
shape_sub_arrays = None
start_ind = None
comm.Barrier()
# send to each process the job to do
local_start_ind = comm.scatter(start_ind, root=0)
local_array_shape = comm.scatter(shape_sub_arrays, root=0)
# set cell indices in linear mapping for each process
local_cell_ind = np.arange(local_start_ind,local_start_ind+local_array_shape,1)
# loop on local cells to clip
localXRawDataL = []
localYRawDataL = []
localnbPtsL = []
localPtsL = []
localXPL = []
localYPL = []
localXVelocityL = []
localYVelocityL = []
for ind in local_cell_ind :
i = ind//N # indice row in matrix mapping
j = N - i # indice column in matrix mapping
Xcell = Clip(Input=XRawData)
Ycell = Clip(Input=YRawData)
Xcell.ClipType='Box'
Ycell.ClipType='Box'
Xcell.Scalars=['POINTS' , 'PR']
Ycell.Scalars=['POINTS' , 'PR']
Xcell.Invert=True
Ycell.Invert=True
Xcell.ClipType.UseReferenceBounds = 1
Ycell.ClipType.UseReferenceBounds = 1
l = self.__Par.getl()
Xcell.ClipType.Bounds = [i*dl/l, (i+1)*dl/l, j*dl/l, (j+1)*dl/l, 0.0, 0.0]
Ycell.ClipType.Bounds = [i*dl/l, (i+1)*dl/l, j*dl/l, (j+1)*dl/l, 0.0, 0.0]
Xcell.ClipType.Length = [l,l,l]
Ycell.ClipType.Length = [l,l,l]
# Updating the attributes of the PostProcessing class
XFetchedData = servermanager.Fetch(Xcell)
YFetchedData = servermanager.Fetch(Ycell)
nbPts = XFetchedData.GetNumberOfPoints()
localXRawDataL.append(Xcell)
localYRawDataL.append(Ycell)
localnbPtsL.append(nbPts)
localPtsL.append(numpy_support.vtk_to_numpy(XFetchedData.GetPoints().GetData()))
localXPL.append(numpy_support.vtk_to_numpy(XFetchedData.GetPointData().GetArray("PR")))
localYPL.append(numpy_support.vtk_to_numpy(YFetchedData.GetPointData().GetArray("PR")))
localXVelocityL.append(numpy_support.vtk_to_numpy(XFetchedData.GetPointData().GetArray("V")))
localYVelocityL.append(numpy_support.vtk_to_numpy(YFetchedData.GetPointData().GetArray("V")))
comm.Barrier()
# results gathering
XRawDataL = comm.gather(localXRawDataL, root=0)
YRawDataL = comm.gather(localYRawDataL, root=0)
nbPtsL = comm.gather(localnbPtsL, root=0)
PtsL = comm.gather(localPtsL, root=0)
XPL = comm.gather(localXPL, root=0)
YPL = comm.gather(localYPL, root=0)
XVelocityL = comm.gather(localXVelocityL, root=0)
YVelocityL = comm.gather(localYVelocityL, root=0)
#result = comm.gather(results, root=0)
if rank == 0:
# Computing CellBoundaries
CellBoundariesX = np.arange(0,N+1,1).reshape(N+1,1)*np.ones((1,N+1))*dl
CellBoundariesY = np.arange(0,N+1,1)*np.ones((N+1,1))*dl
CellCentres = np.zeros((N*N,2))
for j in range(N):
# Computing the CellCentre
CellCentres[j::N] = (np.array([np.ones(N)*j,np.arange(0,N,1)]).T+0.5)*dl
self.__CellCentres = CellCentres
self.__CellBoundariesX = CellBoundariesX.T
self.__CellBoundariesY = CellBoundariesY.T
self.__tag = 'Divided'
self.__XRawDataL = [array for sublist in XRawDataL for array in sublist] # store in the good format values
self.__YRawDataL = [array for sublist in YRawDataL for array in sublist]
self.__nbPtsL = [array for sublist in nbPtsL for array in sublist]
self.__PtsL = [array for sublist in PtsL for array in sublist]
self.__XPL = [array for sublist in XPL for array in sublist]
self.__YPL = [array for sublist in YPL for array in sublist]
self.__XVelocityL = [array for sublist in XVelocityL for array in sublist]
self.__YVelocityL = [array for sublist in YVelocityL for array in sublist]
comm.Barrier()
```