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-2019 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  //- Copy constructor
133 
134  //- Construct and return a clone
135  virtual tmp<fvPatchField<Type>> clone() const
136  {
137  return tmp<fvPatchField<Type>>
138  (
139  new processorFvPatchField<Type>(*this)
140  );
141  }
142 
143  //- Copy constructor setting internal field reference
145  (
148  );
149 
150  //- Construct and return a clone setting internal field reference
152  (
154  ) const
155  {
156  return tmp<fvPatchField<Type>>
157  (
158  new processorFvPatchField<Type>(*this, iF)
159  );
160  }
161 
162 
163  //- Destructor
165 
166 
167  // Member Functions
168 
169  // Access
170 
171  //- Return true if running parallel
172  virtual bool coupled() const
173  {
174  if (Pstream::parRun())
175  {
176  return true;
177  }
178  else
179  {
180  return false;
181  }
182  }
183 
184  //- Return neighbour field given internal field
185  virtual tmp<Field<Type>> patchNeighbourField() const;
186 
187 
188  // Evaluation functions
189 
190  //- Initialise the evaluation of the patch field
191  virtual void initEvaluate(const Pstream::commsTypes commsType);
192 
193  //- Evaluate the patch field
194  virtual void evaluate(const Pstream::commsTypes commsType);
195 
196  //- Return patch-normal gradient
197  virtual tmp<Field<Type>> snGrad
198  (
199  const scalarField& deltaCoeffs
200  ) const;
201 
202  //- Is all data available
203  virtual bool ready() const;
204 
205  //- Initialise neighbour matrix update
206  virtual void initInterfaceMatrixUpdate
207  (
208  scalarField& result,
209  const scalarField& psiInternal,
210  const scalarField& coeffs,
211  const direction cmpt,
212  const Pstream::commsTypes commsType
213  ) const;
214 
215  //- Update result field based on interface functionality
216  virtual void updateInterfaceMatrix
217  (
218  scalarField& result,
219  const scalarField& psiInternal,
220  const scalarField& coeffs,
221  const direction cmpt,
222  const Pstream::commsTypes commsType
223  ) const;
224 
225  //- Initialise neighbour matrix update
226  virtual void initInterfaceMatrixUpdate
227  (
228  Field<Type>& result,
229  const Field<Type>& psiInternal,
230  const scalarField& coeffs,
231  const Pstream::commsTypes commsType
232  ) const;
233 
234  //- Update result field based on interface functionality
235  virtual void updateInterfaceMatrix
236  (
237  Field<Type>& result,
238  const Field<Type>& psiInternal,
239  const scalarField& coeffs,
240  const Pstream::commsTypes commsType
241  ) const;
242 
243 
244  //- Processor coupled interface functions
245 
246  //- Return communicator used for comms
247  virtual label comm() const
248  {
249  return procPatch_.comm();
250  }
251 
252  //- Return processor number
253  virtual int myProcNo() const
254  {
255  return procPatch_.myProcNo();
256  }
257 
258  //- Return neighbour processor number
259  virtual int neighbProcNo() const
260  {
261  return procPatch_.neighbProcNo();
262  }
263 
264  //- Does the patch field perform the transformation
265  virtual bool doTransform() const
266  {
267  return !(procPatch_.parallel() || pTraits<Type>::rank == 0);
268  }
269 
270  //- Return face transformation tensor
271  virtual const tensorField& forwardT() const
272  {
273  return procPatch_.forwardT();
274  }
275 
276  //- Return rank of component for transform
277  virtual int rank() const
278  {
279  return pTraits<Type>::rank;
280  }
281 
282 };
283 
284 
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 
287 } // End namespace Foam
288 
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 
291 #ifdef NoRepository
292  #include "processorFvPatchField.C"
293 #endif
294 
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 
297 #endif
298 
299 // ************************************************************************* //
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
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:158
virtual int neighbProcNo() const
Return neighbour processor number.
virtual bool parallel() const
Are the cyclic planes parallel.
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:61
Traits class for primitives.
Definition: pTraits.H:50
virtual label comm() const
Processor coupled interface functions.
virtual bool doTransform() const
Does the patch field perform the transformation.
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 tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
virtual const tensorField & forwardT() const
Return face transformation tensor.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
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 const tensorField & forwardT() const
Return face transformation tensor.
virtual bool ready() const
Is all data available.
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.