Periodic BC for 1-d unsteady inviscid burgers equation
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(
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(
# 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(
# 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*
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
Question information
- Language:
- English Edit question
- Status:
- Expired
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply: