solution.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::solution
26 
27 Description
28  Selector class for relaxation factors, solver type and solution.
29 
30 SourceFiles
31  solution.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef solution_H
36 #define solution_H
37 
38 #include "IOdictionary.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class solution Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 class solution
50 :
51  public IOdictionary
52 {
53  // Private Data
54 
55  //- Dictionary of temporary fields to cache
56  mutable dictionary cache_;
57 
58  //- Switch for the caching mechanism
59  mutable bool caching_;
60 
61  //- Dictionary of relaxation factors for all the fields
62  dictionary fieldRelaxDict_;
63 
64  //- Dictionary of relaxation factors for all the equations
65  dictionary eqnRelaxDict_;
66 
67  //- Optional default relaxation factor for all the fields
68  scalar fieldRelaxDefault_;
69 
70  //- Optional default relaxation factor for all the equations
71  scalar eqnRelaxDefault_;
72 
73  //- Dictionary of solver parameters for all the fields
74  dictionary solvers_;
75 
76 
77  // Private Member Functions
78 
79  //- Read settings from the dictionary
80  void read(const dictionary&);
81 
82 
83 public:
84 
85  //- Update from older solver controls syntax
86  // Usually verbose, since we want to know about the changes
87  // Returns the number of settings changed
88  static label upgradeSolverDict(dictionary& dict, const bool verbose=true);
89 
90  //- Type information
91  ClassName("solution");
92 
93 
94  // Constructors
95 
96  //- Construct for given objectRegistry and dictionary
97  solution
98  (
99  const objectRegistry& obr,
100  const fileName& dictName
101  );
102 
103  //- Disallow default bitwise copy construction
104  solution(const solution&) = delete;
105 
106 
107  // Member Functions
108 
109  // Access
110 
111  //- Return true if the given field should be cached
112  bool cache(const word& name) const;
113 
114  //- Enable caching of the given field
115  void enableCache(const word& name) const;
116 
117  //- Helper for printing cache message
118  template<class FieldType>
119  static void cachePrintMessage
120  (
121  const char* message,
122  const word& name,
123  const FieldType& vf
124  );
125 
126  //- Return true if the relaxation factor is given for the field
127  bool relaxField(const word& name) const;
128 
129  //- Return true if the relaxation factor is given for the equation
130  bool relaxEquation(const word& name) const;
131 
132  //- Return the relaxation factor for the given field
133  scalar fieldRelaxationFactor(const word& name) const;
134 
135  //- Return the relaxation factor for the given eqation
136  scalar equationRelaxationFactor(const word& name) const;
137 
138  //- Return the selected sub-dictionary of solvers if the "select"
139  // keyword is given, otherwise return the complete dictionary
140  const dictionary& dict() const;
141 
142  //- Return the solver controls dictionary
143  const dictionary& solversDict() const;
144 
145  //- Return the solver controls dictionary for the given field
146  const dictionary& solverDict(const word& name) const;
147 
148 
149  // Read
150 
151  //- Read the solution dictionary
152  bool read();
153 
154 
155  // Member Operators
156 
157  void operator=(const solution&) = delete;
158 };
159 
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 #ifdef NoRepository
168  #include "solutionTemplates.C"
169 #endif
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:123
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:111
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for handling file names.
Definition: fileName.H:82
Registry of regIOobjects.
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:51
void enableCache(const word &name) const
Enable caching of the given field.
Definition: solution.C:234
solution(const objectRegistry &obr, const fileName &dictName)
Construct for given objectRegistry and dictionary.
Definition: solution.C:122
bool cache(const word &name) const
Return true if the given field should be cached.
Definition: solution.C:216
static void cachePrintMessage(const char *message, const word &name, const FieldType &vf)
Helper for printing cache message.
const dictionary & solversDict() const
Return the solver controls dictionary.
Definition: solution.C:342
bool relaxField(const word &name) const
Return true if the relaxation factor is given for the field.
Definition: solution.C:247
scalar fieldRelaxationFactor(const word &name) const
Return the relaxation factor for the given field.
Definition: solution.C:271
const dictionary & solverDict(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:348
static label upgradeSolverDict(dictionary &dict, const bool verbose=true)
Update from older solver controls syntax.
Definition: solution.C:153
scalar equationRelaxationFactor(const word &name) const
Return the relaxation factor for the given eqation.
Definition: solution.C:300
const dictionary & dict() const
Return the selected sub-dictionary of solvers if the "select".
Definition: solution.C:329
void operator=(const solution &)=delete
bool relaxEquation(const word &name) const
Return true if the relaxation factor is given for the equation.
Definition: solution.C:260
ClassName("solution")
Type information.
bool read()
Read the solution dictionary.
Definition: solution.C:359
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59