2. Finite Volume Discretization

This chapter assumes a finite one-dimensional domain \(\Omega := [a,b]; \; a,b \in \mathbb{R}; \; a < b\) which is discretized by \(n\) non-overlapping cells \(\mathcal{C}_i\): \(\Omega = \cup_{i=1}^n \mathcal{C}_i\). In each cell \(i\) we specify the quantities \(Q_i = (h, hu)_i\) and the bathymetry \(b_i\): Again, \(h_i \in \mathbb{R}^+\) is the water height, \((hu)_i \in \mathbb{R}\) the momentum, and \(b_i \in \mathbb{R}\) the bathymetry relative to sea level. Additionally, we have to specify proper boundary conditions which is done by the two ghost cells \(\mathcal{C}_0\) and \(\mathcal{C}_{n+1}\) neighboring the left and right boundary. The obtained spatial discretization is called finite volume discretization.

With a given finite volume discretization we can define a set of \(n+1\) edge-local Riemann problems:

\[\begin{split}q(x,t^n) = \begin{cases} Q_{i-1} \quad &\text{if } x < x_{i-1/2} \\ Q_{i} \quad &\text{if } x > x_{i-1/2} \end{cases} \quad \forall i \in \{ 1, \ldots, n+1 \}.\end{split}\]

The solution of these Riemann problems is obtained analogue to the IVP in Eq. 1.3.1: The f-wave solver determines two net-updates \(A^\mp \Delta Q_{i-1/2}\) per edge \(x_{i-{1/2}}\). The net-update \(A^- \Delta Q_{i-1/2}\) is the net-effect of left-going waves and influences the quantities of \(\mathrm{C}_{i-1}\). \(A^+ \Delta Q_{i-1/2}\) summarizes the net-effect of the right-going waves and influences the quantities in \(\mathrm{C}_i\).

The final update formula from time \(t^n\) to time \(t^{n+1} = t^n + \Delta t\) using the time step \(\Delta t \in \mathbb{R}^+\) is given as:

\[Q_i^{n+1} = Q_i^n - \frac{\Delta t}{\Delta x} \left( A^+ \Delta Q_{i-1/2} + A^- \Delta Q_{i+1/2} \right) \quad \forall i \in \{ 1, \ldots, n \}.\]

Thus a cell \(\mathrm{C}_i\) is influenced by the right going waves – summarized by the net-update \(A^+ \Delta Q_{i-1/2}\) – of its left edge at position \(x_{i-1/2}\) and the left going waves – summarized by the net-update \(A^- \Delta Q_{i+1/2}\) – of its right edge at position \(x_{i+1/2}\). \(\Delta x \in \mathbb{R}^+\) is the cell size which is constant in our implementations.

\(\Delta t\) is chosen in a way such that the waves do not interact with each other. This is implied by waves which do not cross the cell centers \(x_i\). In that case stability of the method is guaranteed if the time step \(\Delta t\) is chosen to satisfy the CFL-criterion:

\[\Delta t < \frac{1}{2} \cdot \frac{\Delta x}{\lambda^\text{max}},\]

where \(\lambda^\text{max}\) is maximum over all absolute values of the eigenvalues computed for the \(n+1\) edges:

\[\lambda^\text{max} = \max_{i=1}^{n+1} \left( \left|\lambda_{1/2}^{\text{Roe}}\right| \right)_{i-1/2}\]

Note: We do not use bathymetry in this part of the project, you can simply set a dummy value in all cells: \(b_i = 0 \quad \forall i \in 0, \ldots, n+1\). The initial code comes with outflow boundary conditions, which set appropriate values in the ghost cells \(\mathcal{C}_0\) and \(\mathcal{C}_{n+1}\) before every time step (see method setGhostOutflow()). We will add bathymetry to our f-wave solver and implement new boundary conditions soon.

