Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
boundary_condition/ReflectiveBoundary.hpp
Go to the documentation of this file.
1 // Copyright (c) 2019 Maikel Nadolski
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #ifndef FUB_BOUNDARY_CONDITION_REFLECTIVE_BOUNDARY_HPP
22 #define FUB_BOUNDARY_CONDITION_REFLECTIVE_BOUNDARY_HPP
23 
24 #include "fub/State.hpp"
25 #include "fub/ext/Eigen.hpp"
26 
27 namespace fub {
29  int side);
31  int side);
33  int side);
34 
35 template <typename Equation> class ReflectiveBoundary {
36 public:
38  static constexpr int Rank = Equation::Rank();
39 
40  ReflectiveBoundary(const Equation& equation);
41 
42  void FillBoundary(const View<Complete>& states,
43  const IndexBox<Rank>& box_to_fill, Direction dir, int side);
44 
45  const Equation& GetEquation() const noexcept { return equation_; }
46 
47 private:
51 };
52 
53 template <typename Equation>
55  : equation_{equation} {}
56 
57 template <typename Equation>
59  const View<Complete>& states, const IndexBox<Rank>& box_to_fill,
60  Direction dir, int side) {
61  const Eigen::Matrix<double, Rank, 1> unit = UnitVector<Rank>(dir);
62  ForEachIndex(box_to_fill, [&](auto... is) {
63  Index<Rank> dest{is...};
64  Index<Rank> src = ReflectIndex(dest, box_to_fill, dir, side);
65  Load(state_, states, src);
66  Reflect(reflected_, state_, unit, equation_);
67  Store(states, reflected_, dest);
68  });
69 }
70 
71 } // namespace fub
72 
73 #endif
Definition: boundary_condition/ReflectiveBoundary.hpp:35
Complete reflected_
Definition: boundary_condition/ReflectiveBoundary.hpp:50
void FillBoundary(const View< Complete > &states, const IndexBox< Rank > &box_to_fill, Direction dir, int side)
Definition: boundary_condition/ReflectiveBoundary.hpp:58
static constexpr int Rank
Definition: boundary_condition/ReflectiveBoundary.hpp:38
const Equation & GetEquation() const noexcept
Definition: boundary_condition/ReflectiveBoundary.hpp:45
ReflectiveBoundary(const Equation &equation)
Definition: boundary_condition/ReflectiveBoundary.hpp:54
Equation equation_
Definition: boundary_condition/ReflectiveBoundary.hpp:48
Complete state_
Definition: boundary_condition/ReflectiveBoundary.hpp:49
Function ForEachIndex(const layout_left::mapping< Extents > &mapping, Function function)
Iterate through the multi-dimensional index space descibed by mapping and invoke function for each su...
Definition: ForEach.hpp:74
std::decay_t< decltype(std::declval< T >().GetEquation())> Equation
A template typedef to detect the member function.
Definition: Meta.hpp:59
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
Index< 1 > ReflectIndex(Index< 1 > i, const IndexBox< 1 > &domain, Direction dir, int side)
void Load(State &state, const BasicView< const State, Layout, Rank > &view, const std::array< std::ptrdiff_t, State::Equation::Rank()> &index)
Definition: State.hpp:640
Direction
This is a type safe type to denote a dimensional split direction.
Definition: Direction.hpp:30
std::array< std::ptrdiff_t, static_cast< std::size_t >(Rank)> Index
Definition: PatchDataView.hpp:34
void Reflect(Complete< IdealGasMix< 1 >> &reflected, const Complete< IdealGasMix< 1 >> &state, const Eigen::Matrix< double, 1, 1 > &normal, const IdealGasMix< 1 > &gas)
void Store(const BasicView< Conservative< Eq >, Layout, Eq::Rank()> &view, const Conservative< Eq > &state, const std::array< std::ptrdiff_t, Eq::Rank()> &index)
Definition: State.hpp:663
Definition: State.hpp:403
Definition: PatchDataView.hpp:56