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,

nate
June 4, 2021, 2:45am
2
```
from dolfin import *
mesh = UnitSquareMesh(32, 32)
XDMFFile("partition.xdmf").write(
MeshFunction("size_t", mesh, mesh.topology().dim(), mesh.mpi_comm().rank))
```

2 Likes

nate:

`, mesh.mpi_comm().rank)`

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

dokken
October 21, 2021, 4:04pm
4
```
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 !

Using current API;

```
from dolfinx.mesh import locate_entities, meshtags, create_unit_square
import dolfinx.io
from mpi4py import MPI
import numpy as np
mesh = create_unit_square(MPI.COMM_WORLD, 10, 10)
num_cells_local = mesh.topology.index_map(mesh.topology.dim).size_local
mt = 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)
```

Is not working, what I am missing in here? Here is the snapshot from paraview using 8 procs;

dokken
August 23, 2022, 6:49pm
8
I cannot reproduce this with `v0.5.0`

using the `XDMF3ReaderT`

. I can reproduce this with the `S`

reader, so I would suggest using the `T`

reader.

1 Like

Using `XDMF3ReaderT`

is worked.