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-2023 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 toProcNo,
38  DynamicList<char>& sendBuf,
39  const int tag,
40  const label comm,
41  const bool sendAtDestruct,
43 )
44 :
45  UOPstreamBase(commsType, toProcNo, sendBuf, tag, comm, sendAtDestruct, fmt)
46 {}
47 
48 
50 (
51  const UPstream::commsTypes commsType,
52  const int toProcNo,
53  const label bufSize,
54  const int tag,
55  const label comm,
57 )
58 :
59  Pstream(commsType, bufSize),
61  (
62  commsType,
63  toProcNo,
64  Pstream::transferBuf_,
65  tag,
66  comm,
67  true, // sendAtDestruct
68  fmt
69  )
70 {}
71 
72 
74 (
75  const int toProcNo,
76  const label comm,
78 )
79 :
80  OPBstream
81  (
82  UPstream::commsTypes::scheduled, // irrelevant
83  toProcNo,
84  label(0), // bufSize
85  UPstream::msgType(), // irrelevant
86  comm,
87  fmt
88  )
89 {}
90 
91 
92 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
93 
95 {
96  if (sendAtDestruct_)
97  {
98  if (!bufferIPCsend())
99  {
101  << "Failed broadcast message of size "
102  << sendBuf_.size() << " root: " << toProcNo_
104  }
105  }
106 }
107 
108 
109 // ************************************************************************* //
commsTypes
Communications types.
Definition: UPstream.H:72
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:598
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:43
Inter-processor communications stream.
Definition: Pstream.H:57
virtual ~UOPBstream()
Destructor, usually sends buffer on destruct.
Definition: OPBstreams.C:87
Output inter-processor communications stream using MPI broadcast - operating on external buffer...
Definition: UOPstream.H:583
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:82
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:60