]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Arrange face gradients contiguously 17162/head
authorDominik Still <dominik.still@tum.de>
Fri, 21 Jun 2024 09:57:39 +0000 (11:57 +0200)
committerDominik Still <dominik.still@tum.de>
Fri, 21 Jun 2024 09:57:39 +0000 (11:57 +0200)
include/deal.II/matrix_free/evaluation_kernels_face.h
include/deal.II/matrix_free/shape_info.h
include/deal.II/matrix_free/shape_info.templates.h

index 9ce0016485eec5ce1a0563e428204c4d23c0b4ab..0356dd1c6b3f93ef61f61737270eac3072d16812 100644 (file)
@@ -1467,50 +1467,46 @@ namespace internal
       const std::size_t  n_dofs     = shape_info.dofs_per_component_on_cell;
       const std::size_t  n_q_points = shape_info.n_q_points_faces[face_no];
 
-      using Eval =
-        EvaluatorTensorProduct<evaluate_general, 1, 0, 0, Number, Number2>;
-
       if (evaluation_flag & EvaluationFlags::values)
         {
           const auto *const shape_values =
             &shape_data.shape_values_face(face_no, face_orientation, 0);
 
-          auto *values_quad_ptr        = fe_eval.begin_values();
-          auto *values_dofs_actual_ptr = values_dofs;
+          auto *out = fe_eval.begin_values();
+          auto *in  = values_dofs;
 
-          Eval eval(shape_values, nullptr, nullptr, n_dofs, n_q_points);
           for (unsigned int c = 0; c < n_components; ++c)
             {
-              eval.template values<0, true, false>(values_dofs_actual_ptr,
-                                                   values_quad_ptr);
-
-              values_quad_ptr += n_q_points;
-              values_dofs_actual_ptr += n_dofs;
+              apply_matrix_vector_product<evaluate_general,
+                                          EvaluatorQuantity::value,
+                                          /*transpose_matrix*/ true,
+                                          /*add*/ false,
+                                          /*consider_strides*/ false>(
+                shape_values, in, out, n_dofs, n_q_points, 1, 1);
+
+              out += n_q_points;
+              in += n_dofs;
             }
         }
 
       if (evaluation_flag & EvaluationFlags::gradients)
         {
-          auto       *gradients_quad_ptr     = fe_eval.begin_gradients();
-          const auto *values_dofs_actual_ptr = values_dofs;
+          auto       *out = fe_eval.begin_gradients();
+          const auto *in  = values_dofs;
 
-          std::array<const Number2 *, dim> shape_gradients;
-          for (unsigned int d = 0; d < dim; ++d)
-            shape_gradients[d] =
-              &shape_data.shape_gradients_face(face_no, face_orientation, d, 0);
+          const auto *const shape_gradients =
+            &shape_data.shape_gradients_face(face_no, face_orientation, 0);
 
           for (unsigned int c = 0; c < n_components; ++c)
             {
-              for (unsigned int d = 0; d < dim; ++d)
-                {
-                  Eval eval(
-                    nullptr, shape_gradients[d], nullptr, n_dofs, n_q_points);
-
-                  eval.template gradients<0, true, false, dim>(
-                    values_dofs_actual_ptr, gradients_quad_ptr + d);
-                }
-              gradients_quad_ptr += n_q_points * dim;
-              values_dofs_actual_ptr += n_dofs;
+              apply_matrix_vector_product<evaluate_general,
+                                          EvaluatorQuantity::value,
+                                          /*transpose_matrix*/ true,
+                                          /*add*/ false,
+                                          /*consider_strides*/ false>(
+                shape_gradients, in, out, n_dofs, n_q_points * dim, 1, 1);
+              out += n_q_points * dim;
+              in += n_dofs;
             }
         }
 
@@ -1879,58 +1875,63 @@ namespace internal
       const std::size_t  n_dofs     = shape_info.dofs_per_component_on_cell;
       const std::size_t  n_q_points = shape_info.n_q_points_faces[face_no];
 
