]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add unit tests for complex-valued PETSc and SLEPc
authorToby D. Young <oneliefleft@gmail.com>
Tue, 23 Feb 2016 06:57:45 +0000 (07:57 +0100)
committerDenis Davydov <davydden@gmail.com>
Sat, 12 Mar 2016 18:55:07 +0000 (19:55 +0100)
76 files changed:
tests/petsc_complex/00.cc [new file with mode: 0644]
tests/petsc_complex/00.output [new file with mode: 0644]
tests/petsc_complex/01.cc [new file with mode: 0644]
tests/petsc_complex/01.output [new file with mode: 0644]
tests/petsc_complex/02.cc [new file with mode: 0644]
tests/petsc_complex/02.output [new file with mode: 0644]
tests/petsc_complex/04.cc [new file with mode: 0644]
tests/petsc_complex/04.output [new file with mode: 0644]
tests/petsc_complex/05.cc [new file with mode: 0644]
tests/petsc_complex/05.output [new file with mode: 0644]
tests/petsc_complex/06.cc [new file with mode: 0644]
tests/petsc_complex/06.output [new file with mode: 0644]
tests/petsc_complex/07.cc [new file with mode: 0644]
tests/petsc_complex/07.output [new file with mode: 0644]
tests/petsc_complex/08.cc [new file with mode: 0644]
tests/petsc_complex/08.output [new file with mode: 0644]
tests/petsc_complex/09.cc [new file with mode: 0644]
tests/petsc_complex/09.output [new file with mode: 0644]
tests/petsc_complex/10.cc [new file with mode: 0644]
tests/petsc_complex/10.output [new file with mode: 0644]
tests/petsc_complex/11.cc [new file with mode: 0644]
tests/petsc_complex/11.output [new file with mode: 0644]
tests/petsc_complex/12.cc [new file with mode: 0644]
tests/petsc_complex/12.output [new file with mode: 0644]
tests/petsc_complex/13.cc [new file with mode: 0644]
tests/petsc_complex/13.output [new file with mode: 0644]
tests/petsc_complex/17.cc [new file with mode: 0644]
tests/petsc_complex/17.output [new file with mode: 0644]
tests/petsc_complex/18.cc [new file with mode: 0644]
tests/petsc_complex/18.output [new file with mode: 0644]
tests/petsc_complex/19.cc [new file with mode: 0644]
tests/petsc_complex/19.output [new file with mode: 0644]
tests/petsc_complex/20.cc [new file with mode: 0644]
tests/petsc_complex/20.output [new file with mode: 0644]
tests/petsc_complex/CMakeLists.txt [new file with mode: 0644]
tests/petsc_complex/element_access_00.cc [new file with mode: 0644]
tests/petsc_complex/element_access_00.output [new file with mode: 0644]
tests/petsc_complex/element_access_01.cc [new file with mode: 0644]
tests/petsc_complex/element_access_01.output [new file with mode: 0644]
tests/petsc_complex/element_access_02.cc [new file with mode: 0644]
tests/petsc_complex/element_access_02.output [new file with mode: 0644]
tests/petsc_complex/element_access_03.cc [new file with mode: 0644]
tests/petsc_complex/element_access_03.output [new file with mode: 0644]
tests/petsc_complex/fe_get_function_values.cc [new file with mode: 0644]
tests/petsc_complex/fe_get_function_values.mpirun=3.output [new file with mode: 0644]
tests/petsc_complex/parallel_sparse_matrix_01.cc [new file with mode: 0644]
tests/petsc_complex/parallel_sparse_matrix_01.mpirun=3.output [new file with mode: 0644]
tests/petsc_complex/solver_real_01.cc [new file with mode: 0644]
tests/petsc_complex/solver_real_01.output [new file with mode: 0644]
tests/petsc_complex/solver_real_02.cc [new file with mode: 0644]
tests/petsc_complex/solver_real_02.output [new file with mode: 0644]
tests/petsc_complex/solver_real_03.cc [new file with mode: 0644]
tests/petsc_complex/solver_real_03.output [new file with mode: 0644]
tests/petsc_complex/solver_real_03_mf.cc [new file with mode: 0644]
tests/petsc_complex/solver_real_03_mf.output [new file with mode: 0644]
tests/petsc_complex/solver_real_04.cc [new file with mode: 0644]
tests/petsc_complex/solver_real_04.output [new file with mode: 0644]
tests/petsc_complex/sparse_matrix_01.cc [new file with mode: 0644]
tests/petsc_complex/sparse_matrix_01.output [new file with mode: 0644]
tests/petsc_complex/vector_02.cc [new file with mode: 0644]
tests/petsc_complex/vector_02.output [new file with mode: 0644]
tests/petsc_complex/vector_assign_01.cc [new file with mode: 0644]
tests/petsc_complex/vector_assign_01.output [new file with mode: 0644]
tests/petsc_complex/vector_assign_02.cc [new file with mode: 0644]
tests/petsc_complex/vector_assign_02.output [new file with mode: 0644]
tests/petsc_complex/vector_equality_1.cc [new file with mode: 0644]
tests/petsc_complex/vector_equality_1.output [new file with mode: 0644]
tests/petsc_complex/vector_equality_2.cc [new file with mode: 0644]
tests/petsc_complex/vector_equality_2.output [new file with mode: 0644]
tests/petsc_complex/vector_print.cc [new file with mode: 0644]
tests/petsc_complex/vector_print.output [new file with mode: 0644]
tests/petsc_complex/vector_wrap_01.cc [new file with mode: 0644]
tests/petsc_complex/vector_wrap_01.output [new file with mode: 0644]
tests/slepc_complex/00.cc [new file with mode: 0644]
tests/slepc_complex/00.output [new file with mode: 0644]
tests/slepc_complex/CMakeLists.txt [new file with mode: 0644]

