https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MooseParsedFunctionBase Class Reference

Adds user facing parameters for parsed function. More...

#include <MooseParsedFunctionBase.h>

Inheritance diagram for MooseParsedFunctionBase:
[legend]

Public Member Functions

 MooseParsedFunctionBase (const InputParameters &parameters)
 
virtual ~MooseParsedFunctionBase ()
 Class destructor.
 

Static Public Member Functions

static InputParameters validParams ()
 Class constructor for the interface.
 

Protected Member Functions

std::string verifyFunction (const std::string &function_str)
 A helper method to check if the function value contains quotes.
 

Protected Attributes

FEProblemBase_pfb_feproblem
 Reference to the FEProblemBase class for this object.
 
const std::vector< std::string > _vars
 Variables passed to libMesh::ParsedFunction.
 
const std::vector< std::string > _vals
 Values passed by the user, they may be Reals for Postprocessors.
 
std::unique_ptr< MooseParsedFunctionWrapper_function_ptr
 Pointer to the Parsed function wrapper object for the scalar.
 

Detailed Description

Adds user facing parameters for parsed function.

See also
ParsedFunction ParsedVectorFunction ParsedGradFunction

Definition at line 37 of file MooseParsedFunctionBase.h.

Constructor & Destructor Documentation

◆ MooseParsedFunctionBase()

MooseParsedFunctionBase::MooseParsedFunctionBase ( const InputParameters parameters)

Definition at line 32 of file MooseParsedFunctionBase.C.

33 : _pfb_feproblem(*parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
34 _vars(parameters.get<std::vector<std::string>>("symbol_names")),
35 _vals(parameters.get<std::vector<std::string>>("symbol_values"))
36{
37 if (_vars.size() != _vals.size())
38 mooseError("Number of symbol_names must match the number of symbol_values!");
39
40 // Loop through the variables assigned by the user and give an error if x,y,z,t are used
41 for (const auto & var : _vars)
42 if (var.find_first_of("xyzt") != std::string::npos && var.size() == 1)
43 mooseError("The variables \"x, y, z, and t\" in the ParsedFunction are pre-declared for use "
44 "and must not be declared in \"symbol_names\"");
45}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller.
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.
const std::vector< std::string > _vars
Variables passed to libMesh::ParsedFunction.

◆ ~MooseParsedFunctionBase()

MooseParsedFunctionBase::~MooseParsedFunctionBase ( )
virtual

Class destructor.

Definition at line 47 of file MooseParsedFunctionBase.C.

47{}

Member Function Documentation

◆ validParams()

InputParameters MooseParsedFunctionBase::validParams ( )
static

Class constructor for the interface.

The first parameter, 'name' is not currently used.

Parameters
parametersInput parameters from the object, it must contain '_fe_problem'

Definition at line 18 of file MooseParsedFunctionBase.C.

19{
21 params.addParam<std::vector<std::string>>(
22 "symbol_names",
23 "Symbols (excluding t,x,y,z) that are bound to the values provided by the corresponding "
24 "items in the symbol_values vector.");
25 params.addParam<std::vector<std::string>>(
26 "symbol_values",
27 "Constant numeric values, postprocessor names, function names, and scalar variables "
28 "corresponding to the symbols in symbol_names.");
29 return params;
30}
InputParameters emptyInputParameters()
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.

Referenced by ParsedChainControl::validParams(), MooseParsedFunction::validParams(), MooseParsedGradFunction::validParams(), and MooseParsedVectorFunction::validParams().

◆ verifyFunction()

std::string MooseParsedFunctionBase::verifyFunction ( const std::string &  function_str)
protected

A helper method to check if the function value contains quotes.

This method should be called from within the initialization list of the object inheriting the MooseParsedFunctionInterface

Parameters
function_strThe name of the ParsedFunction
Returns
The vector of strings, if the input function is valid
See also
ParsedFunction

Definition at line 50 of file MooseParsedFunctionBase.C.

51{
52 // Throws an error if quotes are found
53 if (function_str.find("\"") != std::string::npos)
54 mooseError("The expression in ParsedFunction contains quotes which cannot be properly parsed");
55
56 // Return the input equation (no error)
57 return function_str;
58}

Member Data Documentation

◆ _function_ptr

std::unique_ptr<MooseParsedFunctionWrapper> MooseParsedFunctionBase::_function_ptr
protected

◆ _pfb_feproblem

FEProblemBase& MooseParsedFunctionBase::_pfb_feproblem
protected

◆ _vals

const std::vector<std::string> MooseParsedFunctionBase::_vals
protected

◆ _vars

const std::vector<std::string> MooseParsedFunctionBase::_vars
protected

The documentation for this class was generated from the following files: