www.mooseframework.org
MooseParsedFunctionBase.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
16 
17 // MOOSE includes
18 #include "InputParameters.h"
19 #include "MooseError.h"
21 
22 template <>
25 {
27  params.addParam<std::vector<std::string>>(
28  "vars", "The constant variables (excluding t,x,y,z) in the forcing function.");
29  params.addParam<std::vector<std::string>>(
30  "vals", "Constant numeric values or postprocessor names for vars.");
31  return params;
32 }
33 
35  : _pfb_feproblem(*parameters.get<FEProblemBase *>("_fe_problem_base")),
36  _vars(parameters.get<std::vector<std::string>>("vars")),
37  _vals(parameters.get<std::vector<std::string>>("vals"))
38 {
39  if (_vars.size() != _vals.size())
40  mooseError("Number of vars must match the number of vals for a MooseParsedFunction!");
41 
42  // Loop through the variables assigned by the user and give an error if x,y,z,t are used
43  for (const auto & var : _vars)
44  if (var.find_first_of("xyzt") != std::string::npos && var.size() == 1)
45  mooseError("The variables \"x, y, z, and t\" in the ParsedFunction are pre-declared for use "
46  "and must not be declared in \"vars\"");
47 }
48 
50 
51 const std::string
52 MooseParsedFunctionBase::verifyFunction(const std::string & function_str)
53 {
54  // Throws an error if quotes are found
55  if (function_str.find("\"") != std::string::npos)
56  mooseError("The value in ParsedFunction contains quotes(\") which cannot be properly parsed");
57 
58  // Return the input equation (no error)
59  return function_str;
60 }
virtual ~MooseParsedFunctionBase()
Class destructor.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const std::vector< std::string > _vals
Values passed by the user, they may be Reals for Postprocessors.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
InputParameters emptyInputParameters()
const std::string verifyFunction(const std::string &function_str)
A helper method to check if the function value contains quotes.
InputParameters validParams< MooseParsedFunctionBase >()
Creates the &#39;vars&#39; and &#39;vals&#39; parameters used by all ParsedFunctions, the parameters provided from th...
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.
MooseParsedFunctionBase(const InputParameters &parameters)
Class constructor for the interface.