]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New tests.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 15 Feb 2004 01:58:34 +0000 (01:58 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 15 Feb 2004 01:58:34 +0000 (01:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@8469 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/bits/petsc_49.cc b/tests/bits/petsc_49.cc
new file mode 100644 (file)
index 0000000..8fea52f
--- /dev/null
@@ -0,0 +1,86 @@
+//----------------------------  petsc_49.cc  ---------------------------
+//    petsc_11.cc,v 1.4 2003/07/03 10:31:46 guido Exp
+//    Version: 
+//
+//    Copyright (C) 2004 by the deal.II authors and Anna Schneebeli
+//
+//    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_49.cc  ---------------------------
+
+
+// check petsc_wrapper::copy_from<PetscScalar>
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+  Vector<PetscScalar> w (v.size());
+
+  for (unsigned int i=0; i<w.size(); ++i)
+    w(i) = i;
+  
+  v.copy_from (w);
+
+  
+                                   // make sure we get the expected result
+  for (unsigned int i=0; i<v.size(); ++i)
+    {
+      Assert (w(i) == i, ExcInternalError());
+      Assert (v(i) == i, ExcInternalError());
+    }
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv) 
+{
+  std::ofstream logfile("petsc_49.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      PetscInitialize(&argc,&argv,0,0);
+      {
+        petsc_wrappers::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;
+    };
+}
diff --git a/tests/bits/petsc_50.cc b/tests/bits/petsc_50.cc
new file mode 100644 (file)
index 0000000..0ea597e
--- /dev/null
@@ -0,0 +1,102 @@
+//----------------------------  petsc_50.cc  ---------------------------
+//    petsc_11.cc,v 1.4 2003/07/03 10:31:46 guido Exp
+//    Version: 
+//
+//    Copyright (C) 2004 by the deal.II authors and Anna Schneebeli
+//
+//    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_50.cc  ---------------------------
+
+
+// check petsc_wrapper::copy_from<T> with T!=PetscScalar
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+  Vector<double> w (v.size());
+  Vector<float>  x (v.size());
+
+  for (unsigned int i=0; i<w.size(); ++i)
+    {
+      w(i) = i;
+      x(i) = i+1;
+    }
+  
+                                   // first copy from w and make sure we get
+                                   // the expected result. then copy from x
+                                   // and do the same. in at least one of the
+                                   // two cases, the template argument to
+                                   // Vector<T> must be different from
+                                   // PetscScalar
+  v.copy_from (w);
+  for (unsigned int i=0; i<v.size(); ++i)
+    {
+      Assert (w(i) == i, ExcInternalError());
+      Assert (v(i) == i, ExcInternalError());
+      Assert (x(i) == i+1, ExcInternalError());
+    }
+
+  v.copy_from (x);
+  for (unsigned int i=0; i<v.size(); ++i)
+    {
+      Assert (w(i) == i, ExcInternalError());
+      Assert (v(i) == i+1, ExcInternalError());
+      Assert (x(i) == i+1, ExcInternalError());
+    }
+  
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv) 
+{
+  std::ofstream logfile("petsc_50.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      PetscInitialize(&argc,&argv,0,0);
+      {
+        petsc_wrappers::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.