Skip to content

Linear Solvers

Once a model has assembled and constrained its system \(A\,\mathbf{x} = \mathbf{b}\), a linear solver computes the solution \(\mathbf{x}\). This is the innermost and often most expensive part of a simulation. μfem offers two families, direct and iterative, selected per model on its Solver page (for example the Time-Harmonic Magnetic Solver).

Direct solvers

A direct solver computes \(\mathbf{x}\) by factorizing the system matrix (a sparse \(LU\) or Cholesky decomposition) and then performing forward and backward substitution. μfem uses MUMPS, a parallel sparse direct solver, for both real- and complex-valued systems.

Direct solvers are robust: they solve any non-singular system in a single pass, with no tolerances to tune and no convergence to monitor. Their cost is memory and time. The factorization fills in many of the zero entries of a sparse matrix, so storage and work grow rapidly with problem size, especially in three dimensions. Direct solvers are therefore the natural choice for small to medium problems, or as a dependable reference when an iterative solver struggles to converge.

Iterative solvers

An iterative solver never forms a factorization. Starting from an initial guess it builds a sequence of improving approximations, each step requiring only a few matrix-vector products with \(A\). μfem uses Krylov subspace methods: the conjugate gradient method (CG) for symmetric positive-definite systems, and GMRES / flexible GMRES (FGMRES) for the general case.

Because they touch the matrix only through matrix-vector products, iterative solvers keep the sparsity of \(A\) and have a much smaller memory footprint. They scale to large meshes where a direct factorization would be infeasible. The trade-off is that convergence is not guaranteed in a fixed number of steps and depends strongly on the conditioning of the system, which is where preconditioning enters.

The iteration is governed by a stopping criterion and an iteration budget:

Control Meaning
Relative tolerance Stop once the residual norm has dropped by this factor relative to the initial residual.
Absolute tolerance Stop once the residual norm falls below this floor, regardless of the initial value.
Maximum iterations Cap on the number of iterations, so a poorly conditioned solve terminates.

The exact defaults and setters are documented on each model's Solver page.

Preconditioning

The convergence rate of a Krylov solver is set by the conditioning of the system. A preconditioner \(M\) approximates \(A\) but is cheap to invert, and transforms the system into an equivalent one that iterates far faster:

\[ M^{-1} A\,\mathbf{x} = M^{-1}\mathbf{b} . \]

A good preconditioner makes \(M^{-1} A\) close to the identity, so the solver converges in few iterations; the art is balancing that quality against the cost of applying \(M^{-1}\) every step. μfem provides several, matched to the structure of the problem:

Preconditioner Typical use
Jacobi / diagonal Cheapest option; rescales by the matrix diagonal.
Algebraic multigrid (BoomerAMG) Strong general-purpose preconditioner for scalar elliptic problems (for example thermal conduction).
Auxiliary-space Maxwell (AMS) Tailored to \(H(\mathrm{curl})\) edge-element systems that arise in electromagnetics.
Block-diagonal For coupled multi-field systems: preconditions each physical field block separately.

The multigrid and auxiliary-space preconditioners are what let the iterative solvers retain a nearly mesh-independent iteration count as the problem is refined, which is the key to scaling to large three-dimensional models.