--- /dev/null
+//---------------------------------------------------------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 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::set_zero(Vector) for parallel distributed vectors
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/parallel_vector.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/lac/parallel_block_vector.h>
+
+#include <fstream>
+
+
+void test ()
+{
+ unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+ unsigned int numproc = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD);
+
+ std::vector<IndexSet> local_active(2);
+
+ // block 0:
+ local_active[0].set_size(numproc);
+ local_active[0].add_range(myid,myid+1);
+
+ // block 1:
+ local_active[1].set_size(2*numproc);
+ local_active[1].add_range(myid*2,myid*2+2);
+
+ parallel::distributed::BlockVector<double> v(2);
+ v.block(0).reinit(local_active[0], complete_index_set(numproc), MPI_COMM_WORLD);
+ v.block(1).reinit(local_active[1], complete_index_set(2*numproc), MPI_COMM_WORLD);
+ v.collect_sizes();
+
+ for (unsigned int i=0;i<v.size();++i)
+ v(i)=1.0+i;
+ v.compress(VectorOperation::insert);
+
+ IndexSet local_active_together(3*numproc);
+ local_active_together.add_range(myid,myid+1);
+ local_active_together.add_range(numproc+myid*2,numproc+myid*2+2);
+
+ ConstraintMatrix cm(local_active_together);
+ cm.add_line(numproc + myid*2);
+ cm.close();
+
+ deallog << "vector before:" << std::endl;
+ v.block(0).print(deallog.get_file_stream());
+ v.block(1).print(deallog.get_file_stream());
+
+ deallog << std::endl;
+ deallog << "CM:" << std::endl;
+ cm.print(deallog.get_file_stream());
+
+ cm.set_zero(v);
+
+ deallog << "vector after:" << std::endl;
+ v.block(0).print(deallog.get_file_stream());
+ v.block(1).print(deallog.get_file_stream());
+
+ deallog << "OK" << std::endl;
+}
+
+
+int main(int argc, char *argv[])
+{
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+ MPILogInitAll log(__FILE__);
+
+ test();
+ return 0;
+}
--- /dev/null
+
+DEAL:0::vector before:
+Process #0
+Local range: [0/1], global size: 1
+Vector data:
+1.000e+00
+Ghost entries (global index / value):
+
+Process #0
+Local range: [0/2], global size: 2
+Vector data:
+2.000e+00 3.000e+00
+Ghost entries (global index / value):
+
+DEAL:0::
+DEAL:0::CM:
+ 1 = 0
+DEAL:0::vector after:
+Process #0
+Local range: [0/1], global size: 1
+Vector data:
+1.000e+00
+Ghost entries (global index / value):
+
+Process #0
+Local range: [0/2], global size: 2
+Vector data:
+0.000e+00 3.000e+00
+Ghost entries (global index / value):
+
+DEAL:0::OK
--- /dev/null
+
+DEAL:0::vector before:
+Process #0
+Local range: [0/1], global size: 2
+Vector data:
+1.000e+00
+Ghost entries (global index / value):
+(1/0.000e+00)
+Process #0
+Local range: [0/2], global size: 4
+Vector data:
+3.000e+00 4.000e+00
+Ghost entries (global index / value):
+(2/0.000e+00) (3/0.000e+00)
+DEAL:0::
+DEAL:0::CM:
+ 2 = 0
+DEAL:0::vector after:
+Process #0
+Local range: [0/1], global size: 2
+Vector data:
+1.000e+00
+Ghost entries (global index / value):
+(1/0.000e+00)
+Process #0
+Local range: [0/2], global size: 4
+Vector data:
+0.000e+00 4.000e+00
+Ghost entries (global index / value):
+(2/0.000e+00) (3/0.000e+00)
+DEAL:0::OK
+
+DEAL:1::vector before:
+Process #1
+Local range: [1/2], global size: 2
+Vector data:
+2.000e+00
+Ghost entries (global index / value):
+(0/0.000e+00)
+Process #1
+Local range: [2/4], global size: 4
+Vector data:
+5.000e+00 6.000e+00
+Ghost entries (global index / value):
+(0/0.000e+00) (1/0.000e+00)
+DEAL:1::
+DEAL:1::CM:
+ 4 = 0
+DEAL:1::vector after:
+Process #1
+Local range: [1/2], global size: 2
+Vector data:
+2.000e+00
+Ghost entries (global index / value):
+(0/0.000e+00)
+Process #1
+Local range: [2/4], global size: 4
+Vector data:
+0.000e+00 6.000e+00
+Ghost entries (global index / value):
+(0/0.000e+00) (1/0.000e+00)
+DEAL:1::OK
+