Skip to content

Handle MeshGeometry in cached solvers (-> #4638)#5188

Draft
angus-g wants to merge 3 commits into
JHopeCollins/nlvs-hessian-fixfrom
angus-g/4638-meshgeometry
Draft

Handle MeshGeometry in cached solvers (-> #4638)#5188
angus-g wants to merge 3 commits into
JHopeCollins/nlvs-hessian-fixfrom
angus-g/4638-meshgeometry

Conversation

@angus-g

@angus-g angus-g commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This threads MeshGeometry dependencies through the CachedSolverBlock. Because CoordinateDerivative is a bit strange, we do need to special case forms and flip signs here and there. Particularly for the Hessian forms it goes back to the action -> derivative approach (restrained by CoordinateDerivative) rather than derivative -> action -> adjoint.

I did also test Fireshape here (it passes, whereas before this PR it would fail on test_L2tracking[FeMultiGridControlSpace] and test_TimeTracking). @APaganini do you have anything that we should ensure we check related to this?

This test relies on moving geometry, so it does exercise the
changes in this branch. test_shape_derivatives probably does too,
but implicitly through interpolate so it might not fail until
we route all solves through the cached solver block.
@angus-g angus-g requested a review from JHopeCollins June 18, 2026 03:20
@angus-g angus-g added the base:main Run this PR using a main (dev) build label Jun 18, 2026
angus-g added 2 commits June 18, 2026 13:26
For whatever reason, derivative(-F, m, dm) has very different behaviour
when passed through the adjoint -> action -> expand_derivatives chain
compared to the non-negated variant. We just push subtraction to the
dFdm_adj and dFdm_adj2 forms instead.
@angus-g angus-g force-pushed the angus-g/4638-meshgeometry branch from dc82f03 to 3be5af2 Compare June 18, 2026 04:32
Comment on lines +43 to +45
def __init__(
self, forward_cache, tangent_cache, adjoint_cache, hessian_cache, ad_block_tag=None
):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops I was going to type-annotate these but that introduces a circular dependency, I should probably go back to an if TYPE_CHECKING import.

@APaganini

APaganini commented Jun 18, 2026 via email

Copy link
Copy Markdown
Contributor

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

Labels

base:main Run this PR using a main (dev) build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants