From be89e7b8f3c0848008a9ba937b6d85d652973600 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Mon, 6 Jun 2022 14:52:22 +0200 Subject: [PATCH] MF: make things more consistent --- .../deal.II/matrix_free/evaluation_kernels.h | 1 - .../matrix_free/shape_info.templates.h | 4 +- .../matrix_free/tensor_product_kernels.h | 51 ++++++++++--------- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/include/deal.II/matrix_free/evaluation_kernels.h b/include/deal.II/matrix_free/evaluation_kernels.h index ff05bbc5a0..c43ba6bb14 100644 --- a/include/deal.II/matrix_free/evaluation_kernels.h +++ b/include/deal.II/matrix_free/evaluation_kernels.h @@ -3672,7 +3672,6 @@ namespace internal } } - private: template static EvalType create_evaluator_tensor_product( diff --git a/include/deal.II/matrix_free/shape_info.templates.h b/include/deal.II/matrix_free/shape_info.templates.h index 2dc95d4e4c..b471045787 100644 --- a/include/deal.II/matrix_free/shape_info.templates.h +++ b/include/deal.II/matrix_free/shape_info.templates.h @@ -944,7 +944,7 @@ namespace internal { face_to_cell_index_nodal.reinit(GeometryInfo::faces_per_cell, dofs_per_component_on_face); - for (auto f : GeometryInfo::face_indices()) + for (const auto f : GeometryInfo::face_indices()) { const unsigned int direction = f / 2; const unsigned int stride = @@ -990,7 +990,7 @@ namespace internal { face_to_cell_index_hermite.reinit(GeometryInfo::faces_per_cell, 2 * dofs_per_component_on_face); - for (auto f : GeometryInfo::face_indices()) + for (const auto f : GeometryInfo::face_indices()) { const unsigned int direction = f / 2; const unsigned int stride = diff --git a/include/deal.II/matrix_free/tensor_product_kernels.h b/include/deal.II/matrix_free/tensor_product_kernels.h index 50f3166800..8e7b206113 100644 --- a/include/deal.II/matrix_free/tensor_product_kernels.h +++ b/include/deal.II/matrix_free/tensor_product_kernels.h @@ -476,7 +476,7 @@ namespace internal (dim > 2 ? n_rows : 1); AssertIndexRange(face_direction, dim); - constexpr int stride = Utilities::pow(n_rows, face_direction); + constexpr int in_stride = Utilities::pow(n_rows, face_direction); constexpr int out_stride = Utilities::pow(n_rows, dim - 1); const Number *DEAL_II_RESTRICT shape_values = this->shape_values; @@ -494,11 +494,12 @@ namespace internal res2 = shape_values[2 * n_rows] * in[0]; for (int ind = 1; ind < n_rows; ++ind) { - res0 += shape_values[ind] * in[stride * ind]; + res0 += shape_values[ind] * in[in_stride * ind]; if (max_derivative > 0) - res1 += shape_values[ind + n_rows] * in[stride * ind]; + res1 += shape_values[ind + n_rows] * in[in_stride * ind]; if (max_derivative > 1) - res2 += shape_values[ind + 2 * n_rows] * in[stride * ind]; + res2 += + shape_values[ind + 2 * n_rows] * in[in_stride * ind]; } if (add) { @@ -522,14 +523,14 @@ namespace internal for (int col = 0; col < n_rows; ++col) { if (add) - out[col * stride] += shape_values[col] * in[0]; + out[col * in_stride] += shape_values[col] * in[0]; else - out[col * stride] = shape_values[col] * in[0]; + out[col * in_stride] = shape_values[col] * in[0]; if (max_derivative > 0) - out[col * stride] += + out[col * in_stride] += shape_values[col + n_rows] * in[out_stride]; if (max_derivative > 1) - out[col * stride] += + out[col * in_stride] += shape_values[col + 2 * n_rows] * in[2 * out_stride]; } } @@ -916,7 +917,7 @@ namespace internal const int n_blocks2 = dim > 2 ? n_rows : 1; AssertIndexRange(face_direction, dim); - const int stride = + const int in_stride = face_direction > 0 ? Utilities::fixed_power(n_rows) : 1; const int out_stride = dim > 1 ? Utilities::fixed_power(n_rows) : 1; @@ -935,11 +936,12 @@ namespace internal res2 = shape_values[2 * n_rows] * in[0]; for (unsigned int ind = 1; ind < n_rows; ++ind) { - res0 += shape_values[ind] * in[stride * ind]; + res0 += shape_values[ind] * in[in_stride * ind]; if (max_derivative > 0) - res1 += shape_values[ind + n_rows] * in[stride * ind]; + res1 += shape_values[ind + n_rows] * in[in_stride * ind]; if (max_derivative > 1) - res2 += shape_values[ind + 2 * n_rows] * in[stride * ind]; + res2 += + shape_values[ind + 2 * n_rows] * in[in_stride * ind]; } if (add) { @@ -963,14 +965,14 @@ namespace internal for (unsigned int col = 0; col < n_rows; ++col) { if (add) - out[col * stride] += shape_values[col] * in[0]; + out[col * in_stride] += shape_values[col] * in[0]; else - out[col * stride] = shape_values[col] * in[0]; + out[col * in_stride] = shape_values[col] * in[0]; if (max_derivative > 0) - out[col * stride] += + out[col * in_stride] += shape_values[col + n_rows] * in[out_stride]; if (max_derivative > 1) - out[col * stride] += + out[col * in_stride] += shape_values[col + 2 * n_rows] * in[2 * out_stride]; } } @@ -2661,7 +2663,7 @@ namespace internal AssertIndexRange(face_direction, dim); - constexpr int stride = + constexpr int in_stride = (face_direction == normal_dir) ? Utilities::pow(n_rows - 1, face_direction) : ((face_direction == 0) ? @@ -2691,12 +2693,13 @@ namespace internal for (int ind = 1; ind < n_rows; ++ind) { - res0 += shape_values[ind] * in[stride * ind]; + res0 += shape_values[ind] * in[in_stride * ind]; if (max_derivative > 0) - res1 += shape_values[ind + n_rows] * in[stride * ind]; + res1 += shape_values[ind + n_rows] * in[in_stride * ind]; if (max_derivative > 1) - res2 += shape_values[ind + 2 * n_rows] * in[stride * ind]; + res2 += + shape_values[ind + 2 * n_rows] * in[in_stride * ind]; } if (add) { @@ -2724,16 +2727,16 @@ namespace internal for (int col = 0; col < n_rows; ++col) { if (add) - out[col * stride] += shape_values[col] * in[0]; + out[col * in_stride] += shape_values[col] * in[0]; else - out[col * stride] = shape_values[col] * in[0]; + out[col * in_stride] = shape_values[col] * in[0]; if (max_derivative > 0) - out[col * stride] += + out[col * in_stride] += shape_values[col + n_rows] * in[out_stride]; if (max_derivative > 1) - out[col * stride] += + out[col * in_stride] += shape_values[col + 2 * n_rows] * in[2 * out_stride]; } } -- 2.39.5