From: Timo Heister Date: Sun, 21 Nov 2021 22:04:49 +0000 (-0500) Subject: add Assert to get_mg_dof_indices X-Git-Tag: v9.4.0-rc1~815^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12978%2Fhead;p=dealii.git add Assert to get_mg_dof_indices 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). --- diff --git a/include/deal.II/dofs/dof_accessor.templates.h b/include/deal.II/dofs/dof_accessor.templates.h index 95223ebe54..96493e2dbc 100644 --- a/include/deal.II/dofs/dof_accessor.templates.h +++ b/include/deal.II/dofs/dof_accessor.templates.h @@ -1569,6 +1569,9 @@ DoFAccessor::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::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 &&