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-2026 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  const dictionary* fieldRelaxDict_;
63 
64  //- Dictionary of relaxation factors for all the equations
65  const 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  const dictionary* solvers_;
75 
76 
77  // Private Member Functions
78 
79  //- Read settings from fvSolution
80  void readDict();
81 
82 
83 public:
84 
85  //- Type information
86  ClassName("solution");
87 
88 
89  // Constructors
90 
91  //- Construct for given objectRegistry and dictionary
92  solution
93  (
94  const objectRegistry& obr,
95  const fileName& dictName
96  );
97 
98  //- Disallow default bitwise copy construction
99  solution(const solution&) = delete;
100 
101 
102  // Member Functions
103 
104  // Access
105 
106  //- Return true if the given field should be cached
107  bool cache(const word& name) const;
108 
109  //- Enable caching of the given field
110  void enableCache(const word& name) const;
111 
112  //- Helper for printing cache message
113  template<class FieldType>
114  static void cachePrintMessage
115  (
116  const char* message,
117  const word& name,
118  const FieldType& vf
119  );
120 
121  //- Return true if the relaxation factor is given for the field
122  bool relaxField(const word& name) const;
123 
124  //- Return true if the relaxation factor is given for the equation
125  bool relaxEquation(const word& name) const;
126 
127  //- Return the relaxation factor for the given field
128  scalar fieldRelaxationFactor(const word& name) const;
129 
130  //- Return the relaxation factor for the given eqation
131  scalar equationRelaxationFactor(const word& name) const;
132 
133  //- Return the solver controls dictionary
134  const dictionary& solversDict() const;
135 
136  //- Return the solver controls dictionary for the given field
137  const dictionary& solverDict(const word& name) const;
138 
139 
140  // Read
141 
142  //- Read the solution dictionary
143  bool read();
144 
145 
146  // Member Operators
147 
148  void operator=(const solution&) = delete;
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace Foam
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 #ifdef NoRepository
159  #include "solutionTemplates.C"
160 #endif
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 #endif
165 
166 // ************************************************************************* //
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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:137
solution(const objectRegistry &obr, const fileName &dictName)
Construct for given objectRegistry and dictionary.
Definition: solution.C:89
bool cache(const word &name) const
Return true if the given field should be cached.
Definition: solution.C:119
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:232
bool relaxField(const word &name) const
Return true if the relaxation factor is given for the field.
Definition: solution.C:150
scalar fieldRelaxationFactor(const word &name) const
Return the relaxation factor for the given field.
Definition: solution.C:174
const dictionary & solverDict(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:238
scalar equationRelaxationFactor(const word &name) const
Return the relaxation factor for the given eqation.
Definition: solution.C:203
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:163
ClassName("solution")
Type information.
bool read()
Read the solution dictionary.
Definition: solution.C:249
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.