OpenFOAM
v2406
The open source CFD toolbox
collatedFileOperation.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) 2017 OpenFOAM Foundation
9
Copyright (C) 2019-2023 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::fileOperations::collatedFileOperation
29
30
Description
31
Version of masterUncollatedFileOperation that collates regIOobjects
32
into a container in the processors/ subdirectory.
33
34
Uses threading if maxThreadFileBufferSize != 0.
35
> 0 : Can use mpi inside thread to collect data if buffer is not
36
large enough. Does need full thread support inside MPI.
37
38
< 0 : special : -maxThreadFileBufferSize is guaranteed large enough
39
for all writing. Initialises MPI without thread support.
40
41
See also
42
masterUncollatedFileOperation
43
44
SourceFiles
45
collatedFileOperation.C
46
47
\*---------------------------------------------------------------------------*/
48
49
#ifndef Foam_fileOperations_collatedFileOperation_H
50
#define Foam_fileOperations_collatedFileOperation_H
51
52
#include "
masterUncollatedFileOperation.H
"
53
#include "
fileOperationInitialise.H
"
54
#include "
OFstreamCollator.H
"
55
56
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57
58
namespace
Foam
59
{
60
namespace
fileOperations
61
{
62
63
/*---------------------------------------------------------------------------*\
64
Class collatedFileOperation Declaration
65
\*---------------------------------------------------------------------------*/
66
67
class
collatedFileOperation
68
:
69
public
masterUncollatedFileOperation
70
{
71
// Private Data
72
73
//- Communicator allocated/managed by us
74
mutable
label managedComm_;
75
76
77
// Private Member Functions
78
79
//- Any initialisation steps after constructing
80
void
init(
bool
verbose);
81
82
83
protected
:
84
85
// Protected Data
86
87
//- Threaded writer
88
mutable
OFstreamCollator
writer_
;
89
90
91
// Protected Member Functions
92
93
//- Print banner information, optionally with io ranks
94
void
printBanner
(
const
bool
withRanks =
false
)
const
;
95
96
//- Append to processorsNN/ file
97
bool
appendObject
98
(
99
const
regIOobject
&
io
,
100
const
fileName
& pathName,
101
IOstreamOption
streamOpt
102
)
const
;
103
104
105
public
:
106
107
//- Runtime type information
108
TypeName
(
"collated"
);
109
110
111
// Static Data
112
113
//- Max size of thread buffer size. This is the overall size of
114
// all files to be written. Starts blocking if not enough size.
115
// Read as float to enable easy specification of large sizes.
116
static
float
maxThreadFileBufferSize
;
117
118
119
// Constructors
120
121
//- Default construct
122
explicit
collatedFileOperation
(
bool
verbose =
false
);
123
124
//- Construct from communicator with specified io-ranks
125
explicit
collatedFileOperation
126
(
127
const
Tuple2<label, labelList>
& commAndIORanks,
128
const
bool
distributedRoots,
129
bool
verbose =
false
130
);
131
132
133
//- Destructor
134
virtual
~collatedFileOperation
();
135
136
137
// Member Functions
138
139
//- Transfer ownership of communicator to this fileOperation.
140
//- Use with caution
141
virtual
void
storeComm
()
const
;
142
143
144
// (reg)IOobject functionality
145
146
//- Generate disk file name for object. Opposite of filePath.
147
virtual
fileName
objectPath
148
(
149
const
IOobject
&
io
,
150
const
word
& typeName
151
)
const
;
152
153
//- Writes a regIOobject (so header, contents and divider).
154
// Returns success state.
155
virtual
bool
writeObject
156
(
157
const
regIOobject
&,
158
IOstreamOption
streamOpt =
IOstreamOption
(),
159
const
bool
writeOnProc =
true
160
)
const
;
161
162
163
// Other
164
165
//- Forcibly wait until all output done. Flush any cached data
166
virtual
void
flush
()
const
;
167
168
//- Actual name of processors dir
169
virtual
word
processorsDir
(
const
IOobject
&)
const
;
170
171
//- Actual name of processors dir
172
virtual
word
processorsDir
(
const
fileName
&)
const
;
173
};
174
175
176
/*---------------------------------------------------------------------------*\
177
Class fileOperationInitialise_collated Declaration
178
\*---------------------------------------------------------------------------*/
179
180
//- A fileOperation initialiser for collated file handlers.
181
//- Requires threading for non-zero maxThreadFileBufferSize.
182
class
fileOperationInitialise_collated
183
:
184
public
fileOperationInitialise
185
{
186
public
:
187
188
// Constructors
189
190
//- Construct from components
191
fileOperationInitialise_collated
(
int
& argc,
char
**& argv)
192
:
193
fileOperationInitialise
(argc, argv)
194
{}
195
196
197
//- Destructor
198
virtual
~fileOperationInitialise_collated
() =
default
;
199
200
201
// Member Functions
202
203
//- The (MPI) threading requirement depends on buffering
204
virtual
bool
needsThreading
()
const
205
{
206
return
(
collatedFileOperation::maxThreadFileBufferSize
> 0);
207
}
208
};
209
210
211
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212
213
}
// End namespace fileOperations
214
}
// End namespace Foam
215
216
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217
218
#endif
219
220
// ************************************************************************* //
Foam::fileOperations::fileOperationInitialise
Definition:
fileOperationInitialise.H:46
Foam::OFstreamCollator
Threaded file writer.
Definition:
OFstreamCollator.H:66
Foam::fileName
A class for handling file names.
Definition:
fileName.H:72
Foam::fileOperations::fileOperationInitialise_collated::needsThreading
virtual bool needsThreading() const
The (MPI) threading requirement depends on buffering.
Definition:
collatedFileOperation.H:241
Foam::fileOperations::fileOperationInitialise_collated
A fileOperation initialiser for collated file handlers. Requires threading for non-zero maxThreadFile...
Definition:
collatedFileOperation.H:213
Foam::Tuple2
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition:
stringOps.H:54
Foam::fileOperations::collatedFileOperation::TypeName
TypeName("collated")
Runtime type information.
Foam::fileOperations::collatedFileOperation::writer_
OFstreamCollator writer_
Threaded writer.
Definition:
collatedFileOperation.H:89
Foam::IOstreamOption
A simple container for options an IOstream can normally have.
Definition:
IOstreamOption.H:59
Foam::fileOperations::collatedFileOperation::appendObject
bool appendObject(const regIOobject &io, const fileName &pathName, IOstreamOption streamOpt) const
Append to processorsNN/ file.
Definition:
collatedFileOperation.C:145
OFstreamCollator.H
fileOperationInitialise.H
Foam::fileOperations::collatedFileOperation::collatedFileOperation
collatedFileOperation(bool verbose=false)
Default construct.
Definition:
collatedFileOperation.C:262
Foam::fileOperations::collatedFileOperation::objectPath
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
Definition:
collatedFileOperation.C:320
Foam::word
A class for handling words, derived from Foam::string.
Definition:
word.H:63
Foam::fileOperations::collatedFileOperation::printBanner
void printBanner(const bool withRanks=false) const
Print banner information, optionally with io ranks.
Definition:
collatedFileOperation.C:79
Foam::fileOperations::collatedFileOperation::storeComm
virtual void storeComm() const
Transfer ownership of communicator to this fileOperation. Use with caution.
Definition:
collatedFileOperation.C:299
Foam::fileOperations::collatedFileOperation::flush
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
Definition:
collatedFileOperation.C:523
Foam::fileOperations::collatedFileOperation::writeObject
virtual bool writeObject(const regIOobject &, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Writes a regIOobject (so header, contents and divider).
Definition:
collatedFileOperation.C:350
Foam::fileOperations::collatedFileOperation::maxThreadFileBufferSize
static float maxThreadFileBufferSize
Max size of thread buffer size. This is the overall size of.
Definition:
collatedFileOperation.H:126
Foam::fileOperations::collatedFileOperation::~collatedFileOperation
virtual ~collatedFileOperation()
Destructor.
Definition:
collatedFileOperation.C:308
Foam::fileOperations::fileOperationInitialise_collated::fileOperationInitialise_collated
fileOperationInitialise_collated(int &argc, char **&argv)
Construct from components.
Definition:
collatedFileOperation.H:224
Foam::fileOperations::collatedFileOperation
Version of masterUncollatedFileOperation that collates regIOobjects into a container in the processor...
Definition:
collatedFileOperation.H:62
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition:
regIOobject.H:68
masterUncollatedFileOperation.H
io
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Foam::fileOperations::fileOperationInitialise_collated::~fileOperationInitialise_collated
virtual ~fileOperationInitialise_collated()=default
Destructor.
Foam::fileOperations::masterUncollatedFileOperation
fileOperations that performs all file operations on the master processor. Requires the calls to be pa...
Definition:
masterUncollatedFileOperation.H:78
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition:
IOobject.H:180
Foam::fileOperations::collatedFileOperation::processorsDir
virtual word processorsDir(const IOobject &) const
Actual name of processors dir.
Definition:
collatedFileOperation.C:606
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:26
src
OpenFOAM
global
fileOperations
collatedFileOperation
collatedFileOperation.H
Generated by
1.8.14