Alsvinn  0.5.3
The fast FVM simulator with UQ support
WENOCoefficients.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 #include <cmath>
20 #include <limits>
21 #define ALSFVM_WENO_EPSILON 1e-8
22 namespace alsfvm {
23 namespace reconstruction {
24 
25 template<int k>
27 public:
28  static const real epsilon;
29  static real coefficients[];
30 
31  template<size_t index, class T>
32  __device__ __host__ static real computeBeta(const T& stencil);
33 
34 
35 };
36 
37 template<>
38 template<size_t index, class T>
40  if (index == 0) {
41  real beta = V[2] - V[1];
42  return beta * beta;
43  } else if (index == 1) {
44  real beta = V[1] - V[0];
45  return beta * beta;
46  }
47 
48  static_assert(index < 2, "Only up to index 1 for order 2 in WENO");
49  return 0;
50 }
51 
52 template<>
53 template<size_t index, class T>
55  if (index == 0) {
56  return 13.0 / 12.0 * pow(V[2] - 2 * V[3] + V[4],
57  2) + 1 / 4.0 * pow(3 * V[2] - 4 * V[3] + V[4], 2);
58  } else if (index == 1) {
59  return 13.0 / 12.0 * pow(V[1] - 2 * V[2] + V[3],
60  2) + 1 / 4.0 * pow(V[1] - V[3], 2);
61  } else if (index == 2) {
62  return 13.0 / 12.0 * pow(V[0] - 2 * V[1] + V[2],
63  2) + 1 / 4.0 * pow(V[0] - 4 * V[1] + 3 * V[2], 2);
64  }
65 
66  static_assert(index < 3, "Only up to index 1 for order 2 in WENO");
67  return 0;
68 }
69 
70 
71 
72 
73 
74 
75 
76 } // namespace alsfvm
77 } // namespace reconstruction
alsfvm::shared_ptr< reconstruction::Reconstruction > & reconstruction
Definition: NumericalFluxFactory.cpp:101
real coefficients[]
Definition: WENOCoefficients.cpp:29
#define __host__
Definition: types.hpp:46
double real
Definition: types.hpp:65
Definition: WENOCoefficients.hpp:26
#define static_assert(x, y)
Definition: types.hpp:52
#define __device__
Definition: types.hpp:45
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
__device__ static __host__ real computeBeta(const T &stencil)
static const real epsilon
Definition: WENOCoefficients.hpp:28