https://mooseframework.inl.gov
TimeStepper.h
Go to the documentation of this file.
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 
22 class TimeStepper : public MooseObject, public Restartable, public ScalarCoupleable
23 {
24 public:
26 
28  virtual ~TimeStepper();
29 
33  virtual void init();
34 
35  virtual void preExecute();
36  virtual void preSolve() {}
37  virtual void postSolve() {}
38  virtual void postExecute() {}
39  virtual void preStep() {}
40  virtual void postStep() {}
41 
50  void computeStep();
51 
56  virtual bool constrainStep(Real & dt);
57 
61  virtual void step();
62 
66  virtual void acceptStep();
67 
71  virtual void rejectStep();
72 
74  unsigned int numFailures() const;
75 
80  virtual bool converged() const;
81 
86 
87  virtual void forceTimeStep(Real dt);
88 
93  virtual void forceNumSteps(const unsigned int num_steps);
94 
96 
100  void addSyncTime(Real sync_time);
101  void addSyncTime(const std::set<Real> & times);
103 
106  bool justFailedTimeStep() const { return _currently_restepping; }
107 
108 protected:
112  virtual Real computeInitialDT() = 0;
113 
117  virtual Real computeDT() = 0;
118 
122  virtual Real computeFailedDT();
123 
127 
131  int & _t_step;
136  std::set<Real> & _sync_times;
137 
139 
141  const bool & _verbose;
142 
145 
148 
150  bool _reset_dt;
151 
154 
157 
159  unsigned int _failure_count;
160 
161 private:
164 };
TransientBase & _executioner
Reference to transient executioner.
Definition: TimeStepper.h:126
static InputParameters validParams()
Definition: TimeStepper.C:16
Real & _timestep_tolerance
Definition: TimeStepper.h:138
virtual ~TimeStepper()
Definition: TimeStepper.C:63
virtual Real computeInitialDT()=0
Computes time step size for the initial time step.
virtual Real computeFailedDT()
Computes time step size after a failed time step.
Definition: TimeStepper.C:207
virtual void forceNumSteps(const unsigned int num_steps)
Set the number of time steps.
Definition: TimeStepper.C:226
A class for creating restricted objects.
Definition: Restartable.h:28
void computeStep()
Called before a new step is started.
Definition: TimeStepper.C:79
unsigned int numFailures() const
Gets the number of failures and returns them.
Definition: TimeStepper.C:195
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
virtual void preStep()
Definition: TimeStepper.h:39
Real & _time_old
Definition: TimeStepper.h:130
Base class for time stepping.
Definition: TimeStepper.h:22
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void preSolve()
Definition: TimeStepper.h:36
virtual void postExecute()
Definition: TimeStepper.h:38
virtual bool constrainStep(Real &dt)
Called after computeStep() is called.
Definition: TimeStepper.C:103
virtual bool converged() const
If the time step converged.
Definition: TimeStepper.C:201
const Real _cutback_factor_at_failure
Cutback factor if a time step fails to converge.
Definition: TimeStepper.h:147
Real & _current_dt
Size of the current time step as computed by the Stepper. Note that the actual dt that was taken migh...
Definition: TimeStepper.h:163
void addSyncTime(Real sync_time)
Add a sync time.
std::set< Real > & _sync_times
Definition: TimeStepper.h:136
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const bool & _verbose
whether a detailed diagnostic output should be printed
Definition: TimeStepper.h:141
FEProblemBase & _fe_problem
Definition: TimeStepper.h:124
virtual void acceptStep()
This gets called when time step is accepted.
Definition: TimeStepper.C:176
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
virtual Real computeDT()=0
Computes time step size after the initial time step.
TimeStepper(const InputParameters &parameters)
Definition: TimeStepper.C:35
bool _has_reset_dt
True if dt has been reset.
Definition: TimeStepper.h:153
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
Definition: TransientBase.h:27
virtual void forceTimeStep(Real dt)
Definition: TimeStepper.C:220
bool justFailedTimeStep() const
Whether we are currently solving a failed time step Note: you should first try to use the restartable...
Definition: TimeStepper.h:106
bool _converged
Whether or not the previous solve converged.
Definition: TimeStepper.h:144
Real & _end_time
Definition: TimeStepper.h:135
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void preExecute()
Definition: TimeStepper.C:71
virtual void rejectStep()
This gets called when time step is rejected.
Definition: TimeStepper.C:188
Real & _dt_min
Definition: TimeStepper.h:133
Interface for objects that needs scalar coupling capabilities.
virtual void postSolve()
Definition: TimeStepper.h:37
virtual void step()
Take a time step.
Definition: TimeStepper.C:167
int & _t_step
Definition: TimeStepper.h:131
virtual void postStep()
Definition: TimeStepper.h:40
bool _currently_restepping
If we are currently solving a failed step.
Definition: TimeStepper.h:156
bool _reset_dt
If true then the next dt will be computed by computeInitialDT()
Definition: TimeStepper.h:150
unsigned int _failure_count
Cumulative amount of steps that have failed.
Definition: TimeStepper.h:159
Real & _dt_max
Definition: TimeStepper.h:134
virtual void init()
Initialize the time stepper.
Definition: TimeStepper.C:66
Real & _dt
Definition: TimeStepper.h:132
Real getCurrentDT()
Get the current_dt.
Definition: TimeStepper.h:85
Real & _time
Values from executioner.
Definition: TimeStepper.h:129