Skip to content

Add error check for out of bounds vertex indices in mesh generation #4053

@schnellerhase

Description

@schnellerhase

Following MWE missed a mesh vertex in the definition of x. Crashes with a hard to debug error of

MPI_ERR_RANK: invalid rank
from mpi4py import MPI
import numpy as np
import ufl
import basix
import dolfinx
import basix.ufl

x = np.array([[1, 0], [2, 0]], dtype=np.float64) # missed [3, 0]
cells = np.array([[0, 1], [1, 2]], dtype=np.int64)

element = ufl.Mesh(basix.ufl.element("Lagrange", "interval", 1, shape=(2,)))
mesh = dolfinx.mesh.create_mesh(MPI.COMM_WORLD, cells, element, x) # <- crashes here

In a Debug build this hits the assertion in MPI.h::index_owner. A similar output should be available in Release - but not raised from index_owner due to performance impact - rather as an input argument check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions