Describe the bug
If a ReducedFunctional is independent of a Control, it returns Cofunction instead of Function.
Steps to Reproduce
Run this script:
from firedrake import *
from firedrake.adjoint import *
import pytest
from numpy.testing import assert_allclose
continue_annotation()
mesh = UnitSquareMesh(4, 4)
R = FunctionSpace(mesh, "R", 0)
Controls = []
for i in range(3):
x = function.Function(R, val=i)
Controls.append(Control(x))
J = assemble(x * x * dx(domain=mesh))
Jhat = ReducedFunctional(J, Controls)
der = Jhat.derivative()
for der0 in der:
print(type(der0))
The type is Cofunction for the first two components.
Describe the bug If a ReducedFunctional is independent of a Control, it returns Cofunction instead of Function.
Steps to Reproduce
Run this script:
The type is Cofunction for the first two components.
Expected behavior
The type should be Function in each case.