From f57d56c97002302d873583b3117cc9c6fe3cd55e Mon Sep 17 00:00:00 2001 From: Marc Fehling Date: Sat, 25 Dec 2021 08:50:57 +0100 Subject: [PATCH] Calculate cross product once. --- include/deal.II/grid/manifold_lib.h | 5 +++++ source/grid/manifold_lib.cc | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/deal.II/grid/manifold_lib.h b/include/deal.II/grid/manifold_lib.h index 989bc3a235..06d606c835 100644 --- a/include/deal.II/grid/manifold_lib.h +++ b/include/deal.II/grid/manifold_lib.h @@ -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; }; /** diff --git a/source/grid/manifold_lib.cc b/source/grid/manifold_lib.cc index bc78bc58b5..ad4ad875a9 100644 --- a/source/grid/manifold_lib.cc +++ b/source/grid/manifold_lib.cc @@ -1066,6 +1066,7 @@ CylindricalManifold::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::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::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; -- 2.39.5