Tasks

  1. Integrate your f-wave solver into the one-dimensional implementation of a wave propagation patch given in files WavePropagation1d.h, WavePropagation1d.cpp, WavePropagation1d.test.cpp. Find a good solution to switch between the provided Roe solver and your f-wave solver.

  2. The CSV-file middle_states.csv contains a collection of constant middle states which arise immediately in the Riemann solution at the initial discontinuity. Use these middle states as a sanity check.

  3. Embed your solver into a continuous integration tool. Ensure to run at least the solver’s unit tests after every commit to your git repository. You may use any suitable tool for this task including GitHub Actions, GitLab Runner, Travis CI, Buildkite, GoCD or Jenkins.

2.1. Shock and Rarefaction Waves

Shock-Shock Problem: Let’s use our solver to solve shock-shock Riemann problems. Imagine two streams of water which move in opposite directions and smash into each other at some position \(x_\text{dis}\). The scenario is given by the following setup:

\[\begin{split}\begin{cases} Q_i = q_{l} \quad &\text{if } x_i \le x_\text{dis} \\ Q_i = q_{r} \quad &\text{if } x_i > x_\text{dis} \end{cases} \qquad q_l \in \mathbb{R}^+ \times \mathbb{R}^+, \; q_r \in \mathbb{R}^+ \times \mathbb{R}^-,\end{split}\]

with initial conditions:

(2.1.1)\[\begin{split}q_l= \begin{bmatrix} h_l \\ (hu)_l \end{bmatrix}, \quad q_r = \begin{bmatrix} h_r \\ (hu)_r \end{bmatrix} = \begin{bmatrix} h_l \\ -(hu)_l \end{bmatrix}.\end{split}\]

Rare-Rare Problem: We can setup rare-rare Riemann problems by two streams of water, which move away from each other at some position \(x_\text{dis}\). The scenario is defined as:

\[\begin{split}\begin{cases} Q_i = q_{r} \quad &\text{if } x_i \le x_\text{dis} \\ Q_i = q_{l} \quad &\text{if } x_i > x_\text{dis} \end{cases} \qquad q_l \in \mathbb{R}^+ \times \mathbb{R}^+, \; q_r \in \mathbb{R}^+ \times \mathbb{R}^-,\end{split}\]

with initial conditions identical to Eq. 2.1.1.

Tasks

  1. Implement the shock-shock and rare-rare problems as setups.

  2. Play around with different sets of initial water heights \(h_l\) and particles velocities \(u_l\). What do you observe? Is there a connection to the wave speeds \(\lambda_{1/2} = u \mp \sqrt{gh}\) in Ch. 1.3?

2.2. Dam-Break

../_images/dam_break_initial_eng.svg

Fig. 2.2.1 Illustration of the initial setting for the dam break problem.

Now, let’s solve the dam-break problem. You can imagine a water reservoir which is separated, as illustrated in Fig. 2.2.1, from a river by a dam initially. We assume a total failure of the dam, thus nothing keeps the water from moving downstream:

\[\begin{split}\begin{cases} Q_i = q_{l} \quad &\text{if } x_i \le x_\text{dis} \\ Q_i = q_{r} \quad &\text{if } x_i > x_\text{dis} \end{cases} \qquad q_l \in \mathbb{R}^+ \times 0, \; q_r \in \mathbb{R}^+ \times \mathbb{R}^+, \; h_l > h_r\end{split}\]

Fig. 2.2.2 shows the analytical solution of the dam-break problem, which consists of a rarefaction and a shock wave.

../_images/dam_break_solution_eng.svg

Fig. 2.2.2 Illustration of the analytical solution of the dam break problem.

Tasks

  1. Apply your solver to the dam-break setup and play around with different sets of initial water heights \(h_l\) and \(h_r\). What do you observe? How large is the impact of the particle velocity \(u_r\) in the river?

  2. Assume a water reservoir of unlimited size and a village 25 km downstream with initial values \(q_l=[14, 0]^T\) and \(q_r=[3.5, 0.7]^T\). How much time do you have to evacuate the village in our model before the shock wave arrives?