www.mooseframework.org
MooseParsedGradFunction.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 
17 
18 template <>
21 {
24  params.addParam<std::string>("value", "0", "User defined function.");
25  params.addParam<std::string>("grad_x", "0", "Partial with respect to x.");
26  params.addParam<std::string>("grad_y", "0", "Partial with respect to y.");
27  params.addParam<std::string>("grad_z", "0", "Partial with respect to z.");
28  return params;
29 }
30 
32  : Function(parameters),
33  MooseParsedFunctionBase(parameters),
34  _value(verifyFunction(getParam<std::string>("value"))),
35  _grad_value(verifyFunction(std::string("{") + getParam<std::string>("grad_x") + "}{" +
36  getParam<std::string>("grad_y") + "}{" +
37  getParam<std::string>("grad_z") + "}"))
38 {
39 }
40 
42 
43 Real
44 MooseParsedGradFunction::value(Real t, const Point & p)
45 {
46  // Return a scalar value
47  return _function_ptr->evaluate<Real>(t, p);
48 }
49 
51 MooseParsedGradFunction::gradient(Real t, const Point & p)
52 {
53  // Return gradient (RealGradient = RealVectorValue)
54  return _grad_function_ptr->evaluate<RealVectorValue>(t, p);
55 }
56 
58 MooseParsedGradFunction::vectorValue(Real /*t*/, const Point & /*p*/)
59 {
60  mooseError("The vectorValue method is not defined in ParsedGradFunction");
61 }
62 
63 void
65 {
66  THREAD_ID tid = 0;
67  if (isParamValid("_tid"))
68  tid = getParam<THREAD_ID>("_tid");
69 
70  if (!_function_ptr)
72  libmesh_make_unique<MooseParsedFunctionWrapper>(_pfb_feproblem, _value, _vars, _vals, tid);
73 
74  if (!_grad_function_ptr)
75  _grad_function_ptr = libmesh_make_unique<MooseParsedFunctionWrapper>(
77 }
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
std::string _value
String for the scalar function string.
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.
MooseParsedGradFunction(const InputParameters &parameters)
Class constructor.
virtual void initialSetup() override
Creates two libMesh::ParsedFunction objects for returning a vector via the &#39;gradient&#39; method and a sc...
virtual RealGradient gradient(Real t, const Point &p) override
Compute the gradient of the function.
std::string _grad_value
String for the gradient, vector function string.
virtual Real value(Real t, const Point &p) override
Return a scalar value from the function.
InputParameters validParams< MooseParsedGradFunction >()
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseObject.h:67
InputParameters validParams< MooseParsedFunctionBase >()
Creates the &#39;vars&#39; and &#39;vals&#39; parameters used by all ParsedFunctions, the parameters provided from th...
virtual ~MooseParsedGradFunction()
Destructor necessary for std::unique_ptr usage.
std::unique_ptr< MooseParsedFunctionWrapper > _grad_function_ptr
Pointer to the Parsed function wrapper object for the gradient.
virtual RealVectorValue vectorValue(Real t, const Point &p) override
Method invalid for ParsedGradFunction.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string 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
unsigned int THREAD_ID
Definition: MooseTypes.h:79