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