IOobject.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-2017 OpenFOAM Foundation
9  Copyright (C) 2016-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::IOobject
29 
30 Description
31  Defines the attributes of an object for which implicit
32  objectRegistry management is supported, and provides the infrastructure
33  for performing stream I/O.
34 
35  An IOobject is constructed with an object name, a class name, an instance
36  path, a reference to a objectRegistry, and parameters determining its
37  storage status.
38 
39  \par Read options
40 
41  Define what is done on object construction and explicit reads:
42  - \par NO_READ
43  Do not read
44  - \par MUST_READ
45  Object must be read from Istream on construction. \n
46  Error if Istream does not exist or cannot be read.
47  Does not check timestamp or re-read.
48  - \par READ_MODIFIED (MUST_READ_IF_MODIFIED)
49  Object must be read from Istream on construction. \n
50  Error if Istream does not exist or cannot be read. If object is
51  registered its timestamp will be checked every timestep and possibly
52  re-read.
53  - \par LAZY_READ (READ_IF_PRESENT)
54  Read object from Istream, but only if Istream exists. \n
55  Error only if Istream exists but cannot be read.
56  Does not check timestamp or re-read.
57 
58  \par Write options
59 
60  Define what is done on object destruction and explicit writes:
61  - \par NO_WRITE
62  No automatic writing, but can be written explicitly
63  - \par AUTO_WRITE
64  Object is written automatically when requested to by the
65  objectRegistry.
66 
67  When serializing, the IOobject characteristics are typically written
68  as a \c FoamFile header, which is a sub-dictionary with the following
69  type of content:
70 
71  \table
72  Property | Description | Type | Reqd | Deflt
73  version | The base format version | float | no | 2.0
74  format | The stream format (ascii/binary) | word | yes |
75  arch | The architecture string | string | no |
76  note | Descriptive note about the object | string | no |
77  location | The relative location of the object | string | no |
78  class | The type of the object | word | yes |
79  object | The name of the object | word | yes |
80  \endtable
81 
82 Note
83  Specifying registered does not result in the IOobject itself being
84  registered. It is only serves as guidance for a regIOobject using it.
85 
86 See also
87  Foam::objectRegistry
88  Foam::regIOobject
89 
90 SourceFiles
91  IOobject.C
92  IOobjectReadHeader.C
93  IOobjectWriteHeader.C
94  IOobjectPrint.C
95 
96 \*---------------------------------------------------------------------------*/
97 
98 #ifndef Foam_IOobject_H
99 #define Foam_IOobject_H
100 
101 #include "fileName.H"
102 #include "typeInfo.H"
103 #include "refPtr.H" // For autoPtr, refPtr, tmp, stdFoam
104 #include "Enum.H"
105 #include "InfoProxy.H"
106 #include "IOobjectOption.H"
107 #include "IOstreamOption.H"
108 #include <type_traits>
109 
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 
112 namespace Foam
113 {
114 
115 // Forward Declarations
116 class Time;
117 class dictionary;
118 class objectRegistry;
119 class IOobject;
120 
121 template<>
122 Ostream& operator<<(Ostream&, const InfoProxy<IOobject>&);
123 
124 
125 /*---------------------------------------------------------------------------*\
126  Class IOobject Declaration
127 \*---------------------------------------------------------------------------*/
128 
129 class IOobject
130 :
131  public IOobjectOption
132 {
133 public:
134 
135  // Public Data Types
136 
137  //- Enumeration defining the valid states of an IOobject
138  enum objectState : char
139  {
140  GOOD,
141  BAD
142  };
143 
144  //- Enumeration defining the file checking options
145  enum fileCheckTypes : char
146  {
147  timeStamp,
149  inotify,
151  };
152 
153  //- Names for the fileCheckTypes
154  static const Enum<fileCheckTypes> fileCheckTypesNames;
155 
156 
157 private:
158 
159  // Static Data Members
160 
161  //- Use an output file banner, enabled by default
162  static bool bannerEnabled_;
163 
164 
165  // Private Data (NB: byte-flags first for better alignment)
166 
167  //- The IOobject state
168  objectState objState_;
169 
170  //- The sizeof (label) in bytes, possibly read from the header
171  unsigned char sizeofLabel_;
173  //- The sizeof (scalar) in bytes, possibly read from the header
174  unsigned char sizeofScalar_;
175 
176  //- Name
177  word name_;
178 
179  //- Class name read from header
180  word headerClassName_;
181 
182  //- Optional note
183  string note_;
184 
185  //- Instance path component
186  fileName instance_;
187 
188  //- Local path component
189  fileName local_;
190 
191  //- Reference to the objectRegistry
192  const objectRegistry& db_;
193 
195  // Private Member Functions
197  //- Construct from registry, io options. Without name, instance, local
198  IOobject(const objectRegistry& registry, IOobjectOption ioOpt);
199 
200  //- Read header and check its info.
201  // Optionally checks headerClassName against the type-name.
202  // When search is false, simply use the current instance,
203  // otherwise search previous instances.
204  bool readAndCheckHeader
205  (
206  const bool isGlobal,
207  const word& typeName,
208  const bool checkType = true,
209  const bool search = true,
210  const bool verbose = true
211  );
212 
213 
214 protected:
215 
216  // Protected Member Functions
217 
218  //- Helper: write content for FoamFile IOobject header
219  //- with optional meta information.
220  static void writeHeaderContent
221  (
222  Ostream& os,
223  const IOobject& io,
224  const word& objectType,
225  const dictionary* metaDataDict = nullptr
226  );
227 
228  //- Helper: write dictionary content for FoamFile header
229  //- with optional meta information.
230  static void writeHeaderContent
231  (
232  dictionary& dict,
233  const IOobject& io,
234  const word& objectType,
235  IOstreamOption streamOpt,
236  const dictionary* metaDataDict = nullptr
237  );
238 
239  //- Set the object state to bad
240  void setBad(const string& s);
241 
242 
243 public:
244 
245  //- Declare type-name, virtual type (with debug switch)
246  TypeName("IOobject");
247 
248 
249  // Static Data
250 
251  //- Character for scoping object names (':' or '_')
252  // Change with caution.
253  static char scopeSeparator;
254 
255  //- Type of file modification checking
257 
258  //- Time skew (seconds) for file modification checks
259  static float fileModificationSkew;
260 
261  //- Max number of times to poll for file modification changes
262  static int maxFileModificationPolls;
263 
264 
265  // Static Functions
266 
267  //- Status of output file banner
268  static bool bannerEnabled() noexcept
269  {
270  return bannerEnabled_;
271  }
272 
273  //- Enable/disable output file banner
274  // \return the previous value
275  static bool bannerEnabled(bool on) noexcept
276  {
277  bool old(bannerEnabled_);
278  bannerEnabled_ = on;
279  return old;
280  }
281 
282  //- Split path into instance, local, name components
283  //
284  // The splitting behaviour is as follows:
285  // \verbatim
286  // input | instance | local | name
287  // ----------- | ---------- | ----- | ----
288  // a | | | a
289  // a/b | a | | b
290  // a/b/c/d | a | b/c | d
291  // /a/b/c | /a/b | | c
292  // ./a/b/c | PWD/a/b | | c
293  // ../a/b/c | PWD/../a/b | | c
294  // a/b/ | ERROR | |
295  // \endverbatim
296  // where PWD is the Foam::cwd() current working directory
297  static bool fileNameComponents
298  (
299  const fileName& path,
300  fileName& instance,
301  fileName& local,
302  word& name
303  );
304 
305  //- Create dot-delimited name.group string
306  // An empty group is ignored.
307  template<class StringType>
308  static inline word groupName(StringType base, const word& group);
309 
310  //- Return group (extension part of name)
311  static word group(const word& name);
312 
313  //- Return member (name without the extension)
314  static word member(const word& name);
315 
316  //- Create scope:name or scope_name string
317  // An empty scope is ignored.
318  static inline word scopedName
319  (
320  const std::string& scope,
321  const word& name
322  );
323 
324  //- Create scope:name1:name2 or scope_name1_name2 string
325  // An empty scope is ignored.
326  static inline word scopedName
327  (
328  const std::string& scope,
329  const word& name1,
330  const word& name2
331  );
332 
333  //- Return the IOobject, but also consider an alternative file name.
334  //
335  // \param io The expected IOobject to use
336  // \param altFile Alternative fileName (ignored if empty).
337  // \param ioName The alternative name for the IOobject when
338  // the altFile resolves to a directory.
339  //
340  // \note If the alternative fileName is a non-empty string,
341  // it defines the location but uses all other properties of the
342  // expected IOobject.
343  // The location may be an absolute or a relative path.
344  // If it corresponds to a directory, the name of the
345  // expected IOobject will be used in its resolution.
346  // This expected name can provided via the ioName parameter.
347  static IOobject selectIO
348  (
349  const IOobject& io,
350  const fileName& altFile,
351  const word& ioName = ""
352  );
354 
355  // Generated Methods
356 
357  //- Copy construct
358  IOobject(const IOobject&) = default;
359 
360  //- Destructor
361  virtual ~IOobject() = default;
362 
363 
364  // Constructors
365 
366  //- Construct from name, instance, registry, io options
367  // (default: NO_READ, NO_WRITE, REGISTER, non-global)
368  IOobject
369  (
370  const word& name,
372  const objectRegistry& registry,
374  );
375 
376  //- Construct from name, instance, local, registry, io options
377  // (default: NO_READ, NO_WRITE, REGISTER, non-global)
378  IOobject
379  (
380  const word& name,
381  const fileName& instance,
382  const fileName& local,
383  const objectRegistry& registry,
385  );
386 
387  //- Construct from path, registry, io options.
388  // (default: NO_READ, NO_WRITE, REGISTER, non-global)
389  //
390  // Uses fileNameComponents() to split path into components.
391  // A path that starts with a '/' is regarded as a file system path.
392  // Paths starting with either './' or '../' are relative to
393  // current working directory (and replaced with absolute equivalents).
394  // All other paths are considered to be relative to the case.
395  IOobject
396  (
397  const fileName& path,
398  const objectRegistry& registry,
400  );
401 
402  //- Construct from name, instance, registry, io options
403  inline IOobject
404  (
405  const word& name,
406  const fileName& instance,
407  const objectRegistry& registry,
410  bool registerObject = true, // == IOobjectOption::LEGACY_REGISTER
411  bool globalObject = false
412  );
413 
414  //- Construct from name, instance, local, registry, io options
415  inline IOobject
416  (
417  const word& name,
418  const fileName& instance,
419  const fileName& local,
420  const objectRegistry& registry,
423  bool registerObject = true, // == IOobjectOption::LEGACY_REGISTER
424  bool globalObject = false
425  );
426 
427  //- Construct from path, registry, io options.
428  // Uses fileNameComponents() to split path into components.
429  // A path that starts with a '/' is regarded as a file system path.
430  // Paths starting with either './' or '../' are relative to
431  // current working directory (and replaced with absolute equivalents).
432  // All other paths are considered to be relative to the case.
433  inline IOobject
434  (
435  const fileName& path,
436  const objectRegistry& registry,
439  bool registerObject = true, // == IOobjectOption::LEGACY_REGISTER
440  bool globalObject = false
441  );
442 
443  //- Copy construct, resetting registry
444  IOobject(const IOobject& io, const objectRegistry& registry);
445 
446  //- Copy construct, resetting name
447  IOobject(const IOobject& io, const word& name);
448 
449  //- Copy construct, resetting name and local component
450  inline IOobject
451  (
452  const IOobject& io,
453  const word& name,
454  const fileName& local
455  );
456 
457  //- Copy construct, resetting read/write options
458  inline IOobject
459  (
460  const IOobject& io,
463  );
464 
465  //- Copy construct, resetting register option
466  inline IOobject
467  (
468  const IOobject& io,
470  );
471 
472 
473  //- Clone
474  autoPtr<IOobject> clone() const
475  {
476  return autoPtr<IOobject>::New(*this);
477  }
478 
479  //- Clone resetting registry
480  autoPtr<IOobject> clone(const objectRegistry& registry) const
481  {
482  return autoPtr<IOobject>::New(*this, registry);
483  }
484 
485 
486  // Member Functions
487 
488  // General Access
489 
490  //- Return the local objectRegistry
491  const objectRegistry& db() const noexcept;
492 
493  //- Return Time associated with the objectRegistry
494  const Time& time() const noexcept;
495 
496  //- Return the object name
497  inline const word& name() const noexcept;
498 
499  //- Return name of the class name read from header
500  inline const word& headerClassName() const noexcept;
501 
502  //- Return non-constant access to the class name read from header
503  inline word& headerClassName() noexcept;
504 
505  //- Return the optional note
506  inline const string& note() const noexcept;
507 
508  //- Modifiable access to the optional note
509  inline string& note() noexcept;
510 
511  //- Rename the object
512  virtual void rename(const word& newName)
513  {
514  name_ = newName;
515  }
516 
517  //- The sizeof (label) in bytes, possibly read from the header
518  inline unsigned labelByteSize() const noexcept;
519 
520  //- The sizeof (scalar) in bytes, possibly read from the header
521  inline unsigned scalarByteSize() const noexcept;
522 
523  //- Clear various bits (headerClassName, note, sizeof...)
524  //- that would be obtained when reading from a file.
525  // \param newName if non-null, optionally rename the IOobject
526  void resetHeader(const word& newName = word::null);
527 
528 
529  // Checks
530 
531  //- True if headerClassName() is non-empty (after reading)
532  inline bool hasHeaderClass() const noexcept;
533 
534  //- Check if headerClassName() equals Type::typeName
535  template<class Type>
536  inline bool isHeaderClass() const;
537 
538  //- Same as isHeaderClass()
539  template<class Type>
540  bool isHeaderClassName() const { return isHeaderClass<Type>(); }
541 
542 
543  // Meta-data
544 
545  //- Return pointer to meta-data (if any) or nullptr
546  virtual const dictionary* findMetaData() const noexcept;
547 
548 
549  // Path components
550 
551  //- Return group (extension part of name)
552  inline word group() const;
553 
554  //- Return member (name without the extension)
555  inline word member() const;
556 
557  //- Return the Time::rootPath()
558  const fileName& rootPath() const noexcept;
559 
560  //- Return the Time::caseName()
561  const fileName& caseName() const noexcept;
562 
563  //- Return the Time::globalCaseName()
564  const fileName& globalCaseName() const noexcept;
565 
566  //- Read access to instance path component
567  inline const fileName& instance() const noexcept;
568 
569  //- Write access to instance path component
570  inline fileName& instance() noexcept;
571 
572  //- Read access to local path component
573  inline const fileName& local() const noexcept;
574 
575  //- The complete path for the object (with instance, local,...).
576  fileName path() const;
577 
578  //- The complete global path for the object (with instance, local,...)
579  fileName globalPath() const;
580 
581  //- The complete path with alternative instance and local
582  fileName path
583  (
584  const word& instance,
585  const fileName& local = fileName::null
586  ) const;
587 
588  //- The complete global path with alternative instance and local
589  fileName globalPath
590  (
591  const word& instance,
592  const fileName& local = fileName::null
593  ) const;
594 
595  //- The complete path + object name
596  inline fileName objectPath() const;
597 
598  //- The complete global path + object name
599  inline fileName globalObjectPath() const;
600 
601  //- The object path relative to the root
602  fileName objectRelPath() const;
603 
604  //- Redirect to fileHandler filePath, searching locally.
605  // When search is false, simply use the current instance,
606  // otherwise search previous instances.
607  fileName localFilePath
608  (
609  const word& typeName,
610  const bool search=true
611  ) const;
612 
613  //- Redirect to fileHandler filePath, searching up if in parallel.
614  // When search is false, simply use the current instance,
615  // otherwise search previous instances.
616  fileName globalFilePath
617  (
618  const word& typeName,
619  const bool search=true
620  ) const;
622 
623  // Reading
624 
625  //- Parse 'FoamFile' header contents and set the IOobject
626  //- characteristics and return the stream characteristics.
627  IOstreamOption parseHeader(const dictionary& headerDict);
628 
629  //- Read header ('FoamFile' dictionary) and set the
630  //- IOobject and stream characteristics.
631  bool readHeader(Istream& is);
632 
633  //- Read header (the 'FoamFile' dictionary) and set the
634  //- IOobject and stream characteristics.
635  // Saves the header content in the given dictionary.
636  bool readHeader(dictionary& headerDict, Istream& is);
637 
638  //- Read header (respects is_globalIOobject trait) and check its info.
639  template<class Type>
640  bool typeHeaderOk
641  (
643  const bool checkType = true,
645  const bool search = true,
647  const bool verbose = true
648  );
649 
650  //- Call localFilePath or globalFilePath for given type
651  //- depending on its is_globalIOobject trait.
652  template<class Type>
653  fileName typeFilePath(const bool search = true) const;
654 
655  //- Helper: warn that type does not support re-reading
656  template<class Type>
657  void warnNoRereading() const;
658 
659 
660  // Writing
661 
662  //- Write the standard OpenFOAM file/dictionary banner
663  // Optionally without editor syntax hint (eg, for logs)
664  static Ostream& writeBanner(Ostream& os, const bool noSyntaxHint=false);
665 
666  //- Write the standard file section divider
667  static Ostream& writeDivider(Ostream& os);
668 
669  //- Write the standard end file divider
670  static Ostream& writeEndDivider(Ostream& os);
671 
672  //- Write header with current type()
673  bool writeHeader(Ostream& os) const;
674 
675  //- Write header with override of type
676  bool writeHeader(Ostream& os, const word& objectType) const;
678  //- Write header into a dictionary with current type()
679  //- and given output format
680  void writeHeader(dictionary& dict, IOstreamOption streamOpt) const;
681 
682  //- Write header into a dictionary with override of type
683  //- and given output format
684  void writeHeader
685  (
686  dictionary& dict,
687  const word& objectType,
688  IOstreamOption streamOpt
689  ) const;
690 
691 
692  // Error Handling
693 
694  //- Did last readHeader() succeed?
695  inline bool good() const noexcept;
696 
697  //- Did last readHeader() fail?
698  inline bool bad() const noexcept;
699 
700 
701  // Info
702 
703  //- Return info proxy,
704  //- for printing information to a stream
705  InfoProxy<IOobject> info() const noexcept { return *this; }
706 
707 
708  // Member Operators
709 
710  //- Copy assignment, copies all values (except the registry)
711  void operator=(const IOobject& io);
712 };
713 
714 
715 //- Specialization for \c void always returns true (no headerClassName check).
716 template<>
717 inline bool IOobject::isHeaderClass<void>() const
718 {
719  return true;
720 }
721 
722 
723 //- Trait for specifying global vs. local file types
724 template<class T>
725 struct is_globalIOobject : std::false_type {};
726 
727 
728 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
729 
730 } // End namespace Foam
731 
732 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
733 
734 #include "IOobjectI.H"
735 
736 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
737 
738 #ifdef NoRepository
739 # include "IOobjectTemplates.C"
740 #endif
741 
742 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
743 
744 #endif
745 
746 // ************************************************************************* //
constexpr IOobjectOption(readOption rOpt=readOption::NO_READ, writeOption wOpt=writeOption::NO_WRITE, registerOption registerObject=registerOption::REGISTER, bool globalObject=false) noexcept
Default construct (NO_READ, NO_WRITE, REGISTER, non-global) or construct with specified options...
writeOption
Enumeration defining write preferences.
dictionary dict
autoPtr< IOobject > clone() const
Clone.
Definition: IOobject.H:621
static bool fileNameComponents(const fileName &path, fileName &instance, fileName &local, word &name)
Split path into instance, local, name components.
Definition: IOobject.C:165
A class for handling file names.
Definition: fileName.H:72
fileName globalFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching up if in parallel.
Definition: IOobject.C:547
static float fileModificationSkew
Time skew (seconds) for file modification checks.
Definition: IOobject.H:348
void operator=(const IOobject &io)
Copy assignment, copies all values (except the registry)
Definition: IOobject.C:603
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual const dictionary * findMetaData() const noexcept
Return pointer to meta-data (if any) or nullptr.
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
virtual void rename(const word &newName)
Rename the object.
Definition: IOobject.H:677
Trait for specifying global vs. local file types.
Definition: IOobject.H:981
static Ostream & writeDivider(Ostream &os)
Write the standard file section divider.
const string & note() const noexcept
Return the optional note.
Definition: IOobjectI.H:225
word member() const
Return member (name without the extension)
Definition: IOobjectI.H:207
void setBad(const string &s)
Set the object state to bad.
Definition: IOobject.C:568
A simple container for options an IOstream can normally have.
bool bad() const noexcept
Did last readHeader() fail?
Definition: IOobjectI.H:304
word group() const
Return group (extension part of name)
Definition: IOobjectI.H:201
bool good() const noexcept
Did last readHeader() succeed?
Definition: IOobjectI.H:298
Ignore writing from objectRegistry::writeObject()
bool writeHeader(Ostream &os) const
Write header with current type()
fileName objectPath() const
The complete path + object name.
Definition: IOobjectI.H:284
fileName typeFilePath(const bool search=true) const
Call localFilePath or globalFilePath for given type depending on its is_globalIOobject trait...
IOstreamOption parseHeader(const dictionary &headerDict)
Parse &#39;FoamFile&#39; header contents and set the IOobject characteristics and return the stream character...
fileName path() const
The complete path for the object (with instance, local,...).
Definition: IOobject.C:480
bool hasHeaderClass() const noexcept
True if headerClassName() is non-empty (after reading)
Definition: IOobjectI.H:251
const fileName & caseName() const noexcept
Return the Time::caseName()
Definition: IOobject.C:468
bool globalObject() const noexcept
True if object is treated the same for all processors.
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
static word scopedName(const std::string &scope, const word &name)
Create scope:name or scope_name string.
Definition: IOobjectI.H:40
A class for handling words, derived from Foam::string.
Definition: word.H:63
fileCheckTypes
Enumeration defining the file checking options.
Definition: IOobject.H:192
static int maxFileModificationPolls
Max number of times to poll for file modification changes.
Definition: IOobject.H:353
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:450
fileName localFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching locally.
Definition: IOobject.C:536
const fileName & globalCaseName() const noexcept
Return the Time::globalCaseName()
Definition: IOobject.C:474
virtual ~IOobject()=default
Destructor.
bool typeHeaderOk(const bool checkType=true, const bool search=true, const bool verbose=true)
Read header (respects is_globalIOobject trait) and check its info.
const Time & time() const noexcept
Return Time associated with the objectRegistry.
Definition: IOobject.C:456
InfoProxy< IOobject > info() const noexcept
Return info proxy, for printing information to a stream.
Definition: IOobject.H:955
static Ostream & writeEndDivider(Ostream &os)
Write the standard end file divider.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
static const Enum< fileCheckTypes > fileCheckTypesNames
Names for the fileCheckTypes.
Definition: IOobject.H:203
OBJstream os(runTime.globalPath()/outputName)
static fileCheckTypes fileModificationChecking
Type of file modification checking.
Definition: IOobject.H:343
static bool bannerEnabled() noexcept
Status of output file banner.
Definition: IOobject.H:361
fileName globalObjectPath() const
The complete global path + object name.
Definition: IOobjectI.H:290
const fileName & instance() const noexcept
Read access to instance path component.
Definition: IOobjectI.H:266
static char scopeSeparator
Character for scoping object names (&#39;:&#39; or &#39;_&#39;)
Definition: IOobject.H:338
unsigned labelByteSize() const noexcept
The sizeof (label) in bytes, possibly read from the header.
Definition: IOobjectI.H:237
static void writeHeaderContent(Ostream &os, const IOobject &io, const word &objectType, const dictionary *metaDataDict=nullptr)
Helper: write content for FoamFile IOobject header with optional meta information.
registerOption
Enumeration for use with registerObject(). Values map to bool (false/true)
const word & headerClassName() const noexcept
Return name of the class name read from header.
Definition: IOobjectI.H:213
const fileName & rootPath() const noexcept
Return the Time::rootPath()
Definition: IOobject.C:462
A helper class for outputting values to Ostream.
Definition: ensightCells.H:43
bool isHeaderClassName() const
Same as isHeaderClass()
Definition: IOobject.H:718
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
TypeName("IOobject")
Declare type-name, virtual type (with debug switch)
fileName objectRelPath() const
The object path relative to the root.
Definition: IOobject.C:524
bool registerObject() const noexcept
Should objects created with this IOobject be registered?
static Ostream & writeBanner(Ostream &os, const bool noSyntaxHint=false)
Write the standard OpenFOAM file/dictionary banner.
fileName globalPath() const
The complete global path for the object (with instance, local,...)
Definition: IOobject.C:491
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition: fileName.C:642
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Registry of regIOobjects.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition: autoPtr.H:178
objectState
Enumeration defining the valid states of an IOobject.
Definition: IOobject.H:183
const fileName & local() const noexcept
Read access to local path component.
Definition: IOobjectI.H:278
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void resetHeader(const word &newName=word::null)
Clear various bits (headerClassName, note, sizeof...) that would be obtained when reading from a file...
Definition: IOobject.C:587
bool readHeader(Istream &is)
Read header (&#39;FoamFile&#39; dictionary) and set the IOobject and stream characteristics.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
void warnNoRereading() const
Helper: warn that type does not support re-reading.
Namespace for OpenFOAM.
static IOobject selectIO(const IOobject &io, const fileName &altFile, const word &ioName="")
Return the IOobject, but also consider an alternative file name.
Definition: IOobject.C:256
bool isHeaderClass() const
Check if headerClassName() equals Type::typeName.
Definition: IOobjectI.H:258
unsigned scalarByteSize() const noexcept
The sizeof (scalar) in bytes, possibly read from the header.
Definition: IOobjectI.H:243
readOption
Enumeration defining read preferences.