SpECTRE Documentation Coverage Report
Current view: top level - Time/StepChoosers - Random.hpp Hit Total Coverage
Commit: 1f2210958b4f38fdc0400907ee7c6d5af5111418 Lines: 3 24 12.5 %
Date: 2025-12-05 05:03:31
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 <pup.h>
       9             : 
      10             : #include "Options/Context.hpp"
      11             : #include "Options/String.hpp"
      12             : #include "Time/StepChoosers/StepChooser.hpp"
      13             : #include "Time/TimeStepRequest.hpp"
      14             : #include "Utilities/Serialization/CharmPupable.hpp"
      15             : #include "Utilities/TMPL.hpp"
      16             : 
      17             : /// \cond
      18             : template <size_t VolumeDim>
      19             : class Element;
      20             : class TimeStepId;
      21             : namespace Tags {
      22             : struct TimeStepId;
      23             : }  // namespace Tags
      24             : namespace domain::Tags {
      25             : template <size_t VolumeDim>
      26             : struct Element;
      27             : }  // namespace domain::Tags
      28             : /// \endcond
      29             : 
      30             : namespace StepChoosers {
      31             : /// Changes the step size pseudo-randomly.  Values are distributed
      32             : /// uniformly in $\log(dt)$.  The current step is always accepted.
      33             : ///
      34             : /// \note This debugging StepChooser is not included in the
      35             : /// `standard_step_choosers` list, but can be added to the
      36             : /// `factory_creation` struct in the metavariables.
      37             : template <size_t VolumeDim>
      38           1 : class Random : public StepChooser<StepChooserUse::Slab>,
      39             :                public StepChooser<StepChooserUse::LtsStep> {
      40             :  public:
      41             :   /// \cond
      42             :   Random();
      43             :   explicit Random(CkMigrateMessage* /*unused*/);
      44             :   using PUP::able::register_constructor;
      45             :   WRAPPED_PUPable_decl_template(Random);  // NOLINT
      46             :   /// \endcond
      47             : 
      48           0 :   struct Minimum {
      49           0 :     using type = double;
      50           0 :     static constexpr Options::String help{"Minimum value to suggest"};
      51           0 :     static type lower_bound() { return 0.0; }
      52             :   };
      53             : 
      54           0 :   struct Maximum {
      55           0 :     using type = double;
      56           0 :     static constexpr Options::String help{"Maximum value to suggest"};
      57           0 :     static type lower_bound() { return 0.0; }
      58             :   };
      59             : 
      60           0 :   struct Seed {
      61           0 :     using type = size_t;
      62           0 :     static constexpr Options::String help{"RNG seed"};
      63             :   };
      64             : 
      65           0 :   static constexpr Options::String help =
      66             :       "Changes the step size pseudo-randomly.";
      67           0 :   using options = tmpl::list<Minimum, Maximum, Seed>;
      68             : 
      69           0 :   Random(double minimum, double maximum, size_t seed,
      70             :          const Options::Context& context = {});
      71             : 
      72           0 :   using argument_tags =
      73             :       tmpl::list<domain::Tags::Element<VolumeDim>, Tags::TimeStepId>;
      74             : 
      75           0 :   TimeStepRequest operator()(const Element<VolumeDim>& element,
      76             :                              const TimeStepId& time_step_id,
      77             :                              double last_step) const;
      78             : 
      79           1 :   bool uses_local_data() const override;
      80           1 :   bool can_be_delayed() const override;
      81             : 
      82             :   // NOLINTNEXTLINE(google-runtime-references)
      83           0 :   void pup(PUP::er& p) override;
      84             : 
      85             :  private:
      86           0 :   double minimum_ = std::numeric_limits<double>::signaling_NaN();
      87           0 :   double maximum_ = std::numeric_limits<double>::signaling_NaN();
      88           0 :   size_t seed_ = 0;
      89             : };
      90             : }  // namespace StepChoosers

Generated by: LCOV version 1.14