Alsvinn  0.5.3
The fast FVM simulator with UQ support
PrimitiveVariables.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"
18 
19 namespace alsfvm {
20 namespace equation {
21 namespace euler {
27 template<int nsd>
29 public:
30  typedef typename Types<nsd>::rvec rvec;
31 
32 
34  : rho(0), u(0), p(0) {
35  // empty
36  }
37 
39  : rho(rho), u(u), p(p) {
40  // empty
41  }
42 
43  template<class T>
45  : rho(rho), u(rvec3{ux, uy, uz}), p(p) {
46  static_assert(nsd == 3 || sizeof(T) == 0, "Only for 3 dimensions!");
47  }
48 
49  template<class T>
51  : rho(rho), u(rvec2{ux, uy}), p(p) {
52  static_assert(nsd == 2 || sizeof(T) == 0, "Only for 3 dimensions!");
53  }
54 
59 
63  rvec u;
64 
69 
70 };
75 template<int nsd>
78  return PrimitiveVariables<nsd>(a.rho - b.rho, a.u - b.u, a.p - b.p);
79 }
80 
85 template<int nsd>
88  return PrimitiveVariables<nsd>(a.rho + b.rho, a.u + b.u, a.p + b.p);
89 }
90 
95 template<int nsd>
97  const PrimitiveVariables<nsd>& b) {
98  return PrimitiveVariables<nsd>(a * b.rho, a * b.u, a * b.p);
99 }
100 
105 template<int nsd>
108  return PrimitiveVariables<nsd>(a.rho / b, a.u / b, a.p / b);
109 }
110 }
111 }
112 }
real rho
rho is the density
Definition: PrimitiveVariables.hpp:58
Definition: types.hpp:104
__device__ __host__ PrimitiveVariables(T rho, T ux, T uy, T p)
Definition: PrimitiveVariables.hpp:50
__device__ __host__ PrimitiveVariables(T rho, T ux, T uy, T uz, T p)
Definition: PrimitiveVariables.hpp:44
#define __host__
Definition: types.hpp:46
Definition: vec2.hpp:24
double real
Definition: types.hpp:65
int ux
Definition: sodshocktube.py:4
Types< nsd >::rvec rvec
Definition: PrimitiveVariables.hpp:30
Definition: PrimitiveVariables.hpp:28
__device__ __host__ PrimitiveVariables()
Definition: PrimitiveVariables.hpp:33
#define static_assert(x, y)
Definition: types.hpp:52
rvec u
u is the velocity
Definition: PrimitiveVariables.hpp:63
__device__ __host__ ConservedVariables< nsd > operator*(real a, const ConservedVariables< nsd > &b)
Definition: ConservedVariables.hpp:123
#define __device__
Definition: types.hpp:45
__device__ __host__ PrimitiveVariables(real rho, rvec u, real p)
Definition: PrimitiveVariables.hpp:38
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
real p
p is the pressure
Definition: PrimitiveVariables.hpp:68