processorLduInterface.H
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-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2023 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 Class
28  Foam::processorLduInterface
29 
30 Description
31  An abstract base class for processor coupled interfaces.
32 
33 SourceFiles
34  processorLduInterface.C
35  processorLduInterfaceTemplates.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_processorLduInterface_H
40 #define Foam_processorLduInterface_H
41 
42 #include "lduInterface.H"
43 #include "primitiveFieldsFwd.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class processorLduInterface Declaration
52 \*---------------------------------------------------------------------------*/
53 
55 {
56  // Private Data
57 
58  //- Send buffer.
59  // Only sized and used when compressed or non-blocking comms used.
60  mutable List<char> byteSendBuf_;
61 
62  //- Receive buffer.
63  // Only sized and used when compressed or non-blocking comms used.
64  mutable List<char> byteRecvBuf_;
65 
66 
67  // Private Member Functions
68 
69  //- Increase buffer size if required
70  // Uses the nocopy variant since it will be overwritten
71  static void resizeBuf(List<char>& buf, const label len)
72  {
73  if (buf.size() < len)
74  {
75  buf.resize_nocopy(len);
76  }
77  }
78 
79 
80 public:
81 
82  //- Runtime type information
83  TypeNameNoDebug("processorLduInterface");
84 
85 
86  // Constructors
87 
88  //- Default construct
89  processorLduInterface() noexcept = default;
90 
91 
92  //- Destructor
93  virtual ~processorLduInterface() = default;
94 
95 
96  // Member Functions
97 
98  // Access
99 
100  //- Return communicator used for parallel communication
101  virtual label comm() const = 0;
102 
103  //- Return processor number (rank in communicator)
104  virtual int myProcNo() const = 0;
105 
106  //- Return neighbour processor number (rank in communicator)
107  virtual int neighbProcNo() const = 0;
108 
109  //- Return face transformation tensor
110  virtual const tensorField& forwardT() const = 0;
111 
112  //- Return message tag used for sending
113  virtual int tag() const = 0;
114 
115 
116  // Transfer Functions
117 
118  //- Raw send function
119  template<class Type>
120  void send
121  (
122  const UPstream::commsTypes commsType,
123  const UList<Type>& f
124  ) const;
125 
126  //- Raw receive function
127  template<class Type>
128  void receive
129  (
130  const UPstream::commsTypes commsType,
131  UList<Type>& f
132  ) const;
133 
134  //- Raw receive function returning field
135  template<class Type>
137  (
138  const UPstream::commsTypes commsType,
139  const label size
140  ) const;
141 
142 
143  //- Raw send function with data compression
144  template<class Type>
145  void compressedSend
146  (
147  const UPstream::commsTypes commsType,
148  const UList<Type>& f
149  ) const;
150 
151  //- Raw receive function with data compression
152  template<class Type>
153  void compressedReceive
154  (
155  const UPstream::commsTypes commsType,
156  UList<Type>& f
157  ) const;
158 
159  //- Raw receive function with data compression returning field
160  template<class Type>
162  (
163  const UPstream::commsTypes commsType,
164  const label size
165  ) const;
166 };
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #ifdef NoRepository
177 #endif
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #endif
182 
183 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
void send(const UPstream::commsTypes commsType, const UList< Type > &f) const
Raw send function.
commsTypes
Communications types.
Definition: UPstream.H:72
processorLduInterface() noexcept=default
Default construct.
virtual ~processorLduInterface()=default
Destructor.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
Definition: ListI.H:175
Forward declarations of the specialisations of Field<T> for scalar, vector and tensor.
TypeNameNoDebug("processorLduInterface")
Runtime type information.
virtual label comm() const =0
Return communicator used for parallel communication.
virtual int tag() const =0
Return message tag used for sending.
const direction noexcept
Definition: Scalar.H:258
virtual const tensorField & forwardT() const =0
Return face transformation tensor.
An abstract base class for processor coupled interfaces.
labelList f(nPoints)
void compressedReceive(const UPstream::commsTypes commsType, UList< Type > &f) const
Raw receive function with data compression.
virtual int neighbProcNo() const =0
Return neighbour processor number (rank in communicator)
virtual int myProcNo() const =0
Return processor number (rank in communicator)
A class for managing temporary objects.
Definition: HashPtrTable.H:50
void compressedSend(const UPstream::commsTypes commsType, const UList< Type > &f) const
Raw send function with data compression.
void receive(const UPstream::commsTypes commsType, UList< Type > &f) const
Raw receive function.
Namespace for OpenFOAM.