From 469a490b48f5a9070bbe43ab5c0b04acd65b2331 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 16 Oct 2014 10:27:11 -0500 Subject: [PATCH] Introduce signals into the Solver base class. This patch uses signals to determine whether a current iterate satisfies the convergence criterion. Currently, the only slot that is connected to a signal is the SolverControl::check() function, but users will be able to connect different slots there as well, closely monitoring the convergence process. Adjust the testcases. --- include/deal.II/lac/eigen.h | 28 ++-- include/deal.II/lac/solver.h | 134 +++++++++++++++--- include/deal.II/lac/solver_bicgstab.h | 75 +++++++--- include/deal.II/lac/solver_cg.h | 20 +-- include/deal.II/lac/solver_gmres.h | 59 ++++---- include/deal.II/lac/solver_minres.h | 13 +- include/deal.II/lac/solver_qmrs.h | 67 ++++++--- include/deal.II/lac/solver_relaxation.h | 10 +- include/deal.II/lac/solver_richardson.h | 34 +++-- tests/bits/deal_solver_04.cc | 10 +- tests/bits/deal_solver_05.cc | 10 +- tests/lac/solver.output | 22 +-- tests/lapack/solver_cg.output | 2 +- tests/petsc/deal_solver_01.cc | 10 +- tests/petsc/deal_solver_02.cc | 12 +- tests/petsc/deal_solver_03.cc | 10 +- tests/petsc/deal_solver_04.cc | 10 +- tests/petsc/deal_solver_05.cc | 10 +- tests/petsc/solver_01.cc | 10 +- tests/petsc/solver_02.cc | 10 +- tests/petsc/solver_03.cc | 10 +- tests/petsc/solver_03_mf.cc | 10 +- .../petsc/solver_03_precondition_boomeramg.cc | 10 +- ...ver_03_precondition_boomeramg_symmetric.cc | 10 +- .../petsc/solver_03_precondition_eisenstat.cc | 10 +- tests/petsc/solver_03_precondition_icc.cc | 10 +- tests/petsc/solver_03_precondition_ilu.cc | 10 +- tests/petsc/solver_03_precondition_lu.cc | 12 +- .../petsc/solver_03_precondition_parasails.cc | 10 +- tests/petsc/solver_03_precondition_sor.cc | 10 +- tests/petsc/solver_03_precondition_ssor.cc | 10 +- tests/petsc/solver_04.cc | 10 +- tests/petsc/solver_05.cc | 10 +- tests/petsc/solver_06.cc | 10 +- tests/petsc/solver_07.cc | 10 +- tests/petsc/solver_08.cc | 10 +- tests/petsc/solver_09.cc | 10 +- tests/petsc/solver_10.cc | 10 +- tests/petsc/solver_11.cc | 10 +- tests/petsc/solver_12.cc | 12 +- tests/petsc/solver_13.cc | 12 +- tests/petsc/sparse_direct_mumps.cc | 24 +--- tests/trilinos/deal_solver_01.cc | 10 +- tests/trilinos/deal_solver_02.cc | 12 +- tests/trilinos/deal_solver_03.cc | 10 +- tests/trilinos/deal_solver_04.cc | 10 +- tests/trilinos/deal_solver_05.cc | 10 +- tests/trilinos/deal_solver_06.cc | 10 +- tests/trilinos/solver_03.cc | 10 +- tests/trilinos/solver_05.cc | 10 +- tests/trilinos/solver_07.cc | 10 +- 51 files changed, 565 insertions(+), 323 deletions(-) diff --git a/include/deal.II/lac/eigen.h b/include/deal.II/lac/eigen.h index 7fbe6320a1..aa03e5ad84 100644 --- a/include/deal.II/lac/eigen.h +++ b/include/deal.II/lac/eigen.h @@ -273,7 +273,8 @@ EigenPower::solve (double &value, A.vmult (y,x); // Main loop - for (int iter=0; conv==SolverControl::iterate; iter++) + int iter=0; + for (; conv==SolverControl::iterate; iter++) { y.add(additional_data.shift, x); @@ -307,7 +308,7 @@ EigenPower::solve (double &value, // Check the change of the eigenvalue // Brrr, this is not really a good criterion - conv = this->control().check (iter, std::fabs(1./length-1./old_length)); + conv = this->iteration_status (iter, std::fabs(1./length-1./old_length), x); } this->memory.free(Vy); @@ -316,9 +317,9 @@ EigenPower::solve (double &value, deallog.pop(); // in case of failure: throw exception - if (this->control().last_check() != SolverControl::success) - AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value())); + AssertThrow(conv == SolverControl::success, SolverControl::NoConvergence (iter, + std::fabs(1./length-1./old_length))); + // otherwise exit as normal } @@ -378,7 +379,9 @@ EigenInverse::solve (double &value, x.scale(1./length); // Main loop - for (size_type iter=0; conv==SolverControl::iterate; iter++) + double res = -std::numeric_limits::max(); + size_type iter=0; + for (; conv==SolverControl::iterate; iter++) { solver.solve (A_s, y, x, prec); @@ -420,13 +423,14 @@ EigenInverse::solve (double &value, y.equ (value, x); A.vmult(r,x); r.sadd(-1., value, x); - double res = r.l2_norm(); + res = r.l2_norm(); // Check the residual - conv = this->control().check (iter, res); + conv = this->iteration_status (iter, res, x); } else { - conv = this->control().check (iter, std::fabs(1./value-1./old_value)); + res = std::fabs(1./value-1./old_value); + conv = this->iteration_status (iter, res, x); } old_value = value; } @@ -438,9 +442,9 @@ EigenInverse::solve (double &value, // in case of failure: throw // exception - if (this->control().last_check() != SolverControl::success) - throw SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value()); + AssertThrow (conv == SolverControl::success, + SolverControl::NoConvergence (iter, + res)); // otherwise exit as normal } diff --git a/include/deal.II/lac/solver.h b/include/deal.II/lac/solver.h index 748e748eec..327f7e4e6f 100644 --- a/include/deal.II/lac/solver.h +++ b/include/deal.II/lac/solver.h @@ -19,11 +19,13 @@ #include #include #include +#include + +#include DEAL_II_NAMESPACE_OPEN template class Vector; -class SolverControl; /** * A base class for iterative linear solvers. This class @@ -192,12 +194,6 @@ public: */ Solver (SolverControl &solver_control); - /** - * Return a reference to the object that controls - * convergence. - */ - SolverControl &control() const; - protected: /** * A static vector memory object @@ -208,27 +204,120 @@ protected: mutable GrowingVectorMemory static_vector_memory; /** - * Reference to the object that determines convergence. + * A reference to an object that provides memory for auxiliary vectors. */ - SolverControl &cntrl; + VectorMemory &memory; +private: /** - * A reference to an object that provides memory for auxiliary vectors. + * A class whose operator() combines two states indicating whether + * we should continue iterating or stop, and returns a state that + * dominates. The rules are: + * - If one of the two states indicates failure, return failure. + * - Otherwise, if one of the two states indicates to continue + * iterating, then continue iterating. + * - Otherwise, return success. */ - VectorMemory &memory; + struct StateCombiner + { + typedef SolverControl::State result_type; + + SolverControl::State operator() (const SolverControl::State state1, + const SolverControl::State state2) const; + + template + SolverControl::State operator() (const Iterator begin, + const Iterator end) const; + }; + +protected: + /** + * A signal that iterative solvers can execute at the end of every + * iteration (or in an otherwise periodic fashion) to find out whether + * we should continue iterating or not. The signal may call one or + * more slots that each will make this determination by themselves, + * and the result over all slots (function calls) will be determined + * by the StateCombiner object. + * + * The arguments passed to the signal are (i) the number of the current + * iteration; (ii) the value that is used to determine convergence (oftentimes + * the residual, but in other cases other quantities may be used as long + * as they converge to zero as the iterate approaches the solution of + * the linear system); and (iii) a vector that corresponds to the current + * best guess for the solution at the point where the signal is called. + * Note that some solvers do not update the approximate solution in every + * iteration but only after convergence or failure has been determined + * (GMRES is an example); in such cases, the vector passed as the last + * argument to the signal is simply the best approximate at the time + * the signal is called, but not the vector that will be returned if + * the signal's return value indicates that the iteration should be + * terminated. + */ + boost::signals2::signal iteration_status; }; /*-------------------------------- Inline functions ------------------------*/ + +template +inline +SolverControl::State +Solver::StateCombiner::operator ()(const SolverControl::State state1, + const SolverControl::State state2) const +{ + if ((state1 == SolverControl::failure) + || + (state2 == SolverControl::failure)) + return SolverControl::failure; + else if ((state1 == SolverControl::iterate) + || + (state2 == SolverControl::iterate)) + return SolverControl::iterate; + else + return SolverControl::success; +} + + +template +template +inline +SolverControl::State +Solver::StateCombiner::operator ()(const Iterator begin, + const Iterator end) const +{ + Assert (begin != end, ExcMessage ("You can't combine iterator states if no state is given.")); + + // combine the first with all of the following states + SolverControl::State state = *begin; + Iterator p = begin; + ++p; + for (; p != end; ++p) + state = this->operator()(state, *p); + + return state; +} + + template inline Solver::Solver (SolverControl &solver_control, VectorMemory &vector_memory) : - cntrl(solver_control), memory(vector_memory) -{} +{ + // connect the solver control object to the signal. SolverControl::check + // only takes two arguments, the iteration and the check_value, and so + // we simply ignore the third argument that is passed in whenever the + // signal is executed + iteration_status.connect (std_cxx11::bind(&SolverControl::check, + std_cxx11::ref(solver_control), + std_cxx11::_1, + std_cxx11::_2)); +} @@ -236,18 +325,17 @@ template inline Solver::Solver (SolverControl &solver_control) : - cntrl(solver_control), + // use the static memory object this class owns memory(static_vector_memory) -{} - - - -template -inline -SolverControl & -Solver::control() const { - return cntrl; + // connect the solver control object to the signal. SolverControl::check + // only takes two arguments, the iteration and the check_value, and so + // we simply ignore the third argument that is passed in whenever the + // signal is executed + iteration_status.connect (std_cxx11::bind(&SolverControl::check, + std_cxx11::ref(solver_control), + std_cxx11::_1, + std_cxx11::_2)); } diff --git a/include/deal.II/lac/solver_bicgstab.h b/include/deal.II/lac/solver_bicgstab.h index 5041c67c19..bde7fc7353 100644 --- a/include/deal.II/lac/solver_bicgstab.h +++ b/include/deal.II/lac/solver_bicgstab.h @@ -226,12 +226,30 @@ private: SolverControl::State start(const MATRIX &A); /** - * The iteration loop itself. + * A structure returned by the iterate() function representing + * what it found is happening during the iteration. */ - template - bool - iterate(const MATRIX &A, const PRECONDITIONER &precondition); + struct IterationResult + { + bool breakdown; + SolverControl::State state; + unsigned int last_step; + double last_residual; + + IterationResult (const bool breakdown, + const SolverControl::State state, + const unsigned int last_step, + const double last_residual); + }; + /** + * The iteration loop itself. The function returns a structure + * indicating what happened in this function. + */ + template + IterationResult + iterate(const MATRIX &A, + const PRECONDITIONER &precondition); }; /*@}*/ @@ -239,6 +257,20 @@ private: #ifndef DOXYGEN + +template +SolverBicgstab::IterationResult::IterationResult(const bool breakdown, + const SolverControl::State state, + const unsigned int last_step, + const double last_residual) + : + breakdown (breakdown), + state (state), + last_step (last_step), + last_residual (last_residual) +{} + + template SolverBicgstab::SolverBicgstab (SolverControl &cn, VectorMemory &mem, @@ -289,7 +321,7 @@ SolverBicgstab::start(const MATRIX &A) Vr->sadd(-1.,1.,*Vb); res = Vr->l2_norm(); - return this->control().check(step, res); + return this->iteration_status(step, res, *Vx); } @@ -306,7 +338,7 @@ SolverBicgstab::print_vectors(const unsigned int, template template -bool +typename SolverBicgstab::IterationResult SolverBicgstab::iterate(const MATRIX &A, const PRECONDITIONER &precondition) { @@ -349,17 +381,22 @@ SolverBicgstab::iterate(const MATRIX &A, //TODO:[?] Find better breakdown criterion if (std::fabs(alpha) > 1.e10) - return true; + return IterationResult(true, state, step, res); r.add(-alpha, v); // check for early success, see the lac/bicgstab_early testcase as to // why this is necessary - if (this->control().check(step, r.l2_norm()) == SolverControl::success) + // + // note: the vector *Vx we pass to the iteration_status signal here is only + // the current approximation, not the one we will return with, + // which will be x=*Vx + alpha*y + res = r.l2_norm(); + if (this->iteration_status(step, res, *Vx) == SolverControl::success) { Vx->add(alpha, y); print_vectors(step, *Vx, r, y); - return false; + return IterationResult(false, SolverControl::success, step, res); } precondition.vmult(z,r); @@ -374,11 +411,11 @@ SolverBicgstab::iterate(const MATRIX &A, else res = r.l2_norm(); - state = this->control().check(step, res); + state = this->iteration_status(step, res, *Vx); print_vectors(step, *Vx, r, y); } while (state == SolverControl::iterate); - return false; + return IterationResult(false, state, step, res); } @@ -411,17 +448,21 @@ SolverBicgstab::solve(const MATRIX &A, step = 0; - bool state; + IterationResult state(false,SolverControl::failure,0,0); + // iterate while the inner iteration returns a breakdown do { if (step != 0) deallog << "Restart step " << step << std::endl; if (start(A) == SolverControl::success) - break; + { + state.state = SolverControl::success; + break; + } state = iterate(A, precondition); } - while (state); + while (state.breakdown == true); this->memory.free(Vr); this->memory.free(Vrbar); @@ -434,9 +475,9 @@ SolverBicgstab::solve(const MATRIX &A, deallog.pop(); // in case of failure: throw exception - if (this->control().last_check() != SolverControl::success) - AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value())); + AssertThrow(state.state == SolverControl::success, + SolverControl::NoConvergence (state.last_step, + state.last_residual)); // otherwise exit as normal } diff --git a/include/deal.II/lac/solver_cg.h b/include/deal.II/lac/solver_cg.h index 9f57f28127..515af42a24 100644 --- a/include/deal.II/lac/solver_cg.h +++ b/include/deal.II/lac/solver_cg.h @@ -332,6 +332,9 @@ SolverCG::solve (const MATRIX &A, std::vector diagonal; std::vector offdiagonal; + int it=0; + double res = -std::numeric_limits::max(); + try { // define some aliases for simpler access @@ -344,10 +347,8 @@ SolverCG::solve (const MATRIX &A, g.reinit(x, true); d.reinit(x, true); h.reinit(x, true); - // Implementation taken from the DEAL - // library - int it=0; - double res,gh,alpha,beta; + + double gh,alpha,beta; // compute residual. if vector is // zero, then short-circuit the @@ -361,8 +362,8 @@ SolverCG::solve (const MATRIX &A, g.equ(-1.,b); res = g.l2_norm(); - conv = this->control().check(0,res); - if (conv) + conv = this->iteration_status(0, res, x); + if (conv != SolverControl::iterate) { cleanup(); return; @@ -397,7 +398,7 @@ SolverCG::solve (const MATRIX &A, print_vectors(it, x, g, d); - conv = this->control().check(it,res); + conv = this->iteration_status(it, res, x); if (conv != SolverControl::iterate) break; @@ -481,9 +482,8 @@ SolverCG::solve (const MATRIX &A, // Deallocate Memory cleanup(); // in case of failure: throw exception - if (this->control().last_check() != SolverControl::success) - AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value())); + if (conv != SolverControl::success) + AssertThrow(false, SolverControl::NoConvergence (it, res)); // otherwise exit as normal } diff --git a/include/deal.II/lac/solver_gmres.h b/include/deal.II/lac/solver_gmres.h index 9e4d933325..d01eeb84ef 100644 --- a/include/deal.II/lac/solver_gmres.h +++ b/include/deal.II/lac/solver_gmres.h @@ -623,6 +623,7 @@ SolverGMRES::solve (const MATRIX &A, unsigned int dim = 0; SolverControl::State iteration_state = SolverControl::iterate; + double last_res = -std::numeric_limits::max(); // switch to determine whether we want a left or a right preconditioner. at // present, left is default, but both ways are implemented @@ -683,8 +684,8 @@ SolverGMRES::solve (const MATRIX &A, // check here, the next scaling operation would produce garbage if (use_default_residual) { - iteration_state = this->control().check ( - accumulated_iterations, rho); + last_res = rho; + iteration_state = this->iteration_status (accumulated_iterations, rho, x); if (iteration_state != SolverControl::iterate) break; @@ -702,8 +703,8 @@ SolverGMRES::solve (const MATRIX &A, precondition.vmult(*r,v); double res = r->l2_norm(); - iteration_state = this->control().check ( - accumulated_iterations, res); + last_res = res; + iteration_state = this->iteration_status (accumulated_iterations, res, x); if (iteration_state != SolverControl::iterate) { @@ -741,7 +742,7 @@ SolverGMRES::solve (const MATRIX &A, { precondition.vmult(p, tmp_vectors[inner_iteration]); A.vmult(vv,p); - }; + } dim = inner_iteration+1; @@ -761,7 +762,7 @@ SolverGMRES::solve (const MATRIX &A, for (unsigned int i=0; i::solve (const MATRIX &A, rho = std::fabs(gamma(dim)); if (use_default_residual) - iteration_state = this->control().check ( - accumulated_iterations, rho); + { + last_res = rho; + iteration_state = this->iteration_status (accumulated_iterations, rho, x); + } else { deallog << "default_res=" << rho << std::endl; @@ -806,17 +809,18 @@ SolverGMRES::solve (const MATRIX &A, if (left_precondition) { const double res=r->l2_norm(); + last_res = res; - iteration_state = this->control().check ( - accumulated_iterations, res); + iteration_state = this->iteration_status (accumulated_iterations, res, x); } else { precondition.vmult(*x_, *r); const double preconditioned_res=x_->l2_norm(); + last_res = preconditioned_res; - iteration_state = this->control().check ( - accumulated_iterations, preconditioned_res); + iteration_state = this->iteration_status (accumulated_iterations, + preconditioned_res, x); } } }; @@ -878,11 +882,11 @@ SolverGMRES::solve (const MATRIX &A, } deallog.pop(); + // in case of failure: throw exception - if (this->control().last_check() != SolverControl::success) - AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value())); - // otherwise exit as normal + AssertThrow(iteration_state == SolverControl::success, + SolverControl::NoConvergence (accumulated_iterations, + last_res)); } @@ -952,6 +956,7 @@ SolverFGMRES::solve ( Vector y; // Iteration starts here + double res = -std::numeric_limits::max(); VECTOR *aux = this->memory.alloc(); aux->reinit(x); @@ -961,8 +966,9 @@ SolverFGMRES::solve ( aux->sadd(-1., 1., b); double beta = aux->l2_norm(); - if (this->control().check(accumulated_iterations,beta) - == SolverControl::success) + res = beta; + iteration_state = this->iteration_status(accumulated_iterations, res, x); + if (iteration_state == SolverControl::success) break; H.reinit(basis_size+1, basis_size); @@ -996,17 +1002,22 @@ SolverFGMRES::solve ( y.reinit(j); projected_rhs(0) = beta; H1.fill(H); + + // check convergence. note that the vector 'x' we pass to the + // criterion is not the final solution we compute if we + // decide to jump out of the iteration (we update 'x' again + // right after the current loop) Householder house(H1); - double res = house.least_squares(y, projected_rhs); - iteration_state = this->control().check(++accumulated_iterations, res); + res = house.least_squares(y, projected_rhs); + iteration_state = this->iteration_status(++accumulated_iterations, res, x); if (iteration_state != SolverControl::iterate) break; } } + // Update solution vector for (unsigned int j=0; j::solve ( deallog.pop(); // in case of failure: throw exception - if (this->control().last_check() != SolverControl::success) - AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value())); + if (iteration_state != SolverControl::success) + AssertThrow(false, SolverControl::NoConvergence (accumulated_iterations, + res)); } #endif // DOXYGEN diff --git a/include/deal.II/lac/solver_minres.h b/include/deal.II/lac/solver_minres.h index 72a830adc1..66bbf5ae5d 100644 --- a/include/deal.II/lac/solver_minres.h +++ b/include/deal.II/lac/solver_minres.h @@ -281,7 +281,7 @@ SolverMinRes::solve (const MATRIX &A, m[1]->reinit(b); m[2]->reinit(b); - conv = this->control().check(0,r_l2); + conv = this->iteration_status(0, r_l2, x); while (conv==SolverControl::iterate) { @@ -321,7 +321,8 @@ SolverMinRes::solve (const MATRIX &A, d = std::sqrt (d_*d_ + delta[2]); - if (j>1) tau *= s / c; + if (j>1) + tau *= s / c; c = d_ / d; tau *= c; @@ -337,7 +338,7 @@ SolverMinRes::solve (const MATRIX &A, x.add (tau, *m[0]); r_l2 *= std::fabs(s); - conv = this->control().check(j,r_l2); + conv = this->iteration_status(j, r_l2, x); // next iteration step ++j; @@ -380,9 +381,9 @@ SolverMinRes::solve (const MATRIX &A, deallog.pop (); // in case of failure: throw exception - if (this->control().last_check() != SolverControl::success) - AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value())); + AssertThrow(conv == SolverControl::success, + SolverControl::NoConvergence (j, r_l2)); + // otherwise exit as normal } diff --git a/include/deal.II/lac/solver_qmrs.h b/include/deal.II/lac/solver_qmrs.h index 545804866a..cbd3234c1c 100644 --- a/include/deal.II/lac/solver_qmrs.h +++ b/include/deal.II/lac/solver_qmrs.h @@ -189,19 +189,39 @@ protected: * the square root of the @p res2 value. */ double res2; + /** - * Additional parameters.. + * Additional parameters. */ AdditionalData additional_data; + private: + + /** + * A structure returned by the iterate() function representing + * what it found is happening during the iteration. + */ + struct IterationResult + { + SolverControl::State state; + double last_residual; + + IterationResult (const SolverControl::State state, + const double last_residual); + }; + + /** - * The iteration loop itself. + * The iteration loop itself. The function returns a structure + * indicating what happened in this function. */ template - bool - iterate(const MATRIX &A, const PRECONDITIONER &precondition); + IterationResult + iterate (const MATRIX &A, + const PRECONDITIONER &precondition); + /** - * The current iteration step. + * Number of the current iteration (accumulated over restarts) */ unsigned int step; }; @@ -211,6 +231,15 @@ private: #ifndef DOXYGEN +template +SolverQMRS::IterationResult::IterationResult(const SolverControl::State state, + const double last_residual) + : + state (state), + last_residual (last_residual) +{} + + template SolverQMRS::SolverQMRS(SolverControl &cn, VectorMemory &mem, @@ -280,15 +309,15 @@ SolverQMRS::solve (const MATRIX &A, step = 0; - bool state; + IterationResult state (SolverControl::failure,0); do { - if (step) + if (step > 0) deallog << "Restart step " << step << std::endl; state = iterate(A, precondition); } - while (state); + while (state.state == SolverControl::iterate); // Deallocate Memory this->memory.free(Vv); @@ -301,9 +330,9 @@ SolverQMRS::solve (const MATRIX &A, deallog.pop(); // in case of failure: throw exception - if (this->control().last_check() != SolverControl::success) - AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value())); + AssertThrow(state.state == SolverControl::success, + SolverControl::NoConvergence (step, + state.last_residual)); // otherwise exit as normal } @@ -311,7 +340,7 @@ SolverQMRS::solve (const MATRIX &A, template template -bool +typename SolverQMRS::IterationResult SolverQMRS::iterate(const MATRIX &A, const PRECONDITIONER &precondition) { @@ -346,8 +375,8 @@ SolverQMRS::iterate(const MATRIX &A, v.sadd(-1.,1.,b); res = v.l2_norm(); - if (this->control().check(step, res) == SolverControl::success) - return false; + if (this->iteration_status(step, res, x) == SolverControl::success) + return IterationResult(SolverControl::success, res); p = v; @@ -367,7 +396,7 @@ SolverQMRS::iterate(const MATRIX &A, //TODO:[?] Find a really good breakdown criterion. The absolute one detects breakdown instead of convergence if (std::fabs(sigma/rho) < additional_data.breakdown) - return true; + return IterationResult(SolverControl::iterate, std::fabs(sigma/rho)); // Step 3 alpha = rho/sigma; @@ -391,13 +420,13 @@ SolverQMRS::iterate(const MATRIX &A, } else res = std::sqrt((it+1)*tau); - state = this->control().check(step,res); + state = this->iteration_status(step,res,x); if ((state == SolverControl::success) || (state == SolverControl::failure)) - return false; + return IterationResult(state, res); // Step 6 if (std::fabs(rho) < additional_data.breakdown) - return true; + return IterationResult(SolverControl::iterate, std::fabs(rho)); // Step 7 rho_old = rho; precondition.vmult(q,v); @@ -407,7 +436,7 @@ SolverQMRS::iterate(const MATRIX &A, p.sadd(beta,v); precondition.vmult(q,p); } - return false; + return IterationResult(SolverControl::success, std::fabs(rho)); } #endif // DOXYGEN diff --git a/include/deal.II/lac/solver_relaxation.h b/include/deal.II/lac/solver_relaxation.h index 491f8afd0f..22e40e8e2a 100644 --- a/include/deal.II/lac/solver_relaxation.h +++ b/include/deal.II/lac/solver_relaxation.h @@ -122,10 +122,11 @@ SolverRelaxation::solve ( deallog.push("Relaxation"); + int iter=0; try { // Main loop - for (int iter=0; conv==SolverControl::iterate; iter++) + for (; conv==SolverControl::iterate; iter++) { // Compute residual A.vmult(r,x); @@ -136,7 +137,7 @@ SolverRelaxation::solve ( // residual is computed in // criterion() and stored // in res. - conv = this->control().check (iter, r.l2_norm()); + conv = this->iteration_status (iter, r.l2_norm(), x); if (conv != SolverControl::iterate) break; R.step(x,b); @@ -150,9 +151,8 @@ SolverRelaxation::solve ( deallog.pop(); // in case of failure: throw exception - if (this->control().last_check() != SolverControl::success) - AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value())); + AssertThrow(conv == SolverControl::success, + SolverControl::NoConvergence (iter, r.l2_norm())); // otherwise exit as normal } diff --git a/include/deal.II/lac/solver_richardson.h b/include/deal.II/lac/solver_richardson.h index 5ce4178a9f..9e2938227a 100644 --- a/include/deal.II/lac/solver_richardson.h +++ b/include/deal.II/lac/solver_richardson.h @@ -237,6 +237,10 @@ SolverRichardson::solve (const MATRIX &A, { SolverControl::State conv=SolverControl::iterate; + double last_criterion = -std::numeric_limits::max(); + + unsigned int iter = 0; + // Memory allocation Vr = this->memory.alloc(); VECTOR &r = *Vr; @@ -250,7 +254,7 @@ SolverRichardson::solve (const MATRIX &A, try { // Main loop - for (int iter=0; conv==SolverControl::iterate; iter++) + while (conv==SolverControl::iterate) { // Do not use residual, // but do it in 2 steps @@ -263,13 +267,15 @@ SolverRichardson::solve (const MATRIX &A, // residual is computed in // criterion() and stored // in res. - conv = this->control().check (iter, criterion()); -// conv = this->control().check (iter, std::sqrt(A.matrix_norm_square(r))); + last_criterion = criterion(); + conv = this->iteration_status (iter, last_criterion, x); if (conv != SolverControl::iterate) break; x.add(additional_data.omega,d); print_vectors(iter,x,r,d); + + ++iter; } } catch (...) @@ -285,9 +291,9 @@ SolverRichardson::solve (const MATRIX &A, deallog.pop(); // in case of failure: throw exception - if (this->control().last_check() != SolverControl::success) - AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value())); + if (conv != SolverControl::success) + AssertThrow(false, SolverControl::NoConvergence (iter, + last_criterion)); // otherwise exit as normal } @@ -301,6 +307,9 @@ SolverRichardson::Tsolve (const MATRIX &A, const PRECONDITIONER &precondition) { SolverControl::State conv=SolverControl::iterate; + double last_criterion = -std::numeric_limits::max(); + + unsigned int iter = 0; // Memory allocation Vr = this->memory.alloc(); @@ -315,7 +324,7 @@ SolverRichardson::Tsolve (const MATRIX &A, try { // Main loop - for (int iter=0; conv==SolverControl::iterate; iter++) + while (conv==SolverControl::iterate) { // Do not use Tresidual, // but do it in 2 steps @@ -323,12 +332,15 @@ SolverRichardson::Tsolve (const MATRIX &A, r.sadd(-1.,1.,b); precondition.Tvmult(d,r); - conv = this->control().check (iter, criterion()); + last_criterion = criterion(); + conv = this->iteration_status (iter, last_criterion, x); if (conv != SolverControl::iterate) break; x.add(additional_data.omega,d); print_vectors(iter,x,r,d); + + ++iter; } } catch (...) @@ -344,9 +356,9 @@ SolverRichardson::Tsolve (const MATRIX &A, this->memory.free(Vd); deallog.pop(); // in case of failure: throw exception - if (this->control().last_check() != SolverControl::success) - AssertThrow(false, SolverControl::NoConvergence (this->control().last_step(), - this->control().last_value())); + if (conv != SolverControl::success) + AssertThrow(false, SolverControl::NoConvergence (iter, last_criterion)); + // otherwise exit as normal } diff --git a/tests/bits/deal_solver_04.cc b/tests/bits/deal_solver_04.cc index 69f167dc77..ee108412eb 100644 --- a/tests/bits/deal_solver_04.cc +++ b/tests/bits/deal_solver_04.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -39,7 +39,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -56,7 +58,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -91,6 +93,6 @@ int main() SolverMinRes<> solver(control, mem); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } diff --git a/tests/bits/deal_solver_05.cc b/tests/bits/deal_solver_05.cc index 5154b08106..05c46a9ca5 100644 --- a/tests/bits/deal_solver_05.cc +++ b/tests/bits/deal_solver_05.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -38,7 +38,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -55,7 +57,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -90,6 +92,6 @@ int main() SolverQMRS<> solver(control, mem); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } diff --git a/tests/lac/solver.output b/tests/lac/solver.output index c5eda03ebd..d77ff53976 100644 --- a/tests/lac/solver.output +++ b/tests/lac/solver.output @@ -55,7 +55,7 @@ DEAL:sor:Richardson::Starting value 3.000 DEAL:sor:Richardson::Convergence step 7 value 0.0004339 DEAL:sor:cg::Starting value 3.000 DEAL:sor:cg::Failure step 100 value 0.2585 -DEAL:sor::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) +DEAL:sor::Exception: SolverControl::NoConvergence (it, res) DEAL:sor:Bicgstab::Starting value 3.000 DEAL:sor:Bicgstab::Convergence step 5 value 0 DEAL:sor:GMRES::Starting value 1.462 @@ -70,7 +70,7 @@ DEAL:psor:Richardson::Starting value 3.000 DEAL:psor:Richardson::Convergence step 8 value 0.0004237 DEAL:psor:cg::Starting value 3.000 DEAL:psor:cg::Failure step 100 value 0.1024 -DEAL:psor::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) +DEAL:psor::Exception: SolverControl::NoConvergence (it, res) DEAL:psor:Bicgstab::Starting value 3.000 DEAL:psor:Bicgstab::Convergence step 4 value 0.0007969 DEAL:psor:GMRES::Starting value 1.467 @@ -81,23 +81,23 @@ DEAL::Size 12 Unknowns 121 DEAL::SOR-diff:0 DEAL:no-fail:cg::Starting value 11.00 DEAL:no-fail:cg::Failure step 10 value 0.1496 -DEAL:no-fail::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) +DEAL:no-fail::Exception: SolverControl::NoConvergence (it, res) DEAL:no-fail:Bicgstab::Starting value 11.00 DEAL:no-fail:Bicgstab::Failure step 10 value 0.002830 DEAL:no-fail:Bicgstab::Failure step 10 value 0.001961 -DEAL:no-fail::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) +DEAL:no-fail::Exception: SolverControl::NoConvergence (state.last_step, state.last_residual) DEAL:no-fail:GMRES::Starting value 11.00 DEAL:no-fail:GMRES::Failure step 10 value 0.8414 -DEAL:no-fail::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) +DEAL:no-fail::Exception: SolverControl::NoConvergence (accumulated_iterations, last_res) DEAL:no-fail:GMRES::Starting value 11.00 DEAL:no-fail:GMRES::Failure step 10 value 0.8414 -DEAL:no-fail::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) +DEAL:no-fail::Exception: SolverControl::NoConvergence (accumulated_iterations, last_res) DEAL:no-fail:QMRS::Starting value 11.00 DEAL:no-fail:QMRS::Failure step 10 value 0.4215 -DEAL:no-fail::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) +DEAL:no-fail::Exception: SolverControl::NoConvergence (step, state.last_residual) DEAL:no:Richardson::Starting value 11.00 DEAL:no:Richardson::Failure step 100 value 0.3002 -DEAL:no::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) +DEAL:no::Exception: SolverControl::NoConvergence (iter, last_criterion) DEAL:no:cg::Starting value 11.00 DEAL:no:cg::Convergence step 15 value 0.0005794 DEAL:no:Bicgstab::Starting value 11.00 @@ -110,7 +110,7 @@ DEAL:no:QMRS::Starting value 11.00 DEAL:no:QMRS::Convergence step 16 value 0.0002583 DEAL:rich:Richardson::Starting value 11.00 DEAL:rich:Richardson::Failure step 100 value 1.219 -DEAL:rich::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) +DEAL:rich::Exception: SolverControl::NoConvergence (iter, last_criterion) DEAL:rich:cg::Starting value 11.00 DEAL:rich:cg::Convergence step 15 value 0.0005794 DEAL:rich:Bicgstab::Starting value 11.00 @@ -141,7 +141,7 @@ DEAL:sor:Richardson::Starting value 11.00 DEAL:sor:Richardson::Convergence step 88 value 0.0009636 DEAL:sor:cg::Starting value 11.00 DEAL:sor:cg::Failure step 100 value 5.643 -DEAL:sor::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) +DEAL:sor::Exception: SolverControl::NoConvergence (it, res) DEAL:sor:Bicgstab::Starting value 11.00 DEAL:sor:Bicgstab::Convergence step 14 value 0.0009987 DEAL:sor:GMRES::Starting value 7.322 @@ -154,7 +154,7 @@ DEAL:psor:Richardson::Starting value 11.00 DEAL:psor:Richardson::Convergence step 89 value 0.0009736 DEAL:psor:cg::Starting value 11.00 DEAL:psor:cg::Failure step 100 value 2.935 -DEAL:psor::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) +DEAL:psor::Exception: SolverControl::NoConvergence (it, res) DEAL:psor:Bicgstab::Starting value 11.00 DEAL:psor:Bicgstab::Convergence step 11 value 0.0005151 DEAL:psor:GMRES::Starting value 7.345 diff --git a/tests/lapack/solver_cg.output b/tests/lapack/solver_cg.output index a407848c23..609ea6e9a6 100644 --- a/tests/lapack/solver_cg.output +++ b/tests/lapack/solver_cg.output @@ -29,7 +29,7 @@ DEAL:no-fail:cg::Condition number estimate: 53.54 DEAL:no-fail:cg::Condition number estimate: 54.75 DEAL:no-fail:cg::Failure step 10 value 0.1496 DEAL:no-fail:cg:: 0.1363 0.6565 1.499 2.357 3.131 3.994 5.392 6.576 7.464 -DEAL:no-fail::Exception: SolverControl::NoConvergence (this->control().last_step(), this->control().last_value()) +DEAL:no-fail::Exception: SolverControl::NoConvergence (it, res) DEAL:no:cg::Starting value 11.00 DEAL:no:cg::Condition number estimate: 11.01 DEAL:no:cg::Condition number estimate: 21.10 diff --git a/tests/petsc/deal_solver_01.cc b/tests/petsc/deal_solver_01.cc index c0f4a69a4f..51fe084280 100644 --- a/tests/petsc/deal_solver_01.cc +++ b/tests/petsc/deal_solver_01.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -38,7 +38,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -55,7 +57,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -92,7 +94,7 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverCG solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } GrowingVectorMemory::release_unused_memory (); diff --git a/tests/petsc/deal_solver_02.cc b/tests/petsc/deal_solver_02.cc index c6ed17c75d..b45cb28dff 100644 --- a/tests/petsc/deal_solver_02.cc +++ b/tests/petsc/deal_solver_02.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -40,7 +40,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -60,7 +62,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - const unsigned int steps = solver.control().last_step(); + const unsigned int steps = solver_control.last_step(); if (steps >= 49 && steps <= 51) { deallog << "Solver stopped within 49 - 51 iterations" @@ -68,7 +70,7 @@ check_solve( SOLVER &solver, const MATRIX &A, } else { - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } } @@ -106,7 +108,7 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverBicgstab solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } GrowingVectorMemory::release_unused_memory (); diff --git a/tests/petsc/deal_solver_03.cc b/tests/petsc/deal_solver_03.cc index 87797610f4..3edb73d612 100644 --- a/tests/petsc/deal_solver_03.cc +++ b/tests/petsc/deal_solver_03.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -40,7 +40,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -57,7 +59,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -94,7 +96,7 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverGMRES solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } GrowingVectorMemory::release_unused_memory (); diff --git a/tests/petsc/deal_solver_04.cc b/tests/petsc/deal_solver_04.cc index 2ee73c6efc..d3f932664b 100644 --- a/tests/petsc/deal_solver_04.cc +++ b/tests/petsc/deal_solver_04.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -39,7 +39,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -56,7 +58,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -93,7 +95,7 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverMinRes solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } GrowingVectorMemory::release_unused_memory (); diff --git a/tests/petsc/deal_solver_05.cc b/tests/petsc/deal_solver_05.cc index b7c165cea8..ce225df08d 100644 --- a/tests/petsc/deal_solver_05.cc +++ b/tests/petsc/deal_solver_05.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -38,7 +38,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -55,7 +57,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -92,7 +94,7 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverQMRS solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } GrowingVectorMemory::release_unused_memory (); diff --git a/tests/petsc/solver_01.cc b/tests/petsc/solver_01.cc index 427c60fe5b..0294903e55 100644 --- a/tests/petsc/solver_01.cc +++ b/tests/petsc/solver_01.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -49,7 +51,7 @@ check_solve( SOLVER &solver, const MATRIX &A, deallog << "Exception: " << e.get_exc_name() << std::endl; } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -85,7 +87,7 @@ int main(int argc, char **argv) PETScWrappers::SolverRichardson solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_02.cc b/tests/petsc/solver_02.cc index 0a5caf7bed..372fe4acc7 100644 --- a/tests/petsc/solver_02.cc +++ b/tests/petsc/solver_02.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -52,7 +54,7 @@ check_solve( SOLVER &solver, const MATRIX &A, deallog << "Exception: " << e.get_exc_name() << std::endl; } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -88,7 +90,7 @@ int main(int argc, char **argv) PETScWrappers::SolverChebychev solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_03.cc b/tests/petsc/solver_03.cc index 4960762653..c8ba190a51 100644 --- a/tests/petsc/solver_03.cc +++ b/tests/petsc/solver_03.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -50,7 +52,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -86,7 +88,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_03_mf.cc b/tests/petsc/solver_03_mf.cc index 300a874561..ad3b8eae4c 100644 --- a/tests/petsc/solver_03_mf.cc +++ b/tests/petsc/solver_03_mf.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -51,7 +53,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -84,7 +86,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionNone preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_03_precondition_boomeramg.cc b/tests/petsc/solver_03_precondition_boomeramg.cc index 809d85534c..3952dd18c1 100644 --- a/tests/petsc/solver_03_precondition_boomeramg.cc +++ b/tests/petsc/solver_03_precondition_boomeramg.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -34,7 +34,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -51,7 +53,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -87,7 +89,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionBoomerAMG preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_03_precondition_boomeramg_symmetric.cc b/tests/petsc/solver_03_precondition_boomeramg_symmetric.cc index 7d40747ce6..c301083b4a 100644 --- a/tests/petsc/solver_03_precondition_boomeramg_symmetric.cc +++ b/tests/petsc/solver_03_precondition_boomeramg_symmetric.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -35,7 +35,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -52,7 +54,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -88,7 +90,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionBoomerAMG preconditioner(A, true); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_03_precondition_eisenstat.cc b/tests/petsc/solver_03_precondition_eisenstat.cc index 8c8e2fb76f..8528015206 100644 --- a/tests/petsc/solver_03_precondition_eisenstat.cc +++ b/tests/petsc/solver_03_precondition_eisenstat.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -50,7 +52,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -86,7 +88,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionEisenstat preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_03_precondition_icc.cc b/tests/petsc/solver_03_precondition_icc.cc index 2d8655d9ea..6f3fa7708a 100644 --- a/tests/petsc/solver_03_precondition_icc.cc +++ b/tests/petsc/solver_03_precondition_icc.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -50,7 +52,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -86,7 +88,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionICC preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_03_precondition_ilu.cc b/tests/petsc/solver_03_precondition_ilu.cc index b561b7473f..7d5ce9fe65 100644 --- a/tests/petsc/solver_03_precondition_ilu.cc +++ b/tests/petsc/solver_03_precondition_ilu.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -50,7 +52,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -85,7 +87,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionILU preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_03_precondition_lu.cc b/tests/petsc/solver_03_precondition_lu.cc index 2d01d1bc19..3bb0a590b4 100644 --- a/tests/petsc/solver_03_precondition_lu.cc +++ b/tests/petsc/solver_03_precondition_lu.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -34,7 +34,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -51,13 +53,13 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; // we use a direct solver as a // preconditioner. this should // converge in one step! - Assert (solver.control().last_step() == 1, + Assert (solver_control.last_step() == 1, ExcInternalError()); } @@ -93,7 +95,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionLU preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_03_precondition_parasails.cc b/tests/petsc/solver_03_precondition_parasails.cc index 2d2e253daf..def46b1520 100644 --- a/tests/petsc/solver_03_precondition_parasails.cc +++ b/tests/petsc/solver_03_precondition_parasails.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -50,7 +52,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -86,7 +88,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionParaSails preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_03_precondition_sor.cc b/tests/petsc/solver_03_precondition_sor.cc index c86ba4717a..ceab998ba0 100644 --- a/tests/petsc/solver_03_precondition_sor.cc +++ b/tests/petsc/solver_03_precondition_sor.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -50,7 +52,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -86,7 +88,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionSOR preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_03_precondition_ssor.cc b/tests/petsc/solver_03_precondition_ssor.cc index 3c8cda90c8..5f47ab3d90 100644 --- a/tests/petsc/solver_03_precondition_ssor.cc +++ b/tests/petsc/solver_03_precondition_ssor.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -50,7 +52,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -86,7 +88,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionSSOR preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_04.cc b/tests/petsc/solver_04.cc index fae99130b9..895845c74e 100644 --- a/tests/petsc/solver_04.cc +++ b/tests/petsc/solver_04.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -50,7 +52,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -86,7 +88,7 @@ int main(int argc, char **argv) PETScWrappers::SolverBiCG solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_05.cc b/tests/petsc/solver_05.cc index 08086eb5e9..c88c9e4786 100644 --- a/tests/petsc/solver_05.cc +++ b/tests/petsc/solver_05.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -50,7 +52,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -86,7 +88,7 @@ int main(int argc, char **argv) PETScWrappers::SolverGMRES solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_06.cc b/tests/petsc/solver_06.cc index 3691b25164..1a81d8e151 100644 --- a/tests/petsc/solver_06.cc +++ b/tests/petsc/solver_06.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -53,7 +55,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -89,7 +91,7 @@ int main(int argc, char **argv) PETScWrappers::SolverBicgstab solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_07.cc b/tests/petsc/solver_07.cc index 1759d9fdea..6d677ade05 100644 --- a/tests/petsc/solver_07.cc +++ b/tests/petsc/solver_07.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -50,7 +52,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -86,7 +88,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCGS solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_08.cc b/tests/petsc/solver_08.cc index adb44ad96c..4b749fd338 100644 --- a/tests/petsc/solver_08.cc +++ b/tests/petsc/solver_08.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -50,7 +52,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -86,7 +88,7 @@ int main(int argc, char **argv) PETScWrappers::SolverTFQMR solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_09.cc b/tests/petsc/solver_09.cc index db5e6923b2..08520c11ba 100644 --- a/tests/petsc/solver_09.cc +++ b/tests/petsc/solver_09.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -37,7 +37,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -54,7 +56,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -90,7 +92,7 @@ int main(int argc, char **argv) PETScWrappers::SolverTCQMR solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_10.cc b/tests/petsc/solver_10.cc index ceda168292..5fc7cd7efc 100644 --- a/tests/petsc/solver_10.cc +++ b/tests/petsc/solver_10.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -50,7 +52,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -86,7 +88,7 @@ int main(int argc, char **argv) PETScWrappers::SolverCR solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_11.cc b/tests/petsc/solver_11.cc index 5986f7d370..c22613b528 100644 --- a/tests/petsc/solver_11.cc +++ b/tests/petsc/solver_11.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -54,7 +56,7 @@ check_solve( SOLVER &solver, const MATRIX &A, deallog << "Catched exception dealii::SolverControl::NoConvergence" << std::endl; } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -90,7 +92,7 @@ int main(int argc, char **argv) PETScWrappers::SolverLSQR solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_12.cc b/tests/petsc/solver_12.cc index 1d20e891ae..b0c4032d39 100644 --- a/tests/petsc/solver_12.cc +++ b/tests/petsc/solver_12.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,7 +33,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -43,7 +45,7 @@ check_solve( SOLVER &solver, const MATRIX &A, solver.solve(A,u,f,P); - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -80,10 +82,10 @@ int main(int argc, char **argv) PETScWrappers::SolverPreOnly solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); //run twice because this errored out at some point - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/petsc/solver_13.cc b/tests/petsc/solver_13.cc index e8906cb980..50909db7cd 100644 --- a/tests/petsc/solver_13.cc +++ b/tests/petsc/solver_13.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,14 +33,16 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; solver.solve(A,u,f,P); - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -80,11 +82,11 @@ int main(int argc, char **argv) PETScWrappers::PreconditionJacobi preconditioner(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); deallog << u.l2_norm() << std::endl; - check_solve (solver, A,t,u, preconditioner); + check_solve (solver, control, A,t,u, preconditioner); deallog << t.l2_norm() << std::endl; diff --git a/tests/petsc/sparse_direct_mumps.cc b/tests/petsc/sparse_direct_mumps.cc index dd74621ead..4670fb127e 100644 --- a/tests/petsc/sparse_direct_mumps.cc +++ b/tests/petsc/sparse_direct_mumps.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -31,28 +31,6 @@ #include #include -template -void -check_solve( SOLVER &solver, const MATRIX &A, - VECTOR &u, VECTOR &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) diff --git a/tests/trilinos/deal_solver_01.cc b/tests/trilinos/deal_solver_01.cc index 6f8fbb5666..b77cb5a86a 100644 --- a/tests/trilinos/deal_solver_01.cc +++ b/tests/trilinos/deal_solver_01.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -39,7 +39,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -56,7 +58,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -98,7 +100,7 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverCG solver(control, mem); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/trilinos/deal_solver_02.cc b/tests/trilinos/deal_solver_02.cc index 18da9f9cd5..6457179c2e 100644 --- a/tests/trilinos/deal_solver_02.cc +++ b/tests/trilinos/deal_solver_02.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -41,7 +41,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -61,7 +63,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - const unsigned int steps = solver.control().last_step(); + const unsigned int steps = solver_control.last_step(); if (steps >= 49 && steps <= 51) { deallog << "Solver stopped within 49 - 51 iterations" @@ -69,7 +71,7 @@ check_solve( SOLVER &solver, const MATRIX &A, } else { - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } } @@ -112,7 +114,7 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverBicgstab solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/trilinos/deal_solver_03.cc b/tests/trilinos/deal_solver_03.cc index 40a1f3e125..b62bffd74c 100644 --- a/tests/trilinos/deal_solver_03.cc +++ b/tests/trilinos/deal_solver_03.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -41,7 +41,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -58,7 +60,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -100,7 +102,7 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverGMRES solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/trilinos/deal_solver_04.cc b/tests/trilinos/deal_solver_04.cc index 44a3b8d4ca..eb9c9baa58 100644 --- a/tests/trilinos/deal_solver_04.cc +++ b/tests/trilinos/deal_solver_04.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -40,7 +40,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -57,7 +59,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -99,7 +101,7 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverMinRes solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/trilinos/deal_solver_05.cc b/tests/trilinos/deal_solver_05.cc index e1140b2571..7c1f701861 100644 --- a/tests/trilinos/deal_solver_05.cc +++ b/tests/trilinos/deal_solver_05.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -39,7 +39,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -56,7 +58,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -98,7 +100,7 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverQMRS solver(control,mem); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/trilinos/deal_solver_06.cc b/tests/trilinos/deal_solver_06.cc index 8ca8def3a2..13fd553254 100644 --- a/tests/trilinos/deal_solver_06.cc +++ b/tests/trilinos/deal_solver_06.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -39,7 +39,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -55,7 +57,7 @@ check_solve( SOLVER &solver, const MATRIX &A, deallog << e.what() << std::endl; } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -96,7 +98,7 @@ int main(int argc, char **argv) GrowingVectorMemory mem; SolverRichardson solver(control,mem,0.1); PreconditionIdentity preconditioner; - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/trilinos/solver_03.cc b/tests/trilinos/solver_03.cc index 38eb27cb01..f551e9ce51 100644 --- a/tests/trilinos/solver_03.cc +++ b/tests/trilinos/solver_03.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -34,7 +34,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -51,7 +53,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -93,7 +95,7 @@ int main(int argc, char **argv) TrilinosWrappers::SolverCG solver(control); TrilinosWrappers::PreconditionJacobi preconditioner; preconditioner.initialize(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/trilinos/solver_05.cc b/tests/trilinos/solver_05.cc index ce55a59fca..cb89878023 100644 --- a/tests/trilinos/solver_05.cc +++ b/tests/trilinos/solver_05.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -34,7 +34,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -51,7 +53,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -93,7 +95,7 @@ int main(int argc, char **argv) TrilinosWrappers::SolverGMRES solver(control); TrilinosWrappers::PreconditionJacobi preconditioner; preconditioner.initialize(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } diff --git a/tests/trilinos/solver_07.cc b/tests/trilinos/solver_07.cc index 4832f78d56..b371296a29 100644 --- a/tests/trilinos/solver_07.cc +++ b/tests/trilinos/solver_07.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2004 - 2013 by the deal.II authors +// Copyright (C) 2004 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -34,7 +34,9 @@ template void -check_solve( SOLVER &solver, const MATRIX &A, +check_solve( SOLVER &solver, + const SolverControl &solver_control, + const MATRIX &A, VECTOR &u, VECTOR &f, const PRECONDITION &P) { deallog << "Solver type: " << typeid(solver).name() << std::endl; @@ -51,7 +53,7 @@ check_solve( SOLVER &solver, const MATRIX &A, abort (); } - deallog << "Solver stopped after " << solver.control().last_step() + deallog << "Solver stopped after " << solver_control.last_step() << " iterations" << std::endl; } @@ -92,7 +94,7 @@ int main(int argc, char **argv) TrilinosWrappers::SolverCGS solver(control); TrilinosWrappers::PreconditionJacobi preconditioner; preconditioner.initialize(A); - check_solve (solver, A,u,f, preconditioner); + check_solve (solver, control, A,u,f, preconditioner); } } -- 2.39.5