]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add test for a parallel trilinos bug when calling compress()
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 3 Aug 2011 03:36:32 +0000 (03:36 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 3 Aug 2011 03:36:32 +0000 (03:36 +0000)
git-svn-id: https://svn.dealii.org/trunk@24000 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/mpi/trilinos_compress_bug.cc b/tests/mpi/trilinos_compress_bug.cc
new file mode 100644 (file)
index 0000000..da708c5
--- /dev/null
@@ -0,0 +1,104 @@
+//----------------------------  trilinos_vector_reinit.cc  ---------------------------
+//    $Id: trilinos_vector_reinit.cc 23710 2011-05-17 04:50:10Z bangerth $
+//    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  ---------------------------
+
+
+// document a bug in Trilinos regarding compress()
+
+#include "../tests.h"
+#include <deal.II/base/utilities.h>
+#include <deal.II/base/index_set.h>
+#include <deal.II/lac/trilinos_vector.h>
+#include <deal.II/lac/constraint_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+#include "../../deal.II/include/deal.II/base/index_set.h"
+#include "../../deal.II/include/deal.II/lac/trilinos_vector.h"
+
+
+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;
+
+  IndexSet locally_owned(21);
+  if (myid==0)
+    locally_owned.add_range(0,9);
+  else
+    locally_owned.add_range(9,21);
+
+  TrilinosWrappers::MPI::Vector test1(locally_owned);
+  if (myid==0)
+  {
+    unsigned int idx[]={0,1,2,3,4,5,6,7,8};
+    double val[]={0,1,2,3,4,5,6,7,8};
+    test1.add(9,idx,val);
+  }
+  else
+  {
+   {
+      unsigned int idx[]={1,9,3,10,5,11,12,13,14};
+    double val[]={1,9,3,10,5,11,12,13,14};
+    test1.add(9,idx,val);
+    }
+  }
+  
+  test1.compress(Add);
+  TrilinosWrappers::MPI::Vector test(locally_owned);
+  //  TrilinosWrappers::MPI::Vector test(test1);
+
+  test = 0;
+
+  if (myid==0)
+    test(locally_owned.nth_index_in_set(5))=7;  
+
+  if (myid==0)
+    deallog << "before compress: " << test(locally_owned.nth_index_in_set(5)) << endl;
+      
+   test.compress(Insert);
+  if (myid==0)
+    deallog << "after compress: " << test(locally_owned.nth_index_in_set(5)) << endl;
+      
+
+  // Trilinos produces a 0 instead of a 7 here. Why? 
+  Assert(test(locally_owned.nth_index_in_set(5)) == 7, 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_compress_bug").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_compress_bug/ncpu_2/cmp/generic b/tests/mpi/trilinos_compress_bug/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.