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