From af4e6fa97a3bbd7391455d0b48a01c5b1e4bd923 Mon Sep 17 00:00:00 2001 From: "Toby D. Young" Date: Thu, 14 Nov 2013 13:37:28 +0000 Subject: [PATCH] Add requested output to slepc quicktest. git-svn-id: https://svn.dealii.org/trunk@31650 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/tests/quick_tests/step-slepc.cc | 56 ++++++++++++++++++++----- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/deal.II/tests/quick_tests/step-slepc.cc b/deal.II/tests/quick_tests/step-slepc.cc index 51bc2a664f..e0818b475e 100644 --- a/deal.II/tests/quick_tests/step-slepc.cc +++ b/deal.II/tests/quick_tests/step-slepc.cc @@ -16,6 +16,7 @@ */ #include +#include #include #include #include @@ -60,9 +61,10 @@ private: PETScWrappers::SparseMatrix A, B; std::vector x; - std::vector lambda; - - ConstraintMatrix constraints; + std::vector lambda; + ConstraintMatrix constraints; + + TableHandler output_table; }; LaplaceEigenspectrumProblem::LaplaceEigenspectrumProblem () @@ -73,10 +75,9 @@ LaplaceEigenspectrumProblem::LaplaceEigenspectrumProblem () void LaplaceEigenspectrumProblem::setup_system () { - GridGenerator::hyper_cube (triangulation, -1, 1); - triangulation.refine_global (3); dof_handler.distribute_dofs (fe); + constraints.clear (); DoFTools::make_zero_boundary_constraints (dof_handler, constraints); constraints.close (); @@ -89,6 +90,10 @@ void LaplaceEigenspectrumProblem::setup_system () x[0].reinit (dof_handler.n_dofs ()); lambda.resize (1); lambda[0] = 0.; + + // some output + output_table.add_value ("cells", triangulation.n_active_cells()); + output_table.add_value ("dofs", dof_handler.n_dofs()); } void LaplaceEigenspectrumProblem::assemble_system () @@ -150,16 +155,46 @@ void LaplaceEigenspectrumProblem::assemble_system () void LaplaceEigenspectrumProblem::solve () { - SolverControl solver_control (1., 1e-03); - SLEPcWrappers::SolverLAPACK eigensolver (solver_control); + SolverControl solver_control (1000, 1e-03); + SLEPcWrappers::SolverArnoldi eigensolver (solver_control); + eigensolver.set_which_eigenpairs (EPS_SMALLEST_REAL); eigensolver.solve (A, B, lambda, x, x.size()); + + // some output + output_table.add_value ("lambda", lambda[0]); + output_table.add_value ("error", std::fabs(2.-lambda[0])); } void LaplaceEigenspectrumProblem::run () { - setup_system (); - assemble_system (); - solve (); + const double radius = dealii::numbers::PI/2.; + GridGenerator::hyper_cube (triangulation, -radius, radius); + + // set the old eigenvalue to a silly number. + double old_lambda = 1000; + + for (unsigned int c=0; c<5; ++c) + { + // obtain numerical result + triangulation.refine_global (1); + setup_system (); + assemble_system (); + solve (); + + // check energy convergence with previous result + AssertThrow (lambda[0]