https://mooseframework.inl.gov
MooseParsedFunctionBase.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 
11 
12 // MOOSE includes
13 #include "InputParameters.h"
14 #include "MooseError.h"
16 
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 }
31 
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 }
46 
48 
49 std::string
50 MooseParsedFunctionBase::verifyFunction(const std::string & function_str)
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 }
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:311
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()
std::string verifyFunction(const std::string &function_str)
A helper method to check if the function value contains quotes.
static InputParameters validParams()
Class constructor for the interface.
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...
const std::vector< std::string > _vars
Variables passed to libMesh::ParsedFunction.
const Elem & get(const ElemType type_in)
MooseParsedFunctionBase(const InputParameters &parameters)