]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix a DoFRenumbering issue with p::s::T.
authorDavid Wells <drwells@email.unc.edu>
Tue, 3 May 2022 20:12:24 +0000 (16:12 -0400)
committerDavid Wells <drwells@email.unc.edu>
Tue, 3 May 2022 20:12:24 +0000 (16:12 -0400)
This can happen if some processors don't have any degrees of freedom (e.g., we
run in parallel with only one cell in the triangulation). This crashed in a
spectacular way since this test would ultimately call MPI_Allgather with
different types at the same time.

The correct workaround here is to verify that all processors are doing the same
type of renumbering.

source/dofs/dof_handler_policy.cc
tests/sharedtria/dof_04.cc
tests/sharedtria/dof_04.with_metis=true.mpirun=3.output

index f86e09bb067a16beda55c508dc58cf0fa7623b87..58d71ca31221c881886f647749fed759d414e621 100644 (file)
@@ -3456,11 +3456,19 @@ namespace internal
 
         std::vector<types::global_dof_index> global_gathered_numbers(
           this->dof_handler->n_dofs(), 0);
-        // as we call DoFRenumbering::subdomain_wise (*dof_handler) from
+        // as we call DoFRenumbering::subdomain_wise(*dof_handler) from
         // distribute_dofs(), we need to support sequential-like input.
         // Distributed-like input from, for example, component_wise renumbering
         // is also supported.
-        if (new_numbers.size() == this->dof_handler->n_dofs())
+        const bool uses_sequential_numbering =
+          new_numbers.size() == this->dof_handler->n_dofs();
+        bool all_use_sequential_numbering = false;
+        Utilities::MPI::internal::all_reduce<bool>(
+          MPI_LAND,
+          ArrayView<const bool>(&uses_sequential_numbering, 1),
+          tr->get_communicator(),
+          ArrayView<bool>(&all_use_sequential_numbering, 1));
+        if (all_use_sequential_numbering)
           {
             global_gathered_numbers = new_numbers;
           }
index aa08376fa91194088c24efabcdf45b91b29cdba4..42c6427d6ac43acf4110aaa240c43d56f37988a8 100644 (file)
@@ -41,7 +41,7 @@
 
 template <int dim>
 void
-test()
+test(const unsigned int n_global_refinements)
 {
   parallel::shared::Triangulation<dim> triangulation(
     MPI_COMM_WORLD,
@@ -54,7 +54,7 @@ test()
   DoFHandler<dim> dof_handler(triangulation);
 
   GridGenerator::hyper_cube(triangulation);
-  triangulation.refine_global(2);
+  triangulation.refine_global(n_global_refinements);
 
   const unsigned int n_refinements[] = {0, 4, 3, 2};
   for (unsigned int i = 0; i < n_refinements[dim]; ++i)
@@ -158,11 +158,18 @@ main(int argc, char *argv[])
 
   MPILogInitAll all;
 
-  deallog.push("2d");
-  test<2>();
+  deallog.push("2d, no global refinements");
+  test<2>(0);
+  deallog.pop();
+
+  // To preserve output with an older version of this test reseed here:
+  Testing::srand(1);
+
+  deallog.push("2d, global refinements");
+  test<2>(2);
   deallog.pop();
 
   deallog.push("3d");
-  test<3>();
+  test<3>(2);
   deallog.pop();
 }
index ae56d843df0bbcef7b586f869f8b8478b3a6d6e7..4a96e0233bafc9954a0ccc6bb23a3714705b5493 100644 (file)
@@ -1,20 +1,29 @@
 
-DEAL:0:2d::n_dofs: 818
-DEAL:0:2d::n_dofs: 1754
-DEAL:0:2d::n_dofs: 3056
+DEAL:0:2d, no global refinements::n_dofs: 114
+DEAL:0:2d, no global refinements::n_dofs: 272
+DEAL:0:2d, no global refinements::n_dofs: 652
+DEAL:0:2d, global refinements::n_dofs: 818
+DEAL:0:2d, global refinements::n_dofs: 1754
+DEAL:0:2d, global refinements::n_dofs: 3056
 DEAL:0:3d::n_dofs: 13282
 DEAL:0:3d::n_dofs: 41826
 
-DEAL:1:2d::n_dofs: 818
-DEAL:1:2d::n_dofs: 1754
-DEAL:1:2d::n_dofs: 3056
+DEAL:1:2d, no global refinements::n_dofs: 114
+DEAL:1:2d, no global refinements::n_dofs: 272
+DEAL:1:2d, no global refinements::n_dofs: 652
+DEAL:1:2d, global refinements::n_dofs: 818
+DEAL:1:2d, global refinements::n_dofs: 1754
+DEAL:1:2d, global refinements::n_dofs: 3056
 DEAL:1:3d::n_dofs: 13282
 DEAL:1:3d::n_dofs: 41826
 
 
-DEAL:2:2d::n_dofs: 818
-DEAL:2:2d::n_dofs: 1754
-DEAL:2:2d::n_dofs: 3056
+DEAL:2:2d, no global refinements::n_dofs: 114
+DEAL:2:2d, no global refinements::n_dofs: 272
+DEAL:2:2d, no global refinements::n_dofs: 652
+DEAL:2:2d, global refinements::n_dofs: 818
+DEAL:2:2d, global refinements::n_dofs: 1754
+DEAL:2:2d, global refinements::n_dofs: 3056
 DEAL:2:3d::n_dofs: 13282
 DEAL:2:3d::n_dofs: 41826
 

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.