From 274fd80c057f64871e88af808c24448eb4722a52 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 2 Jul 2017 18:17:01 -0600 Subject: [PATCH] Simplify code a bit. --- source/dofs/dof_handler_policy.cc | 12 ++++++++++-- source/hp/dof_handler.cc | 5 +---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index e1c0490b1e..a298d25c1e 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -1398,8 +1398,16 @@ namespace internal Implementation::renumber_dofs (new_numbers, IndexSet(0), *dof_handler, true); - // return a sequential, complete index set - return NumberCache (new_numbers.size()); + // return a sequential, complete index set. take into account that the + // number of DoF indices may in fact be smaller than there were before + // if some previously separately numbered dofs have been identified. + // this is, for example, what the hp::DoFHandler does: it first + // enumerates all DoFs on cells independently, and then unifies + // some located at vertices or faces; this leaves us with fewer + // DoFs than there were before, so use the largest index as + // the one to determine the size of the index space + return NumberCache (*std::max_element(new_numbers.begin(), + new_numbers.end()) + 1); } diff --git a/source/hp/dof_handler.cc b/source/hp/dof_handler.cc index 4ec421b208..54893a9558 100644 --- a/source/hp/dof_handler.cc +++ b/source/hp/dof_handler.cc @@ -2691,10 +2691,7 @@ namespace hp // finally, do the renumbering and set the number of actually // used dof indices - policy->renumber_dofs (new_dof_indices); - - // now set the elements of the number cache appropriately - number_cache = dealii::internal::DoFHandler::NumberCache (next_free_dof); + number_cache = policy->renumber_dofs (new_dof_indices); Assert ((dynamic_cast*> (&this->get_triangulation()) -- 2.39.5