]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New tests.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 27 Feb 2004 19:46:52 +0000 (19:46 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 27 Feb 2004 19:46:52 +0000 (19:46 +0000)
git-svn-id: https://svn.dealii.org/trunk@8604 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/petsc_53.cc [new file with mode: 0644]
tests/bits/petsc_54.cc [new file with mode: 0644]
tests/bits/petsc_55.cc [new file with mode: 0644]
tests/bits/petsc_56.cc [new file with mode: 0644]

diff --git a/tests/bits/petsc_53.cc b/tests/bits/petsc_53.cc
new file mode 100644 (file)
index 0000000..ade4680
--- /dev/null
@@ -0,0 +1,92 @@
+//----------------------------  petsc_53.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_53.cc  ---------------------------
+
+
+// check PETScWrappers::Vector::operator() in set, and later in add-mode
+
+#include "../tests.h"
+#include <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) = i;
+      pattern[i] = true;
+    }
+  for (unsigned int i=0; i<v.size(); i+=1+i)
+    v(i) += i;
+
+  v.compress ();
+
+                                   // 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) == 2*i)
+             ||
+             (pattern[i] == false) && (v(i) == 0)),
+             ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv) 
+{
+  std::ofstream logfile("petsc_53.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;
+    };
+}
diff --git a/tests/bits/petsc_54.cc b/tests/bits/petsc_54.cc
new file mode 100644 (file)
index 0000000..c48458a
--- /dev/null
@@ -0,0 +1,92 @@
+//----------------------------  petsc_54.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_54.cc  ---------------------------
+
+
+// check PETScWrappers::Vector::operator() in set, and later in -= mode
+
+#include "../tests.h"
+#include <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) = 2*i;
+      pattern[i] = true;
+    }
+  for (unsigned int i=0; i<v.size(); i+=1+i)
+    v(i) -= i;
+
+  v.compress ();
+
+                                   // 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) == i)
+             ||
+             (pattern[i] == false) && (v(i) == 0)),
+             ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv) 
+{
+  std::ofstream logfile("petsc_54.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;
+    };
+}
diff --git a/tests/bits/petsc_55.cc b/tests/bits/petsc_55.cc
new file mode 100644 (file)
index 0000000..c27201b
--- /dev/null
@@ -0,0 +1,92 @@
+//----------------------------  petsc_55.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_55.cc  ---------------------------
+
+
+// check PETScWrappers::Vector::operator() in set, and later in *= mode
+
+#include "../tests.h"
+#include <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) = i;
+      pattern[i] = true;
+    }
+  for (unsigned int i=0; i<v.size(); i+=1+i)
+    v(i) *= 2;
+
+  v.compress ();
+
+                                   // 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) == 2*i)
+             ||
+             (pattern[i] == false) && (v(i) == 0)),
+             ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv) 
+{
+  std::ofstream logfile("petsc_55.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;
+    };
+}
diff --git a/tests/bits/petsc_56.cc b/tests/bits/petsc_56.cc
new file mode 100644 (file)
index 0000000..b465284
--- /dev/null
@@ -0,0 +1,92 @@
+//----------------------------  petsc_56.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_56.cc  ---------------------------
+
+
+// check PETScWrappers::Vector::operator() in set, and later in /= mode
+
+#include "../tests.h"
+#include <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) = 2*i;
+      pattern[i] = true;
+    }
+  for (unsigned int i=0; i<v.size(); i+=1+i)
+    v(i) /= 2;
+
+  v.compress ();
+
+                                   // 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) == i)
+             ||
+             (pattern[i] == false) && (v(i) == 0)),
+             ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv) 
+{
+  std::ofstream logfile("petsc_56.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.