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-2024 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 \*---------------------------------------------------------------------------*/
27 
28 #include "UOPstream.H"
29 #include "OPstream.H"
30 #include "IOstreams.H"
31 
32 // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
33 
35 (
36  const UPstream::commsTypes commsType,
37  const int rootProcNo,
38  DynamicList<char>& sendBuf,
39  const int tag,
40  const label comm,
41  const bool sendAtDestruct,
43 )
44 :
46  (
47  commsType, // irrelevant
48  rootProcNo, // normally UPstream::masterNo()
49  sendBuf,
50  tag, // irrelevant
51  comm,
52  sendAtDestruct,
53  fmt
54  )
55 {}
56 
57 
59 (
60  const UPstream::commsTypes commsType,
61  const int rootProcNo,
62  const label bufSize,
63  const int tag,
64  const label comm,
66 )
67 :
68  Pstream(commsType, bufSize),
70  (
71  commsType, // irrelevant
72  rootProcNo, // normally UPstream::masterNo()
73  Pstream::transferBuf_,
74  tag, // irrelevant
75  comm,
76  true, // sendAtDestruct
77  fmt
78  )
79 {}
80 
81 
83 (
84  const int rootProcNo,
85  const label comm,
87 )
88 :
89  OPBstream
90  (
91  UPstream::commsTypes::scheduled, // irrelevant
92  rootProcNo,
93  label(0), // bufSize
94  UPstream::msgType(), // irrelevant
95  comm,
96  fmt
97  )
98 {}
99 
100 
102 (
103  const label comm,
105 )
106 :
107  OPBstream
108  (
109  UPstream::commsTypes::scheduled, // irrelevant
110  UPstream::masterNo(), // rootProcNo
111  label(0), // bufSize
112  UPstream::msgType(), // irrelevant
113  comm,
114  fmt
115  )
116 {}
117 
118 
119 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
120 
122 {
123  if (sendAtDestruct_)
124  {
125  if (!bufferIPCsend())
126  {
128  << "Failed broadcast message of size "
129  << sendBuf_.size() << " root: " << toProcNo_
131  }
132  }
133 }
134 
135 
136 // ************************************************************************* //
commsTypes
Communications types.
Definition: UPstream.H:77
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:608
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
OPBstream(const UPstream::commsTypes, const int rootProcNo, const label bufSize=0, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct for broadcast root, optional buffer size, write format.
Definition: OPBstreams.C:52
Inter-processor communications stream.
Definition: Pstream.H:54
virtual ~UOPBstream()
Destructor, usually sends buffer on destruct.
Definition: OPBstreams.C:114
Output inter-processor communications stream using MPI broadcast - operating on external buffer...
Definition: UOPstream.H:588
errorManip< error > abort(error &err)
Definition: errorManip.H:139
UOPBstream(const UPstream::commsTypes, const int toProcNo, DynamicList< char > &sendBuf, const int tag=UPstream::msgType(), const label comm=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...
Definition: OPBstreams.C:28
Output inter-processor communications stream using MPI broadcast.
Definition: OPstream.H:130
streamFormat
Data format (ascii | binary)
Base class for output inter-processor communications stream (ie, parallel streams). Not to be used directly, thus contructors are protected.
Definition: UOPstream.H:54
Inter-processor communications stream.
Definition: UPstream.H:65