www.mooseframework.org
MooseParsedVectorFunction.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 
12 
13 registerMooseObjectAliased("MooseApp", MooseParsedVectorFunction, "ParsedVectorFunction");
14 
17 {
20  params.addClassDescription(
21  "Returns a vector function based on string descriptions for each component.");
22  params.addDeprecatedParam<std::string>(
23  "value_x", "x-component of function.", "value_x is deprecated, use expression_x");
24  params.addDeprecatedParam<std::string>(
25  "value_y", "y-component of function.", "value_y is deprecated, use expression_y");
26  params.addDeprecatedParam<std::string>(
27  "value_z", "z-component of function.", "value_z is deprecated, use expression_z");
28  params.addParam<std::string>("expression_x", "0", "x-component of function.");
29  params.addParam<std::string>("expression_y", "0", "y-component of function.");
30  params.addParam<std::string>("expression_z", "0", "z-component of function.");
31  params.addParam<std::string>("curl_x", "0", "x-component of curl of function.");
32  params.addParam<std::string>("curl_y", "0", "y-component of curl of function.");
33  params.addParam<std::string>("curl_z", "0", "z-component of curl of function.");
34  params.addParam<std::string>("div", "0", "divergence of function.");
35  return params;
36 }
37 
39  : Function(parameters),
40  MooseParsedFunctionBase(parameters),
41  _vector_value(verifyFunction(std::string("{") +
42  getRenamedParam<std::string>("value_x", "expression_x") + "}{" +
43  getRenamedParam<std::string>("value_y", "expression_y") + "}{" +
44  getRenamedParam<std::string>("value_z", "expression_z") + "}")),
45  _curl_value(verifyFunction(std::string("{") + getParam<std::string>("curl_x") + "}{" +
46  getParam<std::string>("curl_y") + "}{" +
47  getParam<std::string>("curl_z") + "}")),
48  _div_value(verifyFunction(getParam<std::string>("div")))
49 {
50 }
51 
53 MooseParsedVectorFunction::vectorValue(Real t, const Point & p) const
54 {
55  return _function_ptr->evaluate<RealVectorValue>(t, p);
56 }
57 
59 MooseParsedVectorFunction::curl(Real t, const Point & p) const
60 {
61  return _curl_function_ptr->evaluate<RealVectorValue>(t, p);
62 }
63 
64 Real
65 MooseParsedVectorFunction::div(Real t, const Point & p) const
66 {
67  return _div_function_ptr->evaluate<Real>(t, p);
68 }
69 
71 MooseParsedVectorFunction::gradient(Real /*t*/, const Point & /*p*/) const
72 {
73  mooseError("The gradient method is not defined in MooseParsedVectorFunction");
74 }
75 
76 void
78 {
79  THREAD_ID tid = 0;
80  if (isParamValid("_tid"))
81  tid = getParam<THREAD_ID>("_tid");
82 
83  if (!_function_ptr)
84  _function_ptr = std::make_unique<MooseParsedFunctionWrapper>(
86 
87  if (!_curl_function_ptr)
88  _curl_function_ptr = std::make_unique<MooseParsedFunctionWrapper>(
90 
91  if (!_div_function_ptr)
93  std::make_unique<MooseParsedFunctionWrapper>(_pfb_feproblem, _div_value, _vars, _vals, tid);
94 }
std::unique_ptr< MooseParsedFunctionWrapper > _function_ptr
Pointer to the Parsed function wrapper object for the scalar.
Base class for function objects.
Definition: Function.h:37
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
virtual RealVectorValue curl(Real t, const Point &p) const override
Override this to evaluate the curl of the vector function at a point (t,x,y,z), by default this retur...
Creates the &#39;vars&#39; and &#39;vals&#39; parameters used by all ParsedFunctions, the parameters provided from th...
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
registerMooseObjectAliased("MooseApp", MooseParsedVectorFunction, "ParsedVectorFunction")
virtual RealVectorValue vectorValue(Real t, const Point &p) const override
Override this to evaluate the vector function at a point (t,x,y,z), by default this returns a zero ve...
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.
std::string _vector_value
Storage for vector input function(s), in format ready for libMesh.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
static InputParameters validParams()
Class constructor.
std::string _curl_value
Storage for curl input function(s), in format ready for libMesh.
virtual Real div(Real t, const Point &p) const override
Override this to evaluate the divergence of the vector function at a point (t,x,y,z), by default this returns zero, you must override it.
virtual RealGradient gradient(Real t, const Point &p) const override
Function objects can optionally provide a gradient at a point.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
Class constructor for the interface.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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...
MooseParsedVectorFunction(const InputParameters &parameters)
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...
const std::vector< std::string > _vars
Variables passed to libMesh::ParsedFunction.
std::unique_ptr< MooseParsedFunctionWrapper > _curl_function_ptr
Pointer to the Parsed function wrapper object for the curl.
static InputParameters validParams()
Class constructor.
Definition: Function.C:15
This class is similar to ParsedFunction except it returns a vector function.
unsigned int THREAD_ID
Definition: MooseTypes.h:198
std::string _div_value
Storage for div input function, in format ready for libMesh.
std::unique_ptr< MooseParsedFunctionWrapper > _div_function_ptr
Pointer to the Parsed function wrapper object for the div.