]> https://gitweb.dealii.org/ - dealii.git/commitdiff
changed std::pow to Utilities::fixed_power in include/ source/ 14759/head
authorVadim Gallyamov <vgalliamov@gmail.com>
Wed, 8 Feb 2023 20:48:33 +0000 (21:48 +0100)
committerVadim Gallyamov <vgalliamov@gmail.com>
Wed, 8 Feb 2023 20:48:33 +0000 (21:48 +0100)
include/deal.II/optimization/line_minimization.h
source/base/function_lib_cutoff.cc
source/base/function_signed_distance.cc
source/base/quadrature_lib.cc
source/grid/grid_generator.cc
source/grid/manifold_lib.cc
source/numerics/derivative_approximation.cc

index b5478e9f1c23ddae6a213b9c242362e0d6199147..be571a27ab8a6441fcda122da803c60af10651d9 100644 (file)
@@ -22,6 +22,7 @@
 #include <deal.II/base/logstream.h>
 #include <deal.II/base/numbers.h>
 #include <deal.II/base/std_cxx17/optional.h>
+#include <deal.II/base/utilities.h>
 
 #include <deal.II/numerics/history.h>
 
@@ -419,14 +420,16 @@ namespace LineMinimization
     const NumberType r1       = f2 - f1 - g1 * x2_shift;
     const NumberType r2       = f3 - f1 - g1 * x3_shift;
     const NumberType denom =
-      std::pow(x2_shift * x3_shift, 2) * (x2_shift - x3_shift);
+      Utilities::fixed_power<2>(x2_shift * x3_shift) * (x2_shift - x3_shift);
     if (denom == 0.)
       return {};
 
-    const NumberType A =
-      (r1 * std::pow(x3_shift, 2) - r2 * std::pow(x2_shift, 2)) / denom;
-    const NumberType B =
-      (r2 * std::pow(x2_shift, 3) - r1 * std::pow(x3_shift, 3)) / denom;
+    const NumberType A = (r1 * Utilities::fixed_power<2>(x3_shift) -
+                          r2 * Utilities::fixed_power<2>(x2_shift)) /
+                         denom;
+    const NumberType B = (r2 * Utilities::fixed_power<3>(x2_shift) -
+                          r1 * Utilities::fixed_power<3>(x3_shift)) /
+                         denom;
     const NumberType &C = g1;
 
     // now get the minimizer:
index 546bf7ddc868505b7f01a8831711e57bab10f48e..f795eee876c2935155460b65bf1f665b84de0504 100644 (file)
@@ -470,11 +470,12 @@ namespace Functions
     if (d >= r)
       return Tensor<1, dim>();
     const double e = -d * d / (r - d) / (r + d);
-    return ((e < -50) ? Point<dim>() :
-                        (p - this->center) / d *
-                          (-2.0 * r * r / std::pow(-r * r + d * d, 2.0) * d *
-                           std::exp(e)) *
-                          this->rescaling);
+    return ((e < -50) ?
+              Point<dim>() :
+              (p - this->center) / d *
+                (-2.0 * r * r / Utilities::fixed_power<2>(-r * r + d * d) * d *
+                 std::exp(e)) *
+                this->rescaling);
   }
 
 
index 1ab7fb79665c33cdbc12036e3fd4c52936123415..8d17b5b407156f76852830b02179fa2fbb495a8b 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <deal.II/base/exceptions.h>
 #include <deal.II/base/function_signed_distance.h>
+#include <deal.II/base/utilities.h>
 
 #include <algorithm>
 
@@ -76,7 +77,7 @@ namespace Functions
       const SymmetricTensor<2, dim> hess =
         unit_symmetric_tensor<dim>() / distance -
         symmetrize(outer_product(center_to_point, center_to_point)) /
-          std::pow(distance, 3);
+          Utilities::fixed_power<3>(distance);
 
       return hess;
     }
@@ -201,7 +202,7 @@ namespace Functions
     {
       double val = 0.0;
       for (unsigned int d = 0; d < dim; ++d)
-        val += std::pow((point[d] - center[d]) / radii[d], 2);
+        val += Utilities::fixed_power<2>((point[d] - center[d]) / radii[d]);
       return val - 1.0;
     }
 
