Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
PressureValveBoundary.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_BOUNDARY_CONDITION_PRESSURE_VALVE_HPP
22 #define FUB_AMREX_BOUNDARY_CONDITION_PRESSURE_VALVE_HPP
23 
28 
29 #include "fub/Duration.hpp"
30 
31 #include <boost/serialization/access.hpp>
32 
33 #include "fub/ext/Log.hpp"
35 
36 namespace fub::amrex {
37 /// \ingroup BoundaryCondition
38 ///
40  PressureValveOptions() = default;
42 
43  void Print(SeverityLogger& log);
44 
45  std::string prefix{"PressureValve"};
46  double equivalence_ratio{1.0};
47  double outer_pressure{1.5 * 101325.0};
48  double outer_temperature{300.0};
50  double pressure_value_which_closes_boundary{3.0 * 101325.0};
55  double valve_efficiency{1.0};
59 };
60 
61 } // namespace fub::amrex
62 
63 namespace boost::serialization {
64 
65 template <typename Archive>
66 void serialize(Archive& ar, ::fub::amrex::PressureValveOptions& opts,
67  unsigned int version);
68 
69 }
70 
71 namespace fub::amrex {
72 
74 /// \ingroup BoundaryCondition
75 ///
76 struct PressureValve {
78  Duration last_closed{std::numeric_limits<double>::lowest()};
79  Duration last_fuel{std::numeric_limits<double>::lowest()};
80 };
81 
82 /// \ingroup BoundaryCondition
83 ///
85 public:
87  PressureValveOptions options);
88 
90  const std::map<std::string, pybind11::object>& options);
91 
92  [[nodiscard]] const PressureValveOptions& GetOptions() const noexcept;
93 
94  void FillBoundary(::amrex::MultiFab& mf, const GriddingAlgorithm& gridding,
95  int level);
96 
97  void FillBoundary(::amrex::MultiFab& mf, const GriddingAlgorithm& gridding,
98  int level, Direction dir);
99 
100  [[nodiscard]] const std::shared_ptr<PressureValve>& GetSharedState() const
101  noexcept {
102  return shared_valve_;
103  }
104 
105 private:
108  std::shared_ptr<PressureValve> shared_valve_;
109 };
110 
111 } // namespace fub::amrex
112 
113 namespace boost::serialization {
114 
115 template <typename Archive>
116 void serialize(Archive& ar, ::fub::amrex::PressureValve& valve,
117  unsigned int /* version */) {
118  int state = static_cast<int>(valve.state);
119  ar& state;
120  valve.state = static_cast<::fub::amrex::PressureValveState>(state);
121  ar& valve.last_closed;
122  ar& valve.last_fuel;
123 }
124 
125 template <typename Archive>
126 void serialize(Archive& ar, ::fub::amrex::PressureValveOptions& opts,
127  unsigned int /* version */) {
128  ar& opts.open_at_interval;
129  ar& opts.offset;
130 }
131 
132 } // namespace boost::serialization
133 
134 #endif // FINITEVOLUMESOLVER_PRESSUREVALVE_HPP
This class modifies and initializes a PatchLevel in a PatchHierarchy.
Definition: AMReX/GriddingAlgorithm.hpp:60
Definition: PressureValveBoundary.hpp:84
std::shared_ptr< PressureValve > shared_valve_
Definition: PressureValveBoundary.hpp:108
void FillBoundary(::amrex::MultiFab &mf, const GriddingAlgorithm &gridding, int level)
PressureValveBoundary(const IdealGasMix< 1 > &equation, PressureValveOptions options)
PressureValveOptions options_
Definition: PressureValveBoundary.hpp:106
const std::shared_ptr< PressureValve > & GetSharedState() const noexcept
Definition: PressureValveBoundary.hpp:100
PressureValveBoundary(const IdealGasMix< 1 > &equation, const std::map< std::string, pybind11::object > &options)
IdealGasMix< 1 > equation_
Definition: PressureValveBoundary.hpp:107
const PressureValveOptions & GetOptions() const noexcept
The amrex namespace.
Definition: AverageState.hpp:33
PressureValveState
Definition: PressureValveBoundary.hpp:73
std::chrono::duration< double > Duration
Definition: Duration.hpp:31
boost::log::sources::severity_logger< boost::log::trivial::severity_level > SeverityLogger
Definition: Log.hpp:46
Direction
This is a type safe type to denote a dimensional split direction.
Definition: Direction.hpp:30
std::map< std::string, pybind11::object > ProgramOptions
Definition: ProgramOptions.hpp:40
Definition: boundary_condition/MassflowBoundary.hpp:33
Definition: PressureValveBoundary.hpp:39
double fuel_measurement_position
Definition: PressureValveBoundary.hpp:53
Duration open_at_interval
Definition: PressureValveBoundary.hpp:56
PressureValveOptions(const ProgramOptions &vm)
double outer_pressure
Definition: PressureValveBoundary.hpp:47
void Print(SeverityLogger &log)
Duration offset
Definition: PressureValveBoundary.hpp:57
std::string prefix
Definition: PressureValveBoundary.hpp:45
double outer_temperature
Definition: PressureValveBoundary.hpp:48
double equivalence_ratio
Definition: PressureValveBoundary.hpp:46
double fuel_measurement_criterium
Definition: PressureValveBoundary.hpp:54
double oxygen_measurement_criterium
Definition: PressureValveBoundary.hpp:52
MassflowBoundaryOptions massflow_boundary
Definition: PressureValveBoundary.hpp:58
double pressure_value_which_opens_boundary
Definition: PressureValveBoundary.hpp:49
double valve_efficiency
Definition: PressureValveBoundary.hpp:55
double oxygen_measurement_position
Definition: PressureValveBoundary.hpp:51
double pressure_value_which_closes_boundary
Definition: PressureValveBoundary.hpp:50
Definition: PressureValveBoundary.hpp:76
Duration last_fuel
Definition: PressureValveBoundary.hpp:79
Duration last_closed
Definition: PressureValveBoundary.hpp:78
PressureValveState state
Definition: PressureValveBoundary.hpp:77