}
+/*
+ * Test that a solver converged within a certain range of iteration steps.
+ *
+ * SOLVER_COMMAND is the command to issue, CONTROL_COMMAND a function call
+ * that returns the number of iterations (castable to unsigned int), and
+ * MIN_ALLOWED, MAX_ALLOWED is the inclusive range of allowed iteration
+ * steps.
+ */
+
+#define check_solver_within_range(SOLVER_COMMAND, CONTROL_COMMAND, MIN_ALLOWED, MAX_ALLOWED) \
+{ \
+ const unsigned int previous_depth = deallog.depth_file(0); \
+ SOLVER_COMMAND; \
+ deallog.depth_file(previous_depth); \
+ const unsigned int steps = CONTROL_COMMAND; \
+ if (steps >= MIN_ALLOWED && steps <= MAX_ALLOWED) \
+ { \
+ deallog << "Solver stopped within " << MIN_ALLOWED << " - " \
+ << MAX_ALLOWED << " iterations" << std::endl; \
+ } \
+ else \
+ { \
+ deallog << "Solver stopped after " << steps << " iterations" \
+ << std::endl; \
+ } \
+}
+
+
// ------------------------------ Functions used in initializing subsystems -------------------
ubb = bb;
SolverControl control (1000, 1e-13);
-
SolverCG<BlockVector<double> > bcg(control, SolverCG<BlockVector<double> >::AdditionalData());
- bcg.solve(Bb, bx, bb, PreconditionIdentity());
+
+ switch (dim)
+ {
+ case 1:
+ check_solver_within_range(
+ bcg.solve(Bb, bx, bb, PreconditionIdentity()),
+ control.last_step(), 112, 114);
+ break;
+ case 2:
+ check_solver_within_range(
+ bcg.solve(Bb, bx, bb, PreconditionIdentity()),
+ control.last_step(), 60, 62);
+ break;
+ case 3:
+ check_solver_within_range(
+ bcg.solve(Bb, bx, bb, PreconditionIdentity()),
+ control.last_step(), 24, 26);
+ break;
+ default:
+ Assert(false, ExcNotImplemented());
+ }
SolverCG<Vector<double> > cg(control, SolverCG<Vector<double> >::AdditionalData());
- cg.solve(B, x, b, PreconditionIdentity());
+
+ switch (dim)
+ {
+ case 1:
+ check_solver_within_range(
+ cg.solve(B, x, b, PreconditionIdentity()),
+ control.last_step(), 112, 114);
+ break;
+ case 2:
+ check_solver_within_range(
+ cg.solve(B, x, b, PreconditionIdentity()),
+ control.last_step(), 60, 62);
+ break;
+ case 3:
+ check_solver_within_range(
+ cg.solve(B, x, b, PreconditionIdentity()),
+ control.last_step(), 24, 26);
+ break;
+ default:
+ Assert(false, ExcNotImplemented());
+ }
deallog << "Sparse Factorization" << std::endl;
SparseDirectUMFPACK umfpack, umfpackb;
+++ /dev/null
-
-DEAL::1d
-DEAL::Number of dofs = 97
-DEAL:cg::Starting value 0.215517
-DEAL:cg::Convergence step 112 value 0
-DEAL:cg::Starting value 0.215517
-DEAL:cg::Convergence step 112 value 0
-DEAL::Sparse Factorization
-DEAL::absolute norms = 6.45748 6.45748
-DEAL::relative norm distance = 0
-DEAL::Block Sparse Factorization
-DEAL::absolute norms = 6.45748 6.45748
-DEAL::relative norm distance = 0
-DEAL::2d
-DEAL::Number of dofs = 994
-DEAL:cg::Starting value 0.595296
-DEAL:cg::Convergence step 61 value 0
-DEAL:cg::Starting value 0.595296
-DEAL:cg::Convergence step 61 value 0
-DEAL::Sparse Factorization
-DEAL::absolute norms = 10.0596 10.0596
-DEAL::relative norm distance = 0
-DEAL::Block Sparse Factorization
-DEAL::absolute norms = 10.0596 10.0596
-DEAL::relative norm distance = 0
-DEAL::3d
-DEAL::Number of dofs = 669
-DEAL:cg::Starting value 3.12141
-DEAL:cg::Convergence step 25 value 0
-DEAL:cg::Starting value 3.12141
-DEAL:cg::Convergence step 25 value 0
-DEAL::Sparse Factorization
-DEAL::absolute norms = 13.7931 13.7931
-DEAL::relative norm distance = 0
-DEAL::Block Sparse Factorization
-DEAL::absolute norms = 13.7931 13.7931
-DEAL::relative norm distance = 0
+++ /dev/null
-
-DEAL::1d
-DEAL::Number of dofs = 97
-DEAL:cg::Starting value 0.215517
-DEAL:cg::Convergence step 113 value 0
-DEAL:cg::Starting value 0.215517
-DEAL:cg::Convergence step 113 value 0
-DEAL::Sparse Factorization
-DEAL::absolute norms = 6.45748 6.45748
-DEAL::relative norm distance = 0
-DEAL::Block Sparse Factorization
-DEAL::absolute norms = 6.45748 6.45748
-DEAL::relative norm distance = 0
-DEAL::2d
-DEAL::Number of dofs = 994
-DEAL:cg::Starting value 0.595296
-DEAL:cg::Convergence step 61 value 0
-DEAL:cg::Starting value 0.595296
-DEAL:cg::Convergence step 61 value 0
-DEAL::Sparse Factorization
-DEAL::absolute norms = 10.0596 10.0596
-DEAL::relative norm distance = 0
-DEAL::Block Sparse Factorization
-DEAL::absolute norms = 10.0596 10.0596
-DEAL::relative norm distance = 0
-DEAL::3d
-DEAL::Number of dofs = 669
-DEAL:cg::Starting value 3.12141
-DEAL:cg::Convergence step 25 value 0
-DEAL:cg::Starting value 3.12141
-DEAL:cg::Convergence step 25 value 0
-DEAL::Sparse Factorization
-DEAL::absolute norms = 13.7931 13.7931
-DEAL::relative norm distance = 0
-DEAL::Block Sparse Factorization
-DEAL::absolute norms = 13.7931 13.7931
-DEAL::relative norm distance = 0
DEAL::1d
DEAL::Number of dofs = 97
-DEAL:cg::Starting value 0.215517
-DEAL:cg::Convergence step 113 value 0
-DEAL:cg::Starting value 0.215517
-DEAL:cg::Convergence step 113 value 0
+DEAL::Solver stopped within 112 - 114 iterations
+DEAL::Solver stopped within 112 - 114 iterations
DEAL::Sparse Factorization
DEAL::absolute norms = 6.45748 6.45748
DEAL::relative norm distance = 0
DEAL::relative norm distance = 0
DEAL::2d
DEAL::Number of dofs = 994
-DEAL:cg::Starting value 0.595296
-DEAL:cg::Convergence step 61 value 0
-DEAL:cg::Starting value 0.595296
-DEAL:cg::Convergence step 61 value 0
+DEAL::Solver stopped within 60 - 62 iterations
+DEAL::Solver stopped within 60 - 62 iterations
DEAL::Sparse Factorization
DEAL::absolute norms = 10.0596 10.0596
DEAL::relative norm distance = 0
DEAL::relative norm distance = 0
DEAL::3d
DEAL::Number of dofs = 669
-DEAL:cg::Starting value 3.12141
-DEAL:cg::Convergence step 25 value 0
-DEAL:cg::Starting value 3.12141
-DEAL:cg::Convergence step 25 value 0
+DEAL::Solver stopped within 24 - 26 iterations
+DEAL::Solver stopped within 24 - 26 iterations
DEAL::Sparse Factorization
DEAL::absolute norms = 13.7931 13.7931
DEAL::relative norm distance = 0