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 lduAddressing& lduAddr,
218  const label patchId,
219  const solveScalarField& psiInternal,
220  const scalarField& coeffs,
221  const direction cmpt,
222  const Pstream::commsTypes commsType
223  ) const;
224 
225  //- Update result field based on interface functionality
226  virtual void updateInterfaceMatrix
227  (
228  solveScalarField& result,
229  const bool add,
230  const lduAddressing& lduAddr,
231  const label patchId,
232  const solveScalarField& psiInternal,
233  const scalarField& coeffs,
234  const direction cmpt,
235  const Pstream::commsTypes commsType
236  ) const;
237 
238  //- Initialise neighbour matrix update
239  virtual void initInterfaceMatrixUpdate
240  (
241  Field<Type>& result,
242  const bool add,
243  const lduAddressing& lduAddr,
244  const label patchId,
245  const Field<Type>& psiInternal,
246  const scalarField& coeffs,
247  const Pstream::commsTypes commsType
248  ) const;
249 
250  //- Update result field based on interface functionality
251  virtual void updateInterfaceMatrix
252  (
253  Field<Type>& result,
254  const bool add,
255  const lduAddressing& lduAddr,
256  const label patchId,
257  const Field<Type>& psiInternal,
258  const scalarField& coeffs,
259  const Pstream::commsTypes commsType
260  ) const;
261 
262 
263 
264  //- Processor coupled interface functions
265 
266  //- Return communicator used for comms
267  virtual label comm() const
268  {
269  return procPatch_.comm();
270  }
271 
272  //- Return processor number
273  virtual int myProcNo() const
274  {
275  return procPatch_.myProcNo();
276  }
277 
278  //- Return neighbour processor number
279  virtual int neighbProcNo() const
280  {
281  return procPatch_.neighbProcNo();
282  }
283 
284  //- Does the patch field perform the transformation
285  virtual bool doTransform() const
286  {
287  return !(procPatch_.parallel() || pTraits<Type>::rank == 0);
288  }
289 
290  //- Return face transformation tensor
291  virtual const tensorField& forwardT() const
292  {
293  return procPatch_.forwardT();
294  }
295 
296  //- Return rank of component for transform
297  virtual int rank() const
298  {
299  return pTraits<Type>::rank;
300  }
301 
302 };
303 
304 
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 
307 } // End namespace Foam
308 
309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 
311 #ifdef NoRepository
312  #include "processorFvPatchField.C"
313 #endif
314 
315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316 
317 #endif
318 
319 // ************************************************************************* //
Foam::lduAddressing
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Definition: lduAddressing.H:114
Foam::processorFvPatchField::coupled
virtual bool coupled() const
Return true if running parallel.
Definition: processorFvPatchField.H:178
Foam::processorFvPatchField::updateInterfaceMatrix
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
Definition: processorFvPatchField.C:391
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:266
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:125
Foam::processorFvPatchField::myProcNo
virtual int myProcNo() const
Return processor number.
Definition: processorFvPatchField.H:272
processorLduInterfaceField.H
Foam::processorFvPatch
Processor patch.
Definition: processorFvPatch.H:53
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::processorFvPatchField::initInterfaceMatrixUpdate
virtual void initInterfaceMatrixUpdate(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
Definition: processorFvPatchField.C:320
Foam::processorFvPatch::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: processorFvPatch.H:131
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::processorFvPatch::neighbProcNo
virtual int neighbProcNo() const
Return neighbour processor number.
Definition: processorFvPatch.H:102
Foam::processorFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
Definition: processorFvPatchField.C:269
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:123
Foam::processorFvPatchField::doTransform
virtual bool doTransform() const
Does the patch field perform the transformation.
Definition: processorFvPatchField.H:284
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:290
Foam::processorFvPatch::comm
virtual label comm() const
Return communicator used for comms.
Definition: processorFvPatch.H:90
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::processorFvPatchField::patchNeighbourField
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field given internal field.
Definition: processorFvPatchField.C:199
processorFvPatchField.C
Foam::coupledFvPatchField
Abstract base class for coupled patches.
Definition: coupledFvPatchField.H:57
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::processorFvPatchField::ready
virtual bool ready() const
Is all data available.
Definition: processorFvPatchField.C:604
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:296
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
patchId
label patchId(-1)
coupledFvPatchField.H
Foam::processorFvPatchField::neighbProcNo
virtual int neighbProcNo() const
Return neighbour processor number.
Definition: processorFvPatchField.H:278
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:96