From: bangerth Date: Tue, 10 Sep 2013 20:13:37 +0000 (+0000) Subject: Merge a bunch of functions now that hp::DoFHandler and DoFHandler behave similarly. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=738d09dbbb5e82fc42d64d882edb39615bc2c0f3;p=dealii-svn.git Merge a bunch of functions now that hp::DoFHandler and DoFHandler behave similarly. git-svn-id: https://svn.dealii.org/trunk@30670 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/dofs/dof_accessor.templates.h b/deal.II/include/deal.II/dofs/dof_accessor.templates.h index af53612a03..ad15a3d3ae 100644 --- a/deal.II/include/deal.II/dofs/dof_accessor.templates.h +++ b/deal.II/include/deal.II/dofs/dof_accessor.templates.h @@ -2756,17 +2756,13 @@ namespace internal /** * A function that collects the * global indices of degrees of - * freedom. This function works - * for ::DoFHandler and all - * template arguments and copies - * the data out of the cache that - * we hold for each cell. + * freedom. */ - template + template static void - get_dof_indices (const DoFCellAccessor, lda> &accessor, - std::vector &dof_indices) + get_dof_indices (const Accessor &accessor, + std::vector &dof_indices) { AssertDimension (dof_indices.size(), accessor.get_fe().dofs_per_cell); @@ -2780,30 +2776,6 @@ namespace internal dof_indices[i] = *cache; } - /** - * Same function as above except - * that it works for - * hp::DoFHandler objects that do - * not have a cache for the local - * DoF indices. - */ - template - static - void - get_dof_indices (const DoFCellAccessor, lda> &accessor, - std::vector &dof_indices) - { - AssertDimension (dof_indices.size(), accessor.get_fe().dofs_per_cell); - - Assert (!accessor.has_children(), - ExcMessage ("Cell must be active.")); - - const types::global_dof_index *cache - = accessor.dof_handler->levels[accessor.level()] - ->get_cell_cache_start (accessor.present_index, accessor.get_fe().dofs_per_cell); - for (unsigned int i=0; i + template static void - get_dof_values (const DoFCellAccessor, lda> &accessor, + get_dof_values (const Accessor &accessor, const InputVector &values, ForwardIterator local_values_begin, ForwardIterator local_values_end) { - typedef dealii::DoFAccessor, lda> BaseClass; Assert (static_cast(local_values_end-local_values_begin) == accessor.get_fe().dofs_per_cell, - typename BaseClass::ExcVectorDoesNotMatch()); + typename Accessor::ExcVectorDoesNotMatch()); Assert (values.size() == accessor.get_dof_handler().n_dofs(), - typename BaseClass::ExcVectorDoesNotMatch()); + typename Accessor::ExcVectorDoesNotMatch()); Assert (!accessor.has_children(), ExcMessage ("Cell must be active.")); - types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()] - ->cell_dof_indices_cache[accessor.present_index * - accessor.get_fe().dofs_per_cell]; + const types::global_dof_index *cache + = accessor.dof_handler->levels[accessor.level()] + ->get_cell_cache_start (accessor.present_index, accessor.get_fe().dofs_per_cell); values.extract_subvector_to (cache, cache + accessor.get_fe().dofs_per_cell, local_values_begin); } - /** - * Same function as above except - * that it works for - * hp::DoFHandler objects that do - * not have a cache for the local - * DoF indices. - */ - template - static - void - get_dof_values (const DoFCellAccessor, lda> &accessor, - const InputVector &values, - ForwardIterator local_values_begin, - ForwardIterator local_values_end) - { - typedef dealii::DoFAccessor, lda> BaseClass; - - // no caching for hp::DoFHandler - // implemented - Assert (static_cast(local_values_end-local_values_begin) - == accessor.get_fe().dofs_per_cell, - typename BaseClass::ExcVectorDoesNotMatch()); - const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell; - - std::vector local_dof_indices (dofs_per_cell); - get_dof_indices (accessor, local_dof_indices); - - values.extract_subvector_to (local_dof_indices.begin(), - local_dof_indices.end(), - local_values_begin); - } - /** * A function that collects the @@ -2883,62 +2822,32 @@ namespace internal * indices that we hold for each * cell. */ - template + template static void - get_dof_values (const DoFCellAccessor, lda> &accessor, + get_dof_values (const Accessor &accessor, const ConstraintMatrix &constraints, const InputVector &values, ForwardIterator local_values_begin, ForwardIterator local_values_end) { - typedef dealii::DoFAccessor, lda> BaseClass; Assert (static_cast(local_values_end-local_values_begin) == accessor.get_fe().dofs_per_cell, - typename BaseClass::ExcVectorDoesNotMatch()); + typename Accessor::ExcVectorDoesNotMatch()); Assert (values.size() == accessor.get_dof_handler().n_dofs(), - typename BaseClass::ExcVectorDoesNotMatch()); + typename Accessor::ExcVectorDoesNotMatch()); Assert (!accessor.has_children(), ExcMessage ("Cell must be active.")); - types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()] - ->cell_dof_indices_cache[accessor.present_index * - accessor.get_fe().dofs_per_cell]; + const types::global_dof_index *cache + = accessor.dof_handler->levels[accessor.level()] + ->get_cell_cache_start (accessor.present_index, accessor.get_fe().dofs_per_cell); + constraints.get_dof_values(values, *cache, local_values_begin, local_values_end); } - /** - * Same function as above except - * that it works for - * hp::DoFHandler objects that do - * not have a cache for the local - * DoF indices. - */ - template - static - void - get_dof_values (const DoFCellAccessor, lda> &accessor, - const ConstraintMatrix &constraints, - const InputVector &values, - ForwardIterator local_values_begin, - ForwardIterator local_values_end) - { - // no caching for hp::DoFHandler - // implemented - typedef dealii::DoFAccessor, lda> BaseClass; - Assert (static_cast(local_values_end-local_values_begin) - == accessor.get_fe().dofs_per_cell, - typename BaseClass::ExcVectorDoesNotMatch()); - const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell; - - std::vector local_dof_indices (dofs_per_cell); - get_dof_indices (accessor, local_dof_indices); - - constraints.get_dof_values (values, local_dof_indices.begin(), - local_values_begin, local_values_end); - } /** @@ -2946,49 +2855,30 @@ namespace internal * except that it sets rather than * gets values */ - template + template static void - set_dof_values (const DoFCellAccessor, lda> &accessor, + set_dof_values (const Accessor &accessor, const dealii::Vector &local_values, OutputVector &values) { - typedef dealii::DoFAccessor, lda> BaseClass; Assert (local_values.size() == accessor.get_fe().dofs_per_cell, - typename BaseClass::ExcVectorDoesNotMatch()); + typename Accessor::ExcVectorDoesNotMatch()); Assert (values.size() == accessor.get_dof_handler().n_dofs(), - typename BaseClass::ExcVectorDoesNotMatch()); + typename Accessor::ExcVectorDoesNotMatch()); Assert (!accessor.has_children(), ExcMessage ("Cell must be active.")); - types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()] - ->cell_dof_indices_cache[accessor.present_index * accessor.get_fe().dofs_per_cell]; + const types::global_dof_index *cache + = accessor.dof_handler->levels[accessor.level()] + ->get_cell_cache_start (accessor.present_index, accessor.get_fe().dofs_per_cell); for (unsigned int i=0; i - static - void - set_dof_values (const DoFCellAccessor, lda> &accessor, - const dealii::Vector &local_values, - OutputVector &values) - { - // no caching for hp::DoFHandler - // implemented - const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell; - - std::vector local_dof_indices (dofs_per_cell); - get_dof_indices (accessor, local_dof_indices); - - for (unsigned int i=0; i