From: Toby D. Young Date: Thu, 2 May 2013 20:18:40 +0000 (+0000) Subject: Build in assertions... X-Git-Tag: v8.0.0~583 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36a4a6657f3e30af9fe15074c80dff1c65fd3bb6;p=dealii.git Build in assertions... git-svn-id: https://svn.dealii.org/trunk@29432 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/lac/slepc_solver.h b/deal.II/include/deal.II/lac/slepc_solver.h index 595843a5d0..402f4ebf69 100644 --- a/deal.II/include/deal.II/lac/slepc_solver.h +++ b/deal.II/include/deal.II/lac/slepc_solver.h @@ -151,9 +151,9 @@ namespace SLEPcWrappers template void solve (const PETScWrappers::MatrixBase &A, - std::vector &kr, - std::vector &vr, - const unsigned int n_eigenvectors = 1); + std::vector &r_eigenvalues, + std::vector &r_eigenvectors = std::vector (), + const unsigned int n_eigenvectors = 1); /** * Same as above, but here a composite method for solving the @@ -163,8 +163,8 @@ namespace SLEPcWrappers void solve (const PETScWrappers::MatrixBase &A, const PETScWrappers::MatrixBase &B, - std::vector &kr, - std::vector &vr, + std::vector &r_eigenvalues, + std::vector &r_eigenvectors = std::vector (), const unsigned int n_eigenvectors = 1); /** @@ -288,12 +288,8 @@ namespace SLEPcWrappers * \text{n\_converged}-1$. */ void - get_eigenpair (const unsigned int index, -#ifndef PETSC_USE_COMPLEX + get_eigenpair (const unsigned int index, double &kr, -#else - std::complex &kr, -#endif PETScWrappers::VectorBase &vr); /** @@ -723,15 +719,15 @@ namespace SLEPcWrappers std::vector &vr, const unsigned int n_eigenvectors) { - // Panic if no eigenpairs are wanted. - AssertThrow (n_eigenvectors != 0, ExcSLEPcWrappersUsageError()); - - unsigned int n_converged = 0; + // Panic if the number of eigenpairs wanted is out of bounds. + AssertThrow ((n_eigenvectors > 0) && (n_eigenvectors <= A.m ()), + ExcSLEPcWrappersUsageError()); // Set the matrices of the problem set_matrices (A); // and solve + unsigned int n_converged = 0; solve (n_eigenvectors, &n_converged); if (n_converged > n_eigenvectors) @@ -755,15 +751,19 @@ namespace SLEPcWrappers std::vector &vr, const unsigned int n_eigenvectors) { - // Panic if no eigenpairs are wanted. - AssertThrow (n_eigenvectors != 0, ExcSLEPcWrappersUsageError()); + // Guard against incompatible matrix sizes: + AssertThrow (A.m() == B.m (), ExcDimensionMismatch(A.m(), B.m())); + AssertThrow (A.n() == B.n (), ExcDimensionMismatch(A.n(), B.n())); - unsigned int n_converged = 0; + // Panic if the number of eigenpairs wanted is out of bounds. + AssertThrow ((n_eigenvectors > 0) && (n_eigenvectors <= A.m ()), + ExcSLEPcWrappersUsageError()); // Set the matrices of the problem set_matrices (A, B); // and solve + unsigned int n_converged = 0; solve (n_eigenvectors, &n_converged); if (n_converged >= n_eigenvectors) diff --git a/deal.II/source/lac/slepc_solver.cc b/deal.II/source/lac/slepc_solver.cc index ded535c6bc..9d5877f2aa 100644 --- a/deal.II/source/lac/slepc_solver.cc +++ b/deal.II/source/lac/slepc_solver.cc @@ -220,11 +220,7 @@ namespace SLEPcWrappers void SolverBase::get_eigenpair (const unsigned int index, -#ifndef PETSC_USE_COMPLEX double &kr, -#else - std::complex &kr, -#endif PETScWrappers::VectorBase &vr) { AssertThrow (solver_data.get() != 0, ExcSLEPcWrappersUsageError());