From: Martin Kronbichler Date: Thu, 18 Aug 2022 09:52:36 +0000 (+0200) Subject: Typedef to define the temporary array in single place only X-Git-Tag: v9.5.0-rc1~939^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F14068%2Fhead;p=dealii.git Typedef to define the temporary array in single place only --- diff --git a/include/deal.II/dofs/dof_accessor.templates.h b/include/deal.II/dofs/dof_accessor.templates.h index 9ce2006fb2..b5b14b4de2 100644 --- a/include/deal.II/dofs/dof_accessor.templates.h +++ b/include/deal.II/dofs/dof_accessor.templates.h @@ -250,6 +250,17 @@ namespace internal */ struct Implementation { + /** + * In several applications of DoFAccessor::get_dof_values(), we want to + * extract some indices without having to allocate memory. We do this by + * setting a boost small_vector with 27 elements on the stack, and only + * allocate when we exceed 27. The number 27 is heuristic and allows up + * to quadratic shape functions on scalar problems in 3D, or linear + * shape functions on systems (elasticity). + */ + using dof_index_vector_type = + boost::container::small_vector; + /** * Process the @p local_index-th degree of freedom corresponding to the * finite element specified by @p fe_index on the vertex with global @@ -1449,8 +1460,8 @@ namespace internal void get_cell_dof_indices( const dealii::DoFCellAccessor &accessor, - boost::container::small_vector &dof_indices, - const unsigned int fe_index); + Implementation::dof_index_vector_type &dof_indices, + const unsigned int fe_index); } // namespace DoFAccessorImplementation } // namespace internal @@ -2551,8 +2562,8 @@ DoFCellAccessor::get_dof_values( Assert(values.size() == this->get_dof_handler().n_dofs(), typename DoFCellAccessor::ExcVectorDoesNotMatch()); - boost::container::small_vector dof_indices( - this->get_fe().n_dofs_per_cell()); + internal::DoFAccessorImplementation::Implementation::dof_index_vector_type + dof_indices(this->get_fe().n_dofs_per_cell()); internal::DoFAccessorImplementation::get_cell_dof_indices( *this, dof_indices, this->active_fe_index()); dealii::internal::DoFAccessorImplementation::Implementation:: @@ -2584,8 +2595,8 @@ DoFCellAccessor::get_dof_values( typename DoFCellAccessor::ExcVectorDoesNotMatch()); - boost::container::small_vector dof_indices( - this->get_fe().n_dofs_per_cell()); + internal::DoFAccessorImplementation::Implementation::dof_index_vector_type + dof_indices(this->get_fe().n_dofs_per_cell()); internal::DoFAccessorImplementation::get_cell_dof_indices( *this, dof_indices, this->active_fe_index()); @@ -2616,8 +2627,8 @@ DoFCellAccessor::set_dof_values( Assert(this->dof_handler != nullptr, typename BaseClass::ExcInvalidObject()); - boost::container::small_vector dof_indices( - this->get_fe().n_dofs_per_cell()); + internal::DoFAccessorImplementation::Implementation::dof_index_vector_type + dof_indices(this->get_fe().n_dofs_per_cell()); internal::DoFAccessorImplementation::get_cell_dof_indices( *this, dof_indices, this->active_fe_index()); @@ -2845,8 +2856,8 @@ DoFCellAccessor:: const unsigned int n_dofs = local_source_end - local_source_begin; - boost::container::small_vector dof_indices( - n_dofs); + internal::DoFAccessorImplementation::Implementation::dof_index_vector_type + dof_indices(n_dofs); internal::DoFAccessorImplementation::get_cell_dof_indices( *this, dof_indices, this->active_fe_index()); @@ -2876,8 +2887,8 @@ DoFCellAccessor:: Assert(!this->has_children(), ExcMessage("Cell must be active.")); - boost::container::small_vector dof_indices( - this->get_fe().n_dofs_per_cell()); + internal::DoFAccessorImplementation::Implementation::dof_index_vector_type + dof_indices(this->get_fe().n_dofs_per_cell()); internal::DoFAccessorImplementation::get_cell_dof_indices( *this, dof_indices, this->active_fe_index()); @@ -2912,8 +2923,8 @@ DoFCellAccessor:: const unsigned int n_dofs = local_source.m(); - boost::container::small_vector dof_indices( - n_dofs); + internal::DoFAccessorImplementation::Implementation::dof_index_vector_type + dof_indices(n_dofs); internal::DoFAccessorImplementation::get_cell_dof_indices( *this, dof_indices, this->active_fe_index()); @@ -2954,8 +2965,8 @@ DoFCellAccessor:: Assert(!this->has_children(), ExcMessage("Cell must be active.")); const unsigned int n_dofs = this->get_fe().n_dofs_per_cell(); - boost::container::small_vector dof_indices( - n_dofs); + internal::DoFAccessorImplementation::Implementation::dof_index_vector_type + dof_indices(n_dofs); internal::DoFAccessorImplementation::get_cell_dof_indices( *this, dof_indices, this->active_fe_index());