From: Timo Heister Date: Fri, 20 Oct 2017 18:57:22 +0000 (-0400) Subject: assert having Triangulation in DoFHandler X-Git-Tag: v9.0.0-rc1~917^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0df2a802c899fb35e6e61964cacb4748b5f90600;p=dealii.git assert having Triangulation in DoFHandler If you forget to initialize a DoFHandler with a Triangulation, distribute_dofs() gives an unhelpful Assert() somewhere deep in the code. Fix this. --- diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index 5013af979d..1c1756a3c9 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -991,6 +991,12 @@ DoFHandler::memory_consumption () const template void DoFHandler::distribute_dofs (const FiniteElement &ff) { + Assert(tria!=nullptr, + ExcMessage("You need to set the Triangulation in the DoFHandler using initialize() or " + "in the constructor before you can distribute DoFs.")); + Assert (tria->n_levels() > 0, + ExcMessage("The Triangulation you are using is empty!")); + fe_collection = std_cxx14::make_unique>(ff); // delete all levels and set them diff --git a/source/hp/dof_handler.cc b/source/hp/dof_handler.cc index 067f8c87fe..d6d9b57e15 100644 --- a/source/hp/dof_handler.cc +++ b/source/hp/dof_handler.cc @@ -1281,7 +1281,11 @@ namespace hp template void DoFHandler::distribute_dofs (const hp::FECollection &ff) { - Assert (tria->n_levels() > 0, ExcInvalidTriangulation()); + Assert(tria!=nullptr, + ExcMessage("You need to set the Triangulation in the DoFHandler using initialize() or " + "in the constructor before you can distribute DoFs.")); + Assert (tria->n_levels() > 0, + ExcMessage("The Triangulation you are using is empty!")); finite_elements = &ff;