https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ParsedFunctionControl.C
Go to the documentation of this file.
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
12
14
17{
20 params.addRequiredCustomTypeParam<std::string>(
21 "function", "FunctionExpression", "The function to be evaluated by this control.");
22 params.addClassDescription("Control that evaluates a parsed function");
23 return params;
24}
25
27 : THMControl(parameters),
28 MooseParsedFunctionBase(parameters),
29 _function(verifyFunction(getParam<std::string>("function"))),
30 _value(declareComponentControlData<Real>("value"))
31{
32}
33
34void
36{
37 if (!_function_ptr)
38 {
39 THREAD_ID tid = 0;
40 if (isParamValid("_tid"))
41 tid = getParam<THREAD_ID>("_tid");
42
43 _function_ptr = std::make_unique<THMParsedFunctionWrapper>(
45 }
46}
47
48void
53
54void
56{
58
59 // establish dependency so that the control data graph is properly evaluated
60 for (auto & ctrl_name : _function_ptr->getRealControlData())
61 getControlDataByName<Real>(ctrl_name->name());
62 for (auto & ctrl_name : _function_ptr->getBoolControlData())
63 getControlDataByName<bool>(ctrl_name->name());
64}
65
66void
68{
69 _value = _function_ptr->evaluate(_t, Point(0., 0., 0.));
70}
unsigned int THREAD_ID
registerMooseObject("ThermalHydraulicsApp", ParsedFunctionControl)
void addRequiredCustomTypeParam(const std::string &name, const std::string &custom_type, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
bool isParamValid(const std::string &name) const
const std::vector< std::string > _vals
FEProblemBase & _pfb_feproblem
static InputParameters validParams()
const std::vector< std::string > _vars
This control block takes a parsed function and evaluates it.
void buildFunction()
Build the function that will be evaluated by this control.
virtual void execute() override
virtual void init() override
std::string _function
The user-defined function to be evaluated.
std::unique_ptr< THMParsedFunctionWrapper > _function_ptr
Pointer to the Parsed function wrapper object.
static InputParameters validParams()
ParsedFunctionControl(const InputParameters &parameters)
virtual void initialSetup() override
Real & _value
The function value.
static InputParameters validParams()
Definition THMControl.C:13
THMProblem * _sim
Definition THMControl.h:90
Real & _t