Why finite elements?
Domain for flow around a dolphin
The flow
Solving PDEs by the finite element method
We start with function approximation, then we treat PDEs
Approximation in vector spaces
Approximation set-up
How to determine the coefficients?
Approximation of planar vectors; problem
Approximation of planar vectors; vector space terminology
The least squares method; principle
The least squares method; calculations
The projection (or Galerkin) method
Approximation of general vectors
The least squares method
The projection (or Galerkin) method
Approximation of functions
The least squares method can be extended from vectors to functions
The least squares method; details
The projection (or Galerkin) method
Example: linear approximation; problem
Example: linear approximation; solution
Example: linear approximation; plot
Implementation of the least squares method; ideas
Implementation of the least squares method; symbolic code
Improved code if symbolic integration fails
Implementation of the least squares method; plotting
Implementation of the least squares method; application
Perfect approximation; parabola approximating parabola
Perfect approximation; the general result
Perfect approximation; proof of the general result
Finite-precision/numerical computations; question
Finite-precision/numerical computations; results
The ill-conditioning is due to almost linearly dependent basis functions for large \( N \)
Ill-conditioning: general conclusions
Fourier series approximation; problem and code
Fourier series approximation; plot
Fourier series approximation; improvements
Fourier series approximation; final results
Orthogonal basis functions
Function for the least squares method with orthogonal basis functions
Function for the least squares method with orthogonal basis functions; symbolic and numerical integration
The collocation or interpolation method; ideas and math
The collocation or interpolation method; implementation
The collocation or interpolation method; approximating a parabola by linear functions
Lagrange polynomials; motivation and ideas
Lagrange polynomials; formula and code
Lagrange polynomials; successful example
Lagrange polynomials; a less successful example
Lagrange polynomials; oscillatory behavior
Lagrange polynomials; remedy for strong oscillations
Lagrange polynomials; recalculation with Chebyshev nodes
Lagrange polynomials; less oscillations with Chebyshev nodes
Finite element basis functions
The basis functions have so far been global: \( \baspsi_i(x) \neq 0 \) almost everywhere
In the finite element method we use basis functions with local support
The linear combination of hat functions is a piecewise linear function
Elements and nodes
Example on elements with two nodes (P1 elements)
Illustration of two basis functions on the mesh
Example on elements with three nodes (P2 elements)
Some corresponding basis functions (P2 elements)
Examples on elements with four nodes (P3 elements)
Some corresponding basis functions (P3 elements)
The numbering does not need to be regular from left to right
Interpretation of the coefficients \( c_i \)
Properties of the basis functions
How to construct quadratic \( \basphi_i \) (P2 elements)
Example on linear \( \basphi_i \) (P1 elements)
Example on cubic \( \basphi_i \) (P3 elements)
Calculating the linear system for \( c_i \)
Computing a specific matrix entry (1)
Computing a specific matrix entry (2)
Calculating a general row in the matrix; figure
Calculating a general row in the matrix; details
Calculation of the right-hand side
Specific example with two elements; linear system and solution
Specific example with two elements; plot
Specific example with four elements; plot
Specific example: what about P2 elements?
Assembly of elementwise computations
Split the integrals into elementwise integrals
The element matrix and local vs global node numbers
Illustration of the matrix assembly: regularly numbered P1 elements
Illustration of the matrix assembly: regularly numbered P3 elements
Illustration of the matrix assembly: irregularly numbered P1 elements
Assembly of the right-hand side
Mapping to a reference element
We use affine mapping: linear stretch of \( X\in [-1,1] \) to \( x\in [x_L,x_R] \)
Integral transformation
Advantages of the reference element
Standardized basis functions for P1 elements
Standardized basis functions for P2 elements
How to find the polynomial expressions?
Integration over a reference element; element matrix
Integration over a reference element; element vector
Tedious calculations! Let's use symbolic software
Implementation
Compute finite element basis functions in the reference element
Compute the element matrix
Example on symbolic vs numeric element matrix
Compute the element vector
Fallback on numerical integration if symbolic integration of \( \int f\refphi_r dx \) fails
Linear system assembly and solution
Linear system solution
Example on computing symbolic approximations
Example on computing numerical approximations
The structure of the coefficient matrix
General result: the coefficient matrix is sparse
Exemplifying the sparsity for P2 elements
Matrix sparsity pattern for regular/random numbering of P1 elements
Matrix sparsity pattern for regular/random numbering of P3 elements
Sparse matrix storage and solution
Approximate \( f\sim x^9 \) by various elements; code
Approximate \( f\sim x^9 \) by various elements; plot
Comparison of finite element and finite difference approximation
Interpolation/collocation with finite elements
Galerkin/project and least squares vs collocation/interpolation or finite differences
Expressing the left-hand side in finite difference operator notation
Treating the right-hand side; Trapezoidal rule
Treating the right-hand side; Simpson's rule
Finite element approximation vs finite differences
Making finite elements behave as finite differences
Limitations of the nodes and element concepts
The generalized element concept has cells, vertices, nodes, and degrees of freedom
The concept of a finite element
Basic data structures: vertices
, cells
, dof_map
Example: data structures for P2 elements
Example: P0 elements
A program with the fundamental algorithmic steps
Approximating a parabola by P0 elements
Computing the error of the approximation; principles
Computing the error of the approximation; details
How does the error depend on \( h \) and \( d \)?
Cubic Hermite polynomials; definition
Cubic Hermite polynomials; derivation
Cubic Hermite polynomials; result
Numerical integration
Common form of a numerical integration rule
The Midpoint rule
Newton-Cotes rules apply the nodes
Gauss-Legendre rules apply optimized points
Approximation of functions in 2D
Quick overview of the 2D case
2D basis functions as tensor products of 1D functions
Tensor products
Double or single index?
Example on 2D (bilinear) basis functions; formulas
Example on 2D (bilinear) basis functions; plot
Implementation; principal changes to the 1D code
Implementation; 2D integration
Implementation; 2D basis functions
Implementation; application
Implementation; trying a perfect expansion
Generalization to 3D
Finite elements in 2D and 3D
Examples on cell types
Rectangular domain with 2D P1 elements
Deformed geometry with 2D P1 elements
Rectangular domain with 2D Q1 elements
Basis functions over triangles in the physical domain
Basic features of 2D elements
Linear mapping of reference element onto general triangular cell
\( \basphi_i \): pyramid shape, composed of planes
Element matrices and vectors
Basis functions over triangles in the reference cell
2D P1, P2, P3, P4, P5, and P6 elements
P1 elements in 1D, 2D, and 3D
P2 elements in 1D, 2D, and 3D
Affine mapping of the reference cell; formula
Affine mapping of the reference cell; figure
Isoparametric mapping of the reference cell
Computing integrals
Remark on going from 1D to 2D/3D
Basic principles for approximating differential equations
We shall apply least squares, Galerkin/projection, and collocation to differential equation models
Abstract differential equation
Abstract boundary conditions
Reminder about notation
New topics: variational formulation and boundary conditions
Residual-minimizing principles
The least squares method
The Galerkin method
The Method of Weighted Residuals
New terminology: test and trial functions
The collocation method
Examples on using the principles
The first model problem
Boundary conditions
The least squares method; principle
The least squares method; equation system
The least squares method; matrix and right-hand side expressions
Orthogonality of the basis functions gives diagonal matrix
Least squares method; solution
The Galerkin method; principle
The Galerkin method; solution
The collocation method
Comparison of the methods
Useful techniques
Integration by parts has many advantages
We use a boundary function to deal with non-zero Dirichlet boundary conditions
Example on constructing a boundary function for two Dirichlet conditions
Example on constructing a boundary function for one Dirichlet conditions
With a \( B(x) \), \( u\not\in V \), but \( \sum_{j}c_j\baspsi_j\in V \)
Abstract notation for variational formulations
Example on abstract notation
Bilinear and linear forms
The linear system associated with the abstract form
Equivalence with minimization problem
Examples on variational formulations
Variable coefficient; problem
Variable coefficient; Galerkin principle
Variable coefficient; integration by parts
Variable coefficient; variational formulation
Variable coefficient; linear system (the easy way)
Variable coefficient; linear system (full derivation)
First-order derivative in the equation and boundary condition; problem
First-order derivative in the equation and boundary condition; details
First-order derivative in the equation and boundary condition; observations
First-order derivative in the equation and boundary condition; abstract notation (optional)
First-order derivative in the equation and boundary condition; linear system
Terminology: natural and essential boundary conditions
Nonlinear coefficient; problem
Nonlinear coefficient; variational formulation
Nonlinear coefficient; where does the nonlinearity cause challenges?
Examples on detailed computations by hand
Dirichlet and Neumann conditions; problem
Dirichlet and Neumann conditions; linear system
Dirichlet and Neumann conditions; integration
Dirichlet and Neumann conditions; \( 2\times 2 \) system
When is the numerical method is exact?
Computing with finite elements
Variational formulation
How to deal with the boundary conditions?
Computation in the global physical domain; formulas
Computation in the global physical domain; details
Computation in the global physical domain; linear system
Write out the corresponding difference equation
Comparison with a finite difference discretization
Cellwise computations; formulas
Cellwise computations; details
Cellwise computations; details of boundary cells
Cellwise computations; assembly
General construction of a boundary function
Explanation
Example with two nonzero Dirichlet values; variational formulation
Example with two Dirichlet values; boundary function
Example with two Dirichlet values; details
Example with two Dirichlet values; cellwise computations
Modification of the linear system; ideas
Modification of the linear system; original system
Modification of the linear system; row replacement
Modification of the linear system; element matrix/vector
Symmetric modification of the linear system; algorithm
Symmetric modification of the linear system; example
Symmetric modification of the linear system; element level
Boundary conditions: specified derivative
The variational formulation
Method 1: Boundary function and exclusion of Dirichlet degrees of freedom
Method 2: Use all \( \basphi_i \) and insert the Dirichlet condition in the linear system
How the Neumann condition impacts the element matrix and vector
The finite element algorithm
Python pseudo code; the element matrix and vector
Python pseudo code; boundary conditions and assembly
Variational formulations in 2D and 3D
Integration by parts
Example on integration by parts; problem
Example on integration by parts in 1D/2D/3D
Incorporation of the Neumann condition in the variational formulation
Derivation of the linear system
Transformation to a reference cell in 2D/3D (1)
Transformation to a reference cell in 2D/3D (2)
Transformation to a reference cell in 2D/3D (3)
Numerical integration
Time-dependent problems
Example: diffusion problem
A Forward Euler scheme; ideas
A Forward Euler scheme; stages in the discretization
A Forward Euler scheme; weighted residual (or Galerkin) principle
A Forward Euler scheme; integration by parts
New notation for the solution at the most recent time levels
Deriving the linear systems
Structure of the linear systems
Computational algorithm
Comparing P1 elements with the finite difference method; ideas
Comparing P1 elements with the finite difference method; results
Discretization in time by a Backward Euler scheme
The variational form of the time-discrete problem
Calculations with P1 elements in 1D
Dirichlet boundary conditions
Boundary function
Finite element basis functions
Modification of the linear system; the raw system
Modification of the linear system; setting Dirichlet conditions
Modification of the linear system; Backward Euler example
Analysis of the discrete equations
Handy formulas
Amplification factor for the Forward Euler method; results
Amplification factor for the Backward Euler method; results
Amplification factors for smaller time steps; Forward Euler
Amplification factors for smaller time steps; Backward Euler