Alsvinn  0.5.3
The fast FVM simulator with UQ support
TecnoCombined4.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
17 #include "alsfvm/types.hpp"
19 namespace alsfvm {
20 namespace numflux {
21 
32 template<class Equation, class BaseFlux>
34 public:
38  static const std::string name;
39 
40  template<int direction>
41  __device__ __host__ inline static real computeFlux(const Equation& eq,
42  const typename Equation::AllVariables& uiMinus1,
43  const typename Equation::AllVariables& ui,
44  const typename Equation::AllVariables& uiPlus1,
45  const typename Equation::AllVariables& uiPlus2,
46  typename Equation::ConservedVariables& F) {
47 
48  real maxWaveSpeed = 0;
49  // helper function to compute the numerical flux
50  auto flux = [&](const typename Equation::AllVariables & left,
51  const typename Equation::AllVariables & right
52  ) {
53 
54  typename Equation::ConservedVariables returnValue;
55  real waveSpeed = BaseFlux::template computeFlux<direction>(eq, left, right,
56  returnValue);
57  maxWaveSpeed = fmax(maxWaveSpeed, waveSpeed);
58 
59  return returnValue;
60 
61  };
62  F = (4.0 / 3.0 * flux(ui, uiPlus1) - 1.0 / 6.0 * (flux(uiMinus1,
63  uiPlus1) + flux(ui, uiPlus2)));
64  return maxWaveSpeed;
65  }
66 
67  static constexpr bool hasStencil = true;
68 
70  return{ -1, 0, 1, 2 };
71  }
72 };
73 } // namespace numflux
74 } // namespace alsfvm
Definition: vec4.hpp:25
static constexpr bool hasStencil
Definition: TecnoCombined4.hpp:67
#define __host__
Definition: types.hpp:46
double real
Definition: types.hpp:65
Definition: TecnoCombined4.hpp:33
static const std::string name
name is "tecno4"
Definition: TecnoCombined4.hpp:38
static __host__ __device__ ivec4 stencil()
Definition: TecnoCombined4.hpp:69
#define __device__
Definition: types.hpp:45
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
__device__ static __host__ real computeFlux(const Equation &eq, const typename Equation::AllVariables &uiMinus1, const typename Equation::AllVariables &ui, const typename Equation::AllVariables &uiPlus1, const typename Equation::AllVariables &uiPlus2, typename Equation::ConservedVariables &F)
Definition: TecnoCombined4.hpp:41