Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: domain of Constant not preserved in adjoint replay #3009

Closed
stephankramer opened this issue Jun 27, 2023 · 0 comments · Fixed by #3024
Closed

BUG: domain of Constant not preserved in adjoint replay #3009

stephankramer opened this issue Jun 27, 2023 · 0 comments · Fixed by #3024
Labels

Comments

@stephankramer
Copy link
Contributor

Describe the bug
When assigning to a Constant T the value of a Constant S on a different domain, it appears that in the replay the checkpointed value of T after the assignment has taken the domain of S. I think this is because the checkpointed value of T just points to the checkpointed value of S (through a DeferredCheckpoint). This means T ends up on the wrong domain.

Steps to Reproduce
Consider the following example where S is on a normal FEM mesh, and T is on a vertexonly mesh mesh0. The functional integrates T over mesh0. This works correctly in the initial run of the model, but in the replay it errors in the assembly of that integral complaining NotImplementedError: Assembly with multiple meshes is not supported and digging into the 0-form it's trying to assemble at that point it does appear that the checkpointed value of T it is using there is on mesh instead of mesh0

from firedrake import *
from firedrake_adjoint import *
mesh = UnitSquareMesh(10,10)
mesh0 = VertexOnlyMesh(mesh, [[.5,.5]])
S = Constant(1.0, domain=mesh)
T = Constant(2.0, domain=mesh0)
T.assign(S)
J = assemble(T*dx(domain=mesh0))
rf = ReducedFunctional(J, Control(S))
rf(Constant(3.0, domain=mesh))

When constructing T immediately from the value of S:

T = Constant(S, domain=mesh0)

the same error is produced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant