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);
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", 1.0e-12,
"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",
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");
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 "normalize_solution_diff_norm_by_dt",
103 "Whether to divide the solution difference norm by dt. If taking 'small' " 104 "time steps you probably want this to be true. If taking very 'large' timesteps in an " 105 "attempt to *reach* a steady-state, you probably want this parameter to be false.");
107 params.
addParam<std::vector<std::string>>(
"time_periods",
"The names of periods");
108 params.
addParam<std::vector<Real>>(
"time_period_starts",
"The start times of time periods");
109 params.
addParam<std::vector<Real>>(
"time_period_ends",
"The end times of time periods");
111 "abort_on_solve_fail",
false,
"abort if solve not converged rather than cut timestep");
115 "Throw error when timestep is less than dtmin instead of just aborting solve.");
119 "the tolerance setting for final timestep size and sync times");
121 params.
addParam<
bool>(
"use_multiapp_dt",
123 "If true then the dt for the simulation will be " 124 "chosen by the MultiApps. If false (the " 125 "default) then the minimum over the master dt " 126 "and the MultiApps is used");
130 "Whether to check the auxiliary system for convergence to steady-state. If " 131 "false, then the nonlinear system is used.");
134 "steady_state_detection steady_state_tolerance steady_state_start_time check_aux",
135 "Steady State Detection");
137 params.
addParamNamesToGroup(
"start_time dtmin dtmax n_startup_steps trans_ss_check ss_check_tol " 138 "ss_tmin abort_on_solve_fail timestep_tolerance use_multiapp_dt",
141 params.
addParamNamesToGroup(
"time_periods time_period_starts time_period_ends",
"Time Periods");
148 _problem(_fe_problem),
149 _feproblem_solve(*this),
150 _nl(_fe_problem.getNonlinearSystemBase(0)),
151 _aux(_fe_problem.getAuxiliarySystem()),
152 _check_aux(getParam<bool>(
"check_aux")),
154 _time_stepper(nullptr),
155 _t_step(_problem.timeStep()),
156 _time(_problem.time()),
157 _time_old(_problem.timeOld()),
159 _dt_old(_problem.dtOld()),
160 _unconstrained_dt(declareRecoverableData<
Real>(
"unconstrained_dt", -1)),
161 _at_sync_point(declareRecoverableData<bool>(
"at_sync_point", false)),
162 _last_solve_converged(declareRecoverableData<bool>(
"last_solve_converged", true)),
163 _xfem_repeat_step(false),
164 _end_time(getParam<
Real>(
"end_time")),
165 _dtmin(getParam<
Real>(
"dtmin")),
166 _dtmax(getParam<
Real>(
"dtmax")),
167 _num_steps(getParam<unsigned
int>(
"num_steps")),
168 _n_startup_steps(getParam<
int>(
"n_startup_steps")),
169 _steady_state_detection(getParam<bool>(
"steady_state_detection")),
170 _steady_state_tolerance(getParam<
Real>(
"steady_state_tolerance")),
171 _steady_state_start_time(getParam<
Real>(
"steady_state_start_time")),
172 _sync_times(_app.getOutputWarehouse().getSyncTimes()),
173 _abort(getParam<bool>(
"abort_on_solve_fail")),
174 _error_on_dtmin(getParam<bool>(
"error_on_dtmin")),
175 _time_interval(declareRecoverableData<bool>(
"time_interval", false)),
176 _start_time(getParam<
Real>(
"start_time")),
177 _timestep_tolerance(getParam<
Real>(
"timestep_tolerance")),
178 _target_time(declareRecoverableData<
Real>(
"target_time", -
std::numeric_limits<
Real>::
max())),
179 _use_multiapp_dt(getParam<bool>(
"use_multiapp_dt")),
180 _solution_change_norm(declareRecoverableData<
Real>(
"solution_change_norm", 0.0)),
181 _normalize_solution_diff_norm_by_dt(getParam<bool>(
"normalize_solution_diff_norm_by_dt"))
234 mooseError(
"Internal error in Transient executioner: _t_step is equal to 0 while recovering " 259 mooseError(
"Time stepper computed zero time step size on initial which is not allowed.\n" 260 "1. If you are using an existing time stepper, double check the values in your " 261 "input file or report an error.\n" 262 "2. If you are developing a new time stepper, make sure that initial time step " 263 "size in your code is computed correctly.");
320 TIME_SECTION(
"final", 1,
"Executing Final Objects");
347 #ifdef LIBMESH_ENABLE_AMR 402 if (input_dt == -1.0)
423 _console <<
"Aborting as solve did not converge" << std::endl;
448 if (input_time == -1.0)
485 std::ostringstream diag;
493 diag <<
"Timestep < n_startup_steps, using old dt: " << std::setw(9) << std::setprecision(6)
494 << std::setfill(
'0') << std::showpoint << std::left <<
_dt <<
" tstep: " <<
_t_step 514 diag <<
"Limiting dt for time interval output at time: " << std::setw(9) << std::setprecision(6)
516 <<
" dt: " << std::setw(9) << std::setprecision(6) << std::setfill(
'0') << std::showpoint
517 << std::left << dt_cur << std::endl;
527 diag <<
"Limiting dt for target time: " << std::setw(9) << std::setprecision(6)
529 <<
" dt: " << std::setw(9) << std::setprecision(6) << std::setfill(
'0') << std::showpoint
530 << std::left << dt_cur << std::endl;
547 std::ostringstream & diag,
553 dt_cur = multi_app_dt;
555 diag <<
"Limiting dt for MultiApps on " << execute_on.
name() <<
": " << std::setw(9)
556 << std::setprecision(6) << std::setfill(
'0') << std::showpoint << std::left << dt_cur
582 _console <<
"Steady-State Solution Achieved at time: " <<
_time << std::endl;
604 _console <<
"Aborting as solve did not converge and input selected to abort" << std::endl;
609 _console <<
"Aborting as timestep already at or below dtmin" << std::endl;
649 mooseError(
"You cannot specify time_scheme in the Executioner and independently add a " 650 "TimeIntegrator to the system at the same time");
656 using namespace Moose;
661 ti_str =
"ImplicitEuler";
664 ti_str =
"ExplicitEuler";
667 ti_str =
"CrankNicolson";
673 ti_str =
"ExplicitMidpoint";
676 ti_str =
"LStableDirk2";
679 ti_str =
"ExplicitTVDRK2";
682 ti_str =
"NewmarkBeta";
703 return std::string();
713 mooseError(
"Time integrator has not been built yet so we can't retrieve its name");
Moose::TimeIntegratorType _time_scheme
void timestepSetup() override
Transient executioners usually loop through a number of timesteps...
virtual std::string getTimeIntegratorName() const override
Get the name of the time integrator (time integration scheme) used.
const bool _normalize_solution_diff_norm_by_dt
Whether to divide the solution difference norm by dt.
void constrainDTFromMultiApp(Real &dt_cur, std::ostringstream &diag, const ExecFlagType &execute_on) const
Constrain the timestep dt_cur by looking at the timesteps for the MultiApps on execute_on.
const std::string & name() const
NumericVector< Number > & solution()
virtual void setTargetTime(Real target_time)
Can be used to set the next "target time" which is a time to nail perfectly.
const bool _check_aux
Whether to use the auxiliary system solution to determine steady-states.
virtual void postExecute()
Method called at the end of the simulation.
virtual void postStep()
Callback to the TimeIntegrator called at the very end of time step.
void computeStep()
Called before a new step is started.
FEProblemBase & _problem
Here for backward compatibility.
virtual void computeMarkers()
virtual void init() override
Initialize the executioner.
TimeIntegrator * getTimeIntegrator()
const bool & _verbose
True if printing out additional information.
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Base class for time stepping.
virtual void execute() override
Pure virtual execute function MUST be overridden by children classes.
virtual void endStep(Real input_time=-1.0)
const ExecFlagType EXEC_MULTIAPP_FIXED_POINT_END
void finishMultiAppStep(ExecFlagType type, bool recurse_through_multiapp_levels=false)
Finish the MultiApp time step (endStep, postStep) associated with the ExecFlagType.
virtual void postExecute()
virtual bool constrainStep(Real &dt)
Called after computeStep() is called.
virtual void postExecute() override
Override this for actions that should take place after execution.
bool haveXFEM()
Find out whether the current analysis is using XFEM.
const ExecFlagType EXEC_TIMESTEP_END
Real getStartTime() const
virtual bool converged() const
If the time step converged.
bool isRestarting() const
Whether or not this is a "restart" calculation.
virtual void init()
Called only before the very first timestep (t_step = 0) Never called again (not even during recover/r...
virtual const std::string & name() const
Get the name of the class.
bool _xfem_repeat_step
Whether step should be repeated due to xfem modifying the mesh.
bool _steady_state_detection
Steady state detection variables:
Real computeMultiAppsDT(ExecFlagType type)
Find the smallest timestep over all MultiApps.
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
auto max(const L &left, const R &right)
virtual bool isSolveTerminationRequested() const
Check of termination has been requested.
Real l2_norm_diff(const NumericVector< Number > &other_vec) const
Real & _time_old
Previous time.
virtual void advanceState()
Advance all of the state holding vectors / datastructures so that we can move to the next timestep...
bool & _time_interval
if to use time interval output
virtual void execute(const ExecFlagType &exec_type)
Convenience function for performing execution of MOOSE systems.
virtual void takeStep(Real input_dt=-1.0)
Do whatever is necessary to advance one step.
Transient(const InputParameters ¶meters)
TimeStepper * _time_stepper
virtual Real l2_norm() const =0
virtual void acceptStep()
This gets called when time step is accepted.
static InputParameters validParams()
virtual Real computeConstrainedDT()
virtual bool lastSolveConverged() const override
Whether or not the last solve converged.
NonlinearSystemBase & _nl
Reference to nonlinear system base for faster access.
TimeStepper * getTimeStepper()
Pointer to the TimeStepper.
const ExecFlagType EXEC_TIMESTEP_BEGIN
const ExecFlagType EXEC_PRE_MULTIAPP_SETUP
bool hasTimeIntegrator() const
Returns whether or not this Problem has a TimeIntegrator.
virtual void computeIndicators()
const std::string & type() const
Get the type of this class.
virtual std::string getTimeStepperName() const override
Get the name of the timestepper.
void initialSetup() override
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Executioners are objects that do the actual work of solving your problem.
virtual void addTimeIntegrator(const std::string &type, const std::string &name, InputParameters ¶meters)
bool testCheckpointHalfTransient() const
Whether or not this simulation should only run half its transient (useful for testing recovery) ...
Real _steady_state_tolerance
void setupTimeIntegrator()
MooseApp & _app
The MOOSE application this is associated with.
virtual void incrementStepOrReject()
This is where the solve step is actually incremented.
static InputParameters validParams()
virtual void estimateTimeError()
std::string demangle(const char *name)
const bool _error_on_dtmin
This parameter controls how the system will deal with _dt <= _dtmin If true, the time stepper is expe...
const NumericVector< Number > *const & currentSolution() const override
The solution vector that is currently being operated on.
Real & _dt
Current delta t... or timestep size.
virtual void preExecute() override
Override this for actions that should take place before execution.
Real _time_interval_output_interval
Real & _time
Current time.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Class for containing MooseEnum item information.
const ExecFlagType EXEC_MULTIAPP_FIXED_POINT_BEGIN
Real _steady_state_start_time
void restoreMultiApps(ExecFlagType type, bool force=false)
Restore the MultiApps associated with the ExecFlagType.
void setTimeStepper(TimeStepper &ts)
Set the timestepper to use.
bool hasStartTime() const
virtual void onTimestepBegin() override
virtual Real relativeSolutionDifferenceNorm()
The relative L2 norm of the difference between solution and old solution vector.
virtual void preExecute()
virtual void rejectStep()
This gets called when time step is rejected.
void incrementMultiAppTStep(ExecFlagType type)
Advance the MultiApps t_step (incrementStepOrReject) associated with the ExecFlagType.
virtual void transient(bool trans)
TimeIntegratorType
Time integrators.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
virtual bool keepGoing()
Transient loop will continue as long as this keeps returning true.
virtual void step()
Take a time step.
const InputParameters & parameters() const
Get the parameters of the object.
static InputParameters validParams()
Constructor.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
bool execMultiApps(ExecFlagType type, bool auto_advance=true)
Execute the MultiApps associated with the ExecFlagType.
NumericVector< Number > & solutionOld()
AuxiliarySystem & _aux
Reference to auxiliary system base for faster access.
Real & _solution_change_norm
bool isRecovering() const
Whether or not this is a "recover" calculation.
virtual void init()
Initialize the time stepper.
Real _next_interval_output_time
const ExecFlagType EXEC_FINAL
registerMooseObject("MooseApp", Transient)
int & _t_step
Current timestep.
Real getCurrentDT()
Get the current_dt.
void ErrorVector unsigned int
std::unique_ptr< FixedPointSolve > _fixed_point_solve
virtual void outputStep(ExecFlagType type)
Output the current step.
Real getSolutionChangeNorm()
Get the Relative L2 norm of the change in the solution.
void setStartTime(Real time)
Set the starting time for the simulation.
FEProblemSolve _feproblem_solve
inner-most solve object to perform Newton solve with PETSc on every time step
bool & _last_solve_converged
Whether or not the last solve converged.
const ExecFlagType EXEC_INITIAL