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  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  // Private 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 
98  // Private 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 public:
110 
111  //- Runtime type information
112  TypeName("calculatedProcessor");
113 
114 
115  // Constructors
116 
117  //- Construct from patch and internal field
119  (
120  const lduInterface& interface,
121  const fvPatch&,
123  );
124 
125  //- Construct as copy
127  (
129  );
130 
131  //- Construct and return a clone
132  virtual tmp<fvPatchField<Type>> clone() const
133  {
134  return tmp<fvPatchField<Type>>
135  (
137  );
138  }
139 
140  //- Construct as copy setting internal field reference
142  (
145  );
146 
147  //- Construct and return a clone setting internal field reference
149  (
151  ) const
152  {
153  return tmp<fvPatchField<Type>>
154  (
156  );
157  }
158 
159 
160  //- Destructor
161  virtual ~calculatedProcessorFvPatchField() = default;
162 
163 
164  // Member functions
165 
166  // processorLduInterfaceField implementation
167 
168  //- Return communicator used for comms
169  virtual label comm() const
170  {
171  return procInterface_.comm();
172  }
173 
174  //- Return processor number
175  virtual int myProcNo() const
176  {
177  return procInterface_.myProcNo();
178  }
179 
180 
181  //- Return neighbour processor number
182  virtual int neighbProcNo() const
183  {
184  return procInterface_.myProcNo();
185  }
186 
187  //- Is the transform required
188  virtual bool doTransform() const
189  {
190  return false;
191  }
192 
193  //- Return face transformation tensor
194  virtual const tensorField& forwardT() const
195  {
196  return procInterface_.forwardT();
197  }
198 
199  //- Return rank of component for transform
200  virtual int rank() const
201  {
202  return pTraits<Type>::rank;
203  }
204 
205 
206  // Access
207 
208  //- Return true if this patch field is coupled.
209  // Our field supplies coefficients to the fvMatrix so
210  // should behave as a processorFvPatchField (in
211  // addBoundarySource it should not add to the source)
212  virtual bool coupled() const
213  {
214  return Pstream::parRun();
215  }
216 
217  //- Return neighbour field of internal field
218  virtual tmp<Field<Type>> patchNeighbourField() const;
219 
220 
221  // Evaluation functions
222 
223  //- Is all data available
224  virtual bool ready() const;
225 
226  //- Initialise the evaluation of the patch field
227  virtual void initEvaluate(const Pstream::commsTypes commsType);
228 
229  //- Evaluate the patch field
230  virtual void evaluate(const Pstream::commsTypes commsType);
231 
232  //- Initialise neighbour matrix update
233  virtual void initInterfaceMatrixUpdate
234  (
235  solveScalarField& result,
236  const bool add,
237  const solveScalarField& psiInternal,
238  const scalarField& coeffs,
239  const direction cmpt,
240  const Pstream::commsTypes commsType
241  ) const;
242 
243  //- Update result field based on interface functionality
244  virtual void updateInterfaceMatrix
245  (
246  solveScalarField& result,
247  const bool add,
248  const solveScalarField& psiInternal,
249  const scalarField& coeffs,
250  const direction cmpt,
251  const Pstream::commsTypes commsType
252  ) const;
253 
254  //- Initialise neighbour matrix update
256  (
257  Field<Type>& result,
258  const bool add,
259  const Field<Type>& psiInternal,
260  const scalarField& coeffs,
261  const Pstream::commsTypes commsType
262  ) const
263  {
265  }
266 
267  //- Update result field based on interface functionality
269  (
270  Field<Type>& result,
271  const bool add,
272  const Field<Type>& psiInternal,
273  const scalarField& coeffs,
274  const Pstream::commsTypes commsType
275  ) const
276  {
278  }
279 
280  //- Write
281  //virtual void write(Ostream&) const;
282 };
283 
284 
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 
287 } // End namespace Foam
288 
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 
291 #ifdef NoRepository
293 #endif
294 
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 
297 #endif
298 
299 // ************************************************************************* //
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:275
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:170
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:152
Foam::calculatedProcessorFvPatchField::neighbProcNo
virtual int neighbProcNo() const
Return neighbour processor number.
Definition: calculatedProcessorFvPatchField.H:181
Foam::calculatedProcessorFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
Definition: calculatedProcessorFvPatchField.C:195
Foam::calculatedProcessorFvPatchField::initInterfaceMatrixUpdate
virtual void initInterfaceMatrixUpdate(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Initialise neighbour matrix update.
Definition: calculatedProcessorFvPatchField.C:217
Foam::lduInterface
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
Definition: lduInterface.H:54
Foam::UPstream::parRun
static bool & parRun()
Test if this a parallel run, or allow modify access.
Definition: UPstream.H:434
processorLduInterfaceField.H
Foam::calculatedProcessorFvPatchField::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: calculatedProcessorFvPatchField.H:193
Foam::calculatedProcessorFvPatchField::patchNeighbourField
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour field of internal field.
Definition: calculatedProcessorFvPatchField.C:131
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:148
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:93
Foam::calculatedProcessorFvPatchField::comm
virtual label comm() const
Return communicator used for comms.
Definition: calculatedProcessorFvPatchField.H:168
Foam::calculatedProcessorFvPatchField::doTransform
virtual bool doTransform() const
Is the transform required.
Definition: calculatedProcessorFvPatchField.H:187
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:445
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::updateInterfaceMatrix
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
Definition: calculatedProcessorFvPatchField.C:303
Foam::calculatedProcessorFvPatchField::myProcNo
virtual int myProcNo() const
Return processor number.
Definition: calculatedProcessorFvPatchField.H:174
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:131
Foam::calculatedProcessorFvPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: calculatedProcessorFvPatchField.H:211
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
processorFvPatchField type bypassing fvPatch
Definition: calculatedProcessorFvPatchField.H:63
Foam::calculatedProcessorFvPatchField::outstandingRecvRequest_
label outstandingRecvRequest_
Outstanding request.
Definition: calculatedProcessorFvPatchField.H:93
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
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::pTraits
Traits class for primitives.
Definition: pTraits.H:54
Foam::calculatedProcessorFvPatchField::~calculatedProcessorFvPatchField
virtual ~calculatedProcessorFvPatchField()=default
Destructor.
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
Foam::lduPrimitiveProcessorInterface::myProcNo
virtual int myProcNo() const
Return processor number (rank in communicator)
Definition: lduPrimitiveProcessorInterface.H:158
coupledFvPatchField.H
Foam::calculatedProcessorFvPatchField::rank
virtual int rank() const
Return rank of component for transform.
Definition: calculatedProcessorFvPatchField.H:199
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