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 and return a clone
141  virtual tmp<faPatchField<Type>> clone() const
142  {
143  return tmp<faPatchField<Type>>
144  (
145  new processorFaPatchField<Type>(*this)
146  );
147  }
148 
149  //- Construct as copy setting internal field reference
151  (
154  );
155 
156  //- Construct and return a clone setting internal field reference
158  (
160  ) const
161  {
162  return tmp<faPatchField<Type>>
163  (
164  new processorFaPatchField<Type>(*this, iF)
165  );
166  }
167 
168 
169  //- Destructor
170  ~processorFaPatchField() = default;
171 
172 
173  // Member Functions
174 
175  // Coupling
176 
177  //- The patch field is coupled if running in parallel
178  virtual bool coupled() const { return UPstream::parRun(); }
179 
180  //- Are all (receive) data available?
181  virtual bool ready() const;
182 
183  //- Return neighbour field given internal field
184  tmp<Field<Type>> patchNeighbourField() const;
185 
186 
187  // Evaluation
188 
189  //- Initialise the evaluation of the patch field
190  virtual void initEvaluate(const Pstream::commsTypes commsType);
191 
192  //- Evaluate the patch field
193  virtual void evaluate(const Pstream::commsTypes commsType);
194 
195  //- Initialise the evaluation of the patch field after a local
196  // operation. Dummy since operating on a copy
197  virtual void initEvaluateLocal
198  (
199  const Pstream::commsTypes commsType =
201  )
202  {}
203 
204  //- Evaluate the patch field after a local operation (e.g. *=).
205  // Dummy since operating on a copy
206  virtual void evaluateLocal
207  (
208  const Pstream::commsTypes commsType =
210  )
211  {}
212 
213  //- Return patch-normal gradient
214  virtual tmp<Field<Type>> snGrad() const;
215 
216 
217  // Coupled interface functionality
218 
219  //- Initialise neighbour matrix update
220  virtual void initInterfaceMatrixUpdate
221  (
222  solveScalarField& result,
223  const bool add,
224  const lduAddressing& lduAddr,
225  const label patchId,
226  const solveScalarField& psiInternal,
227  const scalarField& coeffs,
228  const direction cmpt,
229  const Pstream::commsTypes commsType
230  ) const;
231 
232  //- Update result field based on interface functionality
233  virtual void updateInterfaceMatrix
234  (
235  solveScalarField& result,
236  const bool add,
237  const lduAddressing& lduAddr,
238  const label patchId,
239  const solveScalarField& psiInternal,
240  const scalarField& coeffs,
241  const direction cmpt,
242  const Pstream::commsTypes commsType
243  ) const;
244 
245  //- Initialise neighbour matrix update
246  virtual void initInterfaceMatrixUpdate
247  (
248  Field<Type>& result,
249  const bool add,
250  const lduAddressing& lduAddr,
251  const label patchId,
252  const Field<Type>&,
253  const scalarField& coeffs,
254  const Pstream::commsTypes commsType
255  ) const;
256 
257  //- Update result field based on interface functionality
258  virtual void updateInterfaceMatrix
259  (
260  Field<Type>& result,
261  const bool add,
262  const lduAddressing& lduAddr,
263  const label patchId,
264  const Field<Type>&,
265  const scalarField& coeffs,
266  const Pstream::commsTypes commsType
267  ) const;
268 
269 
270  // Processor coupled interface functions
271 
272  //- Return communicator used for communication
273  virtual label comm() const
274  {
275  return procPatch_.comm();
276  }
277 
278  //- Return processor number
279  virtual int myProcNo() const
280  {
281  return procPatch_.myProcNo();
282  }
283 
284  //- Return neighbour processor number
285  virtual int neighbProcNo() const
286  {
287  return procPatch_.neighbProcNo();
288  }
289 
290  //- Does the patch field perform the transformation
291  virtual bool doTransform() const
292  {
293  return (pTraits<Type>::rank && !procPatch_.parallel());
294  }
295 
296  //- Return face transformation tensor
297  virtual const tensorField& forwardT() const
298  {
299  return procPatch_.forwardT();
300  }
301 
302  //- Return rank of component for transform
303  virtual int rank() const
304  {
305  return pTraits<Type>::rank;
306  }
307 };
308 
309 
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 
312 } // End namespace Foam
313 
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
315 
316 #ifdef NoRepository
317  #include "processorFaPatchField.C"
318 #endif
319 
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
321 
322 #endif
323 
324 // ************************************************************************* //
label patchId(-1)
virtual int myProcNo() const
Return processor number.
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
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: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 coupled() const
The patch field is coupled if running in parallel.
virtual void evaluateLocal(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field after a local operation (e.g. *=).
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1049
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.
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
Construct and return a 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...
Definition: areaFieldsFwd.H:42
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
::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
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.