https://mooseframework.inl.gov
ParsedChainControl.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 "ParsedChainControl.h"
12 
14 
17 {
20 
21  params.addClassDescription(
22  "Parses and evaluates a function expression to populate a control value.");
23 
24  params.addRequiredCustomTypeParam<std::string>(
25  "expression", "FunctionExpression", "Expression to parse to create the function to evaluate");
26  params.addParam<Point>("point", Point(), "Spatial point at which to evaluate the function");
27 
28  return params;
29 }
30 
32  : ChainControl(parameters),
33  MooseParsedFunctionBase(parameters),
34  _function_expression(verifyFunction(getParam<std::string>("expression"))),
35  _value(declareChainControlData<Real>("value")),
36  _point(getParam<Point>("point"))
37 {
38 }
39 
40 void
42 {
43  if (!_function_ptr)
44  {
45  THREAD_ID tid = 0;
46  if (isParamValid("_tid"))
47  tid = getParam<THREAD_ID>("_tid");
48 
49  _function_ptr = std::make_unique<ChainControlParsedFunctionWrapper>(
51  }
52 }
53 
54 void
56 {
57  buildFunction();
58 
59  // Add dependencies for the chain control data used in the function expression
60  for (auto & data_ptr : _function_ptr->getRealChainControlData())
61  addChainControlDataDependency(data_ptr->name());
62  for (auto & data_ptr : _function_ptr->getBoolChainControlData())
63  addChainControlDataDependency(data_ptr->name());
64 }
65 
66 void
68 {
69  _value = _function_ptr->evaluate(_t, _point);
70 }
ParsedChainControl(const InputParameters &parameters)
const std::string _function_expression
Function expression to parse and evaluate.
static InputParameters validParams()
Adds user facing parameters for parsed function.
virtual void init() override
Initialization that occurs in ChainControlSetupAction, right before the dependencies are added...
std::unique_ptr< ChainControlParsedFunctionWrapper > _function_ptr
Pointer to the Parsed chain control function.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
FEProblemBase & _pfb_feproblem
Reference to the FEProblemBase class for this object.
const std::vector< std::string > _vals
Values passed by the user, they may be Reals for Postprocessors.
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition: MooseBase.h:45
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
const Point _point
Spatial point at which to evaluate the function.
Parses and evaluates a function expression to populate a control value.
static InputParameters validParams()
Definition: ChainControl.C:14
registerMooseObject("MooseApp", ParsedChainControl)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void execute() override
Execute the control.
static InputParameters validParams()
Class constructor for the interface.
void addChainControlDataDependency(const std::string &data_name)
Adds a chain control data dependency into the list.
Definition: ChainControl.C:24
void addRequiredCustomTypeParam(const std::string &name, const std::string &custom_type, const std::string &doc_string)
These methods add an option parameter and with a customer type to the InputParameters object...
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void buildFunction()
Builds the function that will be evaluated by this control.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
const std::vector< std::string > _vars
Variables passed to libMesh::ParsedFunction.
Real & _value
Control value to populate.
unsigned int THREAD_ID
Definition: MooseTypes.h:209
Control that additionally provides the capability to produce/consume data values, to allow control op...
Definition: ChainControl.h:21