]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
More tests.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 6 Feb 2004 23:27:52 +0000 (23:27 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 6 Feb 2004 23:27:52 +0000 (23:27 +0000)
git-svn-id: https://svn.dealii.org/trunk@8421 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/Makefile
tests/bits/petsc_03a.cc [new file with mode: 0644]
tests/bits/petsc_03b.cc [new file with mode: 0644]
tests/bits/petsc_11.cc [new file with mode: 0644]
tests/bits/petsc_12.cc [new file with mode: 0644]
tests/bits/petsc_13.cc [new file with mode: 0644]
tests/bits/petsc_14.cc [new file with mode: 0644]
tests/bits/petsc_15.cc [new file with mode: 0644]
tests/bits/petsc_16.cc [new file with mode: 0644]

index ce068177320c735eda007d411e0af3849268a469..02faa5f18eec836331776bced6d8f4388313eb08 100644 (file)
@@ -153,6 +153,8 @@ sparse_matrix_10.exe    : sparse_matrix_10.g.$(OBJEXT)     $(libraries)
 petsc_01.exe            : petsc_01.g.$(OBJEXT)             $(libraries)
 petsc_02.exe            : petsc_02.g.$(OBJEXT)             $(libraries)
 petsc_03.exe            : petsc_03.g.$(OBJEXT)             $(libraries)
+petsc_03a.exe           : petsc_03a.g.$(OBJEXT)            $(libraries)
+petsc_03b.exe           : petsc_03b.g.$(OBJEXT)            $(libraries)
 petsc_04.exe            : petsc_04.g.$(OBJEXT)             $(libraries)
 petsc_05.exe            : petsc_05.g.$(OBJEXT)             $(libraries)
 petsc_06.exe            : petsc_06.g.$(OBJEXT)             $(libraries)
@@ -162,6 +164,12 @@ petsc_09.exe            : petsc_09.g.$(OBJEXT)             $(libraries)
 petsc_10.exe            : petsc_10.g.$(OBJEXT)             $(libraries)
 petsc_11.exe            : petsc_11.g.$(OBJEXT)             $(libraries)
 petsc_12.exe            : petsc_12.g.$(OBJEXT)             $(libraries)
+petsc_13.exe            : petsc_13.g.$(OBJEXT)             $(libraries)
+petsc_14.exe            : petsc_14.g.$(OBJEXT)             $(libraries)
+petsc_15.exe            : petsc_15.g.$(OBJEXT)             $(libraries)
+petsc_16.exe            : petsc_16.g.$(OBJEXT)             $(libraries)
+petsc_17.exe            : petsc_17.g.$(OBJEXT)             $(libraries)
+petsc_18.exe            : petsc_18.g.$(OBJEXT)             $(libraries)
 
 tests = anna_1 anna_2 anna_3 anna_4 anna_5 anna_6 \
        geometry_info_1 point_inside_1 point_inside_2 \
@@ -208,8 +216,10 @@ tests = anna_1 anna_2 anna_3 anna_4 anna_5 anna_6 \
         sparse_matrix_10
 
 ifeq ($(USE_CONTRIB_HSL),yes)
-  tests += petsc_01 petsc_02 petsc_03 petsc_04 petsc_05 petsc_06 \
-           petsc_07 petsc_08 petsc_09 petsc_10 petsc_11 petsc_12
+  tests += petsc_01 petsc_02 petsc_03 petsc_03a petsc_03b \
+           petsc_04 petsc_05 petsc_06 \
+           petsc_07 petsc_08 petsc_09 petsc_10 petsc_11 petsc_12 \
+           petsc_13 petsc_14 petsc_15 petsc_16 petsc_17 petsc_18
 endif
 
 ############################################################
diff --git a/tests/bits/petsc_03a.cc b/tests/bits/petsc_03a.cc
new file mode 100644 (file)
index 0000000..acc9649
--- /dev/null
@@ -0,0 +1,101 @@
+//----------------------------  petsc_03a.cc  ---------------------------
+//    petsc_03a.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_03a.cc  ---------------------------
+
+
+// check setting elements in a petsc matrix using set() and add()
+// intermixed. this poses PETSc some problems, since one has to flush some
+// buffer in between these two types of operations
+//
+// in contrast to petsc_03, we set and add the same elements here twice, to
+// get double the original value
+
+#include "../tests.h"
+#include <lac/petsc_sparse_matrix.h>    
+#include <fstream>
+#include <iostream>
+
+
+void test (petsc_wrappers::SparseMatrix &m)
+{
+                                   // first set a few entries
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        m.set (i,j, i*j*.5+.5);
+                                   // then add the same elements again
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        m.add (i,j, i*j*.5+.5);
+  
+  m.compress ();
+  
+                                   // then make sure we retrieve the same ones
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        {
+          Assert (m(i,j) == 2*(i*j*.5+.5), ExcInternalError());
+          Assert (m.el(i,j) == 2*(i*j*.5+.5), ExcInternalError());
+        }
+      else
+        {
+          Assert (m(i,j) == 0, ExcInternalError());
+          Assert (m.el(i,j) == 0, ExcInternalError());
+        }
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv) 
+{
+  std::ofstream logfile("petsc_03a.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      PetscInitialize(&argc,&argv,0,0);
+      {
+        petsc_wrappers::SparseMatrix m (5,5,3);
+        test (m);
+      }
+      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_03b.cc b/tests/bits/petsc_03b.cc
new file mode 100644 (file)
index 0000000..ed06273
--- /dev/null
@@ -0,0 +1,106 @@
+//----------------------------  petsc_03b.cc  ---------------------------
+//    petsc_03b.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_03b.cc  ---------------------------
+
+
+// check setting elements in a petsc matrix using set() and add()
+// intermixed. this poses PETSc some problems, since one has to flush some
+// buffer in between these two types of operations
+//
+// in contrast to petsc_03a, we set and add the same elements here twice, then
+// overwrite them again to get the original value back
+
+#include "../tests.h"
+#include <lac/petsc_sparse_matrix.h>    
+#include <fstream>
+#include <iostream>
+
+
+void test (petsc_wrappers::SparseMatrix &m)
+{
+                                   // first set a few entries
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        m.set (i,j, i*j*.5+.5);
+                                   // then add the same elements again
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        m.add (i,j, i*j*.5+.5);
+                                   // and overwrite everything again
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        m.set (i,j, i*j*.5+.5);
+  
+  m.compress ();
+  
+                                   // then make sure we retrieve the same ones
+  for (unsigned int i=0; i<m.m(); ++i)
+    for (unsigned int j=0; j<m.m(); ++j)
+      if ((i+2*j+1) % 3 == 0)
+        {
+          Assert (m(i,j) == i*j*.5+.5, ExcInternalError());
+          Assert (m.el(i,j) == i*j*.5+.5, ExcInternalError());
+        }
+      else
+        {
+          Assert (m(i,j) == 0, ExcInternalError());
+          Assert (m.el(i,j) == 0, ExcInternalError());
+        }
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv) 
+{
+  std::ofstream logfile("petsc_03b.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      PetscInitialize(&argc,&argv,0,0);
+      {
+        petsc_wrappers::SparseMatrix m (5,5,3);
+        test (m);
+      }
+      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_11.cc b/tests/bits/petsc_11.cc
new file mode 100644 (file)
index 0000000..f8b9b15
--- /dev/null
@@ -0,0 +1,77 @@
+//----------------------------  petsc_11.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_11.cc  ---------------------------
+
+
+// check petsc_wrapper::Vector::size()
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>    
+#include <fstream>
+#include <iostream>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+                                   // set only certain elements of the vector
+  for (unsigned int i=0; i<v.size(); i+=1+i)
+    v(i) = i;
+
+  v.compress ();
+  
+  Assert (v.size() == 100, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv) 
+{
+  std::ofstream logfile("petsc_11.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_12.cc b/tests/bits/petsc_12.cc
new file mode 100644 (file)
index 0000000..625d6f6
--- /dev/null
@@ -0,0 +1,90 @@
+//----------------------------  petsc_12.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_12.cc  ---------------------------
+
+
+// check petsc_wrapper::Vector::operator() in set-mode
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>    
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::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;
+    }
+
+  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_12.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_13.cc b/tests/bits/petsc_13.cc
new file mode 100644 (file)
index 0000000..273c6bf
--- /dev/null
@@ -0,0 +1,90 @@
+//----------------------------  petsc_13.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_13.cc  ---------------------------
+
+
+// check petsc_wrapper::Vector::operator() in add-mode
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>    
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::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;
+    }
+
+  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_13.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_14.cc b/tests/bits/petsc_14.cc
new file mode 100644 (file)
index 0000000..c4180e4
--- /dev/null
@@ -0,0 +1,96 @@
+//----------------------------  petsc_14.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_14.cc  ---------------------------
+
+
+// check petsc_wrapper::Vector::operator() in set/add-mode alternatingly
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>    
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::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);
+  bool flag = false;
+  for (unsigned int i=0; i<v.size(); i+=1+i)
+    {
+      if (flag == true)
+        v(i) += i;
+      else
+        v(i) = i;
+      flag = !flag;
+      
+      pattern[i] = true;
+    }
+
+  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_14.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_15.cc b/tests/bits/petsc_15.cc
new file mode 100644 (file)
index 0000000..b59a353
--- /dev/null
@@ -0,0 +1,93 @@
+//----------------------------  petsc_15.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_15.cc  ---------------------------
+
+
+// check petsc_wrapper::Vector::operator() in set/add-mode alternatingly, but
+// writing to the same elements
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>    
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::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_15.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_16.cc b/tests/bits/petsc_16.cc
new file mode 100644 (file)
index 0000000..1c2eced
--- /dev/null
@@ -0,0 +1,95 @@
+//----------------------------  petsc_16.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_16.cc  ---------------------------
+
+
+// check petsc_wrapper::Vector::operator() in set/add-mode alternatingly, but
+// writing and overwriting the same elements
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>    
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::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;
+  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_16.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.