processorFvPatchField.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 | Copyright (C) 2011-2016 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 Group
28  grpCoupledBoundaryConditions
29 
30 Description
31  This boundary condition enables processor communication across patches.
32 
33 Usage
34  Example of the boundary condition specification:
35  \verbatim
36  <patchName>
37  {
38  type processor;
39  }
40  \endverbatim
41 
42 SourceFiles
43  processorFvPatchField.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef processorFvPatchField_H
48 #define processorFvPatchField_H
49 
50 #include "coupledFvPatchField.H"
52 #include "processorFvPatch.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class processorFvPatchField Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 template<class Type>
65 :
67  public coupledFvPatchField<Type>
68 {
69  // Private data
70 
71  //- Local reference cast into the processor patch
72  const processorFvPatch& procPatch_;
73 
74  // Sending and receiving
75 
76  //- Send buffer.
77  mutable Field<Type> sendBuf_;
78 
79  //- Receive buffer.
80  mutable Field<Type> receiveBuf_;
81 
82  //- Outstanding request
83  mutable label outstandingSendRequest_;
84 
85  //- Outstanding request
86  mutable label outstandingRecvRequest_;
87 
88  //- Scalar send buffer
89  mutable Field<scalar> scalarSendBuf_;
90 
91  //- Scalar receive buffer
92  mutable Field<scalar> scalarReceiveBuf_;
93 
94 public:
95 
96  //- Runtime type information
97  TypeName(processorFvPatch::typeName_());
98 
99 
100  // Constructors
101 
102  //- Construct from patch and internal field
104  (
105  const fvPatch&,
107  );
108 
109  //- Construct from patch and internal field and patch field
111  (
112  const fvPatch&,
114  const Field<Type>&
115  );
116 
117  //- Construct from patch, internal field and dictionary
119  (
120  const fvPatch&,
122  const dictionary&
123  );
124 
125  //- Construct by mapping given processorFvPatchField onto a new patch
127  (
129  const fvPatch&,
131  const fvPatchFieldMapper&
132  );
133 
134  //- Construct as copy
136 
137  //- Construct and return a clone
138  virtual tmp<fvPatchField<Type>> clone() const
139  {
140  return tmp<fvPatchField<Type>>
141  (
142  new processorFvPatchField<Type>(*this)
143  );
144  }
145 
146  //- Construct as copy setting internal field reference
148  (
151  );
152 
153  //- Construct and return a clone setting internal field reference
155  (
157  ) const
158  {
159  return tmp<fvPatchField<Type>>
160  (
161  new processorFvPatchField<Type>(*this, iF)
162  );
163  }
164 
165 
166  //- Destructor
168 
169 
170  // Member functions
171 
172  // Access
173 
174  //- Return true if running parallel
175  virtual bool coupled() const
176  {
177  if (Pstream::parRun())
178  {
179  return true;
180  }
181  else
182  {
183  return false;
184  }
185  }
186 
187  //- Return neighbour field given internal field
188  virtual tmp<Field<Type>> patchNeighbourField() const;
189 
190 
191  // Evaluation functions
192 
193  //- Initialise the evaluation of the patch field
194  virtual void initEvaluate(const Pstream::commsTypes commsType);
195 
196  //- Evaluate the patch field
197  virtual void evaluate(const Pstream::commsTypes commsType);
198 
199  //- Return patch-normal gradient
200  virtual tmp<Field<Type>> snGrad
201  (
202  const scalarField& deltaCoeffs
203  ) const;
204 
205  //- Is all data available
206  virtual bool ready() const;
207 
208  //- Initialise neighbour matrix update
209  virtual void initInterfaceMatrixUpdate
210  (
211  scalarField& result,
212  const scalarField& psiInternal,
213  const scalarField& coeffs,
214  const direction cmpt,
215  const Pstream::commsTypes commsType
216  ) const;
217 
218  //- Update result field based on interface functionality
219  virtual void updateInterfaceMatrix
220  (
221  scalarField& result,
222  const scalarField& psiInternal,
223  const scalarField& coeffs,
224  const direction cmpt,
225  const Pstream::commsTypes commsType
226  ) const;
227 
228  //- Initialise neighbour matrix update
229  virtual void initInterfaceMatrixUpdate
230  (
231  Field<Type>& result,
232  const Field<Type>& psiInternal,
233  const scalarField& coeffs,
234  const Pstream::commsTypes commsType
235  ) const;
236 
237  //- Update result field based on interface functionality
238  virtual void updateInterfaceMatrix
239  (
240  Field<Type>& result,
241  const Field<Type>& psiInternal,
242  const scalarField& coeffs,
243  const Pstream::commsTypes commsType
244  ) const;
245 
246 
247  //- Processor coupled interface functions
248 
249  //- Return communicator used for comms
250  virtual label comm() const
251  {
252  return procPatch_.comm();
253  }
254 
255  //- Return processor number
256  virtual int myProcNo() const
257  {
258  return procPatch_.myProcNo();
259  }
260 
261  //- Return neigbour processor number
262  virtual int neighbProcNo() const
263  {
264  return procPatch_.neighbProcNo();
265  }
266 
267  //- Does the patch field perform the transfromation
268  virtual bool doTransform() const
269  {
270  return !(procPatch_.parallel() || pTraits<Type>::rank == 0);
271  }
272 
273  //- Return face transformation tensor
274  virtual const tensorField& forwardT() const
275  {
276  return procPatch_.forwardT();
277  }
278 
279  //- Return rank of component for transform
280  virtual int rank() const
281  {
282  return pTraits<Type>::rank;
283  }
284 
285 };
286 
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 } // End namespace Foam
291 
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 
294 #ifdef NoRepository
295  #include "processorFvPatchField.C"
296 #endif
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 #endif
301 
302 // ************************************************************************* //
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
uint8_t direction
Definition: direction.H:46
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:137
commsTypes
Types of communications.
Definition: UPstream.H:64
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Traits class for primitives.
Definition: pTraits.H:50
virtual const tensorField & forwardT() const
Return face transformation tensor.
virtual bool coupled() const
Return true if running parallel.
virtual bool parallel() const
Are the cyclic planes parallel.
virtual bool doTransform() const
Does the patch field perform the transfromation.
TypeName(processorFvPatch::typeName_())
Runtime type information.
virtual bool ready() const
Is all data available.
Abstract base class for processor coupled interfaces.
virtual int neighbProcNo() const
Return neigbour processor number.
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::fvPatchFieldMapper.
Processor patch.
virtual void initInterfaceMatrixUpdate(scalarField &result, const scalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field given internal field.
Abstract base class for coupled patches.
virtual int rank() const
Return rank of component for transform.
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
virtual const tensorField & forwardT() const
Return face transformation tensor.
virtual int myProcNo() const
Return processor number.
virtual int myProcNo() const
Return processor number.
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:393
virtual label comm() const
Return communicator used for comms.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
This boundary condition enables processor communication across patches.
A class for managing temporary objects.
Definition: PtrList.H:54
virtual int neighbProcNo() const
Return neigbour processor number.
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.
processorFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Namespace for OpenFOAM.
virtual label comm() const
Processor coupled interface functions.