Skip to content

Coarse spaces for Schwarz: layered elasticity

FEM coarse_spaces_layered_elasticity.py

Overlapping Schwarz solves a problem on many small subdomains at once, but information travels only one subdomain per iteration, so the iteration count grows with the number of subdomains. A coarse space names the few slowly varying modes the local solves cannot reach and solves for them globally. For elasticity these are the rigid-body modes, except when a stiffness jump cuts through the subdomains; then GenEO finds the rest.

The layered block at contrast 10^4, 64 subdomains. Three panels one above the other, one per preconditioner (one-level Schwarz, rigid-body coarse space, GenEO coarse space), show the CG error |u_k - u| over the block on one logarithmic colour scale while k grows. The one-level error stays large over the whole block for hundreds of iterations. With rigid-body modes it fades slowly and lingers in the soft layers. With GenEO it is gone after a few dozen iterations.

The CG error \(|u_k-u|\) over the block for the three preconditioners at the same iteration \(k\), on one logarithmic scale; contrast \(10^4\), 64 subdomains.

The 4 by 1 block sagging under its own weight, clamped at the left edge (hatched). Stiff layers are drawn blue-grey, soft layers orange, the thin outlines are the 64 subdomains and the dashed rectangle is the undeformed block.

The problem: the block sags under its own weight (magnified four times). The subdomains ignore the layers.

The problem

Plane-strain elasticity on a \(4\times1\) block, clamped on the left and loaded by its own weight, made of four layers whose Young's modulus alternates between \(E=10^4\) and \(E=10^4/c\). The preconditioned CG solves \(A\,u=b\) with the two-level balancing Neumann–Neumann preconditioner

\[P^{-1} = Q + (I-QA)\,S\,(I-AQ),\qquad Q = Z\,(Z^\top A Z)^{-1} Z^\top,\]

with \(S\) the one-level Schwarz preconditioner and \(Z\) the coarse space.

The jNO code

The coarse space is a value: here the three rigid-body modes, written as formulas in the coordinates. parts=S cuts them to the subdomains of the Schwarz preconditioner, and Q >> S >> Q is the balancing combination:

rigid = [(1, 0), (0, 1), (-y, x)]  # the 2-D rigid-body modes: two translations, one rotation
for p in PARTS:
    S = jno.precond.schwarz(parts=p, coarse=False)  # one level: local solves on p METIS subdomains
    Q = jno.precond.coarse(rigid, parts=S)  # the same vectors, cut to S's subdomains
    its[contrast, "rigid", p] = cg_iterations(fem, Q >> S >> Q, ref)  # balancing Neumann-Neumann

jno.space.geneo() (Spillane et al., Numer. Math. 126, 2014) builds the coarse space from local eigenproblems: on each subdomain, its own operator with free edges against its block of the global operator, keeping the eigenvectors below tau = 0.2. A subdomain that straddles a soft layer contributes the sliding motion that no rigid mode represents:

G = jno.precond.coarse(jno.space.geneo(), parts=S)  # computed from S's subdomains by local eigenproblems
its[contrast, "geneo", p] = cg_iterations(fem, G >> S >> G, ref)

Result

CG iterations to \(10^{-8}\), 4,068 unknowns, every solve checked against the sparse-direct answer:

preconditioner contrast 1: 4 / 16 / 64 parts contrast \(10^4\): 4 / 16 / 64 parts
one level 55 / 109 / 170 80 / 199 / 291
rigid-body modes 46 / 56 / 45 73 / 136 / 110
GenEO 23 / 39 / 36 26 / 38 / 40

The rigid-body modes stop the growth with the number of subdomains, but at high contrast they leave two to three times the homogeneous count. With GenEO the contrast costs nothing.

Full script

The whole script, as it runs in the tests
"""Coarse spaces for two-level Schwarz: rigid-body modes, where they stop being enough, and GenEO."""

import jax
import numpy as np

import jno

