Loading...
Searching...
No Matches
baseIOdictionary.C
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-2014 OpenFOAM Foundation
9 Copyright (C) 2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
28
29#include "baseIOdictionary.H"
30#include "objectRegistry.H"
31#include "Pstream.H"
32#include "Time.H"
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
39
40 bool baseIOdictionary::writeDictionaries
41 (
42 debug::infoSwitch("writeDictionaries", 0)
43 );
44}
45
46
47// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48
50(
51 const IOobject& io,
52 const dictionary* fallback
53)
62(
63 const IOobject& io,
74 Istream& is
75)
76:
82
83// * * * * * * * * * * * * * * * Members Functions * * * * * * * * * * * * * //
86{
87 return regIOobject::name();
88}
89
90
92{
93 is >> *this;
94
95 if (writeDictionaries && UPstream::master() && !is.bad())
96 {
97 Sout<< nl
98 << "--- baseIOdictionary " << name()
99 << ' ' << objectPath() << ":" << nl;
102 Sout<< "--- End of baseIOdictionary " << name() << nl << endl;
103 }
104
105 return !is.bad();
106}
107
108
109bool Foam::baseIOdictionary::writeData(Ostream& os) const
110{
111 dictionary::write(os, false);
112 return os.good();
113}
114
115
116// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
const word & name() const noexcept
Return the object name.
Definition IOobjectI.H:205
fileName objectPath() const
The complete path + object name.
Definition IOobjectI.H:313
bool bad() const noexcept
True if stream is corrupted.
Definition IOstream.H:305
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Definition UPstream.H:1714
baseIOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO function...
virtual bool writeData(Ostream &) const
The writeData function required by regIOobject write operation.
baseIOdictionary(const baseIOdictionary &)=default
Copy construct.
virtual bool readData(Istream &)
The readData function required by regIOobject read operation.
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
const fileName & name() const noexcept
The dictionary name.
Definition dictionaryI.H:41
dictionary()
Default construct, a top-level empty dictionary.
Definition dictionary.C:68
void write(Ostream &os, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition regIOobject.H:71
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
Definition regIOobject.C:43
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
OBJstream os(runTime.globalPath()/outputName)
const auto & io
auto & name
const auto & fallback
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
Definition debug.C:228
Namespace for OpenFOAM.
static void writeHeader(Ostream &os, const word &fieldName)
OSstream Sout
OSstream wrapped stdout (std::cout).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
static void writeData(Ostream &os, const Type &val)
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict