Support -snes_adapt#5213
Draft
pbrubeck wants to merge 3 commits into
Draft
Conversation
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
Comment on lines
+584
to
+585
| if getattr(ctx, "_adapt_marking_callback", None) is not None: | ||
| return _adaptively_refine(dm, comm) |
Contributor
Author
There was a problem hiding this comment.
This is an antipattern
Contributor
Author
There was a problem hiding this comment.
Add a flag or initialize this to None. Might be better to stash the reult in ctx._fine
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
pbrubeck
commented
Jul 2, 2026
b27150b to
4932ac2
Compare
pbrubeck
commented
Jul 2, 2026
| if level == len(hierarchy) - 1: | ||
| markers = callback(solver, current_solution) | ||
| _validate_refinement_markers(markers, mesh) | ||
| hierarchy.add_mesh(mesh.refine_marked_elements(markers)) |
Contributor
Author
There was a problem hiding this comment.
We should add support for non-netgen meshes. This needs to go through the DMPlex / DMLabel codepath
9bab35e to
8e73057
Compare
230017a to
f817644
Compare
1c7406a to
5ff2783
Compare
pbrubeck
commented
Jul 3, 2026
pbrubeck
commented
Jul 3, 2026
pbrubeck
commented
Jul 3, 2026
pbrubeck
commented
Jul 3, 2026
pbrubeck
commented
Jul 3, 2026
| self._ctx = ctx | ||
| self._work = problem.u_restrict.dof_dset.layout_vec.duplicate() | ||
| self.snes.setDM(problem.dm) | ||
| self._marking_callback = None |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| self._marking_callback = None |
pbrubeck
commented
Jul 3, 2026
| self._marking_callback = None | ||
| if marking_callback is not None: | ||
| self.set_marking_callback(marking_callback) | ||
| ctx._adapt_marking_callback = self._marking_callback |
Contributor
Author
There was a problem hiding this comment.
Suggested change
| ctx._adapt_marking_callback = self._marking_callback |
pbrubeck
commented
Jul 3, 2026
| """ | ||
| if not callable(callback): | ||
| raise TypeError(f"marking callback must be callable, not a {type(callback).__name__}") | ||
| self.parameters.setdefault("adaptor_criterion", "refine") |
Contributor
Author
There was a problem hiding this comment.
This default should live somewhere else
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
Codex-assisted.
Implements UFL-level refinement of a variational problem and PETSc-level refinement of the SNES solver. In this way, users will not require to write the adaptivity loop themselves.
Depends on https://gitlab.com/petsc/petsc/-/merge_requests/9407