Skip to content

Adjoint + submesh#5081

Merged
JHopeCollins merged 14 commits into
mainfrom
knook/adjoint-submesh
May 14, 2026
Merged

Adjoint + submesh#5081
JHopeCollins merged 14 commits into
mainfrom
knook/adjoint-submesh

Conversation

@KarsKnook
Copy link
Copy Markdown
Contributor

@KarsKnook KarsKnook commented May 6, 2026

To make the adjoint compatible with Submesh, both the mesh and submesh are added as dependencies to an adjoint block. This is accomplished by replacing ufl_domain and as_domain with extract_domains in the appropriate files.

Perhaps this implementation is too naive and not all meshes need to be added as dependencies?
Does this account for all adjoint + submesh cases?

To do:

  • answer questions above
  • write tests

Disclaimer:
ChatGPT came up with the initial implementation which was restructured by me

@KarsKnook KarsKnook requested a review from connorjward May 6, 2026 15:26
Copy link
Copy Markdown
Contributor

@connorjward connorjward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some tests

Comment thread firedrake/adjoint_utils/blocks/assembly.py
Comment thread firedrake/adjoint_utils/blocks/solving.py Outdated
Comment thread firedrake/adjoint_utils/blocks/solving.py Outdated
Copy link
Copy Markdown
Contributor

@connorjward connorjward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some tests

Comment thread firedrake/adjoint_utils/blocks/assembly.py Outdated
Comment thread firedrake/adjoint_utils/blocks/solving.py Outdated
@KarsKnook KarsKnook marked this pull request as ready for review May 7, 2026 14:33
Copy link
Copy Markdown
Contributor

@connorjward connorjward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is basically there subject to the final discussion about function_space()

Comment thread firedrake/adjoint_utils/blocks/solving.py
Comment thread firedrake/adjoint_utils/blocks/solving.py Outdated
Copy link
Copy Markdown
Member

@JHopeCollins JHopeCollins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks good to me, thanks for fixing this!

Just a small change needed to the tests so we check the TLM and Hessian models, then this is ready to go.

Comment thread tests/firedrake/adjoint/test_solving.py Outdated
Comment thread tests/firedrake/adjoint/test_solving.py Outdated
Comment thread firedrake/adjoint_utils/blocks/assembly.py Outdated
Comment thread firedrake/adjoint_utils/blocks/solving.py Outdated
Comment thread firedrake/adjoint_utils/blocks/solving.py Outdated
Comment thread firedrake/adjoint_utils/blocks/solving.py Outdated
@KarsKnook
Copy link
Copy Markdown
Contributor Author

Firedrake functions in the real space are now treated as functions without calling isconstant

@JHopeCollins JHopeCollins dismissed their stale review May 14, 2026 10:35

Changes implemented

Copy link
Copy Markdown
Member

@JHopeCollins JHopeCollins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @KarsKnook!

@JHopeCollins JHopeCollins dismissed connorjward’s stale review May 14, 2026 12:10

Discussion resolved

@JHopeCollins JHopeCollins merged commit 6dbd8f0 into main May 14, 2026
7 of 8 checks passed
@JHopeCollins JHopeCollins deleted the knook/adjoint-submesh branch May 14, 2026 12:11
@connorjward
Copy link
Copy Markdown
Contributor

Sorry to be a pain... but shouldn't this have gone into release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants