]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add tests
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 5 Aug 2013 15:32:47 +0000 (15:32 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 5 Aug 2013 15:32:47 +0000 (15:32 +0000)
git-svn-id: https://svn.dealii.org/trunk@30222 0785d39b-7218-0410-832d-ea1e28bc413d

tests/gla/block_vec_03.cc [new file with mode: 0644]
tests/gla/block_vec_03/ncpu_2/cmp/generic [new file with mode: 0644]
tests/gla/block_vec_03/ncpu_4/cmp/generic [new file with mode: 0644]
tests/gla/vec_04.cc [new file with mode: 0644]
tests/gla/vec_04/ncpu_2/cmp/generic [new file with mode: 0644]
tests/gla/vec_04/ncpu_4/cmp/generic [new file with mode: 0644]

diff --git a/tests/gla/block_vec_03.cc b/tests/gla/block_vec_03.cc
new file mode 100644 (file)
index 0000000..cd895ed
--- /dev/null
@@ -0,0 +1,105 @@
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2004 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+// copying of ghosted 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 (myid==0)
+    block1.add_range(0,7);
+  if (myid==1)
+    block1.add_range(7,10);
+
+  IndexSet block2(numproc);
+  block2.add_index(myid);
+
+  std::vector<IndexSet> partitioning;
+  partitioning.push_back(block1);
+  partitioning.push_back(block2);
+
+  std::vector<IndexSet> relevant = partitioning;
+  relevant[0].add_index(0);
+  relevant[1].add_range(0,numproc);
+  
+  typename LA::MPI::BlockVector v(partitioning, MPI_COMM_WORLD);
+  typename LA::MPI::BlockVector v2(partitioning, relevant, MPI_COMM_WORLD);
+
+  Assert(!v.has_ghost_elements(), ExcInternalError());
+  Assert(v2.has_ghost_elements(), ExcInternalError());
+  Assert(!v.block(0).has_ghost_elements(), ExcInternalError());
+  Assert(!v.block(1).has_ghost_elements(), ExcInternalError());
+  Assert(v2.block(0).has_ghost_elements(), ExcInternalError());
+  Assert(v2.block(1).has_ghost_elements(), ExcInternalError());
+
+  v.reinit(partitioning, relevant, MPI_COMM_WORLD);
+  Assert(v.has_ghost_elements(), ExcInternalError());
+  Assert(v.block(0).has_ghost_elements(), ExcInternalError());
+  Assert(v.block(1).has_ghost_elements(), ExcInternalError());
+  v.reinit(partitioning, MPI_COMM_WORLD);
+  Assert(!v.has_ghost_elements(), ExcInternalError());
+  
+
+  typename LA::MPI::BlockVector v3 = v2;
+  Assert(v3.has_ghost_elements(), ExcInternalError());
+
+  v3 = v; // just copy data, keep ghosts
+  Assert(v3.has_ghost_elements(), ExcInternalError());
+
+  typename LA::MPI::Vector x = v2.block(0);
+  Assert(x.has_ghost_elements(), ExcInternalError());
+  
+  // 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_03/ncpu_2/cmp/generic b/tests/gla/block_vec_03/ncpu_2/cmp/generic
new file mode 100644 (file)
index 0000000..ef67ab3
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL:0:PETSc::numproc=2
+DEAL:0:PETSc::OK
+DEAL:0:Trilinos::numproc=2
+DEAL:0:Trilinos::OK
+
+
diff --git a/tests/gla/block_vec_03/ncpu_4/cmp/generic b/tests/gla/block_vec_03/ncpu_4/cmp/generic
new file mode 100644 (file)
index 0000000..9e64c7e
--- /dev/null
@@ -0,0 +1,11 @@
+
+DEAL:0:PETSc::numproc=4
+DEAL:0:PETSc::OK
+DEAL:0:Trilinos::numproc=4
+DEAL:0:Trilinos::OK
+
+
+
+
+
+
diff --git a/tests/gla/vec_04.cc b/tests/gla/vec_04.cc
new file mode 100644 (file)
index 0000000..4576121
--- /dev/null
@@ -0,0 +1,110 @@
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2004 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+// test assignment of ghost 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;
+
+  // each processor owns 2 indices and all
+  // are ghosting Element 1 (the second)
+
+  IndexSet local_active(numproc*2);
+  local_active.add_range(myid*2,myid*2+2);
+  IndexSet local_relevant(numproc*2);
+  local_relevant.add_range(1,2);
+
+  typename LA::MPI::Vector vb(local_active, MPI_COMM_WORLD);
+  typename LA::MPI::Vector v(local_active, local_relevant, MPI_COMM_WORLD);
+
+  vb = 1.0;
+
+  // set local values
+  vb(myid*2)=myid*2.0;
+  vb(myid*2+1)=myid*2.0+1.0;
+
+  vb.compress(VectorOperation::insert);
+  vb*=2.0;
+  v=vb;
+
+  Assert(vb.size() == numproc*2, ExcInternalError());
+  Assert(v.size() == numproc*2, ExcInternalError());
+
+  Assert(!vb.has_ghost_elements(), ExcInternalError());
+  Assert(v.has_ghost_elements(), ExcInternalError());
+  
+  typename LA::MPI::Vector test;
+  Assert(!test.has_ghost_elements(), ExcInternalError());
+
+  {  
+    typename LA::MPI::Vector x;
+    x=v; // x is empty so it should copy layout(with ghosts) and data
+    Assert(x.has_ghost_elements(), ExcInternalError());
+    deallog << "ghosted value: " << x(1) << std::endl;
+    x=vb; // import, so keep ghost elements
+    Assert(x.has_ghost_elements(), ExcInternalError());
+    deallog << "ghosted value: " << x(1) << std::endl;    
+  }
+  {
+    typename LA::MPI::Vector x;
+    x=vb;
+    Assert(!x.has_ghost_elements(), ExcInternalError());
+    x=test;
+    x=v;
+    Assert(x.has_ghost_elements(), ExcInternalError());
+    deallog << "ghosted value: " << x(1) << 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/vec_04/ncpu_2/cmp/generic b/tests/gla/vec_04/ncpu_2/cmp/generic
new file mode 100644 (file)
index 0000000..b31ae49
--- /dev/null
@@ -0,0 +1,19 @@
+
+DEAL:0:PETSc::numproc=2
+DEAL:0:PETSc::ghosted value: 2.00000
+DEAL:0:PETSc::ghosted value: 2.00000
+DEAL:0:PETSc::ghosted value: 2.00000
+DEAL:0:PETSc::OK
+DEAL:0:Trilinos::numproc=2
+DEAL:0:Trilinos::ghosted value: 2.00000
+DEAL:0:Trilinos::ghosted value: 2.00000
+DEAL:0:Trilinos::ghosted value: 2.00000
+DEAL:0:Trilinos::OK
+
+DEAL:1:PETSc::ghosted value: 2.00000
+DEAL:1:PETSc::ghosted value: 2.00000
+DEAL:1:PETSc::ghosted value: 2.00000
+DEAL:1:Trilinos::ghosted value: 2.00000
+DEAL:1:Trilinos::ghosted value: 2.00000
+DEAL:1:Trilinos::ghosted value: 2.00000
+
diff --git a/tests/gla/vec_04/ncpu_4/cmp/generic b/tests/gla/vec_04/ncpu_4/cmp/generic
new file mode 100644 (file)
index 0000000..7913918
--- /dev/null
@@ -0,0 +1,35 @@
+
+DEAL:0:PETSc::numproc=4
+DEAL:0:PETSc::ghosted value: 2.00000
+DEAL:0:PETSc::ghosted value: 2.00000
+DEAL:0:PETSc::ghosted value: 2.00000
+DEAL:0:PETSc::OK
+DEAL:0:Trilinos::numproc=4
+DEAL:0:Trilinos::ghosted value: 2.00000
+DEAL:0:Trilinos::ghosted value: 2.00000
+DEAL:0:Trilinos::ghosted value: 2.00000
+DEAL:0:Trilinos::OK
+
+DEAL:1:PETSc::ghosted value: 2.00000
+DEAL:1:PETSc::ghosted value: 2.00000
+DEAL:1:PETSc::ghosted value: 2.00000
+DEAL:1:Trilinos::ghosted value: 2.00000
+DEAL:1:Trilinos::ghosted value: 2.00000
+DEAL:1:Trilinos::ghosted value: 2.00000
+
+
+DEAL:2:PETSc::ghosted value: 2.00000
+DEAL:2:PETSc::ghosted value: 2.00000
+DEAL:2:PETSc::ghosted value: 2.00000
+DEAL:2:Trilinos::ghosted value: 2.00000
+DEAL:2:Trilinos::ghosted value: 2.00000
+DEAL:2:Trilinos::ghosted value: 2.00000
+
+
+DEAL:3:PETSc::ghosted value: 2.00000
+DEAL:3:PETSc::ghosted value: 2.00000
+DEAL:3:PETSc::ghosted value: 2.00000
+DEAL:3:Trilinos::ghosted value: 2.00000
+DEAL:3:Trilinos::ghosted value: 2.00000
+DEAL:3:Trilinos::ghosted value: 2.00000
+

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.