forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConstantDT.C
53 lines (47 loc) · 1.83 KB
/
ConstantDT.C
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
/****************************************************************/
/* DO NOT MODIFY THIS HEADER */
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* (c) 2010 Battelle Energy Alliance, LLC */
/* ALL RIGHTS RESERVED */
/* */
/* Prepared by Battelle Energy Alliance, LLC */
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/
#include "ConstantDT.h"
#include "FEProblem.h"
#include "Transient.h"
namespace
{
const std::string dt_name = "dt";
const std::string growth_factor_name = "growth_factor";
}
template<>
InputParameters validParams<ConstantDT>()
{
InputParameters params = validParams<TimeStepper>();
params.addRequiredParam<Real>( dt_name, "Size of the time step" );
params.addRangeCheckedParam<Real>( growth_factor_name, 2, growth_factor_name + ">=1",
"Maximum ratio of new to previous timestep sizes following a step that required the time"
" step to be cut due to a failed solve." );
return params;
}
ConstantDT::ConstantDT(const std::string & name, InputParameters parameters) :
TimeStepper( name, parameters ),
_constant_dt( getParam<Real>( dt_name ) ),
_growth_factor( getParam<Real>( growth_factor_name ) )
{
}
Real
ConstantDT::computeInitialDT()
{
return _constant_dt;
}
Real
ConstantDT::computeDT()
{
return std::min( _constant_dt, _growth_factor * getCurrentDT() );
}