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 and return a clone
149  virtual tmp<fvPatchField<Type>> clone() const
150  {
151  return tmp<fvPatchField<Type>>
152  (
153  new processorFvPatchField<Type>(*this)
154  );
155  }
156 
157  //- Construct as copy setting internal field reference
159  (
162  );
163 
164  //- Construct and return a clone setting internal field reference
166  (
168  ) const
169  {
170  return tmp<fvPatchField<Type>>
171  (
172  new processorFvPatchField<Type>(*this, iF)
173  );
174  }
175 
176 
177  //- Destructor
178  ~processorFvPatchField() = default;
179 
180 
181  // Member Functions
182 
183  // Coupling
184 
185  //- The patch field is coupled if running in parallel
186  virtual bool coupled() const { return UPstream::parRun(); }
187 
188  //- Are all (receive) data available?
189  virtual bool ready() const;
190 
191  //- Return neighbour field given internal field
192  virtual tmp<Field<Type>> patchNeighbourField() const;
193 
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 
228  // Coupled interface functionality
229 
230  //- Initialise neighbour matrix update
231  virtual void initInterfaceMatrixUpdate
232  (
233  solveScalarField& result,
234  const bool add,
235  const lduAddressing& lduAddr,
236  const label patchId,
237  const solveScalarField& psiInternal,
238  const scalarField& coeffs,
239  const direction cmpt,
240  const Pstream::commsTypes commsType
241  ) const;
242 
243  //- Update result field based on interface functionality
244  virtual void updateInterfaceMatrix
245  (
246  solveScalarField& result,
247  const bool add,
248  const lduAddressing& lduAddr,
249  const label patchId,
250  const solveScalarField& psiInternal,
251  const scalarField& coeffs,
252  const direction cmpt,
253  const Pstream::commsTypes commsType
254  ) const;
255 
256  //- Initialise neighbour matrix update
257  virtual void initInterfaceMatrixUpdate
258  (
259  Field<Type>& result,
260  const bool add,
261  const lduAddressing& lduAddr,
262  const label patchId,
263  const Field<Type>& psiInternal,
264  const scalarField& coeffs,
265  const Pstream::commsTypes commsType
266  ) const;
267 
268  //- Update result field based on interface functionality
269  virtual void updateInterfaceMatrix
270  (
271  Field<Type>& result,
272  const bool add,
273  const lduAddressing& lduAddr,
274  const label patchId,
275  const Field<Type>& psiInternal,
276  const scalarField& coeffs,
277  const Pstream::commsTypes commsType
278  ) const;
279 
280 
281  // Processor coupled interface functions
282 
283  //- Return communicator used for communication
284  virtual label comm() const
285  {
286  return procPatch_.comm();
287  }
288 
289  //- Return processor number
290  virtual int myProcNo() const
291  {
292  return procPatch_.myProcNo();
293  }
294 
295  //- Return neighbour processor number
296  virtual int neighbProcNo() const
297  {
298  return procPatch_.neighbProcNo();
299  }
300 
301  //- Does the patch field perform the transformation
302  virtual bool doTransform() const
303  {
304  return (pTraits<Type>::rank && !procPatch_.parallel());
305  }
306 
307  //- Return face transformation tensor
308  virtual const tensorField& forwardT() const
309  {
310  return procPatch_.forwardT();
311  }
312 
313  //- Return rank of component for transform
314  virtual int rank() const
315  {
316  return pTraits<Type>::rank;
317  }
318 };
319 
320 
321 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
322 
323 } // End namespace Foam
324 
325 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
326 
327 #ifdef NoRepository
328  #include "processorFvPatchField.C"
329 #endif
330 
331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 
333 #endif
334 
335 // ************************************************************************* //
virtual int myProcNo() const
Return processor number.
label patchId(-1)
virtual void initEvaluateLocal(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Initialise the evaluation of the patch field after a local.
"blocking" : (MPI_Bsend, MPI_Recv)
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:72
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:1049
virtual void evaluateLocal(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field after a local operation (e.g. *=).
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.
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
Construct and 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.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
::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.
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.