- changed status to duplicate
DirichletBC expressions evaluated at the interior
Issue #360
duplicate
(From http://fenicsproject.org/qa/1033/dirichletbc-expressions-evaluated-away-from-the-boundary.)
When using an Expression
for Dirichlet boundary conditions, this expression is not only evaluated at boundary points but also on the interior on the domain. This should be avoided since Expression
might be very expensive to compute, or might not even be properly defined anywhere else except on the boundary.
MWE:
from dolfin import *
from matplotlib import pyplot as pp
class MyExpensiveBoundaryExpression(Expression):
def eval(self, values, x):
values[0] = 0.0
pp.plot(x[0], x[1], 'xk')
return
my_expr = MyExpensiveBoundaryExpression()
mesh = UnitSquareMesh(10, 10)
V = FunctionSpace(mesh, 'CG', 2)
u = TrialFunction(V)
v = TestFunction(V)
a = dot(grad(u), grad(v)) * dx
L = v * dx
bcs = DirichletBC(V, my_expr, 'on_boundary')
sol = Function(V)
solve(a == L, sol, bcs=bcs)
pp.show()
Comments (2)
-
-
reporter As noted by @simon_funke in bug #219, this is probably a different issue. Both may be solved though if we have function spaces on subdomains.
- Log in to comment
Duplicate of #219.