https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MooseParsedVectorFunction.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", MooseParsedVectorFunction, "ParsedVectorFunction");
14
17{
21 "Returns a vector function based on string descriptions for each component.");
22 params.addParam<std::string>("expression_x", "0", "x-component of function.");
23 params.addParam<std::string>("expression_y", "0", "y-component of function.");
24 params.addParam<std::string>("expression_z", "0", "z-component of function.");
25 params.addParam<std::string>("curl_x", "0", "x-component of curl of function.");
26 params.addParam<std::string>("curl_y", "0", "y-component of curl of function.");
27 params.addParam<std::string>("curl_z", "0", "z-component of curl of function.");
28 params.addParam<std::string>("div", "0", "divergence of function.");
29 return params;
30}
31
33 : Function(parameters),
34 MooseParsedFunctionBase(parameters),
35 _vector_value(verifyFunction(std::string("{") + getParam<std::string>("expression_x") + "}{" +
36 getParam<std::string>("expression_y") + "}{" +
37 getParam<std::string>("expression_z") + "}")),
38 _curl_value(verifyFunction(std::string("{") + getParam<std::string>("curl_x") + "}{" +
39 getParam<std::string>("curl_y") + "}{" +
40 getParam<std::string>("curl_z") + "}")),
41 _div_value(verifyFunction(getParam<std::string>("div")))
42{
43}
44
45RealVectorValue
46MooseParsedVectorFunction::vectorValue(Real t, const Point & p) const
47{
48 return _function_ptr->evaluate<RealVectorValue>(t, p);
49}
50
51RealVectorValue
52MooseParsedVectorFunction::curl(Real t, const Point & p) const
53{
54 return _curl_function_ptr->evaluate<RealVectorValue>(t, p);
55}
56
57Real
58MooseParsedVectorFunction::div(Real t, const Point & p) const
59{
60 return _div_function_ptr->evaluate<Real>(t, p);
61}
62
63RealGradient
64MooseParsedVectorFunction::gradient(Real /*t*/, const Point & /*p*/) const
65{
66 mooseError("The gradient method is not defined in MooseParsedVectorFunction");
67}
68
69void
71{
72 THREAD_ID tid = isParamValid("_tid") ? getParam<THREAD_ID>("_tid") : 0;
73
74 if (!_function_ptr)
75 _function_ptr = std::make_unique<MooseParsedFunctionWrapper>(
77
79 _curl_function_ptr = std::make_unique<MooseParsedFunctionWrapper>(
81
84 std::make_unique<MooseParsedFunctionWrapper>(_pfb_feproblem, _div_value, _vars, _vals, tid);
85}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObjectAliased("MooseApp", MooseParsedVectorFunction, "ParsedVectorFunction")
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 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 returns a vector function.
std::string _curl_value
Storage for curl input function(s), in format ready for libMesh.
MooseParsedVectorFunction(const InputParameters &parameters)
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,...
std::unique_ptr< MooseParsedFunctionWrapper > _div_function_ptr
Pointer to the Parsed function wrapper object for the div.
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...
virtual RealGradient gradient(Real t, const Point &p) const override
Function objects can optionally provide a gradient at a point.
std::string _vector_value
Storage for vector input function(s), in format ready for libMesh.
static InputParameters validParams()
Class constructor.
std::unique_ptr< MooseParsedFunctionWrapper > _curl_function_ptr
Pointer to the Parsed function wrapper object for the curl.
std::string _div_value
Storage for div input function, in format ready for libMesh.
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...