Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::functionObjects::caseInfo
28
29Description
30 Collects and writes case information to file.
31
32Usage
33 Minimal example by using \c system/controlDict.functions:
34 \verbatim
35 caseInfoFO
36 {
37 // Mandatory entries
38 type caseInfo;
39 libs (utilityFunctionObjects);
40
41 // Optional entries
42 lookupMode <word>; // none | warn | error;
43 writeFormat <word>; // 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 // Inherited entries
98 ...
99 }
100 \endverbatim
101
102 where the entries mean:
103 \table
104 Property | Description | Type | Reqd | Deflt
105 type | Type name: caseInfo | word | yes | -
106 libs | Library name: utilityFunctionObjects | word | yes | -
107 lookupMode | Lookup mode | word | no | warn
108 writeFormat | Write format | word | no | -
109 dictionaries | Dictionaries to process | word | no | -
110 functionObjects | Function objects to process | word | no | -
111 \endtable
112
113 Options for the \c writeFormat entry:
114 \verbatim
115 dictionary | OpenFOAM native dictionary format
116 json | JSON output format
117 \endverbatim
118
119 Options for the \c lookupMode entry:
120 \verbatim
121 none | Do not report missing entries.
122 warn | Warn about missing entries.
123 error | Error and abort on missing entries.
124 \endverbatim
125
126 The inherited entries are elaborated in:
127 - \link stateFunctionObject.H \endlink
128 - \link writeFile.H \endlink
129
130SourceFiles
131 caseInfo.C
132
133\*---------------------------------------------------------------------------*/
134
135#ifndef Foam_functionObjects_caseInfo_H
136#define Foam_functionObjects_caseInfo_H
137
138#include "IOdictionary.H"
139#include "writeFile.H"
140#include "stateFunctionObject.H"
141#include "Enum.H"
142
143// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144
145namespace Foam
146{
147
148// Forward Declarations
149class fvMesh;
150
151namespace functionObjects
152{
153
154/*---------------------------------------------------------------------------*\
155 Class caseInfo Declaration
156\*---------------------------------------------------------------------------*/
157
158class caseInfo
159:
160 public IOdictionary,
161 public stateFunctionObject,
162 public writeFile
163{
164public:
165
166 // Public Enumerations
167
168 //- Write format enumeration
169 enum class writeFormat
170 {
171 dict,
172 json
173 };
174
175 //- Lookup mode enumeration
176 enum class lookupMode
177 {
178 none,
179 warn,
180 error
181 };
182
183
184private:
185
186 // Private Data
187
188 //- Write format names
189 static const Enum<writeFormat> writeFormatNames_;
190
191 //- Lookup mode names
192 static const Enum<lookupMode> lookupModeNames_;
193
194 //- Write/output format, e.g. dictionary, JSON
195 writeFormat writeFormat_;
196
197 //- Lookup mode when reading entries
198 lookupMode lookupMode_;
199
200 //- Dictionaries
201 dictionary dictionaries_;
202
203 //- List of function objects to process
204 wordList functionObjectNames_;
205
206
207 // Private Member Functions
209 //- Report
210 void report(const string& str) const;
212 //- Process dictionary
213 void processDict
214 (
216 const dictionary& targetDict,
217 const entry* includePtr,
218 const entry* excludePtr
219 ) const;
222protected:
223
224 // Protected Member Functions
225
226 //- No copy construct
227 caseInfo(const caseInfo&) = delete;
228
229 //- No copy assignment
230 void operator=(const caseInfo&) = delete;
231
232
233 // Write data
234
235 //- Write case meta data
236 void writeMeta(dictionary& dict) const;
237
238 //- Write registered dictionaries
240 (
241 const objectRegistry& obr,
243 dictionary& dictionaries
244 ) const;
245
246 //- Write file-based dictionaries
247 void writeFileDicts
248 (
250 dictionary& dictionaries
251 ) const;
252
253 //- Write function object results
255
256 //- Write mesh statistics
257 void writeMeshStats(const polyMesh& mesh, dictionary& dict) const;
258
259 //- Write mesh patches
260 void writePatches(const fvMesh& mesh, dictionary& dict) const;
261
262
263public:
264
265 //- Runtime type information
266 TypeName("caseInfo");
267
268
269 // Constructors
270
271 //- Construct from name, Time and dictionary
273 (
274 const word& name,
275 const Time& runTime,
276 const dictionary& dict
277 );
278
279
280 //- Destructor
281 virtual ~caseInfo() = default;
282
283
284 // Member Functions
285
287 using regIOobject::write;
288
289 //- Read the function-object dictionary
290 virtual bool read(const dictionary& dict);
292 //- Execute the function-object operations (no-op)
293 virtual bool execute();
294
295 //- Write the function-object results
296 virtual bool write();
297};
298
299
300// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301
302} // End namespace functionObjects
303} // End namespace Foam
304
305// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306
307#endif
308
309// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
IOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
const word & name() const
Name function is needed to disambiguate those inherited from regIOobject and dictionary.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
dictionary()
Default construct, a top-level empty dictionary.
Definition dictionary.C:68
friend class entry
Declare friendship with the entry class for IO.
Definition dictionary.H:338
A keyword and a list of tokens is an 'entry'.
Definition entry.H:66
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition error.H:74
Collects and writes case information to file.
Definition caseInfo.H:200
void writeRegisteredDicts(const objectRegistry &obr, dictionary &dict, dictionary &dictionaries) const
Write registered dictionaries.
Definition caseInfo.C:181
writeFormat
Write format enumeration.
Definition caseInfo.H:209
lookupMode
Lookup mode enumeration.
Definition caseInfo.H:218
void writeMeshStats(const polyMesh &mesh, dictionary &dict) const
Write mesh statistics.
Definition caseInfo.C:304
void writeMeta(dictionary &dict) const
Write case meta data.
Definition caseInfo.C:170
caseInfo(const caseInfo &)=delete
No copy construct.
void operator=(const caseInfo &)=delete
No copy assignment.
void writeFunctionObjects(dictionary &dict) const
Write function object results.
Definition caseInfo.C:284
void writePatches(const fvMesh &mesh, dictionary &dict) const
Write mesh patches.
Definition caseInfo.C:367
virtual bool execute()
Execute the function-object operations (no-op).
Definition caseInfo.C:442
virtual bool write()
Write the function-object results.
Definition caseInfo.C:448
void writeFileDicts(dictionary &dict, dictionary &dictionaries) const
Write file-based dictionaries.
Definition caseInfo.C:228
virtual ~caseInfo()=default
Destructor.
TypeName("caseInfo")
Runtime type information.
virtual bool read()
Read object.
Base class for function objects, adding functionality to read/write state information (data required ...
stateFunctionObject(const stateFunctionObject &)=delete
No copy construct.
Base class for writing single files from the function objects.
Definition writeFile.H:113
writeFile(const objectRegistry &obr, const fileName &prefix, const word &name="undefined", const bool writeToFile=true, const string &ext=".dat")
Construct from objectRegistry, prefix, fileName.
Definition writeFile.C:200
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Registry of regIOobjects.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
virtual bool read()
Read object.
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
engineTime & runTime
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68