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  dictionary cache_;
57 
58  //- Switch for the caching mechanism
59  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  //- Helper for printing cache message
115  template<class FieldType>
116  static void cachePrintMessage
117  (
118  const char* message,
119  const word& name,
120  const FieldType& vf
121  );
122 
123  //- Return true if the relaxation factor is given for the field
124  bool relaxField(const word& name) const;
125 
126  //- Return true if the relaxation factor is given for the equation
127  bool relaxEquation(const word& name) const;
128 
129  //- Return the relaxation factor for the given field
130  scalar fieldRelaxationFactor(const word& name) const;
131 
132  //- Return the relaxation factor for the given eqation
133  scalar equationRelaxationFactor(const word& name) const;
134 
135  //- Return the selected sub-dictionary of solvers if the "select"
136  // keyword is given, otherwise return the complete dictionary
137  const dictionary& dict() const;
138 
139  //- Return the solver controls dictionary
140  const dictionary& solversDict() const;
141 
142  //- Return the solver controls dictionary for the given field
143  const dictionary& solverDict(const word& name) const;
144 
145 
146  // Read
147 
148  //- Read the solution dictionary
149  bool read();
150 
151 
152  // Member Operators
153 
154  void operator=(const solution&) = delete;
155 };
156 
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 } // End namespace Foam
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 #ifdef NoRepository
165  #include "solutionTemplates.C"
166 #endif
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************************************************************* //
scalar equationRelaxationFactor(const word &name) const
Return the relaxation factor for the given eqation.
Definition: solution.C:287
A class for handling file names.
Definition: fileName.H:79
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
bool read()
Read the solution dictionary.
Definition: solution.C:346
void operator=(const solution &)=delete
bool relaxField(const word &name) const
Return true if the relaxation factor is given for the field.
Definition: solution.C:234
const dictionary & solverDict(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:335
bool relaxEquation(const word &name) const
Return true if the relaxation factor is given for the equation.
Definition: solution.C:247
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:121
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:109
A class for handling words, derived from string.
Definition: word.H:59
bool cache(const word &name) const
Return true if the given field should be cached.
Definition: solution.C:216
solution(const objectRegistry &obr, const fileName &dictName)
Construct for given objectRegistry and dictionary.
Definition: solution.C:122
const dictionary & solversDict() const
Return the solver controls dictionary.
Definition: solution.C:329
scalar fieldRelaxationFactor(const word &name) const
Return the relaxation factor for the given field.
Definition: solution.C:258
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:48
Registry of regIOobjects.
static void cachePrintMessage(const char *message, const word &name, const FieldType &vf)
Helper for printing cache message.
static label upgradeSolverDict(dictionary &dict, const bool verbose=true)
Update from older solver controls syntax.
Definition: solution.C:153
ClassName("solution")
Type information.
const dictionary & dict() const
Return the selected sub-dictionary of solvers if the "select".
Definition: solution.C:316
Namespace for OpenFOAM.