OpenFOAM
v2412
The open source CFD toolbox
IOField.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) 2011-2017 OpenFOAM Foundation
9
Copyright (C) 2018-2024 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
Class
28
Foam::IOField
29
30
Description
31
A primitive field of type <T> with automated input and output.
32
33
SourceFiles
34
IOField.C
35
36
\*---------------------------------------------------------------------------*/
37
38
#ifndef Foam_IOField_H
39
#define Foam_IOField_H
40
41
#include "
Field.H
"
42
#include "
regIOobject.H
"
43
44
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46
namespace
Foam
47
{
48
49
/*---------------------------------------------------------------------------*\
50
Class IOField Declaration
51
\*---------------------------------------------------------------------------*/
52
53
template
<
class
Type>
54
class
IOField
55
:
56
public
regIOobject,
57
public
Field<Type>
58
{
59
// Private Member Functions
60
61
//- Read if IOobject flags set and 'on-proc' is true.
62
// Return true if read (only accurate when readOnProc == true).
63
bool
readIOcontents(
bool
readOnProc =
true
);
64
65
public
:
66
67
//- The underlying content type
68
typedef
Field<Type>
content_type
;
69
70
//- Runtime type information
71
TypeName
(
"Field"
);
72
73
74
// Constructors
75
76
//- Default copy construct
77
IOField
(
const
IOField
&) =
default
;
78
79
//- Construct from IOobject
80
explicit
IOField
(
const
IOobject
&
io
);
81
82
//- Construct from IOobject, with local processor conditional reading
83
IOField
(
const
IOobject
&
io
,
const
bool
readOnProc);
84
85
//- Construct from IOobject and zero size (if not read)
86
IOField
(
const
IOobject
&
io
,
Foam::zero
);
87
88
//- Construct from IOobject and field size (if not read)
89
IOField
(
const
IOobject
&
io
,
const
label len);
90
91
//- Construct from IOobject and copy of List/Field content
92
IOField
(
const
IOobject
&
io
,
const
UList<Type>
& content);
93
94
//- Construct by transferring the Field content
95
IOField
(
const
IOobject
&
io
,
Field<Type>
&& content);
96
97
//- Construct by copying/moving tmp content
98
IOField
(
const
IOobject
&
io
,
const
tmp
<
Field<Type>
>& tfld);
99
100
101
// Factory Methods
102
103
//- Read and return contents. The IOobject will not be registered
104
static
Field<Type>
readContents
(
const
IOobject
&
io
);
105
106
107
//- Destructor
108
virtual
~IOField
() =
default
;
109
110
111
// Member Functions
112
113
//- The writeData method for regIOobject write operation
114
virtual
bool
writeData
(
Ostream
&
os
)
const
;
115
116
117
// Member Operators
118
119
//- Copy assignment of entries
120
void
operator=
(
const
IOField<Type>
& rhs);
121
122
//- Copy or move assignment of entries
123
using
Field<Type>::operator
=;
124
};
125
126
127
/*---------------------------------------------------------------------------*\
128
Class IOFieldRef Declaration
129
\*---------------------------------------------------------------------------*/
130
131
//- A IOField wrapper for writing external data.
132
template
<
class
Type>
133
class
IOFieldRef
134
:
135
public
regIOobject
136
{
137
// Private Data
138
139
//- Reference to the external content
140
refPtr<Field<Type>
> contentRef_;
141
142
143
public
:
144
145
//- The underlying content type
146
typedef
Field<Type>
content_type
;
147
148
149
//- Type is identical to IOField
150
virtual
const
word
&
type
()
const
151
{
152
return
IOField<Type>::typeName
;
153
}
154
155
156
// Generated Methods
157
158
//- No default construct
159
IOFieldRef
() =
delete
;
160
161
//- No copy construct
162
IOFieldRef
(
const
IOFieldRef
&) =
delete
;
163
164
//- No copy assignment
165
void
operator=
(
const
IOFieldRef
&) =
delete
;
166
167
168
// Constructors
169
170
//- Construct from IOobject and const data reference
171
IOFieldRef
(
const
IOobject
&
io
,
const
Field<Type>
& content);
172
173
174
//- Destructor
175
virtual
~IOFieldRef
() =
default
;
176
177
178
// Member Functions
179
180
//- Allow cast to const content
181
// Fatal if content is not set
182
operator
const
Field<Type>
&()
const
183
{
184
return
contentRef_.
cref
();
185
}
186
187
//- The writeData method for regIOobject write operation
188
// Fatal if content is not set
189
virtual
bool
writeData
(
Ostream
&
os
)
const
;
190
};
191
192
193
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194
195
}
// End namespace Foam
196
197
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198
199
#ifdef NoRepository
200
#include "
IOField.C
"
201
#endif
202
203
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204
205
#endif
206
207
// ************************************************************************* //
Foam::IOFieldRef::IOFieldRef
IOFieldRef()=delete
No default construct.
Foam::IOField::IOField
IOField(const IOField &)=default
Default copy construct.
Foam::IOFieldRef
A IOField wrapper for writing external data.
Definition:
IOField.H:163
Foam::refPtr::cref
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
Definition:
refPtrI.H:216
Foam::refPtr
A class for managing references or pointers (no reference counting)
Definition:
HashPtrTable.H:49
Foam::IOField::writeData
virtual bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
Definition:
IOField.C:181
Foam::IOFieldRef::~IOFieldRef
virtual ~IOFieldRef()=default
Destructor.
Foam::Field
Generic templated field type.
Definition:
Field.H:62
Foam::word
A class for handling words, derived from Foam::string.
Definition:
word.H:63
Foam::IOField::TypeName
TypeName("Field")
Runtime type information.
Foam::UList< Type >
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition:
Ostream.H:56
Foam::IOField::~IOField
virtual ~IOField()=default
Destructor.
Foam::IOField::operator=
void operator=(const IOField< Type > &rhs)
Copy assignment of entries.
Definition:
IOField.C:199
Foam::IOField::content_type
Field< Type > content_type
The underlying content type.
Definition:
IOField.H:68
os
OBJstream os(runTime.globalPath()/outputName)
Field.H
Foam::IOFieldRef::content_type
Field< Type > content_type
The underlying content type.
Definition:
IOField.H:180
Foam::IOFieldRef::type
virtual const word & type() const
Type is identical to IOField.
Definition:
IOField.H:186
regIOobject.H
Foam::IOFieldRef::operator=
void operator=(const IOFieldRef &)=delete
No copy assignment.
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition:
regIOobject.H:68
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition:
zero.H:57
Foam::IOFieldRef::writeData
virtual bool writeData(Ostream &os) const
The writeData method for regIOobject write operation.
Definition:
IOField.C:189
Foam::IOField::readContents
static Field< Type > readContents(const IOobject &io)
Read and return contents. The IOobject will not be registered.
Definition:
IOField.C:164
io
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Foam::tmp
A class for managing temporary objects.
Definition:
HashPtrTable.H:50
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition:
IOobject.H:180
Foam::IOField
A primitive field of type <T> with automated input and output.
Definition:
foamVtkLagrangianWriter.H:57
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:26
IOField.C
src
OpenFOAM
db
IOobjects
IOField
IOField.H
Generated by
1.8.14