refactor(custom-mg): D-79..D-87 readability + minimal-control multigrid design note (PROPOSED)#373
Merged
Merged
Conversation
…ltigrid design note Wave D behaviour-neutral readability pass over utilities/custom_mg.py (docs/reviews/2026-07 REMEDIATION-WORKLIST, D-custom_mg table; all nine rows re-verified live at the post-#369 base): - D-79 LevelLayout NamedTuple replaces the magic lay[3] tuple indexing - D-80 _clone_dm_with_solver_discretisation extracted (copyDS trick documented once, on the helper) - D-81 _assert_no_zero_columns_serial extracted beside the parallel guard - D-82 getNumFields except narrowed to PETSc.Error + sanctioned comment - D-83 parallel-path parameters renamed to the serial vocabulary (coarse_coords/fine_coords/coarse_layout/fine_layout) - D-84 semicolon-packed lines split (6 sites) - D-85 'sub' prefix-string collision renamed vel_prefix, moved into the verbose block - D-86 RBF r=0 clamp commented (r^2 log r -> 0; clamp keeps log finite) - D-87 TODO(deprecate) lifespan marker on the legacy finest-only path, stating the one behavioural difference (no BC-per-level reduction) Plus docs/developer/design/MULTIGRID_MINIMAL_CONTROL_2026-07.md (Status: PROPOSED): survey of the five existing MG paths, a proposed minimal-control auto ladder, and seven numbered maintainer questions. No implementation. Bit-identical check: custom-MG suites identical pre/post edits (serial 1015+1016+1017: 14 passed; np2 1017: 6 passed). Serial 'level_1 and tier_a' gate identical to the development baseline (386 passed / 12 skipped / 2 xfailed / 1 xpassed). Scanner green; docs build green. Underworld development team with AI support from Claude Code
…7-17); SNESFAS not-viable notes The minimal-control design note moves PROPOSED -> RULED: GAMG stays the automatic default (custom-P FMG opt-in); two-tier failure loudness; wants_mg class attribute; solver.multigrid capability spelling; set_custom_mg removed next cycle; no default hierarchies. SNESFAS is ruled NOT viable at present (no good preconditioners; loses the robust linear-solver path) - noted in the solver-strategies catalogue and the plasticity-solvers skill as future investigation only. Underworld development team with AI support from Claude Code
Member
Author
|
Finalises changes to UW-multigrid to allow: rotated bcs, hierarchical adapted meshes (coarse plus non-uniform refinement), etc. Note, the adaptation is 2D only at the moment, but the MG changes are general. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third PR of the 2026-07-16 maintainer-ruled series (#371 retire movers → #372 purposeful naming → this). Based directly on
origin/development(6ca0e60): the file set is disjoint from #371/#372, so it can merge independently; merge order 371 → 372 → 373 is still the tidy sequence.Part 1 — the nine D-custom_mg worklist rows (behaviour-neutral, Wave D rules)
All nine rows (
docs/reviews/2026-07/REMEDIATION-WORKLIST.md, D-custom_mg table) re-verified live at the post-#369 base before editing — #369 rewrote much of this file, but every anchor still existed (at moved line numbers):LevelLayoutNamedTuple (l2g,rstart,rend,n_full) returned by_level_dof_layout/_coarse_dof_layout;lay.n_fullreplaceslay[3]; the serial-vs-parallel two-shapes note now sits at themapsfill site_clone_dm_with_solver_discretisation(solver, coarse_mesh)extracted; the copyFields/copyDS/createDS "trick" explanation lives once, on the helper_assert_no_zero_columns_serialextracted beside_assert_no_zero_columns_parallel, shared wordingexcept ExceptionaroundgetNumFields()narrowed toPETSc.Error+ sanctioned-failure comment (uncreated DS cannot report field count)_build_parallel_transfer/_build_crosspart_transfer/_gather_coarse_cloudparameters renamed to the serial vocabulary (coarse_coords,fine_coords,coarse_layout,fine_layout); call sites are positional, updated in the same commitsub(options-prefix string) renamedvel_prefixand moved inside theif verbose:block, ending the collision withsub= sub-DMr == 0clamp (r² log r → 0; clamp only keeps log finite)TODO(deprecate)lifespan marker on the legacy finest-onlyinject_custom_mgpath, stating the one behavioural difference (no BC-per-level reduction — valid only for non-nested/unconstrained coarse levels)Bit-identical verification: the custom-MG suites are identical pre/post edit in this worktree — serial
test_1015_custom_mg_prolongation + test_1016_custom_mg_hierarchy + test_1017_custom_mg_stokes: 14 passed both times; np2tests/parallel/test_1017_custom_mg_parallel_mpi.py: 6 passed both times. The diff contains no arithmetic changes (renames, extractions, comments only — audited).Part 2 — multigrid minimal-control design note (PROPOSED, no implementation)
docs/developer/design/MULTIGRID_MINIMAL_CONTROL_2026-07.md(added to the design toctree). It surveys the five existing MG paths (solver.preconditionerauto/fmg/gamg with the #276 single-field lock-out; raw PETSc options with the user-override latch;set_custom_fmg; #369's mesh-owned auto-injection on adapt children; the deprecated legacyset_custom_mg), proposes a minimal-control"auto"resolution ladder (the only new machinery: auto-routing single-field solvers with a refinement hierarchy to custom-P FMG instead of the GAMG fallback), and ends with seven numbered maintainer questions: (1) adopt the single-field custom-P auto-route?, (2) failure loudness of explicit vs automatic MG, (3) utility-solver exclusion mechanism, (4) purposeful naming of the knob (solver.multigrid?) under the naming ruling, (5) legacyset_custom_mgremoval timeline, (6) SNESFAS scope, (7) whether common constructors should build a default hierarchy so geometric MG is reachable withoutrefinement=.Gates (strictly serial; amr-dev env)
pytest tests/ -m "level_1 and tier_a"tests/parallel/test_1017_custom_mg_parallel_mpi.pypixi run docs-buildUnderworld development team with AI support from Claude Code