]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add the correct test. 12152/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 6 May 2021 13:51:39 +0000 (07:51 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 6 May 2021 13:51:39 +0000 (07:51 -0600)
tests/base/aligned_vector_replicate_05.cc [deleted file]
tests/base/aligned_vector_replicate_05.mpirun=3.output [deleted file]
tests/base/table_replicate_01.cc [new file with mode: 0644]
tests/base/table_replicate_01.mpirun=3.output [new file with mode: 0644]

diff --git a/tests/base/aligned_vector_replicate_05.cc b/tests/base/aligned_vector_replicate_05.cc
deleted file mode 100644 (file)
index 375b215..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-// ---------------------------------------------------------------------
-//
-// Copyright (C) 2012 - 2018 by the deal.II authors
-//
-// This file is part of the deal.II library.
-//
-// The deal.II library is free software; you can use it, redistribute
-// it, and/or modify it under the terms of the GNU Lesser General
-// Public License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// The full text of the license can be found in the file LICENSE.md at
-// the top level directory of deal.II.
-//
-// ---------------------------------------------------------------------
-
-
-// Test AlignedVector::replicate_across_communicator().
-//
-// Check that all objects are correctly created/destroyed again.
-
-#include <deal.II/base/aligned_vector.h>
-#include <deal.II/base/logstream.h>
-
-#include "../tests.h"
-
-
-int object_number     = 0;
-int objects_destroyed = 0;
-
-class C
-{
-public:
-  C()
-  {
-    object_number = ::object_number++;
-    deallog << "Default constructor. Object number " << object_number
-            << std::endl;
-  }
-
-  C(const C &c)
-  {
-    object_number = ::object_number++;
-    deallog << "copy constructor from " << c.object_number << ". Object number "
-            << object_number << std::endl;
-  }
-
-  C(const C &&c)
-  {
-    object_number = ::object_number++;
-    deallog << "move constructor from " << c.object_number << ". Object number "
-            << object_number << std::endl;
-  }
-
-  ~C()
-  {
-    deallog << "destructor. Object number " << object_number << std::endl;
-    ++objects_destroyed;
-  }
-
-  template <typename Archive>
-  void
-  serialize(Archive &ar, const unsigned int)
-  {
-    ar &object_number;
-  }
-
-
-private:
-  unsigned int object_number;
-};
-
-
-
-void
-test()
-{
-  const MPI_Comm     communicator = MPI_COMM_WORLD;
-  const unsigned int root         = 1;
-  Assert(root < Utilities::MPI::n_mpi_processes(communicator),
-         ExcInternalError());
-
-  // Create an object of nonzero size and then replicate it.
-  AlignedVector<C> avec(Utilities::MPI::this_mpi_process(communicator));
-
-  deallog << "On process " << Utilities::MPI::this_mpi_process(communicator)
-          << ": Replicating..." << std::endl;
-
-  avec.replicate_across_communicator(communicator, root);
-
-  deallog << "On process " << Utilities::MPI::this_mpi_process(communicator)
-          << ": Going out of scope" << std::endl;
-}
-
-
-
-int
-main(int argc, char **argv)
-{
-  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
-  MPILogInitAll                    all;
-
-  test();
-
-  deallog << "Objects created: " << object_number << std::endl;
-  deallog << "Objects destroyed: " << objects_destroyed << std::endl;
-}
diff --git a/tests/base/aligned_vector_replicate_05.mpirun=3.output b/tests/base/aligned_vector_replicate_05.mpirun=3.output
deleted file mode 100644 (file)
index e4fe2b2..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-
-DEAL:0::On process 0: 0
-
-DEAL:1::On process 1: 0
-
-
-DEAL:2::On process 2: 0
-
diff --git a/tests/base/table_replicate_01.cc b/tests/base/table_replicate_01.cc
new file mode 100644 (file)
index 0000000..94d28b5
--- /dev/null
@@ -0,0 +1,75 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2012 - 2018 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// Test Table::replicate_across_communicator(). Cycle through all
+// possible root ranks.
+
+#include <deal.II/base/table.h>
+
+#include "../tests.h"
+
+
+void
+test(const unsigned int root)
+{
+  if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root)
+    deallog << root << " of " << Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD)
+            << ": ";
+
+  Table<2, int> table(10, 12);
+  if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root)
+    {
+      table.reinit(6, 8);
+      unsigned int counter = 0;
+      for (auto &i : table)
+        i = counter++;
+    }
+
+  table.replicate_across_communicator(MPI_COMM_WORLD, root);
+
+  // Now check that the sizes are correct on all processes
+  Assert(table.size()[0] == 6, ExcInternalError());
+  Assert(table.size()[1] == 8, ExcInternalError());
+
+  // Then also check the table contents:
+  {
+    unsigned int counter = 0;
+
+    for (auto &i : table)
+      {
+        AssertDimension(i, counter);
+        ++counter;
+      }
+  }
+
+  MPI_Barrier(MPI_COMM_WORLD);
+
+  if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == root)
+    deallog << "OK!" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  MPILogInitAll                    all;
+
+  for (unsigned int i = 0; i < Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD);
+       ++i)
+    test(i);
+}
diff --git a/tests/base/table_replicate_01.mpirun=3.output b/tests/base/table_replicate_01.mpirun=3.output
new file mode 100644 (file)
index 0000000..db547dd
--- /dev/null
@@ -0,0 +1,8 @@
+
+DEAL:0::0 of 3: OK!
+
+DEAL:1::1 of 3: OK!
+
+
+DEAL:2::2 of 3: OK!
+

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.