]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Split one test into three simpler tests. One test crashes (element_access_02) due...
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 19 Oct 2013 14:06:27 +0000 (14:06 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 19 Oct 2013 14:06:27 +0000 (14:06 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@31315 0785d39b-7218-0410-832d-ea1e28bc413d

tests/petsc_scalar_complex/element_access/cmp/generic [deleted file]
tests/petsc_scalar_complex/element_access_00.cc [moved from tests/petsc_scalar_complex/element_access.cc with 71% similarity]
tests/petsc_scalar_complex/element_access_00/cmp/generic [new file with mode: 0644]
tests/petsc_scalar_complex/element_access_01.cc [new file with mode: 0644]
tests/petsc_scalar_complex/element_access_01/cmp/generic [new file with mode: 0644]
tests/petsc_scalar_complex/element_access_02.cc [new file with mode: 0644]

diff --git a/tests/petsc_scalar_complex/element_access/cmp/generic b/tests/petsc_scalar_complex/element_access/cmp/generic
deleted file mode 100644 (file)
index 6a61861..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-
-DEAL::Check vector access
-DEAL::OK
-
similarity index 71%
rename from tests/petsc_scalar_complex/element_access.cc
rename to tests/petsc_scalar_complex/element_access_00.cc
index aa64a6d06cee6a7eb1616c1862719ef1a30306f3..e701637d4ca2e6fd0006b3e2f6c9f74f595bab9a 100644 (file)
@@ -19,7 +19,6 @@
 // deal.II includes
 #include "../tests.h"
 #include <deal.II/lac/petsc_vector.h>
-#include <deal.II/lac/petsc_sparse_matrix.h>
     
 #include <fstream>
 #include <iostream>
@@ -29,7 +28,7 @@
 
 // test dealii::internal::VectorReference::real() 
 // test dealii::internal::VectorReference::imag() 
-// on vector and matrix
+// on vector 
 
 // vector elements
 void test_vector (PETScWrappers::Vector &v)
@@ -59,35 +58,9 @@ void test_vector (PETScWrappers::Vector &v)
   deallog << "OK" << std::endl;
 }
 
-// sparse matrix elements
-void test_matrix (PETScWrappers::SparseMatrix &m)
-{
-  deallog << "Check matrix access" << std::endl;
-
-  // fill up a matrix with some numbers
-  for (unsigned int k=0; k<m.m(); ++k)
-    for (unsigned int l=0; l<m.n(); ++l)
-      m.set (k,l, std::complex<double> (k+l,-k-l));
-
-  m.compress (VectorOperation::add);
-
-  for (unsigned int k=0; k<m.m(); ++k)
-    for (unsigned int l=0; l<m.n(); ++l)
-      Assert ((static_cast<std::complex<double> > (m(k,l)).real ()==k+l) && 
-             (static_cast<std::complex<double> > (m(k,l)).imag ()==-k-l), 
-             ExcInternalError());
-            
-  for (unsigned int k=0; k<m.m(); ++k)
-    for (unsigned int l=0; l<m.n(); ++l)
-      Assert ((m(k,l).real ()==k+l) && (m(k,l).imag ()==-k-l), 
-             ExcInternalError());
-
-  deallog << "OK" << std::endl;
-}
-
 int main (int argc, char **argv)
 {
-  std::ofstream logfile ("element_access/output");
+  std::ofstream logfile ("element_access_00/output");
   dealii::deallog.attach (logfile);
   dealii::deallog.depth_console (0);
   deallog.threshold_double(1.e-10);
@@ -99,14 +72,8 @@ int main (int argc, char **argv)
         PETScWrappers::Vector v (5);
        test_vector (v);
        
-       // Suprising the matrix part does not produce an
-       // error. However, something is VERY fishy here.
-       //
-       // @TODO Why does this test pass? I have no real() or imag()
-       // operators/functions defined.
-
-       // PETScWrappers::SparseMatrix m (5,5,5);
-       // test_matrix (m);
+       deallog << "vector:" << std::endl;
+       v.print (logfile);
       }
       PetscFinalize ();
     }
