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-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::processorFvPatchField
29 
30 Group
31  grpCoupledBoundaryConditions
32 
33 Description
34  This boundary condition enables processor communication across patches.
35 
36 Usage
37  Example of the boundary condition specification:
38  \verbatim
39  <patchName>
40  {
41  type processor;
42  }
43  \endverbatim
44 
45 SourceFiles
46  processorFvPatchField.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef Foam_processorFvPatchField_H
51 #define Foam_processorFvPatchField_H
52 
53 #include "coupledFvPatchField.H"
55 #include "processorFvPatch.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class processorFvPatchField Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 template<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 
78  // Sending and receiving
79 
80  //- Current (non-blocking) send request
81  mutable label sendRequest_;
82 
83  //- Current (non-blocking) recv request
84  mutable label recvRequest_;
85 
86  //- Send buffer.
87  mutable Field<Type> sendBuf_;
88 
89  //- Receive buffer.
90  mutable Field<Type> recvBuf_;
91 
92  //- Scalar send buffer
93  mutable solveScalarField scalarSendBuf_;
94 
95  //- Scalar recv buffer
96  mutable solveScalarField scalarRecvBuf_;
97 
98 
99  // Private Member Functions
100 
101  //- Receive and send requests have both completed
102  virtual bool all_ready() const;
103 
104 
105 public:
106 
107  //- Runtime type information
108  TypeName(processorFvPatch::typeName_());
109 
110 
111  // Constructors
112 
113  //- Construct from patch and internal field
115  (
116  const fvPatch&,
118  );
119 
120  //- Construct from patch and internal field and patch field
122  (
123  const fvPatch&,
125  const Field<Type>&
126  );
127 
128  //- Construct from patch, internal field and dictionary
130  (
131  const fvPatch&,
133  const dictionary&
134  );
135 
136  //- Construct by mapping given processorFvPatchField onto a new patch
138  (
140  const fvPatch&,
142  const fvPatchFieldMapper&
143  );
144 
145  //- Construct as copy
147 
148  //- Construct as copy setting internal field reference
150  (
153  );
154 
155  //- Return a clone
156  virtual tmp<fvPatchField<Type>> clone() const
157  {
158  return fvPatchField<Type>::Clone(*this);
159  }
160 
161  //- Clone with an internal field reference
163  (
165  ) const
166  {
167  return fvPatchField<Type>::Clone(*this, iF);
168  }
169 
170 
171  //- Destructor
172  ~processorFvPatchField() = default;
173 
174 
175  // Member Functions
176 
177  // Coupling
178 
179  //- The patch field is coupled if running in parallel
180  virtual bool coupled() const { return UPstream::parRun(); }
181 
182  //- Are all (receive) data available?
183  virtual bool ready() const;
184 
185  //- Return neighbour field given internal field
186  virtual tmp<Field<Type>> patchNeighbourField() const;
187 
188 
189  // Evaluation
190 
191  //- Initialise the evaluation of the patch field
192  virtual void initEvaluate(const Pstream::commsTypes commsType);
193 
194  //- Evaluate the patch field
195  virtual void evaluate(const Pstream::commsTypes commsType);
196 
197  //- Initialise the evaluation of the patch field after a local
198  // operation. Dummy since operating on a copy
199  virtual void initEvaluateLocal
200  (
201  const Pstream::commsTypes commsType =
203  )
204  {}
205 
206  //- Evaluate the patch field after a local operation (e.g. *=).
207  // Dummy since operating on a copy
208  virtual void evaluateLocal
209  (
210  const Pstream::commsTypes commsType =
212  )
213  {}
214 
215  //- Return patch-normal gradient
216  virtual tmp<Field<Type>> snGrad
217  (
218  const scalarField& deltaCoeffs
219  ) const;
220 
221 
222  // Coupled interface functionality
223 
224  //- Initialise neighbour matrix update
225  virtual void initInterfaceMatrixUpdate
226  (
227  solveScalarField& result,
228  const bool add,
229  const lduAddressing& lduAddr,
230  const label patchId,
231  const solveScalarField& psiInternal,
232  const scalarField& coeffs,
233  const direction cmpt,
234  const Pstream::commsTypes commsType
235  ) const;
236 
237  //- Update result field based on interface functionality
238  virtual void updateInterfaceMatrix
239  (
240  solveScalarField& result,
241  const bool add,
242  const lduAddressing& lduAddr,
243  const label patchId,
244  const solveScalarField& psiInternal,
245  const scalarField& coeffs,
246  const direction cmpt,
247  const Pstream::commsTypes commsType
248  ) const;
249 
250  //- Initialise neighbour matrix update
251  virtual void initInterfaceMatrixUpdate
252  (
253  Field<Type>& result,
254  const bool add,
255  const lduAddressing& lduAddr,
256  const label patchId,
257  const Field<Type>& psiInternal,
258  const scalarField& coeffs,
259  const Pstream::commsTypes commsType
260  ) const;
261 
262  //- Update result field based on interface functionality
263  virtual void updateInterfaceMatrix
264  (
265  Field<Type>& result,
266  const bool add,
267  const lduAddressing& lduAddr,
268  const label patchId,
269  const Field<Type>& psiInternal,
270  const scalarField& coeffs,
271  const Pstream::commsTypes commsType
272  ) const;
273 
274 
275  // Processor coupled interface functions
276 
277  //- Return communicator used for communication
278  virtual label comm() const
279  {
280  return procPatch_.comm();
281  }
282 
283  //- Return processor number
284  virtual int myProcNo() const
285  {
286  return procPatch_.myProcNo();
287  }
288 
289  //- Return neighbour processor number
290  virtual int neighbProcNo() const
291  {
292  return procPatch_.neighbProcNo();
293  }
294 
295  //- Does the patch field perform the transformation
296  virtual bool doTransform() const
297  {
298  return (pTraits<Type>::rank && !procPatch_.parallel());
299  }
300 
301  //- Return face transformation tensor
302  virtual const tensorField& forwardT() const
303  {
304  return procPatch_.forwardT();
305  }
306 
307  //- Return rank of component for transform
308  virtual int rank() const
309  {
310  return pTraits<Type>::rank;
311  }
312 };
313 
314 
315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316 
317 } // End namespace Foam
318 
319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
320 
321 #ifdef NoRepository
322  #include "processorFvPatchField.C"
323 #endif
324 
325 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
326 
327 #endif
328 
329 // ************************************************************************* //
virtual int myProcNo() const
Return processor number.
virtual void evaluateLocal(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field after a local operation (e.g. *=).
label patchId(-1)
uint8_t direction
Definition: direction.H:46
~processorFvPatchField()=default
Destructor.
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
commsTypes
Communications types.
Definition: UPstream.H:77
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual int neighbProcNo() const
Return neighbour processor number.
virtual bool parallel() const
Are the cyclic planes parallel.
virtual bool coupled() const
The patch field is coupled if running in parallel.
virtual int myProcNo() const
Return processor number.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1061
virtual label comm() const
Return communicator used for communication.
virtual bool doTransform() const
Does the patch field perform the transformation.
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.
virtual int neighbProcNo() const
Return neighbour processor number.
TypeName(processorFvPatch::typeName_())
Runtime type information.
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
Abstract base class for processor coupled interfaces.
Generic templated field type.
Definition: Field.H:62
A FieldMapper for finite-volume patch fields.
Processor patch.
virtual int rank() const
Return rank of component for transform.
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.
Abstract base class for coupled patches.
virtual tmp< fvPatchField< Type > > clone() const
Return a clone.
virtual const tensorField & forwardT() const
Return face transformation tensor.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
virtual void initEvaluateLocal(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Initialise the evaluation of the patch field after a local.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
::Foam::direction rank(const expressions::valueTypeCode) noexcept
The vector-space rank associated with given valueTypeCode.
Definition: exprTraits.C:70
This boundary condition enables processor communication across patches.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual const tensorField & forwardT() const
Return face transformation tensor.
"buffered" : (MPI_Bsend, MPI_Recv)
virtual bool ready() const
Are all (receive) data available?
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field given internal field.
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
virtual label comm() const
Return communicator used for comms.
processorFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Namespace for OpenFOAM.