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
57 
58  //- Switch for the caching mechanism
59  bool caching_;
60 
61  //- Dictionary of relaxation factors for all the fields
63 
64  //- Dictionary of relaxation factors for all the equations
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
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 // ************************************************************************* //
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Foam::dictionaryName::dictName
const word dictName() const
Return the local dictionary name (final part of scoped name)
Definition: dictionary.H:115
Foam::solution::solverDict
const dictionary & solverDict(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:363
Foam::solution
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:48
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
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:250
Foam::solution::cache_
dictionary cache_
Dictionary of temporary fields to cache.
Definition: solution.H:55
Foam::solution::upgradeSolverDict
static label upgradeSolverDict(dictionary &dict, const bool verbose=true)
Update from older solver controls syntax.
Definition: solution.C:173
Foam::solution::solvers_
dictionary solvers_
Dictionary of solver parameters for all the fields.
Definition: solution.H:73
Foam::solution::solution
solution(const solution &)
Disallow default bitwise copy construct and assignment.
Foam::solution::cachePrintMessage
static void cachePrintMessage(const char *message, const word &name, const FieldType &vf)
Helper for printing cache message.
Definition: solutionTemplates.C:33
Foam::solution::fieldRelaxDict_
dictionary fieldRelaxDict_
Dictionary of relaxation factors for all the fields.
Definition: solution.H:61
Foam::solution::operator=
void operator=(const solution &)
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::solution::eqnRelaxDefault_
scalar eqnRelaxDefault_
Optional default relaxation factor for all the equations.
Definition: solution.H:70
solutionTemplates.C
Foam::solution::fieldRelaxationFactor
scalar fieldRelaxationFactor(const word &name) const
Return the relaxation factor for the given field.
Definition: solution.C:292
Foam::label
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
Foam::solution::eqnRelaxDict_
dictionary eqnRelaxDict_
Dictionary of relaxation factors for all the equations.
Definition: solution.H:64
Foam::solution::read
bool read()
Read the solution dictionary.
Definition: solution.C:387
Foam::solution::fieldRelaxDefault_
scalar fieldRelaxDefault_
Optional default relaxation factor for all the fields.
Definition: solution.H:67
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::solution::relaxEquation
bool relaxEquation(const word &name) const
Return true if the relaxation factor is given for the equation.
Definition: solution.C:281
Foam::solution::caching_
bool caching_
Switch for the caching mechanism.
Definition: solution.H:58
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::solution::debug
static int debug
Debug switch.
Definition: solution.H:94
Foam::solution::equationRelaxationFactor
scalar equationRelaxationFactor(const word &name) const
Return the relaxation factor for the given eqation.
Definition: solution.C:321
IOdictionary.H
Foam::solution::solutionDict
const dictionary & solutionDict() const
Return the selected sub-dictionary of solvers if the "select".
Definition: solution.C:350
Foam::IOdictionary::name
const word & name() const
Name function is needed to disambiguate those inherited.
Definition: IOdictionary.C:181
Foam::solution::solver
const dictionary & solver(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:375
Foam::solution::relaxField
bool relaxField(const word &name) const
Return true if the relaxation factor is given for the field.
Definition: solution.C:268