Go to the documentation of this file.
27 #include "libmesh/implicit_system.h"
28 #include "libmesh/nonlinear_implicit_system.h"
29 #include "libmesh/transient_system.h"
30 #include "libmesh/numeric_vector.h"
49 std::vector<Real> sync_times(1);
50 sync_times[0] = -std::numeric_limits<Real>::max();
57 MooseEnum schemes(
"implicit-euler explicit-euler crank-nicolson bdf2 explicit-midpoint dirk "
58 "explicit-tvd-rk-2 newmark-beta",
61 params.
addParam<Real>(
"start_time", 0.0,
"The start time of the simulation");
62 params.
addParam<Real>(
"end_time", 1.0e30,
"The end time of the simulation");
63 params.
addParam<Real>(
"dt", 1.,
"The timestep size between solves");
64 params.
addParam<Real>(
"dtmin", 2.0e-14,
"The minimum timestep size in an adaptive run");
65 params.
addParam<Real>(
"dtmax", 1.0e30,
"The maximum timestep size in an adaptive run");
67 "reset_dt",
false,
"Use when restarting a calculation to force a change in dt.");
68 params.
addParam<
unsigned int>(
"num_steps",
69 std::numeric_limits<unsigned int>::max(),
70 "The number of timesteps in a transient run");
71 params.
addParam<
int>(
"n_startup_steps", 0,
"The number of timesteps during startup");
75 "Whether or not to check for steady state conditions",
76 "Use steady_state_detection instead");
79 "Whenever the relative residual changes by less "
80 "than this the solution will be considered to be "
82 "Use steady_state_tolerance instead");
86 "Minimum amount of time to run before checking for steady state conditions.",
87 "Use steady_state_start_time instead");
90 "steady_state_detection",
false,
"Whether or not to check for steady state conditions");
91 params.
addParam<Real>(
"steady_state_tolerance",
93 "Whenever the relative residual changes by less "
94 "than this the solution will be considered to be "
97 "steady_state_start_time",
99 "Minimum amount of time to run before checking for steady state conditions.");
101 params.
addParam<std::vector<std::string>>(
"time_periods",
"The names of periods");
102 params.
addParam<std::vector<Real>>(
"time_period_starts",
"The start times of time periods");
103 params.
addParam<std::vector<Real>>(
"time_period_ends",
"The end times of time periods");
105 "abort_on_solve_fail",
false,
"abort if solve not converged rather than cut timestep");
107 params.
addParam<Real>(
"timestep_tolerance",
109 "the tolerance setting for final timestep size and sync times");
111 params.
addParam<
bool>(
"use_multiapp_dt",
113 "If true then the dt for the simulation will be "
114 "chosen by the MultiApps. If false (the "
115 "default) then the minimum over the master dt "
116 "and the MultiApps is used");
119 "steady_state_detection steady_state_tolerance steady_state_start_time",
120 "Steady State Detection");
122 params.
addParamNamesToGroup(
"start_time dtmin dtmax n_startup_steps trans_ss_check ss_check_tol "
123 "ss_tmin abort_on_solve_fail timestep_tolerance use_multiapp_dt",
126 params.
addParamNamesToGroup(
"time_periods time_period_starts time_period_ends",
"Time Periods");
133 _problem(_fe_problem),
134 _nl(_fe_problem.getNonlinearSystemBase()),
136 _t_step(_problem.timeStep()),
137 _time(_problem.time()),
138 _time_old(_problem.timeOld()),
140 _dt_old(_problem.dtOld()),
141 _unconstrained_dt(declareRecoverableData<Real>(
"unconstrained_dt", -1)),
142 _at_sync_point(declareRecoverableData<bool>(
"at_sync_point", false)),
143 _last_solve_converged(declareRecoverableData<bool>(
"last_solve_converged", true)),
144 _xfem_repeat_step(false),
145 _end_time(getParam<Real>(
"end_time")),
146 _dtmin(getParam<Real>(
"dtmin")),
147 _dtmax(getParam<Real>(
"dtmax")),
148 _num_steps(getParam<unsigned int>(
"num_steps")),
149 _n_startup_steps(getParam<int>(
"n_startup_steps")),
150 _steady_state_detection(getParam<bool>(
"steady_state_detection")),
151 _steady_state_tolerance(getParam<Real>(
"steady_state_tolerance")),
152 _steady_state_start_time(getParam<Real>(
"steady_state_start_time")),
153 _sync_times(_app.getOutputWarehouse().getSyncTimes()),
154 _abort(getParam<bool>(
"abort_on_solve_fail")),
155 _time_interval(declareRecoverableData<bool>(
"time_interval", false)),
156 _start_time(getParam<Real>(
"start_time")),
157 _timestep_tolerance(getParam<Real>(
"timestep_tolerance")),
158 _target_time(declareRecoverableData<Real>(
"target_time", -1)),
159 _use_multiapp_dt(getParam<bool>(
"use_multiapp_dt")),
160 _solution_change_norm(declareRecoverableData<Real>(
"solution_change_norm", 0.0)),
161 _sln_diff(_nl.addVector(
"sln_diff", false, PARALLEL)),
162 _final_timer(registerTimedSection(
"final", 1))
219 pars.
set<Real>(
"dt") = (getParam<Real>(
"end_time") - getParam<Real>(
"start_time")) /
220 static_cast<Real>(getParam<unsigned int>(
"num_steps"));
222 pars.
set<Real>(
"dt") = getParam<Real>(
"dt");
224 pars.
set<
bool>(
"reset_dt") = getParam<bool>(
"reset_dt");
252 mooseError(
"Internal error in Transient executioner: _t_step is equal to 0 while recovering "
277 mooseError(
"Time stepper computed zero time step size on initial which is not allowed.\n"
278 "1. If you are using an existing time stepper, double check the values in your "
279 "input file or report an error.\n"
280 "2. If you are developing a new time stepper, make sure that initial time step "
281 "size in your code is computed correctly.");
353 #ifdef LIBMESH_ENABLE_AMR
401 if (input_dt == -1.0)
424 _console <<
"Aborting as solve did not converge\n";
452 if (input_time == -1.0)
489 std::ostringstream diag;
497 diag <<
"Timestep < n_startup_steps, using old dt: " << std::setw(9) << std::setprecision(6)
498 << std::setfill(
'0') << std::showpoint << std::left <<
_dt <<
" tstep: " <<
_t_step
518 diag <<
"Limiting dt for time interval output at time: " << std::setw(9) << std::setprecision(6)
520 <<
" dt: " << std::setw(9) << std::setprecision(6) << std::setfill(
'0') << std::showpoint
521 << std::left << dt_cur << std::endl;
530 diag <<
"Limiting dt for target time: " << std::setw(9) << std::setprecision(6)
532 <<
" dt: " << std::setw(9) << std::setprecision(6) << std::setfill(
'0') << std::showpoint
533 << std::left << dt_cur << std::endl;
540 dt_cur = multi_app_dt;
542 diag <<
"Limiting dt for MultiApps: " << std::setw(9) << std::setprecision(6)
543 << std::setfill(
'0') << std::showpoint << std::left << dt_cur << std::endl;
546 if (multi_app_dt < dt_cur)
548 dt_cur = multi_app_dt;
550 diag <<
"Limiting dt for MultiApps: " << std::setw(9) << std::setprecision(6)
551 << std::setfill(
'0') << std::showpoint << std::left << dt_cur << std::endl;
581 _console <<
"Steady-State Solution Achieved at time: " <<
_time << std::endl;
603 _console <<
"Aborting as solve did not converge and input selected to abort" << std::endl;
643 mooseError(
"You cannot specify time_scheme in the Executioner and independently add a "
644 "TimeIntegrator to the system at the same time");
650 using namespace Moose;
655 ti_str =
"ImplicitEuler";
658 ti_str =
"ExplicitEuler";
661 ti_str =
"CrankNicolson";
667 ti_str =
"ExplicitMidpoint";
670 ti_str =
"LStableDirk2";
673 ti_str =
"ExplicitTVDRK2";
676 ti_str =
"NewmarkBeta";
694 return demangle(
typeid(ts).
name());
697 return std::string();
709 return (
_sln_diff.l2_norm() / current_solution.l2_norm());
Transient executioners usually loop through a number of timesteps...
std::shared_ptr< TimeStepper > _time_stepper
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters ¶meters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>())
InputParameters getValidParams(const std::string &name)
Get valid parameters for the object.
void setStartTime(Real time)
Set the starting time for the simulation.
virtual void postStep()
Callback to the TimeIntegrator called at the very end of time step.
Real & _time
Current time.
void mooseError(Args &&... args) const
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
virtual void addTimeIntegrator(const std::string &type, const std::string &name, InputParameters ¶meters)
bool & _last_solve_converged
Whether or not the last solve converged.
bool halfTransient() const
Whether or not this simulation should only run half its transient (useful for testing recovery)
virtual void transient(bool trans)
Real _steady_state_start_time
virtual void initialSetup()
virtual bool isSolveTerminationRequested()
Check of termination has been requested.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual bool keepGoing()
Transient loop will continue as long as this keeps returning true.
FEProblemBase & _problem
Here for backward compatibility.
const NumericVector< Number > *const & currentSolution() const override
The solution vector that is currently being operated on.
registerMooseObject("MooseApp", Transient)
virtual void setInnerSolve(SolveObject &solve)
Set the inner solve object wrapped by this object.
const InputParameters & parameters() const
Get the parameters of the object.
virtual void preExecute() override
Override this for actions that should take place before execution.
virtual void advanceState()
Advance all of the state holding vectors / datastructures so that we can move to the next timestep.
Executioners are objects that do the actual work of solving your problem.
virtual void setTargetTime(Real target_time)
Can be used to set the next "target time" which is a time to nail perfectly.
static InputParameters validParams()
int & _t_step
Current timestep.
void restoreMultiApps(ExecFlagType type, bool force=false)
Restore the MultiApps associated with the ExecFlagType.
bool haveXFEM()
Find out whether the current analysis is using XFEM.
virtual std::string getTimeStepperName() override
Get the timestepper.
FEProblemSolve _feproblem_solve
virtual void init()
Called only before the very first timestep (t_step = 0) Never called again (not even during recover/r...
Real getSolutionChangeNorm()
Get the Relative L2 norm of the change in the solution.
virtual void onTimestepBegin() override
const bool & _verbose
True if printing out additional information.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
virtual void execute() override
Pure virtual execute function MUST be overridden by children classes.
virtual void endStep(Real input_time=-1.0)
static InputParameters validParams()
Constructor.
virtual NumericVector< Number > & solutionOld()=0
const ExecFlagType EXEC_TIMESTEP_BEGIN
virtual bool lastSolveConverged() const override
Whether or not the last solve converged.
NonlinearSystemBase & _nl
Reference to nonlinear system base for faster access.
bool & _time_interval
if to use time interval output
Generic class for solving transient nonlinear problems.
Transient(const InputParameters ¶meters)
bool hasPicardIteration()
Whether or not this has Picard iterations.
bool hasTimeIntegrator() const
Returns whether or not this Problem has a TimeIntegrator.
Real _next_interval_output_time
Base class for time stepping.
bool execMultiApps(ExecFlagType type, bool auto_advance=true)
Execute the MultiApps associated with the ExecFlagType.
PicardSolve _picard_solve
bool XFEMRepeatStep() const
This function checks the _xfem_repeat_step flag set by solve.
virtual void estimateTimeError()
virtual void computeIndicators()
const ExecFlagType EXEC_PRE_MULTIAPP_SETUP
virtual void init() override
Initialize the executioner.
virtual Real relativeSolutionDifferenceNorm()
The relative L2 norm of the difference between solution and old solution vector.
void finishMultiAppStep(ExecFlagType type)
Finish the MultiApp time step (endStep, postStep) associated with the ExecFlagType.
void uniformRefine()
uniformly refine the problem mesh(es).
void setupTimeIntegrator()
const ExecFlagType EXEC_TIMESTEP_END
virtual void incrementStepOrReject()
This is where the solve step is actually incremented.
Real getStartTime() const
virtual void timestepSetup()
const unsigned int _num_grid_steps
The number of steps to perform in a grid sequencing algorithm.
void incrementMultiAppTStep(ExecFlagType type)
Advance the MultiApps t_step (incrementStepOrReject) associated with the ExecFlagType.
virtual void postExecute() override
Override this for actions that should take place after execution.
bool isRecovering() const
Whether or not this is a "recover" calculation.
const ExecFlagType EXEC_INITIAL
Real _time_interval_output_interval
NumericVector< Number > & _sln_diff
The difference of current and old solutions.
Real _steady_state_tolerance
Real & _solution_change_norm
bool _steady_state_detection
Steady state detection variables:
const ExecFlagType EXEC_FINAL
Real & _time_old
Previous time.
defineLegacyParams(Transient)
Real & _dt
Current delta t... or timestep size.
TimeIntegratorType
Time integrators.
virtual void takeStep(Real input_dt=-1.0)
Do whatever is necessary to advance one step.
virtual void computeMarkers()
virtual Real computeConstrainedDT()
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
virtual void postExecute()
Method called at the end of the simulation.
bool isRestarting() const
Whether or not this is a "restart" calculation.
virtual void execute(const ExecFlagType &exec_type)
Convenience function for performing execution of MOOSE systems.
MooseApp & _app
The MooseApp this object is associated with.
bool _xfem_repeat_step
Whether step should be repeated due to xfem modifying the mesh.
bool hasStartTime() const
TimeIntegrator * getTimeIntegrator()
virtual const std::string & name() const
Get the name of the object.
Moose::TimeIntegratorType _time_scheme
virtual void outputStep(ExecFlagType type)
Output the current step.
Real computeMultiAppsDT(ExecFlagType type)
Find the smallest timestep over all MultiApps.