Hi,
I have an elementar question. I would like to assembler KKT systems
using the FEniCS project. The code below illustrates my attempt.
from dolfin import *
mesh = UnitSquareMesh(100, 100)
U = FunctionSpace(mesh, "CG", 1) #foward solution space
V = FunctionSpace(mesh, "CG", 1) #ajoint solution space
M = FunctionSpace(mesh, "DG", 0) #control space
Z = MixedFunctionSpace([U, V, M])
z = Function(Z)
(u, lmbd, m) = split(z)
F = inner(grad(u), grad(lmbd))*dx - m*lmbd*dx
x = triangle.x
ud = exp(-1.0/(1.0-x[0]*x[0])-1.0/(1.0-x[1]*x[1]))
J = inner(u - ud, u - ud)*dx + Constant(1e-6)*inner(m, m)*dx
bc_u = DirichletBC(Z.sub(0), 0.0, "on_boundary")
bc_lmbd = DirichletBC(Z.sub(1), 0.0, "on_boundary")
bcs = [bc_u, bc_lmbd]
L = J + F
kkt = derivative(L, z, TestFunction(Z)) # !
KKT = assemble(kkt) # ?
The derivative(L, z, TestFunction(Z)) returns a UFL form.
But the assembler(kkt) is a vector. How can I get the KKT system matrix
and the righ hand side vector? Thank you for your time.
( The documentation for derivative is rather sparse
http://fenicsproject.org/documentation/dolfin/dev/python/programmers-reference/fem/formmanipulations/derivative.html )