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 
15 template <>
18 {
21  params.addParam<std::string>("value_x", "0", "x-component of function.");
22  params.addParam<std::string>("value_y", "0", "y-component of function.");
23  params.addParam<std::string>("value_z", "0", "z-component of function.");
24  params.addParam<std::string>("curl_x", "0", "x-component of curl of function.");
25  params.addParam<std::string>("curl_y", "0", "y-component of curl of function.");
26  params.addParam<std::string>("curl_z", "0", "z-component of curl of function.");
27  return params;
28 }
29 
31  : Function(parameters),
32  MooseParsedFunctionBase(parameters),
33  _vector_value(verifyFunction(std::string("{") + getParam<std::string>("value_x") + "}{" +
34  getParam<std::string>("value_y") + "}{" +
35  getParam<std::string>("value_z") + "}")),
36  _curl_value(verifyFunction(std::string("{") + getParam<std::string>("curl_x") + "}{" +
37  getParam<std::string>("curl_y") + "}{" +
38  getParam<std::string>("curl_z") + "}"))
39 {
40 }
41 
44 {
45  return _function_ptr->evaluate<RealVectorValue>(t, p);
46 }
47 
49 MooseParsedVectorFunction::vectorCurl(Real t, const Point & p)
50 {
51  return _curl_function_ptr->evaluate<RealVectorValue>(t, p);
52 }
53 
54 RealGradient
55 MooseParsedVectorFunction::gradient(Real /*t*/, const Point & /*p*/)
56 {
57  mooseError("The gradient method is not defined in MooseParsedVectorFunction");
58 }
59 
60 void
62 {
63  THREAD_ID tid = 0;
64  if (isParamValid("_tid"))
65  tid = getParam<THREAD_ID>("_tid");
66 
67  if (!_function_ptr)
68  _function_ptr = libmesh_make_unique<MooseParsedFunctionWrapper>(
70 
71  if (!_curl_function_ptr)
72  _curl_function_ptr = libmesh_make_unique<MooseParsedFunctionWrapper>(
74 }
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
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
Adds user facing parameters for parsed function.
virtual RealVectorValue vectorCurl(Real t, const Point &p) override
Override this to evaluate the curl of the vector function at a point (t,x,y,z), by default this retur...
virtual RealVectorValue vectorValue(Real t, const Point &p) override
Override this to evaluate the vector function at a point (t,x,y,z), by default this returns a zero ve...
VectorValue< Real > RealVectorValue
Definition: Assembly.h:31
InputParameters validParams< MooseParsedVectorFunction >()
registerMooseObjectAliased("MooseApp", MooseParsedVectorFunction, "ParsedVectorFunction")
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.
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
std::string _vector_value
Storage for gradient, vector input function(s), in format ready for libMesh.
std::string _curl_value
Storage for gradient, curl input function(s), in format ready for libMesh.
InputParameters validParams< MooseParsedFunctionBase >()
Creates the &#39;vars&#39; and &#39;vals&#39; parameters used by all ParsedFunctions, the parameters provided from th...
virtual RealGradient gradient(Real t, const Point &p) override
Function objects can optionally provide a gradient at a point.
MooseParsedVectorFunction(const InputParameters &parameters)
Class constructor.
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.
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
std::unique_ptr< MooseParsedFunctionWrapper > _curl_function_ptr
Pointer to the Parsed function wrapper object for the curl.
This class is similar to ParsedFunction except it returns a vector function.
unsigned int THREAD_ID
Definition: MooseTypes.h:161