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

tolerances.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 \*---------------------------------------------------------------------------*/
00026 
00027 #include "tolerances.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 
00034 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00035 
00036 tolerances::tolerances(const Time& t, const fileName& dictName)
00037 :
00038     IOdictionary
00039     (
00040         IOobject
00041         (
00042             dictName,
00043             t.system(),
00044             t,
00045             IOobject::MUST_READ,
00046             IOobject::NO_WRITE
00047         )
00048     ),
00049     relaxationFactors_(ITstream("relaxationFactors", tokenList())()),
00050     solverTolerances_(ITstream("solverTolerances", tokenList())()),
00051     solverRelativeTolerances_
00052     (
00053         ITstream("solverRelativeTolerances", tokenList())()
00054     )
00055 {
00056     read();
00057 }
00058 
00059 
00060 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00061 
00062 bool tolerances::read()
00063 {
00064     if (regIOobject::read())
00065     {
00066         word toleranceSetName(lookup("toleranceSet"));
00067         const dictionary& toleranceSet(subDict(toleranceSetName));
00068 
00069         if (toleranceSet.found("relaxationFactors"))
00070         {
00071             relaxationFactors_ = toleranceSet.subDict("relaxationFactors");
00072         }
00073 
00074         if (toleranceSet.found("solverTolerances"))
00075         {
00076             solverTolerances_ = toleranceSet.subDict("solverTolerances");
00077         }
00078 
00079         if (toleranceSet.found("solverRelativeTolerances"))
00080         {
00081             solverRelativeTolerances_ =
00082                 toleranceSet.subDict("solverRelativeTolerances");
00083         }
00084 
00085         return true;
00086     }
00087     else
00088     {
00089         return false;
00090     }
00091 }
00092 
00093 
00094 bool tolerances::relax(const word& name) const
00095 {
00096     return relaxationFactors_.found(name);
00097 }
00098 
00099 scalar tolerances::relaxationFactor(const word& name) const
00100 {
00101     return readScalar(relaxationFactors_.lookup(name));
00102 }
00103 
00104 scalar tolerances::solverTolerance(const word& name) const
00105 {
00106     return readScalar(solverTolerances_.lookup(name));
00107 }
00108 
00109 bool tolerances::solverRelativeTolerances() const
00110 {
00111     return solverRelativeTolerances_.size();
00112 }
00113 
00114 scalar tolerances::solverRelativeTolerance(const word& name) const
00115 {
00116     return readScalar(solverRelativeTolerances_.lookup(name));
00117 }
00118 
00119 
00120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00121 
00122 } // End namespace Foam
00123 
00124 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd