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 151890 : MooseParsedFunctionBase::validParams() 19 : { 20 151890 : InputParameters params = emptyInputParameters(); 21 151890 : params.addDeprecatedParam<std::vector<std::string>>( 22 : "vars", 23 : "Variables (excluding t,x,y,z) that are bound to the values provided by the corresponding " 24 : "items in the vals vector.", 25 : "Use 'symbol_names' instead."); 26 151890 : params.addDeprecatedParam<std::vector<std::string>>( 27 : "vals", 28 : "Constant numeric values, postprocessor names, " 29 : "function names, and scalar variables for vars.", 30 : "Use 'symbol_values' instead."); 31 151890 : params.addParam<std::vector<std::string>>( 32 : "symbol_names", 33 : "Symbols (excluding t,x,y,z) that are bound to the values provided by the corresponding " 34 : "items in the vals vector."); 35 151890 : params.addParam<std::vector<std::string>>("symbol_values", 36 : "Constant numeric values, postprocessor names, " 37 : "function names, and scalar variables corresponding to" 38 : " the symbols in symbol_names."); 39 151890 : return params; 40 0 : } 41 : 42 41785 : MooseParsedFunctionBase::MooseParsedFunctionBase(const InputParameters & parameters) 43 41785 : : _pfb_feproblem(*parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")), 44 125355 : _vars(parameters.isParamValid("vars") 45 110 : ? parameters.get<std::vector<std::string>>("vars") 46 83460 : : parameters.get<std::vector<std::string>>("symbol_names")), 47 125355 : _vals(parameters.isParamValid("vals") 48 110 : ? parameters.get<std::vector<std::string>>("vals") 49 167030 : : parameters.get<std::vector<std::string>>("symbol_values")) 50 : { 51 41785 : if (_vars.size() != _vals.size()) 52 0 : mooseError("Number of symbol_names must match the number of symbol_values!"); 53 : 54 : // Loop through the variables assigned by the user and give an error if x,y,z,t are used 55 44364 : for (const auto & var : _vars) 56 2583 : if (var.find_first_of("xyzt") != std::string::npos && var.size() == 1) 57 4 : mooseError("The variables \"x, y, z, and t\" in the ParsedFunction are pre-declared for use " 58 : "and must not be declared in \"vars\""); 59 41781 : } 60 : 61 39333 : MooseParsedFunctionBase::~MooseParsedFunctionBase() {} 62 : 63 : const std::string 64 43708 : MooseParsedFunctionBase::verifyFunction(const std::string & function_str) 65 : { 66 : // Throws an error if quotes are found 67 43708 : if (function_str.find("\"") != std::string::npos) 68 4 : mooseError("The expression in ParsedFunction contains quotes which cannot be properly parsed"); 69 : 70 : // Return the input equation (no error) 71 43704 : return function_str; 72 : }