Alsvinn  0.5.3
The fast FVM simulator with UQ support
TecnoCombined6.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& uiMinus2,
43  const typename Equation::AllVariables& uiMinus1,
44  const typename Equation::AllVariables& ui,
45  const typename Equation::AllVariables& uiPlus1,
46  const typename Equation::AllVariables& uiPlus2,
47  const typename Equation::AllVariables& uiPlus3,
48  typename Equation::ConservedVariables& F) {
49 
50  real maxWaveSpeed = 0;
51  // helper function to compute the numerical flux
52  auto flux = [&](const typename Equation::AllVariables & left,
53  const typename Equation::AllVariables & right
54  ) {
55 
56  typename Equation::ConservedVariables returnValue;
57  real waveSpeed = BaseFlux::template computeFlux<direction>(eq, left, right,
58  returnValue);
59  maxWaveSpeed = fmax(maxWaveSpeed, waveSpeed);
60 
61  return returnValue;
62 
63  };
64  F = (3.0 / 2.0 * flux(ui, uiPlus1) - 3.0 / 10.0 * (flux(uiMinus1,
65  uiPlus1) + flux(ui, uiPlus2))
66  + 1.0 / 30.0 * (flux(uiMinus2, uiPlus1) + flux(uiMinus1, uiPlus2) + flux(ui,
67  uiPlus3)));
68  return maxWaveSpeed;
69  }
70 
71  static constexpr bool hasStencil = true;
72 
74  return{ -2, -1, 0, 1, 2, 3 };
75  }
76 };
77 } // namespace numflux
78 } // namespace alsfvm
__device__ static __host__ real computeFlux(const Equation &eq, const typename Equation::AllVariables &uiMinus2, const typename Equation::AllVariables &uiMinus1, const typename Equation::AllVariables &ui, const typename Equation::AllVariables &uiPlus1, const typename Equation::AllVariables &uiPlus2, const typename Equation::AllVariables &uiPlus3, typename Equation::ConservedVariables &F)
Definition: TecnoCombined6.hpp:41
static constexpr bool hasStencil
Definition: TecnoCombined6.hpp:71
#define __host__
Definition: types.hpp:46
double real
Definition: types.hpp:65
static const std::string name
name is "tecno6"
Definition: TecnoCombined6.hpp:38
static __host__ __device__ ivec6 stencil()
Definition: TecnoCombined6.hpp:73
#define __device__
Definition: types.hpp:45
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
Definition: TecnoCombined6.hpp:33