Canoe
Comprehensive Atmosphere N' Ocean Engine
roe_shallow_xy.cpp
Go to the documentation of this file.
1 // \brief Roe's linearized Riemann solver for shallow water model
3 
4 // C/C++
5 #include <algorithm> // min()
6 #include <cmath> // sqrt()
7 #include <iostream>
8 
9 // athena
10 #include <athena/athena.hpp>
11 #include <athena/athena_arrays.hpp>
12 #include <athena/hydro/hydro.hpp>
13 
14 void Hydro::RiemannSolver(int const k, int const j, int const il, int const iu,
15  int const ivx, AthenaArray<Real> &wl,
17  AthenaArray<Real> const &dxw) {
18  int ivy = ivx == IVX ? IVY : IVX;
19 
20  Real wli[NHYDRO], wri[NHYDRO], wave[3][3], speed[3];
21 
22  Real ubar, vbar, cbar, delh, delu, delv, hbar, a1, a2, a3;
23 
24  for (int i = il; i <= iu; ++i) {
25  for (int n = 0; n < NHYDRO; ++n) {
26  wli[n] = wl(n, i);
27  wri[n] = wr(n, i);
28  }
29 
30  ubar = (wli[ivx] * sqrt(wli[IDN]) + wri[ivx] * sqrt(wri[IDN])) /
31  (sqrt(wli[IDN]) + sqrt(wri[IDN]));
32  vbar = (wli[ivy] * sqrt(wli[IDN]) + wri[ivy] * sqrt(wri[IDN])) /
33  (sqrt(wli[IDN]) + sqrt(wri[IDN]));
34  cbar = sqrt(0.5 * (wli[IDN] + wri[IDN]));
35 
36  delh = wri[IDN] - wli[IDN];
37  delu = wri[ivx] - wli[ivx];
38  delv = wri[ivy] - wli[ivy];
39  hbar = sqrt(wli[IDN] * wri[IDN]);
40 
41  a1 = 0.5 * (cbar * delh - hbar * delu) / cbar;
42  a2 = hbar * delv;
43  a3 = 0.5 * (cbar * delh + hbar * delu) / cbar;
44 
45  wave[0][0] = a1;
46  wave[0][1] = a1 * (ubar - cbar);
47  wave[0][2] = a1 * vbar;
48  wave[1][0] = 0.;
49  wave[1][1] = 0.;
50  wave[1][2] = a2;
51  wave[2][0] = a3;
52  wave[2][1] = a3 * (ubar + cbar);
53  wave[2][2] = a3 * vbar;
54 
55  speed[0] = fabs(ubar - cbar);
56  speed[1] = fabs(ubar);
57  speed[2] = fabs(ubar + cbar);
58 
59  flx(IDN, k, j, i) = 0.5 * (wli[IDN] * wli[ivx] + wri[IDN] * wri[ivx]);
60  flx(ivx, k, j, i) =
61  0.5 * (wli[IDN] * wli[ivx] * wli[ivx] + 0.5 * wli[IDN] * wli[IDN] +
62  wri[IDN] * wri[ivx] * wri[ivx] + 0.5 * wri[IDN] * wri[IDN]);
63  flx(ivy, k, j, i) =
64  0.5 * (wli[IDN] * wli[ivx] * wli[ivy] + wri[IDN] * wri[ivx] * wri[ivy]);
65  flx(IVZ, k, j, i) = 0.;
66 
67  for (int r = 0; r < 3; ++r) {
68  flx(IDN, k, j, i) -= 0.5 * speed[r] * wave[r][0];
69  flx(ivx, k, j, i) -= 0.5 * speed[r] * wave[r][1];
70  flx(ivy, k, j, i) -= 0.5 * speed[r] * wave[r][2];
71  }
72  }
73 }