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