OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

lduMatrixTests.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026     Convergence and singularity tests for solvers.
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #include "lduMatrix.H"
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 bool Foam::lduMatrix::solverPerformance::checkConvergence
00035 (
00036     const scalar Tolerance,
00037     const scalar RelTolerance
00038 )
00039 {
00040     if (debug >= 2)
00041     {
00042         Info<< solverName_
00043             << ":  Iteration " << noIterations_
00044             << " residual = " << finalResidual_
00045             << endl;
00046     }
00047 
00048     if
00049     (
00050         finalResidual_ < Tolerance
00051      || (
00052             RelTolerance > SMALL
00053          && finalResidual_ <= RelTolerance*initialResidual_
00054         )
00055   // || (solverName == "symSolve" && iter == 0)
00056     )
00057     {
00058         converged_ = true;
00059     }
00060     else
00061     {
00062         converged_ = false;
00063     }
00064 
00065     return converged_;
00066 }
00067 
00068 
00069 bool Foam::lduMatrix::solverPerformance::checkSingularity
00070 (
00071     const scalar residual
00072 )
00073 {
00074     if (residual > VSMALL)
00075     {
00076         singular_ = false;
00077     }
00078     else
00079     {
00080         singular_ = true;
00081     }
00082 
00083     return singular_;
00084 }
00085 
00086 
00087 void Foam::lduMatrix::solverPerformance::print() const
00088 {
00089     if (debug)
00090     {
00091         Info<< solverName_ << ":  Solving for " << fieldName_;
00092 
00093         if (singular())
00094         {
00095             Info<< ":  solution singularity" << endl;
00096         }
00097         else
00098         {
00099             Info<< ", Initial residual = " << initialResidual_
00100                 << ", Final residual = " << finalResidual_
00101                 << ", No Iterations " << noIterations_
00102                 << endl;
00103         }
00104     }
00105 }
00106 
00107 
00108 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd