Free-Slip Boundary Condition in Fluid Flow

In close alignment to Component-wise Dirichlet BC — FEniCSx tutorial by J.S. Dokken, I would like to do the same with Raviart-Thomas elements.
Consider this example, where the displacement in x-direction at the right boundary is set to zero:

import numpy as np
from dolfinx import fem, mesh
from mpi4py import MPI
from ufl import FiniteElement
from petsc4py.PETSc import ScalarType

msh = mesh.create_unit_square(MPI.COMM_WORLD, 10, 10)
V = fem.FunctionSpace(msh, FiniteElement("RT", msh.ufl_cell(), 1))

boundary_facets = mesh.locate_entities_boundary(msh, msh.topology.dim-1, lambda x: np.isclose(x[0], 1))
boundary_dofs_x = fem.locate_dofs_topological(V.sub(0), msh.topology.dim-1, boundary_facets)

bc = fem.dirichletbc(ScalarType(0), boundary_dofs_x, V.sub(0))

However this produces the error:

File "/usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/fem/function.py", line 501, in sub
    assert self.ufl_element().num_sub_elements() > i
AssertionError

This error does not appear with Lagrange elements.
Why is that and how can I still apply the same boundary condition strongly (weakly is not an option)?

A R-T element has no x-component to constrain. Consider

and for instance the basis functions:


Then you see that the basis function is vector valued. I.e. there is only three degrees of freedom, that are scalar valued.

u_h=\sum_{i=0}^2 c_i \mathcal{F}^{\mathrm{div}}\phi_i(x)
where \mathcal{F}^{\mathrm{div}} is the contravariant Piola mapping, see for instance: DefElement

2 Likes