Theory contents

Linear solve

On this page

How is the linear system solved, and what do tolerance and non-convergence mean?

An iterative solver improves a displacement estimate until an algebraic imbalance is small enough. That establishes how closely it solves the assembled equations. Mesh refinement and comparison with physical evidence answer separate questions. This page covers static, small-strain, isotropic linear-elastic solids; the implementation details refer to KoFEM’s ordinary solid solve. Shell, coupled and optimization solvers have their own settings.

The system after constraints

Assembly collects the element equations. Displacement constraints then move known values to the right-hand side. Write the resulting system as:

Ax=b.

Here A is the constrained stiffness matrix, x contains the displacement coefficients, and b is the modified load vector, including prescribed-displacement contributions. This local b is a discrete vector, not the continuum body-force field. In the N–mm system, their units are N/mm, mm and N. KoFEM keeps each constrained row as an identity row that restates its prescribed value; the free rows express force balance.

Conjugate gradients and preconditioning

Conjugate gradients (CG) uses sparse matrix–vector products and a few vectors instead of forming a dense inverse. It chooses successive search directions that are orthogonal in the stiffness inner product. In exact arithmetic, CG solves a positive-definite system in at most as many steps as there are unknowns. Rounding and poor conditioning make that bound an impractical iteration budget.

Relative residual against iteration on a logarithmic scale for a small plane-elasticity problem. Conjugate gradients without a preconditioner needs many more iterations to reach the 10 to the minus 6 tolerance than conjugate gradients preconditioned with symmetric Gauss–Seidel.
Conjugate gradients on the plane-elasticity system of a small triangular mesh, clamped at one end and loaded at the other. Symmetric Gauss–Seidel preconditioning, one of KoFEM’s two choices, reaches a 10−6 relative tolerance in far fewer iterations. Computed for this figure; the plotted residual is the preconditioned norm relative to its initial value.

CG assumes a symmetric positive-definite matrix: vTAv>​0 for every nonzero vector v. For elastic solids this means every admissible nonzero deformation costs positive strain energy. It requires stable material properties, valid elements and enough constraints on every connected part to remove rigid motions. Merely adding one support does not establish these conditions.

A preconditioner cheaply approximates the inverse action of A. Call its matrix M; applying it means solving approximately with M, not explicitly inverting it. Preconditioned CG also requires a fixed, symmetric positive-definite preconditioner. The Solve panel offers two:

Which residual does the solver measure?

At iteration k, the estimate xk has algebraic residual rk:

rk=b−Axk.

On free solid rows this is the remaining nodal force imbalance, in N. Constrained rows enforce prescribed values; their residual is not a support reaction. KoFEM measures the Euclidean norm of the residual relative to the load:

ρk=|rk|2|b|2.

The solve log calls ρk the force residual. It is dimensionless and means the same accuracy whichever preconditioner is chosen. It is the ratio of two vector norms, not the largest nodal force imbalance. Constrained rows, which hold prescribed values, enter both norms; for fixed supports they are zero. CG updates the residual recursively during the iteration; the solve does not independently recompute the final force imbalance or estimate a condition number.

Tolerances and stopping

The relative tolerance τrel asks for a reduction of the residual relative to the load. KoFEM tests the squared quantities after every step:

|rk|22≤τrel2|b|22.

A relative tolerance of 10−6 asks for a residual a million times smaller than the load, or a factor of 10−12 in the squared test. It does not promise six correct digits of displacement or stress. There is no absolute tolerance.

Ordinary solid solve in KoFEM
SettingValueControl
PreconditionerAMG multigrid or Gauss–Seidel“Solver” on the Solve panel; AMG is the default
Relative tolerance1e-6Fixed internally
Stopping measure|rk|2/|b|2Fixed internally
Initial budget5000 iterationsInternal default; callers can supply cgIterationLimit, not an ordinary solver-settings input
Additional budget1–1 000 000 per continuationUser enters “Extra iterations” in “Keep solving?”

The app exposes the preconditioner and continuation, not a solid tolerance control. Optimization tolerance inputs belong to another solver path. With no load and nothing prescribed, b=​0: the solution is exactly zero and the solve accepts it before the first step.

Worked example: two free bar DOFs

Take two axial bar elements of stiffness 1 N/mm each. Fix the left node and apply 1 N to each of the other two nodes. Their free displacements are x1 and x2, in mm. The reduced system is:

A=[2−1−11]

b=​(1,1)T N. Equilibrium gives x=​(2,3)T mm: the first element carries 2 N, the second 1 N. Start CG at zero. For the forward/backward Gauss–Seidel pair, the inverse action is:

M−1=[3/41/21/21]

Initially M−1r0=​(5/4,3/2)T mm and r0TM−1r0=​11/4 N·mm. CG uses this preconditioned product for its step lengths; the first is 22/13. The stopping test uses the plain residual norm. The resulting iterates are:

Exact arithmetic, symmetric Gauss–Seidel preconditioning
IterationDisplacement (mm)Residual (N)rTM−1r (N·mm)Relative residual
0(0,0)(1,1)11/41
1(55/26,33/13)(−9/13,15/26)99/3380.637232
2(2,3)(0,0)00

