Loading...
Searching...
No Matches
OPBstreams.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) 2022-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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\*---------------------------------------------------------------------------*/
28#include "UOPstream.H"
29#include "OPstream.H"
30#include "IOstreams.H"
31
32// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
33
35(
36 DynamicList<char>& sendBuf,
37 const int communicator,
38 const bool sendAtDestruct,
40)
41:
43 (
44 UPstream::commsTypes::scheduled, // irrelevant
45 UPstream::masterNo(), // irrelevant
46 sendBuf,
47 UPstream::msgType(), // irrelevant
49 sendAtDestruct,
50 fmt
51 )
52{}
53
54
56(
57 const int communicator,
59)
60:
61 Pstream(UPstream::commsTypes::scheduled), // type is irrelevant
63 (
64 Pstream::transferBuf_,
65 communicator,
66 true, // sendAtDestruct
67 fmt
68 )
69{}
70
71
72// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
73
75{
76 if (sendAtDestruct_)
77 {
78 if (!bufferIPCsend())
79 {
81 << "Failed broadcast message of size " << sendBuf_.size()
83 }
84 }
85}
86
87
88// ************************************************************************* //
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
streamFormat
Data format (ascii | binary | coherent).
OPBstream(const int communicator=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct with optional communicator and write format.
Definition OPBstreams.C:49
Inter-processor communications stream.
Definition Pstream.H:59
DynamicList< char > transferBuf_
Allocated transfer buffer (can be used for send or receive).
Definition Pstream.H:67
Pstream(const UPstream::commsTypes commsType) noexcept
Construct for communication type with empty buffer.
Definition Pstream.H:83
Output inter-processor communications stream using MPI broadcast - operating on external buffer.
Definition UOPstream.H:591
UOPBstream(DynamicList< char > &sendBuf, const int communicator=UPstream::worldComm, const bool sendAtDestruct=true, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct with attached send buffer, optional communication characteristics and IO format.
Definition OPBstreams.C:28
virtual ~UOPBstream()
Destructor, usually sends buffer on destruct.
Definition OPBstreams.C:67
DynamicList< char > & sendBuf_
Reference to the send buffer data.
Definition UOPstream.H:128
bool sendAtDestruct_
Call bufferIPCsend on termination (in the destructor).
Definition UOPstream.H:123
UOPstreamBase(const UPstream::commsTypes commsType, const int toProcNo, DynamicList< char > &sendBuf, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, const bool sendAtDestruct=true, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct given process index to write to using the given attached send buffer, optional communicatio...
Wrapper for internally indexed communicator label. Always invokes UPstream::allocateCommunicatorCompo...
Definition UPstream.H:2546
Inter-processor communications stream.
Definition UPstream.H:69
commsTypes
Communications types.
Definition UPstream.H:81
static int & msgType() noexcept
Message tag of standard messages.
Definition UPstream.H:1926
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
Definition UPstream.H:1691
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...