From: Timo Heister Date: Thu, 9 Oct 2014 14:17:38 +0000 (-0400) Subject: Check in DoFHandler::renumber_dofs() that DoFs are distributed X-Git-Tag: v8.2.0-rc1~109^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F191%2Fhead;p=dealii.git Check in DoFHandler::renumber_dofs() that DoFs are distributed - This adds several Asserts to check that DoFs are distributed before calling renumber_dofs() for active or level DoFs. - Note that we now also require that you call distribute_dofs() before distribute_mg_dofs(). - Updated documentation. --- diff --git a/include/deal.II/dofs/dof_handler.h b/include/deal.II/dofs/dof_handler.h index 494257c39a..c38a675aa7 100644 --- a/include/deal.II/dofs/dof_handler.h +++ b/include/deal.II/dofs/dof_handler.h @@ -372,8 +372,11 @@ public: virtual void distribute_dofs (const FiniteElement &fe); /** - * Distribute multigrid degrees of freedom similar - * to distribute_dofs() but on each level. + * Distribute level degrees of freedom on each level for geometric + * multigrid. The active DoFs need to be distributed using distribute_dofs() + * before calling this function and the @p fe needs to be identical to the + * finite element passed to distribute_dofs(). + * * This replaces the functionality of the old MGDoFHandler. */ virtual void distribute_mg_dofs (const FiniteElement &fe); diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index 94d240015d..9f2c038022 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -1239,9 +1239,10 @@ void DoFHandler::distribute_dofs (const FiniteElement void DoFHandler::distribute_mg_dofs (const FiniteElement &fe) { + Assert(levels.size()>0, ExcMessage("Distribute active DoFs using distribute_dofs() before calling distribute_mg_dofs().")); + const FiniteElement *old_fe = selected_fe; - Assert((old_fe==NULL) || (old_fe == &fe), ExcMessage("you are required to use the same FE for level and active DoFs!") ); - selected_fe = &fe; + Assert(old_fe == &fe, ExcMessage("You are required to use the same FE for level and active DoFs!") ); clear_mg_space(); @@ -1311,6 +1312,8 @@ template void DoFHandler::renumber_dofs (const std::vector &new_numbers) { + Assert(levels.size()>0, ExcMessage("You need to distribute DoFs before you can renumber them.")); + Assert (new_numbers.size() == n_locally_owned_dofs(), ExcRenumberingIncomplete()); @@ -1356,6 +1359,8 @@ template<> void DoFHandler<1>::renumber_dofs (const unsigned int level, const std::vector &new_numbers) { + Assert(mg_levels.size()>0 && levels.size()>0, + ExcMessage("You need to distribute active and level DoFs before you can renumber level DoFs.")); Assert (new_numbers.size() == n_dofs(level), DoFHandler<1>::ExcRenumberingIncomplete()); // note that we can not use cell iterators @@ -1390,6 +1395,8 @@ template<> void DoFHandler<2>::renumber_dofs (const unsigned int level, const std::vector &new_numbers) { + Assert(mg_levels.size()>0 && levels.size()>0, + ExcMessage("You need to distribute active and level DoFs before you can renumber level DoFs.")); Assert (new_numbers.size() == n_dofs(level), DoFHandler<2>::ExcRenumberingIncomplete()); @@ -1447,6 +1454,8 @@ template<> void DoFHandler<3>::renumber_dofs (const unsigned int level, const std::vector &new_numbers) { + Assert(mg_levels.size()>0 && levels.size()>0, + ExcMessage("You need to distribute active and level DoFs before you can renumber level DoFs.")); Assert (new_numbers.size() == n_dofs(level), DoFHandler<3>::ExcRenumberingIncomplete());