Creation of Functionspace on submesh of codimension 1 raises ValueError

Hi all,

please consider the following MWE:

from mpi4py import MPI
from dolfinx import mesh, fem
from basix.ufl import element
import numpy as np


def main():
    n = 6
    domain = mesh.create_unit_square(MPI.COMM_WORLD, n, n, mesh.CellType.quadrilateral)
    tdim = domain.topology.dim
    fdim = tdim - 1

    def right(x):
        return np.isclose(x[0], 1.)

    facets = mesh.locate_entities_boundary(domain, fdim, right)
    submesh, entity_map, vertex_map, geom_map = mesh.create_submesh(domain, fdim, facets)

    degree = 1
    fe = element("P", submesh.basix_cell(), degree, shape=())
    V = fem.functionspace(submesh, fe) # raises ValueError


if __name__ == "__main__":
    main()

I am currently on dolfinx version 0.7.1 and get ValueError: Non-matching UFL cell and mesh cell shapes.
If the submesh is of codimension 0, i.e. the submesh also consists of quadrilaterial cells, it works.

Is this a bug?

Best wishes,
Philipp

Hi @dokken ,
sorry for the direct mention, but is this question somehow ill-posed? How could I improve / rephrase the question to receive an answer?

For reference, I get the same error dropping mesh.CellType.quadrilateral from the mesh creation line, i.e. with a triangular mesh. cc @jpdean who may have further insights.

Im not at my computer, but my best guess is that you are missing gdim=submesh.geometry.dim as this will be a space on a manifold.

Hi @dokken, @francesco-ballarin thank you both for your replies.

Indeed, setting

fe = element("P", submesh.basix_cell(), degree, shape=(), gdim=2)

resolves the issue.
It now makes sense to me. The submesh with cell type “interval” has topological dimension 1, but is embedded in 2D space and therefore submesh.geometry.dim equals 2.

Best,
Philipp