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

Neumann Boundary Conditions with Raviart-Thomas Elements

+1 vote

I am solving a system of PDEs on the unit square, where one of the unknowns, a vector field $\mathbf{q}$, must satisfy the boundary condition

$$ \mathbf{q} \cdot \mathbf{n} = 1 $$

on the "lower" or "southern" boundary. If I use a vector function space of Lagrange elements, enforcing this boundary condition is simple, since I only need to enforce that the y component be equal to -1 on that boundary. However, I want to implement this using Raviart-Thomas elements, and am right now enforcing the boundary conditions weakly. Is there a way to force the normal component to be equal to 1 explicitly, using these elements?

asked Aug 11, 2016 by sentz2 FEniCS Novice (140 points)

So do you find a solution about the boundary condition

q⋅n=1?

1 Answer

0 votes

In mixed methods, Neumann boundary conditions become essential boundary condition. In other words, you need to impose them to function space "strongly".


from dolfin import *
import numpy u_0 = Expression('exp(x[1]) + 1')
u_ex = Expression('exp(x[0])exp(x[1]) + x[0]x[1] + 1')
sigma_ex = Expression(('exp(x[0])exp(x[1]) + x[1]', 'exp(x[0])exp(x[1]) + x[0]'))
f = Expression('2exp(x[0])exp(x[1])')
G = Expression(("exp(x[0])exp(x[1]) + x[1]", "exp(x[0])exp(x[1]) + x[0]")) mesh = UnitSquareMesh(nx,nx)
Mh = FunctionSpace(mesh, "RT", 1)
Vh = FunctionSpace(mesh, "DG", 0)
V = MixedFunctionSpace([Mh, Vh]) n = FacetNormal(mesh)
class Nbdy(SubDomain):
def inside(self, x, on_boundary):
return on_boundary and ((abs(x[1]-1.) < tol) or (abs(x[0]-1.) < tol) or (abs(x[1]) < tol))
bc = DirichletBC(V.sub(0), sigma_ex, Nbdy()) (tau, v) = TestFunctions(V)
(sigma, u) = TrialFunctions(V)
a = inner(sigma, tau)dx + udiv(tau)dx + div(sigma)vdx
L = f
vdx + u_0inner(tau, n)*ds su = Function(V)
solve(a == L, su, bc)
(sigma, u) = su.split() u_error = errornorm(u_ex, u, norm_type = 'L2')
sigma_error = errornorm(sigma_ex, sigma, norm_type = 'L2')
answered Oct 4, 2016 by JeonghunLee FEniCS User (1,050 points)

I am confusing about your answer.

Would you please express your code more clear?
Thanks a lot!

...