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

Finite element and boundary conditions

0 votes

Hi,

I've run a simply poisson script similar to the poisson.py demo (see below). It solves the poisson equation on a square mesh. A boundary condition is defined on one side of the mesh.

My question is: How does the finite element method treat the other three sides of the mesh without boundary conditions? I am used to working with a finite difference scheme, where boundary conditions are set all around the mesh. Typically, a sufficiently large mesh is used to simulate dirichlet boundary conditions at infinity. Is something similar happening here?

from dolfin import *

# Create mesh and define function space 
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, "Lagrange", 1)

# Define Dirichlet boundary (x = 0 or x = 1)
def boundary(x):
    return x[0] < DOLFIN_EPS

# Define boundary condition
u0 = Constant(0.0)
bc = DirichletBC(V, u0, boundary)

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(1.0)
a = inner(grad(u), grad(v))*dx
L = f*v*dx

# Compute solution
u = Function(V)
solve(a == L, u, bc)

# Save solution in VTK format
file = File("poisson.pvd")
file << u
asked Nov 12, 2016 by sixtysymbols FEniCS User (2,280 points)

In the above problem you are applying a zero Neumann boundary conditions in the other sides.

1 Answer

+1 vote

Fully agree on the comment by hernan_mella. To see why, derive the weak form for the Poisson equation (in domain $ \Omega$, having boundary $ \partial \Omega$) by multiplying with a test function $v$ and performing integration by parts on the Laplace operator. The latter implies:

$$ \int_\Omega -\nabla^2u v \text{d}\Omega= \int_\Omega \nabla u \cdot \nabla v \text{d}\Omega - \oint_{\partial \Omega} \nabla u \cdot n v \text{d}\varGamma $$

Apparently, the Neumann boundary condition appears naturally in the weak formulation. Hence, omitting this term without specifying any other boundary condition (on the three remaining sides of the domain in your example), means you implicitly satisfy the homogeneous Neumann boundary condition there (i.e. $\nabla u \cdot n = 0$). See also the documentation for demo_poisson.py.

answered Dec 1, 2016 by jmmal FEniCS User (5,890 points)
...