1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Convergence and singularity tests for solvers.
27 \*---------------------------------------------------------------------------*/
29 #include "lduMatrix.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 bool Foam::lduMatrix::solverPerformance::checkConvergence
35 const scalar Tolerance,
36 const scalar RelTolerance
42 << ": Iteration " << noIterations_
43 << " residual = " << finalResidual_
49 finalResidual_ < Tolerance // Abs. tolerance
52 && finalResidual_ <= RelTolerance*initialResidual_ // Rel. tolerance
54 // || (solverName == "symSolve" && iter == 0)
68 bool Foam::lduMatrix::solverPerformance::checkSingularity
73 if (residual > VSMALL)
86 void Foam::lduMatrix::solverPerformance::print() const
90 Info<< solverName_ << ": Solving for " << fieldName_;
94 Info<< ": solution singularity" << endl;
98 Info<< ", Initial residual = " << initialResidual_
99 << ", Final residual = " << finalResidual_
100 << ", No Iterations " << noIterations_
107 bool Foam::lduSolverPerformance::operator!=
109 const lduSolverPerformance& sp
114 solverName() != sp.solverName()
115 || fieldName() != sp.fieldName()
116 || initialResidual() != sp.initialResidual()
117 || finalResidual() != sp.finalResidual()
118 || nIterations() != sp.nIterations()
119 || converged() != sp.converged()
120 || singular() != sp.singular()
125 Foam::Istream& Foam::operator>>
128 lduSolverPerformance& sp
131 is.readBeginList("SolverPerformance<Type>");
134 >> sp.initialResidual_
139 is.readEndList("SolverPerformance<Type>");
145 Foam::Ostream& Foam::operator<<
148 const lduSolverPerformance& sp
151 os << token::BEGIN_LIST
152 << sp.solverName_ << token::SPACE
153 << sp.fieldName_ << token::SPACE
154 << sp.initialResidual_ << token::SPACE
155 << sp.finalResidual_ << token::SPACE
156 << sp.noIterations_ << token::SPACE
157 << sp.converged_ << token::SPACE
158 << sp.singular_ << token::SPACE
165 // ************************************************************************* //