Skip to content

Fix SphericalShellInternalBoundary internal surface labels#242

Open
gthyagi wants to merge 2 commits into
underworldcode:developmentfrom
gthyagi:feature/mantle-convection-benchmarks
Open

Fix SphericalShellInternalBoundary internal surface labels#242
gthyagi wants to merge 2 commits into
underworldcode:developmentfrom
gthyagi:feature/mantle-convection-benchmarks

Conversation

@gthyagi

@gthyagi gthyagi commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix uw.meshing.SphericalShellInternalBoundary() so the generated mesh preserves usable Lower, Internal, and Upper boundary labels for boundary integrals and internal-boundary Stokes loads.

This PR also adds input validation for the radius ordering and a regression test that checks the three spherical boundary areas against analytic values.

Root Cause

The previous implementation built nested spheres with an OCC fragment path and then removed the inner solid volume recursively. In the Zhong-style internal-boundary probe, the resulting mesh loaded successfully and Stokes could converge, but BdIntegral(mesh, fn=1.0, boundary="Lower") returned 0.0. That meant the Lower boundary label existed at the API level but did not correspond to a usable boundary surface in the loaded DMPlex mesh.

A non-recursive volume removal preserved the surface but produced an invalid Gmsh file for PETSc (Could not determine Plex facet for Gmsh element ...), so the fix needed a cleaner geometry construction rather than a one-line removal change.

What Changed

  • Reworked SphericalShellInternalBoundary() geometry construction:
    • create the physical spherical shell volume,
    • create an internal shell only to obtain a clean spherical surface at radiusInternal,
    • embed that internal spherical surface into the shell volume,
    • remove duplicate internal geometry before meshing,
    • assign physical groups for Lower, Internal, and Upper.
  • Added explicit validation that radiusInner < radiusInternal < radiusOuter.
  • Added test_bd_integral_spherical_internal_boundary_areas, which verifies Lower, Internal, and Upper boundary areas are nonzero and close to analytic spherical areas.

Validation

Run locally in the mantle-convection UW3 worktree:

  • ./uw build
  • pixi run -e amr-dev python -m py_compile src/underworld3/meshing/spherical.py
  • pixi run -e amr-dev pytest -q tests/test_0502_boundary_integrals.py::test_bd_integral_spherical_internal_boundary_areas
  • External benchmark probe using SphericalShellInternalBoundary():
    • serial Nitsche: passed
    • serial Stokes_Constrained: passed
    • 8-rank Nitsche: passed
    • 8-rank Stokes_Constrained: passed

Representative fixed serial boundary areas at ri=0.55, rint=0.775, ro=1.0, cellSize=0.25:

  • Lower = 3.651738570092663
  • Internal = 7.402572621636933
  • Upper = 12.418895120898583

Before the fix, the same benchmark path reported Lower = 0.0 and failed its boundary-area check.

Notes

The benchmark now uses the fixed built-in SphericalShellInternalBoundary() path directly and removed its benchmark-local Gmsh fallback helper.

gthyagi added 2 commits June 16, 2026 07:39
Rework SphericalShellInternalBoundary mesh construction so the shell volume is retained, the internal spherical surface is embedded, and duplicate internal geometry is removed before meshing.

The previous nested-sphere fragment path could leave the Lower boundary unusable for BdIntegral; the benchmark probe observed lower_area=0.0 even though the Stokes solve converged.

Add a boundary-integral regression test that checks nonzero, close-to-analytic Lower, Internal, and Upper surface areas.

Validation: ./uw build passed. py_compile passed for src/underworld3/meshing/spherical.py. pytest -q tests/test_0502_boundary_integrals.py::test_bd_integral_spherical_internal_boundary_areas passed. 005_internal_boundary_delta_probe.py passed with -uw_mesh_source uw3_builtin for serial Nitsche, serial constrained, 8-rank Nitsche, and 8-rank constrained runs.
Add explicit radius ordering validation for SphericalShellInternalBoundary and wrap the entity-selection comprehensions introduced by the internal-boundary label fix.

Validation: py_compile passed for src/underworld3/meshing/spherical.py and test_bd_integral_spherical_internal_boundary_areas passed.
@gthyagi gthyagi marked this pull request as ready for review June 16, 2026 03:33
@gthyagi gthyagi requested a review from lmoresi as a code owner June 16, 2026 03:33
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.

1 participant