]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Test vector reinitialization.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 30 Mar 2011 14:32:01 +0000 (14:32 +0000)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 30 Mar 2011 14:32:01 +0000 (14:32 +0000)
git-svn-id: https://svn.dealii.org/trunk@23547 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/mpi/trilinos_vector_reinit.cc b/tests/mpi/trilinos_vector_reinit.cc
new file mode 100644 (file)
index 0000000..7258afc
--- /dev/null
@@ -0,0 +1,79 @@
+//----------------------------  trilinos_vector_reinit.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2011 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.
+//
+//----------------------------  trilinos_vector_reinit.cc  ---------------------------
+
+
+// check correct behaviour of reinit of Trilinos vectors
+
+#include "../tests.h"
+#include <base/utilities.h>
+#include <base/index_set.h>
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test ()
+{
+  unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
+  unsigned int numproc = Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD);
+
+  if (myid==0) deallog << "numproc=" << numproc << std::endl;
+
+
+  TrilinosWrappers::MPI::Vector test1, test2;
+
+  Assert (test1.vector_partitioner().SameAs(test2.vector_partitioner()),
+         ExcInternalError());
+
+                                  // first processor owns 2 indices, second
+                                  // processor owns none
+  IndexSet local_owned(2);
+  if (myid == 0)
+    local_owned.add_range (0,2);
+
+  test1.reinit (local_owned, MPI_COMM_WORLD);
+
+                               // reinit Trilinos vector from other vector
+  test2.reinit (test1, true);
+
+  Assert (test1.vector_partitioner().SameAs(test2.vector_partitioner()),
+         ExcInternalError());
+
+  if (Utilities::System::get_this_mpi_process (MPI_COMM_WORLD) == 0)
+    deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+  Utilities::System::MPI_InitFinalize mpi_initialization(argc, argv);
+
+  unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
+  deallog.push(Utilities::int_to_string(myid));
+
+  if (myid == 0)
+    {
+      std::ofstream logfile(output_file_for_mpi("trilinos_vector_reinit").c_str());
+      deallog.attach(logfile);
+      deallog << std::setprecision(4);
+      deallog.depth_console(0);
+      deallog.threshold_double(1.e-10);
+
+      test();
+    }
+  else
+    test();
+
+}
diff --git a/tests/mpi/trilinos_vector_reinit/ncpu_2/cmp/generic b/tests/mpi/trilinos_vector_reinit/ncpu_2/cmp/generic
new file mode 100644 (file)
index 0000000..1cf39ab
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL:0::numproc=2
+DEAL:0::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.