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