]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix erroneous assert 5412/head
authorAlexander Grayver <agrayver@erdw.ethz.ch>
Mon, 6 Nov 2017 16:00:46 +0000 (17:00 +0100)
committerAlexander Grayver <agrayver@erdw.ethz.ch>
Tue, 7 Nov 2017 16:31:53 +0000 (17:31 +0100)
source/dofs/dof_handler.cc
tests/mpi/subdomain_ids_parallel_08.cc [new file with mode: 0644]
tests/mpi/subdomain_ids_parallel_08.mpirun=2.output [new file with mode: 0644]

index eba12ba4572ac68173ac3cb295a60d8db7697c30..0b455016fa2a53d4473cabda55739e05ba041d54 100644 (file)
@@ -1104,9 +1104,21 @@ DoFHandler<dim,spacedim>::renumber_dofs (const std::vector<types::global_dof_ind
 {
   Assert(levels.size()>0, ExcMessage("You need to distribute DoFs before you can renumber them."));
 
-  AssertDimension (new_numbers.size(), n_locally_owned_dofs());
-
 #ifdef DEBUG
+  if (dynamic_cast<const parallel::shared::Triangulation< dim, spacedim>*> (&*tria) != nullptr)
+    {
+      Assert(new_numbers.size() == n_dofs() || new_numbers.size() == n_locally_owned_dofs(),
+             ExcMessage("Incorrect size of the input array."));
+    }
+  else if (dynamic_cast<const parallel::distributed::Triangulation< dim, spacedim >*> (&*tria) != nullptr)
+    {
+      AssertDimension (new_numbers.size(), n_locally_owned_dofs());
+    }
+  else
+    {
+      AssertDimension (new_numbers.size(), n_dofs());
+    }
+
   // assert that the new indices are
   // consecutively numbered if we are
   // working on a single
diff --git a/tests/mpi/subdomain_ids_parallel_08.cc b/tests/mpi/subdomain_ids_parallel_08.cc
new file mode 100644 (file)
index 0000000..ffcdec1
--- /dev/null
@@ -0,0 +1,52 @@
+// ---------------------------------------------------------------------\r
+//\r
+// Copyright (C) 2015 - 2017 by the deal.II Authors\r
+//\r
+// This file is part of the deal.II library.\r
+//\r
+// The deal.II library is free software; you can use it, redistribute\r
+// it, and/or modify it under the terms of the GNU Lesser General\r
+// Public License as published by the Free Software Foundation; either\r
+// version 2.1 of the License, or (at your option) any later version.\r
+// The full text of the license can be found in the file LICENSE at\r
+// the top level of the deal.II distribution.\r
+//\r
+// ---------------------------------------------------------------------\r
+\r
+// test DoFRenumbering::subdomain_wise with parallel::shared::Triangulation\r
+\r
+#include "../tests.h"\r
+\r
+// all include files you need here\r
+#include <deal.II/distributed/shared_tria.h>\r
+#include <deal.II/grid/grid_generator.h>\r
+#include <deal.II/fe/fe_q.h>\r
+#include <deal.II/dofs/dof_handler.h>\r
+#include <deal.II/dofs/dof_renumbering.h>\r
+\r
+template<int dim>\r
+void test()\r
+{\r
+  parallel::shared::Triangulation<dim> tria(MPI_COMM_WORLD);\r
+  GridGenerator::hyper_cube(tria);\r
+  tria.refine_global(3);\r
+\r
+  FE_Q<dim> fe(1);\r
+  DoFHandler<dim> dof_handler(tria);\r
+  dof_handler.distribute_dofs(fe);\r
+  DoFRenumbering::subdomain_wise(dof_handler);\r
+\r
+  if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0)\r
+    deallog << "OK for " << dim << "d" << std::endl;\r
+}\r
+\r
+int main (int argc, char *argv[])\r
+{\r
+  Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, 1);\r
+  MPILogInitAll log;\r
+\r
+  test<2>();\r
+  test<3>();\r
+\r
+  return 0;\r
+}\r
diff --git a/tests/mpi/subdomain_ids_parallel_08.mpirun=2.output b/tests/mpi/subdomain_ids_parallel_08.mpirun=2.output
new file mode 100644 (file)
index 0000000..5637e3f
--- /dev/null
@@ -0,0 +1,3 @@
+DEAL:0::OK for 2d
+DEAL:0::OK for 3d
+

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.