]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add a missed funky vector test.
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 20 Oct 2013 13:49:49 +0000 (13:49 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 20 Oct 2013 13:49:49 +0000 (13:49 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@31332 0785d39b-7218-0410-832d-ea1e28bc413d

tests/petsc_scalar_complex/vector_wrap_01.cc [new file with mode: 0644]
tests/petsc_scalar_complex/vector_wrap_01/cmp/generic [new file with mode: 0644]

diff --git a/tests/petsc_scalar_complex/vector_wrap_01.cc b/tests/petsc_scalar_complex/vector_wrap_01.cc
new file mode 100644 (file)
index 0000000..409e8db
--- /dev/null
@@ -0,0 +1,119 @@
+// ---------------------------------------------------------------------
+// $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_01 (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;
+}
+
+
+void test_02 (PETScWrappers::Vector &v,
+             PETScWrappers::Vector &w)
+{
+  // copy
+  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("vector_wrap_01/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_01 (v,w);
+
+       w.reinit (100);
+        test_01 (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_scalar_complex/vector_wrap_01/cmp/generic b/tests/petsc_scalar_complex/vector_wrap_01/cmp/generic
new file mode 100644 (file)
index 0000000..8b3b075
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::OK
+DEAL::OK

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.