From 0d433ecfb939321d3f1d4afa5697b22514c6af32 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Wed, 12 Aug 2020 14:03:41 +0200 Subject: [PATCH] Remove n_components template argument from FEEvaluationImpl --- .../deal.II/matrix_free/evaluation_flags.h | 130 ++++ .../deal.II/matrix_free/evaluation_kernels.h | 386 +++++----- .../deal.II/matrix_free/evaluation_selector.h | 659 ++++++++---------- include/deal.II/matrix_free/fe_evaluation.h | 318 +++------ .../matrix_free/mapping_info.templates.h | 12 +- include/deal.II/matrix_free/operators.h | 40 +- source/fe/mapping_q_generic.cc | 66 +- .../matrix_free/evaluation_selector.inst.in | 32 +- source/multigrid/mg_transfer_matrix_free.cc | 16 +- 9 files changed, 768 insertions(+), 891 deletions(-) create mode 100644 include/deal.II/matrix_free/evaluation_flags.h diff --git a/include/deal.II/matrix_free/evaluation_flags.h b/include/deal.II/matrix_free/evaluation_flags.h new file mode 100644 index 0000000000..14dad2145a --- /dev/null +++ b/include/deal.II/matrix_free/evaluation_flags.h @@ -0,0 +1,130 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2020 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +#ifndef dealii_matrix_free_evaluation_flags_h +#define dealii_matrix_free_evaluation_flags_h + +#include + + +DEAL_II_NAMESPACE_OPEN + + + +/** + * @brief The namespace for the EvaluationFlags enum + * + * This namespace contains the enum EvaluationFlags used in FEEvaluation + * to control evaluation and integration of values, gradients, etc.. + */ +namespace EvaluationFlags +{ + /** + * @brief The EvaluationFlags enum + * + * This enum contains a set of flags used by FEEvaluation::integrate(), + * FEEvaluation::evaluate() and others to determine if values, gradients, + * hessians, or a combination of them is being used. + */ + enum EvaluationFlags + { + /** + * Do not use or compute anything. + */ + nothing = 0, + /** + * Use or evaluate values. + */ + values = 0x1, + /** + * Use or evaluate gradients. + */ + gradients = 0x2, + /** + * Use or evaluate hessians. + */ + hessians = 0x4 + }; + + + /** + * Global operator which returns an object in which all bits are set which are + * either set in the first or the second argument. This operator exists since + * if it did not then the result of the bit-or operator | would be an + * integer which would in turn trigger a compiler warning when we tried to + * assign it to an object of type UpdateFlags. + * + * @ref EvaluationFlags + */ + inline EvaluationFlags + operator|(const EvaluationFlags f1, const EvaluationFlags f2) + { + return static_cast(static_cast(f1) | + static_cast(f2)); + } + + + + /** + * Global operator which sets the bits from the second argument also in the + * first one. + * + * @ref EvaluationFlags + */ + inline EvaluationFlags & + operator|=(EvaluationFlags &f1, const EvaluationFlags f2) + { + f1 = f1 | f2; + return f1; + } + + + /** + * Global operator which returns an object in which all bits are set which are + * set in the first as well as the second argument. This operator exists since + * if it did not then the result of the bit-and operator & would be + * an integer which would in turn trigger a compiler warning when we tried to + * assign it to an object of type UpdateFlags. + * + * @ref EvaluationFlags + */ + inline EvaluationFlags operator&(const EvaluationFlags f1, + const EvaluationFlags f2) + { + return static_cast(static_cast(f1) & + static_cast(f2)); + } + + + /** + * Global operator which clears all the bits in the first argument if they are + * not also set in the second argument. + * + * @ref EvaluationFlags + */ + inline EvaluationFlags & + operator&=(EvaluationFlags &f1, const EvaluationFlags f2) + { + f1 = f1 & f2; + return f1; + } + +} // namespace EvaluationFlags + + +DEAL_II_NAMESPACE_CLOSE + +#endif diff --git a/include/deal.II/matrix_free/evaluation_kernels.h b/include/deal.II/matrix_free/evaluation_kernels.h index 76256a27e2..4451027de4 100644 --- a/include/deal.II/matrix_free/evaluation_kernels.h +++ b/include/deal.II/matrix_free/evaluation_kernels.h @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -104,29 +105,27 @@ namespace internal int dim, int fe_degree, int n_q_points_1d, - int n_components, typename Number> struct FEEvaluationImpl { static void - evaluate(const MatrixFreeFunctions::ShapeInfo &shape_info, + evaluate(const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, + const MatrixFreeFunctions::ShapeInfo &shape_info, const Number * values_dofs_actual, Number * values_quad, Number * gradients_quad, Number * hessians_quad, - Number * scratch_data, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians); + Number * scratch_data); static void - integrate(const MatrixFreeFunctions::ShapeInfo &shape_info, + integrate(const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, + const MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs_actual, Number * values_quad, Number * gradients_quad, Number * scratch_data, - const bool integrate_values, - const bool integrate_gradients, const bool add_into_values_array); }; @@ -136,22 +135,19 @@ namespace internal int dim, int fe_degree, int n_q_points_1d, - int n_components, typename Number> inline void - FEEvaluationImpl:: - evaluate(const MatrixFreeFunctions::ShapeInfo &shape_info, - const Number * values_dofs_actual, - Number * values_quad, - Number * gradients_quad, - Number * hessians_quad, - Number * scratch_data, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians) + FEEvaluationImpl::evaluate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, + const MatrixFreeFunctions::ShapeInfo &shape_info, + const Number * values_dofs_actual, + Number * values_quad, + Number * gradients_quad, + Number * hessians_quad, + Number * scratch_data) { - if (evaluate_values == false && evaluate_gradients == false && - evaluate_hessians == false) + if (evaluation_flag == EvaluationFlags::nothing) return; const EvaluatorVariant variant = @@ -209,27 +205,26 @@ namespace internal shape_info.n_q_points)); const int degree = fe_degree != -1 ? fe_degree : shape_info.data.front().fe_degree; - unsigned int count_p = 0, count_q = 0; - for (int i = 0; i < (dim > 2 ? degree + 1 : 1); ++i) - { - for (int j = 0; j < (dim > 1 ? degree + 1 - i : 1); ++j) - { - for (int k = 0; k < degree + 1 - j - i; - ++k, ++count_p, ++count_q) - for (unsigned int c = 0; c < n_components; ++c) + for (unsigned int c = 0; c < n_components; ++c) + for (int i = 0, count_p = 0, count_q = 0; + i < (dim > 2 ? degree + 1 : 1); + ++i) + { + for (int j = 0; j < (dim > 1 ? degree + 1 - i : 1); ++j) + { + for (int k = 0; k < degree + 1 - j - i; + ++k, ++count_p, ++count_q) values_dofs_tmp[c * dofs_per_comp + count_q] = values_dofs_actual [c * shape_info.dofs_per_component_on_cell + count_p]; - for (int k = degree + 1 - j - i; k < degree + 1; ++k, ++count_q) - for (unsigned int c = 0; c < n_components; ++c) + for (int k = degree + 1 - j - i; k < degree + 1; + ++k, ++count_q) values_dofs_tmp[c * dofs_per_comp + count_q] = Number(); - } - for (int j = degree + 1 - i; j < degree + 1; ++j) - for (int k = 0; k < degree + 1; ++k, ++count_q) - for (unsigned int c = 0; c < n_components; ++c) + } + for (int j = degree + 1 - i; j < degree + 1; ++j) + for (int k = 0; k < degree + 1; ++k, ++count_q) values_dofs_tmp[c * dofs_per_comp + count_q] = Number(); - } - AssertDimension(count_q, dofs_per_comp); + } values_dofs = values_dofs_tmp; } @@ -238,12 +233,12 @@ namespace internal case 1: for (unsigned int c = 0; c < n_components; c++) { - if (evaluate_values == true) + if (evaluation_flag & EvaluationFlags::values) eval.template values<0, true, false>(values_dofs, values_quad); - if (evaluate_gradients == true) + if (evaluation_flag & EvaluationFlags::gradients) eval.template gradients<0, true, false>(values_dofs, gradients_quad); - if (evaluate_hessians == true) + if (evaluation_flag & EvaluationFlags::hessians) eval.template hessians<0, true, false>(values_dofs, hessians_quad); @@ -259,15 +254,15 @@ namespace internal for (unsigned int c = 0; c < n_components; c++) { // grad x - if (evaluate_gradients == true) + if (evaluation_flag & EvaluationFlags::gradients) { eval.template gradients<0, true, false>(values_dofs, temp1); eval.template values<1, true, false>(temp1, gradients_quad); } - if (evaluate_hessians == true) + if (evaluation_flag & EvaluationFlags::hessians) { // grad xy - if (evaluate_gradients == false) + if (!(evaluation_flag & EvaluationFlags::gradients)) eval.template gradients<0, true, false>(values_dofs, temp1); eval.template gradients<1, true, false>(temp1, hessians_quad + @@ -280,19 +275,19 @@ namespace internal // grad y eval.template values<0, true, false>(values_dofs, temp1); - if (evaluate_gradients == true) + if (evaluation_flag & EvaluationFlags::gradients) eval.template gradients<1, true, false>(temp1, gradients_quad + n_q_points); // grad yy - if (evaluate_hessians == true) + if (evaluation_flag & EvaluationFlags::hessians) eval.template hessians<1, true, false>(temp1, hessians_quad + n_q_points); // val: can use values applied in x - if (evaluate_values == true) + if (evaluation_flag & EvaluationFlags::values) eval.template values<1, true, false>(temp1, values_quad); // advance to the next component in 1D array @@ -306,7 +301,7 @@ namespace internal case 3: for (unsigned int c = 0; c < n_components; c++) { - if (evaluate_gradients == true) + if (evaluation_flag & EvaluationFlags::gradients) { // grad x eval.template gradients<0, true, false>(values_dofs, temp1); @@ -314,10 +309,10 @@ namespace internal eval.template values<2, true, false>(temp2, gradients_quad); } - if (evaluate_hessians == true) + if (evaluation_flag & EvaluationFlags::hessians) { // grad xz - if (evaluate_gradients == false) + if (!(evaluation_flag & EvaluationFlags::gradients)) { eval.template gradients<0, true, false>(values_dofs, temp1); @@ -341,7 +336,7 @@ namespace internal // grad y eval.template values<0, true, false>(values_dofs, temp1); - if (evaluate_gradients == true) + if (evaluation_flag & EvaluationFlags::gradients) { eval.template gradients<1, true, false>(temp1, temp2); eval.template values<2, true, false>(temp2, @@ -349,10 +344,10 @@ namespace internal n_q_points); } - if (evaluate_hessians == true) + if (evaluation_flag & EvaluationFlags::hessians) { // grad yz - if (evaluate_gradients == false) + if (!(evaluation_flag & EvaluationFlags::gradients)) eval.template gradients<1, true, false>(temp1, temp2); eval.template gradients<2, true, false>(temp2, hessians_quad + @@ -368,21 +363,21 @@ namespace internal // grad z: can use the values applied in x direction stored in // temp1 eval.template values<1, true, false>(temp1, temp2); - if (evaluate_gradients == true) + if (evaluation_flag & EvaluationFlags::gradients) eval.template gradients<2, true, false>(temp2, gradients_quad + 2 * n_q_points); // grad zz: can use the values applied in x and y direction stored // in temp2 - if (evaluate_hessians == true) + if (evaluation_flag & EvaluationFlags::hessians) eval.template hessians<2, true, false>(temp2, hessians_quad + 2 * n_q_points); // val: can use the values applied in x & y direction stored in // temp2 - if (evaluate_values == true) + if (evaluation_flag & EvaluationFlags::values) eval.template values<2, true, false>(temp2, values_quad); // advance to the next component in 1D array @@ -400,7 +395,7 @@ namespace internal // case additional dof for FE_Q_DG0: add values; gradients and second // derivatives evaluate to zero if (type == MatrixFreeFunctions::tensor_symmetric_plus_dg0 && - evaluate_values) + (evaluation_flag & EvaluationFlags::values)) { values_quad -= n_components * n_q_points; values_dofs -= n_components * dofs_per_comp; @@ -417,18 +412,17 @@ namespace internal int dim, int fe_degree, int n_q_points_1d, - int n_components, typename Number> inline void - FEEvaluationImpl:: - integrate(const MatrixFreeFunctions::ShapeInfo &shape_info, - Number * values_dofs_actual, - Number * values_quad, - Number * gradients_quad, - Number * scratch_data, - const bool integrate_values, - const bool integrate_gradients, - const bool add_into_values_array) + FEEvaluationImpl::integrate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, + const MatrixFreeFunctions::ShapeInfo &shape_info, + Number * values_dofs_actual, + Number * values_quad, + Number * gradients_quad, + Number * scratch_data, + const bool add_into_values_array) { const EvaluatorVariant variant = EvaluatorSelector 4)>::variant; @@ -489,7 +483,7 @@ namespace internal case 1: for (unsigned int c = 0; c < n_components; c++) { - if (integrate_values == true) + if (integration_flag & EvaluationFlags::values) { if (add_into_values_array == false) eval.template values<0, false, false>(values_quad, @@ -498,9 +492,10 @@ namespace internal eval.template values<0, false, true>(values_quad, values_dofs); } - if (integrate_gradients == true) + if (integration_flag & EvaluationFlags::gradients) { - if (integrate_values == true || add_into_values_array == true) + if (integration_flag & EvaluationFlags::values || + add_into_values_array == true) eval.template gradients<0, false, true>(gradients_quad, values_dofs); else @@ -518,7 +513,8 @@ namespace internal case 2: for (unsigned int c = 0; c < n_components; c++) { - if (integrate_values == true && integrate_gradients == false) + if ((integration_flag & EvaluationFlags::values) && + !(integration_flag & EvaluationFlags::gradients)) { eval.template values<1, false, false>(values_quad, temp1); if (add_into_values_array == false) @@ -526,12 +522,12 @@ namespace internal else eval.template values<0, false, true>(temp1, values_dofs); } - if (integrate_gradients == true) + if (integration_flag & EvaluationFlags::gradients) { eval.template gradients<1, false, false>(gradients_quad + n_q_points, temp1); - if (integrate_values) + if (integration_flag & EvaluationFlags::values) eval.template values<1, false, true>(values_quad, temp1); if (add_into_values_array == false) eval.template values<0, false, false>(temp1, values_dofs); @@ -551,7 +547,8 @@ namespace internal case 3: for (unsigned int c = 0; c < n_components; c++) { - if (integrate_values == true && integrate_gradients == false) + if ((integration_flag & EvaluationFlags::values) && + !(integration_flag & EvaluationFlags::gradients)) { eval.template values<2, false, false>(values_quad, temp1); eval.template values<1, false, false>(temp1, temp2); @@ -560,12 +557,12 @@ namespace internal else eval.template values<0, false, true>(temp2, values_dofs); } - if (integrate_gradients == true) + if (integration_flag & EvaluationFlags::gradients) { eval.template gradients<2, false, false>(gradients_quad + 2 * n_q_points, temp1); - if (integrate_values) + if (integration_flag & EvaluationFlags::values) eval.template values<2, false, true>(values_quad, temp1); eval.template values<1, false, false>(temp1, temp2); eval.template values<2, false, false>(gradients_quad + @@ -598,7 +595,7 @@ namespace internal values_dofs -= n_components * dofs_per_comp - shape_info.dofs_per_component_on_cell + 1; values_quad -= n_components * n_q_points; - if (integrate_values) + if (integration_flag & EvaluationFlags::values) for (unsigned int c = 0; c < n_components; ++c) { values_dofs[0] = values_quad[0]; @@ -618,28 +615,25 @@ namespace internal if (type == MatrixFreeFunctions::truncated_tensor) { values_dofs -= dofs_per_comp * n_components; - unsigned int count_p = 0, count_q = 0; - const int degree = + const int degree = fe_degree != -1 ? fe_degree : shape_info.data.front().fe_degree; - for (int i = 0; i < (dim > 2 ? degree + 1 : 1); ++i) - { - for (int j = 0; j < (dim > 1 ? degree + 1 - i : 1); ++j) - { - for (int k = 0; k < degree + 1 - j - i; - ++k, ++count_p, ++count_q) - { - for (unsigned int c = 0; c < n_components; ++c) - values_dofs_actual - [c * shape_info.dofs_per_component_on_cell + count_p] = - values_dofs[c * dofs_per_comp + count_q]; - } - count_q += j + i; - } - count_q += i * (degree + 1); - } - AssertDimension(count_q, - Utilities::fixed_power( - shape_info.data.front().fe_degree + 1)); + for (unsigned int c = 0; c < n_components; ++c) + for (int i = 0, count_p = 0, count_q = 0; + i < (dim > 2 ? degree + 1 : 1); + ++i) + { + for (int j = 0; j < (dim > 1 ? degree + 1 - i : 1); ++j) + { + for (int k = 0; k < degree + 1 - j - i; + ++k, ++count_p, ++count_q) + values_dofs_actual[c * + shape_info.dofs_per_component_on_cell + + count_p] = + values_dofs[c * dofs_per_comp + count_q]; + count_q += j + i; + } + count_q += i * (degree + 1); + } } } @@ -658,7 +652,6 @@ namespace internal int dim, int basis_size_1, int basis_size_2, - int n_components, typename Number, typename Number2> struct FEEvaluationImplBasisChange @@ -692,6 +685,7 @@ namespace internal #endif static void do_forward( + const unsigned int n_components, const AlignedVector &transformation_matrix, const Number * values_in, Number * values_out, @@ -748,9 +742,9 @@ namespace internal next_dim, basis_size_1, basis_size_2, - 1, Number, - Number2>::do_forward(transformation_matrix, + Number2>::do_forward(1, + transformation_matrix, values_in + (q - 1) * Utilities::fixed_power(np_1), @@ -811,6 +805,7 @@ namespace internal #endif static void do_backward( + const unsigned int n_components, const AlignedVector &transformation_matrix, const bool add_into_result, Number * values_in, @@ -879,10 +874,10 @@ namespace internal next_dim, basis_size_1, basis_size_2, - 1, Number, Number2>:: - do_backward(transformation_matrix, + do_backward(1, + transformation_matrix, add_into_result, values_in + q * Utilities::fixed_power(np_2), @@ -916,7 +911,8 @@ namespace internal * the values_in array. */ static void - do_mass(const AlignedVector &transformation_matrix, + do_mass(const unsigned int n_components, + const AlignedVector &transformation_matrix, const AlignedVector & coefficients, const Number * values_in, Number * scratch_data, @@ -939,9 +935,9 @@ namespace internal next_dim, basis_size_1, basis_size_2, - n_components, Number, - Number2>::do_forward(transformation_matrix, + Number2>::do_forward(n_components, + transformation_matrix, values_in + (q - 1) * Utilities::pow(basis_size_1, dim - 1), @@ -979,9 +975,9 @@ namespace internal next_dim, basis_size_1, basis_size_2, - n_components, Number, - Number2>::do_backward(transformation_matrix, + Number2>::do_backward(n_components, + transformation_matrix, false, my_scratch + q * Utilities::pow(basis_size_2, dim - 1), @@ -1004,45 +1000,43 @@ namespace internal * evaluation, spectral collocation or simply collocation, meaning the same * location for shape functions and evaluation space (quadrature points). */ - template + template struct FEEvaluationImplCollocation { static void - evaluate(const MatrixFreeFunctions::ShapeInfo &shape_info, + evaluate(const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, + const MatrixFreeFunctions::ShapeInfo &shape_info, const Number * values_dofs, Number * values_quad, Number * gradients_quad, Number * hessians_quad, - Number * scratch_data, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians); + Number * scratch_data); static void - integrate(const MatrixFreeFunctions::ShapeInfo &shape_info, + integrate(const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, + const MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs, Number * values_quad, Number * gradients_quad, Number * scratch_data, - const bool integrate_values, - const bool integrate_gradients, const bool add_into_values_array); }; - template + template inline void - FEEvaluationImplCollocation::evaluate( + FEEvaluationImplCollocation::evaluate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, const MatrixFreeFunctions::ShapeInfo &shape_info, const Number * values_dofs, Number * values_quad, Number * gradients_quad, Number * hessians_quad, - Number *, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians) + Number *) { AssertDimension( shape_info.data.front().shape_gradients_collocation_eo.size(), @@ -1060,10 +1054,11 @@ namespace internal for (unsigned int c = 0; c < n_components; c++) { - if (evaluate_values == true) + if (evaluation_flag & EvaluationFlags::values) for (unsigned int i = 0; i < n_q_points; ++i) values_quad[i] = values_dofs[i]; - if (evaluate_gradients == true || evaluate_hessians == true) + if (evaluation_flag & + (EvaluationFlags::gradients | EvaluationFlags::hessians)) { eval.template gradients<0, true, false>(values_dofs, gradients_quad); @@ -1076,7 +1071,7 @@ namespace internal gradients_quad + 2 * n_q_points); } - if (evaluate_hessians == true) + if (evaluation_flag & EvaluationFlags::hessians) { eval.template hessians<0, true, false>(values_dofs, hessians_quad); if (dim > 1) @@ -1109,16 +1104,16 @@ namespace internal - template + template inline void - FEEvaluationImplCollocation::integrate( + FEEvaluationImplCollocation::integrate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, const MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs, Number * values_quad, Number * gradients_quad, Number *, - const bool integrate_values, - const bool integrate_gradients, const bool add_into_values_array) { AssertDimension( @@ -1137,15 +1132,19 @@ namespace internal for (unsigned int c = 0; c < n_components; c++) { - if (integrate_values == true && add_into_values_array == false) - for (unsigned int i = 0; i < n_q_points; ++i) - values_dofs[i] = values_quad[i]; - else if (integrate_values == true) - for (unsigned int i = 0; i < n_q_points; ++i) - values_dofs[i] += values_quad[i]; - if (integrate_gradients == true) + if (integration_flag & EvaluationFlags::values) { - if (integrate_values == true || add_into_values_array == true) + if (add_into_values_array == false) + for (unsigned int i = 0; i < n_q_points; ++i) + values_dofs[i] = values_quad[i]; + else + for (unsigned int i = 0; i < n_q_points; ++i) + values_dofs[i] += values_quad[i]; + } + if (integration_flag & EvaluationFlags::gradients) + { + if (integration_flag & EvaluationFlags::values || + add_into_values_array == true) eval.template gradients<0, false, true>(gradients_quad, values_dofs); else @@ -1178,57 +1177,46 @@ namespace internal * the evaluation of the first and second derivatives in this transformed * space, using the identity operation for the shape values. */ - template + template struct FEEvaluationImplTransformToCollocation { static void - evaluate(const MatrixFreeFunctions::ShapeInfo &shape_info, + evaluate(const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, + const MatrixFreeFunctions::ShapeInfo &shape_info, const Number * values_dofs, Number * values_quad, Number * gradients_quad, Number * hessians_quad, - Number * scratch_data, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians); + Number * scratch_data); static void - integrate(const MatrixFreeFunctions::ShapeInfo &shape_info, + integrate(const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, + const MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs, Number * values_quad, Number * gradients_quad, Number * scratch_data, - const bool integrate_values, - const bool integrate_gradients, const bool add_into_values_array); }; - template + template inline void FEEvaluationImplTransformToCollocation< dim, fe_degree, n_q_points_1d, - n_components, - Number>::evaluate(const MatrixFreeFunctions::ShapeInfo &shape_info, + Number>::evaluate(const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, + const MatrixFreeFunctions::ShapeInfo &shape_info, const Number * values_dofs, Number * values_quad, Number *gradients_quad, Number *hessians_quad, - Number *, - const bool, - const bool evaluate_gradients, - const bool evaluate_hessians) + Number *) { Assert(n_q_points_1d > fe_degree, ExcMessage("You lose information when going to a collocation space " @@ -1244,24 +1232,25 @@ namespace internal dim, (fe_degree >= n_q_points_1d ? n_q_points_1d : fe_degree + 1), n_q_points_1d, - 1, Number, - Number>::do_forward(shape_info.data.front().shape_values_eo, + Number>::do_forward(1, + shape_info.data.front().shape_values_eo, values_dofs, values_quad); // apply derivatives in the collocation space - if (evaluate_gradients == true || evaluate_hessians == true) - FEEvaluationImplCollocation:: - evaluate(shape_info, - values_quad, - nullptr, - gradients_quad, - hessians_quad, - nullptr, - false, - evaluate_gradients, - evaluate_hessians); + if (evaluation_flag & + (EvaluationFlags::gradients | EvaluationFlags::hessians)) + FEEvaluationImplCollocation::evaluate( + 1, + evaluation_flag & + (EvaluationFlags::gradients | EvaluationFlags::hessians), + shape_info, + values_quad, + nullptr, + gradients_quad, + hessians_quad, + nullptr); values_dofs += shape_info.dofs_per_component_on_cell; values_quad += n_q_points; @@ -1272,24 +1261,19 @@ namespace internal - template + template inline void FEEvaluationImplTransformToCollocation< dim, fe_degree, n_q_points_1d, - n_components, - Number>::integrate(const MatrixFreeFunctions::ShapeInfo &shape_info, + Number>::integrate(const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, + const MatrixFreeFunctions::ShapeInfo &shape_info, Number *values_dofs, Number *values_quad, Number *gradients_quad, Number *, - const bool integrate_values, - const bool integrate_gradients, const bool add_into_values_array) { Assert(n_q_points_1d > fe_degree, @@ -1305,16 +1289,17 @@ namespace internal for (unsigned int c = 0; c < n_components; c++) { // apply derivatives in collocation space - if (integrate_gradients == true) - FEEvaluationImplCollocation:: - integrate(shape_info, + if (integration_flag & EvaluationFlags::gradients) + FEEvaluationImplCollocation:: + integrate(1, + integration_flag & EvaluationFlags::gradients, + shape_info, values_quad, nullptr, gradients_quad, nullptr, - false, - integrate_gradients, - /*add_into_values_array=*/integrate_values); + /*add_into_values_array=*/integration_flag & + EvaluationFlags::values); // transform back to the original space FEEvaluationImplBasisChange< @@ -1322,9 +1307,9 @@ namespace internal dim, (fe_degree >= n_q_points_1d ? n_q_points_1d : fe_degree + 1), n_q_points_1d, - 1, Number, - Number>::do_backward(shape_info.data.front().shape_values_eo, + Number>::do_backward(1, + shape_info.data.front().shape_values_eo, add_into_values_array, values_quad, values_dofs); @@ -3135,12 +3120,13 @@ namespace internal /** * This struct implements the action of the inverse mass matrix operation */ - template + template struct CellwiseInverseMassMatrixImpl { template static void - apply(const FEEvaluationType &fe_eval, + apply(const unsigned int n_components, + const FEEvaluationType &fe_eval, const Number * in_array, Number * out_array) { @@ -3192,9 +3178,9 @@ namespace internal } static void - apply(const AlignedVector &inverse_shape, + apply(const unsigned int n_desired_components, + const AlignedVector &inverse_shape, const AlignedVector &inverse_coefficients, - const unsigned int n_desired_components, const Number * in_array, Number * out_array) { @@ -3249,10 +3235,10 @@ namespace internal } static void - transform_from_q_points_to_basis(const AlignedVector &inverse_shape, - const unsigned int n_desired_components, - const Number * in_array, - Number * out_array) + transform_from_q_points_to_basis(const unsigned int n_desired_components, + const AlignedVector &inverse_shape, + const Number * in_array, + Number * out_array) { constexpr unsigned int dofs_per_cell = Utilities::pow(fe_degree + 1, dim); internal::EvaluatorTensorProduct + template struct Default { static inline void evaluate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, const internal::MatrixFreeFunctions::ShapeInfo &shape_info, - Number * values_dofs_actual, - Number * values_quad, - Number * gradients_quad, - Number * hessians_quad, - Number * scratch_data, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians) + Number *values_dofs_actual, + Number *values_quad, + Number *gradients_quad, + Number *hessians_quad, + Number *scratch_data) { internal::FEEvaluationImpl< internal::MatrixFreeFunctions::tensor_general, dim, -1, 0, - n_components, - Number>::evaluate(shape_info, + Number>::evaluate(n_components, + evaluation_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + scratch_data); } static inline void integrate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, const internal::MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs_actual, Number * values_quad, Number * gradients_quad, Number * scratch_data, - const bool integrate_values, - const bool integrate_gradients, const bool sum_into_values_array = false) { internal::FEEvaluationImpl< @@ -96,14 +93,13 @@ namespace internal dim, -1, 0, - n_components, - Number>::integrate(shape_info, + Number>::integrate(n_components, + integration_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, scratch_data, - integrate_values, - integrate_gradients, sum_into_values_array); } }; @@ -113,13 +109,12 @@ namespace internal * This class implements the actual choice of the template specialization. */ template - struct Factory : Default + struct Factory : Default {}; /** @@ -127,9 +122,8 @@ namespace internal * which we want to determine the correct template parameters based at * runtime. */ - template - struct Factory - : Default + template + struct Factory : Default {}; /** @@ -137,102 +131,90 @@ namespace internal * which we want to determine the correct template parameters based at * runtime. */ - template + template struct Factory::type> - : Default + : Default {}; /** * This class chooses the correct template degree. */ - template - struct Factory + template + struct Factory { static inline void evaluate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, const internal::MatrixFreeFunctions::ShapeInfo &shape_info, - Number * values_dofs_actual, - Number * values_quad, - Number * gradients_quad, - Number * hessians_quad, - Number * scratch_data, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians) + Number *values_dofs_actual, + Number *values_quad, + Number *gradients_quad, + Number *hessians_quad, + Number *scratch_data) { const unsigned int runtime_degree = shape_info.data.front().fe_degree; constexpr unsigned int start_n_q_points = degree + 1; if (runtime_degree == degree) - Factory:: - evaluate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + Factory::evaluate( + n_components, + evaluation_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + hessians_quad, + scratch_data); else - Factory:: - evaluate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + Factory::evaluate( + n_components, + evaluation_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + hessians_quad, + scratch_data); } static inline void integrate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, const internal::MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs_actual, Number * values_quad, Number * gradients_quad, Number * scratch_data, - const bool integrate_values, - const bool integrate_gradients, const bool sum_into_values_array = false) { const int runtime_degree = shape_info.data.front().fe_degree; constexpr unsigned int start_n_q_points = degree + 1; if (runtime_degree == degree) - Factory:: - integrate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - scratch_data, - integrate_values, - integrate_gradients, - sum_into_values_array); + Factory::integrate( + n_components, + integration_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + scratch_data, + sum_into_values_array); else - Factory:: - integrate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - scratch_data, - integrate_values, - integrate_gradients, - sum_into_values_array); + Factory::integrate( + n_components, + integration_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + scratch_data, + sum_into_values_array); } }; @@ -240,13 +222,8 @@ namespace internal * This class chooses the correct template n_q_points_1d after degree was * chosen. */ - template + template struct Factory &shape_info, - Number * values_dofs_actual, - Number * values_quad, - Number * gradients_quad, - Number * hessians_quad, - Number * scratch_data, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians) + Number *values_dofs_actual, + Number *values_quad, + Number *gradients_quad, + Number *hessians_quad, + Number *scratch_data) { const int runtime_n_q_points_1d = shape_info.data.front().n_q_points_1d; if (runtime_n_q_points_1d == n_q_points_1d) @@ -282,71 +258,64 @@ namespace internal if (n_q_points_1d == degree + 1 && shape_info.element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation) - internal:: - FEEvaluationImplCollocation:: - evaluate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + internal::FEEvaluationImplCollocation:: + evaluate(n_components, + evaluation_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + hessians_quad, + scratch_data); else if (use_collocation) internal::FEEvaluationImplTransformToCollocation< dim, degree, n_q_points_1d, - n_components, - Number>::evaluate(shape_info, + Number>::evaluate(n_components, + evaluation_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + scratch_data); else internal::FEEvaluationImpl< internal::MatrixFreeFunctions::tensor_symmetric, dim, degree, n_q_points_1d, - n_components, - Number>::evaluate(shape_info, + Number>::evaluate(n_components, + evaluation_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + scratch_data); } else - Factory:: - evaluate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + Factory::evaluate( + n_components, + evaluation_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + hessians_quad, + scratch_data); } static inline void integrate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, const internal::MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs_actual, Number * values_quad, Number * gradients_quad, Number * scratch_data, - const bool integrate_values, - const bool integrate_gradients, const bool sum_into_values_array) { const int runtime_n_q_points_1d = shape_info.data.front().n_q_points_1d; @@ -355,29 +324,27 @@ namespace internal if (n_q_points_1d == degree + 1 && shape_info.element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation) - internal:: - FEEvaluationImplCollocation:: - integrate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - scratch_data, - integrate_values, - integrate_gradients, - sum_into_values_array); + internal::FEEvaluationImplCollocation:: + integrate(n_components, + integration_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + scratch_data, + sum_into_values_array); else if (use_collocation) internal::FEEvaluationImplTransformToCollocation< dim, degree, n_q_points_1d, - n_components, - Number>::integrate(shape_info, + Number>::integrate(n_components, + integration_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, scratch_data, - integrate_values, - integrate_gradients, sum_into_values_array); else internal::FEEvaluationImpl< @@ -385,26 +352,25 @@ namespace internal dim, degree, n_q_points_1d, - n_components, - Number>::integrate(shape_info, + Number>::integrate(n_components, + integration_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, scratch_data, - integrate_values, - integrate_gradients, sum_into_values_array); } else - Factory:: - integrate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - scratch_data, - integrate_values, - integrate_gradients, - sum_into_values_array); + Factory::integrate( + n_components, + integration_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + scratch_data, + sum_into_values_array); } }; @@ -414,31 +380,29 @@ namespace internal * This is the entry point for choosing the correct runtime parameters * for the 'evaluate' function. */ - template + template void symmetric_selector_evaluate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, const internal::MatrixFreeFunctions::ShapeInfo &shape_info, - Number * values_dofs_actual, - Number * values_quad, - Number * gradients_quad, - Number * hessians_quad, - Number * scratch_data, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians) + Number *values_dofs_actual, + Number *values_quad, + Number *gradients_quad, + Number *hessians_quad, + Number *scratch_data) { Assert(shape_info.element_type <= internal::MatrixFreeFunctions::tensor_symmetric, ExcInternalError()); - Factory::evaluate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + Factory::evaluate(n_components, + evaluation_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + hessians_quad, + scratch_data); } @@ -447,29 +411,29 @@ namespace internal * This is the entry point for choosing the correct runtime parameters * for the 'integrate' function. */ - template + template void symmetric_selector_integrate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, const internal::MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs_actual, Number * values_quad, Number * gradients_quad, Number * scratch_data, - const bool integrate_values, - const bool integrate_gradients, const bool sum_into_values_array = false) { Assert(shape_info.element_type <= internal::MatrixFreeFunctions::tensor_symmetric, ExcInternalError()); - Factory::integrate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - scratch_data, - integrate_values, - integrate_gradients, - sum_into_values_array); + Factory::integrate(n_components, + integration_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + scratch_data, + sum_into_values_array); } } // namespace EvaluationSelectorImplementation } // namespace internal @@ -487,11 +451,7 @@ namespace internal * $0\leq fe\_degree \leq 9$ and $degree+1\leq n\_q\_points\_1d\leq * fe\_degree+2$. */ -template +template struct SelectEvaluator { /** @@ -513,15 +473,14 @@ struct SelectEvaluator * appropriate template parameters. */ static void - evaluate(const internal::MatrixFreeFunctions::ShapeInfo &shape_info, - Number * values_dofs_actual, - Number * values_quad, - Number * gradients_quad, - Number * hessians_quad, - Number * scratch_data, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians); + evaluate(const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, + const internal::MatrixFreeFunctions::ShapeInfo &shape_info, + Number *values_dofs_actual, + Number *values_quad, + Number *gradients_quad, + Number *hessians_quad, + Number *scratch_data); /** * Chooses an appropriate evaluation strategy for the integrate function, i.e. @@ -531,13 +490,13 @@ struct SelectEvaluator * appropriate template parameters. */ static void - integrate(const internal::MatrixFreeFunctions::ShapeInfo &shape_info, + integrate(const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, + const internal::MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs_actual, Number * values_quad, Number * gradients_quad, Number * scratch_data, - const bool integrate_values, - const bool integrate_gradients, const bool sum_into_values_array = false); }; @@ -551,8 +510,8 @@ struct SelectEvaluator * $degree+1\leq n\_q\_points\_1d\leq fe\_degree+2$, a non-optimized fallback * is used. */ -template -struct SelectEvaluator +template +struct SelectEvaluator { /** * Based on the run time parameters stored in @p shape_info this function @@ -563,15 +522,14 @@ struct SelectEvaluator * appropriate template parameters. */ static void - evaluate(const internal::MatrixFreeFunctions::ShapeInfo &shape_info, - Number * values_dofs_actual, - Number * values_quad, - Number * gradients_quad, - Number * hessians_quad, - Number * scratch_data, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians); + evaluate(const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, + const internal::MatrixFreeFunctions::ShapeInfo &shape_info, + Number *values_dofs_actual, + Number *values_quad, + Number *gradients_quad, + Number *hessians_quad, + Number *scratch_data); /** * Based on the run time parameters stored in @p shape_info this function @@ -582,35 +540,30 @@ struct SelectEvaluator * appropriate template parameters. */ static void - integrate(const internal::MatrixFreeFunctions::ShapeInfo &shape_info, + integrate(const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, + const internal::MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs_actual, Number * values_quad, Number * gradients_quad, Number * scratch_data, - const bool integrate_values, - const bool integrate_gradients, const bool sum_into_values_array = false); }; //----------------------Implementation for SelectEvaluator--------------------- #ifndef DOXYGEN -template +template inline void -SelectEvaluator::evaluate( +SelectEvaluator::evaluate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, const internal::MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs_actual, Number * values_quad, Number * gradients_quad, Number * hessians_quad, - Number * scratch_data, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians) + Number * scratch_data) { Assert(fe_degree >= 0 && n_q_points_1d > 0, ExcInternalError()); @@ -618,17 +571,15 @@ SelectEvaluator::evaluate( shape_info.element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation) { - internal:: - FEEvaluationImplCollocation:: - evaluate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + internal::FEEvaluationImplCollocation::evaluate( + n_components, + evaluation_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + hessians_quad, + scratch_data); } // '<=' on type means tensor_symmetric or tensor_symmetric_hermite, see // shape_info.h for more details @@ -639,16 +590,14 @@ SelectEvaluator::evaluate( dim, fe_degree, n_q_points_1d, - n_components, - Number>::evaluate(shape_info, + Number>::evaluate(n_components, + evaluation_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + scratch_data); } else if (shape_info.element_type <= internal::MatrixFreeFunctions::tensor_symmetric) @@ -658,16 +607,14 @@ SelectEvaluator::evaluate( dim, fe_degree, n_q_points_1d, - n_components, - Number>::evaluate(shape_info, + Number>::evaluate(n_components, + evaluation_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + scratch_data); } else if (shape_info.element_type == internal::MatrixFreeFunctions::tensor_symmetric_plus_dg0) @@ -677,16 +624,14 @@ SelectEvaluator::evaluate( dim, fe_degree, n_q_points_1d, - n_components, - Number>::evaluate(shape_info, + Number>::evaluate(n_components, + evaluation_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + scratch_data); } else if (shape_info.element_type == internal::MatrixFreeFunctions::truncated_tensor) @@ -696,16 +641,14 @@ SelectEvaluator::evaluate( dim, fe_degree, n_q_points_1d, - n_components, - Number>::evaluate(shape_info, + Number>::evaluate(n_components, + evaluation_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + scratch_data); } else if (shape_info.element_type == internal::MatrixFreeFunctions::tensor_general) @@ -714,16 +657,14 @@ SelectEvaluator::evaluate( dim, fe_degree, n_q_points_1d, - n_components, - Number>::evaluate(shape_info, + Number>::evaluate(n_components, + evaluation_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + scratch_data); } else AssertThrow(false, ExcNotImplemented()); @@ -731,20 +672,16 @@ SelectEvaluator::evaluate( -template +template inline void -SelectEvaluator::integrate( +SelectEvaluator::integrate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, const internal::MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs_actual, Number * values_quad, Number * gradients_quad, Number * scratch_data, - const bool integrate_values, - const bool integrate_gradients, const bool sum_into_values_array) { Assert(fe_degree >= 0 && n_q_points_1d > 0, ExcInternalError()); @@ -753,16 +690,15 @@ SelectEvaluator::integrate( shape_info.element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation) { - internal:: - FEEvaluationImplCollocation:: - integrate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - scratch_data, - integrate_values, - integrate_gradients, - sum_into_values_array); + internal::FEEvaluationImplCollocation::integrate( + n_components, + integration_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + scratch_data, + sum_into_values_array); } // '<=' on type means tensor_symmetric or tensor_symmetric_hermite, see // shape_info.h for more details @@ -773,14 +709,13 @@ SelectEvaluator::integrate( dim, fe_degree, n_q_points_1d, - n_components, - Number>::integrate(shape_info, + Number>::integrate(n_components, + integration_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, scratch_data, - integrate_values, - integrate_gradients, sum_into_values_array); } else if (shape_info.element_type <= @@ -791,14 +726,13 @@ SelectEvaluator::integrate( dim, fe_degree, n_q_points_1d, - n_components, - Number>::integrate(shape_info, + Number>::integrate(n_components, + integration_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, scratch_data, - integrate_values, - integrate_gradients, sum_into_values_array); } else if (shape_info.element_type == @@ -809,14 +743,13 @@ SelectEvaluator::integrate( dim, fe_degree, n_q_points_1d, - n_components, - Number>::integrate(shape_info, + Number>::integrate(n_components, + integration_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, scratch_data, - integrate_values, - integrate_gradients, sum_into_values_array); } else if (shape_info.element_type == @@ -827,14 +760,13 @@ SelectEvaluator::integrate( dim, fe_degree, n_q_points_1d, - n_components, - Number>::integrate(shape_info, + Number>::integrate(n_components, + integration_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, scratch_data, - integrate_values, - integrate_gradients, sum_into_values_array); } else if (shape_info.element_type == @@ -844,14 +776,13 @@ SelectEvaluator::integrate( dim, fe_degree, n_q_points_1d, - n_components, - Number>::integrate(shape_info, + Number>::integrate(n_components, + integration_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, scratch_data, - integrate_values, - integrate_gradients, sum_into_values_array); } else @@ -860,18 +791,17 @@ SelectEvaluator::integrate( -template +template inline void -SelectEvaluator::evaluate( +SelectEvaluator::evaluate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags evaluation_flag, const internal::MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs_actual, Number * values_quad, Number * gradients_quad, Number * hessians_quad, - Number * scratch_data, - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians) + Number * scratch_data) { if (shape_info.element_type == internal::MatrixFreeFunctions::tensor_symmetric_plus_dg0) @@ -881,16 +811,14 @@ SelectEvaluator::evaluate( dim, -1, 0, - n_components, - Number>::evaluate(shape_info, + Number>::evaluate(n_components, + evaluation_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + scratch_data); } else if (shape_info.element_type == internal::MatrixFreeFunctions::truncated_tensor) @@ -900,16 +828,14 @@ SelectEvaluator::evaluate( dim, -1, 0, - n_components, - Number>::evaluate(shape_info, + Number>::evaluate(n_components, + evaluation_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + scratch_data); } else if (shape_info.element_type == internal::MatrixFreeFunctions::tensor_general) @@ -917,41 +843,38 @@ SelectEvaluator::evaluate( dim, -1, 0, - n_components, - Number>::evaluate(shape_info, + Number>::evaluate(n_components, + evaluation_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + scratch_data); else internal::EvaluationSelectorImplementation:: - symmetric_selector_evaluate(shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - hessians_quad, - scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + symmetric_selector_evaluate(n_components, + evaluation_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + hessians_quad, + scratch_data); } -template +template inline void -SelectEvaluator::integrate( +SelectEvaluator::integrate( + const unsigned int n_components, + const EvaluationFlags::EvaluationFlags integration_flag, const internal::MatrixFreeFunctions::ShapeInfo &shape_info, Number * values_dofs_actual, Number * values_quad, Number * gradients_quad, Number * scratch_data, - const bool integrate_values, - const bool integrate_gradients, const bool sum_into_values_array) { if (shape_info.element_type == @@ -962,14 +885,13 @@ SelectEvaluator::integrate( dim, -1, 0, - n_components, - Number>::integrate(shape_info, + Number>::integrate(n_components, + integration_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, scratch_data, - integrate_values, - integrate_gradients, sum_into_values_array); } else if (shape_info.element_type == @@ -980,14 +902,13 @@ SelectEvaluator::integrate( dim, -1, 0, - n_components, - Number>::integrate(shape_info, + Number>::integrate(n_components, + integration_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, scratch_data, - integrate_values, - integrate_gradients, sum_into_values_array); } else if (shape_info.element_type == @@ -996,26 +917,24 @@ SelectEvaluator::integrate( dim, -1, 0, - n_components, - Number>::integrate(shape_info, + Number>::integrate(n_components, + integration_flag, + shape_info, values_dofs_actual, values_quad, gradients_quad, scratch_data, - integrate_values, - integrate_gradients, sum_into_values_array); else internal::EvaluationSelectorImplementation:: - symmetric_selector_integrate( - shape_info, - values_dofs_actual, - values_quad, - gradients_quad, - scratch_data, - integrate_values, - integrate_gradients, - sum_into_values_array); + symmetric_selector_integrate(n_components, + integration_flag, + shape_info, + values_dofs_actual, + values_quad, + gradients_quad, + scratch_data, + sum_into_values_array); } #endif // DOXYGEN diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index 62d225bfd1..560d7954ef 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -29,6 +29,7 @@ #include +#include #include #include #include @@ -57,105 +58,6 @@ template operator | would be an - * integer which would in turn trigger a compiler warning when we tried to - * assign it to an object of type UpdateFlags. - * - * @ref EvaluationFlags - */ - inline EvaluationFlags - operator|(const EvaluationFlags f1, const EvaluationFlags f2) - { - return static_cast(static_cast(f1) | - static_cast(f2)); - } - - - - /** - * Global operator which sets the bits from the second argument also in the - * first one. - * - * @ref EvaluationFlags - */ - inline EvaluationFlags & - operator|=(EvaluationFlags &f1, const EvaluationFlags f2) - { - f1 = f1 | f2; - return f1; - } - - - /** - * Global operator which returns an object in which all bits are set which are - * set in the first as well as the second argument. This operator exists since - * if it did not then the result of the bit-and operator & would be - * an integer which would in turn trigger a compiler warning when we tried to - * assign it to an object of type UpdateFlags. - * - * @ref EvaluationFlags - */ - inline EvaluationFlags operator&(const EvaluationFlags f1, - const EvaluationFlags f2) - { - return static_cast(static_cast(f1) & - static_cast(f2)); - } - - - /** - * Global operator which clears all the bits in the first argument if they are - * not also set in the second argument. - * - * @ref EvaluationFlags - */ - inline EvaluationFlags & - operator&=(EvaluationFlags &f1, const EvaluationFlags f2) - { - f1 = f1 & f2; - return f1; - } - -} // namespace EvaluationFlags /** * This is the base class for the FEEvaluation classes. This class is a base @@ -440,8 +342,9 @@ public: /** * Return the value of a finite element function at quadrature point number - * @p q_point after a call to @p evaluate() with EvaluationFlags::value set, or the value that has - * been stored there with a call to @p submit_value. If the object is + * @p q_point after a call to FEEvaluation::evaluate() with + * EvaluationFlags::value set, or the value that has been stored there with + * a call to FEEvaluationBase::submit_value(). If the object is * vector-valued, a vector-valued return argument is given. Note that when * vectorization is enabled, values from several cells are grouped together. * @@ -454,10 +357,11 @@ public: /** * Write a value to the field containing the values on quadrature points - * with component @p q_point. Access to the same field as through @p - * get_value. If applied before the function @p integrate() with EvaluationFlags::values set is - * called, this specifies the value which is tested by all basis function on - * the current cell and integrated over. + * with component @p q_point. Access to the same field as through + * get_value(). If applied before the function FEEvaluation::integrate() + * with EvaluationFlags::values set is called, this specifies the value + * which is tested by all basis function on the current cell and integrated + * over. * * Note that the derived class FEEvaluationAccess overloads this operation * with specializations for the scalar case (n_components == 1) and for the @@ -468,8 +372,9 @@ public: /** * Return the gradient of a finite element function at quadrature point - * number @p q_point after a call to @p evaluate() with EvaluationFlags::gradients, or the value - * that has been stored there with a call to @p submit_gradient. + * number @p q_point after a call to FEEvaluation::evaluate() with + * EvaluationFlags::gradients, or the value that has been stored there with + * a call to FEEvaluationBase::submit_gradient(). * * Note that the derived class FEEvaluationAccess overloads this operation * with specializations for the scalar case (n_components == 1) and for the @@ -480,11 +385,12 @@ public: /** * Return the derivative of a finite element function at quadrature point - * number @p q_point after a call to @p evaluate(...,true,...) in the - * direction normal to the face: - * $\boldsymbol \nabla u(\mathbf x_q) \cdot \mathbf n(\mathbf x_q)$ + * number @p q_point after a call to + * FEEvaluation::evaluate(EvaluationFlags::gradients) the direction normal + * to the face: $\boldsymbol \nabla u(\mathbf x_q) \cdot \mathbf n(\mathbf + * x_q)$ * - * This call is equivalent to calling `get_gradient() * get_normal_vector()` + * This call is equivalent to calling get_gradient() * get_normal_vector() * but will use a more efficient internal representation of data. * * Note that the derived class FEEvaluationAccess overloads this operation @@ -497,10 +403,10 @@ public: /** * Write a contribution that is tested by the gradient to the field * containing the values on quadrature points with component @p q_point. - * Access to the same field as through get_gradient(). If applied before - * the function @p integrate(...,true) is called, this specifies what is - * tested by all basis function gradients on the current cell and integrated - * over. + * Access to the same field as through get_gradient(). If applied before the + * function FEEvaluation::integrate(EvaluationFlags::gradients) is called, + * this specifies what is tested by all basis function gradients on the + * current cell and integrated over. * * Note that the derived class FEEvaluationAccess overloads this operation * with specializations for the scalar case (n_components == 1) and for the @@ -513,9 +419,10 @@ public: * Write a contribution that is tested by the gradient to the field * containing the values on quadrature points with component @p * q_point. Access to the same field as through get_gradient() or - * get_normal_derivative(). If applied before the function @p - * integrate(...,true) is called, this specifies what is tested by all basis - * function gradients on the current cell and integrated over. + * get_normal_derivative(). If applied before the function + * FEEvaluation::integrate(EvaluationFlags::gradients) is called, this + * specifies what is tested by all basis function gradients on the current + * cell and integrated over. * * @note This operation writes the data to the same field as * submit_gradient(). As a consequence, only one of these two can be @@ -532,9 +439,10 @@ public: /** * Return the Hessian of a finite element function at quadrature point - * number @p q_point after a call to @p evaluate(...,true). If only the - * diagonal or even the trace of the Hessian, the Laplacian, is needed, use - * the other functions below. + * number @p q_point after a call to + * FEEvaluation::evaluate(EvaluationFlags::hessians). If only the diagonal + * or even the trace of the Hessian, the Laplacian, is needed, use the other + * functions below. * * Note that the derived class FEEvaluationAccess overloads this operation * with specializations for the scalar case (n_components == 1) and for the @@ -545,7 +453,8 @@ public: /** * Return the diagonal of the Hessian of a finite element function at - * quadrature point number @p q_point after a call to @p evaluate(...,true). + * quadrature point number @p q_point after a call to + * FEEvaluation::evaluate(EvaluationFlags::hessians). * * Note that the derived class FEEvaluationAccess overloads this operation * with specializations for the scalar case (n_components == 1) and for the @@ -555,10 +464,11 @@ public: get_hessian_diagonal(const unsigned int q_point) const; /** - * Return the Laplacian (i.e., the trace of the Hessian) of a finite - * element function at quadrature point number @p q_point after a call to @p - * evaluate(...,true). Compared to the case when computing the full Hessian, - * some operations can be saved when only the Laplacian is requested. + * Return the Laplacian (i.e., the trace of the Hessian) of a finite element + * function at quadrature point number @p q_point after a call to + * FEEvaluation::evaluate(EvaluationFlags::hessians). Compared to the case + * when computing the full Hessian, some operations can be saved when only + * the Laplacian is requested. * * Note that the derived class FEEvaluationAccess overloads this operation * with specializations for the scalar case (n_components == 1) and for the @@ -7326,30 +7236,14 @@ FEEvaluation::evaluate(*this->data, - const_cast( - values_array), - this->values_quad, - this->gradients_quad, - this->hessians_quad, - this->scratch_data, - evaluate_values, - evaluate_gradients, - evaluate_hessians); + const EvaluationFlags::EvaluationFlags flag = + ((evaluate_values) ? EvaluationFlags::values : EvaluationFlags::nothing) | + ((evaluate_gradients) ? EvaluationFlags::gradients : + EvaluationFlags::nothing) | + ((evaluate_hessians) ? EvaluationFlags::hessians : + EvaluationFlags::nothing); -# ifdef DEBUG - if (evaluate_values == true) - this->values_quad_initialized = true; - if (evaluate_gradients == true) - this->gradients_quad_initialized = true; - if (evaluate_hessians == true) - this->hessians_quad_initialized = true; -# endif + evaluate(values_array, flag); } @@ -7370,20 +7264,15 @@ FEEvaluation:: - evaluate(*this->data, - const_cast(values_array), - this->values_quad, - this->gradients_quad, - this->hessians_quad, - this->scratch_data, - evaluation_flags & EvaluationFlags::values, - evaluation_flags & EvaluationFlags::gradients, - evaluation_flags & EvaluationFlags::hessians); + SelectEvaluator::evaluate( + n_components, + evaluation_flags, + *this->data, + const_cast(values_array), + this->values_quad, + this->gradients_quad, + this->hessians_quad, + this->scratch_data); # ifdef DEBUG if (evaluation_flags & EvaluationFlags::values) @@ -7412,10 +7301,9 @@ FEEvaluation< n_components_, Number, VectorizedArrayType>::gather_evaluate(const VectorType &input_vector, - - const bool evaluate_values, - const bool evaluate_gradients, - const bool evaluate_hessians) + const bool evaluate_values, + const bool evaluate_gradients, + const bool evaluate_hessians) { const EvaluationFlags::EvaluationFlags flag = ((evaluate_values) ? EvaluationFlags::values : EvaluationFlags::nothing) | @@ -7472,18 +7360,12 @@ FEEvaluationfirst_selected_component] * VectorizedArrayType::size()); - evaluate(vec_values, - evaluation_flag & EvaluationFlags::values, - evaluation_flag & EvaluationFlags::gradients, - evaluation_flag & EvaluationFlags::hessians); + evaluate(vec_values, evaluation_flag); } else { this->read_dof_values(input_vector); - evaluate(this->begin_dof_values(), - evaluation_flag & EvaluationFlags::values, - evaluation_flag & EvaluationFlags::gradients, - evaluation_flag & EvaluationFlags::hessians); + evaluate(this->begin_dof_values(), evaluation_flag); } } @@ -7553,34 +7435,11 @@ FEEvaluationvalues_quad_submitted == true, - internal::ExcAccessToUninitializedField()); - if (integrate_gradients == true) - Assert(this->gradients_quad_submitted == true, - internal::ExcAccessToUninitializedField()); -# endif - Assert(this->matrix_info != nullptr || - this->mapped_geometry->is_initialized(), - ExcNotInitialized()); - - SelectEvaluator::integrate(*this->data, - values_array, - this->values_quad, - this->gradients_quad, - this->scratch_data, - integrate_values, - integrate_gradients, - false); - -# ifdef DEBUG - this->dof_values_initialized = true; -# endif + EvaluationFlags::EvaluationFlags flag = + (integrate_values ? EvaluationFlags::values : EvaluationFlags::nothing) | + (integrate_gradients ? EvaluationFlags::gradients : + EvaluationFlags::nothing); + integrate(flag, values_array); } @@ -7619,20 +7478,15 @@ FEEvaluation::integrate(*this->data, - values_array, - this->values_quad, - this->gradients_quad, - this->scratch_data, - integration_flag & - EvaluationFlags::values, - integration_flag & - EvaluationFlags::gradients, - false); + SelectEvaluator:: + integrate(n_components, + integration_flag, + *this->data, + values_array, + this->values_quad, + this->gradients_quad, + this->scratch_data, + false); # ifdef DEBUG this->dof_values_initialized = true; @@ -7683,7 +7537,7 @@ FEEvaluation:: - integrate_scatter(const EvaluationFlags::EvaluationFlags evaluation_flag, + integrate_scatter(const EvaluationFlags::EvaluationFlags integration_flag, VectorType & destination) { // If the index storage is interleaved and contiguous and the vector storage @@ -7713,27 +7567,19 @@ FEEvaluationcomponent_dof_indices_offset[this->active_fe_index] [this->first_selected_component] * VectorizedArrayType::size()); - SelectEvaluator< - dim, - fe_degree, - n_q_points_1d, - n_components, - VectorizedArrayType>::integrate(*this->data, - vec_values, - this->values_quad, - this->gradients_quad, - this->scratch_data, - evaluation_flag & - EvaluationFlags::values, - evaluation_flag & - EvaluationFlags::gradients, - true); + SelectEvaluator:: + integrate(n_components, + integration_flag, + *this->data, + vec_values, + this->values_quad, + this->gradients_quad, + this->scratch_data, + true); } else { - integrate(evaluation_flag & EvaluationFlags::values, - evaluation_flag & EvaluationFlags::gradients, - this->begin_dof_values()); + integrate(integration_flag, this->begin_dof_values()); this->distribute_local_to_global(destination); } } diff --git a/include/deal.II/matrix_free/mapping_info.templates.h b/include/deal.II/matrix_free/mapping_info.templates.h index 0ed71677c9..0bb14d8b78 100644 --- a/include/deal.II/matrix_free/mapping_info.templates.h +++ b/include/deal.II/matrix_free/mapping_info.templates.h @@ -1302,16 +1302,18 @@ namespace internal start_indices, cell_points.data()); - SelectEvaluator::evaluate( + SelectEvaluator::evaluate( + dim, + EvaluationFlags::values | EvaluationFlags::gradients | + (update_flags_cells & update_jacobian_grads ? + EvaluationFlags::hessians : + EvaluationFlags::nothing), shape_info, cell_points.data(), cell_quads.data(), cell_grads.data(), cell_grad_grads.data(), - scratch_data.data(), - true, - true, - update_flags_cells & update_jacobian_grads); + scratch_data.data()); } if (update_flags_cells & update_quadrature_points) { diff --git a/include/deal.II/matrix_free/operators.h b/include/deal.II/matrix_free/operators.h index 16c85505e5..9e68e74c98 100644 --- a/include/deal.II/matrix_free/operators.h +++ b/include/deal.II/matrix_free/operators.h @@ -1016,11 +1016,9 @@ namespace MatrixFreeOperators VectorizedArrayType>::apply(const VectorizedArrayType *in_array, VectorizedArrayType * out_array) const { - internal::CellwiseInverseMassMatrixImpl< - dim, - fe_degree, - n_components, - VectorizedArrayType>::apply(fe_eval, in_array, out_array); + internal:: + CellwiseInverseMassMatrixImpl::apply( + n_components, fe_eval, in_array, out_array); } @@ -1041,15 +1039,13 @@ namespace MatrixFreeOperators const VectorizedArrayType * in_array, VectorizedArrayType * out_array) const { - internal::CellwiseInverseMassMatrixImpl:: - apply(fe_eval.get_shape_info().data.front().inverse_shape_values_eo, - inverse_coefficients, - n_actual_components, - in_array, - out_array); + internal:: + CellwiseInverseMassMatrixImpl::apply( + n_actual_components, + fe_eval.get_shape_info().data.front().inverse_shape_values_eo, + inverse_coefficients, + in_array, + out_array); } @@ -1069,15 +1065,13 @@ namespace MatrixFreeOperators const VectorizedArrayType *in_array, VectorizedArrayType * out_array) const { - internal::CellwiseInverseMassMatrixImpl:: - transform_from_q_points_to_basis( - fe_eval.get_shape_info().data.front().inverse_shape_values_eo, - n_actual_components, - in_array, - out_array); + internal:: + CellwiseInverseMassMatrixImpl:: + transform_from_q_points_to_basis( + n_actual_components, + fe_eval.get_shape_info().data.front().inverse_shape_values_eo, + in_array, + out_array); } diff --git a/source/fe/mapping_q_generic.cc b/source/fe/mapping_q_generic.cc index 49a0eea8e4..fa08b3466a 100644 --- a/source/fe/mapping_q_generic.cc +++ b/source/fe/mapping_q_generic.cc @@ -1477,27 +1477,36 @@ namespace internal constexpr unsigned int n_comp = 1 + (spacedim - 1) / n_lanes; constexpr unsigned int n_hessians = (dim * (dim + 1)) / 2; - const bool evaluate_values = update_flags & update_quadrature_points; - const bool evaluate_gradients = - (cell_similarity != CellSimilarity::translation) && - (update_flags & update_contravariant_transformation); - const bool evaluate_hessians = - (cell_similarity != CellSimilarity::translation) && - (update_flags & update_jacobian_grads); - - Assert(!evaluate_values || n_q_points > 0, ExcInternalError()); - Assert(!evaluate_values || n_q_points == quadrature_points.size(), + EvaluationFlags::EvaluationFlags evaluation_flag = + (update_flags & update_quadrature_points ? EvaluationFlags::values : + EvaluationFlags::nothing) | + ((cell_similarity != CellSimilarity::translation) && + (update_flags & update_contravariant_transformation) ? + EvaluationFlags::gradients : + EvaluationFlags::nothing) | + ((cell_similarity != CellSimilarity::translation) && + (update_flags & update_jacobian_grads) ? + EvaluationFlags::hessians : + EvaluationFlags::nothing); + + Assert(!(evaluation_flag & EvaluationFlags::values) || n_q_points > 0, + ExcInternalError()); + Assert(!(evaluation_flag & EvaluationFlags::values) || + n_q_points == quadrature_points.size(), ExcDimensionMismatch(n_q_points, quadrature_points.size())); - Assert(!evaluate_gradients || data.n_shape_functions > 0, + Assert(!(evaluation_flag & EvaluationFlags::gradients) || + data.n_shape_functions > 0, ExcInternalError()); - Assert(!evaluate_gradients || n_q_points == data.contravariant.size(), + Assert(!(evaluation_flag & EvaluationFlags::gradients) || + n_q_points == data.contravariant.size(), ExcDimensionMismatch(n_q_points, data.contravariant.size())); - Assert(!evaluate_hessians || n_q_points == jacobian_grads.size(), + Assert(!(evaluation_flag & EvaluationFlags::hessians) || + n_q_points == jacobian_grads.size(), ExcDimensionMismatch(n_q_points, jacobian_grads.size())); // shortcut in case we have an identity interpolation and only request // the quadrature points - if (evaluate_values && !evaluate_gradients & !evaluate_hessians && + if (evaluation_flag == EvaluationFlags::values && data.shape_info.element_type == internal::MatrixFreeFunctions::tensor_symmetric_collocation) { @@ -1509,14 +1518,14 @@ namespace internal } // prepare arrays - if (evaluate_values || evaluate_gradients || evaluate_hessians) + if (evaluation_flag != EvaluationFlags::nothing) { data.values_dofs.resize(n_comp * n_shape_values); data.values_quad.resize(n_comp * n_q_points); data.gradients_quad.resize(n_comp * n_q_points * dim); data.scratch.resize(2 * std::max(n_q_points, n_shape_values)); - if (evaluate_hessians) + if (evaluation_flag & EvaluationFlags::hessians) data.hessians_quad.resize(n_comp * n_q_points * n_hessians); const std::vector &renumber_to_lexicographic = @@ -1532,20 +1541,19 @@ namespace internal } // do the actual tensorized evaluation - SelectEvaluator>:: - evaluate(data.shape_info, - data.values_dofs.begin(), - data.values_quad.begin(), - data.gradients_quad.begin(), - data.hessians_quad.begin(), - data.scratch.begin(), - evaluate_values, - evaluate_gradients, - evaluate_hessians); + SelectEvaluator>::evaluate( + n_comp, + evaluation_flag, + data.shape_info, + data.values_dofs.begin(), + data.values_quad.begin(), + data.gradients_quad.begin(), + data.hessians_quad.begin(), + data.scratch.begin()); } // do the postprocessing - if (evaluate_values) + if (evaluation_flag & EvaluationFlags::values) { for (unsigned int out_comp = 0; out_comp < n_comp; ++out_comp) for (unsigned int i = 0; i < n_q_points; ++i) @@ -1557,7 +1565,7 @@ namespace internal data.values_quad[out_comp * n_q_points + i][in_comp]; } - if (evaluate_gradients) + if (evaluation_flag & EvaluationFlags::gradients) { std::fill(data.contravariant.begin(), data.contravariant.end(), @@ -1593,7 +1601,7 @@ namespace internal data.volume_elements[point] = data.contravariant[point].determinant(); - if (evaluate_hessians) + if (evaluation_flag & EvaluationFlags::hessians) { constexpr int desymmetrize_3d[6][2] = { {0, 0}, {1, 1}, {2, 2}, {0, 1}, {0, 2}, {1, 2}}; diff --git a/source/matrix_free/evaluation_selector.inst.in b/source/matrix_free/evaluation_selector.inst.in index e456056bb4..1a856fc640 100644 --- a/source/matrix_free/evaluation_selector.inst.in +++ b/source/matrix_free/evaluation_selector.inst.in @@ -14,37 +14,29 @@ // --------------------------------------------------------------------- -for (deal_II_dimension : DIMENSIONS; components : SPACE_DIMENSIONS; - scalar_type : REAL_SCALARS) +for (deal_II_dimension : DIMENSIONS; scalar_type : REAL_SCALARS) { - template void SelectEvaluator>:: - integrate(const internal::MatrixFreeFunctions::ShapeInfo< + template void + SelectEvaluator>:: + integrate(const unsigned int, + const EvaluationFlags::EvaluationFlags, + const internal::MatrixFreeFunctions::ShapeInfo< VectorizedArray> &shape_info, VectorizedArray *, VectorizedArray *, VectorizedArray *, VectorizedArray *, - const bool, - const bool, const bool); - template void SelectEvaluator>:: - evaluate(const internal::MatrixFreeFunctions::ShapeInfo< + template void + SelectEvaluator>:: + evaluate(const unsigned int, + const EvaluationFlags::EvaluationFlags, + const internal::MatrixFreeFunctions::ShapeInfo< VectorizedArray> &shape_info, VectorizedArray *, VectorizedArray *, VectorizedArray *, VectorizedArray *, - VectorizedArray *, - const bool, - const bool, - const bool); + VectorizedArray *); } diff --git a/source/multigrid/mg_transfer_matrix_free.cc b/source/multigrid/mg_transfer_matrix_free.cc index 13dd1c1a21..153f0d28b6 100644 --- a/source/multigrid/mg_transfer_matrix_free.cc +++ b/source/multigrid/mg_transfer_matrix_free.cc @@ -462,10 +462,10 @@ MGTransferMatrixFree::do_prolongate_add( dim, degree + 1, 2 * degree + 1, - 1, VectorizedArray, VectorizedArray>:: - do_forward(prolongation_matrix_1d, + do_forward(1, + prolongation_matrix_1d, evaluation_data.begin() + c * Utilities::fixed_power(degree_size), evaluation_data.begin() + c * n_scalar_cell_dofs, @@ -484,10 +484,10 @@ MGTransferMatrixFree::do_prolongate_add( dim, degree + 1, 2 * degree + 2, - 1, VectorizedArray, VectorizedArray>:: - do_forward(prolongation_matrix_1d, + do_forward(1, + prolongation_matrix_1d, evaluation_data.begin() + c * Utilities::fixed_power(degree_size), evaluation_data.begin() + c * n_scalar_cell_dofs, @@ -560,10 +560,10 @@ MGTransferMatrixFree::do_restrict_add( dim, degree + 1, 2 * degree + 1, - 1, VectorizedArray, VectorizedArray>:: - do_backward(prolongation_matrix_1d, + do_backward(1, + prolongation_matrix_1d, false, evaluation_data.begin() + c * n_scalar_cell_dofs, evaluation_data.begin() + @@ -578,10 +578,10 @@ MGTransferMatrixFree::do_restrict_add( dim, degree + 1, 2 * degree + 2, - 1, VectorizedArray, VectorizedArray>:: - do_backward(prolongation_matrix_1d, + do_backward(1, + prolongation_matrix_1d, false, evaluation_data.begin() + c * n_scalar_cell_dofs, evaluation_data.begin() + -- 2.39.5