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 : #include "ParsedFunctionControl.h" 11 : #include "THMParsedFunctionWrapper.h" 12 : 13 : registerMooseObject("ThermalHydraulicsApp", ParsedFunctionControl); 14 : 15 : InputParameters 16 60 : ParsedFunctionControl::validParams() 17 : { 18 60 : InputParameters params = THMControl::validParams(); 19 60 : params += MooseParsedFunctionBase::validParams(); 20 120 : params.addRequiredCustomTypeParam<std::string>( 21 : "function", "FunctionExpression", "The function to be evaluated by this control."); 22 60 : params.addClassDescription("Control that evaluates a parsed function"); 23 60 : return params; 24 0 : } 25 : 26 30 : ParsedFunctionControl::ParsedFunctionControl(const InputParameters & parameters) 27 : : THMControl(parameters), 28 : MooseParsedFunctionBase(parameters), 29 30 : _function(verifyFunction(getParam<std::string>("function"))), 30 60 : _value(declareComponentControlData<Real>("value")) 31 : { 32 30 : } 33 : 34 : void 35 48 : ParsedFunctionControl::buildFunction() 36 : { 37 48 : if (!_function_ptr) 38 : { 39 30 : THREAD_ID tid = 0; 40 60 : if (isParamValid("_tid")) 41 60 : tid = getParam<THREAD_ID>("_tid"); 42 : 43 30 : _function_ptr = std::make_unique<THMParsedFunctionWrapper>( 44 30 : *_sim, _pfb_feproblem, _function, _vars, _vals, tid); 45 : } 46 48 : } 47 : 48 : void 49 18 : ParsedFunctionControl::initialSetup() 50 : { 51 18 : buildFunction(); 52 18 : } 53 : 54 : void 55 30 : ParsedFunctionControl::init() 56 : { 57 30 : buildFunction(); 58 : 59 : // establish dependency so that the control data graph is properly evaluated 60 84 : for (auto & ctrl_name : _function_ptr->getRealControlData()) 61 54 : getControlDataByName<Real>(ctrl_name->name()); 62 48 : for (auto & ctrl_name : _function_ptr->getBoolControlData()) 63 18 : getControlDataByName<bool>(ctrl_name->name()); 64 30 : } 65 : 66 : void 67 44 : ParsedFunctionControl::execute() 68 : { 69 44 : _value = _function_ptr->evaluate(_t, Point(0., 0., 0.)); 70 44 : }