SpECTRE Documentation Coverage Report
Current view: top level - Time/StepChoosers - Constant.hpp Hit Total Coverage
Commit: 1c32b58340e006addc79befb2cdaa7547247e09c Lines: 2 11 18.2 %
Date: 2024-04-19 07:30:15
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 <limits>
       7             : #include <pup.h>
       8             : #include <utility>
       9             : 
      10             : #include "Options/Options.hpp"
      11             : #include "Options/String.hpp"
      12             : #include "Time/StepChoosers/StepChooser.hpp"  // IWYU pragma: keep
      13             : #include "Utilities/ErrorHandling/Assert.hpp"
      14             : #include "Utilities/Serialization/CharmPupable.hpp"
      15             : #include "Utilities/TMPL.hpp"
      16             : 
      17             : namespace StepChoosers {
      18             : 
      19             : /// Suggests a constant step size.
      20             : template <typename StepChooserUse>
      21           1 : class Constant : public StepChooser<StepChooserUse> {
      22             :  public:
      23             :   /// \cond
      24             :   Constant() = default;
      25             :   explicit Constant(CkMigrateMessage* /*unused*/) {}
      26             :   using PUP::able::register_constructor;
      27             :   WRAPPED_PUPable_decl_template(Constant);  // NOLINT
      28             :   /// \endcond
      29             : 
      30           0 :   static constexpr Options::String help{"Suggests a constant step size."};
      31             : 
      32           0 :   explicit Constant(const double value) : value_(value) {
      33             :     ASSERT(value_ > 0., "Requested step magnitude should be positive.");
      34             :   }
      35             : 
      36           0 :   using argument_tags = tmpl::list<>;
      37             : 
      38           0 :   std::pair<double, bool> operator()(
      39             :       const double /*last_step_magnitude*/) const {
      40             :     return std::make_pair(value_, true);
      41             :   }
      42             : 
      43           1 :   bool uses_local_data() const override { return false; }
      44             : 
      45             :   // NOLINTNEXTLINE(google-runtime-references)
      46           0 :   void pup(PUP::er& p) override { p | value_; }
      47             : 
      48             :  private:
      49           0 :   double value_ = std::numeric_limits<double>::signaling_NaN();
      50             : };
      51             : 
      52             : /// \cond
      53             : template <typename StepChooserUse>
      54             : PUP::able::PUP_ID Constant<StepChooserUse>::my_PUP_ID = 0;  // NOLINT
      55             : /// \endcond
      56             : 
      57             : namespace Constant_detail {
      58             : double parse_options(const Options::Option& options);
      59             : }  // namespace Constant_detail
      60             : }  // namespace StepChoosers
      61             : 
      62             : template <typename StepChooserUse>
      63           0 : struct Options::create_from_yaml<
      64             :     StepChoosers::Constant<StepChooserUse>> {
      65             :   template <typename Metavariables>
      66           0 :   static StepChoosers::Constant<StepChooserUse> create(
      67             :       const Options::Option& options) {
      68             :     return StepChoosers::Constant<StepChooserUse>(
      69             :         StepChoosers::Constant_detail::parse_options(options));
      70             :   }
      71             : };

Generated by: LCOV version 1.14