]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New test for PETSc vectors.
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 3 Dec 2010 22:53:42 +0000 (22:53 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 3 Dec 2010 22:53:42 +0000 (22:53 +0000)
git-svn-id: https://svn.dealii.org/trunk@22915 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/petsc/vector_wrap_01.cc b/tests/petsc/vector_wrap_01.cc
new file mode 100644 (file)
index 0000000..3fd91b0
--- /dev/null
@@ -0,0 +1,93 @@
+//----------------------------  petsc_vector_assign_01.cc  ---------------------------
+//    $Id: vector_assign_01.cc 17443 2008-10-31 19:25:47Z bangerth $
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004, 2005 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_vector_assign_01.cc  ---------------------------
+
+
+// Test the constructor PETScWrappers::Vector(const Vec &) that takes an
+// existing PETSc vector.
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>    
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (PETScWrappers::Vector &v,
+           PETScWrappers::Vector &w)
+{
+                                   // set the first vector
+  for (unsigned int i=0; i<v.size(); ++i)
+    v(i) = i;
+
+                                   // copy elements by reference
+  for (unsigned int i=0; i<v.size(); ++i)
+    w(i) = v(i);
+
+                                   // check that they're equal
+  Assert (v==w, ExcInternalError());
+  
+  v=w;
+  
+  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
+    {
+      PetscInitialize(&argc,&argv,0,0);
+      Vec vpetsc;
+      int ierr = VecCreateSeq (PETSC_COMM_SELF, 100, &vpetsc);
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+      {        
+        PETScWrappers::Vector v (vpetsc);
+        PETScWrappers::Vector w (100);
+        test (v,w);
+      }
+      ierr = VecDestroy(vpetsc);
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+      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/petsc/vector_wrap_01/cmp/generic b/tests/petsc/vector_wrap_01/cmp/generic
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+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.