https://mooseframework.inl.gov
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 
10 #include "ParsedFunctionControl.h"
12 
13 registerMooseObject("ThermalHydraulicsApp", ParsedFunctionControl);
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 
34 void
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 
48 void
50 {
51  buildFunction();
52 }
53 
54 void
56 {
57  buildFunction();
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 
66 void
68 {
69  _value = _function_ptr->evaluate(_t, Point(0., 0., 0.));
70 }
std::string _function
The user-defined function to be evaluated.
This control block takes a parsed function and evaluates it.
FEProblemBase & _pfb_feproblem
const std::vector< std::string > _vals
registerMooseObject("ThermalHydraulicsApp", ParsedFunctionControl)
virtual void init() override
void buildFunction()
Build the function that will be evaluated by this control.
bool isParamValid(const std::string &name) const
virtual void initialSetup() override
Real & _value
The function value.
static InputParameters validParams()
Definition: THMControl.C:13
Real & _t
std::unique_ptr< THMParsedFunctionWrapper > _function_ptr
Pointer to the Parsed function wrapper object.
THMProblem * _sim
Definition: THMControl.h:90
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void execute() override
static InputParameters validParams()
static InputParameters validParams()
void addRequiredCustomTypeParam(const std::string &name, const std::string &custom_type, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const std::vector< std::string > _vars
ParsedFunctionControl(const InputParameters &parameters)
unsigned int THREAD_ID