OpenFOAM: API Guide
v2112
The open source CFD toolbox
GlobalIOField.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-2018 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 "
GlobalIOField.H
"
30
31
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33
template
<
class
Type>
34
Foam::GlobalIOField<Type>::GlobalIOField
(
const
IOobject
&
io
)
35
:
36
regIOobject
(
io
)
37
{
38
// Check for MUST_READ_IF_MODIFIED
39
warnNoRereading<GlobalIOField<Type>>();
40
41
readHeaderOk
(
IOstream::BINARY
,
typeName
);
42
}
43
44
45
template
<
class
Type>
46
Foam::GlobalIOField<Type>::GlobalIOField
(
const
IOobject
&
io
,
const
label size)
47
:
48
regIOobject
(
io
)
49
{
50
// Check for MUST_READ_IF_MODIFIED
51
warnNoRereading<GlobalIOField<Type>>();
52
53
if
(!
readHeaderOk
(
IOstream::BINARY
,
typeName
))
54
{
55
Field<Type>::setSize
(
size
);
56
}
57
}
58
59
60
template
<
class
Type>
61
Foam::GlobalIOField<Type>::GlobalIOField
62
(
63
const
IOobject
&
io
,
64
const
UList<Type>
& content
65
)
66
:
67
regIOobject
(
io
)
68
{
69
// Check for MUST_READ_IF_MODIFIED
70
warnNoRereading<GlobalIOField<Type>>();
71
72
if
(!
readHeaderOk
(
IOstream::BINARY
,
typeName
))
73
{
74
Field<Type>::operator=
(content);
75
}
76
}
77
78
79
template
<
class
Type>
80
Foam::GlobalIOField<Type>::GlobalIOField
81
(
82
const
IOobject
&
io
,
83
Field<Type>
&& content
84
)
85
:
86
regIOobject
(
io
)
87
{
88
// Check for MUST_READ_IF_MODIFIED
89
warnNoRereading<GlobalIOField<Type>>();
90
91
Field<Type>::transfer
(content);
92
93
readHeaderOk(IOstream::BINARY, typeName);
94
}
95
96
97
template
<
class
Type>
98
Foam::GlobalIOField<Type>::GlobalIOField
99
(
100
const
IOobject
&
io
,
101
const
tmp
<
Field<Type>
>& tfld
102
)
103
:
104
regIOobject
(
io
)
105
{
106
// Check for MUST_READ_IF_MODIFIED
107
warnNoRereading<GlobalIOField<Type>>();
108
109
const
bool
reuse = tfld.movable();
110
111
if
(reuse)
112
{
113
Field<Type>::transfer
(tfld.ref());
114
}
115
116
if
(!readHeaderOk(IOstream::BINARY, typeName))
117
{
118
Field<Type>::operator=
(tfld());
119
}
120
121
tfld.clear();
122
}
123
124
125
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
126
127
template
<
class
Type>
128
bool
Foam::GlobalIOField<Type>::readData
(
Istream
& is)
129
{
130
is >> *
this
;
131
return
is.
good
();
132
}
133
134
135
template
<
class
Type>
136
bool
Foam::GlobalIOField<Type>::writeData
(
Ostream
&
os
)
const
137
{
138
return
(
os
<<
static_cast<
const
Field<Type>
&
>
(*
this
)).
good
();
139
}
140
141
142
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
143
144
template
<
class
Type>
145
void
Foam::GlobalIOField<Type>::operator=
(
const
GlobalIOField<Type>
& rhs)
146
{
147
Field<Type>::operator=
(rhs);
148
}
149
150
151
// ************************************************************************* //
GlobalIOField.H
Foam::FieldBase::typeName
static const char *const typeName
Typename for Field.
Definition:
FieldBase.H:59
Foam::Field
Generic templated field type.
Definition:
Field.H:82
Foam::Field::operator=
void operator=(const Field< Type > &)
Copy assignment.
Definition:
Field.C:641
Foam::GlobalIOField
IOField with global data (so optionally read from master)
Definition:
GlobalIOField.H:57
Foam::GlobalIOField::operator=
void operator=(const GlobalIOField< Type > &rhs)
Copy assignment of entries.
Definition:
GlobalIOField.C:145
Foam::GlobalIOField::readData
virtual bool readData(Istream &is)
The readData method for regIOobject read operation.
Definition:
GlobalIOField.C:128
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition:
IOobject.H:170
Foam::IOobject::good
bool good() const noexcept
Did last readHeader() succeed?
Definition:
IOobjectI.H:222
Foam::IOstream::good
bool good() const noexcept
True if next operation might succeed.
Definition:
IOstream.H:233
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition:
Istream.H:64
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition:
Ostream.H:62
Foam::PackedList::setSize
void setSize(const label n, unsigned int val=0u)
Alias for resize()
Definition:
PackedList.H:557
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:
UList.H:94
Foam::UList::size
label size() const noexcept
The number of elements in the UList.
Definition:
UListI.H:420
Foam::fileFormats::STLCore::BINARY
@ BINARY
BINARY.
Definition:
STLCore.H:64
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition:
regIOobject.H:76
Foam::regIOobject::readHeaderOk
bool readHeaderOk(const IOstreamOption::streamFormat fmt, const word &typeName)
Helper: check readOpt flags and read if necessary.
Definition:
regIOobjectRead.C:39
Foam::tmp
A class for managing temporary objects.
Definition:
tmp.H:65
os
OBJstream os(runTime.globalPath()/outputName)
io
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
src
OpenFOAM
db
IOobjects
GlobalIOField
GlobalIOField.C
Generated by
1.9.5
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.