From bcbd9e9f96830fc9ef8cd3a0ae3415f5f79f9cf5 Mon Sep 17 00:00:00 2001 From: David Wells Date: Fri, 2 Jun 2023 10:48:10 -0400 Subject: [PATCH] Make all higher derivative functions of FEValues use ReadVector. --- include/deal.II/fe/fe_values.h | 182 +++++++++----------- source/fe/fe_values.cc | 303 ++++++++++++--------------------- source/fe/fe_values.inst.in | 165 ++++++++---------- 3 files changed, 263 insertions(+), 387 deletions(-) diff --git a/include/deal.II/fe/fe_values.h b/include/deal.II/fe/fe_values.h index 218b391153..b34b0c5e70 100644 --- a/include/deal.II/fe/fe_values.h +++ b/include/deal.II/fe/fe_values.h @@ -520,12 +520,11 @@ namespace FEValuesViews * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_hessians( - const InputVector &fe_function, - std::vector> - &hessians) const; + const ReadVector & fe_function, + std::vector> &hessians) const; /** * This function relates to get_function_hessians() in the same way @@ -559,12 +558,11 @@ namespace FEValuesViews * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_laplacians( - const InputVector &fe_function, - std::vector> - &laplacians) const; + const ReadVector & fe_function, + std::vector> &laplacians) const; /** * This function relates to get_function_laplacians() in the same way @@ -598,13 +596,12 @@ namespace FEValuesViews * * @dealiiRequiresUpdateFlags{update_third_derivatives} */ - template + template void get_function_third_derivatives( - const InputVector &fe_function, - std::vector< - solution_third_derivative_type> - &third_derivatives) const; + const ReadVector & fe_function, + std::vector> &third_derivatives) + const; /** * This function relates to get_function_third_derivatives() in the same way @@ -1212,12 +1209,11 @@ namespace FEValuesViews * * @dealiiRequiresUpdateFlags{update_gradients} */ - template + template void get_function_symmetric_gradients( - const InputVector &fe_function, - std::vector< - solution_symmetric_gradient_type> + const ReadVector &fe_function, + std::vector> &symmetric_gradients) const; /** @@ -1252,12 +1248,11 @@ namespace FEValuesViews * * @dealiiRequiresUpdateFlags{update_gradients} */ - template + template void get_function_divergences( - const InputVector &fe_function, - std::vector> - &divergences) const; + const ReadVector & fe_function, + std::vector> &divergences) const; /** * This function relates to get_function_divergences() in the same way @@ -1290,12 +1285,10 @@ namespace FEValuesViews * * @dealiiRequiresUpdateFlags{update_gradients} */ - template + template void - get_function_curls( - const InputVector &fe_function, - std::vector> &curls) - const; + get_function_curls(const ReadVector & fe_function, + std::vector> &curls) const; /** * This function relates to get_function_curls() in the same way @@ -1327,12 +1320,11 @@ namespace FEValuesViews * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_hessians( - const InputVector &fe_function, - std::vector> - &hessians) const; + const ReadVector & fe_function, + std::vector> &hessians) const; /** * This function relates to get_function_hessians() in the same way @@ -1365,12 +1357,11 @@ namespace FEValuesViews * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_laplacians( - const InputVector &fe_function, - std::vector> - &laplacians) const; + const ReadVector & fe_function, + std::vector> &laplacians) const; /** * This function relates to get_function_laplacians() in the same way @@ -1403,13 +1394,12 @@ namespace FEValuesViews * * @dealiiRequiresUpdateFlags{update_third_derivatives} */ - template + template void get_function_third_derivatives( - const InputVector &fe_function, - std::vector< - solution_third_derivative_type> - &third_derivatives) const; + const ReadVector & fe_function, + std::vector> &third_derivatives) + const; /** * This function relates to get_function_third_derivatives() in the same way @@ -1745,12 +1735,11 @@ namespace FEValuesViews * * @dealiiRequiresUpdateFlags{update_gradients} */ - template + template void get_function_divergences( - const InputVector &fe_function, - std::vector> - &divergences) const; + const ReadVector & fe_function, + std::vector> &divergences) const; /** * This function relates to get_function_divergences() in the same way @@ -2119,12 +2108,11 @@ namespace FEValuesViews * * @dealiiRequiresUpdateFlags{update_gradients} */ - template + template void get_function_divergences( - const InputVector &fe_function, - std::vector> - &divergences) const; + const ReadVector & fe_function, + std::vector> &divergences) const; /** * This function relates to get_function_divergences() in the same way @@ -2986,12 +2974,11 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_hessians( - const InputVector &fe_function, - std::vector> - &hessians) const; + const ReadVector & fe_function, + std::vector> &hessians) const; /** * This function does the same as the other get_function_hessians(), but @@ -3010,13 +2997,11 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_hessians( - const InputVector &fe_function, - std::vector< - std::vector>> - & hessians, + const ReadVector & fe_function, + std::vector>> &hessians, const bool quadrature_points_fastest = false) const; /** @@ -3027,13 +3012,12 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_hessians( - const InputVector & fe_function, + const ReadVector & fe_function, const ArrayView &indices, - std::vector> - &hessians) const; + std::vector> & hessians) const; /** * This function relates to the first of the get_function_hessians() function @@ -3043,14 +3027,12 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_hessians( - const InputVector & fe_function, - const ArrayView &indices, - ArrayView< - std::vector>> - hessians, + const ReadVector & fe_function, + const ArrayView & indices, + ArrayView>> hessians, const bool quadrature_points_fastest = false) const; /** @@ -3093,11 +3075,10 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void - get_function_laplacians( - const InputVector & fe_function, - std::vector &laplacians) const; + get_function_laplacians(const ReadVector &fe_function, + std::vector & laplacians) const; /** * This function does the same as the other get_function_laplacians(), but @@ -3118,11 +3099,10 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void - get_function_laplacians( - const InputVector & fe_function, - std::vector> &laplacians) const; + get_function_laplacians(const ReadVector & fe_function, + std::vector> &laplacians) const; /** * This function relates to the first of the get_function_laplacians() @@ -3132,12 +3112,12 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_laplacians( - const InputVector & fe_function, + const ReadVector & fe_function, const ArrayView &indices, - std::vector & laplacians) const; + std::vector & laplacians) const; /** * This function relates to the first of the get_function_laplacians() @@ -3147,12 +3127,12 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_laplacians( - const InputVector & fe_function, - const ArrayView & indices, - std::vector> &laplacians) const; + const ReadVector & fe_function, + const ArrayView &indices, + std::vector> & laplacians) const; /** * This function relates to the first of the get_function_laplacians() @@ -3162,12 +3142,12 @@ public: * * @dealiiRequiresUpdateFlags{update_hessians} */ - template + template void get_function_laplacians( - const InputVector & fe_function, - const ArrayView & indices, - std::vector> &laplacians, + const ReadVector & fe_function, + const ArrayView &indices, + std::vector> & laplacians, const bool quadrature_points_fastest = false) const; /** @} */ @@ -3212,12 +3192,11 @@ public: * * @dealiiRequiresUpdateFlags{update_3rd_derivatives} */ - template + template void get_function_third_derivatives( - const InputVector &fe_function, - std::vector> - &third_derivatives) const; + const ReadVector & fe_function, + std::vector> &third_derivatives) const; /** * This function does the same as the other @@ -3237,13 +3216,11 @@ public: * * @dealiiRequiresUpdateFlags{update_3rd_derivatives} */ - template + template void get_function_third_derivatives( - const InputVector &fe_function, - std::vector< - std::vector>> - & third_derivatives, + const ReadVector & fe_function, + std::vector>> &third_derivatives, const bool quadrature_points_fastest = false) const; /** @@ -3254,13 +3231,12 @@ public: * * @dealiiRequiresUpdateFlags{update_3rd_derivatives} */ - template + template void get_function_third_derivatives( - const InputVector & fe_function, + const ReadVector & fe_function, const ArrayView &indices, - std::vector> - &third_derivatives) const; + std::vector> & third_derivatives) const; /** * This function relates to the first of the get_function_third_derivatives() @@ -3270,14 +3246,12 @@ public: * * @dealiiRequiresUpdateFlags{update_3rd_derivatives} */ - template + template void get_function_third_derivatives( - const InputVector & fe_function, - const ArrayView &indices, - ArrayView< - std::vector>> - third_derivatives, + const ReadVector & fe_function, + const ArrayView & indices, + ArrayView>> third_derivatives, const bool quadrature_points_fastest = false) const; /** @} */ diff --git a/source/fe/fe_values.cc b/source/fe/fe_values.cc index 7df91e0af0..ffe9371e6b 100644 --- a/source/fe/fe_values.cc +++ b/source/fe/fe_values.cc @@ -32,18 +32,7 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include #include @@ -56,25 +45,6 @@ DEAL_II_NAMESPACE_OPEN namespace internal { - template - typename VectorType::value_type inline get_vector_element( - const VectorType & vector, - const types::global_dof_index cell_number) - { - return internal::ElementAccess::get(vector, cell_number); - } - - - - IndexSet::value_type inline get_vector_element( - const IndexSet & is, - const types::global_dof_index cell_number) - { - return (is.is_element(cell_number) ? 1 : 0); - } - - - template inline std::vector make_shape_function_to_row_table(const FiniteElement &fe) @@ -1643,12 +1613,11 @@ namespace FEValuesViews template - template + template void Scalar::get_function_hessians( - const InputVector &fe_function, - std::vector> - &hessians) const + const ReadVector & fe_function, + std::vector> &hessians) const { Assert(fe_values->update_flags & update_hessians, (typename FEValuesBase::ExcAccessToUninitializedField( @@ -1659,8 +1628,7 @@ namespace FEValuesViews fe_values->present_cell.n_dofs_for_dof_handler()); // get function values of dofs on this cell - dealii::Vector dof_values( - fe_values->dofs_per_cell); + dealii::Vector dof_values(fe_values->dofs_per_cell); fe_values->present_cell.get_interpolated_dof_values(fe_function, dof_values); internal::do_function_derivatives<2, dim, spacedim>( @@ -1697,12 +1665,11 @@ namespace FEValuesViews template - template + template void Scalar::get_function_laplacians( - const InputVector &fe_function, - std::vector> - &laplacians) const + const ReadVector & fe_function, + std::vector> &laplacians) const { Assert(fe_values->update_flags & update_hessians, (typename FEValuesBase::ExcAccessToUninitializedField( @@ -1713,8 +1680,7 @@ namespace FEValuesViews fe_values->present_cell.n_dofs_for_dof_handler()); // get function values of dofs on this cell - dealii::Vector dof_values( - fe_values->dofs_per_cell); + dealii::Vector dof_values(fe_values->dofs_per_cell); fe_values->present_cell.get_interpolated_dof_values(fe_function, dof_values); internal::do_function_laplacians( @@ -1751,13 +1717,12 @@ namespace FEValuesViews template - template + template void Scalar::get_function_third_derivatives( - const InputVector &fe_function, - std::vector< - solution_third_derivative_type> - &third_derivatives) const + const ReadVector & fe_function, + std::vector> &third_derivatives) + const { Assert(fe_values->update_flags & update_3rd_derivatives, (typename FEValuesBase::ExcAccessToUninitializedField( @@ -1768,8 +1733,7 @@ namespace FEValuesViews fe_values->present_cell.n_dofs_for_dof_handler()); // get function values of dofs on this cell - dealii::Vector dof_values( - fe_values->dofs_per_cell); + dealii::Vector dof_values(fe_values->dofs_per_cell); fe_values->present_cell.get_interpolated_dof_values(fe_function, dof_values); internal::do_function_derivatives<3, dim, spacedim>( @@ -1909,13 +1873,12 @@ namespace FEValuesViews template - template + template void Vector::get_function_symmetric_gradients( - const InputVector &fe_function, - std::vector< - solution_symmetric_gradient_type> - &symmetric_gradients) const + const ReadVector & fe_function, + std::vector> &symmetric_gradients) + const { Assert(fe_values->update_flags & update_gradients, (typename FEValuesBase::ExcAccessToUninitializedField( @@ -1926,8 +1889,7 @@ namespace FEValuesViews fe_values->present_cell.n_dofs_for_dof_handler()); // get function values of dofs on this cell - dealii::Vector dof_values( - fe_values->dofs_per_cell); + dealii::Vector dof_values(fe_values->dofs_per_cell); fe_values->present_cell.get_interpolated_dof_values(fe_function, dof_values); internal::do_function_symmetric_gradients( @@ -1965,12 +1927,11 @@ namespace FEValuesViews template - template + template void Vector::get_function_divergences( - const InputVector &fe_function, - std::vector> - &divergences) const + const ReadVector & fe_function, + std::vector> &divergences) const { Assert(fe_values->update_flags & update_gradients, (typename FEValuesBase::ExcAccessToUninitializedField( @@ -1982,8 +1943,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values( - fe_values->dofs_per_cell); + dealii::Vector dof_values(fe_values->dofs_per_cell); fe_values->present_cell.get_interpolated_dof_values(fe_function, dof_values); internal::do_function_divergences( @@ -2020,12 +1980,11 @@ namespace FEValuesViews template - template + template void Vector::get_function_curls( - const InputVector &fe_function, - std::vector> &curls) - const + const ReadVector & fe_function, + std::vector> &curls) const { Assert(fe_values->update_flags & update_gradients, (typename FEValuesBase::ExcAccessToUninitializedField( @@ -2036,8 +1995,7 @@ namespace FEValuesViews fe_values->present_cell.n_dofs_for_dof_handler()); // get function values of dofs on this cell - dealii::Vector dof_values( - fe_values->dofs_per_cell); + dealii::Vector dof_values(fe_values->dofs_per_cell); fe_values->present_cell.get_interpolated_dof_values(fe_function, dof_values); internal::do_function_curls( @@ -2074,12 +2032,11 @@ namespace FEValuesViews template - template + template void Vector::get_function_hessians( - const InputVector &fe_function, - std::vector> - &hessians) const + const ReadVector & fe_function, + std::vector> &hessians) const { Assert(fe_values->update_flags & update_hessians, (typename FEValuesBase::ExcAccessToUninitializedField( @@ -2090,8 +2047,7 @@ namespace FEValuesViews fe_values->present_cell.n_dofs_for_dof_handler()); // get function values of dofs on this cell - dealii::Vector dof_values( - fe_values->dofs_per_cell); + dealii::Vector dof_values(fe_values->dofs_per_cell); fe_values->present_cell.get_interpolated_dof_values(fe_function, dof_values); internal::do_function_derivatives<2, dim, spacedim>( @@ -2128,12 +2084,11 @@ namespace FEValuesViews template - template + template void Vector::get_function_laplacians( - const InputVector &fe_function, - std::vector> - &laplacians) const + const ReadVector & fe_function, + std::vector> &laplacians) const { Assert(fe_values->update_flags & update_hessians, (typename FEValuesBase::ExcAccessToUninitializedField( @@ -2149,8 +2104,7 @@ namespace FEValuesViews fe_values->present_cell.n_dofs_for_dof_handler())); // get function values of dofs on this cell - dealii::Vector dof_values( - fe_values->dofs_per_cell); + dealii::Vector dof_values(fe_values->dofs_per_cell); fe_values->present_cell.get_interpolated_dof_values(fe_function, dof_values); internal::do_function_laplacians( @@ -2190,13 +2144,12 @@ namespace FEValuesViews template - template + template void Vector::get_function_third_derivatives( - const InputVector &fe_function, - std::vector< - solution_third_derivative_type> - &third_derivatives) const + const ReadVector & fe_function, + std::vector> &third_derivatives) + const { Assert(fe_values->update_flags & update_3rd_derivatives, (typename FEValuesBase::ExcAccessToUninitializedField( @@ -2207,8 +2160,7 @@ namespace FEValuesViews fe_values->present_cell.n_dofs_for_dof_handler()); // get function values of dofs on this cell - dealii::Vector dof_values( - fe_values->dofs_per_cell); + dealii::Vector dof_values(fe_values->dofs_per_cell); fe_values->present_cell.get_interpolated_dof_values(fe_function, dof_values); internal::do_function_derivatives<3, dim, spacedim>( @@ -2296,12 +2248,11 @@ namespace FEValuesViews template - template + template void SymmetricTensor<2, dim, spacedim>::get_function_divergences( - const InputVector &fe_function, - std::vector> - &divergences) const + const ReadVector & fe_function, + std::vector> &divergences) const { Assert(fe_values->update_flags & update_gradients, (typename FEValuesBase::ExcAccessToUninitializedField( @@ -2313,8 +2264,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values( - fe_values->dofs_per_cell); + dealii::Vector dof_values(fe_values->dofs_per_cell); fe_values->present_cell.get_interpolated_dof_values(fe_function, dof_values); internal::do_function_divergences( @@ -2402,12 +2352,11 @@ namespace FEValuesViews template - template + template void Tensor<2, dim, spacedim>::get_function_divergences( - const InputVector &fe_function, - std::vector> - &divergences) const + const ReadVector & fe_function, + std::vector> &divergences) const { Assert(fe_values->update_flags & update_gradients, (typename FEValuesBase::ExcAccessToUninitializedField( @@ -2419,8 +2368,7 @@ namespace FEValuesViews // get function values of dofs // on this cell - dealii::Vector dof_values( - fe_values->dofs_per_cell); + dealii::Vector dof_values(fe_values->dofs_per_cell); fe_values->present_cell.get_interpolated_dof_values(fe_function, dof_values); internal::do_function_divergences( @@ -3469,7 +3417,7 @@ FEValuesBase::get_function_gradients( auto view = make_array_view(dof_values.begin(), dof_values.end()); fe_function.extract_subvector_to(indices, view); internal::do_function_derivatives( - make_array_view(dof_values.begin(), dof_values.end()), + view, this->finite_element_output.shape_gradients, *fe, this->finite_element_output.shape_function_to_row_table, @@ -3481,14 +3429,12 @@ FEValuesBase::get_function_gradients( template -template +template void FEValuesBase::get_function_hessians( - const InputVector &fe_function, - std::vector> &hessians) - const + const ReadVector & fe_function, + std::vector> &hessians) const { - using Number = typename InputVector::value_type; AssertDimension(fe->n_components(), 1); Assert(this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); @@ -3507,25 +3453,22 @@ FEValuesBase::get_function_hessians( template -template +template void FEValuesBase::get_function_hessians( - const InputVector & fe_function, + const ReadVector & fe_function, const ArrayView &indices, - std::vector> &hessians) - const + std::vector> & hessians) const { - using Number = typename InputVector::value_type; Assert(this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); AssertDimension(fe_function.size(), present_cell.n_dofs_for_dof_handler()); AssertDimension(indices.size(), dofs_per_cell); boost::container::small_vector dof_values(dofs_per_cell); - for (unsigned int i = 0; i < dofs_per_cell; ++i) - dof_values[i] = internal::get_vector_element(fe_function, indices[i]); - internal::do_function_derivatives(make_array_view(dof_values.begin(), - dof_values.end()), + auto view = make_array_view(dof_values.begin(), dof_values.end()); + fe_function.extract_subvector_to(indices, view); + internal::do_function_derivatives(view, this->finite_element_output.shape_hessians, hessians); } @@ -3533,16 +3476,13 @@ FEValuesBase::get_function_hessians( template -template +template void FEValuesBase::get_function_hessians( - const InputVector &fe_function, - std::vector< - std::vector>> - & hessians, + const ReadVector & fe_function, + std::vector>> &hessians, const bool quadrature_points_fastest) const { - using Number = typename InputVector::value_type; Assert(this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); Assert(present_cell.is_initialized(), ExcNotReinited()); @@ -3563,26 +3503,24 @@ FEValuesBase::get_function_hessians( template -template +template void FEValuesBase::get_function_hessians( - const InputVector & fe_function, - const ArrayView &indices, - ArrayView>> - hessians, + const ReadVector & fe_function, + const ArrayView & indices, + ArrayView>> hessians, const bool quadrature_points_fastest) const { - using Number = typename InputVector::value_type; Assert(this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); Assert(indices.size() % dofs_per_cell == 0, ExcNotMultiple(indices.size(), dofs_per_cell)); boost::container::small_vector dof_values(indices.size()); - for (unsigned int i = 0; i < indices.size(); ++i) - dof_values[i] = internal::get_vector_element(fe_function, indices[i]); + auto view = make_array_view(dof_values.begin(), dof_values.end()); + fe_function.extract_subvector_to(indices, view); internal::do_function_derivatives( - make_array_view(dof_values.begin(), dof_values.end()), + view, this->finite_element_output.shape_hessians, *fe, this->finite_element_output.shape_function_to_row_table, @@ -3594,13 +3532,12 @@ FEValuesBase::get_function_hessians( template -template +template void FEValuesBase::get_function_laplacians( - const InputVector & fe_function, - std::vector &laplacians) const + const ReadVector &fe_function, + std::vector & laplacians) const { - using Number = typename InputVector::value_type; Assert(this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); AssertDimension(fe->n_components(), 1); @@ -3619,24 +3556,22 @@ FEValuesBase::get_function_laplacians( template -template +template void FEValuesBase::get_function_laplacians( - const InputVector & fe_function, + const ReadVector & fe_function, const ArrayView &indices, - std::vector & laplacians) const + std::vector & laplacians) const { - using Number = typename InputVector::value_type; Assert(this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); AssertDimension(fe->n_components(), 1); AssertDimension(indices.size(), dofs_per_cell); boost::container::small_vector dof_values(dofs_per_cell); - for (unsigned int i = 0; i < dofs_per_cell; ++i) - dof_values[i] = internal::get_vector_element(fe_function, indices[i]); - internal::do_function_laplacians(make_array_view(dof_values.begin(), - dof_values.end()), + auto view = make_array_view(dof_values.begin(), dof_values.end()); + fe_function.extract_subvector_to(indices, view); + internal::do_function_laplacians(view, this->finite_element_output.shape_hessians, laplacians); } @@ -3644,13 +3579,12 @@ FEValuesBase::get_function_laplacians( template -template +template void FEValuesBase::get_function_laplacians( - const InputVector & fe_function, - std::vector> &laplacians) const + const ReadVector & fe_function, + std::vector> &laplacians) const { - using Number = typename InputVector::value_type; Assert(present_cell.is_initialized(), ExcNotReinited()); Assert(this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); @@ -3670,14 +3604,13 @@ FEValuesBase::get_function_laplacians( template -template +template void FEValuesBase::get_function_laplacians( - const InputVector & fe_function, - const ArrayView & indices, - std::vector> &laplacians) const + const ReadVector & fe_function, + const ArrayView &indices, + std::vector> & laplacians) const { - using Number = typename InputVector::value_type; // Size of indices must be a multiple of dofs_per_cell such that an integer // number of function values is generated in each point. Assert(indices.size() % dofs_per_cell == 0, @@ -3686,10 +3619,10 @@ FEValuesBase::get_function_laplacians( ExcAccessToUninitializedField("update_hessians")); boost::container::small_vector dof_values(indices.size()); - for (unsigned int i = 0; i < indices.size(); ++i) - dof_values[i] = internal::get_vector_element(fe_function, indices[i]); + auto view = make_array_view(dof_values.begin(), dof_values.end()); + fe_function.extract_subvector_to(indices, view); internal::do_function_laplacians( - make_array_view(dof_values.begin(), dof_values.end()), + view, this->finite_element_output.shape_hessians, *fe, this->finite_element_output.shape_function_to_row_table, @@ -3701,25 +3634,24 @@ FEValuesBase::get_function_laplacians( template -template +template void FEValuesBase::get_function_laplacians( - const InputVector & fe_function, - const ArrayView & indices, - std::vector> &laplacians, + const ReadVector & fe_function, + const ArrayView &indices, + std::vector> & laplacians, const bool quadrature_points_fastest) const { - using Number = typename InputVector::value_type; Assert(indices.size() % dofs_per_cell == 0, ExcNotMultiple(indices.size(), dofs_per_cell)); Assert(this->update_flags & update_hessians, ExcAccessToUninitializedField("update_hessians")); boost::container::small_vector dof_values(indices.size()); - for (unsigned int i = 0; i < indices.size(); ++i) - dof_values[i] = internal::get_vector_element(fe_function, indices[i]); + auto view = make_array_view(dof_values.begin(), dof_values.end()); + fe_function.extract_subvector_to(indices, view); internal::do_function_laplacians( - make_array_view(dof_values.begin(), dof_values.end()), + view, this->finite_element_output.shape_hessians, *fe, this->finite_element_output.shape_function_to_row_table, @@ -3731,14 +3663,12 @@ FEValuesBase::get_function_laplacians( template -template +template void FEValuesBase::get_function_third_derivatives( - const InputVector &fe_function, - std::vector> - &third_derivatives) const + const ReadVector & fe_function, + std::vector> &third_derivatives) const { - using Number = typename InputVector::value_type; AssertDimension(fe->n_components(), 1); Assert(this->update_flags & update_3rd_derivatives, ExcAccessToUninitializedField("update_3rd_derivatives")); @@ -3757,42 +3687,35 @@ FEValuesBase::get_function_third_derivatives( template -template +template void FEValuesBase::get_function_third_derivatives( - const InputVector & fe_function, + const ReadVector & fe_function, const ArrayView &indices, - std::vector> - &third_derivatives) const + std::vector> & third_derivatives) const { - using Number = typename InputVector::value_type; Assert(this->update_flags & update_3rd_derivatives, ExcAccessToUninitializedField("update_3rd_derivatives")); AssertDimension(fe_function.size(), present_cell.n_dofs_for_dof_handler()); AssertDimension(indices.size(), dofs_per_cell); boost::container::small_vector dof_values(dofs_per_cell); - for (unsigned int i = 0; i < dofs_per_cell; ++i) - dof_values[i] = internal::get_vector_element(fe_function, indices[i]); + auto view = make_array_view(dof_values.begin(), dof_values.end()); + fe_function.extract_subvector_to(indices, view); internal::do_function_derivatives( - make_array_view(dof_values.begin(), dof_values.end()), - this->finite_element_output.shape_3rd_derivatives, - third_derivatives); + view, this->finite_element_output.shape_3rd_derivatives, third_derivatives); } template -template +template void FEValuesBase::get_function_third_derivatives( - const InputVector &fe_function, - std::vector< - std::vector>> - & third_derivatives, + const ReadVector & fe_function, + std::vector>> &third_derivatives, const bool quadrature_points_fastest) const { - using Number = typename InputVector::value_type; Assert(this->update_flags & update_3rd_derivatives, ExcAccessToUninitializedField("update_3rd_derivatives")); Assert(present_cell.is_initialized(), ExcNotReinited()); @@ -3813,26 +3736,24 @@ FEValuesBase::get_function_third_derivatives( template -template +template void FEValuesBase::get_function_third_derivatives( - const InputVector & fe_function, - const ArrayView &indices, - ArrayView>> - third_derivatives, + const ReadVector & fe_function, + const ArrayView & indices, + ArrayView>> third_derivatives, const bool quadrature_points_fastest) const { - using Number = typename InputVector::value_type; Assert(this->update_flags & update_3rd_derivatives, ExcAccessToUninitializedField("update_3rd_derivatives")); Assert(indices.size() % dofs_per_cell == 0, ExcNotMultiple(indices.size(), dofs_per_cell)); boost::container::small_vector dof_values(indices.size()); - for (unsigned int i = 0; i < indices.size(); ++i) - dof_values[i] = internal::get_vector_element(fe_function, indices[i]); + auto view = make_array_view(dof_values.begin(), dof_values.end()); + fe_function.extract_subvector_to(indices, view); internal::do_function_derivatives( - make_array_view(dof_values.begin(), dof_values.end()), + view, this->finite_element_output.shape_3rd_derivatives, *fe, this->finite_element_output.shape_function_to_row_table, diff --git a/source/fe/fe_values.inst.in b/source/fe/fe_values.inst.in index 6fb81be92f..d75f616bd7 100644 --- a/source/fe/fe_values.inst.in +++ b/source/fe/fe_values.inst.in @@ -198,93 +198,82 @@ for (S : REAL_AND_COMPLEX_SCALARS; deal_II_dimension : DIMENSIONS; -for (VEC : VECTOR_TYPES; deal_II_dimension : DIMENSIONS; +for (S : REAL_AND_COMPLEX_SCALARS; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) { # if deal_II_dimension <= deal_II_space_dimension template void FEValuesViews::Scalar:: - get_function_hessians( - const dealii::VEC &, + get_function_hessians( + const dealii::ReadVector &, std::vector< - ProductType>::type> &) + ProductType>::type> &) const; template void FEValuesViews::Scalar:: - get_function_laplacians( - const dealii::VEC &, - std::vector::type> &) + get_function_laplacians(const dealii::ReadVector &, + std::vector::type> &) const; template void FEValuesViews::Scalar:: - get_function_third_derivatives( - const dealii::VEC &, + get_function_third_derivatives( + const dealii::ReadVector &, std::vector< - ProductType>::type> &) + ProductType>::type> &) const; template void FEValuesViews::Vector:: - get_function_symmetric_gradients( - const dealii::VEC &, + get_function_symmetric_gradients( + const dealii::ReadVector &, std::vector>::type> &) const; + template void FEValuesViews:: + Vector::get_function_curls( + const dealii::ReadVector &, + std::vector::type> &) const; template void FEValuesViews::Vector:: - get_function_curls( - const dealii::VEC &, - std::vector::type> &) - const; - template void - FEValuesViews::Vector:: - get_function_divergences( - const dealii::VEC &, - std::vector::type> - &) const; + get_function_divergences( + const dealii::ReadVector &, + std::vector::type> &) const; template void FEValuesViews::Vector:: - get_function_hessians( - const dealii::VEC &, + get_function_hessians( + const dealii::ReadVector &, std::vector< - ProductType>::type> &) + ProductType>::type> &) const; template void FEValuesViews::Vector:: - get_function_laplacians( - const dealii::VEC &, + get_function_laplacians( + const dealii::ReadVector &, std::vector< - ProductType>::type> &) + ProductType>::type> &) const; template void FEValuesViews::Vector:: - get_function_third_derivatives( - const dealii::VEC &, + get_function_third_derivatives( + const dealii::ReadVector &, std::vector< - ProductType>::type> &) + ProductType>::type> &) const; template void FEValuesViews:: SymmetricTensor<2, deal_II_dimension, deal_II_space_dimension>:: - get_function_divergences( - const dealii::VEC &, + get_function_divergences( + const dealii::ReadVector &, std::vector< - ProductType>::type> &) + ProductType>::type> &) const; template void FEValuesViews::Tensor<2, deal_II_dimension, deal_II_space_dimension>:: - get_function_divergences( - const dealii::VEC &, + get_function_divergences( + const dealii::ReadVector &, std::vector< - ProductType>::type> &) + ProductType>::type> &) const; # endif } @@ -406,88 +395,80 @@ for (VEC : GENERAL_CONTAINER_TYPES; Number : ALL_SCALAR_TYPES; } -for (VEC : VECTOR_TYPES; deal_II_dimension : DIMENSIONS; +for (S : REAL_AND_COMPLEX_SCALARS; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) { # if deal_II_dimension <= deal_II_space_dimension template void FEValuesBase:: - get_function_hessians( - const VEC &, - std::vector> - &) const; + get_function_hessians( + const ReadVector &, + std::vector> &) const; template void FEValuesBase:: - get_function_hessians( - const VEC &, + get_function_hessians( + const ReadVector &, const ArrayView &, - std::vector> - &) const; + std::vector> &) const; template void FEValuesBase:: - get_function_hessians( - const VEC &, - std::vector>> &, + get_function_hessians( + const ReadVector &, + std::vector>> + &, bool) const; template void FEValuesBase:: - get_function_hessians( - const VEC &, + get_function_hessians( + const ReadVector &, const ArrayView &, - ArrayView>>, + ArrayView>>, bool) const; template void FEValuesBase:: - get_function_laplacians(const VEC &, std::vector &) - const; + get_function_laplacians(const ReadVector &, std::vector &) const; template void FEValuesBase:: - get_function_laplacians( - const VEC &, + get_function_laplacians( + const ReadVector &, const ArrayView &, - std::vector &) const; + std::vector &) const; template void FEValuesBase:: - get_function_laplacians(const VEC &, - std::vector> &) - const; + get_function_laplacians(const ReadVector &, + std::vector> &) const; template void FEValuesBase:: - get_function_laplacians( - const VEC &, + get_function_laplacians( + const ReadVector &, const ArrayView &, - std::vector> &) const; + std::vector> &) const; template void FEValuesBase:: - get_function_laplacians( - const VEC &, + get_function_laplacians( + const ReadVector &, const ArrayView &, - std::vector> &, + std::vector> &, bool) const; template void FEValuesBase:: - get_function_third_derivatives( - const VEC &, - std::vector> - &) const; + get_function_third_derivatives( + const ReadVector &, + std::vector> &) const; template void FEValuesBase:: - get_function_third_derivatives( - const VEC &, + get_function_third_derivatives( + const ReadVector &, const ArrayView &, - std::vector> - &) const; + std::vector> &) const; template void FEValuesBase:: - get_function_third_derivatives( - const VEC &, - std::vector>> &, + get_function_third_derivatives( + const ReadVector &, + std::vector>> + &, bool) const; template void FEValuesBase:: - get_function_third_derivatives( - const VEC &, + get_function_third_derivatives( + const ReadVector &, const ArrayView &, - ArrayView>>, + ArrayView>>, bool) const; # endif -- 2.39.5