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
174 
175  //- Retrieve neighbour field
176  virtual void patchNeighbourField(UList<Type>& result) const;
177 
178 
179  // Evaluation
180 
181  //- Initialise the evaluation of the patch field
182  virtual void initEvaluate(const Pstream::commsTypes commsType);
183 
184  //- Evaluate the patch field
185  virtual void evaluate(const Pstream::commsTypes commsType);
186 
187 
188  // Coupled interface functionality
189 
190  //- Initialise neighbour matrix update
191  virtual void initInterfaceMatrixUpdate
192  (
193  solveScalarField& result,
194  const bool add,
195  const lduAddressing& lduAddr,
196  const label patchId,
197  const solveScalarField& psiInternal,
198  const scalarField& coeffs,
199  const direction cmpt,
200  const Pstream::commsTypes commsType
201  ) const;
202 
203  //- Update result field based on interface functionality
204  virtual void updateInterfaceMatrix
205  (
206  solveScalarField& result,
207  const bool add,
208  const lduAddressing& lduAddr,
209  const label patchId,
210  const solveScalarField& psiInternal,
211  const scalarField& coeffs,
212  const direction cmpt,
213  const Pstream::commsTypes commsType
214  ) const;
215 
216  //- Initialise neighbour matrix update
217  virtual void initInterfaceMatrixUpdate
218  (
219  Field<Type>& result,
220  const bool add,
221  const lduAddressing& lduAddr,
222  const label patchId,
223  const Field<Type>& psiInternal,
224  const scalarField& coeffs,
225  const Pstream::commsTypes commsType
226  ) const
227  {
229  }
230 
231  //- Update result field based on interface functionality
232  virtual void updateInterfaceMatrix
233  (
234  Field<Type>& result,
235  const bool add,
236  const lduAddressing& lduAddr,
237  const label patchId,
238  const Field<Type>& psiInternal,
239  const scalarField& coeffs,
240  const Pstream::commsTypes commsType
241  ) const
242  {
244  }
245 
246 
247  // Processor coupled interface functions
248 
249  //- Return communicator used for communication
250  virtual label comm() const
251  {
252  return procInterface_.comm();
253  }
254 
255  //- Return processor number
256  virtual int myProcNo() const
257  {
258  return procInterface_.myProcNo();
259  }
260 
261  //- Return neighbour processor number
262  virtual int neighbProcNo() const
263  {
264  return procInterface_.myProcNo();
265  }
266 
267  //- Is the transform required
268  virtual bool doTransform() const
269  {
270  return false;
271  }
272 
273  //- Return face transformation tensor
274  virtual const tensorField& forwardT() const
275  {
276  return procInterface_.forwardT();
277  }
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 } // End namespace Foam
290 
291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 
293 #ifdef NoRepository
295 #endif
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 #endif
300 
301 // ************************************************************************* //
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.
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:61
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1586
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:607
Abstract base class for processor coupled interfaces.
label sendRequest_
Current (non-blocking) send request.
Generic templated field type.
Definition: Field.H:63
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:688
solveScalarField scalarRecvBuf_
Scalar recv buffer.
Namespace for OpenFOAM.