Assembly
How do element contributions become the global linear system?
Each element knows only its own nodes. Assembly adds every element’s stiffness and load into one global system. Where elements share a node, their contributions add. Units are N, mm and MPa.
Local and global degrees of freedom
A degree of freedom (DOF) is one unknown coefficient: one displacement component of one basis function. An element numbers its DOFs locally, to . The model numbers every DOF once, globally. The element’s connectivity, its list of global node numbers, links the two numberings.
For a solid with scalar basis functions, the global coefficient vector has entries. At order 1, is the number of mesh vertices. Order 2 adds one function per tetrahedral edge; on hexahedra it also adds one per face and one per element. For example, a 10 × 2 × 2 grid of hexahedra has vertices and 297 DOFs at order 1. At order 2 its nodes form a 21 × 5 × 5 lattice: 525 functions and 1575 DOFs.
Worked example: two bar elements
Use the axial bar from What is FEM?: length , area , and end force . Split it into two 500 mm elements with nodes 1, 2 and 3. Each node has one DOF, its axial displacement in mm. Each element is a spring of stiffness:
Element 1 connects nodes (1, 2); element 2 connects (2, 3). Add each 2 × 2 block into the rows and columns of its nodes. Node 2 belongs to both elements, so its diagonal receives twice:
The load vector is , where is the unknown support reaction at node 1. As assembled, is singular: each row sums to zero because a rigid translation costs no energy. Fixing node 1 () leaves two equations for the two unknowns:
Solving gives and . This equals the analytical . The first row then gives , balancing . Linear elements are exact here because the true displacement of a uniform bar without body load is linear. Supports are treated in detail in Loads and constraints.

Assembly as gather and scatter
Formally, a Boolean matrix of size gathers the element’s DOFs from the global vector: . Equating the internal work of the elements with the global work gives:
is never built. Implementations keep a list of the element’s global DOF indices and add entry of to entry of , where is the global index of local DOF . Elements may be processed in any order. In the bar, element 1 has indices (1, 2) and element 2 has (2, 3).
Two tetrahedra sharing a face
Take five vertices, 0 to 4, and two order-1 tetrahedra: and . They share the face . With , there are 15 global DOFs. Using KoFEM’s interleaved order explained below, component () of vertex has global index :
| Element | x DOFs | y DOFs | z DOFs |
|---|---|---|---|
| (0, 1, 2, 3) | 0, 3, 6, 9 | 1, 4, 7, 10 | 2, 5, 8, 11 |
| (1, 2, 3, 4) | 3, 6, 9, 12 | 4, 7, 10, 13 | 5, 8, 11, 14 |
Each 12 × 12 element matrix lands in a 15 × 15 global matrix. Nine DOFs belong to both elements, so the 9 × 9 block of the shared face receives two contributions. Vertices 0 and 4 share no element, so their 3 × 3 coupling block stays zero. Of the 25 vertex pairs, 23 are coupled: the global matrix has structural nonzeros out of 225. In a large mesh each vertex couples only to its neighbours, so almost all entries are zero and is stored as a sparse matrix.
DOF ordering
Two orders are common for the same coefficients:
- Interleaved (by node): , index . The notation reference and the blocks on the elements page use this order.
- Component-blocked: all coefficients, then all , then all , index .
KoFEM’s solid solve uses the interleaved order for the global vector and for each element matrix: local index for component of element node . The two orders differ only by a permutation matrix : . Libraries such as MFEM use the component-blocked order. The displacement field and every physical result are unchanged; only array positions differ.
At order 1 the node of a DOF is the input vertex, so the displacement of vertex sits at , and . At order 2, nodes added on edges follow all vertices, then hexahedron face nodes, then hexahedron centre nodes. They are numbered from the mesh alone, so the same mesh always gives the same numbering.
Properties of the global matrix
- Size: , N/mm. The load vector has entries in N.
- Symmetric, because every element matrix is.
- Sparse: nonzero only where two DOFs share an element.
- Positive semi-definite before supports: the strain energy is never negative.
- Singular before supports: every unconnected body has six rigid-body modes. Supports must remove all of them before the system can be solved.
Bodies with different materials still assemble into one . Each element uses its own body’s and , and contributions add at shared nodes. The Linear solve page explains how the constrained system is solved.

KoFEM implementation
KoFEM’s solid solve runs in its Rust finite-element module; the element integrals follow MFEM 4.7, from which they are ported. The app drives the solve from solveSolidInRust.
| Step | Where | What happens |
|---|---|---|
| Mesh and connectivity | App, Rust | The app packs vertices and tetrahedra/hexahedra with a material index per element (amg.ts); the Rust mesh checks every element and adds the order-2 nodes (mesh.rs). |
| DOF numbering | Rust | Three DOFs per node, interleaved, (mesh.rs). |
| Material per element | Rust | and from each body’s and (material.rs). |
| Element stiffness and quadrature | Rust | The isotropic integrand with the rules of the elements page (element.rs). |
| Scatter-add into | Rust | A sparse pattern from the node neighbours, then each element matrix added into it (assembly.rs). |
| Surface loads | App, Rust | The app sends each force, traction or pressure group’s faces; Rust matches them to boundary faces and integrates (surface.rs). |
| Point loads | App | Added directly to the load vector at a vertex’s three DOFs (amg.ts). |
| Supports | App, Rust | The app lists constrained DOFs; Rust extends them to order-2 edge nodes and eliminates them (static_solve.rs). |
| Mixed solid–shell | Rust | The same order-1 solid matrix, combined with the shell facets through the coupling equations (coupled_static.rs). |
KoFEM-specific decisions are the element order offered, the material mapping, the conversion of face forces to tractions and the treatment of supports. The axial bar example runs this complete path in the browser; open it in the app and run it yourself.
Sources and further reading
- MFEM: Finite element methods, finite element spaces, bilinear forms and assembly; KoFEM’s element integrals are ported from MFEM.
- Hughes, The Finite Element Method: Linear Static and Dynamic Finite Element Analysis (2000), the assembly operator and global DOF arrays.
- Bathe, Finite Element Procedures (1996), direct stiffness assembly and properties of the stiffness matrix.
The worked numbers were checked with exact rational arithmetic. Related pages: stiffness notation and Equilibrium and weak form.