From: Denis Davydov Date: Thu, 13 Oct 2016 17:49:53 +0000 (+0200) Subject: add Assert's to some quick tests X-Git-Tag: v8.5.0-rc1~576^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51b5fc1dcb8e165deb801bc57225c59355feb0de;p=dealii.git add Assert's to some quick tests --- diff --git a/tests/quick_tests/arpack.cc b/tests/quick_tests/arpack.cc index 087d061d27..4eda317b6b 100644 --- a/tests/quick_tests/arpack.cc +++ b/tests/quick_tests/arpack.cc @@ -93,6 +93,30 @@ void test () eigenvalues, eigenvectors, eigenvalues.size()); + + { + const double precision = 1e-7; + Vector Ax(eigenvectors[0]), Bx(eigenvectors[0]); + for (unsigned int i=0; i < eigenvectors.size(); ++i) + { + B.vmult(Bx,eigenvectors[i]); + + for (unsigned int j=0; j < eigenvectors.size(); j++) + Assert( std::abs( eigenvectors[j] * Bx - (i==j))< precision, + ExcMessage("Eigenvectors " + + Utilities::int_to_string(i) + + " and " + + Utilities::int_to_string(j) + + " are not orthonormal!")); + + A.vmult(Ax,eigenvectors[i]); + Ax.add(-1.0*std::real(eigenvalues[i]),Bx); + Assert (Ax.l2_norm() < precision, + ExcMessage("Returned vector " + + Utilities::int_to_string(i) + + " is not an eigenvector!")); + } + } } diff --git a/tests/quick_tests/step-petsc.cc b/tests/quick_tests/step-petsc.cc index 61470331a8..77ee6929a7 100644 --- a/tests/quick_tests/step-petsc.cc +++ b/tests/quick_tests/step-petsc.cc @@ -155,8 +155,10 @@ void LaplaceProblem::solve () PETScWrappers::PreconditionBlockJacobi preconditioner (A); cg_solver.solve (A, x, b, preconditioner); - // some output - // ? + PETScWrappers::Vector res(x); + A.residual(res,x,b); + AssertThrow(res.l2_norm()<1e-3, + ExcInternalError()); } void LaplaceProblem::run () diff --git a/tests/quick_tests/step-slepc.cc b/tests/quick_tests/step-slepc.cc index 42f9d79243..c1469519f5 100644 --- a/tests/quick_tests/step-slepc.cc +++ b/tests/quick_tests/step-slepc.cc @@ -154,11 +154,37 @@ void LaplaceEigenspectrumProblem::assemble_system () void LaplaceEigenspectrumProblem::solve () { - SolverControl solver_control (1000, 1e-03); + SolverControl solver_control (1000, 1e-10); SLEPcWrappers::SolverArnoldi eigensolver (solver_control); eigensolver.set_which_eigenpairs (EPS_SMALLEST_REAL); eigensolver.solve (A, B, lambda, x, x.size()); + { + const double precision = 1e-7; + PETScWrappers::Vector Ax(x[0]), Bx(x[0]); + for (unsigned int i=0; i < x.size(); ++i) + { + B.vmult(Bx,x[i]); + + for (unsigned int j=0; j < x.size(); j++) + if (j!=i) + Assert( std::abs( x[j] * Bx )< precision, + ExcMessage("Eigenvectors " + + Utilities::int_to_string(i) + + " and " + + Utilities::int_to_string(j) + + " are not orthogonal!")); + + A.vmult(Ax,x[i]); + Ax.add(-1.0*lambda[i],Bx); + Assert (Ax.l2_norm() < precision, + ExcMessage("Returned vector " + + Utilities::int_to_string(i) + + " is not an eigenvector!")); + } + } + + // some output output_table.add_value ("lambda", lambda[0]); output_table.add_value ("error", std::fabs(2.-lambda[0])); diff --git a/tests/quick_tests/step-trilinos.cc b/tests/quick_tests/step-trilinos.cc index df87c68ddb..b145721504 100644 --- a/tests/quick_tests/step-trilinos.cc +++ b/tests/quick_tests/step-trilinos.cc @@ -159,8 +159,10 @@ void LaplaceProblem::solve () preconditioner.initialize (A); cg_solver.solve (A, x, b, preconditioner); - // some output - // ? + TrilinosWrappers::Vector res(x); + A.residual(res,x,b); + AssertThrow(res.l2_norm()<1e-3, + ExcInternalError()); } void LaplaceProblem::run ()