LCOV - code coverage report
Current view: top level - include/timesteppers - TimeStepper.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 6 6 100.0 %
Date: 2025-07-17 01:28:37 Functions: 6 6 100.0 %
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 "MooseObject.h"
      13             : #include "Restartable.h"
      14             : #include "ScalarCoupleable.h"
      15             : 
      16             : class FEProblemBase;
      17             : class TransientBase;
      18             : 
      19             : /**
      20             :  * Base class for time stepping
      21             :  */
      22             : class TimeStepper : public MooseObject, public Restartable, public ScalarCoupleable
      23             : {
      24             : public:
      25             :   static InputParameters validParams();
      26             : 
      27             :   TimeStepper(const InputParameters & parameters);
      28             :   virtual ~TimeStepper();
      29             : 
      30             :   /**
      31             :    * Initialize the time stepper. Called at the very beginning of Executioner::execute()
      32             :    */
      33             :   virtual void init();
      34             : 
      35             :   virtual void preExecute();
      36      233512 :   virtual void preSolve() {}
      37      229006 :   virtual void postSolve() {}
      38       26579 :   virtual void postExecute() {}
      39      169875 :   virtual void preStep() {}
      40      189744 :   virtual void postStep() {}
      41             : 
      42             :   /**
      43             :    * Called before a new step is started.
      44             :    * This is when the actual computation of the current DT will be done.
      45             :    * Because of that this MUST be called only once per step!
      46             :    *
      47             :    * After calling this function use getCurrentDT() to get the DT
      48             :    * that was computed.
      49             :    */
      50             :   void computeStep();
      51             : 
      52             :   /**
      53             :    * Called after computeStep() is called.
      54             :    * @return true if any type of sync point was hit, false otherwise
      55             :    */
      56             :   virtual bool constrainStep(Real & dt);
      57             : 
      58             :   /**
      59             :    * Take a time step
      60             :    */
      61             :   virtual void step();
      62             : 
      63             :   /**
      64             :    * This gets called when time step is accepted
      65             :    */
      66             :   virtual void acceptStep();
      67             : 
      68             :   /**
      69             :    * This gets called when time step is rejected
      70             :    */
      71             :   virtual void rejectStep();
      72             : 
      73             :   /// Gets the number of failures and returns them.
      74             :   unsigned int numFailures() const;
      75             : 
      76             :   /**
      77             :    * If the time step converged
      78             :    * @return true if converged, otherwise false
      79             :    */
      80             :   virtual bool converged() const;
      81             : 
      82             :   /**
      83             :    * Get the current_dt
      84             :    */
      85      375601 :   Real getCurrentDT() { return _current_dt; }
      86             : 
      87             :   virtual void forceTimeStep(Real dt);
      88             : 
      89             :   /**
      90             :    * Set the number of time steps
      91             :    * @param num_steps number of time steps
      92             :    */
      93             :   virtual void forceNumSteps(const unsigned int num_steps);
      94             : 
      95             :   ///@{
      96             :   /**
      97             :    * Add a sync time
      98             :    * \todo {Remove after old output system is removed; sync time are handled by OutputWarehouse}
      99             :    */
     100             :   void addSyncTime(Real sync_time);
     101             :   void addSyncTime(const std::set<Real> & times);
     102             :   ///@}
     103             : 
     104             : protected:
     105             :   /**
     106             :    * Computes time step size for the initial time step
     107             :    */
     108             :   virtual Real computeInitialDT() = 0;
     109             : 
     110             :   /**
     111             :    * Computes time step size after the initial time step
     112             :    */
     113             :   virtual Real computeDT() = 0;
     114             : 
     115             :   /**
     116             :    * Computes time step size after a failed time step
     117             :    */
     118             :   virtual Real computeFailedDT();
     119             : 
     120             :   FEProblemBase & _fe_problem;
     121             :   /// Reference to transient executioner
     122             :   TransientBase & _executioner;
     123             : 
     124             :   /// Values from executioner
     125             :   Real & _time;
     126             :   Real & _time_old;
     127             :   int & _t_step;
     128             :   Real & _dt;
     129             :   Real & _dt_min;
     130             :   Real & _dt_max;
     131             :   Real & _end_time;
     132             :   std::set<Real> & _sync_times;
     133             : 
     134             :   Real & _timestep_tolerance;
     135             : 
     136             :   /// whether a detailed diagnostic output should be printed
     137             :   const bool & _verbose;
     138             : 
     139             :   /// Whether or not the previous solve converged.
     140             :   bool _converged;
     141             : 
     142             :   /// Cutback factor if a time step fails to converge
     143             :   const Real _cutback_factor_at_failure;
     144             : 
     145             :   /// If true then the next dt will be computed by computeInitialDT()
     146             :   bool _reset_dt;
     147             : 
     148             :   /// True if dt has been reset
     149             :   bool _has_reset_dt;
     150             : 
     151             :   /// Cumulative amount of steps that have failed
     152             :   unsigned int _failure_count;
     153             : 
     154             : private:
     155             :   /// Size of the current time step as computed by the Stepper.  Note that the actual dt that was taken might be smaller if the Executioner constrained it.
     156             :   Real & _current_dt;
     157             : };

Generated by: LCOV version 1.14