Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
MultiBlockBoundary.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_AMREX_MULTI_BLOCK_BOUNDARY_HPP
22 #define FUB_AMREX_MULTI_BLOCK_BOUNDARY_HPP
23 
25 #include "fub/Direction.hpp"
26 #include "fub/Duration.hpp"
27 #include "fub/PatchDataView.hpp"
29 
30 #include <AMReX.H>
31 #include <AMReX_MultiFab.H>
32 
33 #include <boost/log/sources/severity_channel_logger.hpp>
34 #include <boost/log/trivial.hpp>
35 
36 #include <vector>
37 
38 namespace fub::amrex {
39 
40 class MultiBlockGriddingAlgorithm;
41 class PatchHierarchy;
42 class GriddingAlgorithm;
43 
44 namespace cutcell {
45 class PatchHierarchy;
46 class GriddingAlgorithm;
47 } // namespace cutcell
48 
49 struct BlockEntry {
50  std::size_t id;
52 };
53 
58  int side;
60 };
61 
62 /// \ingroup BoundaryCondition
63 ///
65 public:
66  static constexpr int Plenum_Rank = AMREX_SPACEDIM;
67  static constexpr int Tube_Rank = 1;
68 
69  /// Constructs coupled boundary states by pre computing mirror and ghost
70  /// states for each of the specified domains.
71  ///
72  /// This function might grow the specified mirror boxes to an extent which is
73  /// required to fulfill the specified ghost cell width requirements.
74  MultiBlockBoundary(const std::string& name,
75  const MultiBlockGriddingAlgorithm& gridding,
76  const BlockConnection& connection, int gcw,
77  const FlameMasterReactor& reactor, int level);
78 
79  MultiBlockBoundary(const std::string& name,
80  const MultiBlockGriddingAlgorithm& gridding,
81  const BlockConnection& connection, int gcw,
82  const FlameMasterReactor& reactor, int level,
83  std::shared_ptr<PressureValve> valve);
84 
85  /// Constructs coupled boundary states by pre computing mirror and ghost
86  /// states for each of the specified domains.
87  ///
88  /// This function might grow the specified mirror boxes to an extent which is
89  /// required to fulfill the specified ghost cell width requirements.
91  const BlockConnection& connection, int gcw,
92  const FlameMasterReactor& reactor, int level);
93 
96 
99 
100  /// Precompute Boundary states for each domain.
101  ///
102  /// Subsequent calls to FillBoundary will use these computed boundary states.
103  ///
104  /// \param[in] plenum The higher dimensional patch hierarchy with geometry
105  /// information. States here will be conservatively averaged and projected
106  /// onto a one-dimesnional space.
107  ///
108  /// \param[in] tube The low dimensional tube data.
110  const PatchHierarchy& tube);
111 
112  /// Assuming that mf represents a MultiFab living in the higher dimensional
113  /// plenum simulation its ghost layer will be filled with data from the tube
114  /// simulation.
115  void FillBoundary(::amrex::MultiFab& mf,
116  const cutcell::GriddingAlgorithm& gridding, int level);
117 
118  void FillBoundary(::amrex::MultiFab& mf,
119  const cutcell::GriddingAlgorithm& gridding, int level,
120  Direction dir) {
121  if (dir == dir_) {
122  FillBoundary(mf, gridding, level);
123  }
124  }
125 
126  /// Assuming that mf represents a MultiFab living in the one dimensional tube
127  /// simulation its ghost layer will be filled with data from the plenum
128  /// simulation.
129  void FillBoundary(::amrex::MultiFab& mf, const GriddingAlgorithm& gridding,
130  int level);
131 
132  void FillBoundary(::amrex::MultiFab& mf, const GriddingAlgorithm& gridding,
133  int level, Direction dir) {
134  if (dir == dir_) {
135  FillBoundary(mf, gridding, level);
136  }
137  }
138 
139  const std::shared_ptr<PressureValve>& GetValve() const noexcept;
140 
141 private:
142  using logger_type = boost::log::sources::severity_channel_logger<
143  boost::log::trivial::severity_level>;
145 
146  std::shared_ptr<PressureValve> valve_{};
147 
150 
153 
154  std::unique_ptr<::amrex::FArrayBox> plenum_mirror_data_{};
155  std::unique_ptr<::amrex::FArrayBox> tube_ghost_data_{};
156 
157  std::unique_ptr<::amrex::FArrayBox> tube_mirror_data_{};
158  std::unique_ptr<::amrex::FArrayBox> plenum_ghost_data_{};
159 
161  int side_{};
162  int level_{};
163  int gcw_{};
164 };
165 
166 } // namespace fub::amrex
167 
168 #endif
A class mimicking the IdealGasMix / Reactor / ReactorNet interface of Cantera, but with FlameMaster c...
Definition: FlameMasterReactor.hpp:159
This class modifies and initializes a PatchLevel in a PatchHierarchy.
Definition: AMReX/GriddingAlgorithm.hpp:60
Definition: MultiBlockBoundary.hpp:64
std::shared_ptr< PressureValve > valve_
Definition: MultiBlockBoundary.hpp:146
MultiBlockBoundary(const MultiBlockGriddingAlgorithm &gridding, const BlockConnection &connection, int gcw, const FlameMasterReactor &reactor, int level)
Constructs coupled boundary states by pre computing mirror and ghost states for each of the specified...
int level_
Definition: MultiBlockBoundary.hpp:162
int gcw_
Definition: MultiBlockBoundary.hpp:163
MultiBlockBoundary & operator=(const MultiBlockBoundary &other)
void ComputeBoundaryData(const cutcell::PatchHierarchy &plenum, const PatchHierarchy &tube)
Precompute Boundary states for each domain.
logger_type log_
Definition: MultiBlockBoundary.hpp:144
MultiBlockBoundary & operator=(MultiBlockBoundary &&other)=default
void FillBoundary(::amrex::MultiFab &mf, const cutcell::GriddingAlgorithm &gridding, int level)
Assuming that mf represents a MultiFab living in the higher dimensional plenum simulation its ghost l...
IdealGasMix< Plenum_Rank > plenum_equation_
Definition: MultiBlockBoundary.hpp:148
boost::log::sources::severity_channel_logger< boost::log::trivial::severity_level > logger_type
Definition: MultiBlockBoundary.hpp:143
MultiBlockBoundary(const std::string &name, const MultiBlockGriddingAlgorithm &gridding, const BlockConnection &connection, int gcw, const FlameMasterReactor &reactor, int level, std::shared_ptr< PressureValve > valve)
static constexpr int Tube_Rank
Definition: MultiBlockBoundary.hpp:67
void FillBoundary(::amrex::MultiFab &mf, const GriddingAlgorithm &gridding, int level, Direction dir)
Definition: MultiBlockBoundary.hpp:132
const std::shared_ptr< PressureValve > & GetValve() const noexcept
Direction dir_
Definition: MultiBlockBoundary.hpp:160
void FillBoundary(::amrex::MultiFab &mf, const GriddingAlgorithm &gridding, int level)
Assuming that mf represents a MultiFab living in the one dimensional tube simulation its ghost layer ...
MultiBlockBoundary(const std::string &name, const MultiBlockGriddingAlgorithm &gridding, const BlockConnection &connection, int gcw, const FlameMasterReactor &reactor, int level)
Constructs coupled boundary states by pre computing mirror and ghost states for each of the specified...
std::unique_ptr<::amrex::FArrayBox > plenum_mirror_data_
Definition: MultiBlockBoundary.hpp:154
MultiBlockBoundary(const MultiBlockBoundary &other)
IdealGasMix< Tube_Rank > tube_equation_
Definition: MultiBlockBoundary.hpp:149
::amrex::Box tube_mirror_box_
Definition: MultiBlockBoundary.hpp:152
int side_
Definition: MultiBlockBoundary.hpp:161
std::unique_ptr<::amrex::FArrayBox > tube_ghost_data_
Definition: MultiBlockBoundary.hpp:155
MultiBlockBoundary(MultiBlockBoundary &&other)=default
void FillBoundary(::amrex::MultiFab &mf, const cutcell::GriddingAlgorithm &gridding, int level, Direction dir)
Definition: MultiBlockBoundary.hpp:118
::amrex::Box plenum_mirror_box_
Definition: MultiBlockBoundary.hpp:151
std::unique_ptr<::amrex::FArrayBox > plenum_ghost_data_
Definition: MultiBlockBoundary.hpp:158
static constexpr int Plenum_Rank
Definition: MultiBlockBoundary.hpp:66
std::unique_ptr<::amrex::FArrayBox > tube_mirror_data_
Definition: MultiBlockBoundary.hpp:157
Definition: MultiBlockGriddingAlgorithm.hpp:39
The PatchHierarchy holds simulation data on multiple refinement levels.
Definition: AMReX/PatchHierarchy.hpp:156
This class modifies and initializes a cutcell::PatchLevel in a cutcell::PatchHierarchy.
Definition: AMReX/cutcell/GriddingAlgorithm.hpp:56
Definition: AMReX/cutcell/PatchHierarchy.hpp:139
The amrex namespace.
Definition: AverageState.hpp:33
std::decay_t< decltype(*std::declval< T >().GetGriddingAlgorithm())> GriddingAlgorithm
A template typedef to detect the member function.
Definition: Meta.hpp:56
Direction
This is a type safe type to denote a dimensional split direction.
Definition: Direction.hpp:30
IndexBox< Rank > Box(const BasicView< State, Layout, Rank > &view)
Definition: State.hpp:486
Definition: MultiBlockBoundary.hpp:54
Direction direction
Definition: MultiBlockBoundary.hpp:57
BlockEntry tube
Definition: MultiBlockBoundary.hpp:55
int side
Definition: MultiBlockBoundary.hpp:58
BlockEntry plenum
Definition: MultiBlockBoundary.hpp:56
int ghost_cell_width
Definition: MultiBlockBoundary.hpp:59
Definition: MultiBlockBoundary.hpp:49
std::size_t id
Definition: MultiBlockBoundary.hpp:50
::amrex::Box mirror_box
Definition: MultiBlockBoundary.hpp:51
Definition: PressureValveBoundary.hpp:76