Skip to content

Draw a mesh variable of any degree on the mesh's own cells (#1057) - #1084

Merged
lmoresi merged 3 commits into
developmentfrom
feature/higher-order-vis-1057
Nov 11, 2026
Merged

lmoresi merged 3 commits into
developmentfrom
feature/higher-order-vis-1057

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Closes #1057.

What changed and why

meshVariable_to_native_pv_mesh drew only continuous P1 natively. Every other variable fell back to a Delaunay of its nodes, whose alpha filter drops coarse cells on a graded mesh: 361 of 11610 cells were lost at 8:1. Saved refined runs reloaded with #690's fix (#1063) are exactly the meshes we want to look at in house.

Native drawing. A continuous Lagrange variable of any degree k is now drawn on the mesh's own cells, each subdivided through the variable's nodes:

  • k² sub-triangles or sub-quads per cell;
  • k³ sub-tetrahedra (Freudenthal subdivision) or sub-hexahedra.

Point i is still DOF i, so the documented pvm.point_data["T"] = T.data[:, 0] pattern is unchanged. Surfaces in 3D (SphericalManifold) keep all three coordinates, and each sub-cell faces the way its parent does.

The map is topological (_lagrange_subcell_connectivity):

Discontinuous variables keep the Delaunay fallback.

Changes worth noting:

  • In 2D, meshVariable_to_pv_mesh_object now returns an UnstructuredGrid rather than a PolyData for continuous k ≥ 2. No in-repo caller depends on the type.
  • test_0846's continuous-P2 case pinned the old Delaunay route. It is replaced by a DG1 case.
  • The uw-visualisation skill and guide are updated.

Tests (fail on development, pass here)

  • tests/test_1057_native_vis_higher_order.py (30 cases). Meshes: simplex box at refinement 0 and 1, annulus at refinement 0 and 1, a graded moved mesh, quads, hexes, tets (P1–P3), and a SphericalManifold. It checks:

    • the sub-cell count, cells × k^d;
    • DOF order;
    • positive signed areas, computed in numpy (VTK's 2D areas are unsigned), or normals against the parent's on the sphere;
    • k^(d−1) boundary sub-facets per boundary facet, and no non-manifold edges;
    • per cell, an exact fill and an identical sub-cell size-ratio pattern, which catch a node on the wrong site even inside a cell;
    • connectivity unchanged when nodes are perturbed by 10 % of the spacing.

    On development, 18 of the original 27 cases fail.

  • tests/parallel/test_1057_native_vis_parallel.py checks ghost DOFs at np 2 and 4. On development, 4 of 6 cases fail.

  • Mutation checks:

    • disabling the within-entity ordering is caught (annulus P3, quad Q3, tet P3);
    • removing the planar orientation is caught (tri P3);
    • removing the surface orientation is caught (sphere P3).
  • Existing visualisation tests: 148 passed (0055, 0800, 0846×2, 0847, 0848, 0850×2, 1100).

  • Timing: P2 on 92k triangles takes 0.6 s, and P2 on 37k tets takes 0.8 s.

Review

H1 reviewed 23f00d5 adversarially and approved it after two changes. Its oracle covered 43 configurations, 31 curved or split configurations and 231 perturbed trials, with no wrong connectivity. Both blocking findings are addressed in 5a9606d:

  • F1: manifold points and orientation;
  • F3: signed-area tests.

The tolerance finding, F2, is #1083. F4 predates this PR: a rank with no cells raises in meshVariable_to_pv_mesh_object. H1's own record is to follow from H1.

Checklist (UW3 Style Charter)

  • I have read the Style Charter and followed it over the surrounding code (S2)
  • No drive-by refactors, renames, or "while I was here" cleanups (S9)
  • Regression tests written first and shown to fail on development, with level_* and tier_* markers (S8)
  • No hedging names and no commented-out code (S3, S4)
  • Every exception swallow states its sanctioned failure mode in a comment (S4)
  • New data access uses .array / mesh.X.coords (S7)
  • Parallel safety considered: np 2 and np 4 checked (S11)
  • No pixi.toml / pixi.lock or other dependency changes
  • AI-assisted work carries the attribution line below

Underworld development team with AI support from Claude Code

meshVariable_to_native_pv_mesh handled only continuous P1; every other
variable fell back to a Delaunay of its nodes, whose alpha filter drops the
coarse cells of a graded mesh. It now subdivides each cell through the
variable's nodes on the degree-k reference lattice: k^2 sub-triangles or
sub-quads, k^3 sub-tetrahedra (Freudenthal) or sub-hexahedra, with point i
still the variable's DOF i.

The cell-to-DOF map is topological. The DOFs on each vertex, edge, face and
cell interior come from the variable's own section through the DMPlex
closure, and each closure entity is matched to a lattice entity by its
corner set. Position only orders the several nodes of one entity, which
follow that entity's orientation, against candidates a lattice spacing
apart, so nodes off the chord still map correctly. Discontinuous variables
keep the Delaunay fallback; test_0846's continuous-P2 case, which pinned
that fallback, is replaced by a DG1 case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
H1's review of 23f00d5.

F1: on a surface in 3D (a SphericalManifold) the points kept only their
first two coordinates, and sub-cells were left unoriented, so at k >= 2 a
quarter or more of them faced against their parent. The points now carry
every coordinate, and each sub-cell is turned to face the way its parent
cell does. A SphericalManifold test checks both at P1-P3.

F3: VTK's 2D cell areas are unsigned, so removing the planar orientation
passed every 2D test. The 2D checks now assert positive signed areas
computed in numpy, and the tautological polynomial check is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 21:36

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lmoresi
lmoresi merged commit 6a2b04e into development Nov 11, 2026
10 checks passed
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