Skip to content

Add generic spherical-shell geoid and self-gravity postprocessing - #591

Open
gthyagi wants to merge 3 commits into
underworldcode:developmentfrom
gthyagi:feature/spherical-geoid-postprocessing
Open

Add generic spherical-shell geoid and self-gravity postprocessing#591
gthyagi wants to merge 3 commits into
underworldcode:developmentfrom
gthyagi:feature/spherical-geoid-postprocessing

Conversation

@gthyagi

@gthyagi gthyagi commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Add generic spherical-harmonic geoid and self-gravity postprocessing for two-boundary spherical shells, with an optional internal load.

The reusable mathematics now lives in uw.postprocessing.geoid. Zhong et al. (2008) supplies the validation case and exact benchmark parameters, but is not encoded in public class or function names.

This revision deliberately reuses UW3's existing rotated-free-slip stress recovery. It does not add another topography implementation, automatic BC dispatch, CBF fallback, constrained-multiplier path, Stokes.geoid() facade, or semi-analytical Stokes solver.

API

Pure coefficient operations, independent of a Stokes discretisation:

uw.postprocessing.geoid.spherical_shell_geoid_response(...)
uw.postprocessing.geoid.spherical_shell_self_gravity_response(...)

Convenience extraction from a completed rotated-free-slip solve:

response = uw.postprocessing.geoid.spherical_shell_response_from_rotated_stokes(
    stokes=stokes,
    radius_inner=0.55,
    radius_outer=1.0,
    harmonic_degree=2,
    internal_load_radius=0.775,
    internal_load_coefficient=1.0,
    include_self_gravity=True,
    surface_density_contrast=3300.0,
    cmb_density_contrast=5400.0,
    planet_radius=6370000.0,
    gravity=9.8,
    gravitational_constant=6.67e-11,
)

The adapter calls stokes.boundary_normal_traction(boundary, mass="auto") and projects surface/CMB responses onto the unnormalised axisymmetric P_l^0 harmonic. Other harmonic orders or topography-recovery methods can call the pure coefficient functions directly.

Inputs and conventions

  • Surface, CMB, and internal-load coefficients must use one consistent spherical-harmonic normalisation.
  • The radial potential kernel depends on harmonic degree but not order.
  • The internal load is optional; a nonzero coefficient requires a radius strictly inside the shell.
  • Shell radii and response coefficients are nondimensional.
  • Density contrasts are signed and use SI units.
  • Model-specific density contrasts, planet radius, and gravity are required explicitly when self-gravity is enabled. There are no hidden Zhong/Earth defaults.
  • The universal gravitational constant has a CODATA default and can be overridden with a paper's rounded value.

Mathematics

One radial Green-function operator and optional load vector are shared by both paths:

N = G h + n_load
(I - Q G) h_self_gravity = h + Q n_load
N_self_gravity = G h_self_gravity + n_load

Here h contains surface/CMB topography coefficients, N contains surface/CMB geoid coefficients, and Q contains the self-gravity density factors.

This is the geoid/self-gravity algebra applied after topography is known. A Zhong propagator-matrix reference solver would solve the spherical-harmonic radial Stokes equations and belongs separately in uw.analytic.

Validation

  • serial Level 2 geoid suite: 12 passed;
  • four-rank focused MPI regression: 1 passed on every rank;
  • complete Level 1 suite: 1476 passed, 49 skipped, 2 xfailed;
  • pure no-load, internal-load, self-gravity, and validation-error coverage;
  • end-to-end rotated Stokes comparison against Zhong Table 2;
  • production isoviscous serial 1/4 and eight-rank 1/8 runs reproduce prior coefficients to printed precision;
  • production layered eight-rank 1/8 run reproduces its prior coefficients.

Scope

This PR changes only the postprocessing package, focused tests, and concise developer documentation. The independent 3D boundary-flux memory-scaling correction remains #593. Mesh-files-only generation remains separately scoped in #592.

Add pure Appendix A no-self-gravity and self-gravity response operators with explicit internal-load scaling, density-contrast naming, dimensional constant documentation, and harmonic-degree validation.

Provide a rotated-Stokes adapter that delegates normal-traction recovery to the existing Stokes.boundary_normal_traction API, projects only the requested P_l^0 response, and avoids duplicate CBF, constrained, or dynamic-topography implementations.

Keep the feature in uw.postprocessing rather than adding a Zhong-specific facade to the generic Stokes solver. Add focused formula, serial end-to-end, and two/four-rank MPI validation.
@gthyagi
gthyagi force-pushed the feature/spherical-geoid-postprocessing branch from 102ef59 to cce0753 Compare August 16, 2026 14:16
@gthyagi gthyagi changed the title Add spherical-shell topography and geoid postprocessing Add Zhong 2008 spherical-shell geoid response Aug 16, 2026
@gthyagi

gthyagi commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

@lmoresi The benchmark integration is now updated to this narrowed API. Could you please double-check the Appendix A sign/normalisation conventions and whether this rotated-only adapter is the right UW3 abstraction? If an existing implementation is preferable, this focused commit can be discarded without affecting the separate memory fix in #593.

Production validation from benchmark commit 99fc132:

Case Resolution / ranks Surface topo CMB topo Surface geoid CMB geoid Surface topo SG CMB topo SG Surface geoid SG CMB geoid SG
Isoviscous 1/4, serial 0.40907 0.77403 0.02383 0.03183 0.48410 0.93222 0.04173 0.05377
Isoviscous 1/8, 8 ranks 0.40599 0.79339 0.02357 0.03377 0.48070 0.95994 0.04156 0.05661
Layered 1/8, 8 ranks 0.43175 0.42516 0.02198 -0.00518 0.49313 0.41879 0.03414 -0.00216

The isoviscous run is within 3.82% for self-gravity topography and 7.36% for self-gravity geoid at 1/8. The layered surface/geoid response remains under-resolved at 1/8, while CMB velocity and self-gravity topography errors are +0.55% and -3.81%. Stokes/post-processing timings were 10.08/1.27 s (isoviscous) and 58.67/1.26 s (layered). Focused tests pass: 8 serial geoid tests and the dedicated adapter test on 4 MPI ranks.

Move the public API under uw.postprocessing.geoid and remove Zhong-specific names from the reusable response data types and coefficient functions.

Support two-boundary shells with an optional internal load, require model-specific density and gravity inputs explicitly, and retain a focused rotated-free-slip adapter for recovering axisymmetric topography coefficients.

Rename the MPI regression, add no-load and parameter-validation coverage, and update developer documentation to distinguish generic postprocessing from a future semi-analytical propagator solver in uw.analytic.
@gthyagi gthyagi changed the title Add Zhong 2008 spherical-shell geoid response Add generic spherical-shell geoid and self-gravity postprocessing Aug 16, 2026
Allow the generic spherical-shell coefficient functions to evaluate the degree-zero radial potential while keeping the rotated-Stokes adapter at degree one or greater because boundary normal traction recovery removes its mean.

Add focused degree-zero formula and adapter validation tests and document the distinction.
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