diff --git a/tests/petsc_complex/00.cc b/tests/petsc_complex/00.cc
new file mode 100644 (file)
index 0000000..f00cdb4
--- /dev/null
@@ -0,0 +1,218 @@
+// ---------------------------------------------------------------------
+// $Id: 00.cc$
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+// PETSc includes: We would like to do this cleanly
+//
+#include <petscksp.h>
+#include <petscsys.h>
+#include <petscmath.h>
+//
+// though a horrible warning message
+//
+// warning: imaginary constants are a GCC extension [enabled by default]
+//
+// appears. This seems to be related to the direct useage of
+// PetscScalar in accordance with gcc.gnu.org bug 7263.
+
+// deal.II includes
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+
+#include <fstream>
+#include <iostream>
+#include <cassert>
+
+// These tests were used while building extensions for
+// PetscSclar=complex. They check that std::complex<double> and
+// PetscScalar complex are compatible without explicitly casting.
+//
+// These tests look archaic - they are the original tests used to
+// figure out how PetscScalar complex works...
+
+// Multiply a PETSc complex number by a complex number.
+void multiply_petsc_complex_by_a_number ()
+{
+  deallog << "Check PetscScalar multiply" << std::endl;
+
+  // make alpha
+  const PetscScalar alpha = 1.0 + 2.0*PETSC_i;
+
+  // make beta
+  const PetscScalar beta  = 2.0 + 1.0*PETSC_i;
+
+  // multiply them together
+  const PetscScalar gamma = alpha * beta;
+
+  // Check real access
+  Assert (PetscRealPart (gamma)==0., ExcInternalError());
+  Assert (PetscImaginaryPart (gamma) ==5., ExcInternalError());
+
+  // This is legal too!
+  Assert (gamma==std::complex<double> (0.,5), ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+// Divide a PETSc complex number by a real number.
+void divide_petsc_complex_by_a_number ()
+{
+  deallog << "Check PetscScalar division" << std::endl;
+
+  // make alpha
+  PetscScalar alpha      = 1.0 + 2.0*PETSC_i;
+
+  // make beta <- alpha/2
+  const PetscScalar beta = alpha/2.;
+
+  // Check real access
+  Assert (PetscRealPart (alpha)==1.,  ExcInternalError());
+  Assert (PetscRealPart (beta) ==0.5, ExcInternalError());
+
+  // operate on alpha (now alpha==beta)
+  alpha /= 2.;
+
+  // Check complex access
+  Assert (PetscImaginaryPart (alpha)==1., ExcInternalError());
+  Assert (PetscImaginaryPart (beta) ==1., ExcInternalError());
+
+  // This is legal too!
+  Assert (alpha==beta, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+// Initialize a std::complex number from an PETSc complex number
+void make_std_complex_from_petsc_complex ()
+{
+  deallog << "Check std initialised from PetscScalar" << std::endl;
+  const PetscScalar alpha         = 1.0 + 2.0*PETSC_i;
+  const std::complex<double> beta = alpha;
+
+  // These should be the same of course
+  Assert (alpha==beta, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+// Initialize a PETSc complex number from an std::complex number
+void make_petsc_complex_from_std_complex ()
+{
+  deallog << "Check PetscScalar initialised from std" << std::endl;
+  const std::complex<double> beta (1,2);
+  const PetscScalar alpha = beta;
+
+  // These should be the same of course
+  Assert (alpha==beta, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+// Initialize a PETSc complex number directly.
+void make_petsc_complex ()
+{
+  deallog << "Check a nonzero PetscScalar" << std::endl;
+
+  // init
+  const PetscScalar alpha = 1.0 + 2.0*PETSC_i;
+
+  // Test if PetscScalar is an std::complex.
+  Assert (alpha==std::complex<double> (1.,2.), ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+// Initialize a PETSc complex number directly only, check he is
+// initialised to 0+0i.
+void init_petsc_complex ()
+{
+  deallog << "Check PetscScalar initialisation" << std::endl;
+
+  // Initialise (no argument) to zero.
+  const PetscScalar alpha;
+  Assert (alpha==std::complex<double> (0.,0.), ExcInternalError());
+
+  // Initialise (real argument) to zero.
+  const PetscScalar beta = 0.;
+  Assert (beta==alpha, ExcInternalError());
+
+  // Initialise (real+complex argument) to zero.
+  const PetscScalar gamma = 0. + 0.*PETSC_i;
+  Assert (gamma==beta, ExcInternalError());
+
+  // If alpha==beta==gamma, then:
+  Assert (alpha==gamma, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile ("output");
+  dealii::deallog.attach (logfile);
+  dealii::deallog.depth_console (0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      PetscInitialize (&argc, &argv, (char *) 0, (char *) 0);
+      {
+        // initialisation (zero and nonzero)
+        init_petsc_complex ();
+        make_petsc_complex ();
+
+        // initialisation from std::complex (and vice versa)
+        make_petsc_complex_from_std_complex ();
+        make_std_complex_from_petsc_complex ();
+
+        // some operators
+        divide_petsc_complex_by_a_number ();
+        multiply_petsc_complex_by_a_number ();
+      }
+      PetscFinalize ();
+    }
+
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    }
+
+  logfile << std::endl;
+
+  return 0;
+}
+
+
diff --git a/tests/petsc_complex/00.output b/tests/petsc_complex/00.output
new file mode 100644 (file)
index 0000000..8fc890b
--- /dev/null
@@ -0,0 +1,14 @@
+
+DEAL::Check PetscScalar initialisation
+DEAL::OK
+DEAL::Check a nonzero PetscScalar
+DEAL::OK
+DEAL::Check PetscScalar initialised from std
+DEAL::OK
+DEAL::Check std initialised from PetscScalar
+DEAL::OK
+DEAL::Check PetscScalar division
+DEAL::OK
+DEAL::Check PetscScalar multiply
+DEAL::OK
+
diff --git a/tests/petsc_complex/01.cc b/tests/petsc_complex/01.cc
new file mode 100644 (file)
index 0000000..4dbcfec
--- /dev/null
@@ -0,0 +1,95 @@
+// ---------------------------------------------------------------------
+// $Id: 01.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+// check setting elements in a petsc matrix using
+// PETScWrappers::SparseMatrix::set()
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (PETScWrappers::SparseMatrix &m)
+{
+  // first set a few entries
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        m.set (i,j, std::complex<double> (0.,i*j*.5+.5));
+
+  m.compress (VectorOperation::add);
+
+  // then make sure we retrieve the same ones
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        {
+          Assert (m(i,j)    == std::complex<double> (0.,i*j*.5+.5), ExcInternalError());
+          Assert (m.el(i,j) == std::complex<double> (0.,i*j*.5+.5), ExcInternalError());
+        }
+      else
+        {
+          Assert (m(i,j)    == std::complex<double> (0.,0.), ExcInternalError());
+          Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
+        }
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::SparseMatrix m (5,5,3);
+        test (m);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/01.output b/tests/petsc_complex/01.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/02.cc b/tests/petsc_complex/02.cc
new file mode 100644 (file)
index 0000000..dd70f49
--- /dev/null
@@ -0,0 +1,96 @@
+// ---------------------------------------------------------------------
+// $Id: 02.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+// check setting elements in a petsc matrix using
+// PETScWrappers::SparseMatrix::add()
+
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (PETScWrappers::SparseMatrix &m)
+{
+  // first set a few entries
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        m.add (i,j, std::complex<double> (0.,i*j*.5+.5));
+
+  m.compress (VectorOperation::add);
+
+  // then make sure we retrieve the same ones
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        {
+          Assert (m(i,j)    == std::complex<double> (0.,i*j*.5+.5), ExcInternalError());
+          Assert (m.el(i,j) == std::complex<double> (0.,i*j*.5+.5), ExcInternalError());
+        }
+      else
+        {
+          Assert (m(i,j)    == std::complex<double> (0.,0.), ExcInternalError());
+          Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
+        }
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::SparseMatrix m(5,5,3);
+        test (m);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/02.output b/tests/petsc_complex/02.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/04.cc b/tests/petsc_complex/04.cc
new file mode 100644 (file)
index 0000000..b0a8d51
--- /dev/null
@@ -0,0 +1,75 @@
+// ---------------------------------------------------------------------
+// $Id: 04.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+// check querying matrix sizes
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (PETScWrappers::SparseMatrix &m)
+{
+  Assert (m.m() == 5, ExcInternalError());
+  Assert (m.n() == 5, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::SparseMatrix m (5,5,3);
+        test (m);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/04.output b/tests/petsc_complex/04.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/05.cc b/tests/petsc_complex/05.cc
new file mode 100644 (file)
index 0000000..dd468a6
--- /dev/null
@@ -0,0 +1,91 @@
+// ---------------------------------------------------------------------
+// $Id: 05.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+// check querying the number of nonzero elements in
+// PETScWrappers::SparseMatrix
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (PETScWrappers::SparseMatrix &m)
+{
+  // first set a few entries. count how many entries we have
+  unsigned int counter = 0;
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        {
+          m.set (i,j, std::complex<double> (0.,i*j*.5+.5));
+          ++counter;
+        }
+
+  m.compress (VectorOperation::add);
+
+  deallog << m.n_nonzero_elements() << std::endl;
+  Assert (m.n_nonzero_elements() == counter,
+          ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::SparseMatrix m (5,5,3);
+        test (m);
+
+        deallog << "OK" << std::endl;
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/05.output b/tests/petsc_complex/05.output
new file mode 100644 (file)
index 0000000..ab05652
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL::8
+DEAL::OK
+DEAL::OK
diff --git a/tests/petsc_complex/06.cc b/tests/petsc_complex/06.cc
new file mode 100644 (file)
index 0000000..e3cc027
--- /dev/null
@@ -0,0 +1,84 @@
+// ---------------------------------------------------------------------
+// $Id: 06.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+// check PETScWrappers::SparseMatrix::l1_norm
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (PETScWrappers::SparseMatrix &m)
+{
+  // first set a few entries. count how many entries we have
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        m.set (i,j, std::complex<double> (0.,i*j*.5+.5));
+
+  m.compress (VectorOperation::add);
+
+  // compare against the exact value of the l1-norm (max col-sum)
+  deallog << m.l1_norm() << std::endl;
+  Assert (m.l1_norm() == 7, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::SparseMatrix m(5,5,3);
+        test (m);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/06.output b/tests/petsc_complex/06.output
new file mode 100644 (file)
index 0000000..c3a0c69
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::7.00000
+DEAL::OK
diff --git a/tests/petsc_complex/07.cc b/tests/petsc_complex/07.cc
new file mode 100644 (file)
index 0000000..3a1cafb
--- /dev/null
@@ -0,0 +1,87 @@
+// ---------------------------------------------------------------------
+// $Id: 07.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check PETScWrappers::SparseMatrix::linfty_norm
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (PETScWrappers::SparseMatrix &m)
+{
+  // first set a few entries. count how many entries we have
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        m.set (i,j, std::complex<double> (0.,i*j*.5+.5));
+
+  m.compress (VectorOperation::add);
+
+  // compare against the exact value of the linfty-norm (max row-sum).
+  deallog << m.linfty_norm() << std::endl;
+  Assert (m.linfty_norm() == 8.5, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::SparseMatrix m(5,5,3);
+        test (m);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
+
+
diff --git a/tests/petsc_complex/07.output b/tests/petsc_complex/07.output
new file mode 100644 (file)
index 0000000..22d8c0e
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::8.50000
+DEAL::OK
diff --git a/tests/petsc_complex/08.cc b/tests/petsc_complex/08.cc
new file mode 100644 (file)
index 0000000..e34a00a
--- /dev/null
@@ -0,0 +1,92 @@
+// ---------------------------------------------------------------------
+// $Id: 08.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check PETScWrappers::SparseMatrix::frobenius_norm
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (PETScWrappers::SparseMatrix &m)
+{
+  // first set a few entries. count how many entries we have
+  PetscScalar norm = 0;
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        {
+          m.set (i,j, std::complex<double> (0.,i*j*.5+.5));
+          norm += (i*j*.5+.5)*(i*j*.5+.5);
+        }
+  norm = std::sqrt(norm);
+
+  m.compress (VectorOperation::add);
+
+  // compare against the exact value of the l2-norm (max row-sum)
+  deallog << m.frobenius_norm() << std::endl;
+  Assert (m.frobenius_norm() == norm, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::SparseMatrix m(5,5,3);
+        test (m);
+      }
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
+
+
diff --git a/tests/petsc_complex/08.output b/tests/petsc_complex/08.output
new file mode 100644 (file)
index 0000000..d4083f6
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::9.04157
+DEAL::OK
diff --git a/tests/petsc_complex/09.cc b/tests/petsc_complex/09.cc
new file mode 100644 (file)
index 0000000..e04c644
--- /dev/null
@@ -0,0 +1,101 @@
+// ---------------------------------------------------------------------
+// $Id: 09.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check PETScWrappers::SparseMatrix::operator *=
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (PETScWrappers::SparseMatrix &m)
+{
+  // first set a few entries
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        m.set (i,j, std::complex<double> (i*j*.5+.5,i*j*.5));
+
+  m.compress (VectorOperation::add);
+
+  // then multiply everything by 1.25
+  m *= 1.25;
+
+  // and make sure we retrieve the values we expect
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        {
+          Assert (m(i,j)    == std::complex<double> ((i*j*.5+.5)*1.25,i*j*.5*1.25), ExcInternalError());
+          Assert (m.el(i,j) == std::complex<double> ((i*j*.5+.5)*1.25,i*j*.5*1.25), ExcInternalError());
+        }
+      else
+        {
+          Assert (m(i,j)    == std::complex<double> (0.,0.), ExcInternalError());
+          Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
+        }
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::SparseMatrix m(5,5,3);
+        test (m);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
+
+
diff --git a/tests/petsc_complex/09.output b/tests/petsc_complex/09.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/10.cc b/tests/petsc_complex/10.cc
new file mode 100644 (file)
index 0000000..5d27dd6
--- /dev/null
@@ -0,0 +1,100 @@
+// ---------------------------------------------------------------------
+// $id: 10.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+// check PETScWrappers::SparseMatrix::operator /=
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+
+void test (PETScWrappers::SparseMatrix &m)
+{
+  // first set a few entries
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        m.set (i,j, std::complex<double> (0.,i*j*.5+.5));
+
+  m.compress (VectorOperation::add);
+
+  // then divide everything by 4/3 and make sure we retrieve the
+  // values we expect
+  m /= 4./3.;
+
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        {
+          Assert (m(i,j)    == std::complex<double> (0.,(i*j*.5+.5)/4*3), ExcInternalError());
+          Assert (m.el(i,j) == std::complex<double> (0.,(i*j*.5+.5)/4*3), ExcInternalError());
+        }
+      else
+        {
+          Assert (m(i,j)    == std::complex<double> (0.,0.), ExcInternalError());
+          Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
+        }
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::SparseMatrix m(5,5,3);
+        test (m);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
+
+
diff --git a/tests/petsc_complex/10.output b/tests/petsc_complex/10.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/11.cc b/tests/petsc_complex/11.cc
new file mode 100644 (file)
index 0000000..2b332d9
--- /dev/null
@@ -0,0 +1,80 @@
+// ---------------------------------------------------------------------
+// $Id: 11.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check PETScWrappers::Vector::size()
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (PETScWrappers::Vector &v)
+{
+  // set only certain elements of the vector
+  for (unsigned int k=0; k<v.size(); k+=1+k)
+    v(k) = std::complex<double> (k,.5*k);
+
+  v.compress (VectorOperation::add);
+
+  Assert (v.size() == 100, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v(100);
+        test (v);
+      }
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/11.output b/tests/petsc_complex/11.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/12.cc b/tests/petsc_complex/12.cc
new file mode 100644 (file)
index 0000000..608fa3b
--- /dev/null
@@ -0,0 +1,97 @@
+// ---------------------------------------------------------------------
+// $Id: 12.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check PETScWrappers::Vector::operator() in set-mode
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+
+void test (PETScWrappers::Vector &v)
+{
+  deallog << "Complex test" << std::endl;
+
+  // set only certain elements of the vector. have a bit pattern of
+  // where we actually wrote elements to
+  std::vector<bool> pattern (v.size(), false);
+  for (unsigned int k=0; k<v.size(); k+=1+k)
+    {
+      v(k)       = std::complex<double> (0.,k);
+      pattern[k] = true;
+    }
+
+  v.compress (VectorOperation::add);
+
+  // check that they are ok, and this time all of them
+  for (unsigned int k=0; k<v.size(); ++k)
+    {
+      const PetscScalar el = v(k);
+      Assert ( ( (pattern[k] == true) && (PetscRealPart(el) == 0.) && (PetscImaginaryPart(el) == k) )
+               ||
+               ( (pattern[k] == false) && (PetscRealPart(el) == 0.) && (PetscImaginaryPart(el) == 0.)),
+               ExcInternalError());
+    }
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v(100);
+        test (v);
+      }
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/12.output b/tests/petsc_complex/12.output
new file mode 100644 (file)
index 0000000..c3da7ab
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::Complex test
+DEAL::OK
diff --git a/tests/petsc_complex/13.cc b/tests/petsc_complex/13.cc
new file mode 100644 (file)
index 0000000..03af432
--- /dev/null
@@ -0,0 +1,93 @@
+// ---------------------------------------------------------------------
+// $Id: 13.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check PETScWrappers::Vector::operator() in add-mode
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (PETScWrappers::Vector &v)
+{
+  // set only certain elements of the vector. have a bit pattern of
+  // where we actually wrote elements to
+  std::vector<bool> pattern (v.size(), false);
+  for (unsigned int i=0; i<v.size(); i+=1+i)
+    {
+      v(i) += PetscScalar (i,i);
+      pattern[i] = true;
+    }
+
+  v.compress (VectorOperation::add);
+
+  // check that they are ok, and this time all of them
+  for (unsigned int i=0; i<v.size(); ++i)
+    Assert ( ( (pattern[i]==true) && (v(i).real()==i) && (v(i).imag()==i) ) ||
+             //&& (v(i)==std::complex<double> (1.,1.)) ) ||
+             ( (pattern[i]==false) && (v(i).real()==0.) && (v(i).imag()==0.) ),
+             ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v (100);
+        test (v);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/13.output b/tests/petsc_complex/13.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/17.cc b/tests/petsc_complex/17.cc
new file mode 100644 (file)
index 0000000..a4c85e1
--- /dev/null
@@ -0,0 +1,85 @@
+// ---------------------------------------------------------------------
+// $Id: 17.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check PETScWrappers::Vector::l1_norm()
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (PETScWrappers::Vector &v)
+{
+  // set some elements of the vector
+  double norm = 0;
+  for (unsigned int k=0; k<v.size(); k+=1+k)
+    {
+      v(k) = PetscScalar (k,2.*k);
+      norm += std::fabs (1.*k+2.*k);
+    }
+  v.compress (VectorOperation::add);
+
+  // then check the norm
+  Assert (v.l1_norm() == norm, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v (100);
+        test (v);
+      }
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/17.output b/tests/petsc_complex/17.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/18.cc b/tests/petsc_complex/18.cc
new file mode 100644 (file)
index 0000000..c575c59
--- /dev/null
@@ -0,0 +1,91 @@
+// ---------------------------------------------------------------------
+// $Id: 18.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check PETScWrappers::Vector::l2_norm()
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (PETScWrappers::Vector &v)
+{
+  // set some elements of the vector
+  double norm = 0;
+  for (unsigned int k=0; k<v.size(); k+=1+k)
+    {
+      PetscScalar el = PetscScalar (k,2.*k);
+      v(k)  = el;
+
+      // norm += el*PetscConj (el);
+      norm += std::fabs (1.*k*1.*k /*+ 1.*k*2*ki - 1.*k*2*ki*/ + 2*k*2.*k/*i*/);
+    }
+
+  v.compress (VectorOperation::add);
+
+  // then check the l2-norm
+  PetscReal l2_norm = v.l2_norm();
+  Assert (l2_norm==std::sqrt(norm), ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v (100);
+        test (v);
+      }
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/18.output b/tests/petsc_complex/18.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/19.cc b/tests/petsc_complex/19.cc
new file mode 100644 (file)
index 0000000..4bb0c1b
--- /dev/null
@@ -0,0 +1,88 @@
+// ---------------------------------------------------------------------
+// $Id: 19.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check PETScWrappers::Vector::linfty_norm()
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (PETScWrappers::Vector &v)
+{
+  // set some elements of the vector
+  double norm = 0;
+  for (unsigned int k=0; k<v.size(); k+=1+k)
+    {
+      v(k) = std::complex<double> (k,2.*k);
+
+      // Ugly, but equal.
+      norm = std::max (norm,std::fabs (std::sqrt ((k*k + 2.*k*2.*k))));
+    }
+
+  v.compress (VectorOperation::add);
+
+  // then check the norm
+  Assert (v.linfty_norm() == norm, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v (100);
+        test (v);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/19.output b/tests/petsc_complex/19.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/20.cc b/tests/petsc_complex/20.cc
new file mode 100644 (file)
index 0000000..0774b2c
--- /dev/null
@@ -0,0 +1,100 @@
+// ---------------------------------------------------------------------
+// $Id: 23.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check PETScWrappers::Vector::operator*(Vector) on two vectors that are
+// not orthogonal
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (PETScWrappers::Vector &v,
+           PETScWrappers::Vector &w)
+{
+  // set only certain elements of each
+  // vector, and record the expected scalar
+  // product
+  PetscScalar product = PetscScalar(0);
+  for (unsigned int i=0; i<v.size(); ++i)
+    {
+      const PetscScalar vi = std::complex<double> (i, (i%2)*2.0);
+      v(i) = vi;
+      if (i%3 == 0)
+        {
+          const PetscScalar wi = std::complex<double> (5.0-i,2.5*(i%6));
+          w(i) = wi;
+          product += PetscConj(vi)*wi;
+        }
+    }
+
+  v.compress (VectorOperation::add);
+  w.compress (VectorOperation::add);
+
+  // make sure the scalar product is zero
+  Assert (v*w == product, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v (100);
+        PETScWrappers::Vector w (100);
+        test (v,w);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/20.output b/tests/petsc_complex/20.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/CMakeLists.txt b/tests/petsc_complex/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d8809e0
--- /dev/null
@@ -0,0 +1,6 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)
+INCLUDE(../setup_testsubproject.cmake)
+PROJECT(testsuite CXX)
+IF(DEAL_II_WITH_PETSC AND PETSC_WITH_COMPLEX)
+  DEAL_II_PICKUP_TESTS()
+ENDIF()
diff --git a/tests/petsc_complex/element_access_00.cc b/tests/petsc_complex/element_access_00.cc
new file mode 100644 (file)
index 0000000..a088479
--- /dev/null
@@ -0,0 +1,112 @@
+
+// ---------------------------------------------------------------------
+// $Id:
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+// deal.II includes
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <cassert>
+
+#include <complex>
+
+// test dealii::internal::VectorReference::real()
+// test dealii::internal::VectorReference::imag()
+// on vector
+
+// vector elements
+void test_vector (PETScWrappers::Vector &v)
+{
+  deallog << "Check vector access" << std::endl;
+
+  // fill up a vector with some numbers
+  for (unsigned int k=0; k<v.size(); ++k)
+    v(k) = std::complex<double> (k,v.size()-k);
+
+  v.compress (VectorOperation::add);
+
+  // check that is what we get by casting PetscScalar to std::real()
+  // and std::imag()
+  for (unsigned int k=0; k<v.size(); ++k)
+    Assert ((static_cast<std::complex<double> > (v(k)).real ()==k) &&
+            (static_cast<std::complex<double> > (v(k)).imag ()==v.size()-k),
+            ExcInternalError());
+
+  // check that is what we get by
+  // dealii::internal::VectorReference::real() and
+  // dealii::internal::VectorReference::imag()
+  for (unsigned int k=0; k<v.size(); ++k)
+    Assert ((v(k).real ()==k) && (v(k).imag ()==v.size()-k),
+            ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile ("output");
+  dealii::deallog.attach (logfile);
+  dealii::deallog.depth_console (0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      PetscInitialize (&argc, &argv, (char *) 0, (char *) 0);
+      {
+        PETScWrappers::Vector v (5);
+        test_vector (v);
+
+        deallog << "vector:" << std::endl;
+        v.print (logfile);
+      }
+      PetscFinalize ();
+    }
+
+
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    }
+
+  logfile << std::endl;
+
+  return 0;
+}
+
+
diff --git a/tests/petsc_complex/element_access_00.output b/tests/petsc_complex/element_access_00.output
new file mode 100644 (file)
index 0000000..60ff416
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Check vector access
+DEAL::OK
+DEAL::vector:
+(0.000e+00,5.000e+00) (1.000e+00,4.000e+00) (2.000e+00,3.000e+00) (3.000e+00,2.000e+00) (4.000e+00,1.000e+00) 
+
diff --git a/tests/petsc_complex/element_access_01.cc b/tests/petsc_complex/element_access_01.cc
new file mode 100644 (file)
index 0000000..31b0a4f
--- /dev/null
@@ -0,0 +1,111 @@
+
+// ---------------------------------------------------------------------
+// $Id:
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+// deal.II includes
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+
+#include <fstream>
+#include <iostream>
+#include <cassert>
+
+#include <complex>
+
+// test read/write access to matrices using explicit cast always.
+
+// sparse matrix elements
+void test_matrix (PETScWrappers::SparseMatrix &m)
+{
+  deallog << "Check 01 matrix access" << std::endl;
+
+  // fill up a matrix with some numbers
+  for (unsigned int k=0; k<m.m(); ++k)
+    for (unsigned int l=0; l<m.n(); ++l)
+      {
+        PetscReal el_r = static_cast<double> (k+l);
+        PetscReal el_i = static_cast<double> (-1.*(k+l));
+        m.set (k,l, std::complex<double> (el_r,el_i));
+      }
+
+  m.compress (VectorOperation::add);
+
+  for (unsigned int k=0; k<m.m(); ++k)
+    for (unsigned int l=0; l<m.n(); ++l)
+      {
+        PetscReal el_r = static_cast<double> (k+l);
+        PetscReal el_i = static_cast<double> (-1.*(k+l));
+
+        Assert ((m(k,l).real ()==el_r) && (m(k,l).imag ()==el_i),
+                ExcInternalError());
+      }
+
+  deallog << "OK" << std::endl;
+}
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile ("output");
+  dealii::deallog.attach (logfile);
+  dealii::deallog.depth_console (0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      PetscInitialize (&argc, &argv, (char *) 0, (char *) 0);
+      {
+        PETScWrappers::SparseMatrix m (5,5,5);
+        test_matrix (m);
+
+        deallog << "matrix:" << std::endl;
+        m.print (logfile);
+      }
+      PetscFinalize ();
+    }
+
+
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    }
+
+  logfile << std::endl;
+
+  return 0;
+}
+
+
diff --git a/tests/petsc_complex/element_access_01.output b/tests/petsc_complex/element_access_01.output
new file mode 100644 (file)
index 0000000..faa0818
--- /dev/null
@@ -0,0 +1,30 @@
+
+DEAL::Check 01 matrix access
+DEAL::OK
+DEAL::matrix:
+(0,0) (0.00000,0.00000)
+(0,1) (1.00000,-1.00000)
+(0,2) (2.00000,-2.00000)
+(0,3) (3.00000,-3.00000)
+(0,4) (4.00000,-4.00000)
+(1,0) (1.00000,-1.00000)
+(1,1) (2.00000,-2.00000)
+(1,2) (3.00000,-3.00000)
+(1,3) (4.00000,-4.00000)
+(1,4) (5.00000,-5.00000)
+(2,0) (2.00000,-2.00000)
+(2,1) (3.00000,-3.00000)
+(2,2) (4.00000,-4.00000)
+(2,3) (5.00000,-5.00000)
+(2,4) (6.00000,-6.00000)
+(3,0) (3.00000,-3.00000)
+(3,1) (4.00000,-4.00000)
+(3,2) (5.00000,-5.00000)
+(3,3) (6.00000,-6.00000)
+(3,4) (7.00000,-7.00000)
+(4,0) (4.00000,-4.00000)
+(4,1) (5.00000,-5.00000)
+(4,2) (6.00000,-6.00000)
+(4,3) (7.00000,-7.00000)
+(4,4) (8.00000,-8.00000)
+
diff --git a/tests/petsc_complex/element_access_02.cc b/tests/petsc_complex/element_access_02.cc
new file mode 100644 (file)
index 0000000..0b66ad3
--- /dev/null
@@ -0,0 +1,99 @@
+
+// ---------------------------------------------------------------------
+// $Id: element_access_02.cc
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+// deal.II includes
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+
+#include <fstream>
+#include <iostream>
+#include <cassert>
+
+// sparse matrix elements
+void test (PETScWrappers::SparseMatrix &m)
+{
+  deallog << "Check matrix access" << std::endl;
+
+  // fill up a matrix with some numbers
+  for (unsigned int k=0; k<m.m(); ++k)
+    for (unsigned int l=0; l<m.n(); ++l)
+      if (k>l)
+        m.set (k,l, PetscScalar (k+l,-1.*(k+l)));
+
+  m.compress (VectorOperation::add);
+
+  // check the matrix is correctly filled
+  for (unsigned int k=0; k<m.m(); ++k)
+    for (unsigned int l=0; l<m.n(); ++l)
+      Assert (m(k,l).real () == -1.*(m(k,l).imag ()),
+              ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile ("output");
+  dealii::deallog.attach (logfile);
+  dealii::deallog.depth_console (0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      PetscInitialize (&argc, &argv, (char *) 0, (char *) 0);
+      {
+        PETScWrappers::SparseMatrix m (10,10,10);
+        test (m);
+
+        deallog << "matrix:" << std::endl;
+        m.print (logfile);
+      }
+      PetscFinalize ();
+    }
+
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    }
+
+  logfile << std::endl;
+
+  return 0;
+}
+
+
diff --git a/tests/petsc_complex/element_access_02.output b/tests/petsc_complex/element_access_02.output
new file mode 100644 (file)
index 0000000..8681f04
--- /dev/null
@@ -0,0 +1,50 @@
+
+DEAL::Check matrix access
+DEAL::OK
+DEAL::matrix:
+(1,0) (1.00000,-1.00000)
+(2,0) (2.00000,-2.00000)
+(2,1) (3.00000,-3.00000)
+(3,0) (3.00000,-3.00000)
+(3,1) (4.00000,-4.00000)
+(3,2) (5.00000,-5.00000)
+(4,0) (4.00000,-4.00000)
+(4,1) (5.00000,-5.00000)
+(4,2) (6.00000,-6.00000)
+(4,3) (7.00000,-7.00000)
+(5,0) (5.00000,-5.00000)
+(5,1) (6.00000,-6.00000)
+(5,2) (7.00000,-7.00000)
+(5,3) (8.00000,-8.00000)
+(5,4) (9.00000,-9.00000)
+(6,0) (6.00000,-6.00000)
+(6,1) (7.00000,-7.00000)
+(6,2) (8.00000,-8.00000)
+(6,3) (9.00000,-9.00000)
+(6,4) (10.0000,-10.0000)
+(6,5) (11.0000,-11.0000)
+(7,0) (7.00000,-7.00000)
+(7,1) (8.00000,-8.00000)
+(7,2) (9.00000,-9.00000)
+(7,3) (10.0000,-10.0000)
+(7,4) (11.0000,-11.0000)
+(7,5) (12.0000,-12.0000)
+(7,6) (13.0000,-13.0000)
+(8,0) (8.00000,-8.00000)
+(8,1) (9.00000,-9.00000)
+(8,2) (10.0000,-10.0000)
+(8,3) (11.0000,-11.0000)
+(8,4) (12.0000,-12.0000)
+(8,5) (13.0000,-13.0000)
+(8,6) (14.0000,-14.0000)
+(8,7) (15.0000,-15.0000)
+(9,0) (9.00000,-9.00000)
+(9,1) (10.0000,-10.0000)
+(9,2) (11.0000,-11.0000)
+(9,3) (12.0000,-12.0000)
+(9,4) (13.0000,-13.0000)
+(9,5) (14.0000,-14.0000)
+(9,6) (15.0000,-15.0000)
+(9,7) (16.0000,-16.0000)
+(9,8) (17.0000,-17.0000)
+
diff --git a/tests/petsc_complex/element_access_03.cc b/tests/petsc_complex/element_access_03.cc
new file mode 100644 (file)
index 0000000..df1a0fc
--- /dev/null
@@ -0,0 +1,119 @@
+
+// ---------------------------------------------------------------------
+// $Id:
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+// deal.II includes
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/base/numbers.h>
+
+#include <fstream>
+#include <iostream>
+#include <cassert>
+
+#include <complex>
+
+// test read/write element access using unsigned int and double.
+
+
+// sparse matrix elements
+void test_matrix (PETScWrappers::SparseMatrix &m)
+{
+  deallog << "Check matrix access" << std::endl;
+
+  const double r =     dealii::numbers::PI;
+  const double i = -1.*dealii::numbers::PI;
+
+  // fill up a matrix with some numbers
+  for (unsigned int k=0; k<m.m(); ++k)
+    for (unsigned int l=0; l<m.n(); ++l)
+      m.set (k,l, PetscScalar ((k+l)*r,(k+l)*i));
+
+  m.compress (VectorOperation::add);
+
+  // Check elements have the correct value
+  for (unsigned int k=0; k<m.m(); ++k)
+    for (unsigned int l=0; l<m.n(); ++l)
+      Assert ((m(k,l).real () ==     (k+l)*dealii::numbers::PI) &&
+              (m(k,l).imag () == -1.*(k+l)*dealii::numbers::PI),
+              ExcInternalError());
+
+  // Use the conjugate to check elements have equal (and opposite)
+  // values.
+  for (unsigned int k=0; k<m.m(); ++k)
+    for (unsigned int l=0; l<m.n(); ++l)
+      {
+        PetscScalar m_conjugate = PetscConj (m(k,l));
+
+        Assert (m_conjugate.real () == m_conjugate.imag (),
+                ExcInternalError());
+      }
+
+  deallog << "OK" << std::endl;
+}
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile ("output");
+  dealii::deallog.attach (logfile);
+  dealii::deallog.depth_console (0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      PetscInitialize (&argc, &argv, (char *) 0, (char *) 0);
+      {
+        PETScWrappers::SparseMatrix m (5,5,5);
+        test_matrix (m);
+
+        deallog << "matrix:" << std::endl;
+        m.print (logfile);
+      }
+      PetscFinalize ();
+    }
+
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    }
+
+  logfile << std::endl;
+
+  return 0;
+}
+
+
diff --git a/tests/petsc_complex/element_access_03.output b/tests/petsc_complex/element_access_03.output
new file mode 100644 (file)
index 0000000..2195d3d
--- /dev/null
@@ -0,0 +1,30 @@
+
+DEAL::Check matrix access
+DEAL::OK
+DEAL::matrix:
+(0,0) (0.00000,0.00000)
+(0,1) (3.14159,-3.14159)
+(0,2) (6.28319,-6.28319)
+(0,3) (9.42478,-9.42478)
+(0,4) (12.5664,-12.5664)
+(1,0) (3.14159,-3.14159)
+(1,1) (6.28319,-6.28319)
+(1,2) (9.42478,-9.42478)
+(1,3) (12.5664,-12.5664)
+(1,4) (15.7080,-15.7080)
+(2,0) (6.28319,-6.28319)
+(2,1) (9.42478,-9.42478)
+(2,2) (12.5664,-12.5664)
+(2,3) (15.7080,-15.7080)
+(2,4) (18.8496,-18.8496)
+(3,0) (9.42478,-9.42478)
+(3,1) (12.5664,-12.5664)
+(3,2) (15.7080,-15.7080)
+(3,3) (18.8496,-18.8496)
+(3,4) (21.9911,-21.9911)
+(4,0) (12.5664,-12.5664)
+(4,1) (15.7080,-15.7080)
+(4,2) (18.8496,-18.8496)
+(4,3) (21.9911,-21.9911)
+(4,4) (25.1327,-25.1327)
+
diff --git a/tests/petsc_complex/fe_get_function_values.cc b/tests/petsc_complex/fe_get_function_values.cc
new file mode 100644 (file)
index 0000000..999e4f0
--- /dev/null
@@ -0,0 +1,177 @@
+// ---------------------------------------------------------------------
+// $Id: testsuite.html 32446 2014-05-21 14:31:22Z davydov $
+//
+// Copyright (C) 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 FEValuesBase::get_function_values()
+// when used with complex vector;
+
+
+#include "../tests.h"
+
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/utilities.h>
+#include <deal.II/base/conditional_ostream.h>
+#include <deal.II/base/index_set.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_refinement.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_values.h>
+
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/constraint_matrix.h>
+
+#include <deal.II/lac/petsc_parallel_vector.h>
+#include <deal.II/lac/petsc_parallel_sparse_matrix.h>
+
+#include <deal.II/lac/trilinos_vector.h>
+
+#include <deal.II/distributed/tria.h>
+#include <deal.II/distributed/grid_refinement.h>
+
+using namespace dealii;
+
+static const unsigned int dim = 2;
+
+void test ()
+{
+
+  MPI_Comm mpi_communicator (MPI_COMM_WORLD);
+  const unsigned int n_mpi_processes (Utilities::MPI::n_mpi_processes(mpi_communicator));
+  const unsigned int this_mpi_process (Utilities::MPI::this_mpi_process(mpi_communicator));
+
+  ConditionalOStream pcout (std::cout,
+                            (Utilities::MPI::this_mpi_process(mpi_communicator)
+                             == 0));
+
+  parallel::distributed::Triangulation<dim> tria(mpi_communicator,
+                                                 typename Triangulation<dim>::MeshSmoothing
+                                                 (Triangulation<dim>::smoothing_on_refinement |
+                                                  Triangulation<dim>::smoothing_on_coarsening));
+
+
+  GridGenerator::hyper_cube (tria, -1,0);
+  tria.refine_global (2);
+
+
+  const unsigned int poly_degree = 1;
+  FE_Q<dim> fe(poly_degree);
+
+  DoFHandler<dim> dof_handler(tria);
+  dof_handler.distribute_dofs(fe);
+
+  IndexSet locally_owned_dofs = dof_handler.locally_owned_dofs ();
+  IndexSet locally_relevant_dofs;
+  DoFTools::extract_locally_relevant_dofs (dof_handler,locally_relevant_dofs);
+
+  PETScWrappers::MPI::Vector vector, vector_locally_relevant;
+  TrilinosWrappers::MPI::Vector vector_Re, vector_Re_locally_relevant,
+                   vector_Im, vector_Im_locally_relevant;
+  vector.reinit(locally_owned_dofs, mpi_communicator);
+  vector_locally_relevant.reinit (locally_owned_dofs,
+                                  locally_relevant_dofs,mpi_communicator);
+
+  vector_Re.reinit(locally_owned_dofs, mpi_communicator);
+  vector_Re_locally_relevant.reinit (locally_owned_dofs,
+                                     locally_relevant_dofs,mpi_communicator);
+
+  vector_Im.reinit(locally_owned_dofs, mpi_communicator);
+  vector_Im_locally_relevant.reinit (locally_owned_dofs,
+                                     locally_relevant_dofs,mpi_communicator);
+
+  const types::global_dof_index n_local_dofs = locally_owned_dofs.n_elements();
+
+  ConstraintMatrix constraints;
+  constraints.reinit(locally_relevant_dofs);
+  DoFTools::make_hanging_node_constraints  (dof_handler, constraints);
+  constraints.close ();
+  //set vector:
+  unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+  for (unsigned int i = 0; i < locally_owned_dofs.n_elements(); i++)
+    {
+      const PetscScalar val = 1.0+myid+ (myid+i%2)*2.0*PETSC_i;
+      vector   ( locally_owned_dofs.nth_index_in_set(i)) = val;
+      vector_Re( locally_owned_dofs.nth_index_in_set(i)) = PetscRealPart (val);
+      vector_Im( locally_owned_dofs.nth_index_in_set(i)) = PetscImaginaryPart (val);
+
+    }
+  vector.compress(VectorOperation::insert);
+  vector_Re.compress(VectorOperation::insert);
+  vector_Im.compress(VectorOperation::insert);
+
+  vector_locally_relevant = vector;
+  vector_Re_locally_relevant = vector_Re;
+  vector_Im_locally_relevant = vector_Im;
+
+  //test get_function_values:
+  {
+    //a separate quadrature formula
+    //enough for mass and kinetic matrices assembly
+    QGauss<dim> quadrature_formula(poly_degree+1);
+    FEValues<dim> fe_values (fe, quadrature_formula,
+                             update_values | update_JxW_values);
+
+    const unsigned int dofs_per_cell = fe.dofs_per_cell;
+    const unsigned int n_q_points    = quadrature_formula.size();
+
+    std::vector<PetscScalar> values(n_q_points);
+    std::vector<double> values_Re(n_q_points),
+        values_Im(n_q_points);
+
+    std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
+
+    typename DoFHandler<dim>::active_cell_iterator
+    cell = dof_handler.begin_active (),
+    endc = dof_handler.end ();
+    for (; cell!=endc; ++cell)
+      if (cell->is_locally_owned())
+        {
+          fe_values.reinit (cell);
+          fe_values.get_function_values (vector_locally_relevant,    values);
+          fe_values.get_function_values (vector_Re_locally_relevant, values_Re);
+          fe_values.get_function_values (vector_Im_locally_relevant, values_Im);
+
+          for (unsigned int q=0; q<n_q_points; ++q)
+            {
+              Assert ( PetscRealPart(values[q])      == values_Re[q], ExcInternalError() );
+              Assert ( PetscImaginaryPart(values[q]) == values_Im[q], ExcInternalError() );
+            }
+        }
+  }
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main (int argc, char *argv[])
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv);
+
+  test ();
+
+}
\ No newline at end of file
diff --git a/tests/petsc_complex/fe_get_function_values.mpirun=3.output b/tests/petsc_complex/fe_get_function_values.mpirun=3.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/parallel_sparse_matrix_01.cc b/tests/petsc_complex/parallel_sparse_matrix_01.cc
new file mode 100644 (file)
index 0000000..503bb3f
--- /dev/null
@@ -0,0 +1,199 @@
+// ---------------------------------------------------------------------
+// $Id: testsuite.html 32446 2014-02-10 14:31:22Z bangerth $
+//
+// Copyright (C) 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 that matrix_scalar_product of a symmetric matrix
+// applied to the same vector result in a real number
+
+
+#include "../tests.h"
+
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/utilities.h>
+#include <deal.II/base/conditional_ostream.h>
+#include <deal.II/base/index_set.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_refinement.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_values.h>
+
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/constraint_matrix.h>
+
+#include <deal.II/lac/petsc_parallel_vector.h>
+#include <deal.II/lac/petsc_parallel_sparse_matrix.h>
+
+#include <deal.II/distributed/tria.h>
+#include <deal.II/distributed/grid_refinement.h>
+
+using namespace dealii;
+
+template<int dim>
+void test (const unsigned int poly_degree = 1)
+{
+
+  MPI_Comm mpi_communicator (MPI_COMM_WORLD);
+  const unsigned int n_mpi_processes (Utilities::MPI::n_mpi_processes(mpi_communicator));
+  const unsigned int this_mpi_process (Utilities::MPI::this_mpi_process(mpi_communicator));
+
+  parallel::distributed::Triangulation<dim> tria(mpi_communicator,
+                                                 typename Triangulation<dim>::MeshSmoothing
+                                                 (Triangulation<dim>::smoothing_on_refinement |
+                                                  Triangulation<dim>::smoothing_on_coarsening));
+
+  GridGenerator::hyper_cube (tria, -1,0);
+  tria.refine_global (3);
+
+  FE_Q<dim> fe(poly_degree);
+
+  DoFHandler<dim> dof_handler(tria);
+  dof_handler.distribute_dofs(fe);
+
+  IndexSet locally_owned_dofs = dof_handler.locally_owned_dofs ();
+  IndexSet locally_relevant_dofs;
+  DoFTools::extract_locally_relevant_dofs (dof_handler,locally_relevant_dofs);
+
+  PETScWrappers::MPI::Vector vector;
+  PETScWrappers::MPI::SparseMatrix mass_matrix;
+
+
+  vector.reinit(locally_owned_dofs, mpi_communicator);
+  const types::global_dof_index n_local_dofs = locally_owned_dofs.n_elements();
+  mass_matrix.reinit  (mpi_communicator,
+                       dof_handler.n_dofs(),
+                       dof_handler.n_dofs(),
+                       n_local_dofs,
+                       n_local_dofs,
+                       dof_handler.max_couplings_between_dofs());
+
+  ConstraintMatrix constraints;
+  constraints.reinit(locally_relevant_dofs);
+  DoFTools::make_hanging_node_constraints  (dof_handler, constraints);
+  constraints.close ();
+
+  //assemble mass matrix:
+  mass_matrix = 0.0;
+  {
+    QGauss<dim> quadrature_formula(poly_degree+1);
+    FEValues<dim> fe_values (fe, quadrature_formula,
+                             update_values | update_gradients | update_JxW_values);
+
+    const unsigned int dofs_per_cell = fe.dofs_per_cell;
+    const unsigned int n_q_points    = quadrature_formula.size();
+
+    FullMatrix<PetscScalar> cell_mass_matrix (dofs_per_cell, dofs_per_cell);
+
+    std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
+
+    typename DoFHandler<dim>::active_cell_iterator
+    cell = dof_handler.begin_active (),
+    endc = dof_handler.end ();
+    for (; cell!=endc; ++cell)
+      if (cell->is_locally_owned())
+        {
+          fe_values.reinit (cell);
+          cell_mass_matrix    = PetscScalar(0);
+
+          for (unsigned int q_point=0; q_point<n_q_points; ++q_point)
+            for (unsigned int i=0; i<dofs_per_cell; ++i)
+              for (unsigned int j=0; j<dofs_per_cell; ++j)
+                {
+                  cell_mass_matrix (i, j)
+                  += (fe_values.shape_value (i, q_point) *
+                      fe_values.shape_value (j, q_point)
+                     ) * fe_values.JxW (q_point);
+                }
+
+          cell->get_dof_indices (local_dof_indices);
+
+          constraints
+          .distribute_local_to_global (cell_mass_matrix,
+                                       local_dof_indices,
+                                       mass_matrix);
+        }
+    mass_matrix.compress (VectorOperation::add);
+  }
+
+  for (unsigned int i = 0; i < locally_owned_dofs.n_elements(); i++)
+    {
+      double re = 0,
+             im = 0;
+      if ( i % 2 )
+        {
+          re = 1.0*i;
+          im = 1.0*(this_mpi_process+1);
+        }
+      else if (i % 3)
+        {
+          re = 0.0;
+          im = -1.0*(this_mpi_process+1);
+        }
+      else
+        {
+          re = 3.0*i;
+          im = 0.0;
+        }
+      const PetscScalar val = re+im*PETSC_i;
+      vector   ( locally_owned_dofs.nth_index_in_set(i)) = val;
+    }
+  vector.compress(VectorOperation::insert);
+  constraints.distribute(vector);
+
+  deallog<<"symmetric: "<<mass_matrix.is_symmetric()<<std::endl;
+  deallog<<"hermitian: "<<mass_matrix.is_hermitian()<<std::endl;
+
+  PETScWrappers::MPI::Vector tmp(vector);
+  mass_matrix.vmult (tmp, vector);
+
+  const std::complex<double> norm1 = vector*tmp;
+  deallog<<"(conj(vector),M vector): "<<std::endl;
+  deallog<<"real part:      "<<PetscRealPart(norm1)<<std::endl;
+  deallog<<"imaginary part: "<<PetscImaginaryPart(norm1)<<std::endl;
+
+  const std::complex<double> norm2 =
+    mass_matrix.matrix_scalar_product(vector, vector);
+  deallog<<"matrix_scalar_product(vec,vec): "<<std::endl;
+  deallog<<"real part:      "<<PetscRealPart(norm2)<<std::endl;
+  deallog<<"imaginary part: "<<PetscImaginaryPart(norm2)<<std::endl;
+
+  const std::complex<double> norm3 =
+    mass_matrix.matrix_norm_square(vector);
+  deallog<<"matrix_norm_square(vec): "<<std::endl;
+  deallog<<"real part:      "<<PetscRealPart(norm3)<<std::endl;
+  deallog<<"imaginary part: "<<PetscImaginaryPart(norm3)<<std::endl;
+}
+
+
+int main (int argc, char *argv[])
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv);
+
+  test<2>();
+
+}
\ No newline at end of file
diff --git a/tests/petsc_complex/parallel_sparse_matrix_01.mpirun=3.output b/tests/petsc_complex/parallel_sparse_matrix_01.mpirun=3.output
new file mode 100644 (file)
index 0000000..a75f75b
--- /dev/null
@@ -0,0 +1,12 @@
+
+DEAL::symmetric: 1
+DEAL::hermitian: 1
+DEAL::(conj(vector),M vector): 
+DEAL::real part:      337.563
+DEAL::imaginary part: 0
+DEAL::matrix_scalar_product(vec,vec): 
+DEAL::real part:      337.563
+DEAL::imaginary part: 0
+DEAL::matrix_norm_square(vec): 
+DEAL::real part:      337.563
+DEAL::imaginary part: 0
diff --git a/tests/petsc_complex/solver_real_01.cc b/tests/petsc_complex/solver_real_01.cc
new file mode 100644 (file)
index 0000000..9c045ca
--- /dev/null
@@ -0,0 +1,97 @@
+// ---------------------------------------------------------------------
+// $Id: solver_real_01.cc $
+//
+// Copyright (C) 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 the PETSc Richardson solver
+
+// Note: This is (almost) a clone of the tests/petsc/solver_01.cc
+
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_solver.h>
+#include <deal.II/lac/petsc_precondition.h>
+#include <deal.II/lac/vector_memory.h>
+#include <typeinfo>
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+void
+check_solve( SOLVER &solver, const MATRIX &A,
+             VECTOR &u, VECTOR &f, const PRECONDITION &P)
+{
+  deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+  u = 0.;
+  f = 1.;
+  try
+    {
+      solver.solve(A,u,f,P);
+    }
+  catch (std::exception &e)
+    {
+      deallog << e.what() << std::endl;
+      // it needs to be expected for the
+      // richardson solver that we end up
+      // here, so don't abort
+    }
+
+  deallog << "Solver stopped after " << solver.control().last_step()
+          << " iterations" << std::endl;
+}
+
+
+int main(int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  {
+    SolverControl control(100, 1.e-3);
+
+    const unsigned int size = 32;
+    unsigned int dim = (size-1)*(size-1);
+
+    deallog << "Size " << size << " Unknowns " << dim << std::endl;
+
+    // Make matrix
+    FDMatrix testproblem(size, size);
+    PETScWrappers::SparseMatrix  A(dim, dim, 5);
+    testproblem.five_point(A);
+
+    PETScWrappers::Vector  f(dim);
+    PETScWrappers::Vector  u(dim);
+    f = 1.;
+    A.compress (VectorOperation::add);
+    f.compress (VectorOperation::add);
+    u.compress (VectorOperation::add);
+
+    PETScWrappers::SolverRichardson solver(control);
+    PETScWrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+}
+
diff --git a/tests/petsc_complex/solver_real_01.output b/tests/petsc_complex/solver_real_01.output
new file mode 100644 (file)
index 0000000..94aba8f
--- /dev/null
@@ -0,0 +1,18 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers16SolverRichardsonE
+DEAL::Starting value 7.750
+DEAL::Failure step 100 value 4.004
+DEAL::
+--------------------------------------------------------
+An error occurred in file <petsc_solver.cc> in function
+    void dealii::PETScWrappers::SolverBase::solve(const dealii::PETScWrappers::MatrixBase&, dealii::PETScWrappers::VectorBase&, const dealii::PETScWrappers::VectorBase&, const dealii::PETScWrappers::PreconditionerBase&)
+The violated condition was: 
+    false
+The name and call sequence of the exception was:
+    SolverControl::NoConvergence (solver_control.last_step(), solver_control.last_value())
+Additional Information: 
+Iterative method reported convergence failure in step 100 with residual 4.00437
+--------------------------------------------------------
+
+DEAL::Solver stopped after 100 iterations
diff --git a/tests/petsc_complex/solver_real_02.cc b/tests/petsc_complex/solver_real_02.cc
new file mode 100644 (file)
index 0000000..28f4e04
--- /dev/null
@@ -0,0 +1,96 @@
+// ---------------------------------------------------------------------
+// $Id: solver_real_02.cc $
+//
+// Copyright (C) 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 the PETSc Chebychev solver
+
+// Note: This is (almost) a clone of the tests/petsc/solver_02.cc
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_solver.h>
+#include <deal.II/lac/petsc_precondition.h>
+#include <deal.II/lac/vector_memory.h>
+#include <typeinfo>
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+void
+check_solve( SOLVER &solver, const MATRIX &A,
+             VECTOR &u, VECTOR &f, const PRECONDITION &P)
+{
+  deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+  u = 0.;
+  f = 1.;
+  try
+    {
+      solver.solve(A,u,f,P);
+    }
+  catch (std::exception &e)
+    {
+      deallog << e.what() << std::endl;
+      // just like for Richardson: we end up
+      // here normally for this solver
+    }
+
+  deallog << "Solver stopped after " << solver.control().last_step()
+          << " iterations" << std::endl;
+}
+
+
+int main(int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  {
+    SolverControl control(100, 1.e-3);
+
+    const unsigned int size = 32;
+    unsigned int dim = (size-1)*(size-1);
+
+    deallog << "Size " << size << " Unknowns " << dim << std::endl;
+
+    // Make matrix
+    FDMatrix testproblem(size, size);
+    PETScWrappers::SparseMatrix  A(dim, dim, 5);
+    testproblem.five_point(A);
+
+    PETScWrappers::Vector  f(dim);
+    PETScWrappers::Vector  u(dim);
+    f = 1.;
+    A.compress (VectorOperation::add);
+    f.compress (VectorOperation::add);
+    u.compress (VectorOperation::add);
+
+    PETScWrappers::SolverChebychev solver(control);
+    PETScWrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+
+}
+
diff --git a/tests/petsc_complex/solver_real_02.output b/tests/petsc_complex/solver_real_02.output
new file mode 100644 (file)
index 0000000..de02386
--- /dev/null
@@ -0,0 +1,18 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers15SolverChebychevE
+DEAL::Starting value 7.551
+DEAL::Failure step 100 value 2.942
+DEAL::
+--------------------------------------------------------
+An error occurred in file <petsc_solver.cc> in function
+    void dealii::PETScWrappers::SolverBase::solve(const dealii::PETScWrappers::MatrixBase&, dealii::PETScWrappers::VectorBase&, const dealii::PETScWrappers::VectorBase&, const dealii::PETScWrappers::PreconditionerBase&)
+The violated condition was: 
+    false
+The name and call sequence of the exception was:
+    SolverControl::NoConvergence (solver_control.last_step(), solver_control.last_value())
+Additional Information: 
+Iterative method reported convergence failure in step 100 with residual 2.94179
+--------------------------------------------------------
+
+DEAL::Solver stopped after 100 iterations
diff --git a/tests/petsc_complex/solver_real_03.cc b/tests/petsc_complex/solver_real_03.cc
new file mode 100644 (file)
index 0000000..0b69601
--- /dev/null
@@ -0,0 +1,95 @@
+// ---------------------------------------------------------------------
+// $Id: solver_real_03.cc $
+//
+// Copyright (C) 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 the PETSc CG solver
+
+// Note: This is (almost) a clone of the tests/petsc/solver_03.cc
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_solver.h>
+#include <deal.II/lac/petsc_precondition.h>
+#include <deal.II/lac/vector_memory.h>
+#include <typeinfo>
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+void
+check_solve( SOLVER &solver, const MATRIX &A,
+             VECTOR &u, VECTOR &f, const PRECONDITION &P)
+{
+  deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+  u = 0.;
+  f = 1.;
+  try
+    {
+      solver.solve(A,u,f,P);
+    }
+  catch (std::exception &e)
+    {
+      deallog << e.what() << std::endl;
+      abort ();
+    }
+
+  deallog << "Solver stopped after " << solver.control().last_step()
+          << " iterations" << std::endl;
+}
+
+
+int main(int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  {
+    SolverControl control(100, 1.e-3);
+
+    const unsigned int size = 32;
+    unsigned int dim = (size-1)*(size-1);
+
+    deallog << "Size " << size << " Unknowns " << dim << std::endl;
+
+    // Make matrix
+    FDMatrix testproblem(size, size);
+    PETScWrappers::SparseMatrix  A(dim, dim, 5);
+    testproblem.five_point(A);
+
+    PETScWrappers::Vector  f(dim);
+    PETScWrappers::Vector  u(dim);
+    f = 1.;
+    A.compress (VectorOperation::add);
+    f.compress (VectorOperation::add);
+    u.compress (VectorOperation::add);
+
+    PETScWrappers::SolverCG solver(control);
+    PETScWrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+
+}
+
diff --git a/tests/petsc_complex/solver_real_03.output b/tests/petsc_complex/solver_real_03.output
new file mode 100644 (file)
index 0000000..2237281
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers8SolverCGE
+DEAL::Starting value 7.750
+DEAL::Convergence step 41 value 0.0006730
+DEAL::Solver stopped after 41 iterations
diff --git a/tests/petsc_complex/solver_real_03_mf.cc b/tests/petsc_complex/solver_real_03_mf.cc
new file mode 100644 (file)
index 0000000..b3197e7
--- /dev/null
@@ -0,0 +1,105 @@
+// ---------------------------------------------------------------------
+// $Id: solver_03_mf.cc $
+//
+// Copyright (C) 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 the PETSc CG solver with PETSc MatrixFree class
+
+// Note: This is (almost) a clone of the tests/petsc/solver_03_mf.cc
+
+#include "../tests.h"
+#include "../petsc/petsc_mf_testmatrix.h" // It is tempting to copy
+// ../petsc/petsc_mf_testmatrix.h
+// into this directory and
+// play with it, but, by
+// using *that* file
+// directly is instead
+// represents a test of
+// syntax compatibility
+// between petsc-scalar=real
+// and assigning real
+// numbers to a possibly
+// complex matrix where
+// petsc-scalar=complex.
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_solver.h>
+#include <deal.II/lac/petsc_precondition.h>
+#include <deal.II/lac/vector_memory.h>
+#include <typeinfo>
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+void
+check_solve( SOLVER &solver, const MATRIX &A,
+             VECTOR &u, VECTOR &f, const PRECONDITION &P)
+{
+  deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+  u = 0.;
+  f = 1.;
+  try
+    {
+      solver.solve(A,u,f,P);
+    }
+  catch (std::exception &e)
+    {
+      std::cout << e.what() << std::endl;
+      deallog << e.what() << std::endl;
+      abort ();
+    }
+
+  deallog << "Solver stopped after " << solver.control().last_step()
+          << " iterations" << std::endl;
+}
+
+
+int main(int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  {
+    SolverControl control(100, 1.e-3);
+
+    const unsigned int size = 32;
+    unsigned int dim = (size-1)*(size-1);
+
+    deallog << "Size " << size << " Unknowns " << dim << std::endl;
+
+    PetscFDMatrix  A(size, dim);
+
+    PETScWrappers::Vector  f(dim);
+    PETScWrappers::Vector  u(dim);
+    f = 1.;
+    A.compress (VectorOperation::add);
+    f.compress (VectorOperation::add);
+    u.compress (VectorOperation::add);
+
+    PETScWrappers::SolverCG solver(control);
+    PETScWrappers::PreconditionNone preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+
+}
+
diff --git a/tests/petsc_complex/solver_real_03_mf.output b/tests/petsc_complex/solver_real_03_mf.output
new file mode 100644 (file)
index 0000000..bea3eb1
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers8SolverCGE
+DEAL::Starting value 31.00
+DEAL::Convergence step 43 value 0.0008189
+DEAL::Solver stopped after 43 iterations
diff --git a/tests/petsc_complex/solver_real_04.cc b/tests/petsc_complex/solver_real_04.cc
new file mode 100644 (file)
index 0000000..9ace490
--- /dev/null
@@ -0,0 +1,95 @@
+// ---------------------------------------------------------------------
+// $Id: solver_real_04.cc $
+//
+// Copyright (C) 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 the PETSc BiCG solver
+
+// Note: This is (almost) a clone of the tests/petsc/solver_03.cc
+
+#include "../tests.h"
+#include "../lac/testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_solver.h>
+#include <deal.II/lac/petsc_precondition.h>
+#include <deal.II/lac/vector_memory.h>
+#include <typeinfo>
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+void
+check_solve( SOLVER &solver, const MATRIX &A,
+             VECTOR &u, VECTOR &f, const PRECONDITION &P)
+{
+  deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+  u = 0.;
+  f = 1.;
+  try
+    {
+      solver.solve(A,u,f,P);
+    }
+  catch (std::exception &e)
+    {
+      deallog << e.what() << std::endl;
+      abort ();
+    }
+
+  deallog << "Solver stopped after " << solver.control().last_step()
+          << " iterations" << std::endl;
+}
+
+
+int main(int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog << std::setprecision(4);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  {
+    SolverControl control(100, 1.e-3);
+
+    const unsigned int size = 32;
+    unsigned int dim = (size-1)*(size-1);
+
+    deallog << "Size " << size << " Unknowns " << dim << std::endl;
+
+    // Make matrix
+    FDMatrix testproblem(size, size);
+    PETScWrappers::SparseMatrix  A(dim, dim, 5);
+    testproblem.five_point(A);
+
+    PETScWrappers::Vector  f(dim);
+    PETScWrappers::Vector  u(dim);
+    f = 1.;
+    A.compress (VectorOperation::add);
+    f.compress (VectorOperation::add);
+    u.compress (VectorOperation::add);
+
+    PETScWrappers::SolverBiCG solver(control);
+    PETScWrappers::PreconditionJacobi preconditioner(A);
+    check_solve (solver, A,u,f, preconditioner);
+  }
+
+}
+
diff --git a/tests/petsc_complex/solver_real_04.output b/tests/petsc_complex/solver_real_04.output
new file mode 100644 (file)
index 0000000..d69ef94
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers10SolverBiCGE
+DEAL::Starting value 7.750
+DEAL::Convergence step 41 value 0.0006730
+DEAL::Solver stopped after 41 iterations
diff --git a/tests/petsc_complex/sparse_matrix_01.cc b/tests/petsc_complex/sparse_matrix_01.cc
new file mode 100644 (file)
index 0000000..7d7a749
--- /dev/null
@@ -0,0 +1,112 @@
+// ---------------------------------------------------------------------
+// $Id sparse_matrix_01.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+// check SparseMatrix::add(other, factor)
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test ()
+{
+  const unsigned int s = 10;
+  PETScWrappers::SparseMatrix m(s,s,s);
+  for (unsigned int k=0; k<m.m(); ++k)
+    for (unsigned int l=0; l<=k; ++l)
+      m.set (k,l, k+2*l);
+
+  m.compress (VectorOperation::add);
+
+  PETScWrappers::SparseMatrix m2(s,s,s);
+  m2.set(0,1,5.0);
+  for (unsigned int k=0; k<m2.m(); ++k)
+    m2.set(k,k,PetscScalar(1.0+k,-1.0-k));
+  m2.compress(VectorOperation::add);
+
+  // we now print the matrix m, it is all real. Then print after
+  // adding m2 which is complex, and then subtract m2 again to get the
+  // original matrix back.
+
+  deallog << "before: " << m(0,1) << std::endl;
+  for (unsigned int k=0; k<s; ++k)
+    deallog << m(k,k) << " ";
+  deallog << std::endl;
+
+  m.add(m2,1.0);
+
+  deallog << "after: " << m(0,1) << std::endl;
+  for (unsigned int k=0; k<s; ++k)
+    deallog << m(k,k) << " ";
+  deallog << std::endl;
+
+  m.add(m2,-1.0);
+
+  deallog << "back to original: " << m(0,1) << std::endl;
+  for (unsigned int k=0; k<s; ++k)
+    deallog << m(k,k) << " ";
+  deallog << std::endl;
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        test ();
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+
+}
diff --git a/tests/petsc_complex/sparse_matrix_01.output b/tests/petsc_complex/sparse_matrix_01.output
new file mode 100644 (file)
index 0000000..0fac50f
--- /dev/null
@@ -0,0 +1,8 @@
+
+DEAL::before: (0.00000,0.00000)
+DEAL::(0.00000,0.00000) (3.00000,0.00000) (6.00000,0.00000) (9.00000,0.00000) (12.0000,0.00000) (15.0000,0.00000) (18.0000,0.00000) (21.0000,0.00000) (24.0000,0.00000) (27.0000,0.00000) 
+DEAL::after: (5.00000,0.00000)
+DEAL::(1.00000,-1.00000) (5.00000,-2.00000) (9.00000,-3.00000) (13.0000,-4.00000) (17.0000,-5.00000) (21.0000,-6.00000) (25.0000,-7.00000) (29.0000,-8.00000) (33.0000,-9.00000) (37.0000,-10.0000) 
+DEAL::back to original: (0.00000,0.00000)
+DEAL::(0.00000,0.00000) (3.00000,0.00000) (6.00000,0.00000) (9.00000,0.00000) (12.0000,0.00000) (15.0000,0.00000) (18.0000,0.00000) (21.0000,0.00000) (24.0000,0.00000) (27.0000,0.00000) 
+DEAL::OK
diff --git a/tests/petsc_complex/vector_02.cc b/tests/petsc_complex/vector_02.cc
new file mode 100644 (file)
index 0000000..33586ea
--- /dev/null
@@ -0,0 +1,114 @@
+// ---------------------------------------------------------------------
+// $Id vector_02.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check assignment of elements in Vector
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test ()
+{
+  const unsigned int s = 10;
+  PETScWrappers::Vector v(s);
+  for (unsigned int k=0; k<v.size(); ++k)
+    v(k) = k;
+
+  v.compress (VectorOperation::add);
+
+  PETScWrappers::Vector v2(s);
+  for (unsigned int k=0; k<v2.size(); ++k)
+    {
+      // This fails
+      // v2(k) = PetscScalar (k,-k);
+      // This is ok
+      v2(k) = PetscScalar (k,-1.0*k);
+    }
+
+  v2.compress(VectorOperation::add);
+
+  // we now print the vector v, it is all real. Then print after
+  // adding v2 which is complex, and then subtract v2 again to get the
+  // original vector back.
+
+  deallog << "before: " << std::endl;
+  for (unsigned int k=0; k<s; ++k)
+    deallog << "(" << v(k).real () << "," << v(k).imag () << "i) ";
+  deallog << std::endl;
+
+  v.add(1.0,v2);
+
+  deallog << "after: " << std::endl;
+  for (unsigned int k=0; k<s; ++k)
+    deallog << "(" << v(k).real () << "," << v(k).imag () << "i) ";
+  deallog << std::endl;
+
+  v.add(-1.0,v2);
+
+  deallog << "back to original: " << std::endl;
+  for (unsigned int k=0; k<s; ++k)
+    deallog << "(" << v(k).real () << "," << v(k).imag () << "i) ";
+  deallog << std::endl;
+
+  deallog << "OK" << std::endl;
+}
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        test ();
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/vector_02.output b/tests/petsc_complex/vector_02.output
new file mode 100644 (file)
index 0000000..d20636e
--- /dev/null
@@ -0,0 +1,8 @@
+
+DEAL::before: 
+DEAL::(0,0i) (1.00000,0i) (2.00000,0i) (3.00000,0i) (4.00000,0i) (5.00000,0i) (6.00000,0i) (7.00000,0i) (8.00000,0i) (9.00000,0i) 
+DEAL::after: 
+DEAL::(0,0i) (2.00000,-1.00000i) (4.00000,-2.00000i) (6.00000,-3.00000i) (8.00000,-4.00000i) (10.0000,-5.00000i) (12.0000,-6.00000i) (14.0000,-7.00000i) (16.0000,-8.00000i) (18.0000,-9.00000i) 
+DEAL::back to original: 
+DEAL::(0,0i) (1.00000,0i) (2.00000,0i) (3.00000,0i) (4.00000,0i) (5.00000,0i) (6.00000,0i) (7.00000,0i) (8.00000,0i) (9.00000,0i) 
+DEAL::OK
diff --git a/tests/petsc_complex/vector_assign_01.cc b/tests/petsc_complex/vector_assign_01.cc
new file mode 100644 (file)
index 0000000..d8f8536
--- /dev/null
@@ -0,0 +1,86 @@
+// ---------------------------------------------------------------------
+// $Id: vector_assign_01.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// See notes in petsc/vector_assign_01.cc
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (PETScWrappers::Vector &v,
+           PETScWrappers::Vector &w)
+{
+  // set the first vector
+  for (unsigned int k=0; k<v.size(); ++k)
+    v(k) = std::complex<double> (k,k*k);
+
+  // copy elements by reference
+  for (unsigned int k=0; k<v.size(); ++k)
+    w(k) = v(k);
+
+  // check that they're equal
+  Assert (v==w, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v (100);
+        PETScWrappers::Vector w (100);
+        test (v,w);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/vector_assign_01.output b/tests/petsc_complex/vector_assign_01.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/petsc_complex/vector_assign_02.cc b/tests/petsc_complex/vector_assign_02.cc
new file mode 100644 (file)
index 0000000..64c2033
--- /dev/null
@@ -0,0 +1,96 @@
+// ---------------------------------------------------------------------
+// $Id: vector_assign_02.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// this is equivalent to the petsc_vector_assign_01 test, except that we use
+// operator+= instead of operator=. This is also not exciting...
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (PETScWrappers::Vector &v,
+           PETScWrappers::Vector &w)
+{
+  // set the first vector
+  for (unsigned int k=0; k<v.size(); ++k)
+    v(k) = PetscScalar (k,k*k);
+
+  // add elements by reference
+  for (unsigned int k=0; k<v.size(); ++k)
+    w(k) += v(k);
+
+  // check that they're equal
+  Assert (v==w, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile ("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v (20);
+        PETScWrappers::Vector w (20);
+        test (v,w);
+
+        // Some output
+        deallog << "Complex vectors: " << std::endl;
+        deallog << "v: " << std::flush;
+        v.print (logfile, 0, false, true);
+        deallog << "w: " << std::flush;
+        w.print (logfile, 0, false, true);
+        deallog << "OK" << std::endl;
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/vector_assign_02.output b/tests/petsc_complex/vector_assign_02.output
new file mode 100644 (file)
index 0000000..f432760
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::OK
+DEAL::Complex vectors: 
+DEAL::v: (0.,0.) (1.,1.) (2.,4.) (3.,9.) (4.,16.) (5.,25.) (6.,36.) (7.,49.) (8.,64.) (9.,81.) (10.,100.) (11.,121.) (12.,144.) (13.,169.) (14.,196.) (15.,225.) (16.,256.) (17.,289.) (18.,324.) (19.,361.) 
+w: (0.,0.) (1.,1.) (2.,4.) (3.,9.) (4.,16.) (5.,25.) (6.,36.) (7.,49.) (8.,64.) (9.,81.) (10.,100.) (11.,121.) (12.,144.) (13.,169.) (14.,196.) (15.,225.) (16.,256.) (17.,289.) (18.,324.) (19.,361.) 
+OK
diff --git a/tests/petsc_complex/vector_equality_1.cc b/tests/petsc_complex/vector_equality_1.cc
new file mode 100644 (file)
index 0000000..d9d14e9
--- /dev/null
@@ -0,0 +1,94 @@
+// ---------------------------------------------------------------------
+// $Id: vector_equality_1.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check PETScWrappers::Vector::operator==(PETScWrappers::Vector) for vectors that are not
+// equal
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (PETScWrappers::Vector &v,
+           PETScWrappers::Vector &w)
+{
+  // set only certain elements of each vector
+  for (unsigned int k=0; k<v.size(); ++k)
+    {
+      v(k) = std::complex<double> (k,k);
+      if (k%3 == 0)
+        w(k) = std::complex<double> (k+1.,k+1.);
+    }
+
+  Assert (!(v==w), ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v (20);
+        PETScWrappers::Vector w (20);
+        test (v,w);
+
+        // SOme output
+        deallog << "Complex vectors: " << std::endl;
+        v.print (logfile, 0, false, true);
+        w.print (logfile, 0, false, true);
+        deallog << "OK" << std::endl;
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/vector_equality_1.output b/tests/petsc_complex/vector_equality_1.output
new file mode 100644 (file)
index 0000000..450c4b4
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::OK
+DEAL::Complex vectors: 
+(0.,0.) (1.,1.) (2.,2.) (3.,3.) (4.,4.) (5.,5.) (6.,6.) (7.,7.) (8.,8.) (9.,9.) (10.,10.) (11.,11.) (12.,12.) (13.,13.) (14.,14.) (15.,15.) (16.,16.) (17.,17.) (18.,18.) (19.,19.) 
+(1.,1.) (0.,0.) (0.,0.) (4.,4.) (0.,0.) (0.,0.) (7.,7.) (0.,0.) (0.,0.) (10.,10.) (0.,0.) (0.,0.) (13.,13.) (0.,0.) (0.,0.) (16.,16.) (0.,0.) (0.,0.) (19.,19.) (0.,0.) 
+DEAL::OK
diff --git a/tests/petsc_complex/vector_equality_2.cc b/tests/petsc_complex/vector_equality_2.cc
new file mode 100644 (file)
index 0000000..53aa85c
--- /dev/null
@@ -0,0 +1,96 @@
+// ---------------------------------------------------------------------
+// $Id: vector_equality_2.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check PETScWrappers::Vector::operator==(PETScWrappers::Vector) for vectors that are
+// equal
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (PETScWrappers::Vector &v,
+           PETScWrappers::Vector &w)
+{
+  // set only certain elements of each vector
+  for (unsigned int k=0; k<v.size(); ++k)
+    {
+      v(k) = PetscScalar (k,k);
+      if (k%3 == 0)
+        w(k) = std::complex<double> (k+1.,k+1);
+    }
+
+  // then copy elements and make sure the vectors are actually equal
+  v = w;
+  Assert (v==w, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v (20);
+        PETScWrappers::Vector w (20);
+        test (v,w);
+
+        // Output
+        deallog << "Complex vectors: " << std::endl;
+        v.print (logfile, 0, false, true);
+        w.print (logfile, 0, false, true);
+        deallog << "OK" << std::endl;
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/vector_equality_2.output b/tests/petsc_complex/vector_equality_2.output
new file mode 100644 (file)
index 0000000..b49f220
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::OK
+DEAL::Complex vectors: 
+(1.,1.) (0.,0.) (0.,0.) (4.,4.) (0.,0.) (0.,0.) (7.,7.) (0.,0.) (0.,0.) (10.,10.) (0.,0.) (0.,0.) (13.,13.) (0.,0.) (0.,0.) (16.,16.) (0.,0.) (0.,0.) (19.,19.) (0.,0.) 
+(1.,1.) (0.,0.) (0.,0.) (4.,4.) (0.,0.) (0.,0.) (7.,7.) (0.,0.) (0.,0.) (10.,10.) (0.,0.) (0.,0.) (13.,13.) (0.,0.) (0.,0.) (16.,16.) (0.,0.) (0.,0.) (19.,19.) (0.,0.) 
+DEAL::OK
diff --git a/tests/petsc_complex/vector_print.cc b/tests/petsc_complex/vector_print.cc
new file mode 100644 (file)
index 0000000..7d7b64c
--- /dev/null
@@ -0,0 +1,77 @@
+// ---------------------------------------------------------------------
+// $Id: vector_print.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// verify that VectorBase::print uses the precision parameter correctly and
+// restores the previous value of the stream precision
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      {
+        PETScWrappers::Vector v (5);
+        for (unsigned int k=0; k<v.size(); ++k)
+          v(k) = PetscScalar (k*1.2345678901234567,2.*k*1.2345678901234567);
+
+        // print with prescribed precision
+        deallog << "unreadable=true,across=false" << std::endl;
+        v.print (logfile, 10, true, false);
+
+        deallog << "unreadable=false,across=true" << std::endl;
+        v.print (logfile, 3, false, true);
+      }
+
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/vector_print.output b/tests/petsc_complex/vector_print.output
new file mode 100644 (file)
index 0000000..a2b6107
--- /dev/null
@@ -0,0 +1,10 @@
+
+DEAL::unreadable=true,across=false
+(0.0000000000e+00,0.0000000000e+00)
+(1.2345678901e+00,2.4691357802e+00)
+(2.4691357802e+00,4.9382715605e+00)
+(3.7037036704e+00,7.4074073407e+00)
+(4.9382715605e+00,9.8765431210e+00)
+
+DEAL::unreadable=false,across=true
+(0.000,0.000) (1.235,2.469) (2.469,4.938) (3.704,7.407) (4.938,9.877) 
diff --git a/tests/petsc_complex/vector_wrap_01.cc b/tests/petsc_complex/vector_wrap_01.cc
new file mode 100644 (file)
index 0000000..2f520c6
--- /dev/null
@@ -0,0 +1,102 @@
+// ---------------------------------------------------------------------
+// $Id: vector_wrap_01.cc $
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// See comments in tests/petsc/vector_wrap_01.cc
+
+#include "../tests.h"
+#include <deal.II/lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (PETScWrappers::Vector &v,
+           PETScWrappers::Vector &w)
+{
+  // set the first vector
+  for (unsigned int k=0; k<v.size(); ++k)
+    v(k) = std::complex<double> (k,0.5*k);
+
+  // copy elements by reference
+  for (unsigned int k=0; k<v.size(); ++k)
+    w(k) = v(k);
+
+  // check that they're equal
+  Assert (v==w, ExcInternalError());
+
+  v=w;
+
+  // check that they're still equal
+  Assert (v==w, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  try
+    {
+      Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      Vec vpetsc;
+      int ierr = VecCreateSeq (PETSC_COMM_SELF, 100, &vpetsc);
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+      {
+        PETScWrappers::Vector v (vpetsc);
+        PETScWrappers::Vector w (100);
+        test (v,w);
+      }
+
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+      ierr = VecDestroy (vpetsc);
+#else
+      ierr = VecDestroy (&vpetsc);
+#endif
+
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/petsc_complex/vector_wrap_01.output b/tests/petsc_complex/vector_wrap_01.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/slepc_complex/00.cc b/tests/slepc_complex/00.cc
new file mode 100644 (file)
index 0000000..be75da6
--- /dev/null
@@ -0,0 +1,100 @@
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// just check initialising SLEPc can be done and that it initialises
+// PETSc in the way we expect, ie. *a* PETSc object exist. This is an
+// approximate copy of slepc/00.cc..
+
+#include "../tests.h"
+#include <deal.II/lac/slepc_solver.h>
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/numbers.h>
+#include <fstream>
+#include <iostream>
+
+
+std::ofstream logfile ("output");
+
+int main (int argc, char **argv)
+{
+  deallog.attach (logfile);
+  deallog.depth_console (1);
+
+  try
+    {
+      logfile << "Initializing SLEPc (PETSc): "
+              << std::flush;
+
+      SlepcInitialize (&argc, &argv, 0, 0);
+      {
+        logfile << "ok"
+                << std::endl;
+
+        // Do something simple with PETSc
+        logfile << "Using PetscScalar:"
+                << std::endl;
+
+        const PetscScalar pi_1i  = numbers::PI + 1.*PETSC_i;
+        const PetscScalar two    = 2.;
+
+        logfile << "   pi+1i:           " << pi_1i
+                << std::endl
+                << "   two:             " << two
+                << std::endl
+                << "   two times pi+1i: " << two *pi_1i
+                << std::endl;
+
+
+        logfile << "Finalizing SLEPc (PETSc): "
+                << std::flush;
+
+      }
+      SlepcFinalize ();
+
+      logfile << "ok"
+              << std::endl << std::endl;
+    }
+
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+                << exc.what() << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+
+      return 1;
+    }
+
+  catch (...)
+    {
+      std::cerr << std::endl << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+                << "Aborting!" << std::endl
+                << "----------------------------------------------------"
+                << std::endl;
+      return 1;
+    };
+}
+
+
diff --git a/tests/slepc_complex/00.output b/tests/slepc_complex/00.output
new file mode 100644 (file)
index 0000000..10a07da
--- /dev/null
@@ -0,0 +1,8 @@
+
+Initializing SLEPc (PETSc): ok
+Using PetscScalar:
+   pi+1i:           (3.14159,1.00000)
+   two:             (2.00000,0.00000)
+   two times pi+1i: (6.28319,2.00000)
+Finalizing SLEPc (PETSc): ok
+
diff --git a/tests/slepc_complex/CMakeLists.txt b/tests/slepc_complex/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a16db90
--- /dev/null
@@ -0,0 +1,6 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)
+INCLUDE(../setup_testsubproject.cmake)
+PROJECT(testsuite CXX)
+IF(DEAL_II_WITH_PETSC AND DEAL_II_WITH_SLEPC AND PETSC_WITH_COMPLEX)
+  DEAL_II_PICKUP_TESTS()
+ENDIF()

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.