Dolfinx locate _dof's_geometrically fails on mesh imported from gmsh

This has nothing to do with the mesh, but rather with using the mixed space in locate_dofs_geometrical.
I’ve made an issue at: `locate_dofs_geometrical` segfaults on mixedelements · Issue #1764 · FEniCS/dolfinx · GitHub
and I’ll have a look into it.

A work-around for now is to spilt the boundary condition into the sub spaces, and use locate_dofs_geometrical on those:

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

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

mesh =dolfinx.UnitSquareMesh(MPI.COMM_WORLD, 10, 10)
deg = 1
We = ufl.FiniteElement("Lagrange", mesh.ufl_cell(), deg)
Te = ufl.VectorElement("Lagrange", mesh.ufl_cell(), deg)
V = dolfinx.FunctionSpace(mesh, ufl.MixedElement([We,Te]))
Vs = [V.sub(i).collapse() for i in range(V.num_sub_spaces())]
dofs = [dolfinx.fem.locate_dofs_geometrical((V.sub(i), Vs[i]), clamped_boundary) for i in range(V.num_sub_spaces())]
print(dofs)
2 Likes