Skip to content

FMG (preconditioner="fmg"/"auto") fails with PETSc err62 (injection) for scalar solvers on a refined Plex hierarchy #276

Description

@lmoresi

Summary

preconditioner="fmg" (and "auto" when a refinement hierarchy is present) on a
scalar solver (Poisson, Projection, AdvDiffusionSLCN) built over an
Annulus(refinement>=1) hierarchy fails at solve time with

PETSc Error 62: Could not locate matching functional for injection

The Stokes velocity-block FMG works on the same hierarchy, so this is
specific to the scalar (single-field) FMG path.

Reproducer (serial)

import underworld3 as uw, sympy
mesh = uw.meshing.Annulus(radiusOuter=1.0, radiusInner=0.5, cellSize=1/6,
                          refinement=2, qdegree=3)
print("dm_hierarchy levels:", len(mesh.dm_hierarchy))   # -> 3

# SCALAR: fmg FAILS, gamg OK
T = uw.discretisation.MeshVariable("T", mesh, 1, degree=3)
p = uw.systems.Poisson(mesh, T)
p.constitutive_model = uw.constitutive_models.DiffusionModel
p.constitutive_model.Parameters.diffusivity = 1.0
p.add_dirichlet_bc(1.0, "Lower"); p.add_dirichlet_bc(0.0, "Upper")
p.preconditioner = "fmg"      # -> PETSc err 62 ;  "gamg" -> OK
p.solve()

Observed:

scalar Poisson  preconditioner='gamg':  OK
scalar Poisson  preconditioner='fmg':   FAIL -> PETSc Error 62
Stokes velocity preconditioner='fmg':   OK      (same mesh)

PETSc stack

DMPlexComputeInjectorFEM()  plexfem.c:3706
DMCreateInjection_Plex()    plex.c:10343
DMCreateInjection()         dm.c:1362
PCSetUp_MG()                mg.c:1024
PCSetUp() / KSPSetUp() / KSPSolve() / SNESSolve()

PCSetUp_MG requests an injection operator for the scalar field and
DMPlexComputeInjectorFEM cannot build it for the degree-3 field on the
refined, boundary-snapped Plex levels (no matching dual functionals between the
coarse and fine spaces). The Stokes velocity FMG path does not request this
injection, hence it succeeds.

Workaround

Set scalar solvers' preconditioner = "gamg" (no geometric injection). Used in
fs4_compare.py for the FK stagnant-lid runs: FMG on Stokes velocity, gamg on the
auxiliary scalar solvers (diffuser / projection / advection-diffusion).

Possible fixes (for the FMG bundle in _apply_preconditioner_options)

  • Configure the scalar FMG to avoid requiring injection (interpolation-only
    restriction; appropriate pc_mg/DMCreateInjection-skip flags), or supply a
    working injector for high-degree Plex fields.
  • Or gate FMG-auto to the Stokes velocity block until the scalar injection path is
    fixed, so refinement>=1 meshes don't silently break scalar solves.

Repro saved at ~/+Simulations/fmg_scalar_injection_bug/repro.py. Found while
adding FK stagnant-lid (Ra=1e6, Δη=1e3) support to the free-surface convection
driver; related: FMG landed in #231.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions