processorFaPatchField.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) 2016-2017 Wikki Ltd
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::processorFaPatchField
29 
30 Description
31 
32 Author
33  Zeljko Tukovic, FMENA
34  Hrvoje Jasak, Wikki Ltd.
35 
36 SourceFiles
37  processorFaPatchField.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef Foam_processorFaPatchField_H
42 #define Foam_processorFaPatchField_H
43 
44 #include "coupledFaPatchField.H"
46 #include "processorFaPatch.H"
47 #include "areaFaMesh.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class processorFaPatchField Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class Type>
60 :
62  public coupledFaPatchField<Type>
63 {
64  // Private Data
65 
66  //- Local reference cast into the processor patch
67  const processorFaPatch& procPatch_;
68 
69 
70  // Sending and receiving
71 
72  //- Current (non-blocking) send request
73  mutable label sendRequest_;
74 
75  //- Current (non-blocking) recv request
76  mutable label recvRequest_;
77 
78  //- Send buffer.
79  mutable Field<Type> sendBuf_;
80 
81  //- Receive buffer.
82  mutable Field<Type> recvBuf_;
83 
84  //- Scalar send buffer
85  mutable solveScalarField scalarSendBuf_;
86 
87  //- Scalar recv buffer
88  mutable solveScalarField scalarRecvBuf_;
89 
90 
91  // Private Member Functions
92 
93  //- Receive and send requests have both completed
94  virtual bool all_ready() const;
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeName(processorFaPatch::typeName_());
101 
102 
103  // Constructors
104 
105  //- Construct from patch and internal field
107  (
108  const faPatch&,
110  );
111 
112  //- Construct from patch and internal field and patch field
114  (
115  const faPatch&,
117  const Field<Type>&
118  );
119 
120  //- Construct from patch, internal field and dictionary
122  (
123  const faPatch&,
125  const dictionary&
126  );
127 
128  //- Construct by mapping given processorFaPatchField onto a new patch
130  (
132  const faPatch&,
134  const faPatchFieldMapper&
135  );
136 
137  //- Construct as copy
139 
140  //- Construct as copy setting internal field reference
142  (
145  );
146 
147  //- Return clone
148  virtual tmp<faPatchField<Type>> clone() const
149  {
150  return faPatchField<Type>::Clone(*this);
151  }
152 
153  //- Clone with an internal field reference
155  (
157  ) const
158  {
159  return faPatchField<Type>::Clone(*this, iF);
160  }
161 
162 
163  //- Destructor
164  ~processorFaPatchField() = default;
165 
166 
167  // Member Functions
168 
169  // Coupling
170 
171  //- The patch field is coupled if running in parallel
172  virtual bool coupled() const { return UPstream::parRun(); }
173 
174  //- Are all (receive) data available?
175  virtual bool ready() const;
176 
177  //- Return neighbour field given internal field
178  virtual tmp<Field<Type>> patchNeighbourField() const;
179 
180  //- Retrieve neighbour field
181  virtual void patchNeighbourField(UList<Type>& pnf) const;
182 
183 
184  // Evaluation
185 
186  //- Initialise the evaluation of the patch field
187  virtual void initEvaluate(const Pstream::commsTypes commsType);
188 
189  //- Evaluate the patch field
190  virtual void evaluate(const Pstream::commsTypes commsType);
191 
192  //- Initialise the evaluation of the patch field after a local
193  // operation. Dummy since operating on a copy
194  virtual void initEvaluateLocal
195  (
196  const Pstream::commsTypes commsType =
198  )
199  {}
200 
201  //- Evaluate the patch field after a local operation (e.g. *=).
202  // Dummy since operating on a copy
203  virtual void evaluateLocal
204  (
205  const Pstream::commsTypes commsType =
207  )
208  {}
209 
210  //- Return patch-normal gradient
211  virtual tmp<Field<Type>> snGrad() const;
212 
213 
214  // Coupled interface functionality
215 
216  //- Initialise neighbour matrix update
217  virtual void initInterfaceMatrixUpdate
218  (
219  solveScalarField& result,
220  const bool add,
221  const lduAddressing& lduAddr,
222  const label patchId,
223  const solveScalarField& psiInternal,
224  const scalarField& coeffs,
225  const direction cmpt,
226  const Pstream::commsTypes commsType
227  ) const;
228 
229  //- Update result field based on interface functionality
230  virtual void updateInterfaceMatrix
231  (
232  solveScalarField& result,
233  const bool add,
234  const lduAddressing& lduAddr,
235  const label patchId,
236  const solveScalarField& psiInternal,
237  const scalarField& coeffs,
238  const direction cmpt,
239  const Pstream::commsTypes commsType
240  ) const;
242  //- Initialise neighbour matrix update
243  virtual void initInterfaceMatrixUpdate
244  (
245  Field<Type>& result,
246  const bool add,
247  const lduAddressing& lduAddr,
248  const label patchId,
249  const Field<Type>&,
250  const scalarField& coeffs,
251  const Pstream::commsTypes commsType
252  ) const;
254  //- Update result field based on interface functionality
255  virtual void updateInterfaceMatrix
256  (
257  Field<Type>& result,
258  const bool add,
259  const lduAddressing& lduAddr,
260  const label patchId,
261  const Field<Type>&,
262  const scalarField& coeffs,
263  const Pstream::commsTypes commsType
264  ) const;
265 
266 
267  // Processor coupled interface functions
268 
269  //- Return communicator used for communication
270  virtual label comm() const
271  {
272  return procPatch_.comm();
273  }
274 
275  //- Return processor number
276  virtual int myProcNo() const
277  {
278  return procPatch_.myProcNo();
279  }
280 
281  //- Return neighbour processor number
282  virtual int neighbProcNo() const
283  {
284  return procPatch_.neighbProcNo();
285  }
286 
287  //- Does the patch field perform the transformation
288  virtual bool doTransform() const
289  {
290  return (pTraits<Type>::rank && !procPatch_.parallel());
291  }
292 
293  //- Return face transformation tensor
294  virtual const tensorField& forwardT() const
295  {
296  return procPatch_.forwardT();
297  }
298 
299  //- Return rank of component for transform
300  virtual int rank() const
301  {
302  return pTraits<Type>::rank;
303  }
304 };
305 
306 
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 
309 } // End namespace Foam
310 
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 
313 #ifdef NoRepository
314  #include "processorFaPatchField.C"
315 #endif
316 
317 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 
319 #endif
320 
321 // ************************************************************************* //
virtual void evaluateLocal(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field after a local operation (e.g. *=).
label patchId(-1)
virtual int myProcNo() const
Return processor number.
uint8_t direction
Definition: direction.H:46
virtual const tensorField & forwardT() const
Return face transformation tensor.
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 coupled() const
The patch field is coupled if running in parallel.
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1586
virtual label comm() const
Return communicator used for communication.
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.
TypeName(processorFaPatch::typeName_())
Runtime type information.
Abstract base class for processor coupled interfaces.
Generic templated field type.
Definition: Field.H:63
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
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.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
static tmp< faPatchField< Type > > Clone(const DerivedPatchField &pf)
Clone a patch field with its own internal field reference.
Definition: faPatchField.H:541
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
virtual tmp< faPatchField< Type > > clone() const
Return clone.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
~processorFaPatchField()=default
Destructor.
int neighbProcNo() const noexcept
Return neighbour processor number.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
bool parallel() const
Are the cyclic planes parallel.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
virtual void initEvaluateLocal(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Initialise the evaluation of the patch field after a local.
::Foam::direction rank(const expressions::valueTypeCode) noexcept
The vector-space rank associated with given valueTypeCode.
Definition: exprTraits.C:70
The class contains the addressing required by the lduMatrix: upper, lower and losort.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
"buffered" : (MPI_Bsend, MPI_Recv)
A FieldMapper for finite-area patch fields.
virtual const tensorField & forwardT() const
Return face transformation tensor.
processorFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
virtual bool ready() const
Are all (receive) data available?
Namespace for OpenFOAM.
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
Processor patch.
int myProcNo() const noexcept
Return processor number.
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field given internal field.