Skip to content

Lag label#228

Open
danshapero wants to merge 5 commits into
firedrakeproject:masterfrom
danshapero:lag-label
Open

Lag label#228
danshapero wants to merge 5 commits into
firedrakeproject:masterfrom
danshapero:lag-label

Conversation

@danshapero
Copy link
Copy Markdown
Collaborator

Resolves #221. This PR adds a function lag which labels a single expression in a form for holding back to the start of a timestep. As @pbrubeck thought, implementing it amounted to modifying irksome.tools.replace. I added a test based on lagging the conductivity in the Stefan problem. Without lagging, that fails because of the conditional.

In addition to giving you an escape hatch, you can use lagging to define nonlinear preconditioners. I have a demo of this for the Allen-Cahn equation coded up just using petsc4py which I think is pretty compelling. @JHopeCollins and I are working on getting AuxiliaryOperatorSNES merged into Firedrake: firedrakeproject/firedrake#5119. Once that's merged I can write an Irksome demo showing that off, either in this PR or a separate one.

@danshapero danshapero requested a review from pbrubeck May 15, 2026 14:13
Comment thread irksome/tools.py
return enew
else:
return ufl_replace(e, cmapping)
new_terms = []
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I had a bit of help from Claude for this code path. The alternate path below (not a LabelledForm) was straightforward.

Copy link
Copy Markdown
Collaborator

@pbrubeck pbrubeck May 15, 2026

Choose a reason for hiding this comment

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

This code path is going to disappear in #227

Comment thread irksome/tools.py
Comment on lines +125 to +127
for var in extract_type(e, Variable):
if var.ufl_operands[1] is lag_label:
cmapping.setdefault(var, var)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should go at the top of the function, and the rest of the diff could go away

@pbrubeck
Copy link
Copy Markdown
Collaborator

pbrubeck commented May 15, 2026

I just noticed that #227 might potentially be useful for similar purposes.

Fp could then be a bilinear form a(u0; u, v) depending on the frozen state u0, u is a TrialFunction, and the only time derivative we expect is Dt(u). We don't differentiate wrt. u0 to form the preconditioner, nor apply replacement rules involving u0 in this setting.

I think it's fine to support both modes.

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.

lagging terms

2 participants