]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add Assert to MGTransfer* 12645/head
authorTimo Heister <timo.heister@gmail.com>
Wed, 11 Aug 2021 20:22:21 +0000 (16:22 -0400)
committerTimo Heister <timo.heister@gmail.com>
Thu, 12 Aug 2021 16:37:21 +0000 (12:37 -0400)
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
source/multigrid/mg_transfer_prebuilt.cc

index b7baed27e0a30ebed88029611b3a53c777c27f83..e15f327f0ee3af7f99e3ae2aae564b78b8051537 100644 (file)
@@ -99,6 +99,12 @@ MGTransferMatrixFree<dim, Number>::build(
   const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
     &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,
index 13ff599c019399e72d0ba2a3f689b1c743765ace..30a6695d9fbbc170ad26c311ce82fd40d18f8b34 100644 (file)
@@ -152,6 +152,12 @@ void
 MGTransferPrebuilt<VectorType>::build(
   const DoFHandler<dim, spacedim> &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();

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.