]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Convert an extern value into a function.
authorDavid Wells <drwells@email.unc.edu>
Sat, 21 May 2022 03:24:47 +0000 (23:24 -0400)
committerDavid Wells <drwells@email.unc.edu>
Sat, 21 May 2022 19:45:42 +0000 (15:45 -0400)
include/deal.II/base/mu_parser_internal.h
source/base/function_parser.cc
source/base/mu_parser_internal.cc
source/base/tensor_function_parser.cc

index 46a7d6c77cb443c07a8ccf6f399b385b5b0505bc..76a567b897d6f9efc5899ab5121b4e21808f6d8f 100644 (file)
@@ -136,7 +136,11 @@ namespace internal
     double
     mu_rand();
 
-    extern std::vector<std::string> function_names;
+    /**
+     * Get the array of all function names.
+     */
+    std::vector<std::string>
+    get_function_names();
 
   } // namespace FunctionParser
 
index c45d69f70f8e1cf6dfb23061064dc190b638c97d..ea1c952ad5cf77ab84df3e2f34527bd050304a54 100644 (file)
@@ -209,7 +209,7 @@ FunctionParser<dim>::init_muparser() const
           std::string transformed_expression = expressions[component];
 
           for (const auto &current_function_name :
-               internal::FunctionParser::function_names)
+               internal::FunctionParser::get_function_names())
             {
               const unsigned int function_name_length =
                 current_function_name.size();
index 9a925af2e9b2455989ac1666cbd2b99e1c4bd25b..364711d1ff40353e884d4a766ed55514eb3abf62 100644 (file)
@@ -155,47 +155,50 @@ namespace internal
       return uniform_distribution(rng);
     }
 
-    std::vector<std::string> 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<std::string>
+    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
 
index 2447d7b501dd7049a1d2e0bf2849a24b7c363f61..1402675a9e11ce92968e259ad60ce79a71f30286 100644 (file)
@@ -224,7 +224,7 @@ TensorFunctionParser<rank, dim, Number>::init_muparser() const
           std::string transformed_expression = expressions[component];
 
           for (const auto &current_function_name :
-               internal::FunctionParser::function_names)
+               internal::FunctionParser::get_function_names())
             {
               const unsigned int function_name_length =
                 current_function_name.size();

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.