https://mooseframework.inl.gov
AddTimeStepperAction.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 "AddTimeStepperAction.h"
11 #include "TimeStepper.h"
12 #include "FEProblemBase.h"
13 #include "TransientBase.h"
14 
15 registerMooseAction("MooseApp", AddTimeStepperAction, "add_time_stepper");
16 registerMooseAction("MooseApp", AddTimeStepperAction, "add_time_steppers");
17 
20 {
22  params.addClassDescription("Add a TimeStepper object to the simulation.");
23  return params;
24 }
25 
27  : MooseObjectAction(params)
28 {
29 }
30 
31 void
33 {
34  std::string name;
35  // Task: add_time_stepper corresponding to [TimeStepper] block
36  if (_current_task == "add_time_stepper")
37  name = _type;
38  // Task: add_time_steppers corresponding to [TimeSteppers] block
39  else
40  name = _name;
41 
42  TransientBase * transient = dynamic_cast<TransientBase *>(_app.getExecutioner());
43  if (!transient)
44  mooseError("Cannot add TimeSteppers without a Transient executioner");
45  _moose_object_pars.set<TransientBase *>("_executioner") = transient;
46 
47  auto ts =
48  _problem->addObject<TimeStepper>(_type, name, _moose_object_pars, /* threaded = */ false)[0];
49 
50  if (name == "TimeStepper" || name == "CompositionDT")
51  ts->mooseError("The user-defined time stepper name '", name, "' is a reserved name");
52 }
AddTimeStepperAction(const InputParameters &params)
static InputParameters validParams()
static InputParameters validParams()
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Base class for time stepping.
Definition: TimeStepper.h:22
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
Add all timestepper(s) info from input.
const std::string & _current_task
The current action (even though we have separate instances for each action)
Definition: Action.h:162
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
Definition: TransientBase.h:27
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:84
const std::string _name
The name of this class.
Definition: MooseBase.h:90
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition: MooseApp.C:2118
std::string _type
The Object type that is being created.
InputParameters _moose_object_pars
The parameters for the object to be created.
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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...
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:168
registerMooseAction("MooseApp", AddTimeStepperAction, "add_time_stepper")