From 41e423b3511a1a3eb56317071b442814faceebe9 Mon Sep 17 00:00:00 2001 From: David Wells Date: Fri, 20 May 2022 23:24:47 -0400 Subject: [PATCH] Convert an extern value into a function. --- include/deal.II/base/mu_parser_internal.h | 6 +- source/base/function_parser.cc | 2 +- source/base/mu_parser_internal.cc | 85 ++++++++++++----------- source/base/tensor_function_parser.cc | 2 +- 4 files changed, 51 insertions(+), 44 deletions(-) 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(); -- 2.39.5