IOField.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 | Copyright (C) 2011 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 \*---------------------------------------------------------------------------*/
25 
26 #include "IOField.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 :
33  regIOobject(io)
34 {
35  // Temporary warning
37  {
38  WarningIn("IOField::IOField(const IOobject&)")
39  << "IOField " << name()
40  << " constructed with IOobject::MUST_READ_IF_MODIFIED"
41  " but IOField does not support automatic rereading."
42  << endl;
43  }
44 
45  if
46  (
47  (
50  )
52  )
53  {
54  readStream(typeName) >> *this;
55  close();
56  }
57 }
58 
59 
60 template<class Type>
62 :
63  regIOobject(io)
64 {
65  // Temporary warning
67  {
68  WarningIn("IOField::IOField(const IOobject&, const label)")
69  << "IOField " << name()
70  << " constructed with IOobject::MUST_READ_IF_MODIFIED"
71  " but IOField does not support automatic rereading."
72  << endl;
73  }
74 
75  if
76  (
77  (
80  )
82  )
83  {
84  readStream(typeName) >> *this;
85  close();
86  }
87  else
88  {
90  }
91 }
92 
93 
94 template<class Type>
96 :
97  regIOobject(io)
98 {
99  // Temporary warning
101  {
102  WarningIn("IOField::IOField(const IOobject&, const Field<Type>&)")
103  << "IOField " << name()
104  << " constructed with IOobject::MUST_READ_IF_MODIFIED"
105  " but IOField does not support automatic rereading."
106  << endl;
107  }
108 
109  if
110  (
111  (
114  )
115  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
116  )
117  {
118  readStream(typeName) >> *this;
119  close();
120  }
121  else
122  {
124  }
125 }
126 
127 
128 template<class Type>
130 :
131  regIOobject(io)
132 {
133  // Temporary warning
135  {
136  WarningIn
137  (
138  "IOField::IOField(const IOobject&, const Xfer<Field<Type> >&)"
139  ) << "IOField " << name()
140  << " constructed with IOobject::MUST_READ_IF_MODIFIED"
141  " but IOField does not support automatic rereading."
142  << endl;
143  }
144 
146 
147  if
148  (
149  (
152  )
153  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
154  )
155  {
156  readStream(typeName) >> *this;
157  close();
158  }
159 }
160 
161 
162 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
163 
164 template<class Type>
166 {}
167 
168 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
169 
170 template<class Type>
172 {
173  return (os << static_cast<const Field<Type>&>(*this)).good();
174 }
175 
176 
177 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
178 
179 template<class Type>
181 {
183 }
184 
185 
186 template<class Type>
188 {
190 }
191 
192 
193 // ************************************************************************* //
bool writeData(Ostream &) const
Pure virtual writaData function.
Definition: IOField.C:171
static const char *const typeName
Definition: Field.H:94
readOption readOpt() const
Definition: IOobject.H:304
void transfer(List< Type > &)
Transfer the contents of the argument List into this list.
labelList f(nPoints)
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
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
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
#define WarningIn(functionName)
Report a warning using Foam::Warning.
void operator=(const Field< Type > &)
Definition: Field.C:672
IOField(const IOobject &)
Construct from IOobject.
Definition: IOField.C:31
void close()
Close Istream.
void operator=(const IOField< Type > &)
Definition: IOField.C:180
virtual ~IOField()
Destructor.
Definition: IOField.C:165
Pre-declare SubField and related Field type.
Definition: Field.H:57
const word & name() const
Return name.
Definition: IOobject.H:260
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
label size() const
Return the number of elements in the UList.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
bool headerOk()
Read and check header info.
Definition: IOobject.C:424
Istream & readStream(const word &)
Return Istream and check object type against that given.
A primitive field of type <T> with automated input and output.
Definition: IOField.H:50