-      using Eval =
-        EvaluatorTensorProduct<evaluate_general, 1, 0, 0, Number, Number2>;
 
       if (integration_flag & EvaluationFlags::values)
         {
           const auto *const shape_values =
             &shape_data.shape_values_face(face_no, face_orientation, 0);
 
-          auto *values_quad_ptr        = fe_eval.begin_values();
-          auto *values_dofs_actual_ptr = values_dofs;
+          auto *in  = fe_eval.begin_values();
+          auto *out = values_dofs;
 
-          Eval eval(shape_values, nullptr, nullptr, n_dofs, n_q_points);
           for (unsigned int c = 0; c < n_components; ++c)
             {
               if (sum_into_values)
-                eval.template values<0, false, true>(values_quad_ptr,
-                                                     values_dofs_actual_ptr);
+                apply_matrix_vector_product<evaluate_general,
+                                            EvaluatorQuantity::value,
+                                            /*transpose_matrix*/ false,
+                                            /*add*/ true,
+                                            /*consider_strides*/ false>(
+                  shape_values, in, out, n_dofs, n_q_points, 1, 1);
               else
-                eval.template values<0, false, false>(values_quad_ptr,
-                                                      values_dofs_actual_ptr);
-              values_quad_ptr += n_q_points;
-              values_dofs_actual_ptr += n_dofs;
+                apply_matrix_vector_product<evaluate_general,
+                                            EvaluatorQuantity::value,
+                                            /*transpose_matrix*/ false,
+                                            /*add*/ false,
+                                            /*consider_strides*/ false>(
+                  shape_values, in, out, n_dofs, n_q_points, 1, 1);
+              in += n_q_points;
+              out += n_dofs;
             }
         }
 
       if (integration_flag & EvaluationFlags::gradients)
         {
-          auto *gradients_quad_ptr     = fe_eval.begin_gradients();
-          auto *values_dofs_actual_ptr = values_dofs;
+          auto *in  = fe_eval.begin_gradients();
+          auto *out = values_dofs;
 
-          std::array<const Number2 *, dim> shape_gradients;
-          for (unsigned int d = 0; d < dim; ++d)
-            shape_gradients[d] =
-              &shape_data.shape_gradients_face(face_no, face_orientation, d, 0);
+          const auto *const shape_gradients =
+            &shape_data.shape_gradients_face(face_no, face_orientation, 0);
 
           for (unsigned int c = 0; c < n_components; ++c)
             {
-              for (unsigned int d = 0; d < dim; ++d)
-                {
-                  Eval eval(
-                    nullptr, shape_gradients[d], nullptr, n_dofs, n_q_points);
-
-                  if (!sum_into_values &&
-                      !(integration_flag & EvaluationFlags::values) && d == 0)
-                    eval.template gradients<0, false, false, dim>(
-                      gradients_quad_ptr + d, values_dofs_actual_ptr);
-                  else
-                    eval.template gradients<0, false, true, dim>(
-                      gradients_quad_ptr + d, values_dofs_actual_ptr);
-                }
-              gradients_quad_ptr += n_q_points * dim;
-              values_dofs_actual_ptr += n_dofs;
+              if (!sum_into_values &&
+                  !(integration_flag & EvaluationFlags::values))
+                apply_matrix_vector_product<evaluate_general,
+                                            EvaluatorQuantity::value,
+                                            /*transpose_matrix*/ false,
+                                            /*add*/ false,
+                                            /*consider_strides*/ false>(
+                  shape_gradients, in, out, n_dofs, n_q_points * dim, 1, 1);
+              else
+                apply_matrix_vector_product<evaluate_general,
+                                            EvaluatorQuantity::value,
+                                            /*transpose_matrix*/ false,
+                                            /*add*/ true,
+                                            /*consider_strides*/ false>(
+                  shape_gradients, in, out, n_dofs, n_q_points * dim, 1, 1);
+              in += n_q_points * dim;
+              out += n_dofs;
             }
         }
 
index b3d525246451f38d85bf4f20bba5c2005704dc26..779e1753a6ca574d4e5c769227a1528188d264d9 100644 (file)
@@ -374,7 +374,7 @@ namespace internal
        * quadrature points for all faces, orientations, and directions
        * (no tensor-product structure exploited).
        */
-      Table<4, Number> shape_gradients_face;
+      Table<3, Number> shape_gradients_face;
     };
 
 
index c4b6b68d18c0de9f47e9a5627f263253adff6d76..9858856a05a1755bcfbaea6111f8eb9036b9b4eb 100644 (file)
@@ -425,10 +425,10 @@ namespace internal
                                           n_max_face_orientations,
                                           n_dofs * n_q_points_face_max});
 
-                shape_gradients_face.reinit({n_faces,
-                                             n_max_face_orientations,
-                                             dim,
-                                             n_dofs * n_q_points_face_max});
+                shape_gradients_face.reinit(
+                  {n_faces,
+                   n_max_face_orientations,
+                   dim * n_dofs * n_q_points_face_max});
 
                 for (unsigned int f = 0; f < n_faces; ++f)
                   {
@@ -464,8 +464,10 @@ namespace internal
                               const auto grad = fe.shape_grad(i, point);
 
                               for (unsigned int d = 0; d < dim; ++d)
-                                shape_gradients_face(
-                                  f, o, d, i * n_q_points_face + q) = grad[d];
+                                shape_gradients_face(f,
+                                                     o,
+                                                     i * dim * n_q_points_face +
+                                                       q * dim + d) = grad[d];
                             }
                       }
                   }

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.