--- /dev/null
+//---------------------------------------------------------------------------
+// $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();
+
+}