calculatedProcessorFvPatchField.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) 2019-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::calculatedProcessorFvPatchField
28 
29 Group
30  grpGenericBoundaryConditions
31 
32 Description
33  A processorFvPatchField type bypassing fvPatch
34 
35  Used to temporarily add updateInterfaceMatrix capabilities to a matrix
36  during overset solving. Supplies:
37  - patchNeighbourField functionality (cached in *this as per
38  processorFvPatchField)
39  - initEvaluate/evaluate: caching of patchNeighbourField (see above)
40  - initInterfaceMatrixUpdate etc: adding of neighbouring data
41 
42 SourceFiles
43  calculatedProcessorFvPatchField.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef Foam_calculatedProcessorFvPatchField_H
48 #define Foam_calculatedProcessorFvPatchField_H
49 
51 #include "coupledFvPatchField.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class calculatedProcessorFvPatchField Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 template<class Type>
65 :
67  public coupledFvPatchField<Type>
68 {
69 protected:
70 
71  // Protected Data
72 
73  //- Local reference cast into the interface
75 
76 
77  // Sending and receiving
78 
79  //- Current (non-blocking) send request
80  mutable label sendRequest_;
81 
82  //- Current (non-blocking) recv request
83  mutable label recvRequest_;
84 
85  //- Send buffer
86  mutable Field<Type> sendBuf_;
87 
88  //- Receive buffer
90 
91  //- Scalar send buffer
93 
94  //- Scalar recv buffer
96 
97 
98  // Protected Member Functions
99 
100  void addToInternalField
101  (
102  solveScalarField& result,
103  const bool add,
104  const scalarField& coeffs,
105  const solveScalarField& vals
106  ) const;
107 
108 
109  //- Receive and send requests have both completed
110  virtual bool all_ready() const;
111 
112 
113 public:
114 
115  //- Runtime type information
116  TypeName("calculatedProcessor");
117 
118 
119  // Constructors
120 
121  //- Construct from patch and internal field
123  (
124  const lduInterface& interface,
125  const fvPatch&,
127  );
128 
129  //- Construct as copy
131  (
133  );
134 
135  //- Construct as copy setting internal field reference
137  (
140  );
141 
142  //- Return a clone
143  virtual tmp<fvPatchField<Type>> clone() const
144  {
145  return fvPatchField<Type>::Clone(*this);
146  }
147 
148  //- Clone with an internal field reference
150  (
152  ) const
153  {
154  return fvPatchField<Type>::Clone(*this, iF);
155  }
156 
157 
158  //- Destructor
159  virtual ~calculatedProcessorFvPatchField() = default;
160 
161 
162  // Member Functions
163 
164  // Coupling
165 
166  //- The patch field is coupled if running in parallel
167  virtual bool coupled() const { return UPstream::parRun(); }
168 
169  //- Are all (receive) data available?
170  virtual bool ready() const;
171 
172  //- Return neighbour field of internal field
174 
175 
176  // Evaluation
177 
178  //- Initialise the evaluation of the patch field
179  virtual void initEvaluate(const Pstream::commsTypes commsType);
180 
181  //- Evaluate the patch field
182  virtual void evaluate(const Pstream::commsTypes commsType);
183 
184 
185  // Coupled interface functionality
186 
187  //- Initialise neighbour matrix update
188  virtual void initInterfaceMatrixUpdate
189  (
190  solveScalarField& result,
191  const bool add,
192  const lduAddressing& lduAddr,
193  const label patchId,
194  const solveScalarField& psiInternal,
195  const scalarField& coeffs,
196  const direction cmpt,
197  const Pstream::commsTypes commsType
198  ) const;
199 
200  //- Update result field based on interface functionality
201  virtual void updateInterfaceMatrix
202  (
203  solveScalarField& result,
204  const bool add,
205  const lduAddressing& lduAddr,
206  const label patchId,
207  const solveScalarField& psiInternal,
208  const scalarField& coeffs,
209  const direction cmpt,
210  const Pstream::commsTypes commsType
211  ) const;
212 
213  //- Initialise neighbour matrix update
214  virtual void initInterfaceMatrixUpdate
215  (
216  Field<Type>& result,
217  const bool add,
218  const lduAddressing& lduAddr,
219  const label patchId,
220  const Field<Type>& psiInternal,
221  const scalarField& coeffs,
222  const Pstream::commsTypes commsType
223  ) const
224  {
226  }
227 
228  //- Update result field based on interface functionality
229  virtual void updateInterfaceMatrix
230  (
231  Field<Type>& result,
232  const bool add,
233  const lduAddressing& lduAddr,
234  const label patchId,
235  const Field<Type>& psiInternal,
236  const scalarField& coeffs,
237  const Pstream::commsTypes commsType
238  ) const
239  {
241  }
242 
243 
244  // Processor coupled interface functions
245 
246  //- Return communicator used for communication
247  virtual label comm() const
248  {
249  return procInterface_.comm();
250  }
251 
252  //- Return processor number
253  virtual int myProcNo() const
254  {
255  return procInterface_.myProcNo();
256  }
257 
258  //- Return neighbour processor number
259  virtual int neighbProcNo() const
260  {
261  return procInterface_.myProcNo();
262  }
263 
264  //- Is the transform required
265  virtual bool doTransform() const
266  {
267  return false;
268  }
269 
270  //- Return face transformation tensor
271  virtual const tensorField& forwardT() const
272  {
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 } // End namespace Foam
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 #ifdef NoRepository
292 #endif
293 
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 
296 #endif
297 
298 // ************************************************************************* //
virtual label comm() const
Return communicator used for sending.
label patchId(-1)
virtual int myProcNo() const
Return processor number (rank in communicator)
uint8_t direction
Definition: direction.H:46
void addToInternalField(solveScalarField &result, const bool add, const scalarField &coeffs, const solveScalarField &vals) const
virtual const tensorField & forwardT() const
Return face transformation tensor.
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field of internal field.
commsTypes
Communications types.
Definition: UPstream.H:77
virtual bool doTransform() const
Is the transform required.
virtual int neighbProcNo() const
Return neighbour processor number.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:75
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1061
const lduInterface & interface() const noexcept
Return the interface.
virtual ~calculatedProcessorFvPatchField()=default
Destructor.
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
Abstract base class for processor coupled interfaces.
label sendRequest_
Current (non-blocking) send request.
Generic templated field type.
Definition: Field.H:62
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
label recvRequest_
Current (non-blocking) recv request.
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.
virtual bool all_ready() const
Receive and send requests have both completed.
virtual tmp< fvPatchField< Type > > clone() const
Return a clone.
virtual int myProcNo() const
Return processor number.
Abstract base class for coupled patches.
virtual bool ready() const
Are all (receive) data available?
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.
const lduPrimitiveProcessorInterface & procInterface_
Local reference cast into the interface.
virtual const tensorField & forwardT() const
Return face transformation tensor.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
virtual label comm() const
Return communicator used for communication.
Concrete implementation of processor interface. Used to temporarily store settings.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
calculatedProcessorFvPatchField(const lduInterface &interface, const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
solveScalarField scalarSendBuf_
Scalar send buffer.
virtual int rank() const
Return rank of component for transform.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches...
Definition: lduInterface.H:53
virtual bool coupled() const
The patch field is coupled if running in parallel.
A processorFvPatchField type bypassing fvPatch.
TypeName("calculatedProcessor")
Runtime type information.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:696
solveScalarField scalarRecvBuf_
Scalar recv buffer.
Namespace for OpenFOAM.