Preconditioners
Declarative specs — materialized against the assembled operator at solve time. A preconditioner never changes the converged solution, only the speed, so specs need no gradient path.
| Spec | What it is | When |
|---|---|---|
jno.precond.jacobi() |
diagonal | the default — cheapest thing that helps |
jno.precond.chebyshev(degree=…) |
fixed-degree polynomial — matvecs and AXPYs only | GPU, where reductions cost; a fixed linear map, so it legally preconditions cg/minres |
jno.precond.nystrom(rank=…) |
randomized low-rank deflation | SPD only — a spectrum with a few large outlying eigenvalues, where jacobi can be worse than nothing |
jno.precond.inner(solver) |
any jno.solve solver as the M⁻¹ application |
an inexact block/system solve — iterative inner ⇒ outer fgmres |
jno.precond.form([...terms], inner=…) |
an auxiliary operator assembled from ordinary traced terms | when you can write the preconditioner as a weak form |
jno.precond.block_diag((field, spec), …) |
per-field composition over fem.blocks (also triangular) |
multifield problems |
jno.precond.saddle(mass_weight=…, laplace_weight=…) |
the standard saddle recipe as one call | Stokes / Biot — the common case |
jno.precond.lsc() / saddle(schur="lsc") |
least-squares commutator — the convection-aware Schur factor | Navier–Stokes, where the pressure-mass recipe degrades with Re |
jno.precond.fsai(power=…) |
factored sparse approximate inverse M⁻¹ = GᵀG — two sparse products, no triangular solves |
SPD only — the rung between jacobi and multigrid, when the factor is reused (below) |
jno.precond.schwarz(parts=…) |
algebraic overlapping Schwarz (domain decomposition), two-level | SPD elliptic systems split across several devices; elasticity with coarse=[(1, 0), (0, 1), (-y, x)] (below) |
jno.precond.amg(cycles=…, nullspace=…) |
hybrid algebraic multigrid — host setup (pyamg), device apply |
large SPD systems; nullspace= the rigid-body modes for elasticity (a space); needs the optional pyamg |
jno.precond.jaxamg(symmetric=…) |
GPU AMG via NVIDIA AmgX — setup and apply both on device | large systems on a GPU; needs the optional stack |
reuse= (on every spec) |
keep an expensive setup across solves: True once, k every k-th solve |
Newton loops, transients and optimisation loops, where the operator barely changes between solves |
M1 + M2 / M1 @ M2 |
arithmetic on specs — applied in parallel and summed, or in sequence right-to-left | writing your own Schur approximation instead of asking for one |
M1 >> M2 |
multiplicative: M1, then M2 on the residual it left |
a coarse space with a smoother — deflation, two-level methods (below) |
jno.precond.coarse(space, parts=…) |
the correction Z (ZᵀAZ)⁻¹ Zᵀ on a subspace Z you write down |
a few slow modes another preconditioner cannot reach: stiff inclusions, rigid-body modes, constants per subdomain |
Every one of them is passed the same way — fem.solve(precond=…), alongside whichever linear=
solver it is accelerating. Nothing else about the problem changes:
fem = jno.fem([ui.x * vi.x + ui.y * vi.y - 1.0 * vi, u(xb, yb) - 0.0]) # 379 DOFs, SPD
fem.solve(linear=jno.solve.cg(tol=1e-10), precond=jno.precond.jacobi())
fem.solve(linear=jno.solve.cg(tol=1e-10), precond=jno.precond.chebyshev(degree=4))
fem.solve(linear=jno.solve.cg(tol=1e-10), precond=jno.precond.nystrom(rank=20))
fem.solve(linear=jno.solve.cg(tol=1e-10), precond=jno.precond.amg(cycles=1))
# an ITERATIVE preconditioner needs a flexible outer solver — plain gmres assumes a fixed M
fem.solve(linear=jno.solve.fgmres(tol=1e-10),
precond=jno.precond.inner(jno.solve.cg(tol=1e-2, maxiter=30)))
# reuse an expensive setup across solves: build once, pass the SAME spec every time
rigid = [(1, 0), (0, 1), (-y, x)] # rigid-body modes of a 2-D displacement field
M = jno.precond.amg(nullspace=rigid, reuse=True)
fem.solve(linear=jno.solve.cg(tol=1e-10), precond=M)
# three more with the same shape, each needing something the others do not:
jno.precond.gmg(n_pre=2, n_post=2) # geometric MG — needs a STRUCTURED grid
jno.precond.jaxamg(symmetric=True) # GPU AMG (AmgX) — needs the [amg] extra and a CUDA device
jno.precond.ams() # H(curl) auxiliary-space MG — for N1E edge elements
All six agree — the preconditioner is a speed choice, never an answer
Solved on the same 379-DOF Poisson operator, every spec above lands within 3.5e-10 of the
unpreconditioned reference (max|u − u_ref|). That is the contract: a preconditioner changes the
iteration count, never the converged solution — which is also why these specs need no gradient
path of their own.
A preconditioner's own inner solve is exempt from the convergence gate — inner(cg(tol=1e-2,
maxiter=30)) asks for two digits deliberately. See
the gate.
For a multifield system, compose per field over fem.blocks. The key is the trial symbol, not a
name — the same u/p you wrote the weak form with:
fem.solve(linear=jno.solve.fgmres(tol=1e-10, restart=40),
precond=jno.precond.block_diag(
(u, jno.precond.inner(jno.solve.cg(tol=1e-2, maxiter=60))), # velocity block
(p, jno.precond.form([(1.0 / mu) * pp * qq], inner=jno.solve.dense())), # pressure
))
Periodic ties, slip and hanging nodes. These make the solve run on the reduced system PᵀAP, reduced
field by field. The block preconditioners split that operator: the slices they are handed
(ctx.blocks) are each field's reduced DOFs, while fem.blocks keeps slicing the full solution that
fem.solve returns.
An auxiliary form([...]) is written on the full space as usual (no ties in it) and reduced with the
same field's P. So block_diag, triangular, saddle (mass, Cahouet–Chabard, lsc), pcd and
jno.solve.staggered are written exactly as on the untied problem.
The preconditioners that build a pattern once (fsai, schwarz) build it from the reduced operator, and
a coarse space written as formulas (schwarz(coarse=...), coarse(...), amg(nullspace=...)) is
evaluated on the full mesh and restricted to the kept DOFs (a translation along a periodic direction
restricts exactly). One case is refused by name: a complex form solved as its fused real-equivalent [Re;
Im] block. There a field is not one contiguous slice, so use a complex-native composition (a child such
as ams()) or a whole-system preconditioner.
jno.precond.chebyshev(degree=…)
fixed-degree Chebyshev polynomial preconditioner: matvecs and AXPYs only, the GPU-era substitute
for Gauss-Seidel/ILU smoothing, and a fixed linear map so it legally preconditions cg/minres.
Spectrum bounds come from lmin/lmax when you pass them, else both ends are measured by
Lanczos (Lanczos 1950, §II — the extreme Ritz values), at the same cost as a power iteration on the
top end alone.
This matters because the polynomial is a contraction only inside the interval it is fitted to: the
lmin = lmax/30 guess, whenever the true ratio is smaller, leaves the lowest modes outside that
interval where the polynomial amplifies them. Without the optional matfree package that guess is
the fallback.
jno.precond.nystrom(rank=…)
randomized Nyström low-rank preconditioner (Frangella, Tropp & Udell, SIAM J. Matrix Anal.
Appl. 44(2), 2023, Alg. 2.1 and §3), the rung between jacobi and a multilevel method. Sketches A
against a random n × rank matrix — exactly rank matvecs, no factorization, no triangular sweep —
and deflates the captured top of the spectrum.
That is what jacobi cannot do: a diagonal rescales, it cannot separate a few large outlying
eigenvalues, and on such a spectrum Jacobi can be worse than no preconditioner at all (measured on a
rank-15-outlier SPD system: 124 CG iterations for jacobi, 98 unpreconditioned, 46 for
nystrom(rank=20)). SPD only — the sketch takes a Cholesky, so an indefinite operator gives NaN
rather than a quiet wrong answer.
The momentum block: Picard, not Newton
A block preconditioner needs an approximate F⁻¹ on the momentum block, and which linearisation
you pick decides whether one exists. The full Newton tangent carries the reaction term (δu·∇)u,
which is indefinite — measured on a lid-driven cavity, the smallest eigenvalue of its symmetric part
goes negative by Re = 100 (table below).
Why the momentum block uses the Picard linearisation
| Re = 100 | min eig of sym(F) | AMG on that block |
|---|---|---|
| Newton tangent | −6.4e-04 | rel-resid 1.2e-03, diverges by Re = 400 |
Picard / Oseen (jno.lag on the convecting velocity) |
+8.5e-04 | 6.5e-11 |
Smoothed aggregation assumes a positive diagonal, so on the Newton tangent it builds a degenerate
hierarchy — jno.precond.amg() now refuses that by name rather than returning a V-cycle that
silently does nothing. Lag the convecting velocity and the block is definite and AMG-friendly. This
is why the Navier–Stokes preconditioning literature builds on Picard.
Does it scale?
3-D Stokes, lid-driven cube, lu(backend="host") against
fgmres + triangular((u, amg()), (p, lsc())), one 8 GB card (table below).
Direct against iterative, 3-D Stokes cube
| DOFs | direct | iterative | |
|---|---|---|---|
| 15,468 | 2.1 s | 2.9 s | direct still wins |
| 29,114 | 11.5 s | 4.6 s | 2.5× |
| 49,072 | 53.3 s | 6.5 s | 8.2× |
| 76,542 | 166.4 s | 11.4 s | 14.6× |
| 112,724 | 431.3 s | 52.0 s | 8.3× |
The crossover is around 15–20k DOFs. Note what the direct solve is not doing: it does not run out of
memory — it scales as roughly O(N³) in time and simply loses. Below the crossover it is the right
choice and stays the default.
AMG on a march
jno.precond.amg() builds its hierarchy on the host from a concrete matrix, and a march linearises
inside lax.scan where every operator is traced — so it used to refuse every transient problem. A march
now builds it once, before the scan, from the step tangent (a state-dependent mass c(u) u_t included).
How a march keeps the AMG setup
A frozen setup stays correct — a preconditioner changes convergence speed, never the answer — but goes
stale when the operator moves. reuse=k spells the cadence, and the march then runs as
ceil(n/k) scans, re-composed against the carried state:
fem.solve(linear=jno.solve.fgmres(), precond=jno.precond.amg()) # frozen once
fem.solve(linear=jno.solve.fgmres(), precond=jno.precond.amg(reuse=25))
Measured where a melt pool's coefficients move ~1e13 between solid and molten: frozen once, the Krylov
residual stalls at 2.9e-03; at reuse=25 it reaches 1.5e-04. theta()/exponential() integrate
the march themselves and are not chunked, so a cadence beside one raises rather than never firing.
A frozen preconditioner is probed once and refused if it makes a random residual worse — but only when it stands alone, since a block preconditioner need not reduce a full residual in one application.
A steady nonlinear solve has the same problem one level down: Newton runs as a lax.while_loop, so
the tangent is traced there too.
An unbuilt amg() (or ilu(), or a block holding one) is therefore built once, before the loop,
from the assembled tangent at the initial guess x0 (zero by default; a periodic, slip or hanging-node
system uses its reduced tangent). It does not follow the tangent as Newton moves: the root is unchanged
and only the Krylov speed depends on how far the tangent drifts from x0. Specs that already materialize
inside the loop (jacobi, form, lsc, pcd) are left as they were.
fem.solve(linear=jno.solve.fgmres(), precond=jno.precond.amg()) # nonlinear: built at x0
fem.solve(linear=jno.solve.fgmres(),
precond=jno.precond.triangular((u, jno.precond.amg()), (p, jno.precond.form([pb * qb / mu]))))
For Navier–Stokes, lag the convecting velocity (jno.lag, above)
so the velocity block AMG is built on is the Oseen operator. reuse=k is refused
here rather than ignored: a rebuild every k Newton iterations would need the loop cut into chunks,
which the steady solve does not do. To rebuild at a better state, solve again from that state (u.initialize(state)).
When the pressure mass is not enough
saddle()'s pressure-mass Schur approximation stands in for the Schur complement of a viscous
operator. Once convection dominates it degrades. Measured on the Newton tangent of a lid-driven
cavity (812 DOFs, momentum block solved exactly so the count isolates the Schur factor; table below):
Pressure-mass Schur factor against Reynolds number
| Re | 10 | 50 | 100 | 400 | 1000 |
|---|---|---|---|---|---|
saddle() pressure mass |
26 | 38 | 82 | 212 | 105 |
lsc() |
112 | 108 | 106 | 104 | 284 |
Over Re = 10 → 400 the mass degrades 8× while LSC is flat. The robustness ends: by Re = 1000 LSC has jumped to 284 and the mass has (non-monotonically) improved, so LSC is no longer ahead. This is a result about a range, not an unconditional one.
It is built from the system's own blocks — S⁻¹ ≈ (BM⁻¹Bᵀ)⁻¹(BM⁻¹FM⁻¹Bᵀ)(BM⁻¹Bᵀ)⁻¹ — so unlike the
form()-based approximations it cannot be written by the user as weak forms, which is why it ships as a
built-in. B and M do not depend on the solution, so P = BM⁻¹Bᵀ is assembled sparsely and
factorised once, for every application and every Newton step; only F varies, and it is only ever
applied.
Measuring this at all needs args=
These counts come from fem._op.jacobian(sol, args={"nu": …}). If the viscosity is a runtime
parameter and you call jacobian(sol) without args, it evaluates at an unset parameter and
returns a matrix that is 25 % wrong — silently. The operator then does not change with Reynolds
number at all, and every preconditioner looks perfectly robust on it. An earlier version of this
table was measured that way and was wrong.
What LSC does not give you
It is not mesh-independent here. At fixed Re = 100 on a cavity, iterations grow 36 → 67 as the pressure space grows 30 → 198 (the pressure mass grows 32 → 91 over the same range, so LSC is better but neither is flat). And the Reynolds result above is resolution-dependent: at 613 DOFs the same sweep reverses the ordering, because that mesh never enters the regime where the mass approximation degrades. Read the table as a resolved-discretisation result, not an unconditional one.
PCD — and the boundary condition that decides it
PCD (Kay, Loghin & Wathen 2002) is the other convection-aware Schur approximation,
S⁻¹ ≈ A_p⁻¹ F_p M_p⁻¹. It ships as jno.precond.pcd():
xin, yin, _ = d.variable("inlet", split=True)
fem.solve(linear=jno.solve.fgmres(),
precond=jno.precond.triangular((u, jno.precond.amg()),
(p, jno.precond.pcd(viscosity=nu, inflow=(xin, yin)))))
inflow is the coordinate tuple, not a region name — domain.variable(...) mints a fresh
region on every call (inlet_3, inlet_4, …), so a name re-resolved inside the spec would point at
a different region than the one your form constrained and the Dirichlet row would quietly miss the
boundary. Passing a string is refused by name.
Unlike LSC every factor is a weak form, so the supplied spec is a convenience, not a capability — it is verified equal (to 7e-16) to the same thing written by hand, which is where to go for a variant it does not cover:
w = wv.bind(x=xi, y=yi).freeze(u_lagged) # the convecting field, as KNOWN nodal data
lap_p, conv_p = pp.x*qq.x + pp.y*qq.y, (w[0]*pp.x + w[1]*pp.y)*qq
Ap = jno.precond.form([lap_p, p(x_in, y_in) - 0.0], inner=host) # A_p⁻¹
Fp = jno.precond.form([nu*lap_p + conv_p, p(x_in, y_in) - 0.0], inner=False) # F_p, APPLIED
Mp = jno.precond.form([pp*qq], inner=host) # M_p⁻¹
schur = Ap @ Fp @ Mp
Two conditions decide whether it works at all, and both are easy to get wrong:
| Inflow/outflow problem | On an enclosed flow (a lid-driven cavity) PCD fails outright — 400 iterations, the cap, at every Reynolds number, and its eigenvalues straddle zero. The commutator argument leans on boundary behaviour an enclosed flow does not provide. Use lsc() there. |
Inflow-Dirichlet on A_p and F_p |
With Neumann pressure operators PCD also fails (400). With a Dirichlet condition on the inflow boundary it takes 77. Same problem, same mesh, same everything else. |
Channel flow, momentum block exact, per Reynolds number:
| Re | 10 | 50 | 100 | 400 | 1000 |
|---|---|---|---|---|---|
| pressure mass | 41 | 184 | 301 | 284 | 318 |
lsc() |
63 | 158 | 150 | 291 | 263 |
| PCD | 37 | 75 | 77 | 237 | 355 |
PCD is decisively best from Re = 10 to 100 — 4× the mass at Re = 100 — and loses its edge by Re = 400, where everything degrades. Neither method is Reynolds-robust at the top of that range.
Preconditioners compose like the operators they stand for
A materialized spec is a linear map v ↦ M⁻¹v, so the classical physics-based Schur
approximations are arithmetic on specs rather than a menu of built-in names:
Ap = jno.precond.form([inner(gp, gq, n_contract=2), p_sym.pin()]) # A_p⁻¹ (gauged Laplacian)
Mp = jno.precond.form([pp * qq]) # M_p⁻¹ (pressure mass)
Fp = jno.precond.form(F_terms, inner=False) # F_p APPLIED, not inverted
schur = Mp + Ap # Cahouet & Chabard (1988) — which `saddle(laplace_weight=…)` already is
schur = Ap @ Fp @ Mp # PCD — Kay, Loghin & Wathen, SIAM J. Sci. Comput. 24 (2002) 237
fem.solve(linear=jno.solve.fgmres(),
precond=jno.precond.triangular((u, jno.precond.amg()), (p, schur)))
inner=False is the piece that makes a product expressible: it applies the assembled form
(M v = A v) instead of inverting it, which is what the middle factor of PCD needs. On its own such a
factor is not a preconditioner and will make a solve worse — it exists to be composed.
A product is not symmetric
(AB)ᵀ = BᵀAᵀ, and a product of two SPD inverses is not SPD. Drive a product with
jno.solve.gmres() / fgmres(), never cg/minres — a short-recurrence method will simply
fail to reach the residual gate, loudly. (The transpose applier reverses the factor order for
you, which is what keeps the reverse pass of a differentiable solve preconditioned.)
This is why jno.precond.saddle() has no schur= argument: the approximations that would populate
such a menu are things you can write.
jno.precond.form([...terms], inner=…)
preconditioners as weak forms: assemble an auxiliary operator from ordinary traced terms and
invert it as M⁻¹ (weighted mass matrices, shifted-Laplacian Helmholtz twins, low-order proxies —
written in the PDE's language). Pass a callable form(lambda sol: [...terms...]) for a
solution-dependent auxiliary — a (1/μ(u))-weighted Schur mass whose weight is computed from the
current solution.
It is re-assembled once per outer solve from that solve's entry iterate (warm start / previous march
step) — the Picard-lagged preconditioner (Elman, Silvester & Wathen 2014, §9.2): the coefficient
trails the solution by one outer solve, which changes convergence speed only, never the answer.
Eager by necessity — every Newton loop is a lax.while_loop, so the per-step iterate is a tracer no
host assembly can see; a fully traced solve that never supplies a concrete iterate gets a loud
NotImplementedError, not a garbage preconditioner.
A coefficient from another field. An auxiliary form is written over one field, and the
coefficient it needs often lives on another — PCD's F_p carries the velocity into a pressure
form, a lagged eddy viscosity carries the previous velocity, a wall-distance field is reused
across forms. Freeze the foreign field and use it like any other coefficient:
w_frozen = w.bind(x=xi, y=yi).freeze(w_values) # another form's solved field, as data
Fp = jno.precond.form([(nu + w_frozen) * (pi.x * qi.x + pi.y * qi.y), p(xb, yb) - 0.0])
The auxiliary form never declares that field as an unknown, so it is resolved by space rather than by identity: a field of the same space and order has the same nodes and connectivity on this mesh, so the gather is exact, not an interpolation.
Matching space only — a mismatch is refused, not approximated
The foreign field's space must be one the auxiliary form already uses. A P2 field in a P1 form raises: P2 values carry edge nodes a P1 gather never indexes, and reading them through a P1 slot would produce a plausible, wrong operator rather than a visible failure. Project onto the form's own space first, or write the form over a field of the matching space.
This is what still blocks PCD on a Taylor–Hood pair, where the velocity is P2 and the
pressure P1. lsc() needs no such coefficient, which is why it exists.
jno.precond.block_diag((field, spec), …)
/ jno.precond.triangular((field, spec), …) — per-field
composition over fem.blocks. triangular is the standard saddle-point shape: last block solved
first, substituted back through the assembled off-diagonal matvecs.
jno.precond.saddle(mass_weight=…, laplace_weight=…)
that standard shape as one call, for the common case. It finds the constraint block
structurally (the field with no diagonal entry — the same detection behind the saddle-system
warning), puts amg() on the momentum block and a weighted pressure mass matrix on the
constraint block, and assembles that mass on the domain's own P1 space, so no symbols are passed and
it reads identically in 2-D and 3-D.
mass_weight is explicit and never inferred (1/μ for Stokes): digging μ out of an arbitrary weak
form is fragile, and a variable viscosity would silently take the wrong weight — which costs
iterations without ever failing. A wrong weight changes convergence speed only, never the answer.
Pair with jno.solve.fgmres; minres does not apply (block-upper-triangular is nonsymmetric). Needs
pyamg, and refuses by name on a non-saddle system or a constraint field that is not P1 — for
anything outside that, compose triangular yourself.
The mass matrix alone is the pure-Stokes approximation: a strong reaction term (Brinkman / Darcy
drag, or the 1/dt mass of a small implicit step) makes the Schur complement stop looking like a
mass matrix, and the mesh-robustness degrades. laplace_weight switches to the Cahouet–Chabard
approximation, a pressure mass plus a pressure Laplacian, S⁻¹ ≈ μ·M_p⁻¹ + α·L_p⁻¹ (Cahouet &
Chabard, IJNMF 8, 869–895, 1988, §3). Both weights are the reciprocal of the coefficient the
term stands for, so mass_weight=1/μ and laplace_weight=1/α.
Measured through this spec on a 2-D Brinkman channel (μ=1, mesh_size=0.12, preconditioned GMRES
to 1e-8, restart=200): α = 0 / 1e2 / 1e3 / 1e4 → 83 / 135 / 503 / 2312 with the mass alone,
83 / 60 / 76 / 74 with Cahouet–Chabard. The point is the flatness, not the 31× at α=1e4 — the
count stops tracking α.
The same collapse appears with the momentum block inverted exactly instead of by AMG (31 / 63 / 134 /
189 → 31 / 26 / 25 / 24), which is how you can tell it is the Schur approximation doing the work and
not the multigrid. At α=0 the two are the same preconditioner — that column is one number measured
twice — so leave laplace_weight at its None default on pure Stokes and the Laplacian is never
assembled.
The pressure Laplacian is pure-Neumann and therefore singular — and a sparse LU of it factors
happily and then applies nonsense, so the auxiliary carries its own gauge pin and the applier
projects the constant out on both sides. It is derived for a constant α; a spatially varying drag
(topology optimisation's α(ρ)) takes a representative scalar and degrades gracefully rather than
failing.
jno.precond.amg(cycles=…)
hybrid algebraic multigrid: setup once on the host via the optional
pyamg (Vaněk, Mandel & Brezina, Computing 56, 1996; PyAMG — Bell et al., JOSS 8(87), 2023),
applied as a pure-JAX V-cycle with Chebyshev smoothing (Adams et al., JCP 188, 2003). The apply is
jit/vmap-native and exactly linear, so it preconditions cg/minres too. Mesh-independent
convergence ⇒ the choice for large elliptic blocks. Inside traced/parametric solves, pre-build
eagerly: spec = jno.precond.amg(); spec.build(fem.A). Without pyamg, amg raises a clear install hint.
jno.precond.jaxamg(symmetric=…)
GPU AMG via NVIDIA AmgX as the M⁻¹ application (setup and
apply both on the device). symmetric=False builds a second hierarchy on Aᵀ so the adjoint
(reverse-mode) solve of a non-symmetric operator is preconditioned too. Measured caveat: each AmgX
application carries ~11 ms of fixed handle overhead, so it pays only where the iteration savings
exceed it — for most problems prefer precond.amg() (whose V-cycle compiles into the solve) or
linear=jno.solve.amg() (ONE AmgX crossing per solve, with warm structure-keyed re-setup measured
~10x cheaper on repeats).
reuse=
on every spec — keep an expensive setup across solves, the keyword lu and newton use too: False
(default) rebuilds every solve, True builds on the first solve and keeps it (pass the SAME spec
object), an int k rebuilds every k-th solve (the cadence for a march whose operator values drift
step by step). A solve whose preconditioner is kept compiles once and is reused.
It replaces jno.precond.cached(spec) and spec.cached(): cached(spec) is spec with reuse=True,
cached(spec, refresh=k) is reuse=k. refresh=True (rebuild when the operator's sparsity changes) and
refresh=callable (a custom key) have no equivalent; a kept setup is rebuilt only by reuse=k.
The flagship pattern — Taylor–Hood Stokes by FGMRES with an inexact velocity block solve and the viscosity-weighted pressure-mass Schur approximation (Elman, Silvester & Wathen, 2014, §9.2):
sol = fem.solve(
linear = jno.solve.fgmres(tol=1e-10, restart=40),
precond = jno.precond.triangular(
(u, jno.precond.inner(jno.solve.cg(tol=1e-2, maxiter=60))), # Â⁻¹: inexact CG
(p, jno.precond.form([(1.0/mu) * pp * qq], inner=jno.solve.dense())), # Ŝ ≈ μ⁻¹ M_p
),
)
…and the same recipe when the defaults suit — multigrid on the momentum block, exact pressure mass:
sol = fem.solve(linear=jno.solve.fgmres(tol=1e-10, restart=150),
precond=jno.precond.saddle(mass_weight=1.0/mu))
Give FGMRES enough restart: the default restart=30 stagnates on a 3-D Taylor–Hood block
preconditioner and does so quietly — it still returns, just slower and less accurate. Measured at
4302 dofs, tol=1e-10: restart=30 → 2.30 s for 3.3e-6; restart=150 → 0.49 s for 3.3e-9. On
3-D Stokes this is what makes the recipe overtake a direct factorisation — measured crossover at
~15k dofs, and 3.4–3.9× faster (23.2 s → 5.9–6.9 s over repeat runs) at 41k, where LU's fill-in also
costs more memory.
On a reaction-dominated system — Brinkman/Darcy drag, or a small implicit time step — add the Laplacian leg, and the iteration count stops tracking the reaction coefficient: