Canoe
Comprehensive Atmosphere N' Ocean Engine
lmars_shallow_yz.cpp
Go to the documentation of this file.
1 // \brief
3 
4 // C/C++
5 #include <algorithm> // min()
6 #include <cmath> // sqrt()
7 #include <iostream>
8 
9 // Athena++
10 #include <athena.hpp>
11 #include <coordinates/coordinates.hpp>
12 #include <hydro/hydro.hpp>
13 #include <mesh/mesh.hpp>
14 
15 // canoe
16 #include <configure.hpp>
17 
18 void Hydro::RiemannSolver(int const k, int const j, int const il, int const iu,
19  int const ivx, AthenaArray<Real> &wl,
21  AthenaArray<Real> const &dxw) {
22  int ivy = ivx == IVY ? IVZ : IVY;
23 
24  Real wli[NHYDRO], wri[NHYDRO];
25 
26  Real ubar, cbar, hbar;
27 
28  AthenaArray<Real> empty{}; // placeholder for unused electric/magnetic fields
29 #ifdef AFFINE // need of projection
30  {
31  switch (ivx) {
32  case IVY:
33  pmy_block->pcoord->PrimToLocal2(k, j, il, iu, empty, wl, wr, empty);
34  break;
35  case IVZ:
36  pmy_block->pcoord->PrimToLocal3(k, j, il, iu, empty, wl, wr, empty);
37  break;
38  }
39  }
40 #endif // AFFINE
41 
42  for (int i = il; i <= iu; ++i) {
43  for (int n = 0; n < NHYDRO; ++n) {
44  wli[n] = wl(n, i);
45  wri[n] = wr(n, i);
46  }
47 
48  cbar = sqrt(0.5 * (wli[IDN] + wri[IDN]));
49  hbar = 0.5 * (wli[IDN] + wri[IDN]) + 0.5 * cbar * (wli[ivx] - wri[ivx]);
50  ubar = 0.5 * (wli[ivx] + wri[ivx]) + 0.5 / cbar * (wli[IDN] - wri[IDN]);
51 
52  if (ubar > 0.) {
53  flx(IDN, k, j, i) = ubar * wli[IDN];
54  flx(ivx, k, j, i) = ubar * wli[IDN] * wli[ivx] + 0.5 * hbar * hbar;
55  flx(ivy, k, j, i) = ubar * wli[IDN] * wli[ivy];
56  } else {
57  flx(IDN, k, j, i) = ubar * wri[IDN];
58  flx(ivx, k, j, i) = ubar * wri[IDN] * wri[ivx] * 0.5 * hbar * hbar;
59  flx(ivy, k, j, i) = ubar * wri[IDN] * wri[ivy];
60  }
61  flx(IVX, k, j, i) = 0.;
62  }
63 
64 #ifdef AFFINE // need of deprojection
65  {
66  // check if this is correct
67  switch (ivx) {
68  case IVY:
69  pmy_block->pcoord->FluxToGlobal2(k, j, il, iu, empty, empty, flx, empty,
70  empty);
71  break;
72  case IVZ:
73  pmy_block->pcoord->FluxToGlobal3(k, j, il, iu, empty, empty, flx, empty,
74  empty);
75  break;
76  }
77  }
78 #endif // AFFINE
79 }