Visualisation of distributed mesh

Hello,

I have a distributed mesh in parallel, but would like to visualise the exact partitions (e.g a colour map with a different colour for each distributed segment on each process) and then export this to paraview,

What would be the easiest way to do this?

Thanks,

from dolfin import *
mesh = UnitSquareMesh(32, 32)
XDMFFile("partition.xdmf").write(
	MeshFunction("size_t", mesh, mesh.topology().dim(), mesh.mpi_comm().rank))

image

2 Likes

I need the same thing for dolfinx, could you please provide a simple code?

import dolfinx
import dolfinx.io
from mpi4py import MPI
import numpy as np

mesh = dolfinx.UnitSquareMesh(MPI.COMM_WORLD, 10, 10)
num_cells_local = mesh.topology.index_map(mesh.topology.dim).size_local
mt = dolfinx.MeshTags(mesh, mesh.topology.dim, np.arange(num_cells_local, dtype=np.int32), np.full(num_cells_local, MPI.COMM_WORLD.rank, dtype=np.int32))

with dolfinx.io.XDMFFile(MPI.COMM_WORLD, "mf.xdmf", "w") as xdmf:
    xdmf.write_mesh(mesh)
    xdmf.write_meshtags(mt)
2 Likes

Thank you very much @dokken!