Techniquecore
Patch test
Checks that a small patch of distorted elements reproduces a linear exact solution to rounding error. It finds consistency errors in elements and codes, but passing it does not prove convergence.
The patch test checks a finite element, or a whole finite element code, on a small problem whose exact solution the element must reproduce. Take a patch of a few elements with at least one interior node and with distorted shapes. Choose an exact solution in the space that the element must contain, usually a linear field, which has a constant gradient (constant strain in elasticity). Prescribe its values on the boundary of the patch and solve for the interior nodes. The element passes if the computed values and the computed gradients equal the exact ones to rounding error. A conforming element with exact integration always passes. The test finds errors of consistency: wrong shape functions, wrong quadrature, a wrong Jacobian, or nonconforming shape functions whose jumps between elements do not cancel. Passing is not a proof of convergence. Stummel gave a nonconforming element that passes and does not converge, and the test also says nothing about stability unless it includes the stability part of Taylor and coauthors.
In plain words
When the mesh gets finer, the true solution looks flatter and flatter inside each small group of elements. A good element must get a perfectly flat solution exactly right, or its error will not go away when the mesh is refined. The patch test checks this. Build a few elements of odd shapes around one inner point. Fix the outer edge to the values of a flat solution. Solve, and look at the inner point and at the computed slopes. If they are not right to the last digits, something is wrong in the element: in its shape functions, in its numerical integration, or in how its pieces join. The test is small, fast and should be in the automatic tests of every finite element code.
When it applies
- A new element type, a new quadrature rule, a new mapping from the reference element, or new code that assembles the stiffness matrix.
- Nonconforming elements, whose shape functions are not continuous between elements, and elements with incompatible modes or assumed strains. For these the test is a real check of consistency, not a formality.
- Methods without a standard mesh: mesh-free methods, the extended finite element method, the virtual element method and contact or interface discretizations.
- Any problem where the element must contain an exact polynomial space. For second order equations this is the linear functions. For plate bending in Kirchhoff theory it is the quadratic functions.
The template
- Choose the patch. Use at least one interior node, and elements that are not parallelograms, of mixed size and with all the node types of the element (corner, edge and interior nodes). Bugs that cancel on regular meshes appear on distorted ones.
- Choose the exact solution. Take a polynomial of the degree that the element must reproduce, for example , with zero body force. Repeat with each basic field (, , and, in elasticity, each strain component) so that no error can cancel.
- Test A (all nodes given). Put the exact nodal values at every node and compute the residual at the interior nodes. It must be zero. This test needs no solve.
- Test B (boundary nodes given). Prescribe the exact values on the boundary nodes, solve for the interior nodes and compare. This is the usual form.
- Test C (natural boundary conditions). Fix only enough values to remove the rigid motions, apply the boundary tractions of the exact solution, and solve. This test also checks that the stiffness matrix has no spurious zero energy modes.
- Compare. Compare the nodal values and the gradients or stresses at the quadrature points with the exact ones. The difference must be at the level of rounding error, for example below relative. A difference of is a failure, not a near pass.
The idea behind the test: if a smooth solution is replaced by its linear Taylor polynomial on each patch, the remaining error goes to zero with the mesh size. An element that cannot reproduce the linear part has an error that does not go to zero, so a failure of the test means a consistency error of order one.
Classic examples
Linear triangles pass (exact numbers). Take the unit square with the interior node joined to the four corners, which gives four triangles with areas . For the Laplace equation the row of the stiffness matrix for is
The row sums to zero, so a constant passes. For the corner values are , and the interior equation gives , which is the exact value . The reason is general: the row for applied to a linear is , because vanishes on the boundary of the patch.
Bilinear quadrilaterals and the Jacobian. The MacNeal and Harder patch has the corners of a rectangle and the interior nodes , , , , with five quadrilaterals. With and 2 by 2 Gauss quadrature, the isoparametric bilinear element gives the four interior values with an error of . A common shortcut evaluates the Jacobian only at the element centre. It is exact on parallelograms, but on this patch it gives , an error of . It fails the test and it does not converge on distorted meshes.
Incompatible modes. Wilson's element adds to the bilinear quadrilateral two internal modes that are not continuous between elements. It passes on parallelograms and fails on general quadrilaterals. Taylor, Beresford and Wilson in 1976 changed the way the derivatives of the internal modes are integrated, so that their integral over each element is zero. Then the element passes on any shape.
Nonconforming linear triangles. The Crouzeix Raviart element has its nodes at the edge midpoints, so it is not continuous. The jump across each edge has mean value zero, so the boundary terms of the integration by parts cancel for linear fields, and the element passes.
Reduced integration. The bilinear quadrilateral with one quadrature point passes tests A and B. In test C its stiffness matrix is singular, because of the hourglass modes, which have zero energy at the centre. The stability part of the test finds this.
Mesh-free methods. The element-free Galerkin method with simple nodal integration fails the linear patch test. Background cell quadrature with enough points, or a smoothed nodal integration, makes it pass.
Variations
- Higher order patch test. For an element of degree , use all polynomials of degree as exact solutions.
- Single element test. Check one element alone for the right number of zero energy modes (the rigid motions only) and for the rank of its stiffness matrix.
- Weak patch test. Some nonconforming elements fail on a fixed patch, but the error goes to zero as the patch shrinks. This is called passing the test in the weak sense. It still allows convergence, more slowly.
- Generalized patch test of Stummel. A mathematical condition on the jumps of the nonconforming functions. Together with approximability it is necessary and sufficient for convergence.
- Patch tests for contact and interfaces. Two meshes that do not match across a flat interface must transmit a constant stress exactly. Mortar methods pass and simple node to segment contact does not.
- Standard benchmark sets. The MacNeal and Harder set adds bending, twist and distortion problems to the patch test, for elements that must also work well, not only converge.
Pitfalls
- Regular meshes only. A patch of squares or parallelograms hides errors in the Jacobian and in the quadrature. Always distort.
- Only nodal values. Check the stresses at the quadrature points too. An error in the recovery of stresses does not show in the nodal values.
- Passing is not sufficient. Stummel's example passes and does not converge. Also check stability (test C) and the convergence rate on a smooth problem with a refined mesh.
- Tolerance too loose. The test is exact. An error of on a well conditioned patch is a bug.
- Body forces. The exact solution must match the loads. A linear field with a nonzero body force is not a solution, and the test then fails for the wrong reason.
- Only one exact field. An error in the derivative does not show with . Use each basic field.
Exercises
- Prove that every conforming element whose space contains the linear functions passes test A with exact integration. Hint: for an interior node , the row of applied to a linear is . Use the divergence theorem on the support of .
- In the first example, move the interior node to . Show that , that each corner gives , and that is the mean of the four corner values. Check that this equals for every linear .
- Explain why the shortcut with the Jacobian at the centre is exact on a parallelogram. Hint: the map from the reference square to a parallelogram is affine.
- For the bilinear square with one quadrature point at the centre, find the nodal vector times a constant. Show that its gradient is zero at the centre but not elsewhere, so the one point stiffness matrix has a zero energy mode that is not a rigid motion.
- For the Crouzeix Raviart element, show that the jump of a piecewise linear function across an edge, if the function is continuous at the midpoint, has mean value zero on the edge. Use this to show that the element passes test A.
References
- B. M. Irons and A. Razzaque, Experience with the patch test for convergence of finite elements, in A. K. Aziz (editor), The Mathematical Foundations of the Finite Element Method with Applications to Partial Differential Equations, Academic Press, 1972, 557-587, the statement of the patch test and its use on conforming and nonconforming elements
- F. Stummel, The limitations of the patch test, International Journal for Numerical Methods in Engineering 15(2) (1980) 177-188, a nonconforming element that passes the patch test and does not converge
- F. Stummel, The generalized patch test, SIAM Journal on Numerical Analysis 16(3) (1979) 449-471, the generalized patch test, which with approximability is necessary and sufficient for convergence of nonconforming elements
- R. L. Taylor, J. C. Simo, O. C. Zienkiewicz and A. C. H. Chan, The patch test, a condition for assessing FEM convergence, International Journal for Numerical Methods in Engineering 22(1) (1986) 39-62, tests A, B and C, the single element test and the stability part of the patch test
- R. L. Taylor, P. J. Beresford and E. L. Wilson, A non-conforming element for stress analysis, International Journal for Numerical Methods in Engineering 10(6) (1976) 1211-1219, the incompatible modes element changed so that it passes the patch test on general quadrilaterals
- R. H. MacNeal and R. L. Harder, A proposed standard set of problems to test finite element accuracy, Finite Elements in Analysis and Design 1(1) (1985) 3-20, the standard five element patch on a 0.24 by 0.12 rectangle
- O. C. Zienkiewicz, R. L. Taylor and J. Z. Zhu, The Finite Element Method, Its Basis and Fundamentals, seventh edition, Butterworth-Heinemann, 2013, the chapter on the patch test, reduced integration and nonconforming elements
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag SGRJZ0 Edit this page History Report an error Markdown