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 "IOdictionary.H"
122 #include "writeFile.H"
123 #include "stateFunctionObject.H"
124 #include "Enum.H"
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 namespace Foam
129 {
130 
131 // Forward declarations
132 class fvMesh;
133 
134 namespace functionObjects
135 {
136 
137 /*---------------------------------------------------------------------------*\
138  Class caseInfo Declaration
139 \*---------------------------------------------------------------------------*/
140 
141 class caseInfo
142 :
143  public IOdictionary,
144  public stateFunctionObject,
145  public writeFile
146 {
147 public:
148 
149  // Public enumerations
150 
151  //- Write format enumeration
152  enum class writeFormat
153  {
154  dict,
155  json
156  };
157 
158  //- Lookup mode enumeration
159  enum class lookupMode
160  {
161  none,
162  warn,
163  error
164  };
165 
167 private:
168 
169  // Private Member Data
170 
171  //- Write format names
172  static const Enum<writeFormat> writeFormatNames_;
173 
174  //- Lookup mode names
175  static const Enum<lookupMode> lookupModeNames_;
176 
177  //- Write/output format, e.g. dictionary, JSON
178  writeFormat writeFormat_;
180  //- Lookup mode when reading entries
181  lookupMode lookupMode_;
182 
183  //- Dictionaries
184  dictionary dictionaries_;
185 
186  //- List of function objects to process
187  wordList functionObjectNames_;
189 
190  // Private Member Functions
191 
192  //- Report
193  void report(const string& str) const;
194 
195  //- Process dictionary
196  void processDict
197  (
198  dictionary& dict,
199  const dictionary& targetDict,
200  const entry* includePtr,
201  const entry* excludePtr
202  ) const;
203 
204 
205 protected:
206 
207  // Protected Member Functions
208 
209  //- No copy construct
210  caseInfo(const caseInfo&) = delete;
211 
212  //- No copy assignment
213  void operator=(const caseInfo&) = delete;
214 
215 
216  // Write data
217 
218  //- Write case meta data
219  void writeMeta(dictionary& dict) const;
220 
221  //- Write registered dictionaries
223  (
224  const objectRegistry& obr,
225  dictionary& dict,
226  dictionary& dictionaries
227  ) const;
228 
229  //- Write file-based dictionaries
230  void writeFileDicts
231  (
232  dictionary& dict,
233  dictionary& dictionaries
234  ) const;
235 
236  //- Write function object results
237  void writeFunctionObjects(dictionary& dict) const;
238 
239  //- Write mesh statistics
240  void writeMeshStats(const polyMesh& mesh, dictionary& dict) const;
241 
242  //- Write mesh patches
243  void writePatches(const fvMesh& mesh, dictionary& dict) const;
244 
245 
246 public:
247 
248  //- Runtime type information
249  TypeName("caseInfo");
250 
251 
252  // Constructors
253 
254  //- Construct from Time and dictionary
255  caseInfo
256  (
257  const word& name,
258  const Time& runTime,
259  const dictionary& dict
260  );
261 
262 
263  //- Destructor
264  virtual ~caseInfo() = default;
265 
266 
267  // Member Functions
268 
269  using regIOobject::read;
270  using regIOobject::write;
271 
272  //- Read the controls
273  virtual bool read(const dictionary& dict);
274 
275  //- Execute, does nothing
276  virtual bool execute();
277 
278  //- Write the caseInfo
279  virtual bool write();
280 };
281 
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 } // End namespace functionObjects
286 } // End namespace Foam
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 #endif
291 
292 // ************************************************************************* //
virtual bool read()
Read object.
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:188
Collects and writes case information to file.
Definition: caseInfo.H:166
engineTime & runTime
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:442
void writeMeshStats(const polyMesh &mesh, dictionary &dict) const
Write mesh statistics.
Definition: caseInfo.C:304
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:170
caseInfo(const caseInfo &)=delete
No copy construct.
void writeRegisteredDicts(const objectRegistry &obr, dictionary &dict, dictionary &dictionaries) const
Write registered dictionaries.
Definition: caseInfo.C:181
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
virtual ~caseInfo()=default
Destructor.
writeFormat
Write format enumeration.
Definition: caseInfo.H:179
TypeName("caseInfo")
Runtime type information.
const word & name() const
Name function is needed to disambiguate those inherited from regIOobject and dictionary.
void writePatches(const fvMesh &mesh, dictionary &dict) const
Write mesh patches.
Definition: caseInfo.C:367
void writeFileDicts(dictionary &dict, dictionary &dictionaries) const
Write file-based dictionaries.
Definition: caseInfo.C:228
void writeFunctionObjects(dictionary &dict) const
Write function object results.
Definition: caseInfo.C:284
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
void operator=(const caseInfo &)=delete
No copy assignment.
Registry of regIOobjects.
virtual bool write()
Write the caseInfo.
Definition: caseInfo.C:448
Namespace for OpenFOAM.
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:63