processorFvPatchField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::processorFvPatchField
26 
27 Description
28  This boundary condition enables processor communication across patches.
29 
30 Usage
31  Example of the boundary condition specification:
32  \verbatim
33  <patchName>
34  {
35  type processor;
36  }
37  \endverbatim
38 
39 SourceFiles
40  processorFvPatchField.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef processorFvPatchField_H
45 #define processorFvPatchField_H
46 
47 #include "coupledFvPatchField.H"
49 #include "processorFvPatch.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class processorFvPatchField Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 template<class Type>
62 :
64  public coupledFvPatchField<Type>
65 {
66  // Private Data
67 
68  //- Local reference cast into the processor patch
69  const processorFvPatch& procPatch_;
70 
71  // Sending and receiving
72 
73  //- Send buffer.
74  mutable Field<Type> sendBuf_;
75 
76  //- Receive buffer.
77  mutable Field<Type> receiveBuf_;
78 
79  //- Outstanding request
80  mutable label outstandingSendRequest_;
81 
82  //- Outstanding request
83  mutable label outstandingRecvRequest_;
84 
85  //- Scalar send buffer
86  mutable Field<scalar> scalarSendBuf_;
87 
88  //- Scalar receive buffer
89  mutable Field<scalar> scalarReceiveBuf_;
90 
91 public:
92 
93  //- Runtime type information
94  TypeName(processorFvPatch::typeName_());
95 
96 
97  // Constructors
98 
99  //- Construct from patch and internal field
101  (
102  const fvPatch&,
104  );
105 
106  //- Construct from patch and internal field and patch field
108  (
109  const fvPatch&,
111  const Field<Type>&
112  );
113 
114  //- Construct from patch, internal field and dictionary
116  (
117  const fvPatch&,
119  const dictionary&
120  );
121 
122  //- Construct by mapping given processorFvPatchField onto a new patch
124  (
126  const fvPatch&,
128  const fvPatchFieldMapper&
129  );
130 
131  //- Disallow copy without setting internal field reference
133 
134  //- Copy constructor setting internal field reference
136  (
139  );
140 
141  //- Construct and return a clone setting internal field reference
143  (
145  ) const
146  {
147  return tmp<fvPatchField<Type>>
148  (
149  new processorFvPatchField<Type>(*this, iF)
150  );
151  }
152 
153  //- Construct and return a clone onto a new patch
154  // setting internal field reference
156  (
157  const fvPatch& patch,
159  ) const
160  {
161  return tmp<fvPatchField<Type>>
162  (
163  new processorFvPatchField<Type>(patch, iF, *this)
164  );
165  }
166 
167 
168  //- Destructor
170 
171 
172  // Member Functions
173 
174  // Access
175 
176  //- Return true if running parallel
177  virtual bool coupled() const
178  {
179  if (Pstream::parRun())
180  {
181  return true;
182  }
183  else
184  {
185  return false;
186  }
187  }
188 
189  //- Return neighbour field given internal field
191  (
192  const Pstream::commsTypes
193  ) const;
194 
195 
196  // Evaluation functions
197 
198  //- Initialise the evaluation of the patch field
199  virtual void initEvaluate(const Pstream::commsTypes commsType);
200 
201  //- Evaluate the patch field
202  virtual void evaluate(const Pstream::commsTypes commsType);
203 
204  //- Return patch-normal gradient
205  virtual tmp<Field<Type>> snGrad
206  (
207  const scalarField& deltaCoeffs
208  ) const;
209 
210  //- Is all data available
211  virtual bool ready() const;
212 
213  //- Initialise neighbour matrix update
214  virtual void initInterfaceMatrixUpdate
215  (
216  scalarField& result,
217  const scalarField& psiInternal,
218  const scalarField& coeffs,
219  const direction cmpt,
220  const Pstream::commsTypes commsType
221  ) const;
222 
223  //- Update result field based on interface functionality
224  virtual void updateInterfaceMatrix
225  (
226  scalarField& result,
227  const scalarField& psiInternal,
228  const scalarField& coeffs,
229  const direction cmpt,
230  const Pstream::commsTypes commsType
231  ) const;
232 
233  //- Initialise neighbour matrix update
234  virtual void initInterfaceMatrixUpdate
235  (
236  Field<Type>& result,
237  const Field<Type>& psiInternal,
238  const scalarField& coeffs,
239  const Pstream::commsTypes commsType
240  ) const;
241 
242  //- Update result field based on interface functionality
243  virtual void updateInterfaceMatrix
244  (
245  Field<Type>& result,
246  const Field<Type>& psiInternal,
247  const scalarField& coeffs,
248  const Pstream::commsTypes commsType
249  ) const;
250 
251 
252  //- Processor coupled interface functions
253 
254  //- Return communicator used for comms
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  //- Return transformation between the coupled patches
273  virtual const transformer& transform() const
274  {
275  return procPatch_.transform();
276  }
277 
278  //- Return rank of component for transform
279  virtual int rank() const
280  {
281  return pTraits<Type>::rank;
282  }
283 };
284 
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 } // End namespace Foam
289 
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 
292 #ifdef NoRepository
293  #include "processorFvPatchField.C"
294 #endif
295 
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 
298 #endif
299 
300 // ************************************************************************* //
virtual int myProcNo() const
Return processor number.
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space...
Definition: transformer.H:83
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual int neighbProcNo() const
Return neighbour processor number.
commsTypes
Types of communications.
Definition: UPstream.H:64
virtual bool coupled() const
Return true if running parallel.
uint8_t direction
Definition: direction.H:45
virtual int myProcNo() const
Return processor number.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Traits class for primitives.
Definition: pTraits.H:50
virtual label comm() const
Processor coupled interface functions.
virtual const transformer & transform() const
Return transformation between the coupled patches.
virtual int neighbProcNo() const
Return neighbour processor number.
virtual void initInterfaceMatrixUpdate(scalarField &result, const scalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
TypeName(processorFvPatch::typeName_())
Runtime type information.
Abstract base class for processor coupled interfaces.
Pre-declare SubField and related Field type.
Definition: Field.H:56
Foam::fvPatchFieldMapper.
Processor patch.
virtual int rank() const
Return rank of component for transform.
Abstract base class for coupled patches.
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:351
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
virtual const transformer & transform() const
Return transformation between the coupled patches.
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual void updateInterfaceMatrix(scalarField &result, const scalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
virtual tmp< Field< Type > > patchNeighbourField(const Pstream::commsTypes) const
Return neighbour field given internal field.
This boundary condition enables processor communication across patches.
A class for managing temporary objects.
Definition: PtrList.H:53
virtual bool ready() const
Is all data available.
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:199
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.