DirichletBC for vector elements hit recursion limit

Hi everyone, I’m using FEniCS 2018.1 and vector elements (RT, BDM) give recursion error:

File "/home/nico/anaconda3/envs/fenicsproject/lib/python3.7/site-packages/ufl/cell.py", line 223, in __init__
self._cells = tuple(as_cell(cell) for cell in cells)

File "/home/nico/anaconda3/envs/fenicsproject/lib/python3.7/site-packages/ufl/cell.py", line 223, in <genexpr>
self._cells = tuple(as_cell(cell) for cell in cells)

File "/home/nico/anaconda3/envs/fenicsproject/lib/python3.7/site-packages/ufl/cell.py", line 327, in as_cell
return TensorProductCell(cell)

File "/home/nico/anaconda3/envs/fenicsproject/lib/python3.7/site-packages/ufl/cell.py", line 223, in __init__
self._cells = tuple(as_cell(cell) for cell in cells)

RecursionError: maximum recursion depth exceeded

this is a MWE to raise the error:

from dolfin import *

mesh = UnitSquareMesh(10, 10)
el_s = VectorElement("BDM", mesh.ufl_cell(), 1)
V = FunctionSpace(mesh, el_s)
bc = DirichletBC(V, Constant((0,0), (0,0)), "on_boundary")

I’d be tremendously grateful if anyone has dealt with something similar.

Best regs,
Nicolas

If you really need a finite element of value rank=2 (matrix valued), then you are missing one set of round brackets in Constant. Should be Constant(((0, 0), (0, 0))).

Geez, sorry for not seeing that. I would like something else. As DOFs for these kinds of elements are normal components (usually) I was wondering if there is a way to set this as zero. My real bounday condition is sigma.normal = 0, not sigma=0, but I can’t find a way to impose this. Please let me know if you have any thoughts on this, and thanks again.

Nico

If you provide a GenericFunction to DirichletBC - that is indeed the parent class of Constant, it is interpolated locally (per each cell) into function space where you are applying bcs, i.e. to BDM space. The result of this interpolation is a function in BDM space, and its DOFs are used to set values through DirichletBC.

In other words, vector (0, 0) has normal component zero, so will the DOFs of corresponding BDM/RT space be zero. If you apply bc only to one facet, then only DOFs on that facet will be zero.

(I am interchanging terms “degree-of-freedom” and “expansion coefficient”, but these coincide for nodal elements)