]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add test that documents unwanted PETSc::MPI::SparseMatrix behavior. Currently disable...
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 29 Aug 2011 21:59:20 +0000 (21:59 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 29 Aug 2011 21:59:20 +0000 (21:59 +0000)
git-svn-id: https://svn.dealii.org/trunk@24209 0785d39b-7218-0410-832d-ea1e28bc413d

tests/mpi/petsc_02.cc [new file with mode: 0644]
tests/mpi/petsc_02/ncpu_1/cmp/generic [new file with mode: 0644]
tests/mpi/petsc_02/ncpu_10/cmp/generic [new file with mode: 0644]
tests/mpi/petsc_02/ncpu_4/cmp/generic [new file with mode: 0644]

diff --git a/tests/mpi/petsc_02.cc b/tests/mpi/petsc_02.cc
new file mode 100644 (file)
index 0000000..401600b
--- /dev/null
@@ -0,0 +1,78 @@
+//---------------------------------------------------------------------------
+//    $Id: simple_mpi_01.cc 23327 2011-02-11 03:19:07Z bangerth $
+//    Version: $Name$
+//
+//    Copyright (C) 2009 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.
+//
+//---------------------------------------------------------------------------
+
+
+// PETScWrappers: document bug with PETSc SparseMatrix. If only one CPU
+// does matrix-assembly, it calls compress() inside and the others don't.
+// We should implement this like in PETSc::MPI::Vector.
+
+#include "../tests.h"
+
+#include <deal.II/lac/compressed_simple_sparsity_pattern.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>    
+#include <deal.II/lac/petsc_parallel_sparse_matrix.h>    
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/utilities.h>
+
+#include <fstream>
+//#include <mpi.h>
+
+
+void test()
+{
+  unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD);
+  unsigned int numprocs = Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD);
+
+  if (myid==0)
+    deallog << "Running on " << numprocs << " CPU(s)." << std::endl;
+
+  CompressedSimpleSparsityPattern csp(2);
+  csp.add(0,0);
+  csp.add(1,1);
+  
+  PETScWrappers::MPI::SparseMatrix mat;
+  std::vector< unsigned int > local_rows(numprocs, 0);
+  local_rows[0]=2;
+  
+  mat.reinit(MPI_COMM_WORLD, csp, local_rows, local_rows, myid);
+
+#warning this here hangs, so it is uncommented until bug is fixed
+  //if (myid == 0 )
+       mat.add(0, 0, 1.0);
+
+  
+  mat.compress();
+
+  if (myid==0)
+    deallog << "done" << std::endl;
+}
+
+
+int main(int argc, char *argv[])
+{
+  PetscInitialize(&argc,&argv,0,0);
+
+  if (Utilities::System::get_this_mpi_process (MPI_COMM_WORLD) == 0)
+    {
+      std::ofstream logfile(output_file_for_mpi("petsc_02").c_str());
+      deallog.attach(logfile);
+      deallog.depth_console(0);
+      deallog.threshold_double(1.e-10);
+
+      test();
+    }
+  else
+    test();
+
+  PetscFinalize();
+}
diff --git a/tests/mpi/petsc_02/ncpu_1/cmp/generic b/tests/mpi/petsc_02/ncpu_1/cmp/generic
new file mode 100644 (file)
index 0000000..76a3add
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL::Running on 1 CPU(s).
+DEAL::2nd try
+DEAL::done
diff --git a/tests/mpi/petsc_02/ncpu_10/cmp/generic b/tests/mpi/petsc_02/ncpu_10/cmp/generic
new file mode 100644 (file)
index 0000000..729abc0
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL::Running on 10 CPU(s).
+DEAL::2nd try
+DEAL::done
diff --git a/tests/mpi/petsc_02/ncpu_4/cmp/generic b/tests/mpi/petsc_02/ncpu_4/cmp/generic
new file mode 100644 (file)
index 0000000..25e3150
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL::Running on 4 CPU(s).
+DEAL::2nd try
+DEAL::done

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.