Alsvinn  0.5.3
The fast FVM simulator with UQ support
MM.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 
20 namespace alsfvm {
21 namespace reconstruction {
22 
23 template<class Equation>
24 class MM {
25 public:
26 
27  __device__ __host__ static void reconstruct(Equation eq,
28  typename Equation::ConstViews& in,
29  size_t x, size_t y, size_t z,
30  typename Equation::Views& leftView,
31  typename Equation::Views& rightView,
32  bool xDir, bool yDir, bool zDir) {
33  const size_t indexOut = leftView.index(x, y, z);
34  const size_t indexRight = leftView.index(x + xDir, y + yDir, z + zDir);
35  const size_t indexLeft = leftView.index(x - xDir, y - yDir, z - zDir);
36 
37  for (size_t var = 0; var < Equation::getNumberOfConservedVariables(); ++var) {
38  const real left = in.get(var).at(indexLeft);
39  const real middle = in.get(var).at(indexOut);
40  const real right = in.get(var).at(indexRight);
41 
42  const real sigma = minmod((right - middle),
43  (middle - left));
44 
45  leftView.get(var).at(indexOut) = middle - sigma / 2;
46  rightView.get(var).at(indexOut) = middle + sigma / 2;
47  }
48 
49  }
50 
52  return 2;
53  }
54 };
55 } // namespace reconstruction
56 } // namespace alsfvm
alsfvm::shared_ptr< reconstruction::Reconstruction > & reconstruction
Definition: NumericalFluxFactory.cpp:101
__device__ __host__ real minmod(real a, real b)
Definition: minmod.hpp:22
#define __host__
Definition: types.hpp:46
Definition: MM.hpp:24
double real
Definition: types.hpp:65
__device__ static __host__ size_t getNumberOfGhostCells()
Definition: MM.hpp:51
#define __device__
Definition: types.hpp:45
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
__device__ static __host__ void reconstruct(Equation eq, typename Equation::ConstViews &in, size_t x, size_t y, size_t z, typename Equation::Views &leftView, typename Equation::Views &rightView, bool xDir, bool yDir, bool zDir)
Definition: MM.hpp:27