SubcellOptions.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <limits>
7 #include <string>
8 
9 #include "Options/Options.hpp"
10 #include "Utilities/TMPL.hpp"
11 
12 /// \cond
13 namespace PUP {
14 class er;
15 } // namespace PUP
16 /// \endcond
17 
18 namespace evolution::dg::subcell {
19 /*!
20  * \brief Holds the system-agnostic subcell parameters, such as numbers
21  * controlling when to switch between DG and subcell.
22  */
24  public:
25  struct InitialData {
26  static constexpr Options::String help =
27  "Parameters only used when setting up initial data.";
28  };
29 
30  /// The \f$\delta_0\f$ parameter in the relaxed discrete maximum principle
31  /// troubled-cell indicator when applied to the initial data
33  static std::string name() noexcept { return "RdmpDelta0"; }
34  static constexpr Options::String help{"Absolute jump tolerance parameter."};
35  using type = double;
36  static type lower_bound() noexcept { return 0.0; }
37  using group = InitialData;
38  };
39  /// The \f$\epsilon\f$ parameter in the relaxed discrete maximum principle
40  /// troubled-cell indicator when applied to the initial data
42  static std::string name() noexcept { return "RdmpEpsilon"; }
43  static constexpr Options::String help{
44  "The jump-dependent relaxation constant."};
45  using type = double;
46  static type lower_bound() noexcept { return 0.0; }
47  static type upper_bound() noexcept { return 1.0; }
48  using group = InitialData;
49  };
50  /// The exponent \f$\alpha\f$ passed to the Persson troubled-cell indicator
51  /// when applied to the initial data.
53  static std::string name() noexcept { return "PerssonExponent"; }
54  static constexpr Options::String help{
55  "The exponent at which the error should decrease with N."};
56  using type = double;
57  static constexpr type lower_bound() noexcept { return 1.0; }
58  static constexpr type upper_bound() noexcept { return 10.0; }
59  using group = InitialData;
60  };
61 
62  /// The \f$\delta_0\f$ parameter in the relaxed discrete maximum principle
63  /// troubled-cell indicator
64  struct RdmpDelta0 {
65  static std::string name() noexcept { return "RdmpDelta0"; }
66  static constexpr Options::String help{"Absolute jump tolerance parameter."};
67  using type = double;
68  static type lower_bound() noexcept { return 0.0; }
69  };
70  /// The \f$\epsilon\f$ parameter in the relaxed discrete maximum principle
71  /// troubled-cell indicator
72  struct RdmpEpsilon {
73  static std::string name() noexcept { return "RdmpEpsilon"; }
74  static constexpr Options::String help{
75  "The jump-dependent relaxation constant."};
76  using type = double;
77  static type lower_bound() noexcept { return 0.0; }
78  static type upper_bound() noexcept { return 1.0; }
79  };
80  /// The exponent \f$\alpha\f$ passed to the Persson troubled-cell indicator
81  struct PerssonExponent {
82  static std::string name() noexcept { return "PerssonExponent"; }
83  static constexpr Options::String help{
84  "The exponent at which the error should decrease with N."};
85  using type = double;
86  static constexpr type lower_bound() noexcept { return 1.0; }
87  static constexpr type upper_bound() noexcept { return 10.0; }
88  };
89  /// If true, then we always use the subcell method, not DG.
91  static constexpr Options::String help{
92  "If true, then always use the subcell method (e.g. finite-difference) "
93  "instead of DG."};
94  using type = bool;
95  };
96 
97  using options =
101 
102  static constexpr Options::String help{
103  "System-agnostic options for the DG-subcell method."};
104 
105  SubcellOptions() = default;
106  SubcellOptions(double initial_data_rdmp_delta0,
107  double initial_data_rdmp_epsilon, double rdmp_delta0,
108  double rdmp_epsilon, double initial_data_persson_exponent,
109  double persson_exponent, bool always_use_subcells) noexcept;
110 
111  void pup(PUP::er& p) noexcept;
112 
113  double initial_data_rdmp_delta0() const noexcept {
114  return initial_data_rdmp_delta0_;
115  }
116 
117  double initial_data_rdmp_epsilon() const noexcept {
118  return initial_data_rdmp_epsilon_;
119  }
120 
121  double rdmp_delta0() const noexcept { return rdmp_delta0_; }
122 
123  double rdmp_epsilon() const noexcept { return rdmp_epsilon_; }
124 
125  double initial_data_persson_exponent() const noexcept {
126  return initial_data_persson_exponent_;
127  }
128 
129  double persson_exponent() const noexcept { return persson_exponent_; }
130 
131  bool always_use_subcells() const noexcept { return always_use_subcells_; }
132 
133  private:
134  double initial_data_rdmp_delta0_ =
136  double initial_data_rdmp_epsilon_ =
138  double rdmp_delta0_ = std::numeric_limits<double>::signaling_NaN();
139  double rdmp_epsilon_ = std::numeric_limits<double>::signaling_NaN();
140  double initial_data_persson_exponent_ =
142  double persson_exponent_ = std::numeric_limits<double>::signaling_NaN();
143  bool always_use_subcells_ = false;
144 };
145 
146 bool operator==(const SubcellOptions& lhs, const SubcellOptions& rhs) noexcept;
147 
148 bool operator!=(const SubcellOptions& lhs, const SubcellOptions& rhs) noexcept;
149 } // namespace evolution::dg::subcell
evolution::dg::subcell::SubcellOptions::InitialDataRdmpDelta0
The parameter in the relaxed discrete maximum principle troubled-cell indicator when applied to the ...
Definition: SubcellOptions.hpp:32
std::string
evolution::dg::subcell::SubcellOptions::AlwaysUseSubcells
If true, then we always use the subcell method, not DG.
Definition: SubcellOptions.hpp:90
std::rel_ops::operator!=
T operator!=(T... args)
Options.hpp
evolution::dg::subcell::SubcellOptions::InitialDataPerssonExponent
The exponent passed to the Persson troubled-cell indicator when applied to the initial data.
Definition: SubcellOptions.hpp:52
evolution::dg::subcell::SubcellOptions::PerssonExponent
The exponent passed to the Persson troubled-cell indicator.
Definition: SubcellOptions.hpp:81
evolution::dg::subcell::SubcellOptions::RdmpEpsilon
The parameter in the relaxed discrete maximum principle troubled-cell indicator.
Definition: SubcellOptions.hpp:72
evolution::dg::subcell::SubcellOptions::InitialDataRdmpEpsilon
The parameter in the relaxed discrete maximum principle troubled-cell indicator when applied to the ...
Definition: SubcellOptions.hpp:41
evolution::dg::subcell::SubcellOptions::InitialData
Definition: SubcellOptions.hpp:25
evolution::dg::subcell::SubcellOptions
Holds the system-agnostic subcell parameters, such as numbers controlling when to switch between DG a...
Definition: SubcellOptions.hpp:23
std::numeric_limits::signaling_NaN
T signaling_NaN(T... args)
evolution::dg::subcell
Implementation of a generic finite volume/conservative finite difference subcell limiter.
Definition: Actions.hpp:6
limits
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
evolution::dg::subcell::SubcellOptions::RdmpDelta0
The parameter in the relaxed discrete maximum principle troubled-cell indicator.
Definition: SubcellOptions.hpp:64
TMPL.hpp
string