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 318266 : Control::validParams() 17 : { 18 318266 : InputParameters params = MooseObject::validParams(); 19 318266 : params += TransientInterface::validParams(); 20 318266 : params += SetupInterface::validParams(); 21 318266 : params += FunctionInterface::validParams(); 22 : 23 318266 : ExecFlagEnum & exec_enum = params.set<ExecFlagEnum>("execute_on", true); 24 318266 : exec_enum.addAvailableFlags(EXEC_PRE_MULTIAPP_SETUP); 25 954798 : exec_enum = {EXEC_INITIAL, EXEC_TIMESTEP_END}; 26 : 27 318266 : params.registerBase("Control"); 28 : 29 318266 : 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 318266 : return params; 35 318266 : } 36 : 37 1459 : 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 1459 : _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")), 48 1459 : _depends_on(getParam<std::vector<std::string>>("depends_on")), 49 2918 : _input_parameter_warehouse(_app.getInputParameterWarehouse()) 50 : { 51 1459 : if (getExecuteOnEnum().contains(EXEC_TIMESTEP_END) && _app.testReStep()) 52 35 : paramInfo("execute_on", 53 : "Controls executed on timestep_end often have undefined behavior when repeating " 54 : "timesteps."); 55 1459 : } 56 : 57 : MultiMooseEnum 58 0 : Control::getExecuteOptions() 59 : { 60 0 : ::mooseDeprecated("The 'getExecuteOptions' was replaced by the ExecFlagEnum class because MOOSE " 61 : "was updated to use this for the execute flags and the new function provides " 62 : "additional arguments for modification of the enum."); 63 0 : ExecFlagEnum execute_on = MooseUtils::getDefaultExecFlagEnum(); 64 0 : execute_on = {EXEC_INITIAL, EXEC_TIMESTEP_END}; 65 0 : return execute_on; 66 0 : } 67 : 68 : bool 69 112 : Control::hasControllableParameterByName(const std::string & name) const 70 : { 71 112 : MooseObjectParameterName param_name(name); 72 224 : return !_input_parameter_warehouse.getControllableParameter(param_name).empty(); 73 112 : } 74 : 75 : ControllableParameter 76 0 : Control::getControllableParameterByName(const std::string & param_name) 77 : { 78 0 : MooseObjectParameterName desired(param_name); 79 0 : return getControllableParameterByName(desired); 80 0 : } 81 : 82 : ControllableParameter 83 0 : Control::getControllableParameterByName(const std::string & tag, 84 : const std::string & object_name, 85 : const std::string & param_name) 86 : { 87 0 : MooseObjectParameterName desired(tag, object_name, param_name); 88 0 : return getControllableParameterByName(desired); 89 0 : } 90 : 91 : ControllableParameter 92 0 : Control::getControllableParameterByName(const MooseObjectName & object_name, 93 : const std::string & param_name) 94 : { 95 0 : MooseObjectParameterName desired(object_name, param_name); 96 0 : return getControllableParameterByName(desired); 97 0 : } 98 : 99 : ControllableParameter 100 11060 : Control::getControllableParameterByName(const MooseObjectParameterName & param_name) 101 : { 102 11060 : ControllableParameter out = _input_parameter_warehouse.getControllableParameter(param_name); 103 11060 : if (out.empty()) 104 24 : mooseError("The desired parameter '", 105 : param_name, 106 : "' was not located for the '", 107 12 : name(), 108 : "' object, it either does not exist or has not been declared as controllable."); 109 11048 : out.checkExecuteOnType(_fe_problem.getCurrentExecuteOnFlag()); 110 11044 : return out; 111 0 : }