From 091a7e4da8bf8b2a6ee2e34c538d2091f8fe4c16 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Wed, 11 Aug 2021 16:22:21 -0400 Subject: [PATCH] add Assert to MGTransfer* The error message when you forget to call distribute_mg_dofs() is not helpful. Instead, add an Assert. --- source/multigrid/mg_transfer_matrix_free.cc | 6 ++++++ source/multigrid/mg_transfer_prebuilt.cc | 6 ++++++ 2 files changed, 12 insertions(+) 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(); -- 2.39.5