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 | Copyright (C) 2011-2013 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  //- Disallow default bitwise copy construct and assignment
83  solution(const solution&);
84  void operator=(const solution&);
85 
86 
87 public:
88 
89  //- Update from older solver controls syntax
90  // Usually verbose, since we want to know about the changes
91  // Returns the number of settings changed
92  static label upgradeSolverDict(dictionary& dict, const bool verbose=true);
93 
94  //- Debug switch
95  static int debug;
96 
97 
98  // Constructors
99 
100  //- Construct for given objectRegistry and dictionary
101  solution
102  (
103  const objectRegistry& obr,
104  const fileName& dictName
105  );
106 
107 
108  // Member Functions
109 
110  // Access
111 
112  //- Return true if the given field should be cached
113  bool cache(const word& name) const;
114 
115  //- Helper for printing cache message
116  template<class FieldType>
117  static void cachePrintMessage
118  (
119  const char* message,
120  const word& name,
121  const FieldType& vf
122  );
123 
124  //- Return true if the relaxation factor is given for the field
125  bool relaxField(const word& name) const;
126 
127  //- Return true if the relaxation factor is given for the equation
128  bool relaxEquation(const word& name) const;
129 
130  //- Return the relaxation factor for the given field
131  scalar fieldRelaxationFactor(const word& name) const;
132 
133  //- Return the relaxation factor for the given eqation
134  scalar equationRelaxationFactor(const word& name) const;
135 
136  //- Return the selected sub-dictionary of solvers if the "select"
137  // keyword is given, otherwise return the complete dictionary
138  const dictionary& solutionDict() const;
139 
140  //- Return the solver controls dictionary for the given field
141  const dictionary& solverDict(const word& name) const;
142 
143  //- Return the solver controls dictionary for the given field
144  const dictionary& solver(const word& name) const;
145 
146 
147  // Read
148 
149  //- Read the solution dictionary
150  bool read();
151 };
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #ifdef NoRepository
161 # include "solutionTemplates.C"
162 #endif
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
bool relaxField(const word &name) const
Return true if the relaxation factor is given for the field.
Definition: solution.C:268
static int debug
Debug switch.
Definition: solution.H:94
A class for handling words, derived from string.
Definition: word.H:59
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
bool relaxEquation(const word &name) const
Return true if the relaxation factor is given for the equation.
Definition: solution.C:281
const dictionary & solverDict(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:365
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:48
bool cache(const word &name) const
Return true if the given field should be cached.
Definition: solution.C:250
const word & name() const
Name function is needed to disambiguate those inherited.
Definition: IOdictionary.C:183
Namespace for OpenFOAM.
dictionary dict
static label upgradeSolverDict(dictionary &dict, const bool verbose=true)
Update from older solver controls syntax.
Definition: solution.C:173
bool read()
Read the solution dictionary.
Definition: solution.C:389
const dictionary & solver(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:377
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
scalar equationRelaxationFactor(const word &name) const
Return the relaxation factor for the given eqation.
Definition: solution.C:322
static void cachePrintMessage(const char *message, const word &name, const FieldType &vf)
Helper for printing cache message.
scalar fieldRelaxationFactor(const word &name) const
Return the relaxation factor for the given field.
Definition: solution.C:292
Registry of regIOobjects.
A class for handling file names.
Definition: fileName.H:69
const dictionary & solutionDict() const
Return the selected sub-dictionary of solvers if the "select".
Definition: solution.C:352
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115