1D discontinuous galerkin boudary conditions

Hi all! I am recently trying to solve the 1D advection equations with discontinuous galerkin method. The 1D boudary conditions is not working properly. The attached is the code that explains the problem:

m_size = 32
mesh = UnitIntervalMesh(m_size)

beta = Constant((0.5,))

parameters[“ghost_mode”] = “shared_facet”

V_dg = FunctionSpace(mesh, ‘DG’, 2)
phi, v = TrialFunction(V_dg), TestFunction(V_dg)
u_new, u_old = Function(V_dg), Function(V_dg)

u0 = Expression(“sin(2pix[0])”, degree=1, t=0, name=‘u0’) #
u_old = project(u0, V_dg)

u_exact = Expression("sin(2pi(x[0] - c*t)) ", degree=2, t=0, c=float(beta[0])) #

bcs = DirichletBC(V_dg, u_exact, “on_boundary”)

u_exact.t = 0.1
bcs.apply(u_old.vector())
print(u_old(0))

Is there a problem with the boundary conditions definition or application? Thanks a lot in advance!

Hi, it would make your question more readable if you could encapsulate your code between ``` .

This being said, boundary conditions must be imposed ‘‘weakly’’ in Discontinuous Galerkin discretizations. There is a very good package dolfin-dg that makes these things easier, the paper where the authors introduce it is also a good reference, you can check the references in there.

Thanks a lot for your reponse! I will encapsulate my code in the later questions!

Is there a reference that you may recommend where the reasonings behind why BC can only be imposed weakly for DG?

Thanks!

The paper by Nitsche and the classic review paper by Arnold et al.