Line data Source code
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 : // MOOSE includes 11 : #include "Control.h" 12 : #include "InputParameterWarehouse.h" 13 : #include "FEProblemBase.h" 14 : 15 : InputParameters 16 318384 : Control::validParams() 17 : { 18 318384 : InputParameters params = MooseObject::validParams(); 19 318384 : params += TransientInterface::validParams(); 20 318384 : params += SetupInterface::validParams(); 21 318384 : params += FunctionInterface::validParams(); 22 : 23 318384 : ExecFlagEnum & exec_enum = params.set<ExecFlagEnum>("execute_on", true); 24 318384 : exec_enum.addAvailableFlags(EXEC_PRE_MULTIAPP_SETUP); 25 955152 : exec_enum = {EXEC_INITIAL, EXEC_TIMESTEP_END}; 26 : 27 636768 : params.registerBase("Control"); 28 : 29 955152 : params.addParam<std::vector<std::string>>( 30 : "depends_on", 31 : {}, 32 : "The Controls that this control relies upon (i.e. must execute before this one)"); 33 : 34 318384 : return params; 35 318384 : } 36 : 37 1518 : Control::Control(const InputParameters & parameters) 38 : : MooseObject(parameters), 39 : PerfGraphInterface(this), 40 : TransientInterface(this), 41 : SetupInterface(this), 42 : FunctionInterface(this), 43 : UserObjectInterface(this), 44 : Restartable(this, "Controls"), 45 : PostprocessorInterface(this), 46 : VectorPostprocessorInterface(this), 47 : ReporterInterface(this), 48 4554 : _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")), 49 3036 : _depends_on(getParam<std::vector<std::string>>("depends_on")), 50 6072 : _input_parameter_warehouse(_app.getInputParameterWarehouse()) 51 : { 52 1518 : if (getExecuteOnEnum().contains(EXEC_TIMESTEP_END) && _app.testReStep()) 53 117 : paramInfo("execute_on", 54 : "Controls executed on timestep_end often have undefined behavior when repeating " 55 : "timesteps."); 56 1518 : } 57 : 58 : MultiMooseEnum 59 0 : Control::getExecuteOptions() 60 : { 61 0 : ::mooseDeprecated("The 'getExecuteOptions' was replaced by the ExecFlagEnum class because MOOSE " 62 : "was updated to use this for the execute flags and the new function provides " 63 : "additional arguments for modification of the enum."); 64 0 : ExecFlagEnum execute_on = MooseUtils::getDefaultExecFlagEnum(); 65 0 : execute_on = {EXEC_INITIAL, EXEC_TIMESTEP_END}; 66 0 : return execute_on; 67 0 : } 68 : 69 : bool 70 128 : Control::hasControllableParameterByName(const std::string & name) const 71 : { 72 128 : MooseObjectParameterName param_name(name); 73 256 : return !_input_parameter_warehouse.getControllableParameter(param_name).empty(); 74 128 : } 75 : 76 : ControllableParameter 77 0 : Control::getControllableParameterByName(const std::string & param_name) 78 : { 79 0 : MooseObjectParameterName desired(param_name); 80 0 : return getControllableParameterByName(desired); 81 0 : } 82 : 83 : ControllableParameter 84 0 : Control::getControllableParameterByName(const std::string & tag, 85 : const std::string & object_name, 86 : const std::string & param_name) 87 : { 88 0 : MooseObjectParameterName desired(tag, object_name, param_name); 89 0 : return getControllableParameterByName(desired); 90 0 : } 91 : 92 : ControllableParameter 93 0 : Control::getControllableParameterByName(const MooseObjectName & object_name, 94 : const std::string & param_name) 95 : { 96 0 : MooseObjectParameterName desired(object_name, param_name); 97 0 : return getControllableParameterByName(desired); 98 0 : } 99 : 100 : ControllableParameter 101 11228 : Control::getControllableParameterByName(const MooseObjectParameterName & param_name) 102 : { 103 11228 : ControllableParameter out = _input_parameter_warehouse.getControllableParameter(param_name); 104 11228 : if (out.empty()) 105 12 : mooseError("The desired parameter '", 106 : param_name, 107 : "' was not located for the '", 108 12 : name(), 109 : "' object, it either does not exist or has not been declared as controllable."); 110 11216 : out.checkExecuteOnType(_fe_problem.getCurrentExecuteOnFlag()); 111 11212 : return out; 112 0 : }