Line data Source code
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 : 10 : #include "MooseParsedFunctionBase.h" 11 : 12 : // MOOSE includes 13 : #include "InputParameters.h" 14 : #include "MooseError.h" 15 : #include "MooseParsedFunctionWrapper.h" 16 : 17 : InputParameters 18 97517 : MooseParsedFunctionBase::validParams() 19 : { 20 97517 : InputParameters params = emptyInputParameters(); 21 390068 : 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 292551 : 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 97517 : return params; 30 0 : } 31 : 32 53524 : MooseParsedFunctionBase::MooseParsedFunctionBase(const InputParameters & parameters) 33 160572 : : _pfb_feproblem(*parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")), 34 53524 : _vars(parameters.get<std::vector<std::string>>("symbol_names")), 35 107048 : _vals(parameters.get<std::vector<std::string>>("symbol_values")) 36 : { 37 53524 : if (_vars.size() != _vals.size()) 38 0 : 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 60386 : for (const auto & var : _vars) 42 6865 : if (var.find_first_of("xyzt") != std::string::npos && var.size() == 1) 43 3 : 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 53521 : } 46 : 47 51379 : MooseParsedFunctionBase::~MooseParsedFunctionBase() {} 48 : 49 : std::string 50 44971 : MooseParsedFunctionBase::verifyFunction(const std::string & function_str) 51 : { 52 : // Throws an error if quotes are found 53 44971 : if (function_str.find("\"") != std::string::npos) 54 3 : mooseError("The expression in ParsedFunction contains quotes which cannot be properly parsed"); 55 : 56 : // Return the input equation (no error) 57 44968 : return function_str; 58 : }