SpECTRE Documentation Coverage Report
Current view: top level - Time/StepChoosers - PreventRapidIncrease.hpp Hit Total Coverage
Commit: 107e15b340886ae54549b1baa4bfc92e676f667e Lines: 4 11 36.4 %
Date: 2026-09-17 16:38:56
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 <pup.h>
       7             : 
       8             : #include "Options/String.hpp"
       9             : #include "Time/History.hpp"
      10             : #include "Time/StepChoosers/StepChooser.hpp"
      11             : #include "Time/TimeStepRequest.hpp"
      12             : #include "Utilities/Serialization/CharmPupable.hpp"
      13             : #include "Utilities/TMPL.hpp"
      14             : #include "Utilities/TypeTraits/IsA.hpp"
      15             : 
      16             : /// \cond
      17             : namespace Tags {
      18             : template <typename Tag>
      19             : struct HistoryEvolvedVariables;
      20             : }  // namespace Tags
      21             : /// \endcond
      22             : 
      23             : namespace StepChoosers {
      24             : namespace PreventRapidIncrease_detail {
      25             : template <typename T>
      26             : bool limit_from_history(const TimeSteppers::ConstUntypedHistory<T>& history,
      27             :                         double last_step);
      28             : }  // namespace PreventRapidIncrease_detail
      29             : /// Limits the time step to prevent multistep integrator instabilities.
      30             : ///
      31             : /// Avoids instabilities due to rapid increases in the step size by
      32             : /// preventing the step size from increasing if any step in the
      33             : /// time-stepper history increased.  If there have been recent step
      34             : /// size increases, the new size bound is the size of the most recent
      35             : /// step, otherwise no restriction is imposed.
      36             : /// @{
      37             : template <typename System,
      38             :           typename = tmpl::conditional_t<
      39             :               tt::is_a_v<tmpl::list, typename System::variables_tag>,
      40             :               typename System::variables_tag,
      41             :               tmpl::list<typename System::variables_tag>>>
      42           1 : class PreventRapidIncrease;
      43             : 
      44             : template <typename System, typename... VariablesTags>
      45           0 : class PreventRapidIncrease<System, tmpl::list<VariablesTags...>>
      46             :     : public StepChooser<StepChooserUse::Slab>,
      47             :       public StepChooser<StepChooserUse::LtsStep> {
      48             :  public:
      49             :   /// \cond
      50             :   PreventRapidIncrease() = default;
      51             :   explicit PreventRapidIncrease(CkMigrateMessage* /*unused*/) {}
      52             :   using PUP::able::register_constructor;
      53             :   WRAPPED_PUPable_decl_template(PreventRapidIncrease);  // NOLINT
      54             :   /// \endcond
      55             : 
      56           0 :   static constexpr Options::String help{
      57             :       "Limits the time step to prevent multistep integrator instabilities."};
      58           0 :   using options = tmpl::list<>;
      59             : 
      60           0 :   using argument_tags =
      61             :       tmpl::list<::Tags::HistoryEvolvedVariables<VariablesTags>...>;
      62             : 
      63           0 :   TimeStepRequest operator()(
      64             :       const ::TimeSteppers::History<typename VariablesTags::type>&... histories,
      65             :       const double last_step) const {
      66             :     if ((... or PreventRapidIncrease_detail::limit_from_history(
      67             :                     histories.untyped(), last_step))) {
      68             :       return {.size = last_step};
      69             :     } else {
      70             :       return {};
      71             :     }
      72             :   }
      73             : 
      74           1 :   bool uses_local_data() const override { return false; }
      75           1 :   bool can_be_delayed() const override { return true; }
      76           1 :   bool must_set_step_size() const override { return true; }
      77             : 
      78           0 :   void pup(PUP::er& p) override {
      79             :     StepChooser<StepChooserUse::Slab>::pup(p);
      80             :     StepChooser<StepChooserUse::LtsStep>::pup(p);
      81             :   }
      82             : };
      83             : /// @}
      84             : 
      85             : /// \cond
      86             : template <typename System, typename... VariablesTags>
      87             : PUP::able::PUP_ID PreventRapidIncrease<
      88             :     System, tmpl::list<VariablesTags...>>::my_PUP_ID =  // NOLINT
      89             :     0;
      90             : /// \endcond
      91             : }  // namespace StepChoosers

Generated by: LCOV version 1.14