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  {
201  return pTraits<Type>::rank;
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;
218 
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  (
234  solveScalarField& result,
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
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
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 // ************************************************************************* //
Foam::lduAddressing
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Definition: lduAddressing.H:114
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::calculatedProcessorFvPatchField::addToInternalField
void addToInternalField(solveScalarField &result, const bool add, const scalarField &coeffs, const solveScalarField &vals) const
Definition: calculatedProcessorFvPatchField.C:282
Foam::lduPrimitiveProcessorInterface
Concrete implementation of processor interface. Used to temporarily store settings.
Definition: lduPrimitiveProcessorInterface.H:53
Foam::lduPrimitiveProcessorInterface::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: lduPrimitiveProcessorInterface.H:186
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::lduPrimitiveProcessorInterface::comm
virtual label comm() const
Return communicator used for sending.
Definition: lduPrimitiveProcessorInterface.H:168
Foam::calculatedProcessorFvPatchField::neighbProcNo
virtual int neighbProcNo() const
Return neighbour processor number.
Definition: calculatedProcessorFvPatchField.H:180
Foam::calculatedProcessorFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
Definition: calculatedProcessorFvPatchField.C:195
Foam::lduInterface
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
Definition: lduInterface.H:54
processorLduInterfaceField.H
Foam::calculatedProcessorFvPatchField::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: calculatedProcessorFvPatchField.H:192
Foam::calculatedProcessorFvPatchField::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: calculatedProcessorFvPatchField.C:310
Foam::calculatedProcessorFvPatchField::patchNeighbourField
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field of internal field.
Definition: calculatedProcessorFvPatchField.C:124
Foam::calculatedProcessorFvPatchField::scalarSendBuf_
solveScalarField scalarSendBuf_
Scalar send buffer.
Definition: calculatedProcessorFvPatchField.H:84
Foam::calculatedProcessorFvPatchField::initEvaluate
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
Definition: calculatedProcessorFvPatchField.C:141
Foam::calculatedProcessorFvPatchField::scalarReceiveBuf_
solveScalarField scalarReceiveBuf_
Scalar receive buffer.
Definition: calculatedProcessorFvPatchField.H:87
Foam::calculatedProcessorFvPatchField::ready
virtual bool ready() const
Is all data available.
Definition: calculatedProcessorFvPatchField.C:90
Foam::calculatedProcessorFvPatchField::comm
virtual label comm() const
Return communicator used for comms.
Definition: calculatedProcessorFvPatchField.H:167
Foam::calculatedProcessorFvPatchField::doTransform
virtual bool doTransform() const
Is the transform required.
Definition: calculatedProcessorFvPatchField.H:186
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::Field
Generic templated field type.
Definition: Field.H:63
calculatedProcessorFvPatchField.C
Foam::calculatedProcessorFvPatchField::TypeName
TypeName("calculatedProcessor")
Runtime type information.
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::calculatedProcessorFvPatchField::myProcNo
virtual int myProcNo() const
Return processor number.
Definition: calculatedProcessorFvPatchField.H:173
Foam::solveScalarField
Field< solveScalar > solveScalarField
Definition: primitiveFieldsFwd.H:53
Foam::calculatedProcessorFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: calculatedProcessorFvPatchField.H:130
Foam::calculatedProcessorFvPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: calculatedProcessorFvPatchField.H:210
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::calculatedProcessorFvPatchField::procInterface_
const lduPrimitiveProcessorInterface & procInterface_
Local reference cast into the interface.
Definition: calculatedProcessorFvPatchField.H:73
Foam::calculatedProcessorFvPatchField
A processorFvPatchField type bypassing fvPatch.
Definition: calculatedProcessorFvPatchField.H:63
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::calculatedProcessorFvPatchField::outstandingRecvRequest_
label outstandingRecvRequest_
Outstanding request.
Definition: calculatedProcessorFvPatchField.H:93
Foam::calculatedProcessorFvPatchField::receiveBuf_
Field< Type > receiveBuf_
Receive buffer.
Definition: calculatedProcessorFvPatchField.H:81
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::calculatedProcessorFvPatchField::~calculatedProcessorFvPatchField
virtual ~calculatedProcessorFvPatchField()=default
Destructor.
Foam::calculatedProcessorFvPatchField::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: calculatedProcessorFvPatchField.C:217
Foam::calculatedProcessorFvPatchField::calculatedProcessorFvPatchField
calculatedProcessorFvPatchField(const lduInterface &interface, const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: calculatedProcessorFvPatchField.C:34
Foam::calculatedProcessorFvPatchField::sendBuf_
Field< Type > sendBuf_
Send buffer.
Definition: calculatedProcessorFvPatchField.H:78
Foam::direction
uint8_t direction
Definition: direction.H:52
lduPrimitiveProcessorInterface.H
patchId
label patchId(-1)
Foam::lduPrimitiveProcessorInterface::myProcNo
virtual int myProcNo() const
Return processor number (rank in communicator)
Definition: lduPrimitiveProcessorInterface.H:174
coupledFvPatchField.H
Foam::calculatedProcessorFvPatchField::rank
virtual int rank() const
Return rank of component for transform.
Definition: calculatedProcessorFvPatchField.H:198
Foam::processorLduInterfaceField
Abstract base class for processor coupled interfaces.
Definition: processorLduInterfaceField.H:52
Foam::lduInterfaceField::interface
const lduInterface & interface() const
Return the interface.
Definition: lduInterfaceField.H:104
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::calculatedProcessorFvPatchField::outstandingSendRequest_
label outstandingSendRequest_
Outstanding request.
Definition: calculatedProcessorFvPatchField.H:90