OpenFOAM
v2406
The open source CFD toolbox
rawIOField.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) 2020-2023 OpenCFD Ltd.
9
-------------------------------------------------------------------------------
10
License
11
This file is part of OpenFOAM.
12
13
OpenFOAM is free software: you can redistribute it and/or modify it
14
under the terms of the GNU General Public License as published by
15
the Free Software Foundation, either version 3 of the License, or
16
(at your option) any later version.
17
18
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21
for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26
Class
27
Foam::rawIOField
28
29
Description
30
Like IOField but falls back to raw IFstream if no header found.
31
Optionally reads average value. For use in MappedFile container.
32
33
SourceFiles
34
rawIOField.C
35
36
\*---------------------------------------------------------------------------*/
37
38
#ifndef Foam_rawIOField_H
39
#define Foam_rawIOField_H
40
41
#include "
IOField.H
"
42
43
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45
namespace
Foam
46
{
47
48
/*---------------------------------------------------------------------------*\
49
Class rawIOField Declaration
50
\*---------------------------------------------------------------------------*/
51
52
template
<
class
Type>
53
class
rawIOField
54
:
55
public
regIOobject
,
56
public
Field
<Type>
57
{
58
// Private Data
59
60
//- Has an average value
61
bool
hasAverage_;
62
63
//- The average for the field (zero if not used)
64
Type average_;
65
66
67
// Private Member Functions
68
69
//- Read contents and average
70
void
readIOcontents(
Istream
&,
IOobjectOption::readOption
readAverage);
71
72
//- Read if IOobject flags set. Return true if read.
73
bool
readIOcontents(
IOobjectOption::readOption
readAverage);
74
75
76
public
:
77
78
//- The underlying content type
79
typedef
Field<Type>
content_type
;
80
81
//- Runtime type information
82
TypeName
(
"rawField"
);
83
84
85
// Constructors
86
87
//- Default copy construct
88
rawIOField
(
const
rawIOField
&) =
default
;
89
90
//- Construct from IOobject and specified request for reading average
91
//- (default: NO_READ)
92
explicit
rawIOField
93
(
94
const
IOobject
&
io
,
95
IOobjectOption::readOption
readAverage =
IOobjectOption::NO_READ
96
);
97
98
//- Construct from IOobject and specified request for reading average
99
rawIOField
(
const
IOobject
&
io
,
const
bool
readAverage);
100
101
102
// Factory Methods
103
104
//- Read and return contents. The IOobject will not be registered
105
static
Field<Type>
readContents
(
const
IOobject
&
io
);
106
107
108
//- Destructor
109
virtual
~rawIOField
() =
default
;
110
111
112
// Member Functions
113
114
//- The writeData method for regIOobject write operation
115
virtual
bool
writeData
(
Ostream
&
os
)
const
;
116
117
//- The field content
118
const
Field<Type>
&
field
() const
noexcept
119
{
120
return
static_cast<
const
Field<Type>
&
>
(*this);
121
}
122
123
//- The field content, non-const access
124
Field<Type>
&
field
()
noexcept
125
{
126
return
static_cast<
Field<Type>
&
>
(*this);
127
}
128
129
//- The average value (if any)
130
const
Type&
average
() const
noexcept
131
{
132
return
average_;
133
}
134
135
//- Has an average value
136
bool
hasAverage
() const
noexcept
137
{
138
return
hasAverage_;
139
}
140
141
//- Set an average value
142
void
setAverage
(
const
Type& val)
143
{
144
hasAverage_ =
true
;
145
average_ = val;
146
}
147
148
//- Clear average value
149
void
clearAverage
()
150
{
151
hasAverage_ =
false
;
152
average_ =
Zero
;
153
}
154
155
156
// Member Operators
157
158
//- Copy or move assignment of entries
159
using
Field<Type>::operator
=;
160
};
161
162
163
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164
165
}
// End namespace Foam
166
167
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168
169
#ifdef NoRepository
170
#include "
rawIOField.C
"
171
#endif
172
173
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174
175
#endif
176
177
// ************************************************************************* //
Foam::rawIOField::setAverage
void setAverage(const Type &val)
Set an average value.
Definition:
rawIOField.H:171
Foam::rawIOField::readContents
static Field< Type > readContents(const IOobject &io)
Read and return contents. The IOobject will not be registered.
Definition:
rawIOField.C:187
IOField.H
Foam::rawIOField::rawIOField
rawIOField(const rawIOField &)=default
Default copy construct.
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition:
Istream.H:57
Foam::rawIOField::writeData
virtual bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
Definition:
rawIOField.C:204
Foam::rawIOField::content_type
Field< Type > content_type
The underlying content type.
Definition:
rawIOField.H:84
Foam::rawIOField::average
const Type & average() const noexcept
The average value (if any)
Definition:
rawIOField.H:155
Foam::rawIOField
Like IOField but falls back to raw IFstream if no header found. Optionally reads average value...
Definition:
rawIOField.H:48
Foam::Field
Generic templated field type.
Definition:
Field.H:62
rawIOField.C
Foam::rawIOField::~rawIOField
virtual ~rawIOField()=default
Destructor.
Foam::rawIOField::hasAverage
bool hasAverage() const noexcept
Has an average value.
Definition:
rawIOField.H:163
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition:
Ostream.H:56
Foam::noexcept
const direction noexcept
Definition:
Scalar.H:258
os
OBJstream os(runTime.globalPath()/outputName)
Foam::rawIOField::TypeName
TypeName("rawField")
Runtime type information.
Foam::IOobjectOption::NO_READ
Nothing to be read.
Definition:
IOobjectOption.H:60
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition:
regIOobject.H:68
Foam::rawIOField::clearAverage
void clearAverage()
Clear average value.
Definition:
rawIOField.H:180
Foam::rawIOField::field
const Field< Type > & field() const noexcept
The field content.
Definition:
rawIOField.H:139
io
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition:
IOobject.H:180
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:26
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition:
zero.H:127
Foam::IOobjectOption::readOption
readOption
Enumeration defining read preferences.
Definition:
IOobjectOption.H:57
src
OpenFOAM
db
IOobjects
rawIOField
rawIOField.H
Generated by
1.8.14