Lecture 6 (c)

Finite elements in one dimension

Unstructured grids

  • Most problems have complex domains.

  • Boundary conditions crucial.

  • Little “structure” to problem.

  • What use is “structure” in the grid?

  • Use unstructured grids.

  • Use Finite Elements.

An unstructued grid representing parts of the UK

Function bases

Use shape or indicator functions

\[ N_A(x) = \begin{cases} 1 & x = x_A \\ 0 & x = x_j, \quad j \ne A \end{cases} \]

as basis,

\[ \phi = \sum_A c_A(t) N_A(x) \, . \]

Many possibilities; linear case shown.

Shape functions for a domain with two elements (hence three nodes).

Weak form

Focus on time independent case

\[ 0 = \partial_{xx} \psi + S \quad \psi(0) = 0 \quad \partial_x \psi_{x=1} = 0 \, . \]

Switch to weak form: multiply by smooth \(w(x)\), integrate:

\[ \begin{split} 0 = \left[ w(x) \partial_x \psi(x) \right]_0^1 - \int_0^1 \partial_x \psi(x) \partial_x w(x) \, \text{d}x + \\ \int_0^1 w(x) S(x) \, \text{d}x. \end{split} \]

Use basis functions for \(w, \psi, S\): linear system!

Discrete form

Use the basis functions: \[ \begin{aligned} && 0 & = - \int_0^1 \partial_x \psi(x) \partial_x w(x) \, \text{d}x + \int_0^1 w(x) S(x) \, \text{d}x \\ \to && & -\sum_{A, B} \psi_A w_B \int_0^1 \partial_x N_A(x) \partial_x N_B(x) + \sum_{B} w_B \int_0^1 N_B(x) S(x) \, . \end{aligned} \]

The weight function is arbitrary: \[ \begin{aligned} 0 &= \sum_B w_B \left\{ K_{AB} \psi_A - F_B \right\} \, , \\ K_{AB} &= \int_0^1 \partial_x N_A(x) \partial_x N_B(x) \, , & F_B &= \int_0^1 N_B(x) S(x) \, . \end{aligned} \]

\(K\) mass or stiffness matrix, \(F\) force vector.

Linear shape functions, even grid

\[ \begin{aligned} N_A(x) & = \begin{cases} (x - x_{A-1}) / \Delta x & x_{A-1} \le x \le x_A \\ (x_{A+1} - x) / \Delta x & x_{A} \le x \le x_{A+1} \\ 0 & \text{otherwise} \end{cases} \\ \partial_x N_A(x) &= \begin{cases} 1 / \Delta x & x_{A-1} \le x \le x_A \\ -1 / \Delta x & x_{A} \le x \le x_{A+1} \\ 0 & \text{otherwise} \end{cases} \\ K_{AB} &= \int_0^1 \partial_x N_A(x) \partial_x N_B(x) \\ & \sim \frac{1}{\Delta x} \begin{pmatrix} 2 & -1 & 0 \\ -1 & 2 & -1 \\ 0 & -1 & 1 \end{pmatrix} \end{aligned} \]

Shape functions for a domain with three elements (hence four nodes).

Example

Source \(S = 2\).

Exact solution \(\psi = 2x - x^2\).

Force vector \(F_B = \Delta x \, (2, 2, \dots, 1)^T\).

Ne = 4; dx = 1 / Ne
psi = np.zeros(Ne+1)
K = np.diag(2*np.ones(Ne))
K -= np.diag(np.ones(Ne-1), -1)
K -= np.diag(np.ones(Ne-1), +1)
K[-1, -1] = 1
K /= dx
F = 2*np.ones(Ne)
F[-1] = 1
F *= dx
psi[1:] = np.linalg.solve(K, F)

Solution of the simple example.

Summary

  • Finite elements use function basis.
  • Basis not orthogonal: overlap leads to stiffness matrix.
  • Use weak form to shift derivatives to test function.
  • Galerkin: single set of basis functions for everything.
  • Get linear system.