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