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 // Traits
125 
126 //- Trait for specifying global vs. local IOobject file types
127 template<class T>
128 struct is_globalIOobject : std::false_type {};
129 
130 
131 /*---------------------------------------------------------------------------*\
132  Class IOobject Declaration
133 \*---------------------------------------------------------------------------*/
134 
135 class IOobject
136 :
137  public IOobjectOption
138 {
139 public:
140 
141  // Public Data Types
142 
143  //- Enumeration defining the valid states of an IOobject
144  enum objectState : char
145  {
146  GOOD,
147  BAD
148  };
149 
150  //- Enumeration defining the file checking options
151  enum fileCheckTypes : char
152  {
153  timeStamp,
155  inotify,
157  };
158 
159  //- Names for the fileCheckTypes
160  static const Enum<fileCheckTypes> fileCheckTypesNames;
161 
162 
163 private:
164 
165  // Static Data Members
166 
167  //- Use an output file banner, enabled by default
168  static bool bannerEnabled_;
169 
170 
171  // Private Data (NB: byte-flags first for better alignment)
172 
173  //- The IOobject state
174  objectState objState_;
175 
176  //- The sizeof (label) in bytes, possibly read from the header
177  unsigned char sizeofLabel_;
178 
179  //- The sizeof (scalar) in bytes, possibly read from the header
180  unsigned char sizeofScalar_;
181 
182  //- Name
183  word name_;
184 
185  //- Class name read from header
186  word headerClassName_;
187 
188  //- Optional note
189  string note_;
190 
191  //- Instance path component
192  fileName instance_;
194  //- Local path component
195  fileName local_;
196 
197  //- Reference to the objectRegistry
198  const objectRegistry& db_;
199 
201  // Private Member Functions
203  //- Construct from registry, io options. Without name, instance, local
204  IOobject(const objectRegistry& registry, IOobjectOption ioOpt);
206  //- Read header and check its info.
207  // Optionally checks headerClassName against the type-name.
208  // When search is false, simply use the current instance,
209  // otherwise search previous instances.
210  bool readAndCheckHeader
211  (
212  const bool isGlobal,
213  const word& typeName,
214  const bool checkType = true,
215  const bool search = true,
216  const bool verbose = true
217  );
218 
219 
220 protected:
221 
222  // Protected Member Functions
223 
224  //- Helper: write content for FoamFile IOobject header
225  //- with optional meta information.
226  static void writeHeaderContent
227  (
228  Ostream& os,
229  const IOobject& io,
230  const word& objectType,
231  const dictionary* metaDataDict = nullptr
232  );
233 
234  //- Helper: write dictionary content for FoamFile header
235  //- with optional meta information.
236  static void writeHeaderContent
237  (
238  dictionary& dict,
239  const IOobject& io,
240  const word& objectType,
241  IOstreamOption streamOpt,
242  const dictionary* metaDataDict = nullptr
243  );
244 
245  //- Set the object state to bad
246  void setBad(const string& s);
247 
248 
249 public:
250 
251  //- Declare type-name, virtual type (with debug switch)
252  TypeName("IOobject");
253 
254 
255  // Static Data
256 
257  //- Character for scoping object names (':' or '_')
258  // Change with caution.
259  static char scopeSeparator;
260 
261  //- Type of file modification checking
263 
264  //- Time skew (seconds) for file modification checks
265  static float fileModificationSkew;
266 
267  //- Max number of times to poll for file modification changes
268  static int maxFileModificationPolls;
269 
270 
271  // Static Functions
272 
273  //- Status of output file banner
274  static bool bannerEnabled() noexcept
275  {
276  return bannerEnabled_;
277  }
278 
279  //- Enable/disable output file banner
280  // \return the previous value
281  static bool bannerEnabled(bool on) noexcept
282  {
283  bool old(bannerEnabled_);
284  bannerEnabled_ = on;
285  return old;
286  }
287 
288  //- Split path into instance, local, name components
289  //
290  // The splitting behaviour is as follows:
291  // \verbatim
292  // input | instance | local | name
293  // ----------- | ---------- | ----- | ----
294  // a | | | a
295  // a/b | a | | b
296  // a/b/c/d | a | b/c | d
297  // /a/b/c | /a/b | | c
298  // ./a/b/c | PWD/a/b | | c
299  // ../a/b/c | PWD/../a/b | | c
300  // a/b/ | ERROR | |
301  // \endverbatim
302  // where PWD is the Foam::cwd() current working directory
303  static bool fileNameComponents
304  (
305  const fileName& path,
306  fileName& instance,
307  fileName& local,
308  word& name
309  );
310 
311  //- Create dot-delimited name.group string
312  // An empty group is ignored.
313  template<class StringType>
314  static inline word groupName(StringType base, const word& group);
315 
316  //- Return group (extension part of name)
317  static word group(const word& name);
318 
319  //- Return member (name without the extension)
320  static word member(const word& name);
321 
322  //- Create scope:name or scope_name string
323  // An empty scope is ignored.
324  static inline word scopedName
325  (
326  const std::string& scope,
327  const word& name
328  );
329 
330  //- Create scope:name1:name2 or scope_name1_name2 string
331  // An empty scope is ignored.
332  static inline word scopedName
333  (
334  const std::string& scope,
335  const word& name1,
336  const word& name2
337  );
338 
339  //- Return the IOobject, but also consider an alternative file name.
340  //
341  // \param io The expected IOobject to use
342  // \param altFile Alternative fileName (ignored if empty).
343  // \param ioName The alternative name for the IOobject when
344  // the altFile resolves to a directory.
345  //
346  // \note If the alternative fileName is a non-empty string,
347  // it defines the location but uses all other properties of the
348  // expected IOobject.
349  // The location may be an absolute or a relative path.
350  // If it corresponds to a directory, the name of the
351  // expected IOobject will be used in its resolution.
352  // This expected name can provided via the ioName parameter.
353  static IOobject selectIO
354  (
355  const IOobject& io,
356  const fileName& altFile,
357  const word& ioName = ""
358  );
359 
360 
361  // Generated Methods
362 
363  //- Copy construct
364  IOobject(const IOobject&) = default;
365 
366  //- Destructor
367  virtual ~IOobject() = default;
368 
370  // Constructors
371 
372  //- Construct from name, instance, registry, io options
373  // (default: NO_READ, NO_WRITE, REGISTER, non-global)
374  IOobject
375  (
376  const word& name,
377  const fileName& instance,
378  const objectRegistry& registry,
380  );
381 
382  //- Construct from name, instance, local, registry, io options
383  // (default: NO_READ, NO_WRITE, REGISTER, non-global)
384  IOobject
385  (
386  const word& name,
387  const fileName& instance,
388  const fileName& local,
389  const objectRegistry& registry,
391  );
392 
393  //- Construct from path, registry, io options.
394  // (default: NO_READ, NO_WRITE, REGISTER, non-global)
395  //
396  // Uses fileNameComponents() to split path into components.
397  // A path that starts with a '/' is regarded as a file system path.
398  // Paths starting with either './' or '../' are relative to
399  // current working directory (and replaced with absolute equivalents).
400  // All other paths are considered to be relative to the case.
401  IOobject
402  (
403  const fileName& path,
404  const objectRegistry& registry,
406  );
407 
408  //- Construct from name, instance, registry, io options
409  inline IOobject
410  (
411  const word& name,
412  const fileName& instance,
413  const objectRegistry& registry,
416  bool registerObject = true, // == IOobjectOption::LEGACY_REGISTER
417  bool globalObject = false
418  );
419 
420  //- Construct from name, instance, local, registry, io options
421  inline IOobject
422  (
423  const word& name,
424  const fileName& instance,
425  const fileName& local,
426  const objectRegistry& registry,
429  bool registerObject = true, // == IOobjectOption::LEGACY_REGISTER
430  bool globalObject = false
431  );
432 
433  //- Construct from path, registry, io options.
434  // Uses fileNameComponents() to split path into components.
435  // A path that starts with a '/' is regarded as a file system path.
436  // Paths starting with either './' or '../' are relative to
437  // current working directory (and replaced with absolute equivalents).
438  // All other paths are considered to be relative to the case.
439  inline IOobject
440  (
441  const fileName& path,
442  const objectRegistry& registry,
445  bool registerObject = true, // == IOobjectOption::LEGACY_REGISTER
446  bool globalObject = false
447  );
448 
449  //- Copy construct, resetting registry
450  IOobject(const IOobject& io, const objectRegistry& registry);
451 
452  //- Copy construct, resetting name
453  IOobject(const IOobject& io, const word& name);
454 
455  //- Copy construct, resetting name and local component
456  inline IOobject
457  (
458  const IOobject& io,
459  const word& name,
460  const fileName& local
461  );
462 
463  //- Copy construct, resetting read/write options
464  inline IOobject
465  (
466  const IOobject& io,
469  );
470 
471  //- Copy construct, resetting register option
472  inline IOobject
473  (
474  const IOobject& io,
476  );
477 
478 
479  //- Clone
480  autoPtr<IOobject> clone() const
481  {
482  return autoPtr<IOobject>::New(*this);
483  }
484 
485  //- Clone resetting registry
486  autoPtr<IOobject> clone(const objectRegistry& registry) const
487  {
488  return autoPtr<IOobject>::New(*this, registry);
489  }
490 
491 
492  // Member Functions
493 
494  // General Access
495 
496  //- Return the local objectRegistry
497  const objectRegistry& db() const noexcept;
498 
499  //- Return Time associated with the objectRegistry
500  const Time& time() const noexcept;
501 
502  //- Return the object name
503  inline const word& name() const noexcept;
504 
505  //- Return name of the class name read from header
506  inline const word& headerClassName() const noexcept;
507 
508  //- Return non-constant access to the class name read from header
509  inline word& headerClassName() noexcept;
510 
511  //- Return the optional note
512  inline const string& note() const noexcept;
513 
514  //- Modifiable access to the optional note
515  inline string& note() noexcept;
516 
517  //- Rename the object
518  virtual void rename(const word& newName)
519  {
520  name_ = newName;
521  }
522 
523  //- The sizeof (label) in bytes, possibly read from the header
524  inline unsigned labelByteSize() const noexcept;
525 
526  //- The sizeof (scalar) in bytes, possibly read from the header
527  inline unsigned scalarByteSize() const noexcept;
528 
529  //- Clear various bits (headerClassName, note, sizeof...)
530  //- that would be obtained when reading from a file.
531  // \param newName if non-null, optionally rename the IOobject
532  void resetHeader(const word& newName = word::null);
533 
534 
535  // Checks
536 
537  //- True if headerClassName() is non-empty (after reading)
538  inline bool hasHeaderClass() const noexcept;
539 
540  //- Check if headerClassName() equals Type::typeName
541  template<class Type>
542  inline bool isHeaderClass() const;
543 
544  //- Same as isHeaderClass()
545  template<class Type>
546  bool isHeaderClassName() const { return isHeaderClass<Type>(); }
547 
548 
549  // Meta-data
550 
551  //- Return pointer to meta-data (if any) or nullptr
552  virtual const dictionary* findMetaData() const noexcept;
553 
554 
555  // Path components
556 
557  //- Return group (extension part of name)
558  inline word group() const;
559 
560  //- Return member (name without the extension)
561  inline word member() const;
562 
563  //- Return the Time::rootPath()
564  const fileName& rootPath() const noexcept;
565 
566  //- Return the Time::caseName()
567  const fileName& caseName() const noexcept;
568 
569  //- Return the Time::globalCaseName()
570  const fileName& globalCaseName() const noexcept;
571 
572  //- Read access to instance path component
573  inline const fileName& instance() const noexcept;
574 
575  //- Write access to instance path component
576  inline fileName& instance() noexcept;
577 
578  //- Read access to local path component
579  inline const fileName& local() const noexcept;
580 
581  //- The complete path for the object (with instance, local,...).
582  fileName path() const;
583 
584  //- The complete global path for the object (with instance, local,...)
585  fileName globalPath() const;
586 
587  //- The complete path with alternative instance and local
588  fileName path
589  (
590  const word& instance,
591  const fileName& local = fileName::null
592  ) const;
593 
594  //- The complete global path with alternative instance and local
595  fileName globalPath
596  (
597  const word& instance,
598  const fileName& local = fileName::null
599  ) const;
600 
601  //- The complete path + object name
602  inline fileName objectPath() const;
603 
604  //- The complete global path + object name
605  inline fileName globalObjectPath() const;
606 
607  //- The object path relative to the root
608  fileName objectRelPath() const;
609 
610  //- Redirect to fileHandler filePath, searching locally.
611  // When search is false, simply use the current instance,
612  // otherwise search previous instances.
613  fileName localFilePath
614  (
615  const word& typeName,
616  const bool search=true
617  ) const;
618 
619  //- Redirect to fileHandler filePath, searching up if in parallel.
620  // When search is false, simply use the current instance,
621  // otherwise search previous instances.
622  fileName globalFilePath
623  (
624  const word& typeName,
625  const bool search=true
626  ) const;
627 
628 
629  // Reading
630 
631  //- Parse 'FoamFile' header contents and set the IOobject
632  //- characteristics and return the stream characteristics.
633  IOstreamOption parseHeader(const dictionary& headerDict);
634 
635  //- Read header ('FoamFile' dictionary) and set the
636  //- IOobject and stream characteristics.
637  bool readHeader(Istream& is);
638 
639  //- Read header (the 'FoamFile' dictionary) and set the
640  //- IOobject and stream characteristics.
641  // Saves the header content in the given dictionary.
642  bool readHeader(dictionary& headerDict, Istream& is);
643 
644  //- Read header (respects is_globalIOobject trait) and check its info.
645  template<class Type>
646  bool typeHeaderOk
647  (
649  const bool checkType = true,
651  const bool search = true,
653  const bool verbose = true
654  );
655 
656  //- Call localFilePath or globalFilePath for given type
657  //- depending on its is_globalIOobject trait.
658  template<class Type>
659  fileName typeFilePath(const bool search = true) const;
660 
661  //- Helper: warn that type does not support re-reading
662  template<class Type>
663  void warnNoRereading() const;
664 
665 
666  // Writing
667 
668  //- Write the standard OpenFOAM file/dictionary banner
669  // Optionally without editor syntax hint (eg, for logs)
670  static Ostream& writeBanner(Ostream& os, const bool noSyntaxHint=false);
671 
672  //- Write the standard file section divider
673  static Ostream& writeDivider(Ostream& os);
674 
675  //- Write the standard end file divider
676  static Ostream& writeEndDivider(Ostream& os);
677 
678  //- Write header with current type()
679  bool writeHeader(Ostream& os) const;
680 
681  //- Write header with override of type
682  bool writeHeader(Ostream& os, const word& objectType) const;
683 
684  //- Write header into a dictionary with current type()
685  //- and given output format
686  void writeHeader(dictionary& dict, IOstreamOption streamOpt) const;
687 
688  //- Write header into a dictionary with override of type
689  //- and given output format
690  void writeHeader
691  (
692  dictionary& dict,
693  const word& objectType,
694  IOstreamOption streamOpt
695  ) const;
696 
697 
698  // Error Handling
699 
700  //- Did last readHeader() succeed?
701  inline bool good() const noexcept;
702 
703  //- Did last readHeader() fail?
704  inline bool bad() const noexcept;
705 
706 
707  // Info
708 
709  //- Return info proxy,
710  //- for printing information to a stream
711  InfoProxy<IOobject> info() const noexcept { return *this; }
712 
713 
714  // Member Operators
715 
716  //- Copy assignment, copies all values (except the registry)
717  void operator=(const IOobject& io);
718 };
719 
720 
721 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
722 
723 //- Specialization for \c void always returns true (no headerClassName check).
724 template<>
725 inline bool IOobject::isHeaderClass<void>() const
726 {
727  return true;
728 }
729 
730 
731 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
732 
733 } // End namespace Foam
734 
735 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
736 
737 #include "IOobjectI.H"
738 
739 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
740 
741 #ifdef NoRepository
742 # include "IOobjectTemplates.C"
743 #endif
744 
745 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
746 
747 #endif
748 
749 // ************************************************************************* //
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:629
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:356
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:685
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:200
static int maxFileModificationPolls
Max number of times to poll for file modification changes.
Definition: IOobject.H:361
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:963
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:211
OBJstream os(runTime.globalPath()/outputName)
static fileCheckTypes fileModificationChecking
Type of file modification checking.
Definition: IOobject.H:351
static bool bannerEnabled() noexcept
Status of output file banner.
Definition: IOobject.H:369
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:346
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)
Basic run-time type information using word as the type&#39;s name. Used to enhance the standard RTTI to c...
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:44
bool isHeaderClassName() const
Same as isHeaderClass()
Definition: IOobject.H:726
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:191
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:180
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.