From: wolf Date: Wed, 10 Aug 2005 21:52:58 +0000 (+0000) Subject: New tests. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=474c2c9b332a98284c9f8e5542ac121806c59b4e;p=dealii-svn.git New tests. git-svn-id: https://svn.dealii.org/trunk@11276 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/bits/petsc_68.cc b/tests/bits/petsc_68.cc new file mode 100644 index 0000000000..2a902204dc --- /dev/null +++ b/tests/bits/petsc_68.cc @@ -0,0 +1,139 @@ +//---------------------------- petsc_68.cc --------------------------- +// $Id$ +// 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_68.cc --------------------------- + + +// check PETScWrappers::MatrixBase::clear_row () with used second argument + +#include "../tests.h" +#include +#include + +#include +#include +#include + + +void test (PETScWrappers::MatrixBase &m) +{ + Assert (m.m() != 0, ExcInternalError()); + Assert (m.n() != 0, ExcInternalError()); + + // build a tri-diagonal pattern + double norm_sqr = 0; + unsigned int nnz = 0; + const unsigned int N = m.m(); + for (unsigned int i=0; i=5) + { + const double s = rand(); + m.add (i,i-5, s); + norm_sqr += s*s; + ++nnz; + } + + if (i +#include + +#include +#include +#include + + +void test (PETScWrappers::MatrixBase &m) +{ + Assert (m.m() != 0, ExcInternalError()); + Assert (m.n() != 0, ExcInternalError()); + + // build a tri-diagonal pattern + double norm_sqr = 0; + unsigned int nnz = 0; + const unsigned int N = m.m(); + for (unsigned int i=0; i=5) + { + const double s = rand(); + m.add (i,i-5, s); + norm_sqr += s*s; + ++nnz; + } + + if (i(&rows[0], &rows[2]), rnd); + + deallog << m.frobenius_norm() << ' ' << std::sqrt (norm_sqr) + << std::endl; + deallog << m.n_nonzero_elements() << ' ' << nnz << std::endl; + + Assert (std::fabs (m.frobenius_norm() - std::sqrt(norm_sqr)) + < std::fabs (std::sqrt (norm_sqr)), + ExcInternalError()); + + // make sure that zeroing out rows does at + // least not add new nonzero entries (it + // may remove some, though) + Assert (m.n_nonzero_elements() <= nnz, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main (int argc,char **argv) +{ + std::ofstream logfile("petsc_69.output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + PetscInitialize(&argc,&argv,0,0); + { + PETScWrappers::SparseMatrix v (14,14,3); + 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; + }; +}