Alsvinn  0.5.3
The fast FVM simulator with UQ support
Roe.hpp
Go to the documentation of this file.
1 /* Copyright (c) 2018 ETH Zurich, Kjetil Olsen Lye
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #pragma once
18 #include <iostream>
19 
20 #include <algorithm>
21 
22 namespace alsfvm {
23 namespace numflux {
24 namespace cubic {
25 
29 
30 class Roe {
31 public:
35  static const std::string name;
36 
37  template<int direction>
38  __device__ __host__ inline static real computeFlux(const
41  const equation::cubic::AllVariables& right,
43  using namespace equation::cubic;
44 
45  ConservedVariables fluxLeft;
46  eq.computePointFlux<direction>(left, fluxLeft);
47 
48  ConservedVariables fluxRight;
49  eq.computePointFlux<direction>(right,
50  fluxRight);
51 
52  real A = 0;
53 
54  if (left.u != right.u) {
55  A = (fluxLeft.u - fluxRight.u) / (left.u - right.u);
56  } else {
57  A = left.u * left.u;
58  }
59 
60  if (A >= 0) {
61  F = fluxLeft;
62  } else {
63  F = fluxRight;
64  }
65 
66  // This looks a bit weird, but it is OK. The basic principle is that AllVariables
67  // is both a conservedVariable and an extra variable, hence we need to pass
68  // it twice since this function expects both.
69  return fmax(eq.computeWaveSpeed<direction>(left, left),
70  eq.computeWaveSpeed<direction>(right, right));
71  }
72 };
73 } // namespace alsfvm
74 } // namespace numflux
75 } // namespace cubic
static const std::string name
name is "Roe"
Definition: Roe.hpp:35
Definition: Roe.hpp:30
#define __host__
Definition: types.hpp:46
double real
Definition: types.hpp:65
Definition: Cubic.hpp:33
#define __device__
Definition: types.hpp:45
__device__ __host__ real computeWaveSpeed(const ConservedVariables &u, const ExtraVariables &v) const
Definition: Cubic.hpp:203
__device__ static __host__ real computeFlux(const equation::cubic::Cubic &eq, const equation::cubic::AllVariables &left, const equation::cubic::AllVariables &right, equation::cubic::ConservedVariables &F)
Definition: Roe.hpp:38
__device__ __host__ void computePointFlux(const AllVariables &u, ConservedVariables &F) const
Definition: Cubic.hpp:159
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
Definition: ConservedVariables.hpp:26
Definition: AllVariables.hpp:24