UPstream.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) 2011-2018 OpenFOAM Foundation
9  Copyright (C) 2016-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "Pstream.H"
30 #include "PstreamReduceOps.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
35 {}
36 
37 
39 {
41  << "The dummy Pstream library cannot be used in parallel mode"
42  << endl;
43 
44  return false;
45 }
46 
47 
48 bool Foam::UPstream::init(int& argc, char**& argv, const bool needsThread)
49 {
51  << "The dummy Pstream library cannot be used in parallel mode"
52  << endl
54 
55  return false;
56 }
57 
58 
59 void Foam::UPstream::exit(int errnum)
60 {
61  // No MPI - just exit
62  std::exit(errnum);
63 }
64 
65 
67 {
68  // No MPI - just abort
69  std::abort();
70 }
71 
72 
73 void Foam::reduce(scalar&, const sumOp<scalar>&, const int, const label)
74 {}
75 
76 
77 void Foam::reduce(scalar&, const minOp<scalar>&, const int, const label)
78 {}
79 
80 
81 void Foam::reduce(vector2D&, const sumOp<vector2D>&, const int, const label)
82 {}
83 
84 
85 void Foam::sumReduce
86 (
87  scalar&,
88  label&,
89  const int,
90  const label
91 )
92 {}
93 
94 
95 void Foam::reduce(scalar&, const sumOp<scalar>&, const int, const label, label&)
96 {}
97 
98 
100 (
101  const labelUList& sendData,
102  labelUList& recvData,
103  const label communicator
104 )
105 {
106  recvData.deepCopy(sendData);
107 }
108 
109 
111 (
112  const char* sendData,
113  int sendSize,
114 
115  char* recvData,
116  const UList<int>& recvSizes,
117  const UList<int>& recvOffsets,
118  const label communicator
119 )
120 {
121  memmove(recvData, sendData, sendSize);
122 }
123 
124 
126 (
127  const char* sendData,
128  const UList<int>& sendSizes,
129  const UList<int>& sendOffsets,
130 
131  char* recvData,
132  int recvSize,
133  const label communicator
134 )
135 {
136  memmove(recvData, sendData, recvSize);
137 }
138 
139 
140 void Foam::UPstream::allocatePstreamCommunicator
141 (
142  const label,
143  const label
144 )
145 {}
146 
147 
148 void Foam::UPstream::freePstreamCommunicator(const label)
149 {}
150 
151 
153 {
154  return 0;
155 }
156 
157 
159 {}
160 
161 
163 {}
164 
165 
167 {}
168 
169 
171 {
173  return false;
174 }
175 
176 
177 // ************************************************************************* //
Foam::UPstream::resetRequests
static void resetRequests(const label sz)
Truncate number of outstanding requests.
Definition: UPstream.C:158
Foam::minOp
Definition: ops.H:224
Foam::UPstream::exit
static void exit(int errnum=1)
Exit program.
Definition: UPstream.C:59
Foam::UPstream::waitRequests
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
Definition: UPstream.C:162
Foam::UPstream::abort
static void abort()
Abort program.
Definition: UPstream.C:66
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::Vector2D< scalar >
Foam::UList::deepCopy
void deepCopy(const UList< T > &list)
Copy elements of the given UList.
Definition: UList.C:105
Foam::UPstream::allToAll
static void allToAll(const labelUList &sendData, labelUList &recvData, const label communicator=0)
Exchange label with all processors (in the communicator).
Definition: UPstream.C:100
Foam::UPstream::gather
static void gather(const char *sendData, int sendSize, char *recvData, const UList< int > &recvSizes, const UList< int > &recvOffsets, const label communicator=0)
Receive data from all processors on the master.
Definition: UPstream.C:111
Foam::sumOp
Definition: ops.H:213
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:419
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:51
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::UPstream::waitRequest
static void waitRequest(const label i)
Wait until request i has finished.
Definition: UPstream.C:166
Foam::UPstream::addValidParOptions
static void addValidParOptions(HashTable< string > &validParOptions)
Definition: UPstream.C:34
Foam::UPstream::scatter
static void scatter(const char *sendData, const UList< int > &sendSizes, const UList< int > &sendOffsets, char *recvData, int recvSize, const label communicator=0)
Send data to all processors from the root of the communicator.
Definition: UPstream.C:126
Foam::FatalError
error FatalError
Pstream.H
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
PstreamReduceOps.H
Inter-processor communication reduction functions.
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::UPstream::nRequests
static label nRequests()
Get number of outstanding requests.
Definition: UPstream.C:152
Foam::UPstream::initNull
static bool initNull()
Special purpose initialisation function.
Definition: UPstream.C:38
Foam::start
label ListType::const_reference const label start
Definition: ListOps.H:408
Foam::UList< label >
Foam::UPstream::finishedRequest
static bool finishedRequest(const label i)
Non-blocking comms: has request i finished?
Definition: UPstream.C:170
Foam::sumReduce
void sumReduce(T &Value, label &Count, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:133
Foam::UPstream::communicator
Helper class for allocating/freeing communicators.
Definition: UPstream.H:321
Foam::UPstream::init
static bool init(int &argc, char **&argv, const bool needsThread)
Initialisation function called from main.
Definition: UPstream.C:48
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:294