forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimeStepper.h
150 lines (123 loc) · 3.57 KB
/
TimeStepper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#pragma once
#include "MooseObject.h"
#include "Restartable.h"
#include "ScalarCoupleable.h"
class TimeStepper;
class FEProblemBase;
class Transient;
template <>
InputParameters validParams<TimeStepper>();
/**
* Base class for time stepping
*/
class TimeStepper : public MooseObject, public Restartable, public ScalarCoupleable
{
public:
TimeStepper(const InputParameters & parameters);
virtual ~TimeStepper();
/**
* Initialize the time stepper. Called at the very beginning of Executioner::execute()
*/
virtual void init();
virtual void preExecute();
virtual void preSolve() {}
virtual void postSolve() {}
virtual void postExecute() {}
virtual void preStep() {}
virtual void postStep() {}
/**
* Called before a new step is started.
* This is when the actual computation of the current DT will be done.
* Because of that this MUST be called only once per step!
*
* After calling this function use getCurrentDT() to get the DT
* that was computed.
*/
void computeStep();
/**
* Called after computeStep() is called.
* @return true if any type of sync point was hit, false otherwise
*/
virtual bool constrainStep(Real & dt);
/**
* Take a time step
*/
virtual void step();
/**
* This gets called when time step is accepted
*/
virtual void acceptStep();
/**
* This gets called when time step is rejected
*/
virtual void rejectStep();
/**
* If the time step converged
* @return true if converged, otherwise false
*/
virtual bool converged() const;
/**
* Get the current_dt
*/
Real getCurrentDT() { return _current_dt; }
virtual void forceTimeStep(Real dt);
///@{
/**
* Add a sync time
* \todo {Remove after old output system is removed; sync time are handled by OutputWarehouse}
*/
void addSyncTime(Real sync_time);
void addSyncTime(const std::set<Real> & times);
///@}
protected:
/**
* Called to compute _current_dt for the first timestep.
* Note that this does not return.
* The TimeStepper's job here is to fill in _current_dt.
*/
virtual Real computeInitialDT() = 0;
/**
* Called to compute _current_dt for a normal step.
* Note that this does not return.
* The TimeStepper's job here is to fill in _current_dt.
*/
virtual Real computeDT() = 0;
/**
* Called to compute _current_dt after a solve has failed.
* Note that this does not return.
* The TimeStepper's job here is to fill in _current_dt.
*/
virtual Real computeFailedDT();
FEProblemBase & _fe_problem;
/// Reference to transient executioner
Transient & _executioner;
/// Values from executioner
Real & _time;
Real & _time_old;
int & _t_step;
Real & _dt;
Real & _dt_min;
Real & _dt_max;
Real & _end_time;
std::set<Real> & _sync_times;
Real & _timestep_tolerance;
///should detailed diagnostic output be printed
const bool & _verbose;
/// Whether or not the previous solve converged.
bool _converged;
/// If true then the next dt will be computed by computeInitialDT()
bool _reset_dt;
/// True if dt has been reset
bool _has_reset_dt;
private:
/// 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.
Real & _current_dt;
};