# Boundary conditions for vector elements (RT, BDM)

Hi community,

This is more of a theoretical concern. Regarding vector elements which have dofs on th normal components (RT, BDM), typical boundary conditions are of type
u.n = f
i.e, something on the normal component. Now, implementations all around fenics are done by imposing something on the entire vector, such as
DirichletBC(V.sub(u_component), Constant((1,2,3)), “on_boundary”),
where I’m assuming that u is a vector. So my question is, does this assign only the corresponding dof, meaning that if u_D=(1,2,3), in this case I would get
u.n = (1,2,3).n
or does it set dofs somehow differently? Thanks for your help, and sorry but I couldn’t find anything related on the documentation.

Best regards

Pd: The same would apply to curl elements w.r.t curl boundary conditions.

The boundary dofs in the BDM/RT spaces are the normal components. These dofs are set to the value of the Expression in the DirichletBC when applying it, see e.g. the below example.

from dolfin import *

mesh = UnitSquareMesh(5,5)
n = FacetNormal(mesh)

V = FunctionSpace(mesh, 'BDM', 1)

bc = DirichletBC(V, Constant((0,0)), 'on_boundary')

g = Expression(('x[0]+1','x[1]+1'), degree=1)

u = project(g, V)

print(assemble(inner(u,n)**2*ds))
print(u.vector()[:])

bc.apply(u.vector())

print(assemble(inner(u,n)**2*ds))
print(u.vector()[:])


Thank you Volkerk, my problem was with Tensor spaces but what you say is of course still true. I will just elaborate so that this is useful for someone who encounters this afterwards: It seems like internally when you give a function G to a bc of a Vector type of element (RT, BDM), it applies the condition like this:
sigma . n = G . n
so that it doesn’t actually interfere with the function outside those dofs. I added the tensor example to your script, and I will just leave it here. Thanks again!

from dolfin import *

# Vector test

mesh = UnitSquareMesh(8,8)
n = FacetNormal(mesh)

V = FunctionSpace(mesh, ‘BDM’, 1)

bc = DirichletBC(V, Constant((0,0)), ‘on_boundary’)

g = Expression((‘x[0]+1’,‘x[1]+1’), degree=1)

u = project(g, V)
plot(u)
print(assemble(inner(u,n)**2*ds))

bc.apply(u.vector())
plot(u)

print(assemble(inner(u,n)**2*ds))

# Tensor test

V_ten = VectorFunctionSpace(mesh, ‘BDM’, 1)

bc_ten = DirichletBC(V_ten, Constant(((0,0), (0,0))), ‘on_boundary’)

g_ten = Expression(((‘x[0]+1’,‘x[1]+1’), (‘x[0]-1’,‘x[1]-1’)), degree=1)

u = Function(V_ten)
u.interpolate(g_ten)
plot(u.sub(0))
plot(u.sub(1))

arg = as_vector([dot(u.sub(0),n), dot(u.sub(1),n)]) # Required, known bug
print(assemble(inner(arg,arg)**2*ds))

bc_ten.apply(u.vector())
plot(u.sub(0))
plot(u.sub(1))

arg = as_vector([dot(u.sub(0),n), dot(u.sub(1),n)])
print(assemble(inner(arg,arg)**2*ds))