www.mooseframework.org
MooseParsedFunction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "MooseError.h"
16 
17 // MOOSE includes
18 #include "InputParameters.h"
19 #include "MooseParsedFunction.h"
21 
22 template <>
25 {
28  params.addRequiredCustomTypeParam<std::string>(
29  "value", "FunctionExpression", "The user defined function.");
30  return params;
31 }
32 
34  : Function(parameters),
35  MooseParsedFunctionBase(parameters),
36  _value(verifyFunction(getParam<std::string>("value")))
37 {
38 }
39 
40 Real
41 MooseParsedFunction::value(Real t, const Point & p)
42 {
43  return _function_ptr->evaluate<Real>(t, p);
44 }
45 
47 MooseParsedFunction::gradient(Real t, const Point & p)
48 {
49  return _function_ptr->evaluateGradient(t, p);
50 }
51 
52 Real
53 MooseParsedFunction::timeDerivative(Real t, const Point & p)
54 {
55  return _function_ptr->evaluateDot(t, p);
56 }
57 
59 MooseParsedFunction::vectorValue(Real /*t*/, const Point & /*p*/)
60 {
61  mooseError("The vectorValue method is not defined in ParsedFunction");
62 }
63 
64 void
66 {
67  if (!_function_ptr)
68  {
69  THREAD_ID tid = 0;
70  if (isParamValid("_tid"))
71  tid = getParam<THREAD_ID>("_tid");
72 
74  libmesh_make_unique<MooseParsedFunctionWrapper>(_pfb_feproblem, _value, _vars, _vals, tid);
75  }
76 }
std::unique_ptr< MooseParsedFunctionWrapper > _function_ptr
Pointer to the Parsed function wrapper object for the scalar.
RealVectorValue RealGradient
Definition: Assembly.h:43
Base class for function objects.
Definition: Function.h:46
Adds user facing parameters for parsed function.
VectorValue< Real > RealVectorValue
Definition: Assembly.h:40
MooseParsedFunction(const InputParameters &parameters)
Created from MooseSystem via the FunctionFactory.
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.
virtual void initialSetup() override
Creates the parsed function.
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.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseObject.h:67
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...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
const std::vector< std::string > _vars
Variables passed to libMesh::ParsedFunction.
InputParameters validParams< Function >()
Definition: Function.C:19
virtual RealGradient gradient(Real t, const Point &p) override
Evaluate the gradient of the function.
unsigned int THREAD_ID
Definition: MooseTypes.h:79