Loading...
Searching...
No Matches
threadedCollatedOFstream.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) 2017-2018 OpenFOAM Foundation
9 Copyright (C) 2020-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
30#include "decomposedBlockData.H"
31#include "OFstreamCollator.H"
32
33// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34
36(
39 const fileName& pathName,
40 IOstreamOption streamOpt,
41 const bool useThread
42)
43:
44 OCharStream(streamOpt),
45 writer_(writer),
46 pathName_(pathName),
47 atomic_(atomic),
48 compression_(streamOpt.compression()),
49 useThread_(useThread),
50 headerEntries_()
51{
52 // Start with a slightly larger buffer
54}
55
56
58(
60 const fileName& pathName,
61 IOstreamOption streamOpt,
62 const bool useThread
63)
64:
66 (
67 writer,
68 IOstreamOption::NON_ATOMIC,
69 pathName,
70 streamOpt,
71 useThread
72 )
73{}
74
75
76// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
77
79{
80 commit();
81}
82
83
84// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85
86void Foam::threadedCollatedOFstream::commit()
87{
88 // Take ownership of serialized content, without copying or reallocation
89 DynamicList<char> charData(OCharStream::release());
90
91 writer_.write
92 (
93 decomposedBlockData::typeName,
94 pathName_,
95 std::move(charData),
96 IOstreamOption(IOstreamOption::BINARY, version(), compression_),
97 atomic_,
99 useThread_,
100 headerEntries_
101 );
102}
103
104
105// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106
108{
109 headerEntries_ = dict;
110}
111
112
113// ************************************************************************* //
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edgesCentres")))
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
A simple container for options an IOstream can normally have.
compressionType compression() const noexcept
Get the stream compression.
atomicType
Atomic operations (output).
@ NON_ATOMIC
atomic = false
@ NO_APPEND
no append (truncates existing)
OCharStream(IOstreamOption streamOpt=IOstreamOption())
Default construct (empty output).
DynamicList< char > release()
Reset buffer and return contents.
void reserve(std::streamsize n)
Reserve output space for at least this amount.
Threaded file writer.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
Master-only drop-in replacement for OFstream.
~threadedCollatedOFstream()
Destructor - commits buffered information to file.
threadedCollatedOFstream(OFstreamCollator &writer, IOstreamOption::atomicType atomic, const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool useThread=true)
Construct and set stream status.
void setHeaderEntries(const dictionary &dict)
Define the header entries for the data block(s).
dictionary dict