@@ -245,8 +246,10 @@ namespace Functions
       do
         {
           // compute the ellipse evolute (center of curvature) for the current t
-          const double ex = (a * a - b * b) * std::pow(std::cos(t), 3) / a;
-          const double ey = (b * b - a * a) * std::pow(std::sin(t), 3) / b;
+          const double ex =
+            (a * a - b * b) * Utilities::fixed_power<3>(std::cos(t)) / a;
+          const double ey =
+            (b * b - a * a) * Utilities::fixed_power<3>(std::sin(t)) / b;
           // compute distances from current point on ellipse to its evolute
           const double rx = x - ex;
           const double ry = y - ey;
index df8cb2efac4e5c88d158b6fd21903377850a195d..3a45349c9025e5ce725074e55d78912a21cf855a 100644 (file)
@@ -16,6 +16,7 @@
 #include <deal.II/base/geometry_info.h>
 #include <deal.II/base/polynomial.h>
 #include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/utilities.h>
 
 #include <deal.II/fe/fe_nothing.h>
 #include <deal.II/fe/fe_values.h>
@@ -946,7 +947,7 @@ QTelles<1>::QTelles(const Quadrature<1> &base_quad, const Point<1> &singularity)
   for (unsigned int q = 0; q < quadrature_points.size(); ++q)
     {
       double gamma = quadrature_points[q][0] * 2 - 1;
-      double eta   = (std::pow(gamma - gamma_bar, 3.0) +
+      double eta   = (Utilities::fixed_power<3>(gamma - gamma_bar) +
                     gamma_bar * (gamma_bar * gamma_bar + 3)) /
                    (1 + 3 * gamma_bar * gamma_bar);
 
index 3ab2989de085d9bc4c76ecf6b9f26e078115a0a6..ee8359a4b0364400aa6da03958414bda707e729f 100644 (file)
@@ -667,8 +667,10 @@ namespace GridGenerator
                 const double y_t =
                   5 * t *
                   (0.2969 * std::pow(x, 0.5) - 0.126 * x -
-                   0.3516 * std::pow(x, 2) + 0.2843 * std::pow(x, 3) -
-                   0.1036 * std::pow(x, 4)); // half thickness at a position x
+                   0.3516 * Utilities::fixed_power<2>(x) +
+                   0.2843 * Utilities::fixed_power<3>(x) -
+                   0.1036 * Utilities::fixed_power<4>(
+                              x)); // half thickness at a position x
 
                 if (is_upper)
                   naca_points.emplace_back(x, +y_t);
@@ -683,19 +685,23 @@ namespace GridGenerator
                 const double x = i * 1 / (1.0 * number_points - 1);
 
                 const double y_c =
-                  (x <= p) ? m / std::pow(p, 2) * (2 * p * x - std::pow(x, 2)) :
-                             m / std::pow(1 - p, 2) *
-                               ((1 - 2 * p) + 2 * p * x - std::pow(x, 2));
+                  (x <= p) ?
+                    m / Utilities::fixed_power<2>(p) *
+                      (2 * p * x - Utilities::fixed_power<2>(x)) :
+                    m / Utilities::fixed_power<2>(1 - p) *
+                      ((1 - 2 * p) + 2 * p * x - Utilities::fixed_power<2>(x));
 
-                const double dy_c = (x <= p) ?
-                                      2 * m / std::pow(p, 2) * (p - x) :
-                                      2 * m / std::pow(1 - p, 2) * (p - x);
+                const double dy_c =
+                  (x <= p) ? 2 * m / Utilities::fixed_power<2>(p) * (p - x) :
+                             2 * m / Utilities::fixed_power<2>(1 - p) * (p - x);
 
                 const double y_t =
                   5 * t *
                   (0.2969 * std::pow(x, 0.5) - 0.126 * x -
-                   0.3516 * std::pow(x, 2) + 0.2843 * std::pow(x, 3) -
-                   0.1036 * std::pow(x, 4)); // half thickness at a position x
+                   0.3516 * Utilities::fixed_power<2>(x) +
+                   0.2843 * Utilities::fixed_power<3>(x) -
+                   0.1036 * Utilities::fixed_power<4>(
+                              x)); // half thickness at a position x
 
                 const double theta = std::atan(dy_c);
 
index 3359be1bce6e654838839d7bece559847fc856e5..fa1c04174facd94ac0d21c4d77001a272de50a71 100644 (file)
@@ -1559,9 +1559,10 @@ TorusManifold<dim>::pull_back(const Point<3> &p) const
   double y     = p(2);
   double phi   = std::atan2(y, x);
   double theta = std::atan2(z, std::sqrt(x * x + y * y) - R);
-  double w     = std::sqrt(std::pow(y - std::sin(phi) * R, 2.0) +
-                       std::pow(x - std::cos(phi) * R, 2.0) + z * z) /
-             r;
+  double w =
+    std::sqrt(Utilities::fixed_power<2>(y - std::sin(phi) * R) +
+              Utilities::fixed_power<2>(x - std::cos(phi) * R) + z * z) /
+    r;
   return {phi, theta, w};
 }
 
index 6fec92c8c03f2f3afdc23f140d09262759ca745b..2b2abe4c0df84f3055ed53a2ec62591efff3b1f3 100644 (file)
@@ -14,6 +14,7 @@
 // ---------------------------------------------------------------------
 
 #include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/utilities.h>
 #include <deal.II/base/work_stream.h>
 
 #include <deal.II/dofs/dof_accessor.h>
@@ -436,9 +437,11 @@ namespace DerivativeApproximation
                          s[2][2] * s[2][2] + 2 * (ss01 + ss02 + ss12)) /
                         2.;
       const double J3 =
-        (std::pow(s[0][0], 3) + std::pow(s[1][1], 3) + std::pow(s[2][2], 3) +
-         3. * s[0][0] * (ss01 + ss02) + 3. * s[1][1] * (ss01 + ss12) +
-         3. * s[2][2] * (ss02 + ss12) + 6. * s[0][1] * s[0][2] * s[1][2]) /
+        (Utilities::fixed_power<3>(s[0][0]) +
+         Utilities::fixed_power<3>(s[1][1]) +
+         Utilities::fixed_power<3>(s[2][2]) + 3. * s[0][0] * (ss01 + ss02) +
+         3. * s[1][1] * (ss01 + ss12) + 3. * s[2][2] * (ss02 + ss12) +
+         6. * s[0][1] * s[0][2] * s[1][2]) /
         3.;
 
       const double R = std::sqrt(4. * J2 / 3.);

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.