tolerances.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011 OpenFOAM Foundation
9 Copyright (C) 2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "tolerances.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
34:
36 (
38 (
40 t.system(),
41 t,
42 IOobject::MUST_READ_IF_MODIFIED,
43 IOobject::NO_WRITE
44 )
45 ),
46
47 // Named, but empty dictionaries
48 relaxationFactors_("relaxationFactors"),
49 solverTolerances_("solverTolerances"),
50 solverRelativeTolerances_("solverRelativeTolerances")
51{
52 read();
53}
54
55
56// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
57
59{
61 {
62 const word toleranceSetName(get<word>("toleranceSet"));
63 const dictionary& toleranceSet = subDict(toleranceSetName);
64
65 if (toleranceSet.found("relaxationFactors"))
66 {
67 relaxationFactors_ = toleranceSet.subDict("relaxationFactors");
68 }
69
70 if (toleranceSet.found("solverTolerances"))
71 {
72 solverTolerances_ = toleranceSet.subDict("solverTolerances");
73 }
74
75 if (toleranceSet.found("solverRelativeTolerances"))
76 {
77 solverRelativeTolerances_ =
78 toleranceSet.subDict("solverRelativeTolerances");
79 }
80
81 return true;
82 }
83
84 return false;
85}
86
87
89{
90 return relaxationFactors_.found(name);
91}
92
93
95{
96 return relaxationFactors_.get<scalar>(name);
97}
98
99
101{
102 return solverTolerances_.get<scalar>(name);
103}
104
105
107{
108 return solverRelativeTolerances_.size();
109}
110
111
113{
114 return solverRelativeTolerances_.get<scalar>(name);
115}
116
117
118// ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:460
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
void relax()
Relax matrix (for steady-state solution).
Definition: faMatrix.C:581
A class for handling file names.
Definition: fileName.H:76
virtual bool read()
Read object.
Selector class for solution tolerances.
Definition: tolerances.H:53
scalar solverTolerance(const word &name) const
Definition: tolerances.C:100
bool solverRelativeTolerances() const
Definition: tolerances.C:106
scalar relaxationFactor(const word &name) const
Definition: tolerances.C:94
scalar solverRelativeTolerance(const word &name) const
Definition: tolerances.C:112
bool read()
Read the tolerances.
Definition: tolerances.C:58
A class for handling words, derived from Foam::string.
Definition: word.H:68
const word dictName("faMeshDefinition")
int system(const std::string &command, const bool bg=false)
Execute the specified command via the shell.
Definition: MSwindows.C:1158
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59