]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test for communication patterns supported now.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 8 Mar 2017 09:36:29 +0000 (10:36 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 8 Mar 2017 09:39:52 +0000 (10:39 +0100)
tests/mpi/communicator_validity.cc [new file with mode: 0644]
tests/mpi/communicator_validity.mpirun=2.output [new file with mode: 0644]

diff --git a/tests/mpi/communicator_validity.cc b/tests/mpi/communicator_validity.cc
new file mode 100644 (file)
index 0000000..6a4b5c6
--- /dev/null
@@ -0,0 +1,76 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 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 at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// check that LinearAlgebra::distributed::Vector::operator= does not carry
+// over any state from a duplicated MPI communicator in conjunction with a
+// distributed mesh
+
+
+#include "../tests.h"
+#include <deal.II/base/mpi.h>
+#include <deal.II/lac/la_parallel_vector.h>
+#include <deal.II/lac/vector_memory.h>
+#include <deal.II/distributed/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/fe/fe_dgq.h>
+
+template <typename VectorType>
+void do_test(MPI_Comm communicator)
+{
+  const int dim = 2;
+  parallel::distributed::Triangulation<dim> tria(communicator);
+  GridGenerator::hyper_cube(tria);
+  tria.refine_global(2);
+  FE_DGQ<dim> fe(0);
+  DoFHandler<dim> dof(tria);
+  dof.distribute_dofs(fe);
+
+  VectorType v1;
+  v1.reinit(dof.locally_owned_dofs(), communicator);
+  if (dof.locally_owned_dofs().n_elements() > 0)
+    v1.local_element(0) = 1;
+
+  GrowingVectorMemory<VectorType> memory;
+  typename VectorMemory<VectorType>::Pointer v3(memory);
+  *v3 = v1;
+
+  deallog << v1.l2_norm() << " " << v3->l2_norm() << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, testing_max_num_threads());
+
+  mpi_initlog();
+
+  do_test<LinearAlgebra::distributed::Vector<double> >(MPI_COMM_WORLD);
+
+  {
+    MPI_Comm communicator = Utilities::MPI::duplicate_communicator(MPI_COMM_WORLD);
+    do_test<LinearAlgebra::distributed::Vector<double> >(communicator);
+    MPI_Comm_free (&communicator);
+  }
+  {
+    MPI_Comm communicator = Utilities::MPI::duplicate_communicator(MPI_COMM_WORLD);
+    do_test<LinearAlgebra::distributed::Vector<double> >(communicator);
+    MPI_Comm_free (&communicator);
+  }
+
+  do_test<LinearAlgebra::distributed::Vector<double> >(MPI_COMM_WORLD);
+}
diff --git a/tests/mpi/communicator_validity.mpirun=2.output b/tests/mpi/communicator_validity.mpirun=2.output
new file mode 100644 (file)
index 0000000..b5fba2e
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::1.41421 1.41421
+DEAL::1.41421 1.41421
+DEAL::1.41421 1.41421
+DEAL::1.41421 1.41421

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.