meshState.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  Copyright (C) 2020-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::meshState
29 
30 Description
31  Database for mesh data, solution data, solver performance and other
32  reduced data.
33 
34  polyMesh has a meshState data member so that
35  every GeometricField has access.
36 
37 SourceFiles
38  meshState.C
39  meshStateTemplates.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef Foam_meshState_H
44 #define Foam_meshState_H
45 
46 #include "IOdictionary.H"
47 #include "solverPerformance.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class meshState Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class meshState
59 :
60  public IOdictionary
61 {
62  // Private Data
63 
64  //- Previously used time-index, used for reset between iterations
65  mutable label prevTimeIndex_;
66 
67 
68  // Private Member Functions
69 
70  //- True if boolean entry exists and is set
71  static bool getBoolEntry(const dictionary& dict, const word& keyword);
72 
73  //- Add/remove boolean entry
74  static void setBoolEntry
75  (
77  const word& keyword,
78  bool on
79  );
80 
81  //- No copy construct
82  meshState(const meshState&) = delete;
83 
84  //- No copy assignment
85  void operator=(const meshState&) = delete;
86 
87 
88 public:
89 
90  // Static Data Members
91 
92  //- Name for "controls" sub-dictionary
93  static const word controlsDictName;
94 
95  //- Name for "mesh" sub-dictionary
96  static const word meshDictName;
97 
98  //- Name for "solver" (solver performance) sub-dictionary
99  static const word solverPerformanceDictName;
101 
102  // Constructors
103 
104  //- Construct for objectRegistry (registered with specified name)
105  //- optionally with initial content
106  meshState
107  (
108  const word& name,
109  const objectRegistry& obr,
110  const dictionary* content = nullptr
111  );
112 
113  //- Construct for objectRegistry (registered as "data")
114  explicit meshState(const objectRegistry& obr)
115  :
116  meshState("data", obr)
117  {}
118 
119  //- Construct for objectRegistry (registered with specified name)
120  //- copying initial content
121  meshState
122  (
123  const word& name,
124  const objectRegistry& obr,
125  const dictionary& dict
126  )
127  :
128  meshState(name, obr, &dict)
129  {}
130 
131  //- Construct for objectRegistry (registered as "data")
132  //- copying initial content
133  meshState(const objectRegistry& obr, const dictionary& dict)
134  :
135  meshState("data", obr, &dict)
136  {}
137 
138 
139  // Member Functions
140 
141  //- Reset the dictionary
142  void reset(const meshState& ms);
143 
144  //- Return the dictionary of controls
146  const dictionary& controlsDict() const;
147 
148  //- Return the dictionary of mesh data, typically populated by
149  //- the polyMesh::checkXXX functions, checkMesh etc.
150  dictionary& meshDict();
151  const dictionary& meshDict() const;
153  //- Return the dictionary of solver performance data which
154  //- includes initial and final residuals for convergence checking
156  const dictionary& solverPerformanceDict() const;
157 
158  //- True if "firstIteration" entry exists (in controls) and is set
159  bool isFirstIteration() const;
160 
161  //- True if "finalIteration" entry exists (in controls) and is set
162  bool isFinalIteration() const;
163 
164  //- Add/remove "firstIteration" entry (from controls)
165  void setFirstIteration(bool on);
166 
167  //- Add/remove "finalIteration" entry (from controls)
168  void setFinalIteration(bool on);
169 
170  //- Add/set the solverPerformance entry for the named field
171  template<class Type>
173  (
174  const word& name,
175  const SolverPerformance<Type>& sp
176  ) const;
177 
178  //- Add/set the solverPerformance entry, using its fieldName
179  template<class Type>
181  (
182  const SolverPerformance<Type>& sp
183  ) const;
184 };
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 } // End namespace Foam
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #ifdef NoRepository
194  #include "meshStateTemplates.C"
195 #endif
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #endif
200 
201 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
bool isFirstIteration() const
True if "firstIteration" entry exists (in controls) and is set.
Definition: meshState.C:137
Database for mesh data, solution data, solver performance and other reduced data. ...
Definition: meshState.H:53
static const word meshDictName
Name for "mesh" sub-dictionary.
Definition: meshState.H:105
bool isFinalIteration() const
True if "finalIteration" entry exists (in controls) and is set.
Definition: meshState.C:143
void setSolverPerformance(const word &name, const SolverPerformance< Type > &sp) const
Add/set the solverPerformance entry for the named field.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
void setFinalIteration(bool on)
Add/remove "finalIteration" entry (from controls)
Definition: meshState.C:155
A class for handling words, derived from Foam::string.
Definition: word.H:63
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics...
void reset(const meshState &ms)
Reset the dictionary.
Definition: meshState.C:95
static const word controlsDictName
Name for "controls" sub-dictionary.
Definition: meshState.H:100
const word & name() const
Name function is needed to disambiguate those inherited from regIOobject and dictionary.
dictionary & solverPerformanceDict()
Return the dictionary of solver performance data which includes initial and final residuals for conve...
Definition: meshState.C:125
void setFirstIteration(bool on)
Add/remove "firstIteration" entry (from controls)
Definition: meshState.C:149
dictionary & controlsDict()
Return the dictionary of controls.
Definition: meshState.C:101
static const word solverPerformanceDictName
Name for "solver" (solver performance) sub-dictionary.
Definition: meshState.H:110
Registry of regIOobjects.
dictionary & meshDict()
Return the dictionary of mesh data, typically populated by the polyMesh::checkXXX functions...
Definition: meshState.C:113
Namespace for OpenFOAM.