CompactIOField.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) 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::CompactIOField
29 
30 Description
31  A Field of objects of type <T> with automated input and output using
32  a compact storage. Behaves like IOField except when binary output in
33  case it writes a CompactListList.
34 
35  Useful for fields of small subfields e.g. in lagrangian
36 
37 SourceFiles
38  CompactIOField.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef CompactIOField_H
43 #define CompactIOField_H
44 
45 #include "IOField.H"
46 #include "regIOobject.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declarations
54 template<class T, class BaseType> class CompactIOField;
55 
56 template<class T, class BaseType> Istream& operator>>
57 (
58  Istream&,
60 );
61 
62 template<class T, class BaseType> Ostream& operator<<
63 (
64  Ostream&,
66 );
67 
68 /*---------------------------------------------------------------------------*\
69  Class CompactIOField Declaration
70 \*---------------------------------------------------------------------------*/
71 
72 template<class T, class BaseType>
73 class CompactIOField
74 :
75  public regIOobject,
76  public Field<T>
77 {
78  // Private Member Functions
79 
80  //- Read according to header type
81  void readFromStream(const bool valid = true);
82 
83 public:
84 
85  //- Runtime type information
86  TypeName("FieldField");
87 
88 
89  // Constructors
90 
91  //- Default copy construct
92  CompactIOField(const CompactIOField&) = default;
93 
94  //- Construct from IOobject
95  explicit CompactIOField(const IOobject& io);
96 
97  //- Construct from IOobject; does local processor require reading?
98  CompactIOField(const IOobject& io, const bool valid);
99 
100  //- Construct from IOobject and size
101  CompactIOField(const IOobject& io, const label size);
102 
103  //- Construct from IOobject and a List/Field content
104  CompactIOField(const IOobject& io, const UList<T>& content);
105 
106  //- Construct by transferring the Field contents
107  CompactIOField(const IOobject& io, Field<T>&& content);
108 
109 
110  //- Destructor
111  virtual ~CompactIOField() = default;
112 
113 
114  // Member Functions
115 
116  //- Write using stream options
117  virtual bool writeObject
118  (
119  IOstreamOption streamOpt,
120  const bool valid
121  ) const;
122 
123  virtual bool writeData(Ostream& os) const;
124 
125 
126  // Member Operators
127 
128  //- Copy assignment of entries
129  void operator=(const CompactIOField<T, BaseType>& rhs);
130 
131  //- Copy or move assignment of entries
132  using Field<T>::operator=;
133 };
134 
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace Foam
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 #ifdef NoRepository
143  #include "CompactIOField.C"
144 #endif
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #endif
149 
150 // ************************************************************************* //
regIOobject.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
CompactIOField.C
Foam::CompactIOField
A Field of objects of type <T> with automated input and output using a compact storage....
Definition: CompactIOField.H:53
Foam::CompactIOField::TypeName
TypeName("FieldField")
Runtime type information.
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::CompactIOField::writeObject
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
Definition: CompactIOField.C:177
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::CompactIOField::~CompactIOField
virtual ~CompactIOField()=default
Destructor.
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::CompactIOField::CompactIOField
CompactIOField(const CompactIOField &)=default
Default copy construct.
Foam::CompactIOField::writeData
virtual bool writeData(Ostream &os) const
Definition: CompactIOField.C:202
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
IOField.H
Foam::CompactIOField::operator=
void operator=(const CompactIOField< T, BaseType > &rhs)
Copy assignment of entries.
Definition: CompactIOField.C:212
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56