Loading...
Searching...
No Matches
IPstreams.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 "UIPstream.H"
29#include "IPstream.H"
30#include "IOstreams.H"
31
32// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
33
35(
37 const int fromProcNo,
38 DynamicList<char>& receiveBuf,
39 label& receiveBufPosition,
40 const int tag,
41 const int communicator,
42 const bool clearAtEnd,
44)
45:
47 (
49 fromProcNo,
50 receiveBuf,
51 receiveBufPosition,
52 tag,
54 clearAtEnd,
55 fmt
56 )
57{
59 {
60 // Message is already received into buffer
61 }
62 else
63 {
64 bufferIPCrecv();
65 }
66}
67
68
69Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
70:
71 UIPstreamBase(fromProcNo, buffers)
72{
74 {
75 // Message is already received into buffer
77
78 if (debug)
79 {
80 Perr<< "UIPstream::UIPstream PstreamBuffers :"
81 << " fromProcNo:" << fromProcNo_
82 << " tag:" << tag_ << " comm:" << comm_
83 << " receive buffer size:" << messageSize_
84 << Foam::endl;
85 }
86 }
87 else
88 {
89 bufferIPCrecv();
90 }
91}
92
93
95(
96 const DynamicList<char>& recvBuf,
98)
99:
100 UIPstreamBase(recvBuf, fmt)
101{}
102
103
105(
106 const UPstream::commsTypes commsType,
107 const int fromProcNo,
108 const int bufferSize,
109 const int tag,
110 const int communicator,
112)
113:
114 Pstream(commsType, bufferSize),
116 (
117 commsType,
118 fromProcNo,
119 Pstream::transferBuf_,
120 UIPstreamBase::storedRecvBufPos_, // Internal only
121 tag,
122 communicator,
123 false, // Do not clear Pstream::transferBuf_ if at end
124 fmt
125 )
126{}
127
128
129// ************************************************************************* //
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).
IPstream(const UPstream::commsTypes commsType, const int fromProcNo, const int bufferSize=0, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct given process index to read from.
Definition IPstreams.C:98
Buffers for inter-processor communications streams (UOPstream, UIPstream).
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
const int tag
Definition Pstream.H:874
Base class for input inter-processor communications stream (ie, parallel streams)....
Definition UIPstream.H:59
label storedRecvBufPos_
Receive position in buffer data, if ony If there is no external location for recvBufPos_.
Definition UIPstream.H:120
const int fromProcNo_
Source rank for the data.
Definition UIPstream.H:99
const int tag_
Message tag for communication.
Definition UIPstream.H:104
const int comm_
The communicator index.
Definition UIPstream.H:109
label messageSize_
The message size, read on bufferIPCrecv or set directly.
Definition UIPstream.H:114
UIPstreamBase(const UPstream::commsTypes commsType, const int fromProcNo, DynamicList< char > &receiveBuf, label &receiveBufPosition, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, const bool clearAtEnd=false, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct given process index to read from using the given attached receive buffer,...
DynamicList< char > & recvBuf_
Reference to the receive buffer data.
Definition UIPstream.H:130
Input inter-processor communications stream using MPI send/recv etc. - operating on external buffer.
Definition UIPstream.H:313
UIPstream(const UPstream::commsTypes commsType, const int fromProcNo, DynamicList< char > &receiveBuf, label &receiveBufPosition, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm, const bool clearAtEnd=false, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct given process index to read from using the given attached receive buffer,...
Definition IPstreams.C:28
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Wrapper for internally indexed communicator label. Always invokes UPstream::allocateCommunicatorCompo...
Definition UPstream.H:2546
commsTypes
Communications types.
Definition UPstream.H:81
@ nonBlocking
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
Definition UPstream.H:84
commsTypes commsType() const noexcept
Get the communications type of the stream.
Definition UPstream.H:1958
Namespace for handling debugging switches.
Definition debug.C:45
prefixOSstream Perr
OSstream wrapped stderr (std::cerr) with parallel prefix.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519