www.mooseframework.org
Transient.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "Executioner.h"
13 #include "TimeIntegrator.h"
14 
15 // System includes
16 #include <string>
17 #include <fstream>
18 
19 class TimeStepper;
20 class FEProblemBase;
21 
26 class Transient : public Executioner
27 {
28 public:
36 
38 
39  virtual void init() override;
40 
41  virtual void execute() override;
42 
46  virtual void takeStep(Real input_dt = -1.0);
47 
51  virtual Real computeConstrainedDT();
52  virtual void estimateTimeError();
53 
57  virtual Real getDT();
58 
62  virtual bool keepGoing();
63 
67  virtual bool lastSolveConverged() const override;
68 
69  virtual void preExecute() override;
70 
71  virtual void postExecute() override;
72 
73  virtual void computeDT();
74 
75  virtual void preStep();
76 
77  virtual void postStep();
78 
82  virtual void incrementStepOrReject();
83 
84  virtual void endStep(Real input_time = -1.0);
85 
90  virtual void setTargetTime(Real target_time);
91 
95  virtual Real getTime() const { return _time; };
96 
101  virtual Real getTargetTime() { return _target_time; }
102 
106  virtual void setTime(Real t) { _time = t; };
107 
111  virtual void setTimeOld(Real t) { _time_old = t; };
112 
117 
123  const TimeStepper * getTimeStepper() const { return _time_stepper; }
124 
130  void setTimeStepper(TimeStepper & ts);
131 
135  virtual std::string getTimeStepperName() const override;
136 
141  virtual std::string getTimeIntegratorName() const override;
142 
148 
153  std::set<Real> & syncTimes() { return _sync_times; }
154 
159  Real & dtMax() { return _dtmax; }
160 
165  Real & dtMin() { return _dtmin; }
166 
171  Real getStartTime() const { return _start_time; }
172 
177  Real getEndTime() const { return _end_time; }
178 
183  Real & endTime() { return _end_time; }
184 
190 
195  virtual void setTimestepTolerance(const Real & tolerance) { _timestep_tolerance = tolerance; }
196 
201  bool atSyncPoint() { return _at_sync_point; }
202 
208 
210 
215 
220  virtual void forceNumSteps(const unsigned int num_steps) { _num_steps = num_steps; }
221 
223  virtual SolveObject * timeStepSolveObject() { return _fixed_point_solve.get(); }
224 
225 protected:
228 
231 
234 
237 
239  const bool _check_aux;
240 
243 
245  int & _t_step;
253 
256 
259 
262 
266  unsigned int _num_steps;
268 
275 
276  std::set<Real> & _sync_times;
277 
278  bool _abort;
282  const bool _error_on_dtmin;
283 
288 
293 
295 
296  void setupTimeIntegrator();
297 
302 
304  bool convergedToSteadyState() const;
305 
306 private:
308  void constrainDTFromMultiApp(Real & dt_cur,
309  std::ostringstream & diag,
310  const ExecFlagType & execute_on) const;
311 };
Moose::TimeIntegratorType _time_scheme
Definition: Transient.h:241
virtual Real getDT()
Definition: Transient.C:562
bool atSyncPoint()
Is the current step at a sync point (sync times, time interval, target time, etc)?
Definition: Transient.h:201
Real _dtmax
Definition: Transient.h:265
Transient executioners usually loop through a number of timesteps...
Definition: Transient.h:26
virtual std::string getTimeIntegratorName() const override
Get the name of the time integrator (time integration scheme) used.
Definition: Transient.C:707
Real & _unconstrained_dt
Definition: Transient.h:254
const bool _normalize_solution_diff_norm_by_dt
Whether to divide the solution difference norm by dt.
Definition: Transient.h:301
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.
Definition: Transient.C:546
Real & dtMin()
Get the minimal dt.
Definition: Transient.h:165
virtual void forceNumSteps(const unsigned int num_steps)
Set the number of time steps.
Definition: Transient.h:220
virtual void setTargetTime(Real target_time)
Can be used to set the next "target time" which is a time to nail perfectly.
Definition: Transient.C:634
const bool _check_aux
Whether to use the auxiliary system solution to determine steady-states.
Definition: Transient.h:239
virtual SolveObject * timeStepSolveObject()
Return the solve object wrapped by time stepper.
Definition: Transient.h:223
virtual void computeDT()
Definition: Transient.C:335
void parentOutputPositionChanged()
Calls parentOutputPositionChanged() on all sub apps.
FEProblemBase & _problem
Here for backward compatibility.
Definition: Transient.h:227
int _n_startup_steps
Definition: Transient.h:267
virtual void init() override
Initialize the executioner.
Definition: Transient.C:222
virtual void setTimeOld(Real t)
Set the old time.
Definition: Transient.h:111
Base class for time stepping.
Definition: TimeStepper.h:22
virtual void execute() override
Pure virtual execute function MUST be overridden by children classes.
Definition: Transient.C:281
virtual void endStep(Real input_time=-1.0)
Definition: Transient.C:446
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void postExecute() override
Override this for actions that should take place after execution.
Definition: Transient.C:628
virtual void setTime(Real t)
Set the current time.
Definition: Transient.h:106
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
bool _xfem_repeat_step
Whether step should be repeated due to xfem modifying the mesh.
Definition: Transient.h:261
bool _steady_state_detection
Steady state detection variables:
Definition: Transient.h:272
Real _dtmin
Definition: Transient.h:264
Real & _time_old
Previous time.
Definition: Transient.h:249
Nonlinear system to be solved.
virtual Real getTargetTime()
Get the current target time.
Definition: Transient.h:101
bool & _time_interval
if to use time interval output
Definition: Transient.h:285
Real unconstrainedDT()
Get the unconstrained dt.
Definition: Transient.h:207
virtual void takeStep(Real input_dt=-1.0)
Do whatever is necessary to advance one step.
Definition: Transient.C:398
Transient(const InputParameters &parameters)
Definition: Transient.C:146
TimeStepper * _time_stepper
Definition: Transient.h:242
std::set< Real > & _sync_times
Definition: Transient.h:276
unsigned int _num_steps
Definition: Transient.h:266
virtual Real computeConstrainedDT()
Definition: Transient.C:476
virtual bool lastSolveConverged() const override
Whether or not the last solve converged.
Definition: Transient.C:622
NonlinearSystemBase & _nl
Reference to nonlinear system base for faster access.
Definition: Transient.h:233
TimeStepper * getTimeStepper()
Pointer to the TimeStepper.
Definition: Transient.h:122
const TimeStepper * getTimeStepper() const
Definition: Transient.h:123
bool _use_multiapp_dt
Definition: Transient.h:292
virtual std::string getTimeStepperName() const override
Get the name of the timestepper.
Definition: Transient.C:695
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:30
Real & _target_time
Definition: Transient.h:291
Real _steady_state_tolerance
Definition: Transient.h:273
void setupTimeIntegrator()
Definition: Transient.C:646
Real _start_time
Definition: Transient.h:289
virtual void setTimestepTolerance(const Real &tolerance)
Set the timestep tolerance.
Definition: Transient.h:195
virtual void incrementStepOrReject()
This is where the solve step is actually incremented.
Definition: Transient.C:341
virtual void estimateTimeError()
Definition: Transient.C:617
Real _timestep_tolerance
Definition: Transient.h:290
const bool _error_on_dtmin
This parameter controls how the system will deal with _dt <= _dtmin If true, the time stepper is expe...
Definition: Transient.h:282
bool _abort
Definition: Transient.h:278
Real & _dt
Current delta t... or timestep size.
Definition: Transient.h:251
Real & _dt_old
Definition: Transient.h:252
void parentOutputPositionChanged() override
Can be used by subclasses to call parentOutputPositionChanged() on the underlying FEProblemBase...
Definition: Transient.h:209
virtual void preExecute() override
Override this for actions that should take place before execution.
Definition: Transient.C:242
Real _time_interval_output_interval
Definition: Transient.h:287
bool & _at_sync_point
Definition: Transient.h:255
Real & _time
Current time.
Definition: Transient.h:247
Real & endTime()
Get a modifiable reference to the end time.
Definition: Transient.h:183
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real getTime() const
Get the current time.
Definition: Transient.h:95
Real & timestepTol()
Get the timestep tolerance.
Definition: Transient.h:189
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
Moose::TimeIntegratorType getTimeScheme() const
Get the time scheme used.
Definition: Transient.h:147
std::set< Real > & syncTimes()
Get the set of sync times.
Definition: Transient.h:153
Real _steady_state_start_time
Definition: Transient.h:274
void setTimeStepper(TimeStepper &ts)
Set the timestepper to use.
Definition: Transient.C:727
virtual Real relativeSolutionDifferenceNorm()
The relative L2 norm of the difference between solution and old solution vector.
Definition: Transient.C:717
TimeIntegratorType
Time integrators.
Definition: MooseTypes.h:815
virtual void preStep()
Definition: Transient.C:269
virtual bool keepGoing()
Transient loop will continue as long as this keeps returning true.
Definition: Transient.C:568
Real getEndTime() const
Get the end time.
Definition: Transient.h:177
const InputParameters & parameters() const
Get the parameters of the object.
static InputParameters validParams()
Constructor.
Definition: Transient.C:42
Real getStartTime() const
Return the start time.
Definition: Transient.h:171
Real & dtMax()
Get the maximum dt.
Definition: Transient.h:159
Real _end_time
Definition: Transient.h:263
virtual void postStep()
Definition: Transient.C:275
AuxiliarySystem & _aux
Reference to auxiliary system base for faster access.
Definition: Transient.h:236
Real & _solution_change_norm
Definition: Transient.h:294
Real _next_interval_output_time
Definition: Transient.h:286
int & _t_step
Current timestep.
Definition: Transient.h:245
A system that holds auxiliary variables.
std::unique_ptr< FixedPointSolve > _fixed_point_solve
Definition: Executioner.h:169
bool convergedToSteadyState() const
Determines whether the problem has converged to steady state.
Definition: Transient.C:734
Real getSolutionChangeNorm()
Get the Relative L2 norm of the change in the solution.
Definition: Transient.C:640
FEProblemSolve _feproblem_solve
inner-most solve object to perform Newton solve with PETSc on every time step
Definition: Transient.h:230
bool & _last_solve_converged
Whether or not the last solve converged.
Definition: Transient.h:258
FEProblemBase & _fe_problem
Definition: Executioner.h:166