Engineering Guides

Finite element analysis, chapter 1

The finite element method in one dimension

How a differential equation becomes a matrix equation, worked through on a bar you can check by hand. Every idea in this chapter carries over unchanged to 3D models.

1.1

What the method does

Most problems in structural mechanics, heat transfer and fluid flow are boundary value problems: a partial differential equation must hold everywhere inside a domain, and some conditions must hold on its boundary. For a prismatic beam or a thin-walled cylinder you can solve these on paper. For a bracket with a fillet, a boss and three bolt holes, you can’t.

The finite element method (FEM) gets around this in three moves:

  1. Approximate. Cut the domain into small, simple pieces (elements) and describe the unknown field on each piece with a low-order polynomial, defined by its values at a few points (nodes).
  2. Discretise. Instead of asking the differential equation to hold at every point, which a piecewise polynomial cannot do, ask it to hold on average (the weak form), weighted by a set of test functions. That turns the PDE into a linear system Ku=f\mathbf{K}\mathbf{u} = \mathbf{f}.
  3. Solve the linear system, then recover derived quantities such as strain and stress from u\mathbf{u}.

The figure shows all three on a real part. Switch between geometry, mesh and stress. Using the method on real parts like this one is finite element analysis (FEA), and that is what this track teaches.

This chapter does all three for the simplest possible case: a straight bar under axial load. That is not a toy. Every idea you need for a 3D solid model (weak form, shape functions, element stiffness, assembly, supports, convergence) appears here unchanged. Going to 3D only adds bookkeeping.

Figure 1 The three moves on a real part. Geometry, an aluminium angle bracket bolted at the base and pulled at the upright. Mesh, 31 000 quadratic tetrahedra and 151 000 unknowns. Stress, the solution of Ku = f shown on the deformed shape. Solved offline with gmsh and scikit-fem; drag to rotate.

1.2

A bar you can solve by hand

Take a straight bar of length LL, Young’s modulus EE and cross-section AA, fixed at x=0x=0. It carries a distributed axial load q(x)q(x) (force per unit length, say its own weight hanging vertically) and a point load FF at the free end.

Cut out a slice of length dxdx. Equilibrium of the normal force NN across it gives dN/dx+q=0dN/dx + q = 0. Hooke’s law with the small-strain definition ε=du/dx\varepsilon = du/dx gives N=EA du/dxN = EA\, du/dx. Combine them:

−ddx ⁣(EA dudx)=q(x),0<x<L(1.1)-\frac{d}{dx}\!\left(EA\,\frac{du}{dx}\right) = q(x), \qquad 0 < x < L \tag{1.1}

with two boundary conditions of different character:

  • u(0)=0u(0) = 0 prescribes the unknown itself. This is an essential (Dirichlet) condition: a support.
  • EA u′(L)=FEA\,u'(L) = F prescribes its derivative, which here is a force. This is a natural (Neumann) condition: a load.

For constant EAEA and qq, integrate twice:

N(x)=F+q (L−x),u(x)=FxEA+qEA(Lx−x22)(1.2)\begin{aligned} N(x) &= F + q\,(L - x), \\[4pt] u(x) &= \frac{F x}{EA} + \frac{q}{EA}\left(Lx - \frac{x^2}{2}\right) \end{aligned} \tag{1.2}

This is the strong form: it asks uu to be twice differentiable and the equation to hold at every point. Keep this solution in mind; we’ll measure the finite element answer against it.

Figure 2 Exact solution for a bar fixed at x = 0, with a uniform axial load q along its length and a point load F at the tip (EA = L = 1). The normal force is linear in x; the displacement is a parabola.

1.3

Why the strong form is the wrong target

We want to approximate uu with something a computer can store: a finite list of numbers. The simplest continuous choice is a piecewise-linear function: split [0,L][0, L] into elements of length hh and connect the values at the nodes with straight lines.

