]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add new test
authorTimo Heister <timo.heister@gmail.com>
Tue, 13 Aug 2013 19:55:26 +0000 (19:55 +0000)
committerTimo Heister <timo.heister@gmail.com>
Tue, 13 Aug 2013 19:55:26 +0000 (19:55 +0000)
git-svn-id: https://svn.dealii.org/trunk@30305 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/gla/block_vec_04.cc b/tests/gla/block_vec_04.cc
new file mode 100644 (file)
index 0000000..ee5398d
--- /dev/null
@@ -0,0 +1,102 @@
+// ---------------------------------------------------------------------
+// $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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// allow operator= for BlockVectors if dest is same size or empty
+
+#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);
+  typename LA::MPI::BlockVector v_1(partitioning, MPI_COMM_WORLD);
+  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_2(partitioning, MPI_COMM_WORLD);
+
+  {
+    typename LA::MPI::BlockVector x(partitioning, MPI_COMM_WORLD);
+    x=v_2;
+  }
+  {
+    typename LA::MPI::BlockVector x;
+    x=v_2;
+  }
+  {
+    deal_II_exceptions::disable_abort_on_exception();
+    try
+      {        
+       typename LA::MPI::BlockVector x=v_1;
+       x=v_2; // error
+      }
+    catch (const ExceptionBase &e)
+      {
+       deallog << "Exception: " << e.get_exc_name() << 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_04/ncpu_2/cmp/generic b/tests/gla/block_vec_04/ncpu_2/cmp/generic
new file mode 100644 (file)
index 0000000..9f3dc0c
--- /dev/null
@@ -0,0 +1,11 @@
+
+DEAL:0:PETSc::numproc=2
+DEAL:0:PETSc::Exception: ExcDimensionMismatch(n_blocks(), v.n_blocks())
+DEAL:0:PETSc::OK
+DEAL:0:Trilinos::numproc=2
+DEAL:0:Trilinos::Exception: ExcDimensionMismatch(n_blocks(), v.n_blocks())
+DEAL:0:Trilinos::OK
+
+DEAL:1:PETSc::Exception: ExcDimensionMismatch(n_blocks(), v.n_blocks())
+DEAL:1:Trilinos::Exception: ExcDimensionMismatch(n_blocks(), v.n_blocks())
+

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.