SpECTRE Documentation Coverage Report
Current view: top level - Time/StepChoosers - LimitIncrease.hpp Hit Total Coverage
Commit: f23e75c235cae5144b8ac7ce01280be5b8cd2c8a Lines: 3 15 20.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/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             : namespace StepChoosers {
      18             : /// Limits step increase to a constant ratio.
      19             : template <typename StepChooserUse>
      20           1 : class LimitIncrease : public StepChooser<StepChooserUse> {
      21             :  public:
      22             :   /// \cond
      23             :   LimitIncrease() = default;
      24             :   explicit LimitIncrease(CkMigrateMessage* /*unused*/) {}
      25             :   using PUP::able::register_constructor;
      26             :   WRAPPED_PUPable_decl_template(LimitIncrease);  // NOLINT
      27             :   /// \endcond
      28             : 
      29           0 :   struct Factor {
      30           0 :     using type = double;
      31           0 :     static constexpr Options::String help{"Factor to allow increase by"};
      32           0 :     static type lower_bound() { return 1.0; }
      33             :   };
      34             : 
      35           0 :   static constexpr Options::String help{
      36             :       "Limits step increase to a constant ratio."};
      37           0 :   using options = tmpl::list<Factor>;
      38             : 
      39           0 :   explicit LimitIncrease(const double factor) : factor_(factor) {}
      40             : 
      41           0 :   using argument_tags = tmpl::list<>;
      42             : 
      43           0 :   std::pair<TimeStepRequest, bool> operator()(const double last_step) const {
      44             :     return {{.size = last_step * factor_}, true};
      45             :   }
      46             : 
      47           1 :   bool uses_local_data() const override { return false; }
      48           1 :   bool can_be_delayed() const override { return true; }
      49             : 
      50             :   // NOLINTNEXTLINE(google-runtime-references)
      51           0 :   void pup(PUP::er& p) override { p | factor_; }
      52             : 
      53             :  private:
      54           0 :   double factor_ = std::numeric_limits<double>::signaling_NaN();
      55             : };
      56             : 
      57             : /// \cond
      58             : template <typename StepChooserUse>
      59             : PUP::able::PUP_ID LimitIncrease<StepChooserUse>::my_PUP_ID = 0;  // NOLINT
      60             : /// \endcond
      61             : }  // namespace StepChoosers

Generated by: LCOV version 1.14