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 "ParsedChainControl.h" 11 : #include "ChainControlParsedFunctionWrapper.h" 12 : 13 : registerMooseObject("MooseApp", ParsedChainControl); 14 : 15 : InputParameters 16 14345 : ParsedChainControl::validParams() 17 : { 18 14345 : InputParameters params = ChainControl::validParams(); 19 14345 : params += MooseParsedFunctionBase::validParams(); 20 : 21 14345 : params.addClassDescription( 22 : "Parses and evaluates a function expression to populate a control value."); 23 : 24 14345 : params.addRequiredCustomTypeParam<std::string>( 25 : "expression", "FunctionExpression", "Expression to parse to create the function to evaluate"); 26 14345 : params.addParam<Point>("point", Point(), "Spatial point at which to evaluate the function"); 27 : 28 14345 : return params; 29 0 : } 30 : 31 40 : ParsedChainControl::ParsedChainControl(const InputParameters & parameters) 32 : : ChainControl(parameters), 33 : MooseParsedFunctionBase(parameters), 34 40 : _function_expression(verifyFunction(getParam<std::string>("expression"))), 35 40 : _value(declareChainControlData<Real>("value")), 36 80 : _point(getParam<Point>("point")) 37 : { 38 40 : } 39 : 40 : void 41 40 : ParsedChainControl::buildFunction() 42 : { 43 40 : if (!_function_ptr) 44 : { 45 40 : THREAD_ID tid = 0; 46 40 : if (isParamValid("_tid")) 47 40 : tid = getParam<THREAD_ID>("_tid"); 48 : 49 76 : _function_ptr = std::make_unique<ChainControlParsedFunctionWrapper>( 50 76 : getMooseApp(), _pfb_feproblem, _function_expression, _vars, _vals, tid); 51 : } 52 36 : } 53 : 54 : void 55 40 : ParsedChainControl::init() 56 : { 57 40 : buildFunction(); 58 : 59 : // Add dependencies for the chain control data used in the function expression 60 60 : for (auto & data_ptr : _function_ptr->getRealChainControlData()) 61 60 : addChainControlDataDependency(data_ptr->name()); 62 60 : for (auto & data_ptr : _function_ptr->getBoolChainControlData()) 63 60 : addChainControlDataDependency(data_ptr->name()); 64 36 : } 65 : 66 : void 67 1169 : ParsedChainControl::execute() 68 : { 69 1169 : _value = _function_ptr->evaluate(_t, _point); 70 1169 : }