]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add new test
authorTimo Heister <timo.heister@gmail.com>
Thu, 6 Jun 2013 21:52:38 +0000 (21:52 +0000)
committerTimo Heister <timo.heister@gmail.com>
Thu, 6 Jun 2013 21:52:38 +0000 (21:52 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_unify_linear_algebra@29790 0785d39b-7218-0410-832d-ea1e28bc413d

tests/gla/block_vec_01.cc [new file with mode: 0644]
tests/gla/block_vec_01/ncpu_10/cmp/generic [new file with mode: 0644]
tests/gla/block_vec_01/ncpu_4/cmp/generic [new file with mode: 0644]

diff --git a/tests/gla/block_vec_01.cc b/tests/gla/block_vec_01.cc
new file mode 100644 (file)
index 0000000..b21a5e3
--- /dev/null
@@ -0,0 +1,93 @@
+//---------------------------------------------------------------------------
+//    $Id: ghost_01.cc 28440 2013-02-17 14:35:08Z heister $
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004, 2005, 2010 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.
+//
+//---------------------------------------------------------------------------
+
+
+// block vectors
+
+#include "../tests.h"
+#include <deal.II/lac/generic_linear_algebra.h>
+#include <deal.II/base/index_set.h>
+#include <deal.II/lac/constraint_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <vector>
+
+#include "gla.h"
+
+template <class LA> 
+void test ()
+{
+  unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+  unsigned int numproc = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD);
+  
+  if (myid==0)
+    deallog << "numproc=" << numproc << std::endl;
+
+  IndexSet block1(10);
+  if (numproc==1)
+    block1.add_range(0,10);
+
+  if (myid==0)
+    block1.add_range(0,7);
+  if (myid==1)
+    block1.add_range(7,10);
+
+  IndexSet block2(6);
+  if (numproc==1)
+    block2.add_range(0,6);
+
+  if (myid==0)
+    block2.add_range(0,2);
+  if (myid==1)
+    block2.add_range(2,6);
+
+  std::vector<IndexSet> partitioning;
+  partitioning.push_back(block1);
+  partitioning.push_back(block2);
+
+  typename LA::MPI::BlockVector v(partitioning, MPI_COMM_WORLD);
+  v = 0.1;
+
+  deallog << "l2norm: " << v.l2_norm() << std::endl;
+
+  v(myid) = myid;
+  v.compress(VectorOperation::insert);
+
+  deallog << "size: " << v.size() << std::endl;
+  deallog << "block(0).size: " << v.block(0).size() << std::endl;
+  deallog << "block(1).size: " << v.block(1).size() << std::endl;
+  if (block1.n_elements()>0)
+    deallog << "my first entry: " << v(block1.nth_index_in_set(0)) << std::endl;
+  
+                                  // done
+  if (myid==0)
+    deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  MPILogInitAll log(__FILE__);
+  {
+    deallog.push("PETSc");
+    test<LA_PETSc>();
+    deallog.pop();
+    deallog.push("Trilinos");
+    test<LA_Trilinos>();
+    deallog.pop();
+  }
+
+}
diff --git a/tests/gla/block_vec_01/ncpu_10/cmp/generic b/tests/gla/block_vec_01/ncpu_10/cmp/generic
new file mode 100644 (file)
index 0000000..43306ba
--- /dev/null
@@ -0,0 +1,107 @@
+
+DEAL:0:PETSc::numproc=10
+DEAL:0:PETSc::l2norm: 0.400000
+DEAL:0:PETSc::size: 16
+DEAL:0:PETSc::block(0).size: 10
+DEAL:0:PETSc::block(1).size: 6
+DEAL:0:PETSc::my first entry: 0.00000
+DEAL:0:PETSc::OK
+DEAL:0:Trilinos::numproc=10
+DEAL:0:Trilinos::l2norm: 0.400000
+DEAL:0:Trilinos::size: 16
+DEAL:0:Trilinos::block(0).size: 10
+DEAL:0:Trilinos::block(1).size: 6
+DEAL:0:Trilinos::my first entry: 0.00000
+DEAL:0:Trilinos::OK
+
+DEAL:1:PETSc::l2norm: 0.400000
+DEAL:1:PETSc::size: 16
+DEAL:1:PETSc::block(0).size: 10
+DEAL:1:PETSc::block(1).size: 6
+DEAL:1:PETSc::my first entry: 7.00000
+DEAL:1:Trilinos::l2norm: 0.400000
+DEAL:1:Trilinos::size: 16
+DEAL:1:Trilinos::block(0).size: 10
+DEAL:1:Trilinos::block(1).size: 6
+DEAL:1:Trilinos::my first entry: 7.00000
+
+
+DEAL:2:PETSc::l2norm: 0.400000
+DEAL:2:PETSc::size: 16
+DEAL:2:PETSc::block(0).size: 10
+DEAL:2:PETSc::block(1).size: 6
+DEAL:2:Trilinos::l2norm: 0.400000
+DEAL:2:Trilinos::size: 16
+DEAL:2:Trilinos::block(0).size: 10
+DEAL:2:Trilinos::block(1).size: 6
+
+
+DEAL:3:PETSc::l2norm: 0.400000
+DEAL:3:PETSc::size: 16
+DEAL:3:PETSc::block(0).size: 10
+DEAL:3:PETSc::block(1).size: 6
+DEAL:3:Trilinos::l2norm: 0.400000
+DEAL:3:Trilinos::size: 16
+DEAL:3:Trilinos::block(0).size: 10
+DEAL:3:Trilinos::block(1).size: 6
+
+
+DEAL:4:PETSc::l2norm: 0.400000
+DEAL:4:PETSc::size: 16
+DEAL:4:PETSc::block(0).size: 10
+DEAL:4:PETSc::block(1).size: 6
+DEAL:4:Trilinos::l2norm: 0.400000
+DEAL:4:Trilinos::size: 16
+DEAL:4:Trilinos::block(0).size: 10
+DEAL:4:Trilinos::block(1).size: 6
+
+
+DEAL:5:PETSc::l2norm: 0.400000
+DEAL:5:PETSc::size: 16
+DEAL:5:PETSc::block(0).size: 10
+DEAL:5:PETSc::block(1).size: 6
+DEAL:5:Trilinos::l2norm: 0.400000
+DEAL:5:Trilinos::size: 16
+DEAL:5:Trilinos::block(0).size: 10
+DEAL:5:Trilinos::block(1).size: 6
+
+
+DEAL:6:PETSc::l2norm: 0.400000
+DEAL:6:PETSc::size: 16
+DEAL:6:PETSc::block(0).size: 10
+DEAL:6:PETSc::block(1).size: 6
+DEAL:6:Trilinos::l2norm: 0.400000
+DEAL:6:Trilinos::size: 16
+DEAL:6:Trilinos::block(0).size: 10
+DEAL:6:Trilinos::block(1).size: 6
+
+
+DEAL:7:PETSc::l2norm: 0.400000
+DEAL:7:PETSc::size: 16
+DEAL:7:PETSc::block(0).size: 10
+DEAL:7:PETSc::block(1).size: 6
+DEAL:7:Trilinos::l2norm: 0.400000
+DEAL:7:Trilinos::size: 16
+DEAL:7:Trilinos::block(0).size: 10
+DEAL:7:Trilinos::block(1).size: 6
+
+
+DEAL:8:PETSc::l2norm: 0.400000
+DEAL:8:PETSc::size: 16
+DEAL:8:PETSc::block(0).size: 10
+DEAL:8:PETSc::block(1).size: 6
+DEAL:8:Trilinos::l2norm: 0.400000
+DEAL:8:Trilinos::size: 16
+DEAL:8:Trilinos::block(0).size: 10
+DEAL:8:Trilinos::block(1).size: 6
+
+
+DEAL:9:PETSc::l2norm: 0.400000
+DEAL:9:PETSc::size: 16
+DEAL:9:PETSc::block(0).size: 10
+DEAL:9:PETSc::block(1).size: 6
+DEAL:9:Trilinos::l2norm: 0.400000
+DEAL:9:Trilinos::size: 16
+DEAL:9:Trilinos::block(0).size: 10
+DEAL:9:Trilinos::block(1).size: 6
+
diff --git a/tests/gla/block_vec_01/ncpu_4/cmp/generic b/tests/gla/block_vec_01/ncpu_4/cmp/generic
new file mode 100644 (file)
index 0000000..e82db44
--- /dev/null
@@ -0,0 +1,47 @@
+
+DEAL:0:PETSc::numproc=4
+DEAL:0:PETSc::l2norm: 0.400000
+DEAL:0:PETSc::size: 16
+DEAL:0:PETSc::block(0).size: 10
+DEAL:0:PETSc::block(1).size: 6
+DEAL:0:PETSc::my first entry: 0.00000
+DEAL:0:PETSc::OK
+DEAL:0:Trilinos::numproc=4
+DEAL:0:Trilinos::l2norm: 0.400000
+DEAL:0:Trilinos::size: 16
+DEAL:0:Trilinos::block(0).size: 10
+DEAL:0:Trilinos::block(1).size: 6
+DEAL:0:Trilinos::my first entry: 0.00000
+DEAL:0:Trilinos::OK
+
+DEAL:1:PETSc::l2norm: 0.400000
+DEAL:1:PETSc::size: 16
+DEAL:1:PETSc::block(0).size: 10
+DEAL:1:PETSc::block(1).size: 6
+DEAL:1:PETSc::my first entry: 0.100000
+DEAL:1:Trilinos::l2norm: 0.400000
+DEAL:1:Trilinos::size: 16
+DEAL:1:Trilinos::block(0).size: 10
+DEAL:1:Trilinos::block(1).size: 6
+DEAL:1:Trilinos::my first entry: 0.100000
+
+
+DEAL:2:PETSc::l2norm: 0.400000
+DEAL:2:PETSc::size: 16
+DEAL:2:PETSc::block(0).size: 10
+DEAL:2:PETSc::block(1).size: 6
+DEAL:2:Trilinos::l2norm: 0.400000
+DEAL:2:Trilinos::size: 16
+DEAL:2:Trilinos::block(0).size: 10
+DEAL:2:Trilinos::block(1).size: 6
+
+
+DEAL:3:PETSc::l2norm: 0.400000
+DEAL:3:PETSc::size: 16
+DEAL:3:PETSc::block(0).size: 10
+DEAL:3:PETSc::block(1).size: 6
+DEAL:3:Trilinos::l2norm: 0.400000
+DEAL:3:Trilinos::size: 16
+DEAL:3:Trilinos::block(0).size: 10
+DEAL:3:Trilinos::block(1).size: 6
+

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.