GlobalIOList.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) 2015 OpenFOAM Foundation
9  Copyright (C) 2016-2022 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 \*---------------------------------------------------------------------------*/
28 
29 #include "GlobalIOList.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 :
37 {
38  // Check for MUST_READ_IF_MODIFIED
39  warnNoRereading<GlobalIOList<Type>>();
40 
41  readHeaderOk(IOstreamOption::BINARY, typeName);
42 }
43 
44 
45 template<class Type>
47 :
49 {
50  // Check for MUST_READ_IF_MODIFIED
51  warnNoRereading<GlobalIOList<Type>>();
52 
53  readHeaderOk(IOstreamOption::BINARY, typeName);
54 }
55 
56 
57 template<class Type>
58 Foam::GlobalIOList<Type>::GlobalIOList(const IOobject& io, const label len)
59 :
61 {
62  // Check for MUST_READ_IF_MODIFIED
63  warnNoRereading<GlobalIOList<Type>>();
64 
65  if (!readHeaderOk(IOstreamOption::BINARY, typeName))
66  {
68  }
69 }
70 
71 
72 template<class Type>
74 (
75  const IOobject& io,
76  const UList<Type>& content
77 )
78 :
79  regIOobject(io)
80 {
81  // Check for MUST_READ_IF_MODIFIED
82  warnNoRereading<GlobalIOList<Type>>();
83 
84  if (!readHeaderOk(IOstreamOption::BINARY, typeName))
85  {
87  }
88 }
89 
90 
91 template<class Type>
93 (
94  const IOobject& io,
95  List<Type>&& content
96 )
97 :
98  regIOobject(io)
99 {
100  // Check for MUST_READ_IF_MODIFIED
101  warnNoRereading<GlobalIOList<Type>>();
102 
103  List<Type>::transfer(content);
104 
105  readHeaderOk(IOstreamOption::BINARY, typeName);
106 }
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
111 template<class Type>
113 {
114  is >> *this;
115  return is.good();
116 }
117 
118 
119 template<class Type>
121 {
122  return (os << *this).good();
123 }
124 
125 
126 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
127 
128 template<class Type>
130 {
132 }
133 
134 
135 // ************************************************************************* //
GlobalIOList(const GlobalIOList &)=default
Default copy construct.
patchWriters resize(patchIds.size())
void transfer(List< Type > &list)
Transfer the contents of the argument List into this list and annul the argument list.
Definition: List.C:326
void operator=(const GlobalIOList< Type > &rhs)
Copy assignment of entries.
Definition: GlobalIOList.C:122
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
virtual bool readData(Istream &is)
The readData method for regIOobject read operation.
Definition: GlobalIOList.C:105
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
IOList with global data (so optionally read from master)
Definition: GlobalIOList.H:48
bool good() const noexcept
True if next operation might succeed.
Definition: IOstream.H:281
bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
Definition: GlobalIOList.C:113
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:66
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172