Lesson 5 of 13 20 min

Assembly — Global System

We now have element stiffness matrices. But a real structure consists of many elements connected together. How do we combine these individual matrices into a single global system that represents the entire structure?

This process is called assembly, and it's based on two fundamental principles:

  • Compatibility: Shared nodes have the same displacement
  • Equilibrium: Forces at each node must balance

The Assembly Concept

Consider a bar divided into 3 elements with 4 nodes:

   Node 1      Node 2      Node 3      Node 4
     ●──────────●──────────●──────────●
        Elem 1     Elem 2     Elem 3

Each element has its own 2×2 stiffness matrix. But at shared nodes (2 and 3), the element contributions must be added together.

Watch how element matrices are assembled into the global matrix. Click "Next Step" to see each element's contribution.

Why Stiffnesses Add at Shared Nodes

At node 2, both Element 1 and Element 2 contribute stiffness:

  • Element 1 pulls from the left
  • Element 2 pulls from the right

The total stiffness at node 2 is the sum of contributions from both elements. This is like springs in parallel — their stiffnesses add.

Mathematical View

For Element 1 (nodes 1-2) with stiffness $k_1$:

$$[K_1] = k_1 \begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix}$$

For Element 2 (nodes 2-3) with stiffness $k_2$:

$$[K_2] = k_2 \begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix}$$

The global matrix for nodes 1, 2, 3:

$$[K_{global}] = \begin{bmatrix} k_1 & -k_1 & 0 \\ -k_1 & k_1+k_2 & -k_2 \\ 0 & -k_2 & k_2 \end{bmatrix}$$

Notice:

  • $K_{22} = k_1 + k_2$ — contributions from both elements add
  • Off-diagonal terms connect only adjacent nodes
  • The matrix is symmetric and banded

The Assembly Algorithm

The assembly process follows these steps:

Step 1: Define Element Connectivity

Create a table mapping each element to its global node numbers:

ElementLocal Node 1Local Node 2
112
223
334

This connectivity table tells us where each element's entries go in the global matrix.

Step 2: Initialize Global Matrix

Create a zero matrix of size $n \times n$, where $n$ = total number of DOFs.

For our 4-node 1D problem: $[K_{global}]$ is $4 \times 4$, initialized to zeros.

Step 3: Loop Over Elements

For each element $e$:

  • Get the element stiffness matrix $[K_e]$
  • Get the global node numbers from connectivity table
  • Add each entry $K_e(i,j)$ to the corresponding position in $[K_{global}]$

Step 4: The Scatter Operation

For element $e$ connecting global nodes $I$ and $J$:

$$K_{global}(I,I) \mathrel{+}= K_e(1,1)$$

$$K_{global}(I,J) \mathrel{+}= K_e(1,2)$$

$$K_{global}(J,I) \mathrel{+}= K_e(2,1)$$

$$K_{global}(J,J) \mathrel{+}= K_e(2,2)$$

The "+=" means we add to the existing value, not replace it.

Connectivity and DOF Mapping

Hover over elements to see their connectivity. Click elements to highlight their contribution to the global matrix.

For 2D and 3D Elements

The same principle applies, but with more DOFs per node:

2D (2 DOFs per node):
  • Node $i$ has DOFs: $2i-1$ (x-direction), $2i$ (y-direction)
  • A 3-node triangle has a $6 \times 6$ element stiffness matrix
  • Assembly scatters into a larger global matrix
3D (3 DOFs per node):
  • Node $i$ has DOFs: $3i-2$, $3i-1$, $3i$
  • A 4-node tetrahedron has a $12 \times 12$ element stiffness matrix

Assembly Rules (Direct Stiffness Method)

Two simple rules govern the assembled matrix:

Rule 1: Diagonal Terms

$$K_{ii} = \sum_{\text{elements at node } i} K_e(\text{local } i, \text{local } i)$$

The diagonal entry for DOF $i$ is the sum of direct stiffnesses from all elements connected to that DOF.

Rule 2: Off-Diagonal Terms

$$K_{ij} = \sum_{\text{elements connecting } i \text{ and } j} K_e(\text{local } i, \text{local } j)$$

The off-diagonal entry is the sum of coupling stiffnesses from elements that connect DOFs $i$ and $j$.

