caseInfo.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) 2023 OpenCFD Ltd.
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::functionObjects::caseInfo
28 
29 Description
30  Collects and writes case information to file.
31 
32  Example of function object specification:
33  \verbatim
34  caseInfo
35  {
36  type caseInfo;
37  libs (utilityFunctionObjects);
38 
39  // Warn when entries are not found
40  lookupMode warn; // none | warn | error;
41 
42  // Write format
43  writeFormat json; // dictionary | json;
44 
45  dictionaries
46  {
47  USolver // User-specified names
48  {
49  // Look up using registered name
50  name "fvSolution";
51 
52  // Optionally limit to specific entries
53  include
54  (
55  "solvers/U/solver"
56  );
57  }
58  fvSchemes
59  {
60  name "fvSchemes";
61 
62  // include all entries by default
63  }
64  timeScheme
65  {
66  name "fvSchemes";
67 
68  include
69  (
70  "/ddtSchemes/default"
71  );
72  }
73 
74  turbulence
75  {
76  name "turbulenceProperties";
77 
78  // include all entries by default
79  }
80  controlDict
81  {
82  // Look up using file path
83  path "<case>/system/controlDict";
84 
85  include
86  (
87  "application"
88  "deltaT"
89  "startTime"
90  "endTime"
91  );
92  }
93  }
94 
95  functionObjects (minMax1); // v2306 only
96  }
97  \endverbatim
98 
99  Where the entries comprise:
100  \table
101  Property | Description | Required | Default
102  type | Type name: caseInfo | yes |
103  lookupMode | Lookup mode | no | warn
104  writeFormat | Write format | yes |
105  dictionaries | Dictionaries to process | no | <none>
106  functionObjects | Function objects to process | no | <none>
107  \endtable
108 
109 See also
110  Foam::functionObject
111  Foam::timeFunctionObject
112 
113 SourceFiles
114  caseInfo.C
115 
116 \*---------------------------------------------------------------------------*/
117 
118 #ifndef functionObjects_caseInfo_H
119 #define functionObjects_caseInfo_H
120 
121 #include "writeFile.H"
122 #include "stateFunctionObject.H"
123 #include "Enum.H"
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 namespace Foam
128 {
129 
130 // Forward declarations
131 class fvMesh;
132 
133 namespace functionObjects
134 {
135 
136 /*---------------------------------------------------------------------------*\
137  Class caseInfo Declaration
138 \*---------------------------------------------------------------------------*/
139 
140 class caseInfo
141 :
142  public stateFunctionObject,
143  public writeFile
144 {
145 public:
146 
147  // Public enumerations
148 
149  //- Write format enumeration
150  enum class writeFormat
151  {
152  dict,
153  json
154  };
155 
156  //- Lookup mode enumeration
157  enum class lookupMode
158  {
159  none,
160  warn,
161  error
162  };
163 
164 
165 private:
166 
167  // Private Member Data
168 
169  //- Write format names
170  static const Enum<writeFormat> writeFormatNames_;
171 
172  //- Lookup mode names
173  static const Enum<lookupMode> lookupModeNames_;
174 
175  //- Write/output format, e.g. dictionary, JSON
176  writeFormat writeFormat_;
178  //- Lookup mode when reading entries
179  lookupMode lookupMode_;
180 
181  //- Dictionaries
182  dictionary dictionaries_;
183 
184  //- List of function objects to process
185  wordList functionObjectNames_;
187 
188  // Private Member Functions
189 
190  //- Report
191  void report(const string& str) const;
192 
193  //- Process dictionary
194  void processDict
195  (
196  dictionary& dict,
197  const dictionary& targetDict,
198  const entry* includePtr,
199  const entry* excludePtr
200  ) const;
201 
202 
203 protected:
204 
205  // Protected Member Functions
206 
207  //- No copy construct
208  caseInfo(const caseInfo&) = delete;
209 
210  //- No copy assignment
211  void operator=(const caseInfo&) = delete;
212 
213 
214  // Write data
215 
216  //- Write case meta data
217  void writeMeta(dictionary& dict) const;
218 
219  //- Write registered dictionaries
221  (
222  const objectRegistry& obr,
223  dictionary& dict,
224  dictionary& dictionaries
225  ) const;
226 
227  //- Write file-based dictionaries
228  void writeFileDicts
229  (
230  dictionary& dict,
231  dictionary& dictionaries
232  ) const;
233 
234  //- Write function object results
235  void writeFunctionObjects(dictionary& dict) const;
236 
237  //- Write mesh statistics
238  void writeMeshStats(const polyMesh& mesh, dictionary& dict) const;
239 
240  //- Write mesh patches
241  void writePatches(const fvMesh& mesh, dictionary& dict) const;
242 
243 
244 public:
245 
246  //- Runtime type information
247  TypeName("caseInfo");
248 
249 
250  // Constructors
251 
252  //- Construct from Time and dictionary
253  caseInfo
254  (
255  const word& name,
256  const Time& runTime,
257  const dictionary& dict
258  );
259 
260 
261  //- Destructor
262  virtual ~caseInfo() = default;
263 
264 
265  // Member Functions
266 
267  //- Read the controls
268  virtual bool read(const dictionary& dict);
269 
270  //- Execute, does nothing
271  virtual bool execute();
272 
273  //- Write the caseInfo
274  virtual bool write();
275 };
276 
277 
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 
280 } // End namespace functionObjects
281 } // End namespace Foam
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 #endif
286 
287 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
lookupMode
Lookup mode enumeration.
Definition: caseInfo.H:186
Collects and writes case information to file.
Definition: caseInfo.H:165
engineTime & runTime
virtual bool read(const dictionary &dict)
Read the controls.
Definition: caseInfo.C:408
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
virtual bool execute()
Execute, does nothing.
Definition: caseInfo.C:427
const word & name() const noexcept
Return the name of this functionObject.
void writeMeshStats(const polyMesh &mesh, dictionary &dict) const
Write mesh statistics.
Definition: caseInfo.C:300
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
void writeMeta(dictionary &dict) const
Write case meta data.
Definition: caseInfo.C:166
caseInfo(const caseInfo &)=delete
No copy construct.
void writeRegisteredDicts(const objectRegistry &obr, dictionary &dict, dictionary &dictionaries) const
Write registered dictionaries.
Definition: caseInfo.C:177
virtual ~caseInfo()=default
Destructor.
writeFormat
Write format enumeration.
Definition: caseInfo.H:177
TypeName("caseInfo")
Runtime type information.
void writePatches(const fvMesh &mesh, dictionary &dict) const
Write mesh patches.
Definition: caseInfo.C:364
void writeFileDicts(dictionary &dict, dictionary &dictionaries) const
Write file-based dictionaries.
Definition: caseInfo.C:224
void writeFunctionObjects(dictionary &dict) const
Write function object results.
Definition: caseInfo.C:280
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
void operator=(const caseInfo &)=delete
No copy assignment.
Registry of regIOobjects.
virtual bool write()
Write the caseInfo.
Definition: caseInfo.C:433
Namespace for OpenFOAM.
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:63