fieldDictionary.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-2015 OpenFOAM Foundation
9  Copyright (C) 2020 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::fieldDictionary
29 
30 Description
31  Read field as dictionary (without mesh).
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef fieldDictionary_H
36 #define fieldDictionary_H
37 
38 #include "regIOobject.H"
39 #include "dictionary.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class fieldDictionary Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class fieldDictionary
51 :
52  public regIOobject,
53  public dictionary
54 {
55 
56  // Private Data
57 
58  const word type_;
59 
60 
61 public:
62 
63  // Constructors
64 
65  //- Construct from ioobject and overloaded typename.
66  fieldDictionary(const IOobject& io, const word& type)
67  :
68  regIOobject(io),
70  type_(type)
71  {
72  close();
73  }
74 
75 
76  // Member Functions
77 
78  //- Redefine type name to be of the instantiated type
79  virtual const word& type() const
80  {
81  return type_;
82  }
83 
84  bool writeData(Ostream& os) const
85  {
86  static_cast<const dictionary&>(*this).write(os, false);
87 
88  return os.good();
89  }
90 };
91 
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 } // End namespace Foam
96 
97 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98 
99 #endif
100 
101 // ************************************************************************* //
regIOobject.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fieldDictionary::fieldDictionary
fieldDictionary(const IOobject &io, const word &type)
Construct from ioobject and overloaded typename.
Definition: fieldDictionary.H:65
Foam::fieldDictionary
Read field as dictionary (without mesh).
Definition: fieldDictionary.H:49
Foam::fieldDictionary::writeData
bool writeData(Ostream &os) const
Pure virtual writeData function.
Definition: fieldDictionary.H:83
Foam::fieldDictionary::type
virtual const word & type() const
Redefine type name to be of the instantiated type.
Definition: fieldDictionary.H:78
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
Foam::regIOobject::close
void close()
Close Istream.
Definition: regIOobjectRead.C:171
Foam::dictionary::write
void write(Ostream &os, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:206
dictionary.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::regIOobject::readStream
Istream & readStream(const word &, const bool valid=true)
Return Istream and check object type against that given.
Definition: regIOobjectRead.C:129