MPI demo in dolfinx

Hello there,

I’m new to dolfinx and trying to reproduce the tutorial (DOLFINx in Parallel with MPI — NewFrac FEniCSx Training) in the latest version, but cannot get through the example 04-mpi-dolfinx.py.

I couldn’t find the alternative of “mesh.topology.create_connectivity_all()” so I deleted this line. When I run

mpirun -n 2 python3 04-mpi-dolfinx.py

I have the results

Rank 0: Number of local cells: 2
Rank 0: Number of global cells: 2
Rank 0: Number of local vertices: 4
Rank 0: Cell (dim = 2) to vertex (dim = 0) connectivity
Rank 0: <AdjacencyList> with 2 nodes
  0: [0 1 2 ]
  1: [0 3 2 ]

Rank 1: Number of local cells: 0
Rank 1: Number of global cells: 2
Rank 1: Number of local vertices: 0
Rank 1: Cell (dim = 2) to vertex (dim = 0) connectivity
Rank 1: <AdjacencyList> with 0 nodes

which is different from the tutorial where two nodes assemble the mesh cooperatively.
Here is my code (just minimal changes from the tutorial).

from mpi4py import MPI
import dolfinx
import dolfinx.io

comm = MPI.COMM_WORLD

def mpi_print(s):
    print(f"Rank {comm.rank}: {s}")

mesh = dolfinx.mesh.create_unit_square(comm=comm, nx=1, ny=1, ghost_mode=dolfinx.mesh.GhostMode.none, diagonal=dolfinx.mesh.DiagonalType.right)
#mesh.topology.create_connectivity_all()

mpi_print(f"Number of local cells: {mesh.topology.index_map(2).size_local}")
mpi_print(f"Number of global cells: {mesh.topology.index_map(2).size_global}")
mpi_print(f"Number of local vertices: {mesh.topology.index_map(0).size_local}")
mpi_print("Cell (dim = 2) to vertex (dim = 0) connectivity")
mpi_print(mesh.topology.connectivity(2, 0))

Could you help me out? Thanks!

I cannot reproduce this locally.
I get:

Rank 0: Number of local cells: 1
Rank 0: Number of global cells: 2
Rank 0: Number of local vertices: 2
Rank 0: Cell (dim = 2) to vertex (dim = 0) connectivity
Rank 0: <AdjacencyList> with 1 nodes
  0: [2 0 1 ]

Rank 1: Number of local cells: 1
Rank 1: Number of global cells: 2
Rank 1: Number of local vertices: 2
Rank 1: Cell (dim = 2) to vertex (dim = 0) connectivity
Rank 1: <AdjacencyList> with 1 nodes
  0: [0 1 2 ]

How did you install DOLFINx?

What happens if you use a bigger mesh (say 5x5)?

Hi dokken, thanks for your reply. I installed DOLFINx by conda following GitHub - FEniCS/dolfinx: Next generation FEniCS problem solving environment. If I use a 5x5 mesh, it works fine! Rank 0 and 1 have 25 local cells each.