solution.H
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-2016 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 Class
28  Foam::solution
29 
30 Description
31  Selector class for relaxation factors, solver type and solution.
32 
33 SourceFiles
34  solution.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef solution_H
39 #define solution_H
40 
41 #include "IOdictionary.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class solution Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class solution
53 :
54  public IOdictionary
55 {
56  // Private data
57 
58  //- Dictionary of temporary fields to cache
59  dictionary cache_;
60 
61  //- Switch for the caching mechanism
62  bool caching_;
63 
64  //- Dictionary of relaxation factors for all the fields
65  dictionary fieldRelaxDict_;
66 
67  //- Dictionary of relaxation factors for all the equations
68  dictionary eqnRelaxDict_;
69 
70  //- Optional default relaxation factor for all the fields
71  scalar fieldRelaxDefault_;
72 
73  //- Optional default relaxation factor for all the equations
74  scalar eqnRelaxDefault_;
75 
76  //- Dictionary of solver parameters for all the fields
77  dictionary solvers_;
78 
79 
80  // Private Member Functions
81 
82  //- Read settings from the dictionary
83  void read(const dictionary&);
84 
85  //- No copy construct
86  solution(const solution&) = delete;
87 
88  //- No copy assignment
89  void operator=(const solution&) = delete;
90 
91 
92 public:
93 
94  //- Update from older solver controls syntax
95  // Usually verbose, since we want to know about the changes
96  // Returns the number of settings changed
97  static label upgradeSolverDict(dictionary& dict, const bool verbose=true);
98 
99  //- Debug switch
100  static int debug;
101 
102 
103  // Constructors
104 
105  //- Construct for given objectRegistry and dictionary name
106  solution
107  (
108  const objectRegistry& obr,
109  const fileName& dictName
110  );
111 
112  //- Construct for given objectRegistry, dictionary name and (optional)
113  // content (gets used in case of NO_READ or dictionary cannot be read)
114  solution
115  (
116  const objectRegistry& obr,
117  const fileName& dictName,
118  const dictionary& dict
119  );
120 
121 
122  // Member Functions
123 
124  // Access
125 
126  //- Return true if the given field should be cached
127  bool cache(const word& name) const;
128 
129  //- Helper for printing cache message
130  template<class FieldType>
131  static void cachePrintMessage
132  (
133  const char* message,
134  const word& name,
135  const FieldType& vf
136  );
137 
138  //- Return true if the relaxation factor is given for the field
139  bool relaxField(const word& name) const;
140 
141  //- Return true if the relaxation factor is given for the equation
142  bool relaxEquation(const word& name) const;
143 
144  //- Return the relaxation factor for the given field
145  scalar fieldRelaxationFactor(const word& name) const;
146 
147  //- Return the relaxation factor for the given equation
148  scalar equationRelaxationFactor(const word& name) const;
149 
150  //- Return the selected sub-dictionary of solvers if the "select"
151  // keyword is given, otherwise return the complete dictionary
152  const dictionary& solutionDict() const;
153 
154  //- Return the solver controls dictionary for the given field
155  const dictionary& solverDict(const word& name) const;
156 
157  //- Return the solver controls dictionary for the given field
158  const dictionary& solver(const word& name) const;
159 
160 
161  // Read
162 
163  //- Read the solution dictionary
164  bool read();
165 };
166 
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 } // End namespace Foam
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #ifdef NoRepository
175  #include "solutionTemplates.C"
176 #endif
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 #endif
181 
182 // ************************************************************************* //
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::solution::solverDict
const dictionary & solverDict(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:357
Foam::solution
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:51
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::solution::cache
bool cache(const word &name) const
Return true if the given field should be cached.
Definition: solution.C:267
Foam::solution::upgradeSolverDict
static label upgradeSolverDict(dictionary &dict, const bool verbose=true)
Update from older solver controls syntax.
Definition: solution.C:205
Foam::solution::cachePrintMessage
static void cachePrintMessage(const char *message, const word &name, const FieldType &vf)
Helper for printing cache message.
Definition: solutionTemplates.C:35
Foam::baseIOdictionary::name
const word & name() const
Definition: baseIOdictionary.C:82
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
solutionTemplates.C
Foam::solution::fieldRelaxationFactor
scalar fieldRelaxationFactor(const word &name) const
Return the relaxation factor for the given field.
Definition: solution.C:300
Foam::solution::read
bool read()
Read the solution dictionary.
Definition: solution.C:375
Foam::dictionary::dictName
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionary.H:458
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::solution::relaxEquation
bool relaxEquation(const word &name) const
Return true if the relaxation factor is given for the equation.
Definition: solution.C:291
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::solution::debug
static int debug
Debug switch.
Definition: solution.H:99
Foam::solution::equationRelaxationFactor
scalar equationRelaxationFactor(const word &name) const
Return the relaxation factor for the given equation.
Definition: solution.C:323
IOdictionary.H
Foam::solution::solutionDict
const dictionary & solutionDict() const
Return the selected sub-dictionary of solvers if the "select".
Definition: solution.C:346
Foam::solution::solver
const dictionary & solver(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:366
Foam::solution::relaxField
bool relaxField(const word &name) const
Return true if the relaxation factor is given for the field.
Definition: solution.C:281