]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
added a failing operator*(Vector) test
authordenis.davydov <denis.davydov@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 21 May 2014 12:04:24 +0000 (12:04 +0000)
committerdenis.davydov <denis.davydov@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 21 May 2014 12:04:24 +0000 (12:04 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@32955 0785d39b-7218-0410-832d-ea1e28bc413d

tests/petsc_complex/20.cc [new file with mode: 0644]
tests/petsc_complex/20.output [new file with mode: 0644]

diff --git a/tests/petsc_complex/20.cc b/tests/petsc_complex/20.cc
new file mode 100644 (file)
index 0000000..f983727
--- /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 += 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..e69de29

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.