]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add test.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 26 Feb 2004 23:01:06 +0000 (23:01 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 26 Feb 2004 23:01:06 +0000 (23:01 +0000)
git-svn-id: https://svn.dealii.org/trunk@8584 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/petsc_51.cc [new file with mode: 0644]

diff --git a/tests/bits/petsc_51.cc b/tests/bits/petsc_51.cc
new file mode 100644 (file)
index 0000000..8cbf78d
--- /dev/null
@@ -0,0 +1,86 @@
+//----------------------------  petsc_51.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  petsc_51.cc  ---------------------------
+
+
+// check copy constructor petsc_wrapper::Vector::Vector(Vector) 
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>    
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (PETScWrappers::Vector &v)
+{
+                                   // set some entries of the vector
+  for (unsigned int i=0; i<v.size(); ++i)
+    if (i%3 == 0)
+      v(i) = i+1.;
+  v.compress ();
+
+                                   // then copy it
+  PETScWrappers::Vector w (v);
+  w.compress ();
+
+                                   // make sure they're equal
+  deallog << v*w << ' ' << v.l2_norm() * w.l2_norm()
+          << ' ' << v*w - v.l2_norm() * w.l2_norm() << std::endl;
+  Assert (std::fabs(v*w - v.l2_norm() * w.l2_norm()) < 1e-14*(v*w),
+          ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv) 
+{
+  std::ofstream logfile("petsc_51.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      PetscInitialize(&argc,&argv,0,0);
+      {
+        PETScWrappers::Vector v (100);
+        test (v);
+      }
+      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;
+    };
+}

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.