You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tangent linear model of Function.assign from an AdjFloat fails with AttributeError #5782
When a Function is assigned from an AdjFloat control, rf.derivative() works but rf.tlm(h) and rf.hessian(h) fail with AttributeError: 'AdjFloat' object has no attribute 'ufl_function_space'. This happens in serial, for CG and R target spaces.
The derivative prints 1.0 up to round-off, as expected. The TLM call should also give 1.0, but it raises
File ".../firedrake/adjoint_utils/blocks/assembly.py", line 137, in evaluate_tlm_component
dform += firedrake.action(firedrake.derivative(form, c_rep),
...
File ".../ufl/algorithms/formtransformations.py", line 480, in compute_form_action
elif coefficient.ufl_function_space() != fs:
AttributeError: 'AdjFloat' object has no attribute 'ufl_function_space'
I see this on main (b6bbb54) and on release (881e99d), with pyadjoint 1b85329.
As far as I can tell the cause is FunctionAssignBlock.evaluate_tlm_component in firedrake/adjoint_utils/blocks/function.py. For an assignment without an expression it returns tlm_inputs[0] as the TLM of the output, so the TLM of the Function is the AdjFloat tangent of the control. The next block then fails when it uses it as a Function. Assigning from a Real Function to a CG Function has the same problem in a milder form: the TLM of the CG Function is then a Real Function, which happens to give the right numbers in assemble.
Activity