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