From: David Wells Date: Sat, 21 May 2022 03:24:47 +0000 (-0400) Subject: Convert an extern value into a function. X-Git-Tag: v9.4.0-rc1~132^2~7 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41e423b3511a1a3eb56317071b442814faceebe9;p=dealii.git Convert an extern value into a function. --- diff --git a/include/deal.II/base/mu_parser_internal.h b/include/deal.II/base/mu_parser_internal.h index 46a7d6c77c..76a567b897 100644 --- a/include/deal.II/base/mu_parser_internal.h +++ b/include/deal.II/base/mu_parser_internal.h @@ -136,7 +136,11 @@ namespace internal double mu_rand(); - extern std::vector function_names; + /** + * Get the array of all function names. + */ + std::vector + get_function_names(); } // namespace FunctionParser diff --git a/source/base/function_parser.cc b/source/base/function_parser.cc index c45d69f70f..ea1c952ad5 100644 --- a/source/base/function_parser.cc +++ b/source/base/function_parser.cc @@ -209,7 +209,7 @@ FunctionParser::init_muparser() const std::string transformed_expression = expressions[component]; for (const auto ¤t_function_name : - internal::FunctionParser::function_names) + internal::FunctionParser::get_function_names()) { const unsigned int function_name_length = current_function_name.size(); diff --git a/source/base/mu_parser_internal.cc b/source/base/mu_parser_internal.cc index 9a925af2e9..364711d1ff 100644 --- a/source/base/mu_parser_internal.cc +++ b/source/base/mu_parser_internal.cc @@ -155,47 +155,50 @@ namespace internal return uniform_distribution(rng); } - std::vector function_names = { - // functions predefined by muparser - "sin", - "cos", - "tan", - "asin", - "acos", - "atan", - "sinh", - "cosh", - "tanh", - "asinh", - "acosh", - "atanh", - "atan2", - "log2", - "log10", - "log", - "ln", - "exp", - "sqrt", - "sign", - "rint", - "abs", - "min", - "max", - "sum", - "avg", - // functions we define ourselves above - "if", - "int", - "ceil", - "cot", - "csc", - "floor", - "sec", - "pow", - "erf", - "erfc", - "rand", - "rand_seed"}; + std::vector + get_function_names() + { + return {// functions predefined by muparser + "sin", + "cos", + "tan", + "asin", + "acos", + "atan", + "sinh", + "cosh", + "tanh", + "asinh", + "acosh", + "atanh", + "atan2", + "log2", + "log10", + "log", + "ln", + "exp", + "sqrt", + "sign", + "rint", + "abs", + "min", + "max", + "sum", + "avg", + // functions we define ourselves above + "if", + "int", + "ceil", + "cot", + "csc", + "floor", + "sec", + "pow", + "erf", + "erfc", + "rand", + "rand_seed"}; + } } // namespace FunctionParser diff --git a/source/base/tensor_function_parser.cc b/source/base/tensor_function_parser.cc index 2447d7b501..1402675a9e 100644 --- a/source/base/tensor_function_parser.cc +++ b/source/base/tensor_function_parser.cc @@ -224,7 +224,7 @@ TensorFunctionParser::init_muparser() const std::string transformed_expression = expressions[component]; for (const auto ¤t_function_name : - internal::FunctionParser::function_names) + internal::FunctionParser::get_function_names()) { const unsigned int function_name_length = current_function_name.size();