Fundamentals / Numerical mathematics / Numerical partial differential equations

Building a local residual estimator and refining where it matters

A finite-element solution can satisfy the assembled equations to machine precision while still missing curvature between nodes. Integrate the residual of the computed field by parts on each element and use the resulting cell and interface terms to decide where to spend the next degrees of freedom.

Ask what the discrete solution does to an unresolved test function

Consider \(-u''=f\) on a unit interval with zero Dirichlet data. Use continuous piecewise-linear finite elements with exact integration on a possibly nonuniform mesh. The weak solution satisfies \(a(u,v)=\int u'v'=\int fv\) for every test function vanishing at the endpoints. For \(e=u-u_h\), subtract the computed field to obtain

\[a(e,v)=R(v)=\int fv-\int u_h'v'.\]

The algebraic system makes \(R(v_h)=0\) for all functions in the chosen finite-element space. Tests with more local structure expose what is missing.

\[R(v)=\sum_K\int_K (f+u_h'')v\,dx+\sum_{i\ {\rm interior}} J_i v(x_i),\]
\[J_i=u_h'(x_i^+)-u_h'(x_i^-).\]

The sign follows by adding the right boundary term of the left cell and the left boundary term of the right cell. On a linear cell \(u_h''=0\) classically. Its piecewise constant gradient jumps at interior nodes. In diffusion with varying coefficient k the corresponding jump is in \(k u_h'\), since continuity of normal flux is the conservation condition. A discontinuous material coefficient can cause an exact gradient jump without any flux imbalance.

Scale the cell and node terms before marking

Subtract the finite-element interpolant or a local quasi-interpolant from v inside the residual. Galerkin orthogonality permits this subtraction and bounds the remaining test magnitude by local length times its gradient. This leads to a computable residual indicator. One common one-dimensional choice with a symmetric edge length \(h_i\) equal here to the smaller neighbouring cell is

\[\eta_K^2=h_K^2\int_K f^2\,dx+{1\over2}\sum_{i\in\partial K\ {\rm interior}}h_i J_i^2,\]
\[\eta^2=\sum_K\eta_K^2.\]

Sharing the node contribution prevents double counting. Under the usual mesh and coefficient assumptions such estimates bound the energy error up to constants; their absolute numbers need not equal the measured error. Data oscillation can matter if the source is approximated or oscillates within a cell. To mark by bulk contribution, sort \(\eta_K^2\) in descending order and take cells until their sum exceeds a chosen fraction of the global squared estimator. Bisect marked cells, transfer the coefficient data, assemble and solve again. Reusing the old gradient jumps after refinement would skip the effect of the new trial space.

Work through the first two-element decision

Let \(f=1\) on the left half and \(f=9\) on the right. With two equal cells and zero end values there is a single interior hat unknown. Diagonal stiffness is 4 and the integrated hat load is

\[1(0.25)+9(0.25)=2.5.\]

The middle value is therefore 0.625. The slopes are 1.25 and −1.25, giving \(J=-2.5\). Since \(h=0.5\), the two cell terms are 0.125 and 10.125. Each side receives \((1/2)(0.5)(2.5)^2=1.5625\) from the node. The right cell contributes \(11.6875/(1.6875+11.6875)=87.38\%\) of the squared indicator. A 50% bulk mark selects only that cell.

For this particular problem the finite-element solution equals the piecewise-linear interpolant of the true nodal values. This follows by testing the derivative of the interpolation error against a constant basis gradient on each element. For constant f on each element the derivative error is therefore a line of slope −f with zero mean. Its exact squared energy norm is \(\sum f_K^2 h_K^3/12\). Splitting the right half into two equal cells reduces that half's contribution by a factor of four. Total energy error falls from 0.924 to 0.470 with one extra degree of freedom. Splitting only the left cell leaves about 0.920. Run the loop and compare the indicator's ranking with this independent verification quantity.

Run the mesh from zero to three refinement rounds with a 50% bulk mark. Record error against free values. Repeat with a 90% mark and compare equal computational costs where available. Which choice targets the source localization most strongly?

Tutorial · predict the benefit of two candidate splits

Consider a left cell of length 0.50 with \(f=1\) and a right cell of length 0.125 with \(f=9\). Which single split would remove more exact squared energy error? Show how stiffness residual and source localization answer distinct questions.

Show the local comparison

Bisection removes three quarters of that cell's \(f^2h^3/12\). Before division by 12 the left weight is \(1(0.5)^3=0.125\); the right weight is

\[81(0.125)^3=0.1582.\]

Refining the small right cell still yields about 27% more improvement. Conversely the assembled nodal residual could already be zero on either mesh after a direct solve. Reducing the algebraic tolerance further would improve neither piecewise-linear profile. This calculation is a verification benchmark made possible by the manufactured piecewise-constant data.

Further reading · Joachim Schöberl, Interactive Finite Elements · a posteriori error estimation by residuals

Study the full derivation

Bound diffusion error by balancing a reconstructed flux · Spatial discretisation and field equations

A temperature field from a finite-element calculation looks smooth. Reconstruct a heat flux which exactly balances the source, then derive an upper bound for the true energy error without knowing the exact temperature.