Finite volume schemes

1. Advection problem – constant or variable velocity

We first solve the easy linear problem $$\partial_t u + \partial_x (a u) = 0,\quad x\in[0,L]$$ with periodic boundary conditions. Firstly, the velocity $a>0$ is constant in space and time.

Some tools:
The following function will be usefull to represent the discrete solutions $(U_j^n)$ as functions of space and time.
General syntax: SHOW(data=UTX,leg='scheme')

SHOW() to draw the data stored in the 2-dimensional array UTX.

SHOW(UTX_other) to draw the data stored in another array UTX_other.

SHOW(UTX_other,leg='truc') to add the title truc to the figures.

Question 1. For the two above CFL parameters $\mu\in\{0.9,1\}$, compute the solution with $J=200$ cells to observe the convergence.

Answer 1.

Remark. The scheme for $\mu=1$ is exact since it exactly reproduces the transport along characteristic lines, that are aligned with the space-time grid. For $\mu<1$, we observe the smoothing of the discontinuity, due to the diffusion effect of the scheme (see previous work on finite difference schemes). However, the discrete profile is closer to the exact solution for a large grid.

Question 2. Now implement the Lax-Friedrichs flux
$$F_{j+1/2}^n = \dfrac{1}{2}(f(U_j^n)+f(U_{j+1}^n)) - \dfrac{\sigma}{2}(U_{j+1}^n-U_{j}^n),$$ with $\sigma = \max\big\{|f'(u)|,\ u \in[\inf u_0,\sup u_0]\big\}.$
Compare the discrete solution with $\mu=0.9$ to the one obtained with the previous left scheme.

Answer 2.

Remark. When computing the discrete solution for the Lax-Friedrichs scheme, there is no difference in the numerical solution. Namely, the numerical fluxes exactly coincide since $\sigma=a=1>0$ and the $F_{j+1/2}^n = a U_j^n$. However the Lax-Friedrichs scheme may differ from the Left flux for equations with varying $\sigma$ (non-constant coefficients and/or nonlinear equations.

Advection with time+space-depending velocities

We consider now the linear problem $$\partial_t u + \partial_x (a(t,x) u) = 0$$ with periodic boundary conditions.

For the tests, we consider the following velocity field $$ a(t,x)= 2\cos(2\pi t)\sin(2\pi x),$$ varying both in time and space, for $x\in[0,4]$.
The initial data is $$u_0(x) = e^{-9(x-1)^2}.$$

Remark. The previous figure represents the velocity field, that is concerned with the characteristic lines for the advective equation $\partial_t u + a(t,x)\partial_x u$ but also to understand the behavior and the properties of the conservative form $\partial_t u + \partial_x (a(t,x) u ) =0$.
There are some straigth lines in the $(x-t)$-plane where the velocity field vanishes, namely for $x\in\tfrac{1}{2}\mathbb{Z}$ and for $t\in \tfrac{1}{4}+\tfrac{1}{2}\mathbb{Z}$. The flux along these lines therefore is zero and there is conservation of mass in any space interval of the form $[j,j+1/2]$ for $j\in \tfrac{1}{2}\mathbb{Z}$.

We use the Lax-Friedrichs scheme with $F_{j+1/2}^n \overset{\rm def}{=} \dfrac{1}{2}(f(U_j^n,t^n,x_{j+1/2})+f(U_{j+1}^n,t^n,x_{j+1/2})) - \dfrac{\sigma}{2}(U_{j+1}^n-U_{j}^n)$.

Question 3. From the properties of the velocity field above, explain why the choice of a grid with $J=8p+4$ cells is interesting. What properties are expected to be satisfied for the exact solution to the problem and what kind of defect is however present in the numerical solution ?

Answer. The numerical flux is computed at the points $x_{j+1/2} = (j+1/2)\Delta x = 4(j+1/2)/J$. Among them, there exists an integer $j$ such that $x_{j+1/2}$ coincides with a point in $\tfrac{1}{2}\mathbb{Z}$ if and only if $J\in 4+8\mathbb{N}$.
The conservation of mass in the elementary intervals previously discussed (of the form $[j,j+1/2]$ for $j\in \tfrac{1}{2}\mathbb{Z}$) is not satisfied for the discrete solution: some mass is going outside the domain $[1,3]$. The reason is that the numerical flux does not vanished at the expected points since it includes also a gradient of the discrete solution.

We perform several computations with finer grids.

Question 4. Did the defect disappear for large values of $J$ ?

Answer. Increasing the value of $J$ reduces the observed defect.

We consider now another scheme for the resolution of the same problem, using an upwind strategy. The numerical flux is $$F_{j+1/2}^n = \begin{cases}f(U_j^n,t_n,x_{j+1/2}), & \textrm{ if } a(t_n,x_{j+1/2})>0 ; \\ f(U_{j+1}^n,t_n,x_{j+1/2}), & \textrm{ if } a(t_n,x_{j+1/2})<0.\end{cases}$$

Question 5. Does the upwind scheme provide good results ?

Answer. Even with a very few cells, the upwind scheme strongly reduces the local conservation defect. Having common points in the grid with the $\tfrac{1}{2}\mathbb{Z}$ points, there the numerical flux vanished and the invariance structure is strongly preserved.
Increasing the number of cells significantly improves the quality of the result.

2. Nonlinear Burgers problem

Question 6. Program the Lax-Friedrichs scheme for the Burgers equation: $$F_{j+1/2}^n = \dfrac{1}{2}(f(U_j^n)+f(U_{j+1}^n)) - \dfrac{\sigma}{2}(U_{j+1}^n-U_{j}^n),$$ with $\sigma = \max\big\{|f'(u)|,\ u \in[\inf u_0,\sup u_0]\big\}.$
Compare the discrete solution with $\mu=0.9$ for several values of the grid size $J$.

The Godunov scheme is defined from the exact solution of local Riemann problems.
The discrete flux is then obtained as $$F_{j+1/2}^n = f(w(0,U_j^n,U_{j+1}^n))$$ where $w(\xi,U,V)$ denotes the self-similar (and entropy weak) solution to the Riemann problem with left state $U$ and right state $V$.

Question 7. Solve the Riemann problem for the Burgers flux and then program the Godunov scheme for the Burgers problem. Compare the solution to the Lax-Friedrichs scheme.

Question 8. Program the local Lax-Friedrichs scheme for the Burgers equation: $$F_{j+1/2}^n = \dfrac{1}{2}(f(U_j^n)+f(U_{j+1}^n)) - \dfrac{\sigma_j^n}{2}(U_{j+1}^n-U_{j}^n),$$ with $\sigma_j^n = \max\big\{|f'(u)|,\ u \in[\min(U_j^n,U_{j+1}^n),\max(U_j^n,U_{j+1}^n)]\big\}.$
Compare the solution to the previous schemes.

Question 9. Solve a Cauchy problems for the nonlinear equations with flux $f(u)= 2 u^3 -u$.