Dofmap[icell] and links(icell) return different local connectivities in parallel

For this particular mesh of dimension cdim=2, when ran in parallel across 3 processors, the local connectivities obtained from domain.geometry.dofmap[icell] and domain.topology.connectivity(cdim,0).links(icell) are different for icell=3 on the first (zeroth) rank:

from dolfinx import mesh
from mpi4py import MPI
import numpy as np

comm = MPI.COMM_WORLD
rank = comm.Get_rank()

tdim = 2
domain = mesh.create_unit_square(
    MPI.COMM_WORLD, 4, 4, mesh.CellType.triangle, dtype=np.float64,
)
domain.topology.create_connectivity(tdim,0)
cpc = domain.topology.connectivity(tdim,0)
if (rank == 0):
    icell = 3
    local_nodes_con    = cpc.links(icell)
    local_nodes_dofmap = domain.geometry.dofmap[icell]
    print(f"incident nodes 3rd element:\n",
          f"As computed from connectivity : {local_nodes_con}\n",#[9 1 3]
          f"As computed from dofmap : {local_nodes_dofmap}",)#[8 1 3]

The correct nodes of the cell are [8, 1, 3] but domain.topology.connectivity(cdim,0).links(3) outputs [9,1,3]. Note that both nodes 8 and 9 are ghost nodes.

I tried this from the latest commit and from a commit from the 23rd of September.

Am I doing something wrong?

The geometry and topology dofmap does not necessarily use the same ghost ordering.

You need to use the function dolfinx.mesh.entities_to_geometry to map vertices to geoemtry nodes. See for instance

1 Like