Loading...
Searching...
No Matches
faPatch.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) 2016-2017 Wikki Ltd
9 Copyright (C) 2020-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::faPatch
29
30Description
31 Finite area patch class. Used for 2-D non-Euclidian finite area method.
32
33Author
34 Zeljko Tukovic, FMENA
35 Hrvoje Jasak, Wikki Ltd.
36
37SourceFiles
38 faPatch.C
39 faPatchNew.C
40 faPatchTemplates.C
41 faPatchFaMeshTemplates.C
42
43\*---------------------------------------------------------------------------*/
44
45#ifndef Foam_faPatch_H
46#define Foam_faPatch_H
47
48#include "patchIdentifier.H"
49#include "labelList.H"
50#include "pointField.H"
51#include "typeInfo.H"
52#include "PtrList.H"
53#include "faPatchFieldsFwd.H"
54#include "autoPtr.H"
56
57// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58
59namespace Foam
60{
61
62// Forward Declarations
63class faBoundaryMesh;
64class faPatch;
65
66//- Store lists of faPatch as a PtrList
68
70
71/*---------------------------------------------------------------------------*\
72 Class faPatch Declaration
73\*---------------------------------------------------------------------------*/
74
75class faPatch
76:
77 public patchIdentifier,
78 public labelList
79{
80 // Private Data
81
82 //- Neighbour polyPatch index
83 const label nbrPolyPatchId_;
84
85 //- Reference to boundary mesh
86 const faBoundaryMesh& boundaryMesh_;
87
88 //- Demand-driven: edge-face addressing
89 mutable std::unique_ptr<labelList::subList> edgeFacesPtr_;
90
91 //- Demand-driven: local points labels
92 mutable std::unique_ptr<labelList> pointLabelsPtr_;
93
94 //- Demand-driven: point-edge addressing
95 mutable std::unique_ptr<labelListList> pointEdgesPtr_;
96
97
98 // Private Member Functions
99
100 //- No copy construct
101 faPatch(const faPatch&) = delete;
102
103 //- No copy assignment
104 void operator=(const faPatch&) = delete;
105
106 //- Clear out topological patch data
107 void clearOut();
108
109
110protected:
111
112 // Protected Member Functions
113
114 //- The faPatch geometry initialisation is called by faBoundaryMesh
115 friend class faBoundaryMesh;
116
117 //- Calculate patch point labels
118 void calcPointLabels() const;
119
120 //- Calculate patch point-edge addressing
121 void calcPointEdges() const;
122
123 //- Initialise the calculation of the patch geometry
124 virtual void initGeometry(PstreamBuffers&)
125 {}
126
127 //- Calculate the patch geometry
128 virtual void calcGeometry(PstreamBuffers&)
129 {}
131 //- Initialise the patches for moving points
132 virtual void initMovePoints(PstreamBuffers&, const pointField&)
133 {}
134
135 //- Correct patch after moving points
136 virtual void movePoints(PstreamBuffers&, const pointField&);
137
138 //- Initialise the update of the patch topology
139 virtual void initUpdateMesh(PstreamBuffers&)
140 {}
141
142 //- Update of the patch topology
143 virtual void updateMesh(PstreamBuffers&)
144 {}
146
147public:
148
149 //- The boundary type associated with the patch
152
153 //- Runtime type information
154 TypeName("patch");
155
156 // Declare run-time constructor selection tables
159 (
160 autoPtr,
161 faPatch,
163 (
164 const word& name,
165 const dictionary& dict,
166 const label index,
167 const faBoundaryMesh& bm,
168 const word& patchType
169 ),
170 (name, dict, index, bm, patchType)
171 );
172
173
174 // Constructors
175
176 //- Construct from components
177 faPatch
178 (
179 const word& name,
180 const labelUList& edgeLabels,
181 const label index,
182 const faBoundaryMesh& bm,
183 const label nbrPolyPatchi,
184 const word& patchType
185 );
186
187 //- Construct from dictionary
188 faPatch
190 const word& name,
191 const dictionary& dict,
192 const label index,
193 const faBoundaryMesh& bm,
194 const word& patchType
195 );
196
197 //- Copy construct, resetting the boundary mesh
198 faPatch(const faPatch& p, const faBoundaryMesh& bm);
199
200 //- Copy construct, resetting boundary mesh and addressing
201 faPatch
202 (
203 const faPatch& p,
204 const faBoundaryMesh& bm,
205 const label index,
206 const labelUList& edgeLabels,
207 const label nbrPolyPatchi
208 );
209
210
211 //- Construct and return a clone, resetting the boundary mesh
212 virtual autoPtr<faPatch> clone(const faBoundaryMesh& bm) const
213 {
214 return autoPtr<faPatch>::New(*this, bm);
215 }
216
217 //- Construct and return a clone, resetting the edge list
218 //- and boundary mesh
219 virtual autoPtr<faPatch> clone
220 (
221 const faBoundaryMesh& bm,
222 const labelUList& edgeLabels,
223 const label index,
224 const label nbrPolyPatchi
225 ) const
226 {
228 (
229 *this,
230 bm,
231 index,
233 nbrPolyPatchi
234 );
235 }
236
237
238 // Selectors
239
240 //- Return pointer to a new patch created on freestore from dictionary
241 static autoPtr<faPatch> New
242 (
243 const word& name,
244 const dictionary& dict,
245 const label index,
246 const faBoundaryMesh& bm
247 );
248
249 //- Return pointer to a new patch created on freestore from dictionary
250 static autoPtr<faPatch> New
251 (
252 const word& patchType,
253 const word& name,
254 const dictionary& dict,
255 const label index,
256 const faBoundaryMesh& bm
257 );
258
259
260 //- Destructor
261 virtual ~faPatch();
262
263
264 // Static Member Functions
265
266 //- Return true if the given type is a constraint type
267 static bool constraintType(const word& patchType);
268
269 //- Return a list of all the constraint patch types
270 static wordList constraintTypes();
271
272
273 // Member Functions
274
275 //- Return the list of edges
276 const labelList& edgeLabels() const noexcept
277 {
278 return static_cast<const labelList&>(*this);
279 }
280
281 //- Number of patch points
282 label nPoints() const
283 {
284 return pointLabels().size();
285 }
286
287 //- Number of edge labels (boundary edges) addressed by this patch
288 label nEdges() const noexcept
289 {
290 return labelList::size();
291 }
292
293 //- The neighbour polyPatch index
294 label ngbPolyPatchIndex() const noexcept
295 {
296 return nbrPolyPatchId_;
297 }
298
299 //- Return boundaryMesh reference
300 const faBoundaryMesh& boundaryMesh() const noexcept;
301
302 //- Return true if this patch is coupled
303 virtual bool coupled() const
304 {
305 return false;
306 }
307
308 //- The offset where this patch starts in the boundary edge list.
309 // The value is the same as patch.start() - mesh.nInternalEdges()
310 label offset() const;
311
312 //- Patch start in edge list
313 label start() const;
314
315 //- Patch size is the number of edge labels, but can be overloaded
316 virtual label size() const
317 {
318 return labelList::size();
319 }
320
321 //- Return label of edge in patch from global edge label
322 label whichEdge(const label edgei) const
323 {
324 return edgei - start();
325 }
326
327 //- This patch slice from the complete list of values, which has
328 //- size mesh::nEdges(), using the virtual patch size.
329 template<class T>
330 const typename List<T>::subList
331 patchSlice(const UList<T>& values) const
332 {
333 return typename List<T>::subList(values, size(), start());
334 }
336 //- This patch slice from the list of boundary values, which has
337 //- size mesh::nBoundaryEdges(), using the virtual patch size.
338 template<class T>
339 const typename List<T>::subList
340 boundarySlice(const UList<T>& values) const
341 {
342 return typename List<T>::subList(values, size(), offset());
344
345
346 //- Write
347 virtual void write(Ostream&) const;
348
349
350 // Topological information
352 //- List of proc/face for the boundary edge neighbours
353 //- in locally reordered edge numbering.
354 List<labelPair> boundaryConnections() const;
355
356 //- Boundary edge neighbour processors
357 //- (does not include own proc)
358 labelList boundaryProcs() const;
360 //- List of proc/size for the boundary edge neighbour processors
361 //- (does not include own proc)
362 List<labelPair> boundaryProcSizes() const;
363
364
365 // Access functions for geometrical data
366
367 //- Return patch point labels
368 const labelList& pointLabels() const;
369
370 //- Return patch point-edge addressing
371 const labelListList& pointEdges() const;
373 //- Return normals of neighbour polyPatch faces
374 // Same as faMesh::haloFaceNormals()
376
377 //- Return normals of neighbour polyPatch joined points
379
380 //- Return edge-face addressing
381 const labelUList& edgeFaces() const;
382
383 //- Return edge centres
384 const vectorField& edgeCentres() const;
385
386 //- Return edge length vectors, like the faMesh::Le() method
387 const vectorField& edgeLengths() const;
388
389 //- Return edge length magnitudes, like the faMesh::magLe() method
390 const scalarField& magEdgeLengths() const;
391
392 //- Return edge unit normals, like the faMesh::unitLe() method
394
395 //- Return neighbour face centres
397
398 //- Return cell-centre to face-centre vector
399 // except for coupled patches for which the cell-centre
400 // to coupled-cell-centre vector is returned
401 virtual tmp<vectorField> delta() const;
402
403
404 // Access functions for demand driven data
405
406 //- Make patch weighting factors
407 virtual void makeWeights(scalarField&) const;
408
409 //- Return patch weighting factors
410 const scalarField& weights() const;
412 //- Make patch geodesic distance between P and N
413 virtual void makeLPN(scalarField&) const;
414
415 //- Return patch geodesic distance between P and N
416 const scalarField& lPN() const;
417
418 //- Make patch edge - neighbour face distances
419 virtual void makeDeltaCoeffs(scalarField&) const;
420
421 //- Return patch edge - neighbour face distances
422 const scalarField& deltaCoeffs() const;
423
424 //- Make non-orthogonality correction vectors
425 virtual void makeCorrectionVectors(vectorField&) const;
426
427 //- Return patch skew-correction vectors
428 const vectorField& skewCorrectionVectors() const;
429
430
431 // Topological changes
432
433 //- Reset the list of edges (use with caution)
434 void resetEdges(const labelUList& newEdges);
435
436 //- Reset the list of edges (use with caution)
437 void resetEdges(labelList&& newEdges);
438
439
440 // Evaluation
441
442 //- Extract internal field next to patch using specified addressing
443 // \param internalData The internal field to extract from
444 // \param addressing Addressing from patch into internal field
445 // \param [out] pfld The extracted patch field.
446 // Should normally be sized according to the patch size(),
447 // which can be smaller than the addressing size
448 template<class Type>
449 inline void patchInternalField
450 (
451 const UList<Type>& internalData,
452 const labelUList& addressing,
453 UList<Type>& pfld
454 ) const;
455
456 //- Extract internal field next to patch as patch field
457 //- using edgeFaces() mapping.
458 // \param internalData The internal field to extract from
459 // \param [out] pfld The extracted patch field.
460 // Should normally be sized according to the patch size(),
461 // which can be smaller than the edgeFaces() size
462 template<class Type>
464 (
465 const UList<Type>& internalData,
466 UList<Type>& pfld
467 ) const;
468
469 //- Return given internal field next to patch as patch field
470 //- using edgeFaces() mapping.
471 // \param internalData The internal field to extract from
472 template<class Type>
473 [[nodiscard]] tmp<Field<Type>>
475 (
476 const UList<Type>& internalData
477 ) const;
478
479
480 // Lookup
481
482 //- Return the patch field of the GeometricField
483 //- corresponding to this patch.
484 template<class GeometricField, class AnyType = bool>
485 const typename GeometricField::Patch&
486 patchField(const GeometricField& gf) const;
487
488 //- Lookup the named field from the local registry and
489 //- return the patch field corresponding to this patch.
490 template<class GeometricField, class AnyType = bool>
491 const typename GeometricField::Patch&
492 lookupPatchField(const word& fldName) const;
493
494 //- Lookup the named field (if any) from the local registry and
495 //- return the patch field corresponding to this patch.
496 template<class GeometricField>
497 const typename GeometricField::Patch*
498 cfindPatchField(const word& fldName) const;
499
500
501 // Ostream Operator
502
503 friend Ostream& operator<<(Ostream&, const faPatch&);
504};
505
506
507// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
508
509} // End namespace Foam
510
511// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
512
513#ifdef NoRepository
514 #include "faPatchTemplates.C"
515#endif
516
517// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
518
519#endif
520
521// ************************************************************************* //
Generic GeometricField class.
PatchField< Type > Patch
The patch field type for the GeometricBoundaryField.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
SubList< T > subList
Declare type of subList.
Definition List.H:129
autoPtr< List< label > > clone() const
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Buffers for inter-processor communications streams (UOPstream, UIPstream).
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
UList(const UList< label > &) noexcept=default
label size() const noexcept
Definition UList.H:706
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Finite area boundary mesh, which is a faPatch list with registered IO, a reference to the associated ...
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition faPatch.H:76
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition faPatch.C:54
virtual label size() const
Patch size is the number of edge labels, but can be overloaded.
Definition faPatch.H:392
faBoundaryMesh BoundaryMesh
The boundary type associated with the patch.
Definition faPatch.H:183
label nPoints() const
Number of patch points.
Definition faPatch.H:343
label offset() const
The offset where this patch starts in the boundary edge list.
Definition faPatch.C:180
const labelListList & pointEdges() const
Return patch point-edge addressing.
Definition faPatch.C:278
tmp< vectorField > ngbPolyPatchPointNormals() const
Return normals of neighbour polyPatch joined points.
Definition faPatch.C:389
TypeName("patch")
Runtime type information.
const GeometricField::Patch * cfindPatchField(const word &fldName) const
Lookup the named field (if any) from the local registry and return the patch field corresponding to t...
const labelList & pointLabels() const
Return patch point labels.
Definition faPatch.C:267
declareRunTimeSelectionTable(autoPtr, faPatch, dictionary,(const word &name, const dictionary &dict, const label index, const faBoundaryMesh &bm, const word &patchType),(name, dict, index, bm, patchType))
virtual ~faPatch()
Destructor.
Definition faPatch.C:166
void resetEdges(const labelUList &newEdges)
Reset the list of edges (use with caution).
Definition faPatch.C:551
virtual bool coupled() const
Return true if this patch is coupled.
Definition faPatch.H:372
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition faPatch.C:535
friend Ostream & operator<<(Ostream &, const faPatch &)
virtual void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition faPatch.H:145
virtual void makeLPN(scalarField &) const
Make patch geodesic distance between P and N.
Definition faPatch.C:496
virtual autoPtr< faPatch > clone(const faBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition faPatch.H:257
const labelList & edgeLabels() const noexcept
Return the list of edges.
Definition faPatch.H:335
virtual void makeDeltaCoeffs(scalarField &) const
Make patch edge - neighbour face distances.
Definition faPatch.C:508
List< labelPair > boundaryConnections() const
List of proc/face for the boundary edge neighbours in locally reordered edge numbering.
Definition faPatch.C:197
const scalarField & magEdgeLengths() const
Return edge length magnitudes, like the faMesh::magLe() method.
Definition faPatch.C:450
const scalarField & lPN() const
Return patch geodesic distance between P and N.
Definition faPatch.C:502
label ngbPolyPatchIndex() const noexcept
The neighbour polyPatch index.
Definition faPatch.H:359
tmp< vectorField > ngbPolyPatchFaceNormals() const
Return normals of neighbour polyPatch faces.
Definition faPatch.C:378
static autoPtr< faPatch > New(const word &name, const dictionary &dict, const label index, const faBoundaryMesh &bm)
Return pointer to a new patch created on freestore from dictionary.
Definition faPatchNew.C:28
friend class faBoundaryMesh
The faPatch geometry initialisation is called by faBoundaryMesh.
Definition faPatch.H:130
const GeometricField::Patch & patchField(const GeometricField &gf) const
Return the patch field of the GeometricField corresponding to this patch.
virtual autoPtr< faPatch > clone(const faBoundaryMesh &bm, const labelUList &edgeLabels, const label index, const label nbrPolyPatchi) const
Construct and return a clone, resetting the edge list and boundary mesh.
Definition faPatch.H:267
const vectorField & skewCorrectionVectors() const
Return patch skew-correction vectors.
Definition faPatch.C:528
const vectorField & edgeLengths() const
Return edge length vectors, like the faMesh::Le() method.
Definition faPatch.C:444
label whichEdge(const label edgei) const
Return label of edge in patch from global edge label.
Definition faPatch.H:400
virtual tmp< vectorField > delta() const
Return cell-centre to face-centre vector.
Definition faPatch.C:472
label nEdges() const noexcept
Number of edge labels (boundary edges) addressed by this patch.
Definition faPatch.H:351
tmp< vectorField > edgeFaceCentres() const
Return neighbour face centres.
Definition faPatch.C:466
void calcPointEdges() const
Calculate patch point-edge addressing.
Definition faPatch.C:347
const faBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
Definition faPatch.C:174
const scalarField & weights() const
Return patch weighting factors.
Definition faPatch.C:541
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition faPatch.H:168
const labelUList & edgeFaces() const
Return edge-face addressing.
Definition faPatch.C:424
virtual void movePoints(PstreamBuffers &, const pointField &)
Correct patch after moving points.
Definition faPatch.C:547
const vectorField & edgeCentres() const
Return edge centres.
Definition faPatch.C:438
labelList boundaryProcs() const
Boundary edge neighbour processors (does not include own proc).
Definition faPatch.C:217
const List< T >::subList patchSlice(const UList< T > &values) const
This patch slice from the complete list of values, which has size mesh::nEdges(), using the virtual p...
Definition faPatch.H:411
tmp< vectorField > edgeNormals() const
Return edge unit normals, like the faMesh::unitLe() method.
Definition faPatch.C:456
void calcPointLabels() const
Calculate patch point labels.
Definition faPatch.C:289
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition faPatch.H:151
List< labelPair > boundaryProcSizes() const
List of proc/size for the boundary edge neighbour processors (does not include own proc).
Definition faPatch.C:237
void patchInternalField(const UList< Type > &internalData, const labelUList &addressing, UList< Type > &pfld) const
Extract internal field next to patch using specified addressing.
const List< T >::subList boundarySlice(const UList< T > &values) const
This patch slice from the list of boundary values, which has size mesh::nBoundaryEdges(),...
Definition faPatch.H:422
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition faPatch.H:174
const scalarField & deltaCoeffs() const
Return patch edge - neighbour face distances.
Definition faPatch.C:514
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition faPatch.H:157
virtual void makeCorrectionVectors(vectorField &) const
Make non-orthogonality correction vectors.
Definition faPatch.C:520
static bool constraintType(const word &patchType)
Return true if the given type is a constraint type.
Definition faPatch.C:45
tmp< Field< Type > > patchInternalField(const UList< Type > &internalData) const
Return given internal field next to patch as patch field using edgeFaces() mapping.
const GeometricField::Patch & lookupPatchField(const word &fldName) const
Lookup the named field from the local registry and return the patch field corresponding to this patch...
label start() const
Patch start in edge list.
Definition faPatch.C:191
label index() const noexcept
The index of this patch in the boundaryMesh.
const word & name() const noexcept
The patch name.
patchIdentifier(const patchIdentifier &)=default
Copy construct.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
Forward declarations for faPatchField types.
auto & name
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Field< vector > vectorField
Specialisation of Field<T> for vector.
const direction noexcept
Definition scalarImpl.H:265
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
vectorField pointField
pointField is a vectorField.
PtrList< faPatch > faPatchList
Store lists of faPatch as a PtrList.
Definition faPatch.H:64
UList< label > labelUList
A UList of labels.
Definition UList.H:75
runTime write()
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
dictionary dict
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68