# Boundary conditions for vector elements (RT, BDM)

**URL:** <https://fenicsproject.discourse.group/t/boundary-conditions-for-vector-elements-rt-bdm/1873>\
**Category:** Uncategorized\
**Created:** [November 10, 2019, 10:50pm UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-vector-elements-rt-bdm/1873 "2019-11-10T22:50:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nabarnaf](https://avatars.discourse-cdn.com/v4/letter/n/dec6dc/32.png) [@nabarnaf](https://fenicsproject.discourse.group/u/nabarnaf)\
**Post date:** [November 10, 2019, 10:50pm UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-vector-elements-rt-bdm/1873/1 "2019-11-10T22:50:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![volkerk](https://avatars.discourse-cdn.com/v4/letter/v/9d8465/32.png) [@volkerk](https://fenicsproject.discourse.group/u/volkerk)\
**Post date:** [November 11, 2019, 9:53am UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-vector-elements-rt-bdm/1873/2 "2019-11-11T09:53:46Z")

</div>

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.

```python
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()[:])

```

---

<div class="post-metadata">

**Author:** ![nabarnaf](https://avatars.discourse-cdn.com/v4/letter/n/dec6dc/32.png) [@nabarnaf](https://fenicsproject.discourse.group/u/nabarnaf)\
**Post date:** [November 13, 2019, 8:33pm UTC](https://fenicsproject.discourse.group/t/boundary-conditions-for-vector-elements-rt-bdm/1873/3 "2019-11-13T20:33:10Z")

</div>

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))
