Error locating DOFs geometrically with P2/CR mixed elements

Hi all,

I am working on implementing a version of the linear shell formulation outlined by @bleyerj here (thanks for the fantastic resource!) and adapting it for dolfinx. As he explains, the formulation uses a P2/CR mixed space for displacements and rotations. Unfortunately, I am getting an error when setting up BC’s for this space as is done in the reference (I am using the latest docker build). Here is a MWE:

import dolfinx
import ufl
from mpi4py import MPI

# simple mesh
N = 4
mesh = dolfinx.UnitSquareMesh(MPI.COMM_WORLD, N, N, dolfinx.cpp.mesh.CellType.triangle)

# create mixed element function space
Ue = ufl.VectorElement("Lagrange", mesh.ufl_cell(), 2, dim=3)
Te = ufl.VectorElement("CR", mesh.ufl_cell(), 1, dim=3)
V = dolfinx.FunctionSpace(mesh, ufl.MixedElement([Ue, Te]))

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

# locate dofs
tmpBc = dolfinx.fem.locate_dofs_geometrical(V, clamped_boundary)

The last line generates the following error for me:

[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see FAQ — PETSc 3.20.1 documentation
[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run
[0]PETSC ERROR: to get more information on the crash.
[0]PETSC ERROR: Run with -malloc_debug to check if memory corruption is causing the crash.
application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0
[unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=59
:
system msg for write_line failure : Bad file descriptor

Interestingly, I do not get this error if I use only Ue or Te to build a (non-mixed) function space. Any thoughts on what might be the issue here and/or how I might work around it? I am still somewhat new to FEniCs so apologies if there is anything basic that I’m missing.

Hi,

I think this is related

Télécharger BlueMail pour Android

Indeed, I think you are correct! Should have seen this before, thanks for pointing it out. Looking at the relevant issue (`locate_dofs_geometrical` segfaults on mixedelements · Issue #1764 · FEniCS/dolfinx · GitHub), the following comment is made (@garth):

This should raise an exception since locating dofs on a mixed element doesn’t really make sense since the different sub-elements can have different dof locations.

Based on this, it seems this implementation won’t be supported? Any alternative way to do this? Simply define the BCs based on a non-mixed element, assuming that could even work?

what about the solution proposed in the thread ?
Dolfinx locate _dof's_geometrically fails on mesh imported from gmsh - #2 by dokken

Missed that again, obviously. Yes, the workaround proposed in the thread appears to work for now. Thanks, sorry for the duplicate question.