Issues with saving mesh connectivity from parellel

Probably something along these lines

import dolfinx
from mpi4py import MPI
import numpy as np


mesh = dolfinx.mesh.create_unit_square(
	MPI.COMM_WORLD, 2, 2)
num_cells_local = mesh.topology.index_map(
	mesh.topology.dim).size_local
cells_local = mesh.topology.connectivity(
	mesh.topology.dim, 0).array.reshape(-1, 3)[:num_cells_local]
cells_global = mesh.topology.index_map(0).local_to_global(
	cells_local.ravel()).reshape(-1, 3)

cells_global = mesh.comm.gather(cells_global, root=0)
if mesh.comm.rank == 0:
	cells_global = np.concatenate(cells_global)
	print(f"num cells global: {cells_global.shape[0]}")
	print(f"cell index map size_global: {mesh.topology.index_map(mesh.topology.dim).size_global}")
	print(f"cells:\n{cells_global}")

It’s not entirely clear what you want this for. See, for example, gathering a mesh on a single process: