Skip to content

Mesh Adaptivity via DMPlexTransform - #5215

Open
pbrubeck wants to merge 105 commits into
mainfrom
pbrubeck/mg-redist
Open

Mesh Adaptivity via DMPlexTransform #5215
pbrubeck wants to merge 105 commits into
mainfrom
pbrubeck/mg-redist

Conversation

@pbrubeck

@pbrubeck pbrubeck commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Description

AI-assisted

Enables adaptivity on any simplicial mesh via DMPlex.adaptLabel()/DMPlex.transform()
Depends on https://gitlab.com/petsc/petsc/-/merge_requests/9412 (merged) which introduces 3D adaptivity

Enables prolong/restrict/inject to natively support adaptively-refined/redistributed hierarchies

Deprecate hierarchy-agnostic AdaptiveTransferManager in favour of TransferManager, now with adaptivity and parallel redistribution support.

@pbrubeck pbrubeck changed the title Native support for redistributed AdaptiveMeshHierarchy TransferManager: support a redistributed AdaptiveMeshHierarchy Jul 3, 2026
@pbrubeck
pbrubeck force-pushed the pbrubeck/mg-redist branch 2 times, most recently from 404f925 to 381f544 Compare July 3, 2026 19:51
@pbrubeck
pbrubeck force-pushed the pbrubeck/mg-redist branch from 381f544 to 885a7eb Compare July 3, 2026 19:56
Comment thread firedrake/mg/interface.py Outdated
Comment thread firedrake/mg/adaptive_hierarchy.py Outdated
Comment thread firedrake/netgen.py Outdated
Comment thread firedrake/netgen.py Outdated
Comment thread firedrake/netgen.py Outdated
Comment thread firedrake/netgen.py Outdated
Comment thread firedrake/mg/utils.py Outdated
Comment thread firedrake/mg/utils.py Outdated
Comment thread firedrake/mesh.py Outdated
Comment on lines +2912 to +2913
:arg mark: the marking function, a Firedrake DG0 function on
this mesh; cells with a positive value are refined.

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.

numpydoc + return type

Comment thread firedrake/netgen.py Outdated
ref_points_a = np.matmul(points_a - bs[:, None, :], Ainvs)
ref_points_b = np.matmul(points_b - bs[:, None, :], Ainvs)

p = [np.argmin(cdist(a, b), axis=0) for a, b in zip(ref_points_a, ref_points_b)]

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'd appreciate a worked example in a comment or similar. This isn't obvious upon reading.

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.

Here I merged #5034 just so that some tests passed. However, I really want to get rid of this python-based lookup in favour of a cleaner cython/PETSc.Section approach from #5277.

This netgen-specific code is going to be replaced with more generic cython code, so I would focus the review on the non-netgen specifc aspects of this 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.

I find it really confusing to review multiple dependent PRs. Could you do them one at a time? At least make them merge into one another so the diffs are always the relevant code changes.

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.

I am not pursuing to merge #5034 to main. #5277 is targetting this 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.

But there is still code in this PR that you want me to ignore? That's what I'm asking to not have happen.

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 assumed that this code would now be removed?

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.

I cannot remove it without breaking the tests. It will be removed in #5277

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.

Alternatively we can merge #5034 to main first

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.

With mesh adaptivity you very quickly get very different geometric scales, so I need to remove the absolute tolerance. #5034 is just a workaround in the reference coordinates, but the correct fix is #5277

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.

I'll remove this fix from here, it seems that the tests are fine with the default tolerance

Comment thread firedrake/netgen.py Outdated
return permutation


def _recurve_netgen_mesh(coarse_mesh, fine_mesh, order):

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.

Can this have a clearer name and docstring? It does something obscure.

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.

Suggested change
def _recurve_netgen_mesh(coarse_mesh, fine_mesh, order):
def _transfer_high_order_coordinates(coarse_mesh, fine_mesh, order):

Comment thread firedrake/cython/mgimpl.pyx Outdated
Comment thread firedrake/cython/mgimpl.pyx Outdated
Comment thread firedrake/adapt.py
Comment thread firedrake/adapt.py Outdated
Comment thread firedrake/adapt.py
Comment thread firedrake/adapt.py
Comment thread firedrake/adapt.py Outdated
Base automatically changed from pbrubeck/snes-adapt to main July 27, 2026 08:18
@pbrubeck
pbrubeck requested a review from connorjward July 27, 2026 12:44
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