]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Test case for parallel block vector
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 8 Jul 2013 05:54:44 +0000 (05:54 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 8 Jul 2013 05:54:44 +0000 (05:54 +0000)
git-svn-id: https://svn.dealii.org/trunk@29951 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/mpi/constraint_matrix_set_zero_02.cc b/tests/mpi/constraint_matrix_set_zero_02.cc
new file mode 100644 (file)
index 0000000..2b1a2d3
--- /dev/null
@@ -0,0 +1,84 @@
+//---------------------------------------------------------------------------
+//    $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;
+}
diff --git a/tests/mpi/constraint_matrix_set_zero_02/ncpu_1/cmp/generic b/tests/mpi/constraint_matrix_set_zero_02/ncpu_1/cmp/generic
new file mode 100644 (file)
index 0000000..25f1bf0
--- /dev/null
@@ -0,0 +1,31 @@
+
+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
diff --git a/tests/mpi/constraint_matrix_set_zero_02/ncpu_2/cmp/generic b/tests/mpi/constraint_matrix_set_zero_02/ncpu_2/cmp/generic
new file mode 100644 (file)
index 0000000..ca88ff9
--- /dev/null
@@ -0,0 +1,63 @@
+
+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
+

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.