From 851c766aa284012edaf6747160bc794f0fb7f11b Mon Sep 17 00:00:00 2001 From: bangerth Date: Wed, 6 Apr 2011 16:03:38 +0000 Subject: [PATCH] If the size of a linear system is small, i.e. when the mesh is very coarse, then it is sometimes not sufficient to set a maximum of src.size() CG iterations before the solver in the vmult() function converges. (This is, of course, a result of numerical round-off, since we know that on paper, the CG method converges in at most src.size() steps.) As a consequence, we set the maximum number of iterations equal to the maximum of the size of the linear system and 200. git-svn-id: https://svn.dealii.org/trunk@23562 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-21/step-21.cc | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/deal.II/examples/step-21/step-21.cc b/deal.II/examples/step-21/step-21.cc index 0f4c805e38..2a82e4958c 100644 --- a/deal.II/examples/step-21/step-21.cc +++ b/deal.II/examples/step-21/step-21.cc @@ -3,7 +3,7 @@ /* $Id$ */ /* */ -/* Copyright (C) 2006, 2007, 2008, 2009, 2010 by the deal.II authors */ +/* Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors */ /* */ /* This file is subject to QPL and may not be distributed */ /* without copyright and license information. Please refer */ @@ -497,9 +497,27 @@ double f_saturation (const double S, // @sect3{Linear solvers and preconditioners} // The linear solvers we use are also - // completely analogous to the ones used in - // step-20. The following classes are - // therefore copied verbatim from there. + // completely analogous to the ones + // used in step-20. The following + // classes are therefore copied + // verbatim from there. There is a + // single change: if the size of a + // linear system is small, i.e. when + // the mesh is very coarse, then it + // is sometimes not sufficient to set + // a maximum of + // src.size() CG + // iterations before the solver in + // the vmult() function + // converges. (This is, of course, a + // result of numerical round-off, + // since we know that on paper, the + // CG method converges in at most + // src.size() steps.) As + // a consequence, we set the maximum + // number of iterations equal to the + // maximum of the size of the linear + // system and 200. template class InverseMatrix : public Subscriptor { @@ -526,7 +544,8 @@ template void InverseMatrix::vmult (Vector &dst, const Vector &src) const { - SolverControl solver_control (src.size(), 1e-8*src.l2_norm()); + SolverControl solver_control (std::max(src.size(), 200U), + 1e-8*src.l2_norm()); SolverCG<> cg (solver_control); dst = 0; -- 2.39.5