From b8b15d0b9961ce6e773bd973e3412b32b5e9acc6 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 16 Jul 2017 10:39:05 -0600 Subject: [PATCH] Replace message-less exceptions with ones that say what's happening. --- include/deal.II/dofs/dof_accessor.templates.h | 8 ++++++-- include/deal.II/dofs/dof_handler.h | 4 +++- include/deal.II/dofs/dof_renumbering.h | 14 ++++++++++++++ include/deal.II/hp/dof_handler.h | 3 +++ source/dofs/dof_renumbering.cc | 12 ++++++------ 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/include/deal.II/dofs/dof_accessor.templates.h b/include/deal.II/dofs/dof_accessor.templates.h index b127266e5a..77de465c2b 100644 --- a/include/deal.II/dofs/dof_accessor.templates.h +++ b/include/deal.II/dofs/dof_accessor.templates.h @@ -2047,9 +2047,13 @@ DoFAccessor::get_dof_indices (std::vector &dof_indices, const unsigned int fe_index) const { - Assert (this->dof_handler != nullptr, ExcNotInitialized()); + Assert (this->dof_handler != nullptr, + ExcMessage("This accessor object has not been associated " + "with any DoFHandler object.")); Assert (static_cast(this->level()) < this->dof_handler->levels.size(), - ExcMessage ("DoFHandler not initialized")); + ExcMessage ("The DoFHandler to which this accessor points has not " + "been initialized, i.e., it doesn't appear that DoF indices " + "have been distributed on it.")); switch (structdim) { diff --git a/include/deal.II/dofs/dof_handler.h b/include/deal.II/dofs/dof_handler.h index 515b9f613f..8cce7cbdfb 100644 --- a/include/deal.II/dofs/dof_handler.h +++ b/include/deal.II/dofs/dof_handler.h @@ -1227,7 +1227,9 @@ inline const Triangulation & DoFHandler::get_triangulation () const { - Assert(tria != nullptr, ExcNotInitialized()); + Assert(tria != nullptr, + ExcMessage("This DoFHandler object has not been associated " + "with a triangulation.")); return *tria; } diff --git a/include/deal.II/dofs/dof_renumbering.h b/include/deal.II/dofs/dof_renumbering.h index 9c61467a33..43212cb374 100644 --- a/include/deal.II/dofs/dof_renumbering.h +++ b/include/deal.II/dofs/dof_renumbering.h @@ -1072,18 +1072,32 @@ namespace DoFRenumbering * @} */ + + + /** + * Exception + * + * @ingroup Exceptions + */ + DeclExceptionMsg (ExcDoFHandlerNotInitialized, + "The DoFHandler on which this function should work has not " + "been initialized, i.e., it doesn't appear that DoF indices " + "have been distributed on it."); + /** * Exception * * @ingroup Exceptions */ DeclException0 (ExcRenumberingIncomplete); + /** * Exception * * @ingroup Exceptions */ DeclException0 (ExcInvalidComponentOrder); + /** * The function is only implemented for Discontinuous Galerkin Finite * elements. diff --git a/include/deal.II/hp/dof_handler.h b/include/deal.II/hp/dof_handler.h index 81c0e3f40f..f315534172 100644 --- a/include/deal.II/hp/dof_handler.h +++ b/include/deal.II/hp/dof_handler.h @@ -1054,6 +1054,9 @@ namespace hp const Triangulation & DoFHandler::get_triangulation () const { + Assert(tria != nullptr, + ExcMessage("This DoFHandler object has not been associated " + "with a triangulation.")); return *tria; } diff --git a/source/dofs/dof_renumbering.cc b/source/dofs/dof_renumbering.cc index 652efdf5e4..81200c8fa5 100644 --- a/source/dofs/dof_renumbering.cc +++ b/source/dofs/dof_renumbering.cc @@ -474,7 +474,7 @@ namespace DoFRenumbering const std::vector &starting_indices) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, - ExcNotInitialized()); + ExcDoFHandlerNotInitialized()); // make the connection graph DynamicSparsityPattern dsp (dof_handler.n_dofs(level), @@ -541,7 +541,7 @@ namespace DoFRenumbering const std::vector &component_order_arg) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, - ExcNotInitialized()); + ExcDoFHandlerNotInitialized()); std::vector renumbering (dof_handler.n_dofs(level), numbers::invalid_dof_index); @@ -874,7 +874,7 @@ namespace DoFRenumbering block_wise (DoFHandler &dof_handler, const unsigned int level) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, - ExcNotInitialized()); + ExcDoFHandlerNotInitialized()); std::vector renumbering (dof_handler.n_dofs(level), numbers::invalid_dof_index); @@ -1238,7 +1238,7 @@ namespace DoFRenumbering const unsigned int level) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, - ExcNotInitialized()); + ExcDoFHandlerNotInitialized()); std::vector renumbering(dof_handler.n_dofs(level), numbers::invalid_dof_index); @@ -1295,7 +1295,7 @@ namespace DoFRenumbering const unsigned int level) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, - ExcNotInitialized()); + ExcDoFHandlerNotInitialized()); const unsigned int n_dofs = dof_handler.n_dofs(level); Assert (selected_dofs.size() == n_dofs, @@ -1419,7 +1419,7 @@ namespace DoFRenumbering const typename std::vector &cells) { Assert(dof.n_dofs(level) != numbers::invalid_dof_index, - ExcNotInitialized()); + ExcDoFHandlerNotInitialized()); std::vector renumbering(dof.n_dofs(level)); std::vector reverse(dof.n_dofs(level)); -- 2.39.5