https://mooseframework.inl.gov
TransientBase.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 #include "TransientBase.h"
11 
12 // MOOSE includes
13 #include "Factory.h"
14 #include "SubProblem.h"
15 #include "TimeStepper.h"
16 #include "MooseApp.h"
17 #include "Conversion.h"
18 #include "FEProblem.h"
19 #include "NonlinearSystem.h"
20 #include "Control.h"
21 #include "TimePeriod.h"
22 #include "MooseMesh.h"
23 #include "TimeIntegrator.h"
24 #include "Console.h"
25 #include "AuxiliarySystem.h"
26 #include "Convergence.h"
28 
29 #include "libmesh/implicit_system.h"
30 #include "libmesh/nonlinear_implicit_system.h"
31 #include "libmesh/transient_system.h"
32 #include "libmesh/numeric_vector.h"
33 
34 // C++ Includes
35 #include <iomanip>
36 #include <iostream>
37 #include <fstream>
38 #include <sstream>
39 #include <iomanip>
40 
43 {
45 
46  params.addParam<Real>("steady_state_tolerance",
47  1.0e-08,
48  "Whenever the relative residual changes by less "
49  "than this the solution will be considered to be "
50  "at steady state.");
51  params.addParam<bool>("check_aux",
52  false,
53  "Whether to check the auxiliary system for convergence to steady-state. If "
54  "false, then the solution vector from the solver system is used.");
55  params.addParam<bool>(
56  "normalize_solution_diff_norm_by_dt",
57  true,
58  "Whether to divide the solution difference norm by dt. If taking 'small' "
59  "time steps you probably want this to be true. If taking very 'large' timesteps in an "
60  "attempt to *reach* a steady-state, you probably want this parameter to be false.");
61 
62  params.addParamNamesToGroup("steady_state_tolerance check_aux normalize_solution_diff_norm_by_dt",
63  "Steady State Detection");
64 
65  return params;
66 }
67 
70 {
73 
74  params.addClassDescription("Executioner for time varying simulations.");
75 
76  std::vector<Real> sync_times(1);
77  sync_times[0] = -std::numeric_limits<Real>::max();
78 
84  MooseEnum schemes("implicit-euler explicit-euler crank-nicolson bdf2 explicit-midpoint dirk "
85  "explicit-tvd-rk-2 newmark-beta",
86  "implicit-euler");
87 
88  params.addParam<Real>("start_time", 0.0, "The start time of the simulation");
89  params.addParam<Real>("end_time", 1.0e30, "The end time of the simulation");
90  params.addParam<Real>("dt", 1., "The timestep size between solves");
91  params.addParam<Real>("dtmin", 1.0e-12, "The minimum timestep size in an adaptive run");
92  params.addParam<Real>("dtmax", 1.0e30, "The maximum timestep size in an adaptive run");
93  params.addParam<bool>(
94  "reset_dt", false, "Use when restarting a calculation to force a change in dt.");
95  params.addParam<unsigned int>("num_steps",
97  "The number of timesteps in a transient run");
98  params.addParam<int>("n_startup_steps", 0, "The number of timesteps during startup");
99 
100  params.addParam<bool>(
101  "steady_state_detection", false, "Whether or not to check for steady state conditions");
102  params.addParam<ConvergenceName>(
103  "steady_state_convergence",
104  "Name of the Convergence object to use to assess whether the solution has reached a steady "
105  "state. If not provided, a default Convergence will be constructed internally from the "
106  "executioner parameters.");
107  params.addParam<Real>(
108  "steady_state_start_time",
109  0.0,
110  "Minimum amount of time to run before checking for steady state conditions.");
111 
112  params.addParam<std::vector<std::string>>("time_periods", "The names of periods");
113  params.addParam<std::vector<Real>>("time_period_starts", "The start times of time periods");
114  params.addParam<std::vector<Real>>("time_period_ends", "The end times of time periods");
115  params.addParam<bool>(
116  "abort_on_solve_fail", false, "abort if solve not converged rather than cut timestep");
117  params.addParam<bool>(
118  "error_on_dtmin",
119  true,
120  "Throw error when timestep is less than dtmin instead of just aborting solve.");
121  params.addParam<MooseEnum>("scheme", schemes, "Time integration scheme used.");
122  params.addParam<Real>("timestep_tolerance",
123  1.0e-12,
124  "the tolerance setting for final timestep size and sync times");
125 
126  params.addParam<bool>("use_multiapp_dt",
127  false,
128  "If true then the dt for the simulation will be "
129  "chosen by the MultiApps. If false (the "
130  "default) then the minimum over the master dt "
131  "and the MultiApps is used");
132 
133  params.addParamNamesToGroup(
134  "steady_state_detection steady_state_convergence steady_state_start_time",
135  "Steady State Detection");
136 
137  params.addParamNamesToGroup("start_time dtmin dtmax n_startup_steps "
138  "abort_on_solve_fail timestep_tolerance use_multiapp_dt",
139  "Advanced");
140 
141  params.addParamNamesToGroup("time_periods time_period_starts time_period_ends", "Time Periods");
142 
143  // This Executioner supports --test-restep
144  params.set<bool>("_supports_test_restep") = true;
145 
146  return params;
147 }
148 
150  : Executioner(parameters),
151  _problem(_fe_problem),
152  _aux(_fe_problem.getAuxiliarySystem()),
153  _time_scheme(getParam<MooseEnum>("scheme").getEnum<Moose::TimeIntegratorType>()),
154  _time_stepper(nullptr),
155  _t_step(_problem.timeStep()),
156  _time(_problem.time()),
157  _time_old(_problem.timeOld()),
158  _dt(_problem.dt()),
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_start_time(getParam<Real>("steady_state_start_time")),
171  _sync_times(_app.getOutputWarehouse().getSyncTimes()),
172  _abort(getParam<bool>("abort_on_solve_fail")),
173  _error_on_dtmin(getParam<bool>("error_on_dtmin")),
174  _time_interval(declareRecoverableData<bool>("time_interval", false)),
175  _start_time(getParam<Real>("start_time")),
176  _timestep_tolerance(getParam<Real>("timestep_tolerance")),
177  _target_time(declareRecoverableData<Real>("target_time", -std::numeric_limits<Real>::max())),
178  _use_multiapp_dt(getParam<bool>("use_multiapp_dt")),
179  _testing_restep(false)
180 {
181  _t_step = 0;
182  _dt = 0;
184 
185  // Either a start_time has been forced on us, or we want to tell the App about what our start time
186  // is (in case anyone else is interested.
187  if (_app.hasStartTime())
189  else if (parameters.isParamSetByUser("start_time"))
191 
193  _problem.transient(true);
194 
196 
197  // Cut timesteps and end_time in half
199  {
200  mooseAssert(!_app.testReStep(), "Cannot use with restep");
201  _end_time = (_start_time + _end_time) / 2.0;
202  _num_steps /= 2.0;
203 
204  if (_num_steps == 0) // Always do one step in the first half
205  _num_steps = 1;
206  }
207  // Retest a timestep (see options below for which timestep)
208  else if (_app.testReStep())
209  {
210  if (_problem.shouldSolve())
211  {
212  // If num_steps is defined, we'll use that to determine restep timestep
213  if (!parameters.isParamSetByAddParam("num_steps"))
214  _test_restep_step = _t_step + (_num_steps + 1) / 2;
215  // If end_time is defined, we'll use the half time to determine when to restep
216  if (!parameters.isParamSetByAddParam("end_time"))
218  // If neither was set or we are doing pseudo-transient, pick the second timestep
220  _test_restep_step = 2;
221 
222  std::stringstream msg;
224  msg << "Timestep " << *_test_restep_step << " or time " << *_test_restep_time
225  << " (whichever happens first)";
226  else if (_test_restep_step)
227  msg << "Timestep " << *_test_restep_step;
228  else if (_test_restep_time)
229  msg << "Time " << *_test_restep_time;
230  mooseInfo(msg.str(), " will be forcefully retried due to --test-restep.");
231  }
232  else
233  mooseInfo(
234  "A timestep is not being retried with --test-restep because Problem/solve=false.\n\nTo "
235  "avoid this test being ran, you could set `restep = false` in the test specification.");
236  }
237 
238  if (isParamValid("steady_state_convergence"))
239  _problem.setSteadyStateConvergenceName(getParam<ConvergenceName>("steady_state_convergence"));
240  else
241  // Note that we create a steady-state Convergence object even if steady_state_detection ==
242  // false. This could possibly be changed in the future, but TransientMultiApp would need to be
243  // able to signal for the Convergence object to be created in case it uses steady-state
244  // detection for sub-stepping.
246 }
247 
248 void
250 {
253  _fixed_point_solve->initialSetup();
254 
255  mooseAssert(getTimeStepper(), "No time stepper was set");
256 
257  _time_stepper->init();
258 
261 
262  if (_app.isRecovering()) // Recover case
263  {
264  if (_t_step == 0)
265  mooseError(
266  "Internal error in TransientBase executioner: _t_step is equal to 0 while recovering "
267  "in init().");
268 
269  _dt_old = _dt;
270  }
271 }
272 
273 void
275 {
277 
278  if (!_app.isRecovering())
279  {
280  _t_step = 0;
281  _dt = 0;
283  if (!_app.isRestarting())
285 
287 
288  computeDT();
289  _dt = getDT();
290  if (_dt == 0)
291  mooseError("Time stepper computed zero time step size on initial which is not allowed.\n"
292  "1. If you are using an existing time stepper, double check the values in your "
293  "input file or report an error.\n"
294  "2. If you are developing a new time stepper, make sure that initial time step "
295  "size in your code is computed correctly.");
296  const auto & tis = getTimeIntegrators();
297  for (auto & ti : tis)
298  ti->init();
299  }
300 }
301 
302 void
304 {
306 }
307 
308 void
310 {
312 }
313 
314 void
316 {
317  preExecute();
318 
319  // Start time loop...
320  while (keepGoing())
321  {
323  preStep();
324  computeDT();
325  takeStep();
326  endStep();
327  postStep();
328  }
329 
330  if (lastSolveConverged())
331  {
332  _t_step++;
333 
334  /*
335  * Call the multi-app executioners endStep and
336  * postStep methods when doing Picard or when not automatically advancing sub-applications for
337  * some other reason. We do not perform these calls for loose-coupling/auto-advancement
338  * problems because TransientBase::endStep and TransientBase::postStep get called from
339  * TransientBaseMultiApp::solveStep in that case.
340  */
341  if (!_fixed_point_solve->autoAdvance())
342  {
344  /*recurse_through_multiapp_levels=*/true);
345  _problem.finishMultiAppStep(EXEC_TIMESTEP_BEGIN, /*recurse_through_multiapp_levels=*/true);
346  _problem.finishMultiAppStep(EXEC_TIMESTEP_END, /*recurse_through_multiapp_levels=*/true);
348  /*recurse_through_multiapp_levels=*/true);
349  }
350  }
351 
353  {
354  TIME_SECTION("final", 1, "Executing Final Objects");
359  }
360 
361  // This method is to finalize anything else we want to do on the problem side.
363 
364  // This method can be overridden for user defined activities in the Executioner.
365  postExecute();
366 
368  mooseError((_test_restep_step ? "Timestep " : "Time "),
370  " was never retried because the simulation did not get to this timestep.\n\nTo "
371  "support restep testing, specify `num_steps` in the input.\nOtherwise, set "
372  "`restep = false` in this test specification.");
373 }
374 
375 void
377 {
378  // We're repeating the solve of the previous timestep,
379  // so we use the same dt
380  if (_testing_restep)
381  {
382  mooseAssert(!_test_restep_step && !_test_restep_time, "Should not be set");
383  return;
384  }
385 
386  _time_stepper->computeStep(); // This is actually when DT gets computed
387 }
388 
389 void
391 {
392  if (lastSolveConverged())
393  {
394  if (!_xfem_repeat_step)
395  {
396 #ifdef LIBMESH_ENABLE_AMR
397  if (_t_step != 0)
399 #endif
400 
401  _time_old = _time;
402  _t_step++;
403 
404  bool advance_problem_state = true;
405  const auto & tis = getTimeIntegrators();
406  for (auto & ti : tis)
407  // We do not want to advance the problem state here if a time integrator is already doing so
408  // itself
409  if (ti->advancesProblemState())
410  {
411  advance_problem_state = false;
412  break;
413  }
414 
415  if (advance_problem_state)
417  else if (tis.size() > 1)
418  mooseError("Either there must be a single time integrator which advances state or none of "
419  "the time integrators should advance state.");
420 
421  if (_t_step == 1)
422  return;
423 
424  /*
425  * Call the multi-app executioners endStep and
426  * postStep methods when doing Picard or when not automatically advancing sub-applications for
427  * some other reason. We do not perform these calls for loose-coupling/auto-advancement
428  * problems because TransientBase::endStep and TransientBase::postStep get called from
429  * TransientBaseMultiApp::solveStep in that case.
430  */
431  if (!_fixed_point_solve->autoAdvance())
432  {
437  }
438 
439  /*
440  * Ensure that we increment the sub-application time steps so that
441  * when dt selection is made in the master application, we are using
442  * the correct time step information
443  */
448  }
449  }
450  else
451  {
457  _time = _time_old;
458  }
459 }
460 
461 void
463 {
464  if (lastSolveConverged())
465  _dt_old = _dt;
466 
467  // We're repeating the solve of the previous timestep,
468  // so we use the same dt
469  if (_testing_restep)
470  {
471  mooseAssert(!_test_restep_step && !_test_restep_time, "Should not be set");
472  _testing_restep = false;
473  }
474  else if (input_dt == -1.0)
476  else
477  _dt = input_dt;
478 
480 
481  // Increment time
482  _time = _time_old + _dt;
483 
485 
487 
488  _time_stepper->step();
489  _xfem_repeat_step = _fixed_point_solve->XFEMRepeatStep();
490 
492 
493  // We're running with --test-restep and we have just solved
494  // the timestep we are to repeat for the first time
497  {
498  mooseAssert(!_testing_restep, "Should not be set");
499 
500  mooseInfo("Aborting and retrying solve for timestep ", _t_step, " due to --test-restep");
501  _last_solve_converged = false;
502  _testing_restep = true;
503  _test_restep_step.reset();
504  _test_restep_time.reset();
505 
506  return;
507  }
508 
509  if (!lastSolveConverged())
510  {
511  _console << "Aborting as solve did not converge" << std::endl;
512  return;
513  }
514 
515  if (!(_problem.haveXFEM() && _fixed_point_solve->XFEMRepeatStep()))
516  {
517  if (lastSolveConverged())
519  else
521  }
522 
523  _time = _time_old;
524 
526 
527  return;
528 }
529 
530 void
531 TransientBase::endStep(Real input_time)
532 {
533  if (input_time == -1.0)
534  _time = _time_old + _dt;
535  else
536  _time = input_time;
537 
538  if (lastSolveConverged())
539  {
540  if (_xfem_repeat_step)
541  _time = _time_old;
542  else
543  {
544  // TODO: add linear system support
545  const auto & tis = getTimeIntegrators();
546  for (auto & ti : tis)
547  ti->postStep();
548 
549  // Compute the Error Indicators and Markers
552 
553  // Perform the output of the current time step
555 
556  // output
559  }
560  }
561 }
562 
563 Real
565 {
566  // // If start up steps are needed
567  // if (_t_step == 1 && _n_startup_steps > 1)
568  // _dt = _input_dt/(double)(_n_startup_steps);
569  // else if (_t_step == 1+_n_startup_steps && _n_startup_steps > 1)
570  // _dt = _input_dt;
571 
572  Real dt_cur = _dt;
573  std::ostringstream diag;
574 
575  // After startup steps, compute new dt
577  dt_cur = getDT();
578 
579  else
580  {
581  diag << "Timestep < n_startup_steps, using old dt: " << std::setw(9) << std::setprecision(6)
582  << std::setfill('0') << std::showpoint << std::left << _dt << " tstep: " << _t_step
583  << " n_startup_steps: " << _n_startup_steps << std::endl;
584  }
585  _unconstrained_dt = dt_cur;
586 
587  if (_verbose)
588  _console << diag.str();
589 
590  diag.str("");
591  diag.clear();
592 
593  // Allow the time stepper to limit the time step
595 
596  // Don't let time go beyond next time interval output if specified
598  {
600  _at_sync_point = true;
601 
602  diag << "Limiting dt for time interval output at time: " << std::setw(9) << std::setprecision(6)
603  << std::setfill('0') << std::showpoint << std::left << _next_interval_output_time
604  << " dt: " << std::setw(9) << std::setprecision(6) << std::setfill('0') << std::showpoint
605  << std::left << dt_cur << std::endl;
606  }
607 
608  // If a target time is set and the current dt would exceed it, limit dt to match the target
610  _time + dt_cur + _timestep_tolerance >= _target_time)
611  {
612  dt_cur = _target_time - _time;
613  _at_sync_point = true;
614 
615  diag << "Limiting dt for target time: " << std::setw(9) << std::setprecision(6)
616  << std::setfill('0') << std::showpoint << std::left << _next_interval_output_time
617  << " dt: " << std::setw(9) << std::setprecision(6) << std::setfill('0') << std::showpoint
618  << std::left << dt_cur << std::endl;
619  }
620 
621  // Constrain by what the multi apps are doing
626 
627  if (_verbose)
628  _console << diag.str();
629 
630  return dt_cur;
631 }
632 
633 void
635  std::ostringstream & diag,
636  const ExecFlagType & execute_on) const
637 {
638  Real multi_app_dt = _problem.computeMultiAppsDT(execute_on);
639  if (_use_multiapp_dt || multi_app_dt < dt_cur)
640  {
641  dt_cur = multi_app_dt;
642  _at_sync_point = false;
643  diag << "Limiting dt for MultiApps on " << execute_on.name() << ": " << std::setw(9)
644  << std::setprecision(6) << std::setfill('0') << std::showpoint << std::left << dt_cur
645  << std::endl;
646  }
647 }
648 
649 Real
651 {
652  return _time_stepper->getCurrentDT();
653 }
654 
655 bool
657 {
658  bool keep_going = !_problem.isSolveTerminationRequested();
659 
660  // Check for stop condition based upon steady-state check flag:
661  if (lastSolveConverged())
662  {
663  if (!_xfem_repeat_step)
664  {
666  {
667  // Check solution difference relative norm against steady-state tolerance
669  {
670  _console << "Steady-State Solution Achieved at time: " << _time << std::endl;
671  // Output last solve if not output previously by forcing it
672  keep_going = false;
673  }
674  }
675 
676  // Check for stop condition based upon number of simulation steps and/or solution end time:
677  if (static_cast<unsigned int>(_t_step) >= _num_steps)
678  keep_going = false;
679 
680  if ((_time >= _end_time) || (fabs(_time - _end_time) <= _timestep_tolerance))
681  keep_going = false;
682  }
683  }
684  else if (_abort)
685  {
686  _console << "Aborting as solve did not converge and input selected to abort" << std::endl;
687  keep_going = false;
688  }
689  else if (!_error_on_dtmin && _dt <= _dtmin)
690  {
691  _console << "Aborting as timestep already at or below dtmin" << std::endl;
692  keep_going = false;
693  }
694 
695  return keep_going;
696 }
697 
698 void
700 {
701 }
702 
703 bool
705 {
706  return _last_solve_converged;
707 }
708 
709 void
711 {
713 }
714 
715 void
717 {
718  _target_time = target_time;
719 }
720 
721 Real
722 TransientBase::computeSolutionChangeNorm(bool check_aux, bool normalize_by_dt) const
723 {
724  return relativeSolutionDifferenceNorm(check_aux) / (normalize_by_dt ? _dt : Real(1));
725 }
726 
727 void
729 {
731  mooseError("You cannot specify time_scheme in the Executioner and independently add a "
732  "TimeIntegrator to the system at the same time");
733 
735  {
736  // backwards compatibility
737  std::string ti_str;
738  using namespace Moose;
739 
740  switch (_time_scheme)
741  {
742  case TI_IMPLICIT_EULER:
743  ti_str = "ImplicitEuler";
744  break;
745  case TI_EXPLICIT_EULER:
746  ti_str = "ExplicitEuler";
747  break;
748  case TI_CRANK_NICOLSON:
749  ti_str = "CrankNicolson";
750  break;
751  case TI_BDF2:
752  ti_str = "BDF2";
753  break;
755  ti_str = "ExplicitMidpoint";
756  break;
757  case TI_LSTABLE_DIRK2:
758  ti_str = "LStableDirk2";
759  break;
761  ti_str = "ExplicitTVDRK2";
762  break;
763  case TI_NEWMARK_BETA:
764  ti_str = "NewmarkBeta";
765  break;
766  default:
767  mooseError("Unknown scheme: ", _time_scheme);
768  break;
769  }
770 
771  InputParameters params = _app.getFactory().getValidParams(ti_str);
772  _problem.addTimeIntegrator(ti_str, ti_str, params);
773  }
774 }
775 
776 std::string
778 {
779  if (_time_stepper)
780  {
781  TimeStepper & ts = *_time_stepper;
782  return demangle(typeid(ts).name());
783  }
784  else
785  return std::string();
786 }
787 
788 std::vector<std::string>
790 {
791  const auto & tis = getTimeIntegrators();
792  if (tis.empty())
793  mooseError("Time integrator has not been built yet so we can't retrieve its name");
794 
795  std::vector<std::string> ret;
796  for (const auto & ti : tis)
797  {
798  const auto & sys = ti->getCheckedPointerParam<SystemBase *>("_sys")->system();
799  const auto & uvars = ti->getParam<std::vector<VariableName>>("variables");
800 
801  std::vector<VariableName> vars;
802  for (const auto & var : uvars)
803  if (sys.has_variable(var))
804  vars.push_back(var);
805 
806  if (!uvars.empty() && vars.empty())
807  continue;
808 
809  if (tis.size() > 1)
810  {
811  const std::string sys_prefix = _problem.numSolverSystems() > 1 ? sys.name() : "";
812  const std::string var_prefix = MooseUtils::join(vars, ", ");
813  const bool both = !sys_prefix.empty() && !var_prefix.empty();
814  ret.push_back("[" + sys_prefix + (both ? " (" : "") + var_prefix + (both ? ")" : "") + "]:");
815  }
816 
817  ret.push_back(ti->type());
818  }
819  return ret;
820 }
821 
822 void
824 {
825  mooseAssert(!_time_stepper, "Already set");
826  _time_stepper = &ts;
827 }
828 
829 bool
831 {
833  const auto status = convergence.checkConvergence(_t_step);
834 
836  mooseError(
837  "The steady-state Convergence object (", convergence.name(), ") reported divergence.");
839  return true;
840  else // status == Convergence::MooseConvergenceStatus::ITERATING
841  return false;
842 }
843 
844 void
846 {
848 }
void finalizeMultiApps()
void setTimeStepper(TimeStepper &ts)
Set the timestepper to use.
void mooseInfo(Args &&... args) const
Definition: MooseBase.h:317
virtual void preExecute() override
Override this for actions that should take place before execution.
bool shouldSolve() const
void timestepSetup() override
std::string join(Iterator begin, Iterator end, const std::string &delimiter)
Python-like join function for strings over an iterator range.
Definition: MooseUtils.h:142
virtual void postExecute() override
Override this for actions that should take place after execution.
const InputParameters & _pars
The object&#39;s parameters.
Definition: MooseBase.h:362
void setNeedToAddDefaultSteadyStateConvergence()
Sets _need_to_add_default_steady_state_convergence to true.
const Real _steady_state_start_time
const std::string & name() const
Definition: MooseEnumItem.h:35
virtual void estimateTimeError()
Real _time_interval_output_interval
virtual std::string getTimeStepperName() const override
Get the name of the timestepper.
virtual void postExecute()
Method called at the end of the simulation.
static InputParameters validParams()
Definition: TransientBase.C:69
virtual void endStep(Real input_time=-1.0)
Real computeSolutionChangeNorm(bool check_aux, bool normalize_by_dt) const
Compute the relative L2 norm of the change in the solution.
void computeStep()
Called before a new step is started.
Definition: TimeStepper.C:78
virtual void setTargetTime(Real target_time)
Can be used to set the next "target time" which is a time to nail perfectly.
std::optional< Real > _test_restep_time
If the time is greater than this then we fail and repeat if –test-restep is enabled.
void parentOutputPositionChanged()
Calls parentOutputPositionChanged() on all sub apps.
bool & _last_solve_converged
Whether or not the last solve converged.
virtual MooseConvergenceStatus checkConvergence(unsigned int iter)=0
Returns convergence status.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:127
char ** vars
virtual void preStep()
Definition: TimeStepper.h:39
virtual void computeMarkers()
void setupTimeIntegrator()
std::optional< int > _test_restep_step
The timestep we fail and repeat if –test-restep is enabled.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
const bool _error_on_dtmin
This parameter controls how the system will deal with _dt <= _dtmin If true, the time stepper is expe...
const bool & _verbose
True if printing out additional information.
Definition: Executioner.h:157
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Definition: Factory.C:68
Base class for time stepping.
Definition: TimeStepper.h:22
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void setSteadyStateConvergenceName(const ConvergenceName &convergence_name)
Sets the steady-state detection convergence object name if there is one.
virtual void preSolve()
Definition: TimeStepper.h:36
virtual Real getDT()
const ExecFlagType EXEC_MULTIAPP_FIXED_POINT_END
Definition: Moose.C:40
void finishMultiAppStep(ExecFlagType type, bool recurse_through_multiapp_levels=false)
Finish the MultiApp time step (endStep, postStep) associated with the ExecFlagType.
Real & _time
Current time.
virtual void postExecute()
Definition: TimeStepper.h:38
virtual bool constrainStep(Real &dt)
Called after computeStep() is called.
Definition: TimeStepper.C:102
bool haveXFEM()
Find out whether the current analysis is using XFEM.
const ExecFlagType EXEC_TIMESTEP_END
Definition: Moose.C:36
virtual void execute() override
Pure virtual execute function MUST be overridden by children classes.
unsigned int _num_steps
Real getStartTime() const
Definition: MooseApp.h:293
virtual bool converged() const
If the time step converged.
Definition: TimeStepper.C:197
virtual std::set< TimeIntegrator * > getTimeIntegrators() const =0
Get the time integrators (time integration scheme) used Note that because some systems might be stead...
Base class for a system (of equations)
Definition: SystemBase.h:84
bool isRestarting() const
Whether or not this is a "restart" calculation.
Definition: MooseApp.C:1807
bool convergedToSteadyState() const
Determines whether the problem has converged to steady state.
Real & _unconstrained_dt
Real computeMultiAppsDT(ExecFlagType type)
Find the smallest timestep over all MultiApps.
TimeStepper * _time_stepper
InputParameters emptyInputParameters()
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
Definition: MooseApp.h:394
auto max(const L &left, const R &right)
Real & _target_time
virtual bool isSolveTerminationRequested() const
Check of termination has been requested.
Definition: Problem.h:43
virtual Real computeConstrainedDT()
FEProblemBase & _problem
Here for backward compatibility.
MPI_Status status
virtual void advanceState()
Advance all of the state holding vectors / datastructures so that we can move to the next timestep...
virtual void execute(const ExecFlagType &exec_type)
Convenience function for performing execution of MOOSE systems.
virtual std::vector< std::string > getTimeIntegratorNames() const override
Get the name of the time integrator (time integration scheme) used.
bool isParamSetByAddParam(const std::string &name) const
Returns whether or not the parameter was set due to addParam.
TransientBase(const InputParameters &parameters)
const ConvergenceName & getSteadyStateConvergenceName() const
Gets the steady-state detection convergence object name.
virtual bool keepGoing()
Transient loop will continue as long as this keeps returning true.
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:99
virtual void preStep()
virtual void acceptStep()
This gets called when time step is accepted.
Definition: TimeStepper.C:175
TimeStepper * getTimeStepper()
Pointer to the TimeStepper.
static InputParameters validParams()
Definition: Executioner.C:26
virtual Convergence & getConvergence(const std::string &name, const THREAD_ID tid=0) const
Gets a Convergence object.
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition: Moose.C:37
const bool _steady_state_detection
Steady state detection variables:
const ExecFlagType EXEC_PRE_MULTIAPP_SETUP
Definition: Moose.C:54
bool & _time_interval
if to use time interval output
bool hasTimeIntegrator() const
Returns whether or not this Problem has a TimeIntegrator.
virtual void takeStep(Real input_dt=-1.0)
Do whatever is necessary to advance one step.
virtual void computeIndicators()
Real & _time_old
Previous time.
void initialSetup() override
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
Real & _dt
Current delta t... or timestep size.
virtual void postStep()
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:30
virtual void addTimeIntegrator(const std::string &type, const std::string &name, InputParameters &parameters)
bool testReStep() const
Whether or not this simulation should fail a timestep and repeat (for testing).
Definition: MooseApp.h:517
bool testCheckpointHalfTransient() const
Whether or not this simulation should only run half its transient (useful for testing recovery) ...
Definition: MooseApp.h:511
virtual void checkIterationType(IterationType) const
Perform checks related to the iteration type.
Definition: Convergence.h:48
bool _xfem_repeat_step
Whether step should be repeated due to xfem modifying the mesh.
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:353
std::string demangle(const char *name)
Real _timestep_tolerance
bool _testing_restep
Whether or not the last timestep we solved is being repeated with –test-restep.
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
virtual Real relativeSolutionDifferenceNorm(bool check_aux) const =0
The relative L2 norm of the difference between solution and old solution vector.
virtual void init() override
Initialize the executioner.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
Moose::TimeIntegratorType _time_scheme
const ExecFlagType EXEC_MULTIAPP_FIXED_POINT_BEGIN
Definition: Moose.C:42
void restoreMultiApps(ExecFlagType type, bool force=false)
Restore the MultiApps associated with the ExecFlagType.
bool hasStartTime() const
Definition: MooseApp.h:288
virtual void onTimestepBegin() override
static InputParameters defaultSteadyStateConvergenceParams()
Definition: TransientBase.C:42
virtual void preExecute()
Definition: TimeStepper.C:70
virtual void rejectStep()
This gets called when time step is rejected.
Definition: TimeStepper.C:185
void incrementMultiAppTStep(ExecFlagType type)
Advance the MultiApps t_step (incrementStepOrReject) associated with the ExecFlagType.
virtual void transient(bool trans)
virtual void incrementStepOrReject()
This is where the solve step is actually incremented.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
TimeIntegratorType
Time integrators.
Definition: MooseTypes.h:903
virtual void postSolve()
Definition: TimeStepper.h:37
virtual void step()
Take a time step.
Definition: TimeStepper.C:166
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
virtual void postStep()
Definition: TimeStepper.h:40
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:195
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.
virtual bool lastSolveConverged() const override
Whether or not the last solve converged.
bool execMultiApps(ExecFlagType type, bool auto_advance=true)
Execute the MultiApps associated with the ExecFlagType.
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.
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:1801
virtual void init()
Initialize the time stepper.
Definition: TimeStepper.C:65
virtual std::size_t numSolverSystems() const override
bool & _at_sync_point
const ExecFlagType EXEC_FINAL
Definition: Moose.C:46
Real getCurrentDT()
Get the current_dt.
Definition: TimeStepper.h:85
void ErrorVector unsigned int
std::unique_ptr< FixedPointSolve > _fixed_point_solve
Definition: Executioner.h:151
virtual void outputStep(ExecFlagType type)
Output the current step.
int & _t_step
Current timestep.
Real _next_interval_output_time
void setStartTime(Real time)
Set the starting time for the simulation.
Definition: MooseApp.C:2429
void parentOutputPositionChanged() override
Can be used by subclasses to call parentOutputPositionChanged() on the underlying FEProblemBase...
virtual bool adaptMesh()
FEProblemBase & _fe_problem
Definition: Executioner.h:148
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
const ExecFlagType EXEC_INITIAL
Definition: Moose.C:30