threadedCollatedOFstream.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-2018 OpenFOAM Foundation
9  Copyright (C) 2021-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 Class
28  Foam::threadedCollatedOFstream
29 
30 Description
31  Master-only drop-in replacement for OFstream.
32 
33 SourceFiles
34  threadedCollatedOFstream.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_threadedCollatedOFstream_H
39 #define Foam_threadedCollatedOFstream_H
40 
41 #include "dictionary.H"
42 #include "StringStream.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward Declarations
50 class OFstreamCollator;
51 
52 /*---------------------------------------------------------------------------*\
53  Class threadedCollatedOFstream Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 :
58  public OStringStream
59 {
60  // Private Data
61 
62  //- The backend writer
63  OFstreamCollator& writer_;
64 
65  //- The backend file name
66  const fileName pathName_;
67 
68  //- Atomic file creation (ignored with append)
69  const IOstreamOption::atomicType atomic_;
70 
71  //- Output file compression
72  const IOstreamOption::compressionType compression_;
73 
74  //- Use threading
75  const bool useThread_;
76 
77  //- Additional FoamFile entries for decomposed data
78  dictionary headerEntries_;
79 
80 
81 public:
82 
83  // Constructors
84 
85  //- Construct and set stream status
87  (
90  const fileName& pathname,
91  IOstreamOption streamOpt = IOstreamOption(),
92  const bool useThread = true
93  );
94 
95  //- Construct and set stream status
97  (
99  const fileName& pathname,
100  IOstreamOption streamOpt = IOstreamOption(),
101  const bool useThread = true
102  );
103 
104 
105  //- Destructor
107 
108 
109  // Member Functions
110 
111  //- Define the header entries for the data block(s)
112  void setHeaderEntries(const dictionary& dict);
113 };
114 
115 
116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 
118 } // End namespace Foam
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 #endif
123 
124 // ************************************************************************* //
dictionary dict
Threaded file writer.
A class for handling file names.
Definition: fileName.H:72
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/"finiteArea-edgesCentres"))
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Input/output from string buffers.
Master-only drop-in replacement for OFstream.
void setHeaderEntries(const dictionary &dict)
Define the header entries for the data block(s)
A simple container for options an IOstream can normally have.
constexpr IOstreamOption(streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
Default construct (ASCII, UNCOMPRESSED, currentVersion) or construct with format, compression...
atomicType
Atomic operations (output)
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
Definition: StringStream.H:256
threadedCollatedOFstream(OFstreamCollator &writer, IOstreamOption::atomicType atomic, const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool useThread=true)
Construct and set stream status.
Namespace for OpenFOAM.