Hello,
I am trying to plot function self.T
calculated in parallel, but I am not able to gather the data correctly to rank=0. When run in parallel each rank produces correct chunk of the plot, and the solution is also correct when viewed in Paraview through xdmf file.
I have this function (domain is mesh):
def plot(self):
cells, types, x = plot.create_vtk_mesh(self.V)
cells = self.domain.comm.gather(cells, root=0)
types = self.domain.comm.gather(types, root=0)
x = self.domain.comm.gather(x, root=0)
Txarray = self.domain.comm.gather(self.T.x.array, root=0)
if MPI.COMM_WORLD.rank == 0:
cells = np.hstack(cells)
types = np.hstack(types)
x = np.vstack(x)
Txarray = np.hstack(Txarray)
grid = pyvista.UnstructuredGrid(cells, types, x)
grid.point_data["u"] = Txarray
plotter = pyvista.Plotter()
plotter.add_mesh(grid, show_edges=True)
plotter.view_xy()
plotter.show()
The plot it produces looks like this, I think I need to reorder something, but I do not not which of the arrays is wrong.
It should look like this (run with mpirun -n 1):
What I am missing?
Thank you, for any help.
.