As computers cannot work with an infinite domain, discretization of the domain is required.
Contents
Spatial Discretization
There are different methods of spatial discretization:
- Finite differences: Based on differential equations
- Finite volumes: Based on integral equations
- Finite elements
- Spectral
Given the analytical solution in a time t and defined in all values of x:
u=u(x,t)
Spatial discretization:
- Nodes: xi=(i−1)Δx
- i=1,2,…,N
- Δx=L/(N−1)
- Alternatively, xi=iΔx with i=0,1,2,…,N+1 where Δx=L/(N+1)
- Values: ui(t)=u(xi,t)
- i=1,2,…,N
- For simplicity, ui=ui(t)
Nodes i∈{1,N} are boundary nodes, where values of ui should be imposed.
Finite Differences
- Based on differentials
- Domain represented by a distribution of points (nodes)
- Derivatives are approximated with the linear combination of the values of variables being derived
- Consistency condition: The weight of each terms of the lineal combinations must be chosen such that they converge to the corresponding derivative when the nodes are infinitesimally close
Given a generic node i, its value is defined as xi=(i−1)Δx where Δx=L/(N−1)
- Internal nodes: xi→i∈[1,N−1]
- Computational variables: ui→i∈[1,N−1] for each time step
- External (boundary) nodes: x0=0,xN=L
- Boundary conditions: u0,uN
Example of a 2nd order extrapolation: u~N=2uN−1−uN−2:
u~N=2uN−1−uN−2≈≈2(uN−∂xunΔx+21∂xxunΔx2+⋯)−(uN−2∂xunΔx+21∂xxun(2Δx)2+⋯)uN−O(Δx2)
- Consistency: limΔx→0u~N=uN
- For simplicity, uN=u~N
2nd order central derivative:
ui+1=ui+Δxui′+2!(Δx)2ui′′+3!(Δx)3ui′′′+4!(Δx)4ui′′′+⋯ui−1=ui−Δxui′+2!(Δx)2ui′′−3!(Δx)3ui′′′+4!(Δx)4ui′′′−⋯
Summing both expressions, we can only retain 2nd derivative:
ui+1+ui−1=2ui+(Δx)2ui′′+4!2(Δx)4ui′′′′+⋯ui′′=(Δx)2ui+1−2ui+ui−1−121(Δx)2ui′′′′+⋯
The dominant term scales with Δx2, therefore we can define the second derivatives as:
D2ui=(Δx)2ui+1−2ui+ui−1
- Consistency: limΔx→0D2ui=ui′′
A list of delayed, advanced, and centered discretizations:
Dui≈Δxui−ui−1Dui≈Δxui+1−u1Dui≈2Δxui+1−ui−1;;;D2ui≈Δx2ui−2ui−1+ui−2D2ui≈Δx2ui+2−2ui+1+uiD2ui≈Δx2ui+1−2ui+ui−1
Finite Volumes
Both NS and Euler equations can be written in the conservative form:
∂t∂U+∇⋅F=S
- U: Vector of conservative variables
- F: Vector of fluxes. Sum of convective Fc and viscous Fv fluxes
- Fv is also the sum of physical viscosity and numerical viscosity
Integrating the equation in a control volume p gives:
VpdtdUp+∫Vp∇⋅FdV=∫VpSdV
- Up=Vp1∫∂VpUdV: Mean of the computational variable in the control volume p,
Using Gauss:
VpdtdUp+∮∂VpF⋅dS=∫VpSdV
Given the control volumes are plain faces, this can be simplified to:
dtdUp+Vp1f∈∂Vp∑facesFf⋅ΔAf=S
Temporal Discretization
Now considering the solution of any node xi, in function of the time: ui(t). The time discretization is defined as:
tn=nΔt;n=0,1,2,…;Δt>0
- tn+1=(n+1)Δt=tn+Δt
- The value of ui in time tn can be represented as uin.
Space-Time Discretization
Using the method of lines:
- Spatial discretization: ∂tui+c∂xui=0
- Temporal discretization: uin+1=uin+ΔtFin
- Fin=−ui∂xui at tn