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 and return a clone
136  virtual tmp<fvPatchField<Type>> clone() const
137  {
138  return tmp<fvPatchField<Type>>
139  (
141  );
142  }
143 
144  //- Construct as copy setting internal field reference
146  (
149  );
150 
151  //- Construct and return a clone setting internal field reference
153  (
155  ) const
156  {
157  return tmp<fvPatchField<Type>>
158  (
160  );
161  }
162 
163 
164  //- Destructor
165  virtual ~calculatedProcessorFvPatchField() = default;
166 
167 
168  // Member Functions
169 
170  // Coupling
171 
172  //- The patch field is coupled if running in parallel
173  virtual bool coupled() const { return UPstream::parRun(); }
174 
175  //- Are all (receive) data available?
176  virtual bool ready() const;
177 
178  //- Return neighbour field of internal field
179  virtual tmp<Field<Type>> patchNeighbourField() const;
180 
181 
182  // Evaluation
183 
184  //- Initialise the evaluation of the patch field
185  virtual void initEvaluate(const Pstream::commsTypes commsType);
186 
187  //- Evaluate the patch field
188  virtual void evaluate(const Pstream::commsTypes commsType);
189 
190 
191  // Coupled interface functionality
192 
193  //- Initialise neighbour matrix update
194  virtual void initInterfaceMatrixUpdate
195  (
196  solveScalarField& result,
197  const bool add,
198  const lduAddressing& lduAddr,
199  const label patchId,
200  const solveScalarField& psiInternal,
201  const scalarField& coeffs,
202  const direction cmpt,
203  const Pstream::commsTypes commsType
204  ) const;
205 
206  //- Update result field based on interface functionality
207  virtual void updateInterfaceMatrix
208  (
209  solveScalarField& result,
210  const bool add,
211  const lduAddressing& lduAddr,
212  const label patchId,
213  const solveScalarField& psiInternal,
214  const scalarField& coeffs,
215  const direction cmpt,
216  const Pstream::commsTypes commsType
217  ) const;
218 
219  //- Initialise neighbour matrix update
220  virtual void initInterfaceMatrixUpdate
221  (
222  Field<Type>& result,
223  const bool add,
224  const lduAddressing& lduAddr,
225  const label patchId,
226  const Field<Type>& psiInternal,
227  const scalarField& coeffs,
228  const Pstream::commsTypes commsType
229  ) const
230  {
232  }
233 
234  //- Update result field based on interface functionality
235  virtual void updateInterfaceMatrix
236  (
237  Field<Type>& result,
238  const bool add,
239  const lduAddressing& lduAddr,
240  const label patchId,
241  const Field<Type>& psiInternal,
242  const scalarField& coeffs,
243  const Pstream::commsTypes commsType
244  ) const
245  {
247  }
248 
249 
250  // Processor coupled interface functions
251 
252  //- Return communicator used for communication
253  virtual label comm() const
254  {
255  return procInterface_.comm();
256  }
257 
258  //- Return processor number
259  virtual int myProcNo() const
260  {
261  return procInterface_.myProcNo();
262  }
263 
264  //- Return neighbour processor number
265  virtual int neighbProcNo() const
266  {
267  return procInterface_.myProcNo();
268  }
269 
270  //- Is the transform required
271  virtual bool doTransform() const
272  {
273  return false;
274  }
275 
276  //- Return face transformation tensor
277  virtual const tensorField& forwardT() const
278  {
280  }
281 
282  //- Return rank of component for transform
283  virtual int rank() const
284  {
285  return pTraits<Type>::rank;
286  }
287 };
288 
289 
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 
292 } // End namespace Foam
293 
294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 
296 #ifdef NoRepository
298 #endif
299 
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 
302 #endif
303 
304 // ************************************************************************* //
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:72
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:1049
const lduInterface & interface() const noexcept
Return the interface.
virtual ~calculatedProcessorFvPatchField()=default
Destructor.
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
Construct and 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...
Definition: areaFieldsFwd.H:42
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:686
solveScalarField scalarRecvBuf_
Scalar recv buffer.
Namespace for OpenFOAM.