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-2025 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
186  virtual tmp<Field<Type>> patchNeighbourField() const;
187 
188  //- Retrieve neighbour field
189  virtual void patchNeighbourField(UList<Type>& pnf) const;
190 
191 
192  // Evaluation
193 
194  //- Initialise the evaluation of the patch field
195  virtual void initEvaluate(const Pstream::commsTypes commsType);
196 
197  //- Evaluate the patch field
198  virtual void evaluate(const Pstream::commsTypes commsType);
199 
200  //- Initialise the evaluation of the patch field after a local
201  // operation. Dummy since operating on a copy
202  virtual void initEvaluateLocal
203  (
204  const Pstream::commsTypes commsType =
206  )
207  {}
208 
209  //- Evaluate the patch field after a local operation (e.g. *=).
210  // Dummy since operating on a copy
211  virtual void evaluateLocal
212  (
213  const Pstream::commsTypes commsType =
215  )
216  {}
217 
218  //- Return patch-normal gradient
219  virtual tmp<Field<Type>> snGrad
220  (
221  const scalarField& deltaCoeffs
222  ) const;
223 
224 
225  // Coupled interface functionality
226 
227  //- Initialise neighbour matrix update
228  virtual void initInterfaceMatrixUpdate
229  (
230  solveScalarField& result,
231  const bool add,
232  const lduAddressing& lduAddr,
233  const label patchId,
234  const solveScalarField& psiInternal,
235  const scalarField& coeffs,
236  const direction cmpt,
237  const Pstream::commsTypes commsType
238  ) const;
239 
240  //- Update result field based on interface functionality
241  virtual void updateInterfaceMatrix
242  (
243  solveScalarField& result,
244  const bool add,
245  const lduAddressing& lduAddr,
246  const label patchId,
247  const solveScalarField& psiInternal,
248  const scalarField& coeffs,
249  const direction cmpt,
250  const Pstream::commsTypes commsType
251  ) const;
252 
253  //- Initialise neighbour matrix update
254  virtual void initInterfaceMatrixUpdate
255  (
256  Field<Type>& result,
257  const bool add,
258  const lduAddressing& lduAddr,
259  const label patchId,
260  const Field<Type>& psiInternal,
261  const scalarField& coeffs,
262  const Pstream::commsTypes commsType
263  ) const;
264 
265  //- Update result field based on interface functionality
266  virtual void updateInterfaceMatrix
267  (
268  Field<Type>& result,
269  const bool add,
270  const lduAddressing& lduAddr,
271  const label patchId,
272  const Field<Type>& psiInternal,
273  const scalarField& coeffs,
274  const Pstream::commsTypes commsType
275  ) const;
276 
277 
278  // Processor coupled interface functions
279 
280  //- Return communicator used for communication
281  virtual label comm() const
282  {
283  return procPatch_.comm();
284  }
285 
286  //- Return processor number
287  virtual int myProcNo() const
288  {
289  return procPatch_.myProcNo();
290  }
291 
292  //- Return neighbour processor number
293  virtual int neighbProcNo() const
294  {
295  return procPatch_.neighbProcNo();
296  }
297 
298  //- Does the patch field perform the transformation
299  virtual bool doTransform() const
300  {
301  return (pTraits<Type>::rank && !procPatch_.parallel());
302  }
303 
304  //- Return face transformation tensor
305  virtual const tensorField& forwardT() const
306  {
307  return procPatch_.forwardT();
308  }
309 
310  //- Return rank of component for transform
311  virtual int rank() const
312  {
313  return pTraits<Type>::rank;
314  }
315 };
316 
317 
318 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
319 
320 } // End namespace Foam
321 
322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
323 
324 #ifdef NoRepository
325  #include "processorFvPatchField.C"
326 #endif
327 
328 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
329 
330 #endif
331 
332 // ************************************************************************* //
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:1586
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:607
Abstract base class for processor coupled interfaces.
Generic templated field type.
Definition: Field.H:63
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.
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.