I am trying to implement a simple mass conservation equation:
$\frac{dh}{dt} + \frac{dq}{dx}= a$
on [0,1], where q=u*h. I set h=1 on the first half of the domain (x<0.5) and zero on the second half. Setting u=1 and a=1, I expect this shock to simply move to the right. I have implemented this UFL file:
cell = interval
element = FiniteElement("Discontinuous Lagrange", cell, 2)
h = TrialFunction(element)
phi = TestFunction(element)
ac = Coefficient(element)
u = Coefficient(element)
h0 = Coefficient(element)
dt = Constant(cell)
flux = h*u
a = phi*h/dt*dx - phi.dx(0)*flux*dx + phi("+")*flux("+")*dS - phi("-")*flux("-")*dS
L = phi*h0/dt*dx + ac*phi*dx
but when I implement the test case described above the solution blows up at the shock.
I don't think I've implemented the weak form correctly --- how should I represent the flux between elements?
Thanks!