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-2020 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 
154  //- Destructor
156 
157 
158  // Member Functions
159 
160  // Access
161 
162  //- Return true if running parallel
163  virtual bool coupled() const
164  {
165  if (Pstream::parRun())
166  {
167  return true;
168  }
169  else
170  {
171  return false;
172  }
173  }
174 
175  //- Return neighbour field given internal field
176  virtual tmp<Field<Type>> patchNeighbourField() const;
177 
178 
179  // Evaluation functions
180 
181  //- Initialise the evaluation of the patch field
182  virtual void initEvaluate(const Pstream::commsTypes commsType);
183 
184  //- Evaluate the patch field
185  virtual void evaluate(const Pstream::commsTypes commsType);
186 
187  //- Return patch-normal gradient
188  virtual tmp<Field<Type>> snGrad
189  (
190  const scalarField& deltaCoeffs
191  ) const;
192 
193  //- Is all data available
194  virtual bool ready() const;
195 
196  //- Initialise neighbour matrix update
197  virtual void initInterfaceMatrixUpdate
198  (
199  scalarField& result,
200  const scalarField& psiInternal,
201  const scalarField& coeffs,
202  const direction cmpt,
203  const Pstream::commsTypes commsType
204  ) const;
205 
206  //- Update result field based on interface functionality
207  virtual void updateInterfaceMatrix
208  (
209  scalarField& result,
210  const scalarField& psiInternal,
211  const scalarField& coeffs,
212  const direction cmpt,
213  const Pstream::commsTypes commsType
214  ) const;
215 
216  //- Initialise neighbour matrix update
217  virtual void initInterfaceMatrixUpdate
218  (
219  Field<Type>& result,
220  const Field<Type>& psiInternal,
221  const scalarField& coeffs,
222  const Pstream::commsTypes commsType
223  ) const;
224 
225  //- Update result field based on interface functionality
226  virtual void updateInterfaceMatrix
227  (
228  Field<Type>& result,
229  const Field<Type>& psiInternal,
230  const scalarField& coeffs,
231  const Pstream::commsTypes commsType
232  ) const;
233 
234 
235  //- Processor coupled interface functions
236 
237  //- Return communicator used for comms
238  virtual label comm() const
239  {
240  return procPatch_.comm();
241  }
242 
243  //- Return processor number
244  virtual int myProcNo() const
245  {
246  return procPatch_.myProcNo();
247  }
248 
249  //- Return neighbour processor number
250  virtual int neighbProcNo() const
251  {
252  return procPatch_.neighbProcNo();
253  }
254 
255  //- Return transformation between the coupled patches
256  virtual const transformer& transform() const
257  {
258  return procPatch_.transform();
259  }
260 
261  //- Return rank of component for transform
262  virtual int rank() const
263  {
264  return pTraits<Type>::rank;
265  }
266 };
267 
268 
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270 
271 } // End namespace Foam
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 
275 #ifdef NoRepository
276  #include "processorFvPatchField.C"
277 #endif
278 
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 
281 #endif
282 
283 // ************************************************************************* //
virtual int myProcNo() const
Return processor number.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
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:62
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.
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.
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 > > patchNeighbourField() const
Return neighbour field given internal field.
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.