Now try to plug this uhu_h into the strong form. Inside each element uh′′=0u_h'' = 0. At each node the slope jumps, so uh′′u_h'' is not a function at all: it is a Dirac delta whose strength equals the jump. The differential equation can’t be satisfied, not even approximately, in any pointwise sense.

There are two ways out. Use smoother functions (cubic splines, for example), which is costly and awkward in 2D and 3D. Or rewrite the problem so that it needs only first derivatives. FEM takes the second route.

Figure 3 Drag the nodes. The first derivative of a piecewise-linear function is piecewise constant and jumps at every node. The second derivative is zero inside each element and a Dirac spike at each kink, so a pointwise second-order equation can't say anything useful about it.

1.4

The weak form

Multiply the differential equation by an arbitrary test function v(x)v(x) and integrate over the bar. Then integrate the left-hand side by parts to move one derivative from uu onto vv:

∫0LEA u′ v′ dx  =  ∫0Lq v dx  +  F v(L)for all v with v(0)=0(1.3)\begin{gathered} \int_0^L EA\,u'\,v'\,dx \;=\; \int_0^L q\,v\,dx \;+\; F\,v(L) \\[2pt] \text{for all } v \text{ with } v(0) = 0 \end{gathered} \tag{1.3}

Three things happened:

  • Only first derivatives remain. Piecewise-linear functions now qualify: their first derivative is piecewise constant, and the integral of a product of piecewise constants is perfectly well defined.
  • The natural condition appeared by itself. The boundary term from integration by parts is [EA u′ v]0L[EA\,u'\,v]_0^L. At x=Lx=L, EA u′=FEA\,u' = F, which is where the F v(L)F\,v(L) on the right comes from. Loads enter the weak form automatically. That is why they are called natural.
  • The essential condition did not. We must build u(0)=0u(0)=0 into the space of candidate functions and choose v(0)=0v(0)=0 so the unknown reaction at the support drops out.

Mechanically, this is the principle of virtual work. Read vv as a virtual displacement compatible with the supports. The left side is the internal virtual work of the normal force; the right side is the virtual work of the applied loads. Equilibrium means the two match for every admissible vv. Equivalently, uu minimises the total potential energy

Π[u]=12∫0LEA (u′)2 dx−∫0Lq u dx−F u(L).(1.4)\Pi[u] = \tfrac12\int_0^L EA\,(u')^2\,dx - \int_0^L q\,u\,dx - F\,u(L). \tag{1.4}

For a smooth uu the strong and weak forms are equivalent. The weak form simply admits a larger family of candidate solutions, and that larger family includes our piecewise polynomials.

Figure 4 The weak form as a balance. Slide the test function v along the bar and change its width. For the exact solution, internal and external virtual work match for every v. For a wrong guess that still satisfies the support, some v exposes the imbalance. Galerkin's method asks for balance only against the finitely many hat functions.

1.5

Shape functions

The Galerkin method restricts both the solution and the test functions to the same finite-dimensional space. For linear elements the natural basis of that space is the set of hat functions, the shape functions Ni(x)N_i(x):

uh(x)=∑i=1nNi(x) ui(1.5)u_h(x) = \sum_{i=1}^{n} N_i(x)\,u_i \tag{1.5}

Each NiN_i equals 1 at node ii, 0 at all other nodes, and is linear in between. The coefficients uiu_i are therefore not abstract weights: they are the nodal displacements, which is why FE output is “displacement at each node”.

Inside one element of length hh, with local coordinate ξ=(x−x1)/h∈[0,1]\xi = (x - x_1)/h \in [0,1], only two hats are non-zero:

N1(ξ)=1−ξ,N2(ξ)=ξ(1.6)N_1(\xi) = 1 - \xi, \qquad N_2(\xi) = \xi \tag{1.6}

Three properties carry over to every element type you’ll meet later:

  • Interpolation: uh(xi)=uiu_h(x_i) = u_i.
  • Partition of unity: ∑iNi(x)=1\sum_i N_i(x) = 1, so a rigid translation (all uiu_i equal) is represented exactly and produces zero strain.
  • Compact support: NiN_i is non-zero only on the elements touching node ii. Two nodes interact only if they share an element. This is what makes the final matrix sparse.
Figure 5 Each hat function Nᵢ is 1 at its own node and 0 at every other node. Scaled by the nodal values uᵢ and added up, they reproduce any piecewise-linear function exactly.

1.6

Element stiffness

Substitute the expansion (1.5) into the weak form (1.3) and choose the test function to be each basis function in turn, v=Njv = N_j. Every choice of jj gives one equation:

∑iKji ui=fj,Kji=∫0LEA Ni′ Nj′ dx,fj=∫0Lq Nj dx+F Nj(L).(1.7)\begin{aligned} \sum_i K_{ji}\,u_i &= f_j, \\[2pt] K_{ji} &= \int_0^L EA\,N_i'\,N_j'\,dx, \\[2pt] f_j &= \int_0^L q\,N_j\,dx + F\,N_j(L). \end{aligned} \tag{1.7}

That is the linear system Ku=f\mathbf{K}\mathbf{u}=\mathbf{f}: one row per test function, one column per nodal unknown. Because each NiN_i lives on only two elements, the integral splits into a sum of per-element integrals. On one element N1′=−1/hN_1' = -1/h and N2′=1/hN_2' = 1/h, so

ke=EAh[1−1−11],fe=q h2[11].(1.8)\mathbf{k}_e = \frac{EA}{h}\begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix}, \qquad \mathbf{f}_e = \frac{q\,h}{2}\begin{bmatrix} 1 \\ 1 \end{bmatrix}. \tag{1.8}

Two observations worth keeping:

  • ke\mathbf{k}_e is the stiffness matrix of a spring with k=EA/hk = EA/h. Shorter elements are stiffer springs.
  • ke\mathbf{k}_e is singular: ke[1,1]T=0\mathbf{k}_e [1, 1]^\mathsf{T} = \mathbf{0}. A free element can translate without resistance. Every element matrix in every FE code has a null space made of its rigid-body motions (one here, three in 2D, six in 3D).

The distributed load is split equally between the two nodes. This is the consistent load vector, and it is what you get from the integral, not a convenient guess.

Figure 6 A linear bar element behaves exactly like a spring of stiffness EA/h between its two nodes. Move both nodes by the same amount and no force develops; that rigid-body motion is the null space of the element matrix.

1.7

Assembly and supports

The global matrix is the sum of the element matrices, each scattered into the rows and columns of its own nodes. This is the direct stiffness method, or assembly, and it fits in a few lines:

K = zeros((n_nodes, n_nodes))
f = zeros(n_nodes)
for (i, j) in elements:            # node pair of each element
    dofs = [i, j]
    K[ix_(dofs, dofs)] += k_e      # 2×2 element matrix
    f[dofs]           += f_e

The assembled K\mathbf{K} is symmetric, banded (node ii only couples to i±1i\pm1), and singular. The whole bar can still slide, so the supports have to go in before solving. The simplest way to impose u1=0u_1 = 0 is to delete row and column 1. What remains is symmetric positive definite and has a unique solution.

In a 3D solid model nothing changes except scale: three unknowns per node, a few hundred thousand to a few million rows, and a sparsity pattern set by the mesh connectivity. Sparse storage and sparse solvers are the only reason this is affordable.

Figure 7 Step through the direct stiffness method. Each element adds its 2×2 matrix into the rows and columns of its two nodes; overlapping entries sum.

1.8

Solve, then look at the error

Solve the 1D system and compare with the exact solution (1.2). Two results stand out.

The nodal displacements are exact, whatever the mesh. That is a special property of 1D problems with linear elements, and you should not expect it anywhere else. Between the nodes the straight lines miss the parabola by at most qh2/8EAq h^2 / 8EA.

The normal force is worse. Nh=EA uh′N_h = EA\,u_h' is constant inside each element, so it approximates a linear function with a staircase. Its error is qh/2q h/2: halve the elements and you only halve the error. The staircase is exact at element midpoints. These superconvergent points are why FE codes evaluate stresses at interior integration points and then extrapolate or average to the nodes.

The general version of this observation holds in every dimension. For smooth solutions and elements of polynomial degree pp:

∥u−uh∥≤C hp+1,∥σ−σh∥≤C hp(1.9)\| u - u_h \| \le C\,h^{p+1}, \qquad \| \sigma - \sigma_h \| \le C\,h^{p} \tag{1.9}

Derived quantities converge one order slower than the primary unknown. In practice: a mesh that gives good displacements may still give poor stresses. Quadratic elements (p=2p = 2) buy one extra order for both.

Figure 8 Uniform load q, fixed at x = 0, free at x = L. Grey is exact, colour is FE. The nodal displacements are exact for any mesh, but the normal force is piecewise constant. On the right, the displacement error falls with h² and the force error only with h.

1.9

The same recipe in two dimensions

In plane stress the unknown becomes a vector field (ux,uy)(u_x, u_y) and the bar’s single strain becomes three: ε=(εx,εy,γxy)\boldsymbol\varepsilon = (\varepsilon_x, \varepsilon_y, \gamma_{xy}). The recipe does not change:

  1. Interpolate each displacement component with shape functions on each element.
  2. Strains are derivatives of displacements, so ε=B ue\boldsymbol\varepsilon = \mathbf{B}\,\mathbf{u}_e with B\mathbf{B} built from ∂Ni/∂x\partial N_i/\partial x and ∂Ni/∂y\partial N_i/\partial y.
  3. Stresses follow from the material law: σ=D ε\boldsymbol\sigma = \mathbf{D}\,\boldsymbol\varepsilon.
  4. The element stiffness is the same weak-form integral in matrix dress:
ke=∫AeBT D B  t dA(1.10)\mathbf{k}_e = \int_{A_e} \mathbf{B}^\mathsf{T}\,\mathbf{D}\,\mathbf{B}\; t\,dA \tag{1.10}
  1. Assemble, apply supports, solve.

With the 3-node linear triangle, B\mathbf{B} is constant, so each element carries a single, constant strain. In bending, strain varies linearly through the depth. A constant-strain element can only follow that variation if there are many of them through the thickness. With few, the elements resist bending in ways the real material doesn’t, and the model comes out too stiff. Try it in the figure: one triangle through the depth recovers less than a third of the true deflection.

This is the first lesson that has no 1D counterpart: element choice matters as much as element size. It is why commercial codes default to quadratic elements, and it gets its own rule in the field notes.

Figure 9 A steel cantilever, 100 × 10 mm, clamped on the left and loaded at the tip, solved in your browser. The dashed line marks the beam-theory deflection. With one or two linear triangles through the thickness the model is far too stiff.

1.10

Summary and further reading

  • A boundary value problem in strong form needs more smoothness than a piecewise polynomial has.
  • The weak form (virtual work) needs only first derivatives. Loads enter it naturally; supports must be built into the trial space.
  • Shape functions turn an unknown function into a finite vector of nodal values. Their compact support makes K\mathbf{K} sparse.
  • Each element contributes a small, singular stiffness matrix. Assembly sums them; supports remove the rigid-body null space.
  • Displacements converge as hp+1h^{p+1}, stresses as hph^{p}. Element type matters as much as element size.

Next chapter: how real elements are built on curved geometry with isoparametric mapping and numerical quadrature.

Books. T. J. R. Hughes, The Finite Element Method: Linear Static and Dynamic Finite Element Analysis (Dover), rigorous and cheap. J. Fish and T. Belytschko, A First Course in Finite Elements (Wiley), the gentlest complete introduction. O. C. Zienkiewicz, R. L. Taylor and J. Z. Zhu, The Finite Element Method: Its Basis and Fundamentals (Elsevier), the reference.

Lectures. K.-J. Bathe, MIT 2.092 Finite Element Analysis of Solids and Fluids, video lectures from one of the field’s founders.