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 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 calculatedProcessorFvPatchField_H
48 #define 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  // Sending and receiving
77 
78  //- Send buffer
79  mutable Field<Type> sendBuf_;
80 
81  //- Receive buffer
82  mutable Field<Type> receiveBuf_;
83 
84  //- Scalar send buffer
86 
87  //- Scalar receive buffer
89 
90  //- Outstanding request
91  mutable label outstandingSendRequest_;
92 
93  //- Outstanding request
94  mutable label outstandingRecvRequest_;
95 
96 
97  // Protected Member Functions
98 
100  (
101  solveScalarField& result,
102  const bool add,
103  const scalarField& coeffs,
104  const solveScalarField& vals
105  ) const;
106 
107 
108 public:
109 
110  //- Runtime type information
111  TypeName("calculatedProcessor");
112 
113 
114  // Constructors
115 
116  //- Construct from patch and internal field
118  (
119  const lduInterface& interface,
120  const fvPatch&,
122  );
123 
124  //- Construct as copy
126  (
128  );
129 
130  //- Construct and return a clone
131  virtual tmp<fvPatchField<Type>> clone() const
132  {
133  return tmp<fvPatchField<Type>>
134  (
136  );
137  }
138 
139  //- Construct as copy setting internal field reference
141  (
144  );
145 
146  //- Construct and return a clone setting internal field reference
148  (
150  ) const
151  {
152  return tmp<fvPatchField<Type>>
153  (
155  );
156  }
157 
158 
159  //- Destructor
160  virtual ~calculatedProcessorFvPatchField() = default;
161 
162 
163  // Member functions
164 
165  // processorLduInterfaceField implementation
166 
167  //- Return communicator used for comms
168  virtual label comm() const
169  {
170  return procInterface_.comm();
171  }
172 
173  //- Return processor number
174  virtual int myProcNo() const
175  {
176  return procInterface_.myProcNo();
177  }
178 
179 
180  //- Return neighbour processor number
181  virtual int neighbProcNo() const
182  {
183  return procInterface_.myProcNo();
184  }
185 
186  //- Is the transform required
187  virtual bool doTransform() const
188  {
189  return false;
190  }
191 
192  //- Return face transformation tensor
193  virtual const tensorField& forwardT() const
194  {
195  return procInterface_.forwardT();
196  }
197 
198  //- Return rank of component for transform
199  virtual int rank() const
200  {
202  }
203 
204 
205  // Access
206 
207  //- Return true if this patch field is coupled.
208  // Our field supplies coefficients to the fvMatrix so
209  // should behave as a processorFvPatchField (in
210  // addBoundarySource it should not add to the source)
211  virtual bool coupled() const
212  {
213  return Pstream::parRun();
214  }
215 
216  //- Return neighbour field of internal field
217  virtual tmp<Field<Type>> patchNeighbourField() const;
219 
220  // Evaluation functions
221 
222  //- Is all data available
223  virtual bool ready() const;
224 
225  //- Initialise the evaluation of the patch field
226  virtual void initEvaluate(const Pstream::commsTypes commsType);
227 
228  //- Evaluate the patch field
229  virtual void evaluate(const Pstream::commsTypes commsType);
230 
231  //- Initialise neighbour matrix update
232  virtual void initInterfaceMatrixUpdate
233  (
235  const bool add,
236  const lduAddressing& lduAddr,
237  const label patchId,
238  const solveScalarField& psiInternal,
239  const scalarField& coeffs,
240  const direction cmpt,
241  const Pstream::commsTypes commsType
242  ) const;
243 
244  //- Update result field based on interface functionality
245  virtual void updateInterfaceMatrix
246  (
247  solveScalarField& result,
248  const bool add,
249  const lduAddressing& lduAddr,
250  const label patchId,
251  const solveScalarField& psiInternal,
252  const scalarField& coeffs,
253  const direction cmpt,
254  const Pstream::commsTypes commsType
255  ) const;
256 
257  //- Initialise neighbour matrix update
258  virtual void initInterfaceMatrixUpdate
259  (
260  Field<Type>& result,
261  const bool add,
262  const lduAddressing& lduAddr,
263  const label patchId,
264  const Field<Type>& psiInternal,
265  const scalarField& coeffs,
266  const Pstream::commsTypes commsType
267  ) const
268  {
270  }
271 
272  //- Update result field based on interface functionality
273  virtual void updateInterfaceMatrix
274  (
275  Field<Type>& result,
276  const bool add,
277  const lduAddressing& lduAddr,
278  const label patchId,
279  const Field<Type>& psiInternal,
280  const scalarField& coeffs,
281  const Pstream::commsTypes commsType
282  ) const
283  {
285  }
286 
287  //- Write
288  // virtual void write(Ostream& os) const;
289 };
290 
291 
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 
294 } // End namespace Foam
295 
296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297 
298 #ifdef NoRepository
300 #endif
301 
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 
304 #endif
305 
306 // ************************************************************************* //
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
Types of communications.
Definition: UPstream.H:66
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:68
A traits class, which is primarily used for primitives.
Definition: pTraits.H:50
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:639
solveScalarField scalarReceiveBuf_
Scalar receive buffer.
virtual ~calculatedProcessorFvPatchField()=default
Destructor.
Abstract base class for processor coupled interfaces.
const lduInterface & interface() const
Return the interface.
Generic templated field type.
Definition: Field.H:61
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
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 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
Is all 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 comms.
Concrete implementation of processor interface. Used to temporarily store settings.
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
Return true if this patch field is coupled.
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:666
Namespace for OpenFOAM.