// tests that GMRES builds an orthonormal basis properly for a few difficult
-// test matrices
+// test matrices. In particular, this test monitors when re-orthogonalization
+// kicks in.
#include "../tests.h"
#include <deal.II/lac/vector.h>
template <typename number>
-void test (unsigned int variant)
+void test (unsigned int variant, unsigned int min_convergence_steps)
{
const unsigned int n = 64;
Vector<number> rhs(n), sol(n);
data.max_n_tmp_vectors = 80;
SolverGMRES<Vector<number> > solver(control, data);
- solver.solve(matrix, sol, rhs, PreconditionIdentity());
+ auto print_re_orthogonalization =
+ [](int accumulated_iterations)
+ {
+ deallog.get_file_stream() << "Re-orthogonalization enabled at step "
+ << accumulated_iterations << std::endl;
+ };
+ solver.connect_re_orthogonalization_slot(print_re_orthogonalization);
+
+ check_solver_within_range
+ (solver.solve(matrix, sol, rhs, PreconditionIdentity()),
+ control.last_step(), min_convergence_steps, min_convergence_steps+2);
deallog.pop();
}
int main()
{
- std::ofstream logfile("output");
- deallog << std::setprecision(3);
- deallog.attach(logfile);
+ initlog();
deallog.push("double");
- test<double>(0);
- test<double>(1);
- test<double>(2);
- test<double>(3);
- test<double>(4);
- test<double>(5);
+ test<double>(0, 56);
+ test<double>(1, 64);
+ test<double>(2, 56);
+ test<double>(3, 64);
+ test<double>(4, 56);
+ test<double>(5, 64);
deallog.pop();
deallog.push("float");
- test<float>(0);
- test<float>(1);
- test<float>(2);
- test<float>(3);
+ test<float>(0, 36);
+ test<float>(1, 64);
+ test<float>(2, 36);
+ test<float>(3, 64);
deallog.pop();
}
-DEAL:double:0:GMRES::Starting value 8.00
-DEAL:double:0:GMRES::Convergence step 57 value 1.62e-14
-DEAL:double:1:GMRES::Starting value 8.00
-DEAL:double:1:GMRES::Re-orthogonalization enabled at step 65
-DEAL:double:1:GMRES::Convergence step 65 value 1.04e-23
-DEAL:double:2:GMRES::Starting value 8.00
-DEAL:double:2:GMRES::Convergence step 57 value 1.72e-14
-DEAL:double:3:GMRES::Starting value 8.00
-DEAL:double:3:GMRES::Re-orthogonalization enabled at step 65
-DEAL:double:3:GMRES::Convergence step 65 value 2.56e-24
-DEAL:double:4:GMRES::Starting value 8.00
-DEAL:double:4:GMRES::Convergence step 57 value 1.59e-14
-DEAL:double:5:GMRES::Starting value 8.00
-DEAL:double:5:GMRES::Re-orthogonalization enabled at step 65
-DEAL:double:5:GMRES::Convergence step 65 value 1.96e-24
-DEAL:float:0:GMRES::Starting value 8.00
-DEAL:float:0:GMRES::Convergence step 37 value 7.73e-06
-DEAL:float:1:GMRES::Starting value 8.00
-DEAL:float:1:GMRES::Re-orthogonalization enabled at step 65
-DEAL:float:1:GMRES::Convergence step 65 value 1.11e-05
-DEAL:float:2:GMRES::Starting value 8.00
-DEAL:float:2:GMRES::Convergence step 37 value 6.87e-06
-DEAL:float:3:GMRES::Starting value 8.00
-DEAL:float:3:GMRES::Re-orthogonalization enabled at step 65
-DEAL:float:3:GMRES::Convergence step 66 value 3.27e-10
+DEAL:double:0::Solver stopped within 56 - 58 iterations
+Re-orthogonalization enabled at step 65
+DEAL:double:1::Solver stopped within 64 - 66 iterations
+DEAL:double:2::Solver stopped within 56 - 58 iterations
+Re-orthogonalization enabled at step 65
+DEAL:double:3::Solver stopped within 64 - 66 iterations
+DEAL:double:4::Solver stopped within 56 - 58 iterations
+Re-orthogonalization enabled at step 65
+DEAL:double:5::Solver stopped within 64 - 66 iterations
+DEAL:float:0::Solver stopped within 36 - 38 iterations
+Re-orthogonalization enabled at step 65
+DEAL:float:1::Solver stopped within 64 - 66 iterations
+DEAL:float:2::Solver stopped within 36 - 38 iterations
+Re-orthogonalization enabled at step 65
+DEAL:float:3::Solver stopped within 64 - 66 iterations
data.max_n_tmp_vectors = 202;
SolverGMRES<Vector<number> > solver(control, data);
+ auto print_re_orthogonalization =
+ [](int accumulated_iterations)
+ {
+ deallog.get_file_stream() << "Re-orthogonalization enabled at step "
+ << accumulated_iterations << std::endl;
+ };
+ solver.connect_re_orthogonalization_slot(print_re_orthogonalization);
solver.solve(matrix, sol, rhs, PreconditionIdentity());
}
data.force_re_orthogonalization = true;
SolverGMRES<Vector<number> > solver(control, data);
+ auto print_re_orthogonalization =
+ [](int accumulated_iterations)
+ {
+ deallog.get_file_stream() << "Re-orthogonalization enabled at step "
+ << accumulated_iterations << std::endl;
+ };
+ solver.connect_re_orthogonalization_slot(print_re_orthogonalization);
solver.solve(matrix, sol, rhs, PreconditionIdentity());
deallog.pop();
data.max_n_tmp_vectors = 202;
SolverGMRES<Vector<number> > solver(control, data);
+ auto print_re_orthogonalization =
+ [](int accumulated_iterations)
+ {
+ deallog.get_file_stream() << "Re-orthogonalization enabled at step "
+ << accumulated_iterations << std::endl;
+ };
+ solver.connect_re_orthogonalization_slot(print_re_orthogonalization);
solver.solve(matrix, sol, rhs, PreconditionIdentity());
}
data.force_re_orthogonalization = true;
SolverGMRES<Vector<number> > solver(control, data);
+ auto print_re_orthogonalization =
+ [](int accumulated_iterations)
+ {
+ deallog.get_file_stream() << "Re-orthogonalization enabled at step "
+ << accumulated_iterations << std::endl;
+ };
+ solver.connect_re_orthogonalization_slot(print_re_orthogonalization);
solver.solve(matrix, sol, rhs, PreconditionIdentity());
}
DEAL::Size 4 Unknowns 9
-DEAL::SOR-diff:0
+DEAL::SOR-diff:0.000
DEAL:no-fail:cg::Starting value 3.000
-DEAL:no-fail:cg::Convergence step 3 value 0
+DEAL:no-fail:cg::Convergence step 3 value 4.807e-17
DEAL:no-fail:Bicgstab::Starting value 3.000
-DEAL:no-fail:Bicgstab::Convergence step 3 value 0
+DEAL:no-fail:Bicgstab::Convergence step 3 value 5.998e-18
DEAL:no-fail:GMRES::Starting value 3.000
-DEAL:no-fail:GMRES::Convergence step 3 value 0
+DEAL:no-fail:GMRES::Convergence step 3 value 1.110e-16
DEAL:no-fail:GMRES::Starting value 3.000
-DEAL:no-fail:GMRES::Convergence step 3 value 0
+DEAL:no-fail:GMRES::Convergence step 3 value 1.110e-16
DEAL:no-fail:QMRS::Starting value 3.000
-DEAL:no-fail:QMRS::Convergence step 3 value 0
+DEAL:no-fail:QMRS::Convergence step 3 value 9.615e-17
DEAL:no-fail:FIRE::Starting value 9.000
DEAL:no-fail:FIRE::Convergence step 38 value 0.0002184
DEAL:no:Richardson::Starting value 3.000
DEAL:no:Richardson::Convergence step 24 value 0.0007118
DEAL:no:cg::Starting value 3.000
-DEAL:no:cg::Convergence step 3 value 0
+DEAL:no:cg::Convergence step 3 value 4.807e-17
DEAL:no:Bicgstab::Starting value 3.000
-DEAL:no:Bicgstab::Convergence step 3 value 0
+DEAL:no:Bicgstab::Convergence step 3 value 5.998e-18
DEAL:no:GMRES::Starting value 3.000
-DEAL:no:GMRES::Convergence step 3 value 0
+DEAL:no:GMRES::Convergence step 3 value 1.110e-16
DEAL:no:GMRES::Starting value 3.000
-DEAL:no:GMRES::Convergence step 3 value 0
+DEAL:no:GMRES::Convergence step 3 value 1.110e-16
DEAL:no:QMRS::Starting value 3.000
-DEAL:no:QMRS::Convergence step 3 value 0
+DEAL:no:QMRS::Convergence step 3 value 9.615e-17
DEAL:no:FIRE::Starting value 9.000
DEAL:no:FIRE::Convergence step 38 value 0.0002184
DEAL:rich:Richardson::Starting value 3.000
DEAL:rich:Richardson::Convergence step 42 value 0.0008696
DEAL:rich:cg::Starting value 3.000
-DEAL:rich:cg::Convergence step 3 value 0
+DEAL:rich:cg::Convergence step 3 value 3.102e-16
DEAL:rich:Bicgstab::Starting value 3.000
-DEAL:rich:Bicgstab::Convergence step 3 value 0
+DEAL:rich:Bicgstab::Convergence step 3 value 7.254e-18
DEAL:rich:GMRES::Starting value 1.800
-DEAL:rich:GMRES::Convergence step 3 value 0
+DEAL:rich:GMRES::Convergence step 3 value 6.029e-16
DEAL:rich:GMRES::Starting value 3.000
-DEAL:rich:GMRES::Convergence step 3 value 0
+DEAL:rich:GMRES::Convergence step 3 value 1.078e-15
DEAL:rich:QMRS::Starting value 3.000
-DEAL:rich:QMRS::Convergence step 3 value 0
+DEAL:rich:QMRS::Convergence step 3 value 7.195e-16
DEAL:rich:FIRE::Starting value 9.000
DEAL:rich:FIRE::Convergence step 32 value 0.0009708
DEAL:ssor:RichardsonT::Starting value 3.000
DEAL:sor:cg::Failure step 100 value 0.2585
DEAL:sor::Exception: SolverControl::NoConvergence (it, res)
DEAL:sor:Bicgstab::Starting value 3.000
-DEAL:sor:Bicgstab::Convergence step 5 value 0
+DEAL:sor:Bicgstab::Convergence step 5 value 6.247e-18
DEAL:sor:GMRES::Starting value 1.462
-DEAL:sor:GMRES::Re-orthogonalization enabled at step 5
-DEAL:sor:GMRES::Convergence step 5 value 0
+DEAL:sor:GMRES::Convergence step 5 value 7.914e-19
DEAL:sor:GMRES::Starting value 3.000
-DEAL:sor:GMRES::Re-orthogonalization enabled at step 5
-DEAL:sor:GMRES::Convergence step 5 value 0
+DEAL:sor:GMRES::Convergence step 5 value 6.144e-18
DEAL:sor:FIRE::Starting value 9.000
DEAL:sor:FIRE::Convergence step 51 value 0.0004993
DEAL:psor:RichardsonT::Starting value 3.000
DEAL:psor:FIRE::Starting value 9.000
DEAL:psor:FIRE::Convergence step 45 value 0.0009217
DEAL::Size 12 Unknowns 121
-DEAL::SOR-diff:0
+DEAL::SOR-diff:0.000
DEAL:no-fail:cg::Starting value 11.00
DEAL:no-fail:cg::Failure step 10 value 0.1496
DEAL:no-fail::Exception: SolverControl::NoConvergence (it, res)