www.mooseframework.org
MooseParsedFunction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "MooseError.h"
11 
12 // MOOSE includes
13 #include "InputParameters.h"
14 #include "MooseParsedFunction.h"
16 
17 registerMooseObjectAliased("MooseApp", MooseParsedFunction, "ParsedFunction");
18 
19 template <>
22 {
25  params.addRequiredCustomTypeParam<std::string>(
26  "value", "FunctionExpression", "The user defined function.");
27  return params;
28 }
29 
31  : Function(parameters),
32  MooseParsedFunctionBase(parameters),
33  _value(verifyFunction(getParam<std::string>("value")))
34 {
35 }
36 
37 Real
38 MooseParsedFunction::value(Real t, const Point & p)
39 {
40  return _function_ptr->evaluate<Real>(t, p);
41 }
42 
43 RealGradient
44 MooseParsedFunction::gradient(Real t, const Point & p)
45 {
46  return _function_ptr->evaluateGradient(t, p);
47 }
48 
49 Real
50 MooseParsedFunction::timeDerivative(Real t, const Point & p)
51 {
52  return _function_ptr->evaluateDot(t, p);
53 }
54 
56 MooseParsedFunction::vectorValue(Real /*t*/, const Point & /*p*/)
57 {
58  mooseError("The vectorValue method is not defined in ParsedFunction");
59 }
60 
61 void
63 {
64  if (!_function_ptr)
65  {
66  THREAD_ID tid = 0;
67  if (isParamValid("_tid"))
68  tid = getParam<THREAD_ID>("_tid");
69 
71  libmesh_make_unique<MooseParsedFunctionWrapper>(_pfb_feproblem, _value, _vars, _vals, tid);
72  }
73 }
std::unique_ptr< MooseParsedFunctionWrapper > _function_ptr
Pointer to the Parsed function wrapper object for the scalar.
Base class for function objects.
Definition: Function.h:40
Adds user facing parameters for parsed function.
MooseParsedFunction(const InputParameters &parameters)
Created from MooseSystem via the FunctionFactory.
VectorValue< Real > RealVectorValue
Definition: Assembly.h:31
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.
This class is used to evaluate symbolic equations passed in to Moose through the input file...
virtual void initialSetup() override
Creates the parsed function.
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
registerMooseObjectAliased("MooseApp", MooseParsedFunction, "ParsedFunction")
virtual RealVectorValue vectorValue(Real t, const Point &p) override
Method invalid for ParsedGradFunction.
InputParameters validParams< MooseParsedFunction >()
virtual Real value(Real t, const Point &pt) override
Evaluate the equation at the given location.
virtual Real timeDerivative(Real t, const Point &p) override
Evaluate the time derivative of the function.
std::string _value
The function defined by the user.
InputParameters validParams< MooseParsedFunctionBase >()
Creates the &#39;vars&#39; and &#39;vals&#39; parameters used by all ParsedFunctions, the parameters provided from th...
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...
const std::vector< std::string > _vars
Variables passed to libMesh::ParsedFunction.
InputParameters validParams< Function >()
Definition: Function.C:14
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseObject.h:89
virtual RealGradient gradient(Real t, const Point &p) override
Evaluate the gradient of the function.
unsigned int THREAD_ID
Definition: MooseTypes.h:161