Open jrmaddison opened 9 months ago
Some related bugs
from firedrake import *
import ufl
mesh = UnitIntervalMesh(10)
space = FunctionSpace(mesh, "Lagrange", 1)
test = TestFunction(space)
u = Function(space, name="u").interpolate(Constant(1.0))
c = Constant(1.0, name="c")
form = c * assemble(inner(u, test) * dx)
# assert c in ufl.algorithms.extract_type(form, type(c)) # Unexpected fail
form = ufl.replace(form, {c: Constant(2.0)})
# assert tuple(map(float, form.weights())) == (2.0,) # Unexpected fail
assert tuple(map(float, form.weights())) == (1.0,) # Unexpected pass
Describe the bug Differentiating a
FormSum
with respect to aCofunction
discards the weight.Steps to Reproduce The following sets
u_star
equal to the domain integration cofunction.formsum
is a linear combination of aForm
and aCofunction
, and is equal to zero.displaying
assemble(assemble(formsum)(u))=-1.1102230246251565e-15
. Howeverdisplays
assemble(der(u))=1.0
, instead of the correct value-2.0
.Similarly
print(f"{str(formsum)=}")
displaysstr(formsum)='{ 2 * w₂ * (conj((v_0))) } * dx(<Mesh #1>[everywhere], {})\n + u_star'
, without the weight.Expected behavior The weight should be included in the derivative.
Error message No error.
Environment: Ubuntu 22.04, Firedrake built today.