From: Martin Kronbichler Date: Wed, 1 Dec 2021 13:40:17 +0000 (+0100) Subject: Simplify extraction of shape info data structure X-Git-Tag: v9.4.0-rc1~765^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a4119d0e82d749458be2601abfbef80c8602450;p=dealii.git Simplify extraction of shape info data structure --- diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index d74ef03107..897dc0ab49 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -3091,46 +3091,51 @@ namespace internal namespace internal { - template - inline unsigned int - get_active_fe_index(const MatrixFreeType &data, - const unsigned int dof_no, - const unsigned int fe_degree, - const unsigned int first_selected_component, - const unsigned int active_fe_index) - { - return fe_degree != numbers::invalid_unsigned_int ? - data.get_dof_info(dof_no).fe_index_from_degree( - first_selected_component, fe_degree) : - (active_fe_index != numbers::invalid_unsigned_int ? - active_fe_index : - 0); - } - - - template - inline unsigned int - get_active_quad_index(const MatrixFree &mf, - const unsigned int quad_no, - const unsigned int fe_degree, - const unsigned int n_q_points, - const unsigned int active_fe_index, - const unsigned int active_quad_index) + inline std::tuple< + const internal::MatrixFreeFunctions::ShapeInfo &, + const internal::MatrixFreeFunctions::DoFInfo &, + unsigned int, + unsigned int> + get_shape_info_and_indices( + const MatrixFree &data, + const unsigned int dof_no, + const unsigned int first_selected_component, + const unsigned int quad_no, + const unsigned int fe_degree, + const unsigned int n_q_points, + const unsigned int active_fe_index_given, + const unsigned int active_quad_index_given) { + const auto &dof_info = data.get_dof_info(dof_no); const auto &mapping_storage = internal::MatrixFreeFunctions:: MappingInfoCellsOrFaces::get( - mf.get_mapping_info(), quad_no); - if (fe_degree == numbers::invalid_unsigned_int) - return active_quad_index != numbers::invalid_unsigned_int ? - active_quad_index : - std::min(active_fe_index, - mapping_storage.descriptor.size() - 1); - else - return mapping_storage.quad_index_from_n_q_points(n_q_points); + data.get_mapping_info(), quad_no); + const unsigned int active_fe_index = + fe_degree != numbers::invalid_unsigned_int ? + dof_info.fe_index_from_degree(first_selected_component, fe_degree) : + (active_fe_index_given != numbers::invalid_unsigned_int ? + active_fe_index_given : + 0); + const unsigned int active_quad_index = + fe_degree == numbers::invalid_unsigned_int ? + (active_quad_index_given != numbers::invalid_unsigned_int ? + active_quad_index_given : + std::min(active_fe_index, + mapping_storage.descriptor.size() - 1)) : + mapping_storage.quad_index_from_n_q_points(n_q_points); + return {data.get_shape_info( + dof_no, + quad_no, + dof_info.component_to_base_index[first_selected_component], + active_fe_index, + active_quad_index), + dof_info, + active_fe_index, + active_quad_index}; } } // namespace internal @@ -3158,54 +3163,24 @@ inline FEEvaluationBase( - data_in.get_shape_info( - dof_no, - quad_no, - data_in.get_dof_info(dof_no) - .component_to_base_index[first_selected_component], - internal::get_active_fe_index(data_in, - dof_no, - fe_degree, - first_selected_component, - active_fe_index), - internal::get_active_quad_index( - data_in, - quad_no, - fe_degree, - n_q_points, - internal::get_active_fe_index(data_in, - dof_no, - fe_degree, - first_selected_component, - active_fe_index), - active_quad_index)), - data_in.get_dof_info(dof_no), + internal::get_shape_info_and_indices(data_in, + dof_no, + first_selected_component, + quad_no, + fe_degree, + n_q_points, + active_fe_index, + active_quad_index), internal::MatrixFreeFunctions:: MappingInfoCellsOrFaces::get( data_in.get_mapping_info(), quad_no), quad_no, is_interior_face, - internal::get_active_fe_index(data_in, - dof_no, - fe_degree, - first_selected_component, - active_fe_index), - internal::get_active_quad_index( - data_in, - quad_no, - fe_degree, - n_q_points, - internal::get_active_fe_index(data_in, - dof_no, - fe_degree, - first_selected_component, - active_fe_index), - active_quad_index), face_type) , scratch_data_array(data_in.acquire_scratch_data()) , matrix_info(&data_in) - , n_fe_components(data_in.get_dof_info(dof_no).start_components.back()) + , n_fe_components(this->dof_info->start_components.back()) , dof_values_initialized(false) , values_quad_initialized(false) , gradients_quad_initialized(false) diff --git a/include/deal.II/matrix_free/fe_evaluation_base_data.h b/include/deal.II/matrix_free/fe_evaluation_base_data.h index dcce525ab9..e95a0a9c87 100644 --- a/include/deal.II/matrix_free/fe_evaluation_base_data.h +++ b/include/deal.II/matrix_free/fe_evaluation_base_data.h @@ -148,7 +148,7 @@ public: /** * Return a reference to the ShapeInfo object currently in use. */ - const internal::MatrixFreeFunctions::ShapeInfo & + const ShapeInfoType & get_shape_info() const; /** @@ -243,14 +243,14 @@ protected: * more than one quadrature formula selected during construction of * `matrix_free`, `quad_no` allows to select the appropriate formula. */ - FEEvaluationBaseData(const ShapeInfoType & shape_info, - const DoFInfo & dof_info, - const MappingInfoStorageType &mapping_data, - const unsigned int quad_no, - const bool is_interior_face, - const unsigned int active_fe_index, - const unsigned int active_quad_index, - const unsigned int face_type); + FEEvaluationBaseData(const std::tuple &info, + const MappingInfoStorageType & mapping_data, + const unsigned int quad_no, + const bool is_interior_face, + const unsigned int face_type); /** * Constructor that comes with reduced functionality and works similar as @@ -440,20 +440,20 @@ protected: template inline FEEvaluationBaseData:: - FEEvaluationBaseData(const ShapeInfoType & shape_info, - const DoFInfo & dof_info, - const MappingInfoStorageType &mapping_data, - const unsigned int quad_no, - const bool is_interior_face, - const unsigned int active_fe_index, - const unsigned int active_quad_index, - const unsigned int face_type) - : data(&shape_info) - , dof_info(&dof_info) + FEEvaluationBaseData(const std::tuple &shape_dof_info, + const MappingInfoStorageType & mapping_data, + const unsigned int quad_no, + const bool is_interior_face, + const unsigned int face_type) + : data(&std::get<0>(shape_dof_info)) + , dof_info(&std::get<1>(shape_dof_info)) , mapping_data(&mapping_data) , quad_no(quad_no) - , active_fe_index(active_fe_index) - , active_quad_index(active_quad_index) + , active_fe_index(std::get<2>(shape_dof_info)) + , active_quad_index(std::get<3>(shape_dof_info)) , descriptor( &mapping_data.descriptor [is_face ?