Skip to content

Adjoint + submesh#5081

Open
KarsKnook wants to merge 10 commits intomainfrom
knook/adjoint-submesh
Open

Adjoint + submesh#5081
KarsKnook wants to merge 10 commits intomainfrom
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 Outdated
Comment thread firedrake/adjoint_utils/blocks/solving.py
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

if isconstant(c):
mesh = as_domain(self.form)
space = c._ad_function_space(mesh)
space = c.function_space()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How come this needs to change? c.function_space() returns a Firedrake type but c._ad_function_space returns the ufl_function_space.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if this is a holder from previous Firedrake/FEniCS compatibility. But I have no idea really.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If it is then we should address that in a separate PR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In which case someone should open an issue. This is a non-core dev submission and saying "leave that for another PR" makes it very likely to never be done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's two questions here:

  1. Does it need changing for the fix in this PR to work? @KarsKnook does it work if you don't change how you get the function space? If not then you can revert back to the original.
  2. Is this a holdover that we could update? I don't know either, but I'm just saying that unless its essential for this PR then this isn't the place to start changing it, lets keep this one as simple as possible.

Comment thread firedrake/adjoint_utils/blocks/solving.py Outdated
@KarsKnook KarsKnook marked this pull request as ready for review May 7, 2026 14:33
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.

3 participants