www.mooseframework.org
Control.C
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 // MOOSE includes
11 #include "Control.h"
13 
16 {
19  params += SetupInterface::validParams();
21 
22  ExecFlagEnum & exec_enum = params.set<ExecFlagEnum>("execute_on", true);
24  exec_enum = {EXEC_INITIAL, EXEC_TIMESTEP_END};
25 
26  params.registerBase("Control");
27 
28  params.addParam<std::vector<std::string>>(
29  "depends_on",
30  {},
31  "The Controls that this control relies upon (i.e. must execute before this one)");
32 
33  return params;
34 }
35 
36 Control::Control(const InputParameters & parameters)
37  : MooseObject(parameters),
38  TransientInterface(this),
39  SetupInterface(this),
40  FunctionInterface(this),
41  UserObjectInterface(this),
42  Restartable(this, "Controls"),
45  _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
46  _depends_on(getParam<std::vector<std::string>>("depends_on")),
47  _input_parameter_warehouse(_app.getInputParameterWarehouse())
48 {
49 }
50 
53 {
54  ::mooseDeprecated("The 'getExecuteOptions' was replaced by the ExecFlagEnum class because MOOSE "
55  "was updated to use this for the execute flags and the new function provides "
56  "additional arguments for modification of the enum.");
58  execute_on = {EXEC_INITIAL, EXEC_TIMESTEP_END};
59  return execute_on;
60 }
61 
63 Control::getControllableParameterByName(const std::string & param_name)
64 {
65  MooseObjectParameterName desired(param_name);
66  return getControllableParameterByName(desired);
67 }
68 
71  const std::string & object_name,
72  const std::string & param_name)
73 {
74  MooseObjectParameterName desired(tag, object_name, param_name);
75  return getControllableParameterByName(desired);
76 }
77 
80  const std::string & param_name)
81 {
82  MooseObjectParameterName desired(object_name, param_name);
83  return getControllableParameterByName(desired);
84 }
85 
88 {
90  if (out.empty())
91  mooseError("The desired parameter '",
92  param_name,
93  "' was not located for the '",
94  name(),
95  "' object, it either does not exist or has not been declared as controllable.");
96  out.checkExecuteOnType(_fe_problem.getCurrentExecuteOnFlag());
97  return out;
98 }
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
A class for creating restricted objects.
Definition: Restartable.h:28
static InputParameters validParams()
Class constructor.
Definition: Control.C:15
void mooseDeprecated(Args &&... args) const
const ExecFlagType & getCurrentExecuteOnFlag() const
Return/set the current execution flag.
The ControllableParameter class is simply a set of ControllableItem objects.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
InputParameterWarehouse & _input_parameter_warehouse
A reference to the InputParameterWarehouse which is used for access the parameter objects...
Definition: Control.h:163
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
Add additional execute_on flags to the list of possible flags.
Definition: ExecFlagEnum.h:82
const ExecFlagType EXEC_TIMESTEP_END
Definition: Moose.C:32
static InputParameters validParams()
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:56
ExecFlagEnum getDefaultExecFlagEnum()
Return the default ExecFlagEnum for MOOSE.
Definition: MooseUtils.C:1053
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
Interface for objects that needs transient capabilities.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:33
const ExecFlagType EXEC_PRE_MULTIAPP_SETUP
Definition: Moose.C:46
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this object.
Definition: Control.h:72
ControllableParameter getControllableParameter(const MooseObjectParameterName &input) const
Returns a ControllableParameter object that contains all matches to ControllableItem objects for the ...
Interface for objects that need to use UserObjects.
static InputParameters validParams()
static MultiMooseEnum getExecuteOptions()
(DEPRECATED) Return the valid "execute_on" options for Control objects
Definition: Control.C:52
static InputParameters validParams()
Control(const InputParameters &parameters)
Definition: Control.C:36
OStreamProxy out
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
ControllableParameter getControllableParameterByName(const std::string &param_name)
Definition: Control.C:63
A class for storing an input parameter name.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
static InputParameters validParams()
Definition: MooseObject.C:24
A class for storing the names of MooseObject by tag and object name.
Interface for objects that need to use functions.
Interface class for classes which interact with Postprocessors.
const ExecFlagType EXEC_INITIAL
Definition: Moose.C:28