processorFvPatchField.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 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::processorFvPatchField
29
30Group
31 grpCoupledBoundaryConditions
32
33Description
34 This boundary condition enables processor communication across patches.
35
36Usage
37 Example of the boundary condition specification:
38 \verbatim
39 <patchName>
40 {
41 type processor;
42 }
43 \endverbatim
44
45SourceFiles
46 processorFvPatchField.C
47
48\*---------------------------------------------------------------------------*/
49
50#ifndef processorFvPatchField_H
51#define processorFvPatchField_H
52
53#include "coupledFvPatchField.H"
55#include "processorFvPatch.H"
56
57// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58
59namespace Foam
60{
61
62/*---------------------------------------------------------------------------*\
63 Class processorFvPatchField Declaration
64\*---------------------------------------------------------------------------*/
65
66template<class Type>
68:
70 public coupledFvPatchField<Type>
71{
72 // Private data
73
74 //- Local reference cast into the processor patch
75 const processorFvPatch& procPatch_;
76
77 // Sending and receiving
78
79 //- Send buffer.
80 mutable Field<Type> sendBuf_;
81
82 //- Receive buffer.
83 mutable Field<Type> receiveBuf_;
84
85 //- Outstanding request
86 mutable label outstandingSendRequest_;
87
88 //- Outstanding request
89 mutable label outstandingRecvRequest_;
90
91 //- Scalar send buffer
92 mutable solveScalarField scalarSendBuf_;
93
94 //- Scalar receive buffer
95 mutable solveScalarField scalarReceiveBuf_;
96
97
98public:
99
100 //- Runtime type information
101 TypeName(processorFvPatch::typeName_());
102
103
104 // Constructors
105
106 //- Construct from patch and internal field
108 (
109 const fvPatch&,
111 );
112
113 //- Construct from patch and internal field and patch field
115 (
116 const fvPatch&,
118 const Field<Type>&
119 );
120
121 //- Construct from patch, internal field and dictionary
123 (
124 const fvPatch&,
126 const dictionary&
127 );
128
129 //- Construct by mapping given processorFvPatchField onto a new patch
131 (
133 const fvPatch&,
135 const fvPatchFieldMapper&
136 );
137
138 //- Construct as copy
140
141 //- Construct and return a clone
142 virtual tmp<fvPatchField<Type>> clone() const
143 {
145 (
147 );
148 }
149
150 //- Construct as copy setting internal field reference
152 (
155 );
156
157 //- Construct and return a clone setting internal field reference
159 (
161 ) const
162 {
164 (
165 new processorFvPatchField<Type>(*this, iF)
166 );
167 }
168
169
170 //- Destructor
171 ~processorFvPatchField() = default;
172
173
174 // Member Functions
175
176 // Access
177
178 //- Return true if running parallel
179 virtual bool coupled() const
180 {
181 return Pstream::parRun();
182 }
183
184 //- Return neighbour field given internal field
185 virtual tmp<Field<Type>> patchNeighbourField() const;
186
187
188 // Evaluation functions
189
190 //- Initialise the evaluation of the patch field
191 virtual void initEvaluate(const Pstream::commsTypes commsType);
192
193 //- Evaluate the patch field
194 virtual void evaluate(const Pstream::commsTypes commsType);
195
196 //- Return patch-normal gradient
197 virtual tmp<Field<Type>> snGrad
198 (
199 const scalarField& deltaCoeffs
200 ) const;
201
202 //- Is all data available
203 virtual bool ready() const;
204
205 //- Initialise neighbour matrix update
206 virtual void initInterfaceMatrixUpdate
207 (
208 solveScalarField& result,
209 const bool add,
210 const lduAddressing& lduAddr,
211 const label patchId,
212 const solveScalarField& psiInternal,
213 const scalarField& coeffs,
214 const direction cmpt,
215 const Pstream::commsTypes commsType
216 ) const;
217
218 //- Update result field based on interface functionality
219 virtual void updateInterfaceMatrix
220 (
221 solveScalarField& result,
222 const bool add,
223 const lduAddressing& lduAddr,
224 const label patchId,
225 const solveScalarField& psiInternal,
226 const scalarField& coeffs,
227 const direction cmpt,
228 const Pstream::commsTypes commsType
229 ) const;
230
231 //- Initialise neighbour matrix update
232 virtual void initInterfaceMatrixUpdate
233 (
234 Field<Type>& result,
235 const bool add,
236 const lduAddressing& lduAddr,
237 const label patchId,
238 const Field<Type>& psiInternal,
239 const scalarField& coeffs,
240 const Pstream::commsTypes commsType
241 ) const;
242
243 //- Update result field based on interface functionality
244 virtual void updateInterfaceMatrix
245 (
246 Field<Type>& result,
247 const bool add,
248 const lduAddressing& lduAddr,
249 const label patchId,
250 const Field<Type>& psiInternal,
251 const scalarField& coeffs,
252 const Pstream::commsTypes commsType
253 ) const;
254
255
256
257 //- Processor coupled interface functions
258
259 //- Return communicator used for comms
260 virtual label comm() const
261 {
262 return procPatch_.comm();
263 }
264
265 //- Return processor number
266 virtual int myProcNo() const
267 {
268 return procPatch_.myProcNo();
269 }
270
271 //- Return neighbour processor number
272 virtual int neighbProcNo() const
273 {
274 return procPatch_.neighbProcNo();
275 }
276
277 //- Does the patch field perform the transformation
278 virtual bool doTransform() const
279 {
280 return !(procPatch_.parallel() || pTraits<Type>::rank == 0);
281 }
282
283 //- Return face transformation tensor
284 virtual const tensorField& forwardT() const
285 {
286 return procPatch_.forwardT();
287 }
288
289 //- Return rank of component for transform
290 virtual int rank() const
291 {
292 return pTraits<Type>::rank;
293 }
294
295};
296
297
298// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299
300} // End namespace Foam
301
302// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303
304#ifdef NoRepository
305 #include "processorFvPatchField.C"
306#endif
307
308// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309
310#endif
311
312// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type.
Definition: Field.H:82
commsTypes
Types of communications.
Definition: UPstream.H:67
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Abstract base class for coupled patches.
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A FieldMapper for finite-volume patch fields.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
The class contains the addressing required by the lduMatrix: upper, lower and losort.
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
This boundary condition enables processor communication across patches.
virtual bool doTransform() const
Does the patch field perform the transformation.
virtual void initInterfaceMatrixUpdate(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
virtual int rank() const
Return rank of component for transform.
virtual bool coupled() const
Return true if running parallel.
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
TypeName(processorFvPatch::typeName_())
Runtime type information.
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
virtual int myProcNo() const
Return processor number.
virtual label comm() const
Processor coupled interface functions.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
virtual bool ready() const
Is all data available.
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field given internal field.
virtual int neighbProcNo() const
Return neighbour processor number.
~processorFvPatchField()=default
Destructor.
virtual tmp< fvPatchField< Type > > clone(const DimensionedField< Type, volMesh > &iF) const
Construct and return a clone setting internal field reference.
virtual const tensorField & forwardT() const
Return face transformation tensor.
virtual bool parallel() const
Are the cyclic planes parallel.
virtual int myProcNo() const
Return processor number.
virtual label comm() const
Return communicator used for comms.
virtual int neighbProcNo() const
Return neighbour processor number.
virtual const tensorField & forwardT() const
Return face transformation tensor.
Abstract base class for processor coupled interfaces.
A class for managing temporary objects.
Definition: tmp.H:65
label patchId(-1)
Namespace for OpenFOAM.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
uint8_t direction
Definition: direction.H:56
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73