Skip to content

Number local Netgen regions by DMPlex label value - #127

Open
pbrubeck wants to merge 2 commits into
mainfrom
pbrubeck/local-plex-regions
Open

pbrubeck wants to merge 2 commits into
mainfrom
pbrubeck/local-plex-regions

Conversation

@pbrubeck

Copy link
Copy Markdown
Collaborator

createNetgenMesh(plex, geo) numbers the regions of the new Netgen mesh by the label values it finds in plex.

Before this PR: regions are numbered by the sorted label values present in plex. On a rank whose part of a distributed plex lacks some values (for example, a rank that touches only 4 of 6 boundary edges), the regions come out renumbered, and only the descriptors for the values present are added. A Netgen mesh built this way cannot serve as geo for a further refinement. The next call looks up descriptors[depth][index-1] with a global label value and raises IndexError: list index out of range.

After this PR: every label value from 1 up to the largest (or up to the number of descriptors of geo) gets its own region, empty where the local plex lacks that value. Region indices therefore equal label values on every rank. Unlabeled cells go into region 1 when no cell is labeled, and otherwise into a new region after the last one. Serial meshes with contiguous label values get the same regions as before.

Firedrake needs this to snap each refined plex onto the geometry before refining it again, in parallel: firedrakeproject/firedrake pbrubeck/adaptive-multigrid, where test_netgen_occ_adaptivity fails on 2 ranks without it.

This PR was written by Claude (Claude Code) on behalf of @pbrubeck.

🤖 Generated with Claude Code

createNetgenMesh numbered the regions of a Netgen mesh by the sorted label
values present in the plex, and looked up descriptors of the geometry mesh
at those values. The local part of a distributed plex can lack some label
values, so its regions were renumbered, and a Netgen mesh built from it
could not serve as the geometry of a further refinement: the next lookup
indexed past its descriptors.

Give every label value up to the largest its own region, empty where the
local plex lacks it, so that region indices match label values on every
rank.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pbrubeck added a commit to firedrakeproject/firedrake that referenced this pull request Sep 16, 2026
Installs NGSolve/ngsPETSc#127, which numbers the regions of a Netgen mesh
built from a local DMPlex by label value. Snapping a refined mesh against
it fails on 2 ranks without that PR. Drop once #127 merges.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pbrubeck added a commit to firedrakeproject/firedrake that referenced this pull request Sep 17, 2026
Installs NGSolve/ngsPETSc#127, which numbers the regions of a Netgen mesh
built from a local DMPlex by label value. Snapping a refined mesh against
it fails on 2 ranks without that PR. Drop once #127 merges.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@UZerbinati

Copy link
Copy Markdown
Collaborator

Do we have a test where we do not pass any geometry information and check that basic features like mesh generation and multigrid (non geometric conforming) still work ?

@pbrubeck

Copy link
Copy Markdown
Collaborator Author

Do we have a test where we do not pass any geometry information and check that basic features like mesh generation and multigrid (non geometric conforming) still work ?

These tests would not make sense. A netgen mesh should always carry geometric information.

@UZerbinati

Copy link
Copy Markdown
Collaborator

Do we have a test where we do not pass any geometry information and check that basic features like mesh generation and multigrid (non geometric conforming) still work ?

These tests would not make sense. A netgen mesh should always carry geometric information.

But we would be breaking code of people that since we did not require to pass geometry before they have not been passing geometry. Let's make the changes compatible with old code, I think this is good practice, no ?

@pbrubeck

Copy link
Copy Markdown
Collaborator Author

Do we have a test where we do not pass any geometry information and check that basic features like mesh generation and multigrid (non geometric conforming) still work ?

These tests would not make sense. A netgen mesh should always carry geometric information.

But we would be breaking code of people that since we did not require to pass geometry before they have not been passing geometry. Let's make the changes compatible with old code, I think this is good practice, no ?

That would be silently giving users the wrong code, and has little to do with this PR.

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.

2 participants