Loading...
Searching...
No Matches
cyclicACMIFvPatchField.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) 2013-2016 OpenFOAM Foundation
9 Copyright (C) 2019-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::cyclicACMIFvPatchField
29
30Group
31 grpCoupledBoundaryConditions
32
33Description
34 This boundary condition enforces a cyclic condition between a pair of
35 boundaries, whereby communication between the patches is performed using
36 an arbitrarily coupled mesh interface (ACMI) interpolation.
37
38Usage
39 Example of the boundary condition specification:
40 \verbatim
41 <patchName>
42 {
43 type cyclicACMI;
44 value <initial value>;
45 neighbourValue <initial value of neighbour patch cells>;
46 }
47 \endverbatim
48
49See also
50 Foam::AMIInterpolation
51
52SourceFiles
53 cyclicACMIFvPatchField.C
54
55\*---------------------------------------------------------------------------*/
56
57#ifndef Foam_cyclicACMIFvPatchField_H
58#define Foam_cyclicACMIFvPatchField_H
59
60#include "coupledFvPatchField.H"
62#include "cyclicACMIFvPatch.H"
63
64// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65
66namespace Foam
67{
68
69/*---------------------------------------------------------------------------*\
70 Class cyclicACMIFvPatchField Declaration
71\*---------------------------------------------------------------------------*/
72
73template<class Type>
75:
76 virtual public cyclicACMILduInterfaceField,
77 public coupledFvPatchField<Type>
78{
79 // Private data
80
81 //- Local reference cast into the cyclic patch
82 const cyclicACMIFvPatch& cyclicACMIPatch_;
83
84
85 // Sending and receiving (distributed AMI)
86
87 //- Current range of send requests (non-blocking)
88 mutable labelRange sendRequests_;
89
90 //- Current range of recv requests (non-blocking)
91 mutable labelRange recvRequests_;
92
93 //- Send buffers
94 mutable PtrList<List<Type>> sendBufs_;
95
96 //- Receive buffers_
97 mutable PtrList<List<Type>> recvBufs_;
98
99 //- Scalar send buffers
100 mutable PtrList<List<solveScalar>> scalarSendBufs_;
101
102 //- Scalar receive buffers
103 mutable PtrList<List<solveScalar>> scalarRecvBufs_;
104
105
106 // Only used for AMI caching
107
108 //- Current range of send requests (non-blocking)
109 mutable labelRange sendRequests1_;
110
111 //- Current range of recv requests (non-blocking)
112 mutable labelRange recvRequests1_;
113
114 //- Send buffers
115 mutable PtrList<List<Type>> sendBufs1_;
116
117 //- Receive buffers_
118 mutable PtrList<List<Type>> recvBufs1_;
119
120 //- Scalar send buffers
121 mutable PtrList<List<solveScalar>> scalarSendBufs1_;
122
123 //- Scalar receive buffers
124 mutable PtrList<List<solveScalar>> scalarRecvBufs1_;
125
126
127 //- Neighbour coupled internal cell data
128 mutable autoPtr<Field<Type>> patchNeighbourFieldPtr_;
129
130
131 // Private Member Functions
132
133 //- Return the AMI corresponding to the owner side
134 const AMIPatchToPatchInterpolation& ownerAMI() const
135 {
136 return
137 (
138 cyclicACMIPatch_.owner()
139 ? cyclicACMIPatch_.AMI()
140 : cyclicACMIPatch_.neighbPatch().AMI()
141 );
142 }
143
144 //- All receive/send requests have completed
145 virtual bool all_ready() const;
146
147 //- Use neighbour field caching
148 static bool cacheNeighbourField();
149
150 //- Return neighbour coupled internal cell data
151 tmp<Field<Type>> getNeighbourField(const UList<Type>&) const;
152
153 //- Return neighbour coupled internal cell data (cached or extracted),
154 //- with optional check that AMI.comm() is valid.
155 tmp<Field<Type>> getPatchNeighbourField(bool checkCommunicator) const;
156
157 //- Return new matrix coeffs
158 tmp<Field<scalar>> coeffs
159 (
160 fvMatrix<Type>& matrix,
161 const Field<scalar>&,
162 const label
163 ) const;
164
165
166public:
167
168 //- Runtime type information
169 TypeName(cyclicACMIFvPatch::typeName_());
170
171
172 // Constructors
173
174 //- Construct from patch and internal field
176 (
177 const fvPatch&,
179 );
180
181 //- Construct from patch, internal field and dictionary
183 (
184 const fvPatch&,
186 const dictionary&
187 );
188
189 //- Construct by mapping given cyclicACMIFvPatchField onto a new patch
191 (
193 const fvPatch&,
195 const fvPatchFieldMapper&
196 );
197
198 //- Construct as copy
200
201 //- Construct as copy setting internal field reference
203 (
206 );
207
208 //- Return a clone
209 virtual tmp<fvPatchField<Type>> clone() const
210 {
211 return fvPatchField<Type>::Clone(*this);
212 }
213
214 //- Clone with an internal field reference
216 (
218 ) const
219 {
220 return fvPatchField<Type>::Clone(*this, iF);
221 }
222
223
224 // Member functions
225
226 // Access
227
228 //- Return local reference cast into the cyclic AMI patch
229 const cyclicACMIFvPatch& cyclicACMIPatch() const
230 {
231 return cyclicACMIPatch_;
232 }
233
234
235 // Coupling
236
237 //- Return true if coupled. Note that the underlying patch
238 // is not coupled() - the points don't align
239 virtual bool coupled() const;
240
241 //- Are all (receive) data available?
242 virtual bool ready() const;
243
244 //- Return true if this patch field fixes a value
245 // Needed to check if a level has to be specified while solving
246 // Poisson equations
247 virtual bool fixesValue() const
248 {
249 const scalarField& mask =
250 cyclicACMIPatch_.cyclicACMIPatch().mask();
251
252 if (gMax(mask) > 1e-5)
253 {
254 // regions connected
255 return false;
256 }
257 else
259 // fully separated
260 return nonOverlapPatchField().fixesValue();
261 }
262 }
263
264 //- Return neighbour coupled internal cell data
265 virtual tmp<Field<Type>> patchNeighbourField() const;
267 //- Retrieve neighbour coupled internal cell data
268 virtual void patchNeighbourField(UList<Type>& pnf) const;
269
270 //- Return reference to neighbour patchField
272
273 //- Return reference to non-overlapping patchField
275
276
277 // Evaluation
278
279 //- Initialise the evaluation of the patch field
280 virtual void initEvaluate(const Pstream::commsTypes commsType);
281
282 //- Evaluate the patch field
283 virtual void evaluate(const Pstream::commsTypes commsType);
284
285
286 // Coupled interface functionality
287
288 //- Initialise neighbour matrix update
289 virtual void initInterfaceMatrixUpdate
290 (
291 solveScalarField& result,
292 const bool add,
293 const lduAddressing& lduAddr,
294 const label patchId,
295 const solveScalarField& psiInternal,
296 const scalarField& coeffs,
297 const direction cmpt,
298 const Pstream::commsTypes commsType
299 ) const;
300
301 //- Update result field based on interface functionality
302 virtual void updateInterfaceMatrix
303 (
304 solveScalarField& result,
305 const bool add,
306 const lduAddressing& lduAddr,
307 const label patchId,
308 const solveScalarField& psiInternal,
309 const scalarField& coeffs,
310 const direction cmpt,
311 const Pstream::commsTypes commsType
312 ) const;
313
314 //- Initialise neighbour matrix update
315 virtual void initInterfaceMatrixUpdate
316 (
317 Field<Type>& result,
318 const bool add,
319 const lduAddressing& lduAddr,
320 const label patchId,
321 const Field<Type>& psiInternal,
322 const scalarField& coeffs,
323 const Pstream::commsTypes commsType
324 ) const;
325
326 //- Update result field based on interface functionality
327 virtual void updateInterfaceMatrix
328 (
330 const bool add,
331 const lduAddressing& lduAddr,
332 const label patchId,
333 const Field<Type>&,
334 const scalarField&,
335 const Pstream::commsTypes commsType
336 ) const;
337
338 //- Manipulate matrix
339 virtual void manipulateMatrix(fvMatrix<Type>& matrix);
340
341 //- Manipulate matrix
342 virtual void manipulateMatrix
343 (
345 const label iMatrix,
346 const direction cmpt
347 );
348
349 //- Update the coefficients associated with the patch field
350 virtual void updateCoeffs();
351
352
353 // Cyclic AMI coupled interface functions
354
355 //- Does the patch field perform the transformation
356 virtual bool doTransform() const
357 {
358 return
359 (
361 && !cyclicACMIPatch_.parallel()
362 );
363 }
364
365 //- Return face transformation tensor
366 virtual const tensorField& forwardT() const
367 {
368 return cyclicACMIPatch_.forwardT();
369 }
370
371 //- Return neighbour-cell transformation tensor
372 virtual const tensorField& reverseT() const
373 {
374 return cyclicACMIPatch_.reverseT();
375 }
376
377 //- Return rank of component for transform
378 virtual int rank() const
379 {
380 return pTraits<Type>::rank;
381 }
382
383
384 // I-O
385
386 //- Write
387 virtual void write(Ostream& os) const;
388};
389
390
391// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
392
393} // End namespace Foam
394
395// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
396
397#ifdef NoRepository
398 #include "cyclicACMIFvPatchField.C"
399#endif
400
401// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
402
403#endif
404
405// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
commsTypes
Communications types.
Definition UPstream.H:81
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
coupledFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
This boundary condition enforces a cyclic condition between a pair of boundaries, whereby communicati...
const cyclicACMIFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
virtual bool fixesValue() const
Return true if this patch field fixes a value.
const fvPatchField< Type > & nonOverlapPatchField() const
Return reference to non-overlapping patchField.
virtual bool doTransform() const
Does the patch field perform the transformation.
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.
virtual int rank() const
Return rank of component for transform.
const cyclicACMIFvPatch & cyclicACMIPatch() const
Return local reference cast into the cyclic AMI patch.
TypeName(cyclicACMIFvPatch::typeName_())
Runtime type information.
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 const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
cyclicACMIFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void initEvaluate(const Pstream::commsTypes commsType)
Initialise the evaluation of the patch field.
virtual bool coupled() const
Return true if coupled. Note that the underlying patch.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void manipulateMatrix(fvMatrix< Type > &matrix)
Manipulate matrix.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
virtual tmp< fvPatchField< Type > > clone() const
Return a clone.
virtual bool ready() const
Are all (receive) data available?
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
virtual tmp< fvPatchField< Type > > clone(const DimensionedField< Type, volMesh > &iF) const
Clone with an internal field reference.
virtual const tensorField & forwardT() const
Return face transformation tensor.
Cyclic patch for Arbitrarily Coupled Mesh Interface (ACMI).
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
virtual const tensorField & forwardT() const
Return face transformation tensor.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition fvMatrix.H:118
A FieldMapper for finite-volume patch fields.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
A range or interval of labels defined by a start and a size.
Definition labelRange.H:66
The class contains the addressing required by the lduMatrix: upper, lower and losort.
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
A class for managing temporary objects.
Definition tmp.H:75
OBJstream os(runTime.globalPath()/outputName)
label patchId(-1)
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
AMIInterpolation AMIPatchToPatchInterpolation
Patch-to-patch interpolation == Foam::AMIInterpolation.
Field< solveScalar > solveScalarField
uint8_t direction
Definition direction.H:49
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
constexpr bool is_rotational_vectorspace_v
The is_rotational_vectorspace value of Type.
Definition pTraits.H:251
Type gMax(const FieldField< Field, Type > &f)
runTime write()
volScalarField & e
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68