The following minimum example tries to solve the problem
curl(curl(A)) = f
A subject to boundary conditions
using curl-conforming Nedelec elements.
For test purposes I set the vector field A to be constant, yielding f = 0.
from fenics import *
def boundary(_, on_boundary):
return on_boundary
mesh = UnitSquareMesh(3, 3)
V = FunctionSpace(mesh, 'Nedelec 1st kind H(curl)', 1)
A = TrialFunction(V)
N = TestFunction(V)
A_D = Constant((0, 1))
bc = DirichletBC(V, A_D, boundary)
f = Constant((0, 0))
a = inner(curl(A), curl(N)) * dx
b = inner(f, N) * dx
A_ = Function(V)
solve(a == b, A_, bc)
print errornorm(A_D, A_, 'Hcurl')
plot(A_, interactive=True)
The result however is entirely wrong.
The norm of the error is between one and two, depending on whether I run FEniCS from a docker image or a self-compiled version, but it is nowhere near zero.
Plotting shows that the result is totally wrong.
The vectors point in all possible directions and their norm varies between zero and hundred on a mesh with 10x10 triangles (the error is then 24.3).
Note, that the test function I use for A is just a constant and thus the error should be zero with respect to machine precision, since it is contained in the space of basis functions.
Surprisingly, the error drops to magnitude 1e-16, when I use a mesh with only 1x1 or 2x2 triangles.
Increasing the number of triangles destroys everything.
Increasing the order of the function space increases the error even further.
What is wrong here?
Replacing the line
V = FunctionSpace(mesh, 'Nedelec 1st kind H(curl)', 1)
with
V = VectorFunctionSpace(mesh, 'Lagrange', 1)
solves the problem exactly, but is not what we want / need.
print dolfin.__version__
2016.1.0
Thanks in advance.