Alsvinn  0.5.3
The fast FVM simulator with UQ support
Tecno1.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"
21 namespace alsfvm {
22 namespace numflux {
23 namespace euler {
24 
25 
30 template<int nsd>
31 class Tecno1 {
32 public:
36  static const std::string name;
37 
38  typedef typename Types<nsd>::rvec rvec;
40 
43  template<int direction>
44  __device__ __host__ inline static real computeFlux(const
48 };
49 
52 template<>
53 template<int direction>
55  const equation::euler::Euler<3>& eq,
59  real gamma = eq.getGamma();
60  auto rightZ = eq.computeTecnoVariables(right).z;
61  auto leftZ = eq.computeTecnoVariables(left).z;
62 
63  if (left == right) {
64  eq.computePointFlux<direction>(left, F);
65  } else if (direction == 0) {
66  F[0] = bar(leftZ[1], rightZ[1]) * ln(leftZ[4], rightZ[4]);
67  F[1] = bar(leftZ[4], rightZ[4]) / bar(leftZ[0], rightZ[0]) + bar(leftZ[1],
68  rightZ[1]) / bar(leftZ[0], rightZ[0]) * F[0];
69  F[2] = bar(leftZ[2], rightZ[2]) / bar(leftZ[0], rightZ[0]) * F[0];
70  F[3] = 0; // assume 2D
71  F[4] = 1.0 / (2 * bar(leftZ[0],
72  rightZ[0])) * ((gamma + 1) / (gamma - 1) * divLn(leftZ[0], rightZ[0],
73  (F[0])) + bar(leftZ[1], rightZ[1]) * F[1] + bar(leftZ[2], rightZ[2]) * F[2]);
74  } else if (direction == 1) {
75  F[0] = bar(leftZ[2], rightZ[2]) * ln(leftZ[4], rightZ[4]);
76  F[1] = bar(leftZ[1], rightZ[1]) / bar(leftZ[0], rightZ[0]) * F[0];
77  F[2] = bar(leftZ[4], rightZ[4]) / bar(leftZ[0], rightZ[0]) + bar(leftZ[2],
78  rightZ[2]) / bar(leftZ[0], rightZ[0]) * F[0];
79  F[3] = 0; // assume 2D
80  F[4] = 1.0 / (2 * bar(leftZ[0],
81  rightZ[0])) * ((gamma + 1) / (gamma - 1) * divLn(leftZ[0], rightZ[0],
82  (F[0])) + bar(leftZ[1], rightZ[1]) * F[1] + bar(leftZ[2], rightZ[2]) * F[2]);
83  }
84 
85  real leftSpeed = 0, rightSpeed = 0;
86  real cs = 0;
87  HLL3<3>::computeHLLSpeeds<direction>(eq, left, right, leftSpeed, rightSpeed,
88  cs);
89  return fmax(fabs(leftSpeed), fabs(rightSpeed));
90 }
91 
94 template<>
95 template<int direction>
97  const equation::euler::Euler<2>& eq,
101  real gamma = eq.getGamma();
102  auto rightZ = eq.computeTecnoVariables(right).z;
103  auto leftZ = eq.computeTecnoVariables(left).z;
104 
105  if (left == right) {
106  eq.computePointFlux<direction>(left, F);
107  } else if (direction == 0) {
108  F[0] = bar(leftZ[1], rightZ[1]) * ln(leftZ[3], rightZ[3]);
109  F[1] = bar(leftZ[3], rightZ[3]) / bar(leftZ[0], rightZ[0]) + bar(leftZ[1],
110  rightZ[1]) / bar(leftZ[0], rightZ[0]) * F[0];
111  F[2] = bar(leftZ[2], rightZ[2]) / bar(leftZ[0], rightZ[0]) * F[0];
112  F[3] = 1.0 / (2 * bar(leftZ[0],
113  rightZ[0])) * ((gamma + 1) / (gamma - 1) * divLn(leftZ[0], rightZ[0],
114  (F[0])) + bar(leftZ[1], rightZ[1]) * F[1] + bar(leftZ[2], rightZ[2]) * F[2]);
115  } else if (direction == 1) {
116  F[0] = bar(leftZ[2], rightZ[2]) * ln(leftZ[3], rightZ[3]);
117  F[1] = bar(leftZ[1], rightZ[1]) / bar(leftZ[0], rightZ[0]) * F[0];
118  F[2] = bar(leftZ[3], rightZ[3]) / bar(leftZ[0], rightZ[0]) + bar(leftZ[2],
119  rightZ[2]) / bar(leftZ[0], rightZ[0]) * F[0];
120  F[3] = 1.0 / (2 * bar(leftZ[0],
121  rightZ[0])) * ((gamma + 1) / (gamma - 1) * divLn(leftZ[0], rightZ[0],
122  (F[0])) + bar(leftZ[1], rightZ[1]) * F[1] + bar(leftZ[2], rightZ[2]) * F[2]);
123  }
124 
125  real leftSpeed = 0, rightSpeed = 0;
126  real cs = 0;
127  HLL3<2>::computeHLLSpeeds<direction>(eq, left, right, leftSpeed, rightSpeed,
128  cs);
129  return fmax(fabs(leftSpeed), fabs(rightSpeed));
130 
131  //return fmax(eq.template computeWaveSpeed<direction>(left, left),
132  // eq.template computeWaveSpeed<direction>(right, right));
133 }
134 
135 
136 template<>
137 template<int direction>
139  const equation::euler::Euler<1>& eq,
143  real gamma = eq.getGamma();
144  auto rightZ = eq.computeTecnoVariables(right).z;
145  auto leftZ = eq.computeTecnoVariables(left).z;
146 
147  if (left == right) {
148  eq.computePointFlux<direction>(left, F);
149  } else if (direction == 0) {
150  F[0] = bar(leftZ[1], rightZ[1]) * ln(leftZ[2], rightZ[2]);
151  F[1] = bar(leftZ[2], rightZ[2]) / bar(leftZ[0], rightZ[0]) + bar(leftZ[1],
152  rightZ[1]) / bar(leftZ[0], rightZ[0]) * F[0];
153  F[2] = 1.0 / (2 * bar(leftZ[0],
154  rightZ[0])) * ((gamma + 1) / (gamma - 1) * divLn(leftZ[0], rightZ[0],
155  (F[0])) + bar(leftZ[1], rightZ[1]) * F[1]);
156  }
157 
158  real leftSpeed = 0, rightSpeed = 0;
159  real cs = 0;
160  HLL3<1>::computeHLLSpeeds<direction>(eq, left, right, leftSpeed, rightSpeed,
161  cs);
162  return fmax(fabs(leftSpeed), fabs(rightSpeed));
163 
164  //return fmax(eq.template computeWaveSpeed<direction>(left, left),
165  // eq.template computeWaveSpeed<direction>(right, right));
166 }
167 } // namespace euler
168 } // namespace numflux
169 } // namespace alsfvm
Definition: types.hpp:104
Types< nsd+2 >::rvec state_vector
Definition: Tecno1.hpp:39
__device__ __host__ real getGamma() const
Definition: Euler.hpp:299
Definition: HLL3.hpp:37
__device__ __host__ void computePointFlux(const AllVariables &u, ConservedVariables &F) const
Definition: Euler.hpp:173
static const std::string name
name is "tecno1"
Definition: Tecno1.hpp:36
#define __host__
Definition: types.hpp:46
Definition: ConservedVariables.hpp:30
double real
Definition: types.hpp:65
__device__ __host__ TecnoVariables computeTecnoVariables(const ConservedVariables &conserved) const
Definition: Euler.hpp:311
__device__ __host__ real bar(real left, real right)
Definition: tecno_utils.hpp:22
Definition: Tecno1.hpp:31
#define __device__
Definition: types.hpp:45
Definition: Euler.hpp:36
Definition: AllVariables.hpp:27
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
Types< nsd >::rvec rvec
Definition: Tecno1.hpp:38
__device__ __host__ real divLn(real left, real right, real F)
Definition: tecno_utils.hpp:39
__device__ __host__ real ln(real left, real right)
Definition: tecno_utils.hpp:29
__device__ static __host__ real computeFlux(const equation::euler::Euler< nsd > &eq, const equation::euler::AllVariables< nsd > &left, const equation::euler::AllVariables< nsd > &right, equation::euler::ConservedVariables< nsd > &F)