-
Notifications
You must be signed in to change notification settings - Fork 177
Closed
Labels
Description
The implementation of the _ad_dot inner product for Functions in H1 appears to be missing a grad
from firedrake import *
mesh = UnitSquareMesh(1, 1)
V = FunctionSpace(mesh, "CG", 1)
u = Function(V)
print(u._ad_dot(u, options={'riesz_representation': 'H1'}))
produces:
Traceback (most recent call last):
File "/home/skramer/fda/src/firedrake/tst.py", line 6, in <module>
print(u._ad_dot(u, options={'riesz_representation': 'H1'}))
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/skramer/fda/src/firedrake/firedrake/adjoint_utils/function.py", line 272, in _ad_dot
+ firedrake.inner(firedrake.grad(self), other))*firedrake.dx)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/skramer/fda/lib/python3.13/site-packages/ufl/operators.py", line 213, in inner
return Inner(a, b)
File "/home/skramer/fda/lib/python3.13/site-packages/ufl/tensoralgebra.py", line 163, in __new__
raise ValueError(f"Shapes do not match: {ufl_err_str(a)} and {ufl_err_str(b)}")
ValueError: Shapes do not match: <Grad id=139918000025952> and <Coefficient id=139918254987792>
as there should have been a firedrake.grad(other) on line 272 of firedrake/adjoint_utils/function.py
This is used a.o. in the ROLVector dot() method
Happy to provide a (trivial) PR - should this go in release?