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 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 "UIPstream.H"
29 #include "IPstream.H"
30 #include "IOstreams.H"
31 
32 // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
33 
35 (
36  const commsTypes commsType,
37  const int fromProcNo,
38  DynamicList<char>& receiveBuf,
39  label& receiveBufPosition,
40  const int tag,
41  const label comm,
42  const bool clearAtEnd,
44 )
45 :
47  (
48  commsType,
49  fromProcNo,
50  receiveBuf,
51  receiveBufPosition,
52  tag,
53  comm,
54  clearAtEnd,
55  fmt
56  )
57 {
59  {
60  // Message is already received into buffer
61  }
62  else
63  {
64  bufferIPCrecv();
65  }
66 }
67 
68 
69 Foam::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  Pout<< "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 commsTypes commsType,
97  const int fromProcNo,
98  const label bufSize,
99  const int tag,
100  const label comm,
102 )
103 :
104  Pstream(commsType, bufSize),
105  UIPstream
106  (
107  commsType,
108  fromProcNo,
109  Pstream::transferBuf_,
110  transferBufPosition_,
111  tag,
112  comm,
113  false, // Do not clear Pstream::transferBuf_ if at end
114  fmt
115  ),
116  transferBufPosition_(0)
117 {}
118 
119 
120 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:118
commsTypes
Types of communications.
Definition: UPstream.H:66
IPstream(const commsTypes commsType, const int fromProcNo, const label bufSize=0, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct given process index to read from and optional buffer size, read format. ...
Definition: IPstreams.C:88
Base class for input inter-processor communications stream (ie, parallel streams). Not to be used directly, thus contructors are protected.
Definition: UIPstream.H:54
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
UIPstream(const commsTypes commsType, const int fromProcNo, DynamicList< char > &receiveBuf, label &receiveBufPosition, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm, const bool clearAtEnd=false, IOstreamOption::streamFormat fmt=IOstreamOption::BINARY)
Construct given process index to read from using the given attached receive buffer, optional communication characteristics and IO format.
Definition: IPstreams.C:28
commsTypes commsType() const noexcept
Get the communications type of the stream.
Definition: UPstream.H:814
int debug
Static debugging option.
const label comm_
Definition: UIPstream.H:102
DynamicList< char > & recvBuf_
Definition: UIPstream.H:96
streamFormat
Data format (ascii | binary)
"nonBlocking" : (MPI_Isend, MPI_Irecv)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.