Theory contents

Elements and quadrature

On this page

How are the displacement field and element integrals approximated?

The weak form asks for a displacement field in a space of infinitely many functions. A finite element method picks a finite set of shape functions on each element and evaluates every integral with a few weighted points. This page covers static, small-strain, linear-elastic 3D solids; shells use a different element. Units are N, mm and MPa throughout.

Approximate displacement with shape functions

Within one element, each displacement component is a weighted sum of dimensionless shape functions Na. The weights are the displacement coefficients dai in mm:

uih(x)=∑a=1neNa(x)dai,i=x,y,z.

Here ne is the number of scalar basis functions on the element. KoFEM’s solid elements are nodal (Lagrange): Na equals 1 at its own node and 0 at every other node. The coefficient dai is then the displacement of node a in direction i. Two further properties matter:

On a tetrahedron the natural coordinates are the four barycentric coordinates L1,…,L4, each 1 at one corner and 0 on the opposite face; they sum to 1. With the reference coordinates ξ,η,ζ, they are 1−ξ−η−ζ, ξ, η and ζ.

Left: the three quadratic shape functions of a three-node element; each equals one at its own node and zero at the others. Right: the four cubic shape functions of a four-node element, with the same property.
One-dimensional Lagrange shape functions. Each equals 1 at its own node and 0 at every other node, so the coefficient of a shape function is the value at that node. Solid elements use products or barycentric versions of the same idea.

A complete polynomial of degree k is represented exactly. Order 1 therefore reproduces any linear displacement field, including uniform strain; order 2 also reproduces quadratic fields, such as the displacement of a beam under constant bending moment.

Solid elements KoFEM solves

The solid solver accepts tetrahedra and hexahedra at order 1 or 2. The app’s volume mesher creates tetrahedra; hexahedral input is used by solver-level validation cases. Each scalar basis function carries three translational coefficients, so an element with ne functions has 3ne DOFs.

Four solid elements with their nodes: a linear tetrahedron with 4 corner nodes, a quadratic tetrahedron with 10 nodes at corners and edge midpoints, a trilinear hexahedron with 8 corner nodes and a quadratic hexahedron with 27 nodes at corners, edges, faces and centre. Hidden nodes are drawn open.
Node layouts of linear and quadratic tetrahedra and hexahedra. Quadratic elements add nodes at the edge midpoints; the 27-node hexahedron also has face and centre nodes. Open circles are hidden behind the element.
Solid elements in KoFEM
ElementNodesElement DOFsElement stiffnessStiffness rule
Tetrahedron, order 141212 × 121 point
Tetrahedron, order 2103030 × 304 points
Hexahedron, order 182424 × 243 × 3 × 3
Hexahedron, order 2278181 × 814 × 4 × 4

An order-2 tetrahedron has nodes at its 4 corners and 6 edge midpoints. An order-2 hexahedron has 8 corner, 12 edge, 6 face and 1 centre node. Hexahedral rules are tensor products of Gauss points per direction.

One element order applies to the whole solid solve. Order 2 raises the polynomial order of the displacement, not of the geometry: every element is still mapped from its straight-edged corner vertices. A curved CAD surface is therefore represented by flat element faces at either order. The mixed solid–shell solve always uses order-1 tetrahedra, and shells use their own flat-facet element.

From coefficients to strain

Small strain needs first derivatives of displacement. Differentiating the interpolation moves the derivative onto the shape functions. The strain–displacement matrix collects those derivatives. For one basis function a it is a 6 × 3 block, using the guide’s engineering-shear order xx,yy,zz,yz,xz,xy:

Ba=[∂xNa000∂yNa000∂zNa0∂zNa∂yNa∂zNa0∂xNa∂yNa∂xNa0]
εeng=∑aBada=Bd.

Here ∂xNa means ∂Na/∂x, with units 1/mm. da is the 3-vector of coefficients for basis a, and B places the ne blocks side by side, so it is 6×3ne. The physical derivatives come from the reference derivatives through the inverse-transpose Jacobian.

