Hi,
I am trying to implement DG-Fem for the Poisson equation. Here flux term is calculated using the Two-Point Flux Approximation scheme.(Reference Paper)
Find u_h \in V_h such that
\int_{\Gamma_{int}} [v]\frac{[u]}{|| h^+ - h^- ||} dS = \int_{\Gamma_N} v_h ds + \int_{\Omega} fv_h dx for all v_h \in V
Here h^+ and h^- is the center of the current cell and neighboring cell respectively.
Now I have implemented the same:
V = FunctionSpace(mesh,"DG",0)
bc = DirichletBC(V, Constant(0), "near(x[0],0.0) || near(x[0],1.0)")
f = Expression("10*exp(-(pow(x[0]-0.5,2) + pow(x[1]-0.5,2))/0.02)", degree=1)
g = Expression("sin(5*x[0])", degree=1)
x_ = interpolate(Expression("x[0]", degree=1),V)
y_ = interpolate(Expression("x[1]",degree=1),V)
Delta_h = sqrt(jump(x_)**2 + jump(y_)**2)
u = TrialFunction(V)
v = TestFunction(V)
a = jump(u)/Delta_h*jump(v)*dS
L = f*v*dx + g*v*ds
u = Function(V)
solve(a==L, u, bc)
plt_u = plot(u)
cbar = plt.colorbar(plt_u)
Output:
The same is implemented using CFEM as follows:
from dolfin import *
import matplotlib.pyplot as plt
plt.rcParams['image.cmap'] = 'jet'
mesh = UnitSquareMesh(16,16,"left")
V = FunctionSpace(mesh, "CG", 1)
bc = DirichletBC(V, Constant(0), "near(x[0],0) || near(x[0],1)")
f = Expression("10*exp(-(pow(x[0]-0.5,2) + pow(x[1]-0.5,2))/0.02)", degree=1)
g = Expression("sin(5*x[0])", degree=1)
u = TrialFunction(V)
v = TestFunction(V)
a = inner(grad(u), grad(v))*dx
L = f*v*dx + g*v*ds
u = Function(V)
solve(a==L, u, bc)
plt_u = plot(u)
cbar = plt.colorbar(plt_u)
Output:
In the case of DG-Fem, output is wrong. Could you please tell me what wrong I am doing here?
Thank you,
Ranjeet