Imposing strong Dirichlet boundary condition for discontinuous Galerkin method in one dimension
Hi all,
I ran into trouble when I was trying to solve a simple poisson equation "-Laplacian(u) = f" using discontinuous galerkin method. An example code in Python is copied below:
"...
mesh = UnitInterval(2**6)
nu = FacetNormal(mesh)
h = CellSize(mesh)
h_avg = (h('+') + h('-'))/2.0
V = FunctionSpace(mesh, 'DG', 1)
class Boundary(
def inside(self, x, on_boundary):
bc = DirichletBC(V, Constant(0), Boundary(), 'geometric')
alpha=4.0
u = TrialFunction(V)
v = TestFunction(V)
a = dot(grad(u), grad(v)) *dx\
- dot(jump(u,nu), avg(grad(v))) *dS\
- dot(avg(grad(u)), jump(v,nu)) *dS\
+ alpha/h_avg * dot(jump(u,nu), jump(v,nu))*dS
f = Expression(
L = f*v*dx
u = Function(V)
solve(a == L, u, bc)
..."
The error message is :
*** Error: Unable to determine if given point is on facet.
*** Reason: Not implemented for given facet dimension.
*** Where: This error was encountered inside DirichletBC.cpp.
I guess it's not allowed to impose strong Dirichlet boundary condition for DG in one dimension? For this problem, I can impose the boundary function weakly. However, if the Dirichlet boundary is not homogeneous, say "0" on the left end and "1" on the right end, I will have to impose some sort of strong boundary condition. Can it be done or avoided at all in 1D?
Thank you very much!
Xiaoxian
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Jan Blechta
- Solved:
- Last query:
- Last reply: