]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New test.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 25 May 2013 13:02:30 +0000 (13:02 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 25 May 2013 13:02:30 +0000 (13:02 +0000)
git-svn-id: https://svn.dealii.org/trunk@29595 0785d39b-7218-0410-832d-ea1e28bc413d

tests/mpi/petsc_locally_owned_elements.cc [new file with mode: 0644]
tests/mpi/petsc_locally_owned_elements/ncpu_1/cmp/generic [new file with mode: 0644]
tests/mpi/petsc_locally_owned_elements/ncpu_10/cmp/generic [new file with mode: 0644]
tests/mpi/petsc_locally_owned_elements/ncpu_2/cmp/generic [new file with mode: 0644]
tests/mpi/petsc_locally_owned_elements/ncpu_4/cmp/generic [new file with mode: 0644]

diff --git a/tests/mpi/petsc_locally_owned_elements.cc b/tests/mpi/petsc_locally_owned_elements.cc
new file mode 100644 (file)
index 0000000..a56304a
--- /dev/null
@@ -0,0 +1,81 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2009, 2010, 2012, 2013 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+
+
+// check ConstraintMatrix.distribute() for a petsc vector
+//
+// like _01, but for a block vector. this has the additional complication that
+// (at a global level) the set of indices owned by this processor is not
+// contiguous
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_parallel_block_vector.h>
+#include <deal.II/lac/constraint_matrix.h>
+
+#include <fstream>
+#include <sstream>
+
+
+
+void test()
+{
+  const unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+  const unsigned int n_processes = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD);
+
+  // create a vector that consists of elements indexed from 0 to n
+  PETScWrappers::MPI::BlockVector vec(2, MPI_COMM_WORLD, 100 * n_processes, 100);
+  vec.block(0).reinit(MPI_COMM_WORLD, 100 * n_processes, 100);
+  vec.block(1).reinit(MPI_COMM_WORLD, 100 * n_processes, 100);
+  vec.collect_sizes();
+  Assert (vec.block(0).local_size() == 100, ExcInternalError());
+  Assert (vec.block(0).local_range().first == 100*myid, ExcInternalError());
+  Assert (vec.block(0).local_range().second == 100*myid+100, ExcInternalError());
+  Assert (vec.block(1).local_size() == 100, ExcInternalError());
+  Assert (vec.block(1).local_range().first == 100*myid, ExcInternalError());
+  Assert (vec.block(1).local_range().second == 100*myid+100, ExcInternalError());
+
+  IndexSet locally_owned (vec.size());
+  locally_owned.add_range (100*myid, 100*myid+100);
+  locally_owned.add_range (vec.block(0).size()+100*myid,
+                          vec.block(0).size()+100*myid+100);
+  Assert (vec.locally_owned_elements() == locally_owned,
+         ExcInternalError());
+
+  if (myid == 0)
+    deallog << "OK" << std::endl;
+}
+
+
+int main(int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+
+  unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+
+
+  deallog.push(Utilities::int_to_string(myid));
+
+  if (myid == 0)
+    {
+      std::ofstream logfile(output_file_for_mpi("petsc_locally_owned_elements").c_str());
+      deallog.attach(logfile);
+      deallog.depth_console(0);
+      deallog.threshold_double(1.e-10);
+
+      test();
+    }
+  else
+    test();
+
+}
diff --git a/tests/mpi/petsc_locally_owned_elements/ncpu_1/cmp/generic b/tests/mpi/petsc_locally_owned_elements/ncpu_1/cmp/generic
new file mode 100644 (file)
index 0000000..be8d055
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL:0::OK
diff --git a/tests/mpi/petsc_locally_owned_elements/ncpu_10/cmp/generic b/tests/mpi/petsc_locally_owned_elements/ncpu_10/cmp/generic
new file mode 100644 (file)
index 0000000..be8d055
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL:0::OK
diff --git a/tests/mpi/petsc_locally_owned_elements/ncpu_2/cmp/generic b/tests/mpi/petsc_locally_owned_elements/ncpu_2/cmp/generic
new file mode 100644 (file)
index 0000000..be8d055
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL:0::OK
diff --git a/tests/mpi/petsc_locally_owned_elements/ncpu_4/cmp/generic b/tests/mpi/petsc_locally_owned_elements/ncpu_4/cmp/generic
new file mode 100644 (file)
index 0000000..be8d055
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL:0::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.