SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/GrMhd/ValenciaDivClean/Subcell - TciOptions.hpp Hit Total Coverage
Commit: e93d8312de4f331d36b5aa00ea83a894e26dfcb7 Lines: 6 41 14.6 %
Date: 2021-09-24 22:40:29
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <cstddef>
       7             : #include <limits>
       8             : #include <optional>
       9             : 
      10             : #include "DataStructures/DataBox/Tag.hpp"
      11             : #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags/OptionsGroup.hpp"
      12             : #include "Options/Auto.hpp"
      13             : #include "Options/Options.hpp"
      14             : #include "Utilities/TMPL.hpp"
      15             : 
      16             : /// \cond
      17             : namespace PUP {
      18             : class er;
      19             : }  // namespace PUP
      20             : /// \endcond
      21             : 
      22             : namespace grmhd::ValenciaDivClean::subcell {
      23             : /*!
      24             :  * \brief Class holding options using by the GRMHD-specific parts of the
      25             :  * troubled-cell indicator.
      26             :  */
      27           1 : struct TciOptions {
      28             :  private:
      29           0 :   struct DoNotCheckMagneticField {};
      30             : 
      31             :  public:
      32             :   /// \brief Minimum value of rest-mass density times Lorentz factor before we
      33             :   /// switch to subcell. Used to identify places where the density has suddenly
      34             :   /// become negative
      35           1 :   struct MinimumValueOfD {
      36           0 :     using type = double;
      37           0 :     static type lower_bound() noexcept { return 0.0; }
      38           0 :     static constexpr Options::String help = {
      39             :         "Minimum value of rest-mass density times Lorentz factor before we "
      40             :         "switch to subcell."};
      41             :   };
      42             :   /// \brief Minimum value of \f$\tilde{\tau}\f$ before we switch to subcell.
      43             :   /// Used to identify places where the energy has suddenly become negative
      44           1 :   struct MinimumValueOfTildeTau {
      45           0 :     using type = double;
      46           0 :     static type lower_bound() noexcept { return 0.0; }
      47           0 :     static constexpr Options::String help = {
      48             :         "Minimum value of tilde tau before we switch to subcell."};
      49             :   };
      50             :   /// \brief The density cutoff where if the maximum value of the density in the
      51             :   /// DG element is below this value we skip primitive recovery and treat the
      52             :   /// cell as atmosphere.
      53           1 :   struct AtmosphereDensity {
      54           0 :     using type = double;
      55           0 :     static type lower_bound() noexcept { return 0.0; }
      56           0 :     static constexpr Options::String help = {
      57             :         "The density cutoff where if the maximum value of the density in the "
      58             :         "DG element is below this value we skip primitive recovery and treat "
      59             :         "the cell as atmosphere."};
      60             :   };
      61             :   /// \brief Safety factor \f$\epsilon_B\f$.
      62             :   ///
      63             :   /// See the documentation for TciOnDgGrid for details on what this parameter
      64             :   /// controls.
      65           1 :   struct SafetyFactorForB {
      66           0 :     using type = double;
      67           0 :     static type lower_bound() noexcept { return 0.0; }
      68           0 :     static constexpr Options::String help = {
      69             :         "Safety factor for magnetic field bound."};
      70             :   };
      71             :   /// \brief The cutoff where if the maximum of the magnetic field in an element
      72             :   /// is below this value we do not apply the Persson TCI to the magnetic field.
      73           1 :   struct MagneticFieldCutoff {
      74           0 :     using type = Options::Auto<double, DoNotCheckMagneticField>;
      75           0 :     static constexpr Options::String help = {
      76             :         "The cutoff where if the maximum of the magnetic field in an element "
      77             :         "is below this value we do not apply the Persson TCI to the magnetic "
      78             :         "field. This is to avoid switching to subcell in regions where there's "
      79             :         "no magnetic field.\n"
      80             :         "To disable the magnetic field check, set to "
      81             :         "'DoNotCheckMagneticField'."};
      82             :   };
      83             : 
      84           0 :   using options =
      85             :       tmpl::list<MinimumValueOfD, MinimumValueOfTildeTau, AtmosphereDensity,
      86             :                  SafetyFactorForB, MagneticFieldCutoff>;
      87           0 :   static constexpr Options::String help = {
      88             :       "Options for the troubled-cell indicator."};
      89             : 
      90             :   // NOLINTNEXTLINE(google-runtime-references)
      91           0 :   void pup(PUP::er& p) noexcept;
      92             : 
      93           0 :   double minimum_rest_mass_density_times_lorentz_factor{
      94             :       std::numeric_limits<double>::signaling_NaN()};
      95           0 :   double minimum_tilde_tau{std::numeric_limits<double>::signaling_NaN()};
      96           0 :   double atmosphere_density{std::numeric_limits<double>::signaling_NaN()};
      97           0 :   double safety_factor_for_magnetic_field{
      98             :       std::numeric_limits<double>::signaling_NaN()};
      99             :   // The signaling_NaN default is chosen so that users hit an error/FPE if the
     100             :   // cutoff is not specified, rather than silently defaulting to ignoring the
     101             :   // magnetic field.
     102           0 :   std::optional<double> magnetic_field_cutoff{
     103             :       std::numeric_limits<double>::signaling_NaN()};
     104             : };
     105             : 
     106           0 : namespace OptionTags {
     107           0 : struct TciOptions {
     108           0 :   using type = subcell::TciOptions;
     109           0 :   static constexpr Options::String help = "GRMHD-specific options for the TCI.";
     110           0 :   using group = ::dg::OptionTags::DiscontinuousGalerkinGroup;
     111             : };
     112             : }  // namespace OptionTags
     113             : 
     114           0 : namespace Tags {
     115           0 : struct TciOptions : db::SimpleTag {
     116           0 :   using type = subcell::TciOptions;
     117             : 
     118           0 :   using option_tags = tmpl::list<OptionTags::TciOptions>;
     119           0 :   static constexpr bool pass_metavariables = false;
     120           0 :   static type create_from_options(const type& tci_options) noexcept {
     121             :     return tci_options;
     122             :   }
     123             : };
     124             : }  // namespace Tags
     125             : }  // namespace grmhd::ValenciaDivClean::subcell

Generated by: LCOV version 1.14