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-2022 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\*---------------------------------------------------------------------------*/
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 labelList::subList* edgeFacesPtr_;
90
91 //- Demand-driven: local points labels
92 mutable labelList* pointLabelsPtr_;
93
94 //- Demand-driven: point-edge addressing
95 mutable 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 {}
130
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 {}
145
146
147public:
148
149 //- The boundary type associated with the patch
151
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
189 (
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& pt);
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 //- Patch start in edge list
309 label start() const;
310
311 //- Patch size is the number of edge labels
312 virtual label size() const
313 {
314 return labelList::size();
315 }
316
317 //- Return label of edge in patch from global edge label
318 inline label whichEdge(const label l) const
319 {
320 return l - start();
321 }
322
323 //- Slice list to patch
324 template<class T>
325 typename List<T>::subList patchSlice(const List<T>& l) const
326 {
327 return typename List<T>::subList(l, size(), start());
328 }
329
330
331 //- Write
332 virtual void write(Ostream&) const;
333
334
335 // Topological information
336
337 //- List of proc/face for the boundary edge neighbours
338 //- in locally reordered edge numbering.
340
341 //- Boundary edge neighbour processors
342 //- (does not include own proc)
343 labelList boundaryProcs() const;
344
345 //- List of proc/size for the boundary edge neighbour processors
346 //- (does not include own proc)
348
349
350 // Access functions for geometrical data
351
352 //- Return patch point labels
353 const labelList& pointLabels() const;
354
355 //- Return patch point-edge addressing
356 const labelListList& pointEdges() const;
357
358 //- Return normals of neighbour polyPatch faces
359 // Same as faMesh::haloFaceNormals()
361
362 //- Return normals of neighbour polyPatch joined points
364
365 //- Return edge-face addressing
366 const labelUList& edgeFaces() const;
367
368 //- Return edge centres
369 const vectorField& edgeCentres() const;
370
371 //- Return edge length vectors
372 const vectorField& edgeLengths() const;
373
374 //- Return edge length magnitudes
375 const scalarField& magEdgeLengths() const;
376
377 //- Return edge normals
379
380 //- Return neighbour face centres
382
383 //- Return cell-centre to face-centre vector
384 // except for coupled patches for which the cell-centre
385 // to coupled-cell-centre vector is returned
386 virtual tmp<vectorField> delta() const;
387
388
389 // Access functions for demand driven data
390
391 //- Make patch weighting factors
392 virtual void makeWeights(scalarField&) const;
393
394 //- Return patch weighting factors
395 const scalarField& weights() const;
396
397 //- Make patch edge - neighbour face distances
398 virtual void makeDeltaCoeffs(scalarField&) const;
399
401
402 //- Return patch edge - neighbour face distances
403 const scalarField& deltaCoeffs() const;
404
405
406 // Topological changes
407
408 //- Reset the list of edges (use with caution)
409 void resetEdges(const labelUList& newEdges);
410
411 //- Reset the list of edges (use with caution)
412 void resetEdges(labelList&& newEdges);
413
414
415 // Evaluation
416
417 //- Return given internal field next to patch as patch field
418 template<class Type>
420
421 //- Return given internal field next to patch as patch field
422 // providing addressing
423 template<class Type>
425 (
426 const UList<Type>& f,
427 const labelUList& edgeFaces
428 ) const;
429
430 //- Return the corresponding patchField of the named field
431 template<class GeometricField, class Type>
432 const typename GeometricField::Patch& patchField
433 (
434 const GeometricField&
435 ) const;
436
437 //- Lookup and return the patchField of the named field from the
438 //- local objectRegistry.
439 // N.B. The dummy pointer arguments are used if this function is
440 // instantiated within a templated function to avoid a bug in gcc.
441 // See inletOutletFvPatchField.C and outletInletFvPatchField.C
442 template<class GeometricField, class Type>
444 (
445 const word& name,
446 const GeometricField* = nullptr,
447 const Type* = nullptr
448 ) const;
449
450
451 // Ostream Operator
453 friend Ostream& operator<<(Ostream&, const faPatch&);
454};
455
456
457// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
458
459} // End namespace Foam
460
461// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
462
463#ifdef NoRepository
464 #include "faPatchTemplates.C"
465#endif
466
467// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
468
469#endif
470
471// ************************************************************************* //
Generic GeometricField class.
PatchField< Type > Patch
The patch field type for the GeometricBoundaryField.
SubList< T > subList
Declare type of subList.
Definition: List.H:111
autoPtr< List< label > > clone() const
Clone.
Definition: ListI.H:100
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
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:73
A List obtained as a section of another List.
Definition: SubList.H:70
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Finite area boundary mesh.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:78
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: faPatch.C:62
virtual label size() const
Patch size is the number of edge labels.
Definition: faPatch.H:311
faBoundaryMesh BoundaryMesh
The boundary type associated with the patch.
Definition: faPatch.H:149
label nPoints() const
Number of patch points.
Definition: faPatch.H:281
const labelListList & pointEdges() const
Return patch point-edge addressing.
Definition: faPatch.C:284
tmp< vectorField > ngbPolyPatchPointNormals() const
Return normals of neighbour polyPatch joined points.
Definition: faPatch.C:394
TypeName("patch")
Runtime type information.
const labelList & pointLabels() const
Return patch point labels.
Definition: faPatch.C:273
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:183
void resetEdges(const labelUList &newEdges)
Reset the list of edges (use with caution)
Definition: faPatch.C:538
virtual bool coupled() const
Return true if this patch is coupled.
Definition: faPatch.H:302
const GeometricField::Patch & patchField(const GeometricField &) const
Return the corresponding patchField of the named field.
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: faPatch.C:522
friend Ostream & operator<<(Ostream &, const faPatch &)
virtual void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: faPatch.H:123
tmp< Foam::Field< Type > > patchInternalField(const UList< Type > &f, const labelUList &edgeFaces) const
Return given internal field next to patch as patch field.
virtual autoPtr< faPatch > clone(const faBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition: faPatch.H:211
const labelList & edgeLabels() const noexcept
Return the list of edges.
Definition: faPatch.H:275
virtual void makeDeltaCoeffs(scalarField &) const
Make patch edge - neighbour face distances.
Definition: faPatch.C:500
List< labelPair > boundaryConnections() const
Definition: faPatch.C:203
const scalarField & magEdgeLengths() const
Return edge length magnitudes.
Definition: faPatch.C:455
label ngbPolyPatchIndex() const noexcept
The neighbour polyPatch index.
Definition: faPatch.H:293
tmp< vectorField > ngbPolyPatchFaceNormals() const
Return normals of neighbour polyPatch faces.
Definition: faPatch.C:383
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:35
const GeometricField::Patch & lookupPatchField(const word &name, const GeometricField *=nullptr, const Type *=nullptr) const
virtual autoPtr< faPatch > clone(const faBoundaryMesh &bm, const labelUList &edgeLabels, const label index, const label nbrPolyPatchi) const
Definition: faPatch.H:219
const vectorField & edgeLengths() const
Return edge length vectors.
Definition: faPatch.C:449
tmp< Field< Type > > patchInternalField(const UList< Type > &) const
Return given internal field next to patch as patch field.
virtual tmp< vectorField > delta() const
Return cell-centre to face-centre vector.
Definition: faPatch.C:494
label nEdges() const noexcept
Number of edge labels (boundary edges) addressed by this patch.
Definition: faPatch.H:287
tmp< vectorField > edgeFaceCentres() const
Return neighbour face centres.
Definition: faPatch.C:474
void calcPointEdges() const
Calculate patch point-edge addressing.
Definition: faPatch.C:352
const faBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
Definition: faPatch.C:191
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: faPatch.C:53
const scalarField & weights() const
Return patch weighting factors.
Definition: faPatch.C:528
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: faPatch.H:138
const labelUList & edgeFaces() const
Return edge-face addressing.
Definition: faPatch.C:429
virtual void movePoints(PstreamBuffers &, const pointField &)
Correct patch after moving points.
Definition: faPatch.C:534
const vectorField & edgeCentres() const
Return edge centres.
Definition: faPatch.C:443
labelList boundaryProcs() const
Definition: faPatch.C:223
tmp< vectorField > edgeNormals() const
Return edge normals.
Definition: faPatch.C:461
void calcPointLabels() const
Calculate patch point labels.
Definition: faPatch.C:295
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: faPatch.H:127
List< labelPair > boundaryProcSizes() const
Definition: faPatch.C:243
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: faPatch.H:142
const scalarField & deltaCoeffs() const
Return patch edge - neighbour face distances.
Definition: faPatch.C:516
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition: faPatch.H:131
void makeCorrectionVectors(vectorField &) const
Definition: faPatch.C:506
label whichEdge(const label l) const
Return label of edge in patch from global edge label.
Definition: faPatch.H:317
List< T >::subList patchSlice(const List< T > &l) const
Slice list to patch.
Definition: faPatch.H:324
label start() const
Patch start in edge list.
Definition: faPatch.C:197
Identifies a patch by name and index, with optional physical type and group information.
label index() const noexcept
The index of this patch in the boundaryMesh.
const word & name() const noexcept
The patch name.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
const direction noexcept
Definition: Scalar.H:223
PtrList< faPatch > faPatchList
Store lists of faPatch as a PtrList.
Definition: faPatch.H:66
runTime write()
labelList f(nPoints)
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
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73