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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::solution
28 
29 Description
30  Selector class for relaxation factors, solver type and solution.
31 
32 SourceFiles
33  solution.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef solution_H
38 #define solution_H
39 
40 #include "IOdictionary.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class solution Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class solution
52 :
53  public IOdictionary
54 {
55  // Private data
56 
57  //- Dictionary of temporary fields to cache
58  dictionary cache_;
59 
60  //- Switch for the caching mechanism
61  bool caching_;
62 
63  //- Dictionary of relaxation factors for all the fields
64  dictionary fieldRelaxDict_;
65 
66  //- Dictionary of relaxation factors for all the equations
67  dictionary eqnRelaxDict_;
68 
69  //- Optional default relaxation factor for all the fields
70  scalar fieldRelaxDefault_;
71 
72  //- Optional default relaxation factor for all the equations
73  scalar eqnRelaxDefault_;
74 
75  //- Dictionary of solver parameters for all the fields
76  dictionary solvers_;
77 
78 
79  // Private Member Functions
80 
81  //- Read settings from the dictionary
82  void read(const dictionary&);
83 
84  //- No copy construct
85  solution(const solution&) = delete;
86 
87  //- No copy assignment
88  void operator=(const solution&) = delete;
89 
90 
91 public:
92 
93  //- Update from older solver controls syntax
94  // Usually verbose, since we want to know about the changes
95  // Returns the number of settings changed
96  static label upgradeSolverDict(dictionary& dict, const bool verbose=true);
97 
98  //- Debug switch
99  static int debug;
100 
101 
102  // Constructors
103 
104  //- Construct for given objectRegistry and dictionary
105  solution
106  (
107  const objectRegistry& obr,
108  const fileName& dictName
109  );
110 
111 
112  // Member Functions
113 
114  // Access
115 
116  //- Return true if the given field should be cached
117  bool cache(const word& name) const;
118 
119  //- Helper for printing cache message
120  template<class FieldType>
121  static void cachePrintMessage
122  (
123  const char* message,
124  const word& name,
125  const FieldType& vf
126  );
127 
128  //- Return true if the relaxation factor is given for the field
129  bool relaxField(const word& name) const;
130 
131  //- Return true if the relaxation factor is given for the equation
132  bool relaxEquation(const word& name) const;
133 
134  //- Return the relaxation factor for the given field
135  scalar fieldRelaxationFactor(const word& name) const;
136 
137  //- Return the relaxation factor for the given equation
138  scalar equationRelaxationFactor(const word& name) const;
139 
140  //- Return the selected sub-dictionary of solvers if the "select"
141  // keyword is given, otherwise return the complete dictionary
142  const dictionary& solutionDict() const;
143 
144  //- Return the solver controls dictionary for the given field
145  const dictionary& solverDict(const word& name) const;
146 
147  //- Return the solver controls dictionary for the given field
148  const dictionary& solver(const word& name) const;
149 
150 
151  // Read
152 
153  //- Read the solution dictionary
154  bool read();
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 // ************************************************************************* //
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::solution::solverDict
const dictionary & solverDict(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:313
Foam::solution
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:50
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
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:223
Foam::solution::upgradeSolverDict
static label upgradeSolverDict(dictionary &dict, const bool verbose=true)
Update from older solver controls syntax.
Definition: solution.C:161
Foam::solution::cachePrintMessage
static void cachePrintMessage(const char *message, const word &name, const FieldType &vf)
Helper for printing cache message.
Definition: solutionTemplates.C:35
Foam::baseIOdictionary::name
const word & name() const
Name function is needed to disambiguate those inherited.
Definition: baseIOdictionary.C:88
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
solutionTemplates.C
Foam::solution::fieldRelaxationFactor
scalar fieldRelaxationFactor(const word &name) const
Return the relaxation factor for the given field.
Definition: solution.C:256
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:62
Foam::solution::read
bool read()
Read the solution dictionary.
Definition: solution.C:331
Foam::dictionary::dictName
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionary.H:458
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::solution::relaxEquation
bool relaxEquation(const word &name) const
Return true if the relaxation factor is given for the equation.
Definition: solution.C:247
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::solution::debug
static int debug
Debug switch.
Definition: solution.H:98
Foam::solution::equationRelaxationFactor
scalar equationRelaxationFactor(const word &name) const
Return the relaxation factor for the given equation.
Definition: solution.C:279
IOdictionary.H
Foam::solution::solutionDict
const dictionary & solutionDict() const
Return the selected sub-dictionary of solvers if the "select".
Definition: solution.C:302
Foam::solution::solver
const dictionary & solver(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:322
Foam::solution::relaxField
bool relaxField(const word &name) const
Return true if the relaxation factor is given for the field.
Definition: solution.C:237