Repository navigation
Conversation
pbrubeck
added this pull request to stack #5444
September 10, 2026 19:21
…ptive-callback-demos
Since #5414 the demo tests extract only ``.. code-block:: python`` blocks, so these demos ran no code. The goal functional and the error estimate now come from the callback that get_marking_callback returns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ptive-callback-demos
…ptive-callback-demos
pefarrell
requested changes
Oct 5, 2026
|
|
||
| We solve it on the unit square with a known analytical solution, so that we can | ||
| compute effectivity indices for our error estimates. Adaptive refinement needs | ||
| no special mesh: any Firedrake mesh can be refined in place: |
Contributor
There was a problem hiding this comment.
Weird to have two colons in one sentence
| "dwr_monitor": None, | ||
| }) | ||
|
|
||
| There is no loop to write here, unlike in the ad hoc implementations such a |
Contributor
There was a problem hiding this comment.
This feels like a comment put there to contrast with how the code looked before, but of course that code is not visible to the reader. Maybe say 'The adaptive loop is handled inside the solver.'
| method usually needs. The solver runs the configured | ||
| SOLVE--ESTIMATE--MARK--REFINE cycle, and the marking callback supplies the | ||
| cells to refine. We also pass the exact solution, which lets the monitor | ||
| report the true error and an effectivity index. That is a diagnostic, and is |
Contributor
There was a problem hiding this comment.
Maybe 'Of course, this is not needed in general.'
…ptive-callback-demos
The elasticity demo exercised the same machinery as the p-Laplacian demo. A mixed RT x DG Poisson test in test_snes_adapt.py keeps the mixed-space coverage. Also clarify the p-Laplacian demo prose: what solve() returns, and that the adaptive loop runs inside the solver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ptive-callback-demos
pefarrell
previously approved these changes
Oct 5, 2026
… into pbrubeck/goal-adaptive-callback-demos
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a demo of goal-oriented mesh adaptivity with the dual-weighted residual
(DWR) method, using the marking callback and the adaptive
solve-estimate-mark-refine cycle from #5273. This PR is stacked on #5273 and
targets
pbrubeck/goal-adaptive-callback.demos/goal_oriented_nonlinear_p_laplacianThe demo solves a strongly nonlinear p-Laplacian (p = 5) on the unit square,
with a manufactured solution, and adapts the mesh for a goal functional: the
normal flux through the top boundary. The demo shows how to:
(
snes_adapt_sequence,dwr_atol/dwr_rtol,dwr_marking_fraction,dwr_monitor), with no user-written loop;DWRMarkingCallbacktoNonlinearVariationalSolver, and an exactsolution so that the monitor reports effectivity indices;
solver.get_marking_callback()and the solution onthe final mesh from
solver.solve().The text explains that the estimate separates discretisation error from
algebraic error, which permits a coarse nonlinear solver tolerance. It also
explains the warning that is printed when the algebraic error dominates.
The demo is listed in the advanced tutorials and in
tests/firedrake/demos/test_demos_run.py. The references it cites are added todemos/demo_references.bib.Mixed-space test
test_dwr_marking_callback_mixed_spaceintests/firedrake/multigrid/test_snes_adapt.pyruns the DWR callback on amixed RT1 x DG0 Poisson problem in serial and on two ranks. Before this PR,
every DWR test used a scalar space.
🤖 Generated with Claude Code