From: Timo Heister Date: Wed, 11 Aug 2021 20:22:21 +0000 (-0400) Subject: add Assert to MGTransfer* X-Git-Tag: v9.4.0-rc1~1086^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=091a7e4da8bf8b2a6ee2e34c538d2091f8fe4c16;p=dealii.git add Assert to MGTransfer* The error message when you forget to call distribute_mg_dofs() is not helpful. Instead, add an Assert. --- diff --git a/source/multigrid/mg_transfer_matrix_free.cc b/source/multigrid/mg_transfer_matrix_free.cc index b7baed27e0..e15f327f0e 100644 --- a/source/multigrid/mg_transfer_matrix_free.cc +++ b/source/multigrid/mg_transfer_matrix_free.cc @@ -99,6 +99,12 @@ MGTransferMatrixFree::build( const std::vector> &external_partitioners) { + Assert(dof_handler.has_level_dofs(), + ExcMessage( + "The underlying DoFHandler object did not call " + "distribute_mg_dofs(). This is a prerequisite for multigrid " + "transfers.")); + this->fill_and_communicate_copy_indices(dof_handler); vector_partitioners.resize(0, diff --git a/source/multigrid/mg_transfer_prebuilt.cc b/source/multigrid/mg_transfer_prebuilt.cc index 13ff599c01..30a6695d9f 100644 --- a/source/multigrid/mg_transfer_prebuilt.cc +++ b/source/multigrid/mg_transfer_prebuilt.cc @@ -152,6 +152,12 @@ void MGTransferPrebuilt::build( const DoFHandler &dof_handler) { + Assert(dof_handler.has_level_dofs(), + ExcMessage( + "The underlying DoFHandler object did not call " + "distribute_mg_dofs(). This is a prerequisite for multigrid " + "transfers.")); + const unsigned int n_levels = dof_handler.get_triangulation().n_global_levels(); const unsigned int dofs_per_cell = dof_handler.get_fe().n_dofs_per_cell();