]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add Assert to get_mg_dof_indices 12978/head
authorTimo Heister <timo.heister@gmail.com>
Sun, 21 Nov 2021 22:04:49 +0000 (17:04 -0500)
committerTimo Heister <timo.heister@gmail.com>
Sun, 21 Nov 2021 22:08:14 +0000 (17:08 -0500)
Calling get_mg_dof_indices currently causes a segfault when you don't
have MG DoFs distributed. Fix by adding an Assert with a nice message in
two places (why not).

include/deal.II/dofs/dof_accessor.templates.h

index 95223ebe548f3ac8a6bf44a3fec59021003bc11f..96493e2dbc7eb8763131b5759130cb01b9764aac 100644 (file)
@@ -1569,6 +1569,9 @@ DoFAccessor<structdim, dim, spacedim, level_dof_access>::mg_vertex_dof_index(
       fe_index_;
   (void)fe_index;
   Assert(this->dof_handler != nullptr, ExcInvalidObject());
+  Assert(this->dof_handler->mg_vertex_dofs.size() > 0,
+         ExcMessage("Multigrid DoF indices can only be accessed after "
+                    "DoFHandler::distribute_mg_dofs() has been called!"));
   AssertIndexRange(vertex, this->n_vertices());
   AssertIndexRange(i, this->dof_handler->get_fe(fe_index).n_dofs_per_vertex());
 
@@ -1706,6 +1709,9 @@ DoFAccessor<structdim, dim, spacedim, level_dof_access>::get_mg_dof_indices(
   const unsigned int                    fe_index_) const
 {
   Assert(this->dof_handler != nullptr, ExcInvalidObject());
+  Assert(this->dof_handler->mg_vertex_dofs.size() > 0,
+         ExcMessage("Multigrid DoF indices can only be accessed after "
+                    "DoFHandler::distribute_mg_dofs() has been called!"));
 
   const unsigned int fe_index =
     (this->dof_handler->hp_capability_enabled == false &&

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.