This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

DG advection in periodic domain

+3 votes

Hi
I am trying to use DG method with FEnics. it doesnt work at all. I dont know if it is problem of periodic BC?

from dolfin import *
mesh = UnitInterval(16)
c0=Expression('exp(-pow((x[0]-0.5),2)/0.025)')

# Sub domain for Periodic boundary condition
class PeriodicBoundary(SubDomain):

    def inside(self, x, on_boundary):
        return bool(x[0] < DOLFIN_EPS and x[0] > -DOLFIN_EPS and on_boundary)

    def map(self, x, y):
        y[0] = x[0] - 1.0

# Create function space constrained by periodic BC
pbc = PeriodicBoundary()
V = FunctionSpace(mesh, 'DG', 1, constrained_domain=pbc)

c=TrialFunction(V)
v=TestFunction(V)

a_M = c*v*dx
M=assemble(a_M)

# Define normal component, mesh size and right-hand side
n = FacetNormal(mesh)

c=Function(V)

c_1=interpolate(c0,V)
c.assign(c_1)

k=[]
for i in range(4):
    k.append(Function(V))

T = 0.002
t = 0
dt =0.001
alpha=0
co=(1.-alpha)/2.
while t<=T:
    flux = avg(c)+co*jump(c)
    a=v*c.dx(0)*dx - dot(n,flux*v)*dS 
    b=assemble(a)
    solve(M,k[0].vector(),b)

    c.vector()[:]=k[0].vector()
    t += dt
    plot(c,rescale=False)
asked Sep 11, 2013 by waynezw0618 FEniCS Novice (450 points)
edited Sep 15, 2013 by Garth N. Wells

I wondered about this too. Apparently it does not work. See here. I would be interested in getting it to work though.

1 Answer

+2 votes
 
Best answer

Discontinuous Lagrange elements + periodic boundary conditions are not presently supported.

answered Sep 11, 2013 by Garth N. Wells FEniCS Expert (35,930 points)
selected Sep 14, 2013 by Jan Blechta
Advection in periodic domain using DG
...