Discretization


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 tt and defined in all values of xx:

u=u(x,t)u=u(x,t)

Spatial discretization:

  • Nodes: xi=(i1)Δxx_i=(i-1)\Delta x
    • i=1,2,,Ni=1,2,\dots,N
    • Δx=L/(N1)\Delta x=L/(N-1)
    • Alternatively, xi=iΔxx_i=i\Delta x with i=0,1,2,,N+1i=0,1,2,\dots,N+1 where Δx=L/(N+1)\Delta x=L/(N+1)
  • Values: ui(t)=u(xi,t)u_i(t)=u(x_i,t)
    • i=1,2,,Ni=1,2,\dots,N
    • For simplicity, ui=ui(t)u_i=u_i(t)

Nodes i{1,N}i\in\{1,N\} are boundary nodes, where values of uiu_i 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 ii, its value is defined as xi=(i1)Δxx_i=(i-1)\Delta x where Δx=L/(N1)\Delta x=L/(N-1)

  • Internal nodes: xii[1,N1]x_i\rightarrow i\in[1,N-1]
    • Computational variables: uii[1,N1]u_i\rightarrow i\in[1,N-1] for each time step
  • External (boundary) nodes: x0=0,xN=Lx_0=0,x_N=L
    • Boundary conditions: u0,uNu_0,u_N

Example of a 2nd order extrapolation: u~N=2uN1uN2\tilde u_N=2u_{N-1}-u_{N-2}:

u~N=2uN1uN22(uNxunΔx+12xxunΔx2+)(uN2xunΔx+12xxun(2Δx)2+)uNO(Δx2)\begin{aligned} \tilde u_N=2u_{N-1}-u_{N-2}\approx&2\left( u_N-\partial_xu_n \Delta x+\frac{1}{2}\partial_{xx}u_n\Delta x^2+\cdots \right)\\ &-\left( u_N-2\partial_xu_n\Delta x+\frac{1}{2}\partial_{xx}u_n(2\Delta x)^2+\cdots \right)\\ \approx&u_N-O(\Delta x^2) \end{aligned}
  • Consistency: limΔx0u~N=uN\lim_{\Delta_x\rightarrow0}\tilde u_N=u_N
  • For simplicity, uN=u~Nu_N=\tilde u_N

2nd order central derivative:

ui+1=ui+Δxui+(Δx)22!ui+(Δx)33!ui+(Δx)44!ui+ui1=uiΔxui+(Δx)22!ui(Δx)33!ui+(Δx)44!ui\begin{gathered} u_{i+1}=u_i+\Delta xu'_i+\frac{(\Delta x)^2}{2!}u_i''+\frac{(\Delta x)^3}{3!}u_i'''+\frac{(\Delta x)^4}{4!}u_i'''+\cdots\\ u_{i-1}=u_i-\Delta xu'_i+\frac{(\Delta x)^2}{2!}u_i''-\frac{(\Delta x)^3}{3!}u_i'''+\frac{(\Delta x)^4}{4!}u_i'''-\cdots\\ \end{gathered}

Summing both expressions, we can only retain 2nd derivative:

ui+1+ui1=2ui+(Δx)2ui+24!(Δx)4ui+ui=ui+12ui+ui1(Δx)2112(Δx)2ui+\begin{gathered} u_{i+1}+u_{i-1}=2u_i+(\Delta x)^2u_i''+\frac{2}{4!}(\Delta x)^4u_i''''+\cdots\\ u_i''=\frac{u_{i+1}-2u_i+u_{i-1}}{(\Delta x)^2}-\frac{1}{12}(\Delta x)^2u_i''''+\cdots \end{gathered}

The dominant term scales with Δx2\Delta x^2, therefore we can define the second derivatives as:

D2ui=ui+12ui+ui1(Δx)2\mathcal D^2u_i=\frac{u_{i+1}-2u_i+u_{i-1}}{(\Delta x)^2}
  • Consistency: limΔx0D2ui=ui\lim_{\Delta x\rightarrow0}\mathcal D^2u_i=u_i''

A list of delayed, advanced, and centered discretizations:

Duiuiui1Δx;D2uiui2ui1+ui2Δx2Duiui+1u1Δx;D2uiui+22ui+1+uiΔx2Duiui+1ui12Δx;D2uiui+12ui+ui1Δx2\begin{aligned} &\mathcal Du_i\approx\frac{u_i-u_{i-1}}{\Delta x}\quad&;&\quad\mathcal D^2u_i\approx\frac{u_i-2u_{i-1}+u_{i-2}}{\Delta x^2}\\ &\mathcal Du_i\approx\frac{u_{i+1}-u_1}{\Delta x}\quad&;&\quad\mathcal D^2u_i\approx\frac{u_{i+2}-2u_{i+1}+u_i}{\Delta x^2}\\ &\mathcal Du_i\approx\frac{u_{i+1}-u_{i-1}}{2\Delta x}\quad&;&\quad\mathcal D^2u_i\approx\frac{u_{i+1}-2u_i+u_{i-1}}{\Delta x^2}\\ \end{aligned}

Finite Volumes

Both NS and Euler equations can be written in the conservative form:

Ut+F=S\frac{\partial\mathbf U}{\partial t}+\nabla\cdot\mathbf F=\mathbf S
  • U\mathbf U: Vector of conservative variables
  • F\mathbf F: Vector of fluxes. Sum of convective Fc\mathbf F^c and viscous Fv\mathbf F^v fluxes
    • Fv\mathbf F^v is also the sum of physical viscosity and numerical viscosity

Integrating the equation in a control volume pp gives:

Vp ⁣dUp ⁣dt+VpF ⁣dV=VpS ⁣dVV_p\frac{\dd\overline{\mathbf U}_p}{\dd t}+\int_{V_p}\nabla\cdot\mathbf F\dd\mathbf V=\int_{V_p}\mathbf S\dd\mathbf V
  • Up=1VpVpU ⁣dV\overline{\mathbf U}_p=\frac{1}{V_p}\int_{\partial V_p}\mathbf U\dd\mathbf V: Mean of the computational variable in the control volume pp,

Using Gauss:

Vp ⁣dUp ⁣dt+VpF ⁣dS=VpS ⁣dVV_p\frac{\dd\overline{\mathbf U}_p}{\dd t}+\oint_{\partial V_p}\mathbf F\cdot\dd\mathbf S=\int_{V_p}\mathbf S\dd\mathbf V

Given the control volumes are plain faces, this can be simplified to:

 ⁣dUp ⁣dt+1VpfVpfacesFfΔAf=S\frac{\dd\overline{\mathbf U}_p}{\dd t}+\frac{1}{V_p}\sum_{f\in\partial V_p}^\text{faces}\mathbf F_f\cdot\Delta\mathbf A_f=\overline{\mathbf S}

Temporal Discretization

Now considering the solution of any node xix_i, in function of the time: ui(t)u_i(t). The time discretization is defined as:

tn=nΔt;n=0,1,2,;Δt>0t_n=n\Delta t\quad;\quad n=0,1,2,\dots\quad;\quad\Delta t>0
  • tn+1=(n+1)Δt=tn+Δtt_{n+1}=(n+1)\Delta t=t_n+\Delta t
  • The value of uiu_i in time tnt_n can be represented as uinu_i^n.

Space-Time Discretization

Using the method of lines:

  • Spatial discretization: tui+cxui=0\partial_tu_i+c\partial_xu_i=0
  • Temporal discretization: uin+1=uin+ΔtFinu_i^{n+1}=u_i^n+\Delta tF_i^n
    • Fin=uixuiF_i^n=-u_i\partial_xu_i at tnt_n