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:
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:
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:
where \(\lambda^\text{max}\) is maximum over all absolute values of the eigenvalues computed for the \(n+1\) edges:
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
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.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.
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:
with initial conditions:
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:
with initial conditions identical to Eq. 2.1.1.
Tasks
Implement the shock-shock and rare-rare problems as setups.
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
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:
Fig. 2.2.2 shows the analytical solution of the dam-break problem, which consists of a rarefaction and a shock wave.
Tasks
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?
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?