If no element connects nodes $i$ and $j$, then $K_{ij} = 0$.

Properties of the Assembled Matrix

The global stiffness matrix has important properties:

1. Symmetric

$$K_{ij} = K_{ji}$$

This comes from Maxwell-Betti reciprocity and is preserved by assembly.

2. Sparse

Most entries are zero. Only DOFs connected by elements have non-zero coupling.

For a mesh with $n$ nodes and average connectivity $m$:

  • Matrix size: $n \times n$
  • Non-zeros: approximately $m \times n$
  • Sparsity: $(n^2 - mn)/n^2 \approx 1 - m/n$

For large $n$, the matrix is very sparse (often >99% zeros).

3. Banded

If nodes are numbered sequentially along the structure, the matrix has a band structure. The bandwidth depends on the maximum node number difference in any element.

4. Positive Semi-Definite

Before applying boundary conditions, the matrix is singular (rigid body modes exist). After fixing enough DOFs, it becomes positive definite.

Assembly in Code

Here's the assembly algorithm in pseudocode:

# Initialize global matrix
K_global = zeros(n_dofs, n_dofs)
F_global = zeros(n_dofs)

# Loop over elements
for e in elements:
    K_e = compute_element_stiffness(e)
    nodes = connectivity[e]  # Global node numbers

    # Scatter element matrix to global
    for i in range(nodes_per_element):
        I = nodes[i]  # Global node
        for j in range(nodes_per_element):
            J = nodes[j]  # Global node
            K_global[I, J] += K_e[i, j]

This is $O(n_{elements} \times n_{nodes/element}^2)$ — very efficient.

Example: Assembling 3 Bar Elements

Given:
  • 4 nodes, 3 elements
  • All elements: $EA/L = 100$ kN/mm
Element matrices:

$$[K_1] = [K_2] = [K_3] = 100 \begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix}$$

Connectivity:
  • Element 1: nodes (1, 2)
  • Element 2: nodes (2, 3)
  • Element 3: nodes (3, 4)
Assembly:

After Element 1:

$$[K] = 100 \begin{bmatrix} 1 & -1 & 0 & 0 \\ -1 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \end{bmatrix}$$

After Element 2 (adds to positions 2,2 and 2,3 and 3,2 and 3,3):

$$[K] = 100 \begin{bmatrix} 1 & -1 & 0 & 0 \\ -1 & 2 & -1 & 0 \\ 0 & -1 & 1 & 0 \\ 0 & 0 & 0 & 0 \end{bmatrix}$$

After Element 3:

$$[K] = 100 \begin{bmatrix} 1 & -1 & 0 & 0 \\ -1 & 2 & -1 & 0 \\ 0 & -1 & 2 & -1 \\ 0 & 0 & -1 & 1 \end{bmatrix}$$

Notice the tridiagonal pattern — each node connects only to its neighbors.

Force Vector Assembly

The same process applies to the force vector:

$$F_{global}(I) \mathrel{+}= F_e(\text{local } i)$$

Distributed loads get "lumped" to nodes through the element force vector, then assembled into the global force vector.

Bandwidth and Node Numbering

The bandwidth of the stiffness matrix depends on how nodes are numbered:

$$\text{Bandwidth} = \max_{elements}(|I - J|) + 1$$

where $I$ and $J$ are the global node numbers in each element.

Good numbering: Number nodes sequentially along the shortest dimension. Bad numbering: Random numbering leads to large bandwidth.

Modern solvers use automatic renumbering algorithms (Cuthill-McKee, Reverse Cuthill-McKee) to minimize bandwidth.

Key Takeaways

  • Assembly combines element matrices into a global system: $[K_{global}]\{u\} = \{F\}$
  • Connectivity table maps local element nodes to global node numbers
  • Stiffnesses add at shared nodes (compatibility + equilibrium)
  • Scatter operation: $K_{global}(I,J) \mathrel{+}= K_e(i,j)$
  • Global matrix properties: Symmetric, sparse, banded, positive semi-definite
  • Bandwidth depends on node numbering — good numbering improves solver efficiency

What's Next

We now have the global system $[K]\{u\} = \{F\}$, but it's singular — we haven't applied boundary conditions yet. In the next lesson, we'll learn how to apply constraints and solve the system.