← Back to team overview

dolfin team mailing list archive

[Question #159864]: Periodic BC for 1-d unsteady inviscid burgers equation

 

New question #159864 on DOLFIN:
https://answers.launchpad.net/dolfin/+question/159864

Hello all

I wrote a DG code for 1-d burgers equation and I want to use periodic BC. The code below is doing forward euler time stepping. I cant figure out where to apply periodic BC.

Thanks
praveen


# Sub domain for Dirichlet boundary condition
class Boundary(SubDomain):
   def inside(self, x, on_boundary):
      return (x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS) and on_boundary

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

# Initial condition
u0 = Expression("sin(2*pi*x[0])")

# Load mesh
mesh = UnitInterval(100)

# Defining the function spaces
V = FunctionSpace(mesh, "DG", 1)

# Periodic boundary condition
bc = PeriodicBC(V, Boundary())

# Test and trial functions
phi = TestFunction(V)
uh  = TrialFunction(V)


uold = Function(V)  # previous solution
u    = Function(V)  # current solution

# Set initial condition
u = project(u0, V)

# Mesh-related functions
n = FacetNormal(mesh)
un = dot(u, n)

# Numerical flux function - Roe flux
Hn = 0.25*(u('+')**2 + u('-')**2) - 0.5*abs(un('+')+un('-'))*(u('-') - u('+'))

# Mass matrix
M = uh*phi*dx
MMat = assemble(M)

dt = 0.001 # time step
T  = 0.05  # final time
t  = 0.0   # time counter

# RHS
R = uold*phi*dx + dt*0.5*u**2*phi.dx(0)*dx - dt*Hn*jump(phi)*dS

ufile = File("u.pvd")
ufile << u

while t < T + DOLFIN_EPS:
   uold.assign(u)
   rhs = assemble(R)
   solve(MMat, u.vector(), rhs)
   t += dt
   print t
   ufile << u


-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.