LCOV - code coverage report
Current view: top level - include/timesteppers - TimeSequenceStepperBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 329044 Lines: 2 3 66.7 %
Date: 2026-08-03 21:12:22 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #pragma once
      11             : 
      12             : #include "TimeStepper.h"
      13             : 
      14             : /**
      15             :  * Solves the PDEs at a sequence of given time points.
      16             :  * Adjusts the time sequence vector according to Transient start_time and end_time.
      17             :  */
      18             : class TimeSequenceStepperBase : public TimeStepper
      19             : {
      20             : public:
      21             :   static InputParameters validParams();
      22             : 
      23             :   TimeSequenceStepperBase(const InputParameters & parameters);
      24             : 
      25             :   void setupSequence(const std::vector<Real> & times);
      26             :   void updateSequence(const std::vector<Real> & times);
      27             : 
      28             :   // Clear the time sequence array, usually used when the time sequence needs to be updated during
      29             :   // the simulation
      30             :   void resetSequence();
      31             : 
      32             :   // Increase the current step count by one
      33        1444 :   void increaseCurrentStep() { _current_step++; };
      34             : 
      35             :   /// Get the next time in the input time sequence
      36             :   virtual Real getNextTimeInSequence();
      37             : 
      38             :   /**
      39             :    * Return the first sequence time that has not yet been reached, if any
      40             :    *
      41             :    * The search does not advance the current sequence position.
      42             :    *
      43             :    * @return Whether a future sequence time was found and assigned to \p next_time
      44             :    */
      45             :   bool advanceToFutureTime(Real time, Real tolerance, Real & next_time);
      46             : 
      47           0 :   virtual void init() override {}
      48             :   virtual void acceptStep() override;
      49             : 
      50             : protected:
      51             :   virtual Real computeInitialDT() override;
      52             :   virtual Real computeDT() override;
      53             : 
      54             :   /**
      55             :    * Re-read a time sequence source that can change during the simulation
      56             :    *
      57             :    * This hook is called before the stored sequence is accessed. The default implementation is a
      58             :    * no-op for fixed sequences. Derived classes with dynamic sources should retrieve the current
      59             :    * time points and pass them to updateSequence(), which rebuilds the canonical sequence and
      60             :    * synchronizes the current step.
      61             :    */
      62        4236 :   virtual void refreshSequence() {}
      63             : 
      64             :   /// Build the canonical time sequence for the current start and end times
      65             :   std::vector<Real> buildSequence(const std::vector<Real> & times) const;
      66             : 
      67             :   /// Find the first sequence time greater than \p time by more than \p tolerance
      68             :   std::vector<Real>::const_iterator findFirstFutureTime(Real time, Real tolerance) const;
      69             : 
      70             :   /**
      71             :    * Set the current sequence position from \p time
      72             :    *
      73             :    * `_current_step` is the cursor into `_time_sequence`: it indexes the last sequence time
      74             :    * considered reached. Sequence times less than or equal to \p time plus \p tolerance are treated
      75             :    * as reached, so `_current_step + 1` identifies the next future time when one exists.
      76             :    */
      77             :   void synchronizeCurrentStep(Real time, Real tolerance);
      78             : 
      79             :   /// Whether to use the final dt past the last t in sequence
      80             :   const bool _use_last_dt_after_last_t;
      81             : 
      82             :   /// the step that the time stepper is currently at
      83             :   unsigned int & _current_step;
      84             : 
      85             :   /// stores the sequence of time points
      86             :   std::vector<Real> & _time_sequence;
      87             : 
      88             :   /// Whether to use the last t in sequence as Executioner end_time
      89             :   const bool _set_end_time;
      90             : };

Generated by: LCOV version 1.14