]> https://gitweb.dealii.org/ - dealii.git/commitdiff
assert having Triangulation in DoFHandler 5281/head
authorTimo Heister <timo.heister@gmail.com>
Fri, 20 Oct 2017 18:57:22 +0000 (14:57 -0400)
committerTimo Heister <timo.heister@gmail.com>
Fri, 20 Oct 2017 20:11:35 +0000 (16:11 -0400)
If you forget to initialize a DoFHandler with a Triangulation,
distribute_dofs() gives an unhelpful Assert() somewhere deep in the
code. Fix this.

source/dofs/dof_handler.cc
source/hp/dof_handler.cc

index 5013af979d45faad29b0f83fc32cc6f21009e1a5..1c1756a3c98bdae7631309dd8407a218d95d0af1 100644 (file)
@@ -991,6 +991,12 @@ DoFHandler<dim,spacedim>::memory_consumption () const
 template <int dim, int spacedim>
 void DoFHandler<dim,spacedim>::distribute_dofs (const FiniteElement<dim,spacedim> &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<hp::FECollection<dim, spacedim>>(ff);
 
   // delete all levels and set them
index 067f8c87fe7896c0b749741cde963a2147e9d6a9..d6d9b57e15dfbd5b67dcfe529c2e477481eb4c57 100644 (file)
@@ -1281,7 +1281,11 @@ namespace hp
   template <int dim, int spacedim>
   void DoFHandler<dim,spacedim>::distribute_dofs (const hp::FECollection<dim,spacedim> &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;
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.