I want to apply (homogeneous) Dirichlet boundary conditions on BDM elemtents, which are used in a mixed formulation. But this appears to be harder than expected, so I made a minimal example to ask for help.
In the below code, I try to pass a solution through a solve to a solution variable. I invoke DirichletBC on the (zero) function for which BDM elements are used, and this unexpectedly massacres the solution on v (see pictures).
Is this a bug or am I doing something wrong? Thanks in advance!
from dolfin import *
mesh = RectangleMesh(-1., -1., 1, 1, 8, 8, "crossed")
# Prepare function spaces
M = VectorFunctionSpace(mesh, 'BDM', 1)
V = VectorFunctionSpace(mesh, 'DG', 0)
K = FunctionSpace(mesh, 'DG', 0)
Y = MixedFunctionSpace([M, V, K])
ivexp = Expression(("(exp(-pow(x[0], 2)/0.1)*exp(-pow(x[1], 2)/0.1))", "0.0"))
bc = DirichletBC(M, Constant((("0", "0"), ("0", "0"))), "on_boundary")
# Set Test and Trial functions
(sigma, v, r) = TrialFunctions(Y)
(tau, w, q) = TestFunctions(Y)
# Assign initial data
sigma0 = Function(M)
v0 = interpolate(ivexp, V)
r0 = Function(K)
a = (inner(sigma, tau)+inner(v, w)+inner(r, q))*dx
L = (inner(sigma0, tau)+inner(v0, w)+inner(r0, q))*dx
vtk_file = File("results/dbctest.pvd")
y = Function(Y)
vtk_file << v0
solve(a == L, y, bc)
v0.assign(y.sub(1, deepcopy=True))
vtk_file << v0