diff --git a/tests/petsc_scalar_complex/element_access_00/cmp/generic b/tests/petsc_scalar_complex/element_access_00/cmp/generic
new file mode 100644 (file)
index 0000000..60ff416
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Check vector access
+DEAL::OK
+DEAL::vector:
+(0.000e+00,5.000e+00) (1.000e+00,4.000e+00) (2.000e+00,3.000e+00) (3.000e+00,2.000e+00) (4.000e+00,1.000e+00) 
+
diff --git a/tests/petsc_scalar_complex/element_access_01.cc b/tests/petsc_scalar_complex/element_access_01.cc
new file mode 100644 (file)
index 0000000..84904fe
--- /dev/null
@@ -0,0 +1,113 @@
+
+// ---------------------------------------------------------------------
+// $Id: 
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// deal.II includes
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+    
+#include <fstream>
+#include <iostream>
+#include <cassert>
+
+#include <complex>
+
+// test dealii::internal::VectorReference::real() 
+// test dealii::internal::VectorReference::imag() 
+// on vector and matrix
+
+// sparse matrix elements
+void test_matrix (PETScWrappers::SparseMatrix &m)
+{
+  deallog << "Check 01 matrix access" << std::endl;
+
+  // fill up a matrix with some numbers
+  for (unsigned int k=0; k<m.m(); ++k)
+    for (unsigned int l=0; l<m.n(); ++l)
+      {
+       PetscReal el_r = static_cast<double> (k+l);
+       PetscReal el_i = static_cast<double> (-1.*(k+l));
+       m.set (k,l, std::complex<double> (el_r,el_i));
+      }
+
+  m.compress (VectorOperation::add);
+            
+  for (unsigned int k=0; k<m.m(); ++k)
+    for (unsigned int l=0; l<m.n(); ++l)
+      {
+       PetscReal el_r = static_cast<double> (k+l);
+       PetscReal el_i = static_cast<double> (-1.*(k+l));
+
+       Assert ((m(k,l).real ()==el_r) && (m(k,l).imag ()==el_i), 
+               ExcInternalError());
+      }
+
+  deallog << "OK" << std::endl;
+}
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile ("element_access_01/output");
+  dealii::deallog.attach (logfile);
+  dealii::deallog.depth_console (0);
+  deallog.threshold_double(1.e-10);
+  
+  try
+    {
+      PetscInitialize (&argc, &argv, (char*) 0, (char*) 0);
+      {
+       PETScWrappers::SparseMatrix m (5,5,5);
+       test_matrix (m);
+
+       deallog << "matrix:" << std::endl;
+       m.print (logfile);
+      }
+      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;
+    }
+  
+  logfile << std::endl;
+  
+  return 0;
+}
+
+
diff --git a/tests/petsc_scalar_complex/element_access_01/cmp/generic b/tests/petsc_scalar_complex/element_access_01/cmp/generic
new file mode 100644 (file)
index 0000000..faa0818
--- /dev/null
@@ -0,0 +1,30 @@
+
+DEAL::Check 01 matrix access
+DEAL::OK
+DEAL::matrix:
+(0,0) (0.00000,0.00000)
+(0,1) (1.00000,-1.00000)
+(0,2) (2.00000,-2.00000)
+(0,3) (3.00000,-3.00000)
+(0,4) (4.00000,-4.00000)
+(1,0) (1.00000,-1.00000)
+(1,1) (2.00000,-2.00000)
+(1,2) (3.00000,-3.00000)
+(1,3) (4.00000,-4.00000)
+(1,4) (5.00000,-5.00000)
+(2,0) (2.00000,-2.00000)
+(2,1) (3.00000,-3.00000)
+(2,2) (4.00000,-4.00000)
+(2,3) (5.00000,-5.00000)
+(2,4) (6.00000,-6.00000)
+(3,0) (3.00000,-3.00000)
+(3,1) (4.00000,-4.00000)
+(3,2) (5.00000,-5.00000)
+(3,3) (6.00000,-6.00000)
+(3,4) (7.00000,-7.00000)
+(4,0) (4.00000,-4.00000)
+(4,1) (5.00000,-5.00000)
+(4,2) (6.00000,-6.00000)
+(4,3) (7.00000,-7.00000)
+(4,4) (8.00000,-8.00000)
+
diff --git a/tests/petsc_scalar_complex/element_access_02.cc b/tests/petsc_scalar_complex/element_access_02.cc
new file mode 100644 (file)
index 0000000..1fc6273
--- /dev/null
@@ -0,0 +1,104 @@
+
+// ---------------------------------------------------------------------
+// $Id: 
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// deal.II includes
+#include "../tests.h"
+#include <deal.II/lac/petsc_sparse_matrix.h>
+    
+#include <fstream>
+#include <iostream>
+#include <cassert>
+
+#include <complex>
+
+// test dealii::internal::VectorReference::real() 
+// test dealii::internal::VectorReference::imag() 
+// test element access (read/write) on matrix
+
+// sparse matrix elements
+void test_matrix (PETScWrappers::SparseMatrix &m)
+{
+  deallog << "Check 02 matrix access" << std::endl;
+
+  // fill up a matrix with some numbers
+  for (unsigned int k=0; k<m.m(); ++k)
+    for (unsigned int l=0; l<m.n(); ++l)
+      m.set (k,l, PetscScalar (+k+l,-k-l));
+
+  m.compress (VectorOperation::add);
+
+  // This fails, because the write above fails - see output file
+  for (unsigned int k=0; k<m.m(); ++k)
+    for (unsigned int l=0; l<m.n(); ++l)
+      Assert (m(k,l).real () == -1.*m(k,l).imag (), 
+             ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+int main (int argc, char **argv)
+{
+  std::ofstream logfile ("element_access_02/output");
+  dealii::deallog.attach (logfile);
+  dealii::deallog.depth_console (0);
+  deallog.threshold_double(1.e-10);
+  
+  try
+    {
+      PetscInitialize (&argc, &argv, (char*) 0, (char*) 0);
+      {
+       PETScWrappers::SparseMatrix m (5,5,5);
+       test_matrix (m);
+
+       deallog << "matrix:" << std::endl;
+       m.print (logfile);
+      }
+      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;
+    }
+  
+  logfile << std::endl;
+  
+  return 0;
+}
+
+

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.