In an attempt to become familiar with discontinuous Galerkin methods, I tried to derive the weak form for the simple Poisson equation, as used in the code here
# Define variational problem (ds(1) is Dirichlet, ds(2) is Neumann)
a = dot(grad(v), grad(u))*dx \
- dot(avg(grad(v)), jump(u, n))*dS \
- dot(jump(v, n), avg(grad(u)))*dS \
+ alpha/h_avg*dot(jump(v, n), jump(u, n))*dS \
- dot(grad(v), u*n)*ds(1) \
- dot(v*n, grad(u))*ds(1) \
+ (gamma/h)*v*u*ds(1)
L = v*f*dx - u0*dot(grad(v), n)*ds(1) + (gamma/h)*u0*v*ds(1) + g*v*ds(2)
I used a FEniCS lecture as a guide, which can be found here, and I understand the derivations made there. I will repeat the weak form from those slides below:
$$
\int_{\Omega} \nabla u \cdot \nabla v dx + \int_{\Gamma_i} \left( - \langle\nabla u\rangle[v] - \langle\nabla v\rangle[u] + \frac{\alpha}{h}[u][v] \right) dS + $$ $$\int_{\Gamma_e} \left( - \nabla u \cdot n v - \nabla v \cdot n u + \frac{\alpha}{h} u v \right) ds = \int_{\Omega} f v dx
$$
My question now is how to go from here to the form above? This is what I got so far:
- Add the terms containing gamma on both sides to weakly enforce the Dirichlet boundary condition.
- Split the external boundary in a Dirichlet and a Neumann part, and use
dot(grad u, n) = g
on the Neumann boundary
Doing so also results in term $\int_{\Gamma_N} \nabla v \cdot n u$ that is not accounted for in the code. I also miss a term with alpha on the external boundaries.
On the other hand, I cannot explain where the second term on the RHS comes from (u0*dot(grad(v), n)*ds(1)
), neither why terms containing a testfunction v
on the Dirichlet boundary don't disappear.
Any help on this would be very welcome.