DirichletBC does nothing for DG spaces

Issue #511 invalid
Stephan Schmidt created an issue

if I define a Dirichlet boundary condition on a DG space and apply it to a vector, nothing happens at all.

Please see attached minimal example. If you change the space to "CG", the result is as expected: All boundary dofs are 1. But if you leave it as "DG", no boundary condition is applied whatsoever...

from dolfin import *

mesh = UnitSquareMesh(100,100)

NSpaceS = FunctionSpace(mesh, "DG", 1)
N2 = Function(NSpaceS)
bc = DirichletBC(NSpaceS, 1.0, "on_boundary")
bc.apply(N2.vector())
File("./Test/N2.pvd", "compressed") << N2

Comments (3)

  1. Lawrence Mitchell

    You probably want:

    bc = DirichletBC(NSpaceS, 1.0, "on_boundary", method="geometric")
    

    Which sets those nodes whose basis functions don't vanish at the boundary, rather than the default (topological) which only sets nodes for basis functions topologically associated with the boundary.

  2. Log in to comment