At iteration 1, |r1|22=​549/676 N2 and |b|22=​2 N2, so ρ1=​549/1352≈​0.637232. The current 10−6 target requires the second step, and a one-step budget fails to converge. For illustration, a looser relative tolerance of 0.7 would accept step 1; that tolerance is not an app setting. The linked calculation below reproduces the steps in floating point, where roundoff can leave a small nonzero final residual.

Conditioning, scaling and rigid modes

Conditioning describes how strongly a solution responds to perturbations. For a symmetric positive-definite matrix, the spectral condition number κ2(A) is the largest eigenvalue divided by the smallest. Widely separated stiffness scales make this ratio large. CG depends on the spectrum after preconditioning; a good preconditioner clusters those scales.

Residual size alone cannot bound displacement error without information about the inverse stiffness. Let x denote the exact solution of these discrete equations and ek=​x−xk the algebraic error. Then Aek=​rk. For nonzero load and solution, ordinary Euclidean norms satisfy:

|ek|2|x|2≤κ2(A)|rk|2|b|2.

The right-hand factor is the reported ρk, but the condition number of a real stiffness matrix is large and unknown, so the bound gives no useful error estimate. In practice:

Iteration budgets and failure

A budget limits work; it is not a convergence criterion. At the initial 5000-step solid budget, KoFEM can pause at Keep solving? when a recent residual window shows progress. The policy checks both window endpoints and the geometric means of its two halves; it tolerates oscillations but requires improvement beyond roundoff. The window is half the initial budget, at most 100 iterations. This heuristic predicts neither eventual convergence nor the validity of the model.

Continue adds the requested number of iterations to the live loop. It preserves the iterate, residual, search direction, preconditioner and original convergence target. The prompt may recur. Stop, including Escape, raises an explicit error and discards the partial result. When the residual no longer falls, the budget ends the solve with an error.

That error reports the relative residual, iteration count and target 1e-6, with “The partial result was discarded”. Two other errors stop a solve early and say the model is probably not fully constrained: a multigrid setup whose coarsest system is singular, and a CG breakdown, where a search direction meets zero or negative stiffness. A non-convergence message alone does not diagnose singularity; a constrained but poorly conditioned model can also fail.

Check body connectivity and supports first, then material values and units, element quality and stiffness contrasts. Inspect the displacement pattern and residual history if available. A falling residual may justify more iterations; a plateau calls for investigating conditioning. Although the current error suggests refining the mesh, refinement can make convergence harder.

Three different accuracy questions

What each check establishes
QuestionEvidenceRemaining uncertainty
Linear-solver convergenceResidual meets the algebraic stopping test for one assembled systemDisplacement error depends on conditioning; mesh and model errors remain
Mesh convergenceA chosen quantity stabilizes under suitable refinement or higher order, with adequate linear solvesSingular peak stress may never stabilize; modelling assumptions remain
Physical model accuracySuitable assumptions, loads, supports and materials; comparison with analysis, experiments or trusted referencesSmall strain and linear elasticity may fail even on a fine mesh with a tiny residual

Judge the displacement or stress quantity needed for the engineering decision. The axial-bar benchmark checks extension against a known solution. A single passing benchmark does not validate all meshes or boundary conditions. The result interpretation chapter develops these checks further.

KoFEM implementation

KoFEM’s solid solve runs in its Rust finite-element module.

The worked example above was checked independently of the production solver; it illustrates the equations, not KoFEM’s code path. KoFEM’s automated tests drive the real solid solver through successful continuation, Stop and an exhausted iteration budget, and check that a continued solve gives the same final field as an uninterrupted one.

Why KoFEM uses this method

Choice and rationale. Sparse CG suits a constrained, positive-definite elastic system and keeps storage and per-step work modest in the browser. Smoothed-aggregation multigrid uses the six rigid-body motions to correct the long-range errors that local sweeps leave, so it needs far fewer iterations on large and thin-walled models. Gauss–Seidel remains as the simpler choice. The implementation has a fixed accuracy target, checks convergence and lets a progressing solve continue without restarting.

Tradeoff and alternatives. Multigrid costs a setup step and extra memory for its coarse levels, and an under-constrained model fails already in that setup. Geometric multigrid and other algebraic multigrid variants are alternatives. Sparse direct factorization is another general option, with fill-in and memory costs; the current solid path does not select it as a fallback.

Limits. A correctly constrained but very large or poorly conditioned model may still stagnate or need many extensions. Continuation cannot repair a rigid mode or make a wrong physical model accurate.

Sources and further reading

  1. Vaněk, Mandel and Brezina, “Algebraic multigrid by smoothed aggregation for second and fourth order elliptic problems”, Computing 56 (1996), the multigrid preconditioner.
  2. Shewchuk, An Introduction to the Conjugate Gradient Method Without the Agonizing Pain (1994), conjugacy, conditioning and preconditioning.
  3. Saad, Iterative Methods for Sparse Linear Systems, second edition (2003), preconditioned CG and stopping criteria.