+++ /dev/null
-
-DEAL::Check vector access
-DEAL::OK
-
// 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>
// test dealii::internal::VectorReference::real()
// test dealii::internal::VectorReference::imag()
-// on vector and matrix
+// on vector
// vector elements
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);
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 ();
}
--- /dev/null
+
+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)
+
--- /dev/null
+
+// ---------------------------------------------------------------------
+// $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;
+}
+
+
--- /dev/null
+
+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)
+
--- /dev/null
+
+// ---------------------------------------------------------------------
+// $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;
+}
+
+