https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MooseParsedGradFunction.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
12
13registerMooseObjectAliased("MooseApp", MooseParsedGradFunction, "ParsedGradFunction");
14
17{
19 params.addClassDescription("Defines a function and its gradient using input file parameters.");
21 params.addDeprecatedParam<std::string>(
22 "value", "User defined function.", "Use 'expression' instead.");
23 // TODO Make required once deprecation is handled + add 0 default, see #19119
24 params.addParam<std::string>("expression", "User defined function.");
25 params.addParam<std::string>("grad_x", "0", "Partial derivative with respect to x.");
26 params.addParam<std::string>("grad_y", "0", "Partial derivative with respect to y.");
27 params.addParam<std::string>("grad_z", "0", "Partial derivative with respect to z.");
28 return params;
29}
30
32 : Function(parameters),
33 MooseParsedFunctionBase(parameters),
34 _value(verifyFunction(getRenamedParam<std::string>("value", "expression"))),
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
43Real
44MooseParsedGradFunction::value(Real t, const Point & p) const
45{
46 // Return a scalar value
47 return _function_ptr->evaluate<Real>(t, p);
48}
49
50RealGradient
51MooseParsedGradFunction::gradient(Real t, const Point & p) const
52{
53 // Return gradient (RealGradient = RealVectorValue)
54 return _grad_function_ptr->evaluate<RealVectorValue>(t, p);
55}
56
57RealVectorValue
58MooseParsedGradFunction::vectorValue(Real /*t*/, const Point & /*p*/) const
59{
60 mooseError("The vectorValue method is not defined in ParsedGradFunction");
61}
62
63void
65{
66 THREAD_ID tid = 0;
67 if (isParamValid("_tid"))
68 tid = getParam<THREAD_ID>("_tid");
69
70 if (!_function_ptr)
72 std::make_unique<MooseParsedFunctionWrapper>(_pfb_feproblem, _value, _vars, _vals, tid);
73
75 _grad_function_ptr = std::make_unique<MooseParsedFunctionWrapper>(
77}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObjectAliased("MooseApp", MooseParsedGradFunction, "ParsedGradFunction")
unsigned int THREAD_ID
Definition MooseTypes.h:237
Base class for function objects.
Definition Function.h:30
static InputParameters validParams()
Class constructor.
Definition Function.C:16
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
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.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
Adds user facing parameters for parsed function.
const std::vector< std::string > _vals
Values passed by the user, they may be Reals for Postprocessors.
FEProblemBase & _pfb_feproblem
Reference to the FEProblemBase class for this object.
std::unique_ptr< MooseParsedFunctionWrapper > _function_ptr
Pointer to the Parsed function wrapper object for the scalar.
static InputParameters validParams()
Class constructor for the interface.
const std::vector< std::string > _vars
Variables passed to libMesh::ParsedFunction.
This class is similar to ParsedFunction except it also supports returning the gradient of the functio...
virtual RealVectorValue vectorValue(Real t, const Point &p) const override
Method invalid for ParsedGradFunction.
virtual ~MooseParsedGradFunction()
Destructor necessary for std::unique_ptr usage.
virtual RealGradient gradient(Real t, const Point &p) const override
Compute the gradient of the function.
std::string _grad_value
String for the gradient, vector function string.
virtual void initialSetup() override
Creates two libMesh::ParsedFunction objects for returning a vector via the 'gradient' method and a sc...
virtual Real value(Real t, const Point &p) const override
Return a scalar value from the function.
MooseParsedGradFunction(const InputParameters &parameters)
static InputParameters validParams()
Class constructor.
std::unique_ptr< MooseParsedFunctionWrapper > _grad_function_ptr
Pointer to the Parsed function wrapper object for the gradient.
std::string _value
String for the scalar function string.