On a straight-edged linear tetrahedron, every ∇Na is constant, so the strain is constant inside the element. This is why it is often called the constant-strain tetrahedron.

Element stiffness

Substituting the interpolation into internal virtual work gives the element stiffness matrix. With the isotropic elasticity matrix C (6 × 6, MPa) written in Lamé parameters λ and μ:

K(e)=∫ΩeBTCBdV≈∑qBT(ξq)CB(ξq)|detJ(ξq)|ωq.
C=[λ+2μλλ000λλ+2μλ000λλλ+2μ000000μ000000μ000000μ]

ξq and ωq are the reference quadrature points and dimensionless weights; |detJ| converts reference volume to mm³. Units: (1/mm) × MPa × (1/mm) × mm³ = N/mm, a stiffness. K(e) is symmetric. Every rigid-body motion produces zero strain, so it has six zero-energy modes: three translations and three small rotations.

Worked example: one linear tetrahedron

Place the corners at (0,0,0), (ℓ,0,0), (0,ℓ,0) and (0,0,ℓ) with edge length ℓ=​10 mm. Choose E=​250 MPa and ν=​0.25, a soft polymer, because these give the round values λ=​μ=​100 MPa.

  1. Mapping. J=​ℓI, so detJ=​1000 mm3 and the volume is V=​detJ/6=​500/3 mm3≈​166.7 mm3.
  2. Gradients (1/mm): ∇N1=​(−0.1,−0.1,−0.1), ∇N2=​(0.1,0,0), ∇N3=​(0,0.1,0), ∇N4=​(0,0,0.1). They sum to zero, as partition of unity requires.
  3. Sizes. Each Ba is 6 × 3, B is 6 × 12, C is 6 × 6 and K(e) is 12 × 12.
  4. Quadrature. The integrand is constant, so one point with weight 1/6 is exact: K(e)=​VBTCB.

The 3 × 3 block coupling node a to node b is Kab=​BaTCBbV. Three blocks, in N/mm, are:

K22=[500000500/3000500/3]
K23=[0500/30500/300000]
K11=[2500/31000/31000/31000/32500/31000/31000/31000/32500/3]

K22=​(ℓ/6)diag(λ+2μ,μ,μ): pulling node 2 along x stretches the element, while moving it along y or z only shears it. Checks you can repeat:

Choose the quadrature rule

Quadrature replaces a reference integral by a weighted sum of point values. A rule of degree p integrates every polynomial up to degree p exactly. The cheapest safe choice integrates the stiffness integrand exactly when it is a polynomial.

Reference triangles with one and three integration points, and reference squares with two-by-two and three-by-three Gauss points, marked as red dots.
Gauss integration points (red) on reference elements. More points integrate higher-degree polynomials exactly.

On a straight-edged order-2 tetrahedron, each B entry is linear in ξ, so BTCB is quadratic. Test a quadratic over the reference tetrahedron (volume 1/6):

∫Ωrξ2dV=160,1 point: 16(14)2=196,4 points: 160.

The four-point rule uses weights 1/24 at barycentric points (α,β,β,β) and permutations, with α=​(5+35)/20≈​0.5854 and β=​(5−5)/20≈​0.1382. Too few points underestimate such terms and can leave non-rigid deformation modes with zero computed energy.

KoFEM uses the stiffness rule MFEM chooses by default: degree 2(k−1) on straight-edged tetrahedra of order k, which is exact. For hexahedra the rule is a tensor product of Gauss points. It is exact for parallelepipeds; on a distorted hexahedron J varies and the integrand is no longer a polynomial, so any finite rule is approximate. The point counts are listed in the table above.

Element load vectors

A surface traction t (MPa) enters through boundary work. On a loaded element face Γe, the element load vector is:

fa(e)=∫ΓeNatdS.

Each entry is a force in N: MPa × mm². For a uniform traction on a triangular face of area Af, the shares of the face force tAf are:

