UPstreamGatherScatter.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 "UPstream.H"
29 #include <cstring> // memmove
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 #undef Pstream_CommonRoutines
34 #define Pstream_CommonRoutines(Native) \
35 void Foam::UPstream::mpiGather \
36 ( \
37  const Native* sendData, \
38  int sendCount, \
39  \
40  Native* recvData, \
41  int recvCount, \
42  const label comm \
43 ) \
44 { \
45  std::memmove(recvData, sendData, recvCount*sizeof(Native)); \
46 } \
47  \
48  \
49 void Foam::UPstream::mpiScatter \
50 ( \
51  const Native* sendData, \
52  int sendCount, \
53  \
54  Native* recvData, \
55  int recvCount, \
56  const label comm \
57 ) \
58 { \
59  std::memmove(recvData, sendData, recvCount*sizeof(Native)); \
60 }
61 
63 
64 #undef Pstream_CommonRoutines
65 
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 #undef Pstream_CommonRoutines
70 #define Pstream_CommonRoutines(Native) \
71 void Foam::UPstream::gather \
72 ( \
73  const Native* sendData, \
74  int sendCount, \
75  \
76  Native* recvData, \
77  const UList<int>& recvCounts, \
78  const UList<int>& recvOffsets, \
79  const label comm \
80 ) \
81 { \
82  /* recvCounts[0] may be invalid - use sendCount instead */ \
83  std::memmove(recvData, sendData, sendCount*sizeof(Native)); \
84 } \
85  \
86 void Foam::UPstream::scatter \
87 ( \
88  const Native* sendData, \
89  const UList<int>& sendCounts, \
90  const UList<int>& sendOffsets, \
91  \
92  Native* recvData, \
93  int recvCount, \
94  const label comm \
95 ) \
96 { \
97  std::memmove(recvData, sendData, recvCount*sizeof(Native)); \
98 }
99 
101 //TDB: Pstream_CommonRoutines(bool);
103 Pstream_CommonRoutines(int32_t);
104 Pstream_CommonRoutines(int64_t);
105 Pstream_CommonRoutines(uint32_t);
106 Pstream_CommonRoutines(uint64_t);
108 Pstream_CommonRoutines(double);
109 
110 #undef Pstream_CommonRoutines
111 
112 // ************************************************************************* //
#define Pstream_CommonRoutines(Native)