]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Calculate cross product once. 13121/head
authorMarc Fehling <mafehling.git@gmail.com>
Sat, 25 Dec 2021 07:50:57 +0000 (08:50 +0100)
committerMarc Fehling <mafehling.git@gmail.com>
Sat, 25 Dec 2021 07:50:57 +0000 (08:50 +0100)
include/deal.II/grid/manifold_lib.h
source/grid/manifold_lib.cc

index 989bc3a2357a6492479bba7edcb5c2e527b7666a..06d606c835bdae7b16c599f369d1a5ca3c0aa651 100644 (file)
@@ -472,6 +472,11 @@ private:
    * Relative tolerance to measure zero distances.
    */
   const double tolerance;
+
+  /**
+   * The direction vector perpendicular to both direction and normal_direction.
+   */
+  const Tensor<1, spacedim> dxn;
 };
 
 /**
index bc78bc58b59ab2287c4fbe6c7018527bb865ec52..ad4ad875a9e396a03df1030726dafd4feee09692 100644 (file)
@@ -1066,6 +1066,7 @@ CylindricalManifold<dim, spacedim>::CylindricalManifold(
   , direction(direction / direction.norm())
   , point_on_axis(point_on_axis)
   , tolerance(tolerance)
+  , dxn(cross_product_3d(this->direction, normal_direction))
 {
   // do not use static_assert to make dimension-independent programming
   // easier.
@@ -1150,9 +1151,8 @@ CylindricalManifold<dim, spacedim>::push_forward(
          ExcMessage("CylindricalManifold can only be used for spacedim==3!"));
 
   // Rotate the orthogonal direction by the given angle
-  const double sine_r           = std::sin(chart_point(1)) * chart_point(0);
-  const double cosine_r         = std::cos(chart_point(1)) * chart_point(0);
-  const Tensor<1, spacedim> dxn = cross_product_3d(direction, normal_direction);
+  const double sine_r   = std::sin(chart_point(1)) * chart_point(0);
+  const double cosine_r = std::cos(chart_point(1)) * chart_point(0);
   const Tensor<1, spacedim> intermediate =
     normal_direction * cosine_r + dxn * sine_r;
 
@@ -1175,7 +1175,6 @@ CylindricalManifold<dim, spacedim>::push_forward_gradient(
   // Rotate the orthogonal direction by the given angle
   const double              sine   = std::sin(chart_point(1));
   const double              cosine = std::cos(chart_point(1));
-  const Tensor<1, spacedim> dxn = cross_product_3d(direction, normal_direction);
   const Tensor<1, spacedim> intermediate =
     normal_direction * cosine + dxn * sine;
 

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.