From: guido Date: Thu, 7 Dec 2000 10:42:19 +0000 (+0000) Subject: Krylov-space methods do not use residual() anymore X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c62fe2f41c8a5bed306d3a61e1bc9202d50d51a9;p=dealii-svn.git Krylov-space methods do not use residual() anymore git-svn-id: https://svn.dealii.org/trunk@3527 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/solver_bicgstab.h b/deal.II/lac/include/lac/solver_bicgstab.h index ed2a1fcbe6..c01f19051b 100644 --- a/deal.II/lac/include/lac/solver_bicgstab.h +++ b/deal.II/lac/include/lac/solver_bicgstab.h @@ -241,7 +241,10 @@ template double SolverBicgstab::criterion (const MATRIX& A, const VECTOR& x, const VECTOR& b) { - res = A.residual(*Vt, x, b); + A.vmult(*Vt, x); + Vt->sadd(-1.,1.,b); + res = Vt->l2_norm(); + return res; } @@ -252,7 +255,10 @@ template SolverControl::State SolverBicgstab::start(const MATRIX& A) { - res = A.residual(*Vr, *Vx, *Vb); + A.vmult(*Vr, *Vx); + Vr->sadd(-1.,1.,*Vb); + res = Vr->l2_norm(); + Vp->reinit(*Vx); Vv->reinit(*Vx); Vrbar->equ(1.,*Vr); diff --git a/deal.II/lac/include/lac/solver_cg.h b/deal.II/lac/include/lac/solver_cg.h index 5ebb3e822e..d6c8aeae32 100644 --- a/deal.II/lac/include/lac/solver_cg.h +++ b/deal.II/lac/include/lac/solver_cg.h @@ -199,8 +199,11 @@ SolverCG::solve (const MATRIX &A, // library int it=0; double res,gh,alpha,beta; - - res = A.residual(g,x,b); + + A.vmult(g,x); + g.sadd(-1.,1.,b); + res = g.l2_norm(); + conv = control().check(0,res); if (conv) { diff --git a/deal.II/lac/include/lac/solver_gmres.h b/deal.II/lac/include/lac/solver_gmres.h index 23e5e190b1..fd77abd2a5 100644 --- a/deal.II/lac/include/lac/solver_gmres.h +++ b/deal.II/lac/include/lac/solver_gmres.h @@ -279,10 +279,12 @@ unsigned int dim = 0; if (left_precondition) { - A.residual(p,x,b); + A.vmult(p,x); + p.sadd(-1.,1.,b); precondition.vmult(v,p); } else { - A.residual(v,x,b); + A.vmult(v,x); + v.sadd(-1.,1.,b); }; double rho = v.l2_norm(); diff --git a/deal.II/lac/include/lac/solver_qmrs.h b/deal.II/lac/include/lac/solver_qmrs.h index 81a2ac359f..3376d6263f 100644 --- a/deal.II/lac/include/lac/solver_qmrs.h +++ b/deal.II/lac/include/lac/solver_qmrs.h @@ -304,7 +304,9 @@ SolverQMRS::iterate(const MATRIX& A, // Apply right preconditioning to x precondition.vmult(q,x); // Preconditioned residual - res = A.residual(v, q, b); + A.vmult(v,q); + v.sadd(-1.,1.,b); + res = v.l2_norm(); if (control().check(step, res) == SolverControl::success) return success; @@ -352,7 +354,11 @@ while (state == SolverControl::iterate) print_vectors(step,x,v,d); // Step 5 if (additional_data.exact_residual) - res = A.residual(q,x,b); + { + A.vmult(q,x); + q.sadd(-1.,1.,b); + res = q.l2_norm(); + } else res = sqrt((it+1)*tau); state = control().check(step,res);