I am trying to construct a simple upwind scheme, using DG0 and RT1 elements.
What is the best way to do this? I have managed to get something that seems to work,
but it seems a very inelegant way to perform a simple calculation.
from dolfin import *
# mesh with one internal boundary
mesh = UnitSquareMesh(1,1)
RT = FunctionSpace(mesh, "RT", 1)
DG = FunctionSpace(mesh, "DG", 0)
# velocity
U = Function(RT)
# advected quantity (1 in left cell, 2 in right cell)
C = Function(DG)
C.interpolate(Expression("(x[0]>0.5)+1.0"))
n = FacetNormal(mesh)
un = dot(U,n)
up = (un + abs(un))/2.0
um = (un - abs(un))/2.0
Ct = TestFunction(DG)
flux = ((up*Ct*C)('+') + (up*Ct*C)('-') + (um*Ct)('+')*C('-') + (um*Ct)('-')*C('+'))*dS
U.interpolate(Constant((0.1,0.0)))
print assemble(flux).array()
U.interpolate(Constant((-0.1,0.0)))
print assemble(flux).array()