This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

DirichletBC on BDM elemts in mixed formulation

0 votes

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!

Initial solution
Solution after solve

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
asked Aug 17, 2015 by stevenvdk FEniCS User (1,590 points)

1 Answer

+1 vote

I can't reproduce the second figure with dolfin master.

Anyway, the definition of the BC should probably be

bc = DirichletBC(Y.sub(0), Constant((("0", "0"), ("0", "0"))), "on_boundary")
answered Aug 17, 2015 by Magne Nordaas FEniCS Expert (13,820 points)

Idd that was the problem. I was too focused on the BDM elements to think about this solution.
Thanks!

...