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  //- Return patch-normal gradient
196  virtual tmp<Field<Type>> snGrad() const;
197 
198 
199  // Coupled interface functionality
200 
201  //- Initialise neighbour matrix update
202  virtual void initInterfaceMatrixUpdate
203  (
204  solveScalarField& result,
205  const bool add,
206  const lduAddressing& lduAddr,
207  const label patchId,
208  const solveScalarField& psiInternal,
209  const scalarField& coeffs,
210  const direction cmpt,
211  const Pstream::commsTypes commsType
212  ) const;
213 
214  //- Update result field based on interface functionality
215  virtual void updateInterfaceMatrix
216  (
217  solveScalarField& result,
218  const bool add,
219  const lduAddressing& lduAddr,
220  const label patchId,
221  const solveScalarField& psiInternal,
222  const scalarField& coeffs,
223  const direction cmpt,
224  const Pstream::commsTypes commsType
225  ) const;
226 
227  //- Initialise neighbour matrix update
228  virtual void initInterfaceMatrixUpdate
229  (
230  Field<Type>& result,
231  const bool add,
232  const lduAddressing& lduAddr,
233  const label patchId,
234  const Field<Type>&,
235  const scalarField& coeffs,
236  const Pstream::commsTypes commsType
237  ) const;
238 
239  //- Update result field based on interface functionality
240  virtual void updateInterfaceMatrix
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 
252  // Processor coupled interface functions
253 
254  //- Return communicator used for communication
255  virtual label comm() const
256  {
257  return procPatch_.comm();
258  }
259 
260  //- Return processor number
261  virtual int myProcNo() const
262  {
263  return procPatch_.myProcNo();
264  }
265 
266  //- Return neighbour processor number
267  virtual int neighbProcNo() const
268  {
269  return procPatch_.neighbProcNo();
270  }
271 
272  //- Does the patch field perform the transformation
273  virtual bool doTransform() const
274  {
275  return (pTraits<Type>::rank && !procPatch_.parallel());
276  }
277 
278  //- Return face transformation tensor
279  virtual const tensorField& forwardT() const
280  {
281  return procPatch_.forwardT();
282  }
283 
284  //- Return rank of component for transform
285  virtual int rank() const
286  {
287  return pTraits<Type>::rank;
288  }
289 };
290 
291 
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 
294 } // End namespace Foam
295 
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 
298 #ifdef NoRepository
299  #include "processorFaPatchField.C"
300 #endif
301 
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 
304 #endif
305 
306 // ************************************************************************* //
label patchId(-1)
virtual int myProcNo() const
Return processor number.
uint8_t direction
Definition: direction.H:48
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:74
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
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:1004
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.
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.