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.txx
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 {
74 
75  // Private Data
76 
77  //- Local reference cast into the processor patch
78  const processorFvPatch& procPatch_;
79 
80 
81  // Sending and receiving
82 
83  //- Current (non-blocking) send request
84  mutable label sendRequest_;
85 
86  //- Current (non-blocking) recv request
87  mutable label recvRequest_;
88 
89  //- Send buffer.
90  mutable Field<Type> sendBuf_;
91 
92  //- Receive buffer.
93  mutable Field<Type> recvBuf_;
94 
95  //- Scalar send buffer
96  mutable solveScalarField scalarSendBuf_;
97 
98  //- Scalar recv buffer
99  mutable solveScalarField scalarRecvBuf_;
100 
101 
102  // Private Member Functions
103 
104  //- Receive and send requests have both completed
105  virtual bool all_ready() const;
106 
107 
108 public:
109 
110  //- Runtime type information
111  TypeName(processorFvPatch::typeName_());
112 
113 
114  // Constructors
115 
116  //- Construct from patch and internal field
118  (
119  const fvPatch&,
121  );
122 
123  //- Construct from patch and internal field and patch field
125  (
126  const fvPatch&,
128  const Field<Type>&
129  );
130 
131  //- Construct from patch, internal field and dictionary
133  (
134  const fvPatch&,
136  const dictionary&
137  );
138 
139  //- Construct by mapping onto a new patch
141  (
142  const this_bctype&,
143  const fvPatch&,
145  const fvPatchFieldMapper&
146  );
147 
148  //- Construct as copy setting internal field reference
150  (
151  const this_bctype&,
153  );
154 
155  //- No copy without an internal field
156  [[deprecated("2026-03: soon = delete")]]
158  #ifdef Foam_fvPatchField_copyConstruct
159  : this_bctype(pfld, pfld.internalField()) {}
160  #else
161  = delete;
162  #endif
163 
164  //- Clone with an internal field reference
166  (
168  ) const
169  {
170  return fvPatchField<Type>::Clone(*this, iF);
171  }
172 
173 
174  //- Destructor
175  ~processorFvPatchField() = default;
176 
177 
178  // Member Functions
179 
180  // Coupling
181 
182  //- The patch field is coupled if running in parallel
183  virtual bool coupled() const { return UPstream::parRun(); }
184 
185  //- Are all (receive) data available?
186  virtual bool ready() const;
187 
188  //- Return neighbour field
189  virtual tmp<Field<Type>> patchNeighbourField() const;
190 
191  //- Retrieve neighbour field
192  virtual void patchNeighbourField(UList<Type>& pnf) const;
194 
195  // Evaluation
196 
197  //- Initialise the evaluation of the patch field
198  virtual void initEvaluate(const Pstream::commsTypes commsType);
199 
200  //- Evaluate the patch field
201  virtual void evaluate(const Pstream::commsTypes commsType);
202 
203  //- Initialise the evaluation of the patch field after a local
204  // operation. Dummy since operating on a copy
205  virtual void initEvaluateLocal
206  (
207  const Pstream::commsTypes commsType =
209  )
210  {}
211 
212  //- Evaluate the patch field after a local operation (e.g. *=).
213  // Dummy since operating on a copy
214  virtual void evaluateLocal
215  (
216  const Pstream::commsTypes commsType =
218  )
219  {}
220 
221  //- Return patch-normal gradient
222  virtual tmp<Field<Type>> snGrad
223  (
224  const scalarField& deltaCoeffs
225  ) const;
226 
227  //- Retrieve patch-normal gradient
228  virtual void snGrad
229  (
230  const scalarField& deltaCoeffs,
231  UList<Type>& result
232  ) const;
233 
234 
235  // Coupled interface functionality
236 
237  //- Initialise neighbour matrix update
238  virtual void initInterfaceMatrixUpdate
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  //- Update result field based on interface functionality
251  virtual void updateInterfaceMatrix
252  (
253  solveScalarField& result,
254  const bool add,
255  const lduAddressing& lduAddr,
256  const label patchId,
257  const solveScalarField& psiInternal,
258  const scalarField& coeffs,
259  const direction cmpt,
260  const Pstream::commsTypes commsType
261  ) const;
263  //- Initialise neighbour matrix update
264  virtual void initInterfaceMatrixUpdate
265  (
266  Field<Type>& result,
267  const bool add,
268  const lduAddressing& lduAddr,
269  const label patchId,
270  const Field<Type>& psiInternal,
271  const scalarField& coeffs,
272  const Pstream::commsTypes commsType
273  ) const;
274 
275  //- Update result field based on interface functionality
276  virtual void updateInterfaceMatrix
277  (
278  Field<Type>& result,
279  const bool add,
280  const lduAddressing& lduAddr,
281  const label patchId,
282  const Field<Type>& psiInternal,
283  const scalarField& coeffs,
284  const Pstream::commsTypes commsType
285  ) const;
286 
287 
288  // Processor coupled interface functions
289 
290  //- Return communicator used for communication
291  virtual label comm() const
292  {
293  return procPatch_.comm();
294  }
295 
296  //- Return processor number
297  virtual int myProcNo() const
298  {
299  return procPatch_.myProcNo();
300  }
301 
302  //- Return neighbour processor number
303  virtual int neighbProcNo() const
304  {
305  return procPatch_.neighbProcNo();
306  }
307 
308  //- Does the patch field perform the transformation
309  virtual bool doTransform() const
310  {
311  return
312  (
313  is_rotational_vectorspace_v<Type>
314  && !procPatch_.parallel()
315  );
316  }
317 
318  //- Return face transformation tensor
319  virtual const tensorField& forwardT() const
320  {
321  return procPatch_.forwardT();
322  }
323 
324  //- Return rank of component for transform
325  virtual int rank() const
326  {
327  return pTraits<Type>::rank;
328  }
329 
330 
331  // Member Operators
332 
333  //- Inherit assignment
335 };
336 
337 
338 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
339 
340 } // End namespace Foam
341 
342 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
343 
344 #ifdef NoRepository
345  #include "processorFvPatchField.txx"
346 #endif
347 
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 
350 #endif
351 
352 // ************************************************************************* //
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.
commsTypes
Communications types.
Definition: UPstream.H:81
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
virtual int neighbProcNo() const
Return neighbour processor number.
virtual bool parallel() const
Are the cyclic planes parallel.
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)
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:1774
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
virtual bool ready() const
Are all (receive) data available?
virtual label comm() const
Return communicator used for communication.
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
virtual bool doTransform() const
Does the patch field perform the transformation.
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:635
Abstract base class for processor coupled interfaces.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition: Field.H:69
A FieldMapper for finite-volume patch fields.
Processor patch.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
virtual int rank() const
Return rank of component for transform.
Abstract base class for coupled patches.
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field.
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)
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
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 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...
const DimensionedField< Type, volMesh > & internalField() const noexcept
Return const-reference to the dimensioned internal field.
Definition: fvPatchField.H:734
::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 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 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.
virtual tmp< fvPatchField< Type > > clone() const
No clone without an internal field reference.
Definition: fvPatchField.H:610