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

Generated by: LCOV version 1.14