Optimal Control problems seem quite easy to implement in FEniCS as given on pg 206 in
http://www.pefarrell.org/wp-content/uploads/2015/05/pythonfenics.pdf
If to the sample problem, one needs to make an update to inhomogeneous DirichletBC, the obvious change is
bc_u = DirichletBC(Z.sub(0), ud, "on_boundary")
where ud is the inhomogeneous bc. I am performing research on solvers akin to Andy Wathen's group
http://www.kybernetika.cz/content/2010/2/341/paper.pdf
The problem with the above mixed finite element space implementation of optimal control problems is that the individual blocks of the linear system don't seem to be easily extractable to perform matrix level tests, of preconditioning for example. Or is not the case? Is it possible to extract the individual pieces? Are they even arranged in a conventional saddle point form?
The alternative is to construct the matrices separately by the variational forms. The problem there is, as pointed out in the paper (Pg 344-345) is the implementation of Dirichlet boundary conditions which is problematic. And in this particular case, one of the linear equations deals with two boundary conditions: one for y and the other for \lambda. (Pg 343. eq. 7 ). I am not clear how to implement them and test the preconditioners as given in the paper. Can someone give pointers to an implementation that allows both - a correct boundary condition implementation and an access to individual blocks in a format as eq7 in the paper ?
side note: the paper talks about an issue in implementing Dirichlet BC. I hope FEniCS takes care of that.