#define check_solver_within_range(SolverType_COMMAND, CONTROL_COMMAND, MIN_ALLOWED, MAX_ALLOWED) \
{ \
const unsigned int previous_depth = deallog.depth_file(0); \
- SolverType_COMMAND; \
+ try \
+ { \
+ SolverType_COMMAND; \
+ } \
+ catch (SolverControl::NoConvergence &exc) \
+ {} \
deallog.depth_file(previous_depth); \
const unsigned int steps = CONTROL_COMMAND; \
if (steps >= MIN_ALLOWED && steps <= MAX_ALLOWED) \
#include <deal.II/lac/vector_memory.h>
#include <typeinfo>
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve (SolverType &solver,
- const SolverControl &solver_control,
- const MatrixType &A,
- VectorType &u,
- VectorType &f,
- const PRECONDITION &P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception &e)
- {
- deallog << e.what() << std::endl;
- abort ();
- }
-
- deallog << "Solver stopped after " << solver_control.last_step()
- << " iterations" << std::endl;
-}
-
int main(int argc, char **argv)
{
GrowingVectorMemory<TrilinosWrappers::MPI::Vector> mem;
SolverCG<TrilinosWrappers::MPI::Vector> solver(control, mem);
PreconditionIdentity preconditioner;
- check_solve (solver, control, A,u,f, preconditioner);
+
+ deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 42, 44);
}
}
DEAL::Size 32 Unknowns 961
DEAL::Solver type: N6dealii8SolverCGINS_16TrilinosWrappers3MPI6VectorEEE
-DEAL:cg::Starting value 31.0000
-DEAL:cg::Convergence step 43 value 0.000818932
-DEAL::Solver stopped after 43 iterations
+DEAL::Solver stopped within 42 - 44 iterations
#include <deal.II/lac/vector_memory.h>
#include <typeinfo>
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve (SolverType &solver,
- const SolverControl &solver_control,
- const MatrixType &A,
- VectorType &u,
- VectorType &f,
- const PRECONDITION &P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- check_solver_within_range(
- solver.solve(A,u,f,P),
- solver_control.last_step(), 49, 51);
- }
- catch (std::exception &e)
- {
- deallog << e.what() << std::endl;
- abort ();
- }
-}
-
int main(int argc, char **argv)
{
GrowingVectorMemory<TrilinosWrappers::MPI::Vector> mem;
SolverBicgstab<TrilinosWrappers::MPI::Vector> solver(control,mem);
PreconditionIdentity preconditioner;
- check_solve (solver, control, A,u,f, preconditioner);
+
+ deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 49, 51);
}
}
#include <deal.II/lac/vector_memory.h>
#include <typeinfo>
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve (SolverType &solver,
- const SolverControl &solver_control,
- const MatrixType &A,
- VectorType &u,
- VectorType &f,
- const PRECONDITION &P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception &e)
- {
- deallog << e.what() << std::endl;
- abort ();
- }
-
- deallog << "Solver stopped after " << solver_control.last_step()
- << " iterations" << std::endl;
-}
-
int main(int argc, char **argv)
{
GrowingVectorMemory<TrilinosWrappers::MPI::Vector> mem;
SolverGMRES<TrilinosWrappers::MPI::Vector> solver(control,mem);
PreconditionIdentity preconditioner;
- check_solve (solver, control, A,u,f, preconditioner);
+
+ deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 74, 76);
}
}
DEAL::Size 32 Unknowns 961
DEAL::Solver type: N6dealii11SolverGMRESINS_16TrilinosWrappers3MPI6VectorEEE
-DEAL:GMRES::Starting value 31.0000
-DEAL:GMRES::Convergence step 75 value 0.000809583
-DEAL::Solver stopped after 75 iterations
+DEAL::Solver stopped within 74 - 76 iterations
#include <deal.II/lac/vector_memory.h>
#include <typeinfo>
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve (SolverType &solver,
- const SolverControl &solver_control,
- const MatrixType &A,
- VectorType &u,
- VectorType &f,
- const PRECONDITION &P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception &e)
- {
- deallog << e.what() << std::endl;
- abort ();
- }
-
- deallog << "Solver stopped after " << solver_control.last_step()
- << " iterations" << std::endl;
-}
-
int main(int argc, char **argv)
{
GrowingVectorMemory<TrilinosWrappers::MPI::Vector> mem;
SolverMinRes<TrilinosWrappers::MPI::Vector> solver(control,mem);
PreconditionIdentity preconditioner;
- check_solve (solver, control, A,u,f, preconditioner);
+
+ deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 0, 42);
}
}
DEAL::Size 32 Unknowns 961
DEAL::Solver type: N6dealii12SolverMinResINS_16TrilinosWrappers3MPI6VectorEEE
-DEAL:minres::Starting value 31.0000
-DEAL:minres::Convergence step 43 value 0.000691560
DEAL::Solver stopped after 43 iterations
#include <deal.II/lac/vector_memory.h>
#include <typeinfo>
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve (SolverType &solver,
- const SolverControl &solver_control,
- const MatrixType &A,
- VectorType &u,
- VectorType &f,
- const PRECONDITION &P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception &e)
- {
- deallog << e.what() << std::endl;
- abort ();
- }
-
- deallog << "Solver stopped after " << solver_control.last_step()
- << " iterations" << std::endl;
-}
-
int main(int argc, char **argv)
{
GrowingVectorMemory<TrilinosWrappers::MPI::Vector> mem;
SolverQMRS<TrilinosWrappers::MPI::Vector> solver(control,mem);
PreconditionIdentity preconditioner;
- check_solve (solver, control, A,u,f, preconditioner);
+ deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 45, 47);
}
}
DEAL::Size 32 Unknowns 961
DEAL::Solver type: N6dealii10SolverQMRSINS_16TrilinosWrappers3MPI6VectorEEE
-DEAL:QMRS::Starting value 31.0000
-DEAL:QMRS::Convergence step 46 value 0.000906349
-DEAL::Solver stopped after 46 iterations
+DEAL::Solver stopped within 45 - 47 iterations
#include <deal.II/lac/vector_memory.h>
#include <typeinfo>
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve (SolverType &solver,
- const SolverControl &solver_control,
- const MatrixType &A,
- VectorType &u,
- VectorType &f,
- const PRECONDITION &P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception &e)
- {
- deallog << e.what() << std::endl;
- }
-
- deallog << "Solver stopped after " << solver_control.last_step()
- << " iterations" << std::endl;
-}
-
int main(int argc, char **argv)
{
SolverRichardson<TrilinosWrappers::MPI::Vector>::AdditionalData data (/*omega=*/0.1);
SolverRichardson<TrilinosWrappers::MPI::Vector> solver(control, mem, data);
PreconditionIdentity preconditioner;
- check_solve (solver, control, A,u,f, preconditioner);
+ deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 5269, 5271);
}
}
DEAL::Size 32 Unknowns 961
DEAL::Solver type: N6dealii16SolverRichardsonINS_16TrilinosWrappers3MPI6VectorEEE
-DEAL:Richardson::Starting value 31.00
-DEAL:Richardson::Convergence step 5271 value 0.0009996
-DEAL::Solver stopped after 5271 iterations
+DEAL::Solver stopped within 5269 - 5271 iterations
#include <deal.II/lac/vector_memory.h>
#include <typeinfo>
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve (SolverType &solver,
- const SolverControl &solver_control,
- const MatrixType &A,
- VectorType &u,
- VectorType &f,
- const PRECONDITION &P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception &e)
- {
- deallog << e.what() << std::endl;
- abort ();
- }
-
- deallog << "Solver stopped after " << solver_control.last_step()
- << " iterations" << std::endl;
-}
-
int main(int argc, char **argv)
{
TrilinosWrappers::SolverCG solver(control);
TrilinosWrappers::PreconditionJacobi preconditioner;
preconditioner.initialize(A);
- check_solve (solver, control, A,u,f, preconditioner);
+
+ deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 42, 44);
}
}
DEAL::Size 32 Unknowns 961
DEAL::Solver type: N6dealii16TrilinosWrappers8SolverCGE
-DEAL::Convergence step 43 value 0.000818932
-DEAL::Solver stopped after 43 iterations
+DEAL::Solver stopped within 42 - 44 iterations
#include <deal.II/lac/vector_memory.h>
#include <typeinfo>
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve (SolverType &solver,
- const SolverControl &solver_control,
- const MatrixType &A,
- VectorType &u,
- VectorType &f,
- const PRECONDITION &P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception &e)
- {
- deallog << e.what() << std::endl;
- abort ();
- }
-
- deallog << "Solver stopped after " << solver_control.last_step()
- << " iterations" << std::endl;
-}
-
int main(int argc, char **argv)
{
TrilinosWrappers::SolverGMRES solver(control);
TrilinosWrappers::PreconditionJacobi preconditioner;
preconditioner.initialize(A);
- check_solve (solver, control, A,u,f, preconditioner);
+
+ deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 70, 72);
}
}
DEAL::Size 32 Unknowns 961
DEAL::Solver type: N6dealii16TrilinosWrappers11SolverGMRESE
-DEAL::Convergence step 71 value 0.000916839
-DEAL::Solver stopped after 71 iterations
+DEAL::Solver stopped within 70 - 72 iterations
#include <deal.II/lac/vector_memory.h>
#include <typeinfo>
-template <typename SolverType, typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve (SolverType &solver,
- const SolverControl &solver_control,
- const MatrixType &A,
- VectorType &u,
- VectorType &f,
- const PRECONDITION &P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception &e)
- {
- deallog << e.what() << std::endl;
- abort ();
- }
-
- deallog << "Solver stopped after " << solver_control.last_step()
- << " iterations" << std::endl;
-}
-
int main(int argc, char **argv)
{
TrilinosWrappers::SolverCGS solver(control);
TrilinosWrappers::PreconditionJacobi preconditioner;
preconditioner.initialize(A);
- check_solve (solver, control, A,u,f, preconditioner);
+
+ deallog << "Solver type: " << typeid(solver).name() << std::endl;
+
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 40, 42);
}
}
DEAL::Size 32 Unknowns 961
DEAL::Solver type: N6dealii16TrilinosWrappers9SolverCGSE
-DEAL::Convergence step 41 value 0.000549330
-DEAL::Solver stopped after 41 iterations
+DEAL::Solver stopped within 40 - 42 iterations
#include <deal.II/lac/vector_memory.h>
#include <typeinfo>
-template <typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve (SolverControl &solver_control,
- const MatrixType &A,
- VectorType &u,
- VectorType &f,
- const PRECONDITION &P,
- const bool expected_result)
-{
- TrilinosWrappers::SolverCG solver(solver_control);
-
- u = 0.;
- f = 1.;
- bool success = false;
- try
- {
- solver.solve(A,u,f,P);
- deallog << "Success. ";
- success = true;
- }
- catch (std::exception &e)
- {
- deallog << "Failure. ";
- }
-
- deallog << "Solver stopped after " << solver_control.last_step()
- << " iterations" << std::endl;
- Assert(success == expected_result, ExcMessage("Incorrect result."));
-}
-
int main(int argc, char **argv)
{
deallog.push("Abs tol");
{
// Expects success
- SolverControl solver_control(2000, 1.e-3);
- check_solve (solver_control, A,u,f, preconditioner, true);
+ SolverControl control(2000, 1.e-3);
+ TrilinosWrappers::SolverCG solver(control);
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 42, 44);
}
deallog.pop();
+
+ u = 0.;
deallog.push("Iterations");
{
// Expects failure
- SolverControl solver_control(20, 1.e-3);
- check_solve (solver_control, A,u,f, preconditioner, false);
+ SolverControl control(20, 1.e-3);
+ TrilinosWrappers::SolverCG solver(control);
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 0, 19);
}
deallog.pop();
}
DEAL::Size 32 Unknowns 961
-DEAL:Abs tol::Convergence step 43 value 0.000818932
-DEAL:Abs tol::Success. Solver stopped after 43 iterations
-DEAL:Iterations::Failure step 20 value 6.00198
-DEAL:Iterations::Failure. Solver stopped after 20 iterations
+DEAL:Abs tol::Solver stopped within 42 - 44 iterations
+DEAL:Iterations::Solver stopped after 20 iterations
#include <deal.II/lac/vector_memory.h>
#include <typeinfo>
-template <typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve (SolverControl &solver_control,
- const MatrixType &A,
- VectorType &u,
- VectorType &f,
- const PRECONDITION &P,
- const bool expected_result)
-{
- TrilinosWrappers::SolverCG solver(solver_control);
-
- u = 0.;
- f = 1.;
- bool success = false;
- try
- {
- solver.solve(A,u,f,P);
- deallog << "Success. ";
- success = true;
- }
- catch (std::exception &e)
- {
- deallog << "Failure. ";
- }
-
- deallog << "Solver stopped after " << solver_control.last_step()
- << " iterations" << std::endl;
- Assert(success == expected_result, ExcMessage("Incorrect result."));
-}
-
int main(int argc, char **argv)
{
deallog.push("Rel tol");
{
// Expects success
- ReductionControl solver_control(2000, 1.e-30, 1e-6);
- check_solve (solver_control, A,u,f, preconditioner, true);
+ ReductionControl control(2000, 1.e-30, 1e-6);
+ TrilinosWrappers::SolverCG solver(control);
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 49, 51);
}
deallog.pop();
+
+ u = 0.;
deallog.push("Abs tol");
{
// Expects success
- ReductionControl solver_control(2000, 1.e-3, 1e-9);
- check_solve (solver_control, A,u,f, preconditioner, true);
+ ReductionControl control(2000, 1.e-3, 1e-9);
+ TrilinosWrappers::SolverCG solver(control);
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 42, 44);
}
deallog.pop();
+
+ u = 0.;
deallog.push("Iterations");
{
// Expects failure
- ReductionControl solver_control(20, 1.e-30, 1e-6);
- check_solve (solver_control, A,u,f, preconditioner, false);
+ ReductionControl control(20, 1.e-30, 1e-6);
+ TrilinosWrappers::SolverCG solver(control);
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 0, 19);
}
deallog.pop();
}
DEAL::Size 32 Unknowns 961
-DEAL:Rel tol::Starting value 31.0000
-DEAL:Rel tol::Convergence step 50 value 2.11364e-05
-DEAL:Rel tol::Success. Solver stopped after 50 iterations
-DEAL:Abs tol::Starting value 31.0000
-DEAL:Abs tol::Convergence step 43 value 0.000818932
-DEAL:Abs tol::Success. Solver stopped after 43 iterations
-DEAL:Iterations::Starting value 31.0000
-DEAL:Iterations::Failure step 20 value 6.00198
-DEAL:Iterations::Failure. Solver stopped after 20 iterations
+DEAL:Rel tol::Solver stopped within 49 - 51 iterations
+DEAL:Abs tol::Solver stopped within 42 - 44 iterations
+DEAL:Iterations::Solver stopped after 20 iterations
#include <deal.II/lac/vector_memory.h>
#include <typeinfo>
-template <typename MatrixType, typename VectorType, class PRECONDITION>
-void
-check_solve (SolverControl &solver_control,
- const MatrixType &A,
- VectorType &u,
- VectorType &f,
- const PRECONDITION &P,
- const bool expected_result)
-{
- TrilinosWrappers::SolverCG solver(solver_control);
-
- u = 0.;
- f = 1.;
- bool success = false;
- try
- {
- solver.solve(A,u,f,P);
- deallog << "Success. ";
- success = true;
- }
- catch (std::exception &e)
- {
- deallog << "Failure. ";
- }
-
- deallog << "Solver stopped after " << solver_control.last_step()
- << " iterations" << std::endl;
- Assert(success == expected_result, ExcMessage("Incorrect result."));
-}
-
int main(int argc, char **argv)
{
deallog.push("Abs tol");
{
// Expects success
- IterationNumberControl solver_control(2000, 1.e-3);
- check_solve (solver_control, A,u,f, preconditioner, true);
+ IterationNumberControl control(2000, 1.e-3);
+ TrilinosWrappers::SolverCG solver(control);
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 42, 44);
}
deallog.pop();
+
+ u = 0.;
deallog.push("Iterations");
{
// Expects success
- IterationNumberControl solver_control(20, 1.e-3);
- check_solve (solver_control, A,u,f, preconditioner, true);
+ IterationNumberControl control(20, 1.e-3);
+ TrilinosWrappers::SolverCG solver(control);
+ check_solver_within_range(solver.solve(A,u,f,preconditioner),
+ control.last_step(), 19, 21);
}
deallog.pop();
}
DEAL::Size 32 Unknowns 961
-DEAL:Abs tol::Convergence step 43 value 0.000818932
-DEAL:Abs tol::Success. Solver stopped after 43 iterations
-DEAL:Iterations::Convergence step 20 value 6.00198
-DEAL:Iterations::Success. Solver stopped after 20 iterations
+DEAL:Abs tol::Solver stopped within 42 - 44 iterations
+DEAL:Iterations::Solver stopped within 19 - 21 iterations