-
Notifications
You must be signed in to change notification settings - Fork 157
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: pyadjiont.ReducedFunctional.__call__ doesn't notice mesh.coordinates changes #3589
Comments
I have already solved this. What you need to do is a bit hacky:
|
I tried @colinjcotter 's solution but it doesn't work. The following code gives the same output as above
|
Yeah, I don't know anything about how mesh changes are annotated. |
I am not an expert in the adjoint but the tape does look a bit strange: We do annotate changes to the mesh coordinates but I think it's done in quite a fragile way. @dham is really the person to ask about this. |
I think the evaluation of the reduced functional gives exactly the right result here. I suspect the reason your implementation of what @colinjcotter suggested does not work, is because pyadjoint does not correctly handle this aliasing. So instead just specify the mesh itself as the control, i.e.:
|
Stephan has this right. Shape derivatives were a serendipity: we didn't plan for them but more or less discovered that they were possible with minor modifications when Alberto and Florian asked about it. A consequence is that not all the corners of this are fully explored. We definitely don't properly account for aliasing of the coordinate field. The side effect of changing the mesh is similarly accident rather than design, though fixing it would be difficult for exactly the reason that Stephan highlights. I guess it could be done by having a "checkpoint" mesh as suggested, and then being very careful that our own operations only ever apply to things defined on it. That would be a fair bit of legwork. |
Describe the bug
We can use firedrake/pyadjoint to compute shape derivatives. When this is done on a mesh
mesh_m
created from a vector functionT
, callingReducedFunctional.__call__
resets the value ofT
Steps to Reproduce
Expected behavior
Calling
ReducedFunctional.__call__
should not changeT
, and it'd be nice ifReducedFunctional.__call__
noticed changes inmesh_m.coordinates
.Error message
The bug is the last two lines, and it'd be nice if
(pyadjiont) Expanded area:
was 4 instead of 1.Environment:
The text was updated successfully, but these errors were encountered: