All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CompactIOField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::CompactIOField
26 
27 Description
28  A Field of objects of type <T> with automated input and output using
29  a compact storage. Behaves like IOField except when binary output in
30  case it writes a CompactListList.
31 
32  Useful for fields of small subfields e.g. in lagrangian
33 
34 SourceFiles
35  CompactIOField.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef CompactIOField_H
40 #define CompactIOField_H
41 
42 #include "IOField.H"
43 #include "regIOobject.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of friend functions and operators
51 template<class Type, class BaseType> class CompactIOField;
52 
53 template<class Type, class BaseType> Istream& operator>>
54 (
55  Istream&,
57 );
58 
59 template<class Type, class BaseType> Ostream& operator<<
60 (
61  Ostream&,
63 );
64 
65 /*---------------------------------------------------------------------------*\
66  Class CompactIOField Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 template<class Type, class BaseType>
70 class CompactIOField
71 :
72  public regIOobject,
73  public Field<Type>
74 {
75  // Private Member Functions
76 
77  //- Read according to header type
78  void readFromStream(const bool read = true);
79 
80 public:
81 
82  //- Runtime type information
83  TypeName("FieldField");
84 
85 
86  // Constructors
87 
88  //- Construct from IOobject
89  CompactIOField(const IOobject&);
90 
91  //- Construct from IOobject; does local processor require reading?
92  CompactIOField(const IOobject&, const bool read);
93 
94  //- Construct from IOobject and size
95  CompactIOField(const IOobject&, const label);
96 
97  //- Construct from IOobject and a Field
98  CompactIOField(const IOobject&, const Field<Type>&);
99 
100  //- Move construct by transferring the Field contents
102 
103  //- Move constructor
105 
106 
107  // Destructor
108 
109  virtual ~CompactIOField();
110 
111 
112  // Member Functions
113 
114  virtual bool writeObject
115  (
119  const bool write
120  ) const;
121 
122  virtual bool writeData(Ostream&) const;
123 
124 
125  // Member Operators
126 
129 
130  void operator=(const Field<Type>&);
131  void operator=(Field<Type>&&);
132 };
133 
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 } // End namespace Foam
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 #ifdef NoRepository
142  #include "CompactIOField.C"
143 #endif
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #endif
148 
149 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
CompactIOField(const IOobject &)
Construct from IOobject.
virtual bool read()
Read object.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void operator=(const CompactIOField< Type, BaseType > &)
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool write) const
Write using given format, version and compression.
Pre-declare SubField and related Field type.
Definition: Field.H:56
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86
virtual bool writeData(Ostream &) const
Pure virtual writaData function.
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
A Field of objects of type <T> with automated input and output using a compact storage. Behaves like IOField except when binary output in case it writes a CompactListList.
Version number type.
Definition: IOstream.H:96
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:52
virtual bool write(const bool write=true) const
Write using setting from DB.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
TypeName("FieldField")
Runtime type information.
Namespace for OpenFOAM.