The order-2 result is surprising but correct: the corner functions L(2L−1) are negative over part of the face and integrate to zero. Splitting a face force equally over all six nodes would not be work-equivalent. KoFEM converts a face force group into a uniform traction, the total force divided by the loaded area, and integrates it this way. On a flat triangle with uniform traction these shares are exact, so KoFEM applies them directly. Quadrilateral hexahedron faces use a Gauss rule of 2 × 2 points at order 1 and 3 × 3 at order 2. The static solid solve applies no body force: density is stored but unused. How loads and supports enter the global system is covered in Loads and constraints.

A uniform traction q on an edge of length L becomes nodal forces. A linear two-node edge receives qL/2 at each node. A quadratic three-node edge receives qL/6 at each end and 2qL/3 at the midpoint.
A uniform traction on an element edge becomes consistent nodal forces. The shares follow from integrating each shape function along the edge; a quadratic midpoint node takes two thirds of the load.

Mesh size versus element order

Two controls reduce discretisation error: smaller elements (h-refinement) and higher order (p-refinement). For a smooth solution, standard error estimates give, as the element size h decreases at order k:

strain and stress error=O(hk),displacement error=O(hk+1).

These are general expectations, not KoFEM measurements. They need well-shaped elements and a smooth solution. Re-entrant corners, point loads and point supports create singularities: the local stress never converges, and rates elsewhere drop. Halving h at order 1 should roughly halve the stress error; at order 2 it should roughly quarter it.

Log–log plot of relative error against element size. Straight lines of slope 1, 2 and 3 show the expected rates for stress and displacement at element orders 1 and 2. A dashed red line shows a peak stress at a re-entrant corner growing as the elements get smaller.
Expected error against element size for a smooth solution, on logarithmic axes: the slope is the convergence rate. A singular peak stress, as at a re-entrant corner, grows instead. Schematic; not a KoFEM measurement.

Order 2 costs more per element: a 30 × 30 instead of a 12 × 12 tetrahedral stiffness, and more unknowns because every edge adds a node. In a typical tetrahedral mesh there are several edges per vertex, so the same mesh has several times as many DOFs at order 2. The cantilever beam example shows a measured h- and order-study on tetrahedra, solving the same beam at order 1 and order 2.

KoFEM currently returns solid displacement at element corners only, and one von Mises stress at each element centre. The order-2 edge coefficients are solved but are not part of the returned field; see Displacement and stress.

Thin walls and linear tetrahedra

A wall in bending has strain that varies linearly through its thickness, from tension on one side to compression on the other. A linear tetrahedron has one constant strain. With one or two elements through the thickness, the mesh can only bend by also producing spurious shear and volume change. That parasitic energy makes the model too stiff. This effect is called locking.

Locking also misleads convergence checks. Halving the element size changes the result only slowly, so two order-1 solutions can agree closely while both remain far from the converged answer. Agreement between successive order-1 meshes is not, by itself, evidence of accuracy.

Measured in KoFEM. An internal study of a 3 mm sheet-metal bracket found that order 2 on the same tetrahedral mesh about doubled the maximum displacement. Halving the order-1 element size changed it by only 2.6%. KoFEM does not currently warn about this case.

For a thin-walled or bending-dominated solid:

KoFEM implementation

KoFEM’s solid solve runs in its own Rust finite-element module. It implements the tetrahedra and hexahedra above with the shape functions and quadrature rules of MFEM 4.7, from which these parts are ported.

How these element contributions combine into one system is explained in Assembly.

Sources and further reading

  1. MFEM: Finite element methods and MFEM: Integration, H1 spaces, element transformations and quadrature.
  2. Hughes, The Finite Element Method: Linear Static and Dynamic Finite Element Analysis (2000), shape functions, the B matrix and quadrature.
  3. Bathe, Finite Element Procedures (1996), isoparametric elements, numerical integration and locking.
  4. Keast, “Moderate-degree tetrahedral quadrature formulas”, Computer Methods in Applied Mechanics and Engineering 55 (1986), symmetric tetrahedral rules.

All numbers in the worked examples were checked with exact rational arithmetic. Related pages: Linear elasticity, Integration and the weak form and the axial bar example.