From aad047883385608dbeef077a4b7397c060fb3bd0 Mon Sep 17 00:00:00 2001 From: young Date: Sat, 19 Oct 2013 14:06:27 +0000 Subject: [PATCH] Split one test into three simpler tests. One test crashes (element_access_02) due to a hidden bug. git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@31315 0785d39b-7218-0410-832d-ea1e28bc413d --- .../element_access/cmp/generic | 4 - ...element_access.cc => element_access_00.cc} | 41 +------ .../element_access_00/cmp/generic | 6 + .../petsc_scalar_complex/element_access_01.cc | 113 ++++++++++++++++++ .../element_access_01/cmp/generic | 30 +++++ .../petsc_scalar_complex/element_access_02.cc | 104 ++++++++++++++++ 6 files changed, 257 insertions(+), 41 deletions(-) delete mode 100644 tests/petsc_scalar_complex/element_access/cmp/generic rename tests/petsc_scalar_complex/{element_access.cc => element_access_00.cc} (71%) create mode 100644 tests/petsc_scalar_complex/element_access_00/cmp/generic create mode 100644 tests/petsc_scalar_complex/element_access_01.cc create mode 100644 tests/petsc_scalar_complex/element_access_01/cmp/generic create mode 100644 tests/petsc_scalar_complex/element_access_02.cc diff --git a/tests/petsc_scalar_complex/element_access/cmp/generic b/tests/petsc_scalar_complex/element_access/cmp/generic deleted file mode 100644 index 6a61861a6b..0000000000 --- a/tests/petsc_scalar_complex/element_access/cmp/generic +++ /dev/null @@ -1,4 +0,0 @@ - -DEAL::Check vector access -DEAL::OK - diff --git a/tests/petsc_scalar_complex/element_access.cc b/tests/petsc_scalar_complex/element_access_00.cc similarity index 71% rename from tests/petsc_scalar_complex/element_access.cc rename to tests/petsc_scalar_complex/element_access_00.cc index aa64a6d06c..e701637d4c 100644 --- a/tests/petsc_scalar_complex/element_access.cc +++ b/tests/petsc_scalar_complex/element_access_00.cc @@ -19,7 +19,6 @@ // deal.II includes #include "../tests.h" #include -#include #include #include @@ -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 (k+l,-k-l)); - - m.compress (VectorOperation::add); - - for (unsigned int k=0; k > (m(k,l)).real ()==k+l) && - (static_cast > (m(k,l)).imag ()==-k-l), - ExcInternalError()); - - for (unsigned int k=0; k + +#include +#include +#include + +#include + +// 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 (k+l); + PetscReal el_i = static_cast (-1.*(k+l)); + m.set (k,l, std::complex (el_r,el_i)); + } + + m.compress (VectorOperation::add); + + for (unsigned int k=0; k (k+l); + PetscReal el_i = static_cast (-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 index 0000000000..faa0818801 --- /dev/null +++ b/tests/petsc_scalar_complex/element_access_01/cmp/generic @@ -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 index 0000000000..1fc62730c7 --- /dev/null +++ b/tests/petsc_scalar_complex/element_access_02.cc @@ -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 + +#include +#include +#include + +#include + +// 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