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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::processorFvPatchField
29 
30 Group
31  grpCoupledBoundaryConditions
32 
33 Description
34  This boundary condition enables processor communication across patches.
35 
36 Usage
37  Example of the boundary condition specification:
38  \verbatim
39  <patchName>
40  {
41  type processor;
42  }
43  \endverbatim
44 
45 SourceFiles
46  processorFvPatchField.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef processorFvPatchField_H
51 #define processorFvPatchField_H
52 
53 #include "coupledFvPatchField.H"
55 #include "processorFvPatch.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class processorFvPatchField Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 template<class Type>
68 :
70  public coupledFvPatchField<Type>
71 {
72  // Private data
73 
74  //- Local reference cast into the processor patch
75  const processorFvPatch& procPatch_;
76 
77  // Sending and receiving
78 
79  //- Send buffer.
80  mutable Field<Type> sendBuf_;
81 
82  //- Receive buffer.
83  mutable Field<Type> receiveBuf_;
84 
85  //- Outstanding request
86  mutable label outstandingSendRequest_;
87 
88  //- Outstanding request
89  mutable label outstandingRecvRequest_;
90 
91  //- Scalar send buffer
92  mutable solveScalarField scalarSendBuf_;
93 
94  //- Scalar receive buffer
95  mutable solveScalarField scalarReceiveBuf_;
96 
97 
98 public:
99 
100  //- Runtime type information
101  TypeName(processorFvPatch::typeName_());
102 
103 
104  // Constructors
105 
106  //- Construct from patch and internal field
108  (
109  const fvPatch&,
111  );
112 
113  //- Construct from patch and internal field and patch field
115  (
116  const fvPatch&,
118  const Field<Type>&
119  );
120 
121  //- Construct from patch, internal field and dictionary
123  (
124  const fvPatch&,
126  const dictionary&
127  );
128 
129  //- Construct by mapping given processorFvPatchField onto a new patch
131  (
133  const fvPatch&,
135  const fvPatchFieldMapper&
136  );
137 
138  //- Construct as copy
140 
141  //- Construct and return a clone
142  virtual tmp<fvPatchField<Type>> clone() const
143  {
144  return tmp<fvPatchField<Type>>
145  (
146  new processorFvPatchField<Type>(*this)
147  );
148  }
149 
150  //- Construct as copy setting internal field reference
152  (
155  );
156 
157  //- Construct and return a clone setting internal field reference
159  (
161  ) const
162  {
163  return tmp<fvPatchField<Type>>
164  (
165  new processorFvPatchField<Type>(*this, iF)
166  );
167  }
168 
169 
170  //- Destructor
171  ~processorFvPatchField() = default;
172 
173 
174  // Member functions
175 
176  // Access
177 
178  //- Return true if running parallel
179  virtual bool coupled() const
180  {
181  if (Pstream::parRun())
182  {
183  return true;
184  }
185  else
186  {
187  return false;
188  }
189  }
190 
191  //- Return neighbour field given internal field
192  virtual tmp<Field<Type>> patchNeighbourField() const;
193 
194 
195  // Evaluation functions
196 
197  //- Initialise the evaluation of the patch field
198  virtual void initEvaluate(const Pstream::commsTypes commsType);
199 
200  //- Evaluate the patch field
201  virtual void evaluate(const Pstream::commsTypes commsType);
202 
203  //- Return patch-normal gradient
204  virtual tmp<Field<Type>> snGrad
205  (
206  const scalarField& deltaCoeffs
207  ) const;
208 
209  //- Is all data available
210  virtual bool ready() const;
211 
212  //- Initialise neighbour matrix update
213  virtual void initInterfaceMatrixUpdate
214  (
215  solveScalarField& result,
216  const bool add,
217  const solveScalarField& 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  solveScalarField& result,
227  const bool add,
228  const solveScalarField& psiInternal,
229  const scalarField& coeffs,
230  const direction cmpt,
231  const Pstream::commsTypes commsType
232  ) const;
233 
234  //- Initialise neighbour matrix update
235  virtual void initInterfaceMatrixUpdate
236  (
237  Field<Type>& result,
238  const bool add,
239  const Field<Type>& psiInternal,
240  const scalarField& coeffs,
241  const Pstream::commsTypes commsType
242  ) const;
243 
244  //- Update result field based on interface functionality
245  virtual void updateInterfaceMatrix
246  (
247  Field<Type>& result,
248  const bool add,
249  const Field<Type>& psiInternal,
250  const scalarField& coeffs,
251  const Pstream::commsTypes commsType
252  ) const;
253 
254 
255  //- Processor coupled interface functions
256 
257  //- Return communicator used for comms
258  virtual label comm() const
259  {
260  return procPatch_.comm();
261  }
262 
263  //- Return processor number
264  virtual int myProcNo() const
265  {
266  return procPatch_.myProcNo();
267  }
268 
269  //- Return neighbour processor number
270  virtual int neighbProcNo() const
271  {
272  return procPatch_.neighbProcNo();
273  }
274 
275  //- Does the patch field perform the transformation
276  virtual bool doTransform() const
277  {
278  return !(procPatch_.parallel() || pTraits<Type>::rank == 0);
279  }
280 
281  //- Return face transformation tensor
282  virtual const tensorField& forwardT() const
283  {
284  return procPatch_.forwardT();
285  }
286 
287  //- Return rank of component for transform
288  virtual int rank() const
289  {
290  return pTraits<Type>::rank;
291  }
292 
293 };
294 
295 
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 
298 } // End namespace Foam
299 
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 
302 #ifdef NoRepository
303  #include "processorFvPatchField.C"
304 #endif
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 #endif
309 
310 // ************************************************************************* //
Foam::processorFvPatchField::coupled
virtual bool coupled() const
Return true if running parallel.
Definition: processorFvPatchField.H:178
processorFvPatch.H
Foam::processorFvPatchField::processorFvPatchField
processorFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: processorFvPatchField.C:38
Foam::processorFvPatchField::comm
virtual label comm() const
Processor coupled interface functions.
Definition: processorFvPatchField.H:257
Foam::processorFvPatchField
This boundary condition enables processor communication across patches.
Definition: processorFvPatchField.H:66
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::processorFvPatch::parallel
virtual bool parallel() const
Are the cyclic planes parallel.
Definition: processorFvPatch.H:131
Foam::processorFvPatchField::myProcNo
virtual int myProcNo() const
Return processor number.
Definition: processorFvPatchField.H:263
Foam::UPstream::parRun
static bool & parRun()
Test if this a parallel run, or allow modify access.
Definition: UPstream.H:434
processorLduInterfaceField.H
Foam::processorFvPatch
Processor patch.
Definition: processorFvPatch.H:52
Foam::processorFvPatchField::TypeName
TypeName(processorFvPatch::typeName_())
Runtime type information.
Foam::processorFvPatchField::~processorFvPatchField
~processorFvPatchField()=default
Destructor.
Foam::processorFvPatchField::initEvaluate
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
Definition: processorFvPatchField.C:214
Foam::processorFvPatch::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: processorFvPatch.H:137
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::processorFvPatch::neighbProcNo
virtual int neighbProcNo() const
Return neighbour processor number.
Definition: processorFvPatch.H:101
Foam::processorFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
Definition: processorFvPatchField.C:262
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::processorFvPatchField::updateInterfaceMatrix
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
Definition: processorFvPatchField.C:374
Foam::processorFvPatchField::doTransform
virtual bool doTransform() const
Does the patch field perform the transformation.
Definition: processorFvPatchField.H:275
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:939
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::processorFvPatchField::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: processorFvPatchField.H:281
Foam::processorFvPatchField::initInterfaceMatrixUpdate
virtual void initInterfaceMatrixUpdate(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
Definition: processorFvPatchField.C:313
Foam::processorFvPatch::comm
virtual label comm() const
Return communicator used for comms.
Definition: processorFvPatch.H:89
Foam::processorFvPatchField::patchNeighbourField
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field given internal field.
Definition: processorFvPatchField.C:199
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
processorFvPatchField.C
Foam::coupledFvPatchField
Abstract base class for coupled patches.
Definition: coupledFvPatchField.H:57
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:54
Foam::processorFvPatchField::ready
virtual bool ready() const
Is all data available.
Definition: processorFvPatchField.C:563
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::processorFvPatchField::rank
virtual int rank() const
Return rank of component for transform.
Definition: processorFvPatchField.H:287
Foam::processorFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: processorFvPatchField.H:141
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
coupledFvPatchField.H
Foam::processorFvPatchField::neighbProcNo
virtual int neighbProcNo() const
Return neighbour processor number.
Definition: processorFvPatchField.H:269
Foam::coupledFvPatchField::snGrad
virtual tmp< Field< Type > > snGrad() const
Return patch-normal gradient.
Definition: coupledFvPatchField.H:151
Foam::processorLduInterfaceField
Abstract base class for processor coupled interfaces.
Definition: processorLduInterfaceField.H:52
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::processorFvPatch::myProcNo
virtual int myProcNo() const
Return processor number.
Definition: processorFvPatch.H:95