jax.config.update("jax_enable_x64", True)  # Schwarz keys its entries in int64; the solves run in float64
run = jno.setup(__file__)
R, NU, E_STIFF, RHO_G = jno.shape.rect, 0.3, 1e4, 0.1
PARTS, CONTRASTS = (4, 16, 64), (1, 1e4)


def layered_block(contrast, h=0.05):
    """Plane-strain elasticity on a 4 x 1 block of four layers, clamped on the left, under its own weight; soft layers E = E_STIFF / contrast."""
    soft = E_STIFF / contrast
    d = (
        (
            R(0, 0.00, 4, 0.25).name("layer0").attach(E=E_STIFF)
            + R(0, 0.25, 4, 0.50).name("layer1").attach(E=soft)
            + R(0, 0.50, 4, 0.75).name("layer2").attach(E=E_STIFF)
            + R(0, 0.75, 4, 1.00).name("layer3").attach(E=soft)
        )
        .sized(h)
        .domain()
    )
    x, y, _ = d.variable("interior", split=True)
    left = d.variable("left", split=True)
    u = d.unknown.vector(2)
    v = u.test()
    eps, tr, ddot = (lambda w: jno.np.symgrad(w, [x, y])), jno.np.trace, (lambda a, b: jno.np.inner(a, b, n_contract=2))
    lam, mu = d.E * NU / ((1 + NU) * (1 - 2 * NU)), d.E / (2 * (1 + NU))
    fem = jno.fem([2 * mu * ddot(eps(u), eps(v)) + lam * tr(eps(u)) * tr(eps(v)) + RHO_G * v[1], u(*left) - (0.0, 0.0)])
    return fem, (x, y)


def cg_iterations(fem, precond, ref):  # every solve is checked against the sparse-direct answer
    sol = np.asarray(fem.solve(linear=jno.solve.cg(tol=1e-8, maxiter=5000), precond=precond))
    assert np.abs(sol - ref).max() < 1e-5 * np.abs(ref).max()
    return fem.stats["linear_iterations"]["total"]


its = {}
for contrast in CONTRASTS:
    fem, (x, y) = layered_block(contrast)
    ref = np.asarray(fem.solve(linear=jno.solve.lu()))
    rigid = [(1, 0), (0, 1), (-y, x)]  # the 2-D rigid-body modes: two translations, one rotation
    for p in PARTS:
        S = jno.precond.schwarz(parts=p, coarse=False)  # one level: local solves on p METIS subdomains
        Q = jno.precond.coarse(rigid, parts=S)  # the same vectors, cut to S's subdomains
        G = jno.precond.coarse(jno.space.geneo(), parts=S)  # computed from S's subdomains by local eigenproblems
        its[contrast, "one-level", p] = cg_iterations(fem, S, ref)
        its[contrast, "rigid", p] = cg_iterations(fem, Q >> S >> Q, ref)  # balancing Neumann-Neumann
        its[contrast, "geneo", p] = cg_iterations(fem, G >> S >> G, ref)
    print(f"contrast {contrast:g}  ({fem.dofs} dofs): CG iterations to 1e-8")
    for name in ("one-level", "rigid", "geneo"):
        print(f"  {name:10s}" + "".join(f"  parts={p:<3d} {its[contrast, name, p]:4d}" for p in PARTS))

for c in CONTRASTS:  # rigid modes keep the count from growing with the subdomains
    assert its[c, "rigid", 64] < 0.6 * its[c, "one-level", 64]
assert (
    its[1, "rigid", 64] < 1.5 * its[1, "rigid", 4] and its[1e4, "rigid", 64] > 2 * its[1, "rigid", 64]
)  # but the contrast stays
for p in PARTS:  # GenEO closes the gap: the contrast costs almost nothing
    assert its[1e4, "geneo", p] < 0.6 * its[1e4, "rigid", p] and its[1e4, "geneo", p] < 1.3 * its[1, "geneo", p]