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-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::faPatch
29 
30 Description
31  Finite area patch class. Used for 2-D non-Euclidian finite area method.
32 
33 Author
34  Zeljko Tukovic, FMENA
35  Hrvoje Jasak, Wikki Ltd.
36 
37 SourceFiles
38  faPatch.C
39  faPatchNew.C
40  faPatchTemplates.C
41  faPatchFaMeshTemplates.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef faPatch_H
46 #define faPatch_H
47 
48 #include "patchIdentifier.H"
49 #include "labelList.H"
50 #include "pointField.H"
51 #include "typeInfo.H"
52 #include "faPatchFieldsFwd.H"
53 #include "autoPtr.H"
54 #include "runTimeSelectionTables.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 // Forward Declarations
62 class faBoundaryMesh;
63 class faPatch;
64 Ostream& operator<<(Ostream&, const faPatch&);
65 
66 /*---------------------------------------------------------------------------*\
67  Class faPatch Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 class faPatch
71 :
72  public patchIdentifier,
73  public labelList
74 {
75  // Private Data
76 
77  //- Neighbour polyPatch index
78  const label nbrPolyPatchId_;
79 
80  //- Reference to boundary mesh
81  const faBoundaryMesh& boundaryMesh_;
82 
83  //- Demand-driven: edge-face addressing
84  mutable labelList::subList* edgeFacesPtr_;
85 
86  //- Demand-driven: local points labels
87  mutable labelList* pointLabelsPtr_;
88 
89  //- Demand-driven: point-edge addressing
90  mutable labelListList* pointEdgesPtr_;
91 
92 
93  // Private Member Functions
94 
95  //- No copy construct
96  faPatch(const faPatch&) = delete;
97 
98  //- No copy assignment
99  void operator=(const faPatch&) = delete;
100 
101  //- Clear out topological patch data
102  void clearOut();
103 
104 
105 protected:
106 
107  // Protected Member Functions
108 
109  //- The faPatch geometry initialisation is called by faBoundaryMesh
110  friend class faBoundaryMesh;
111 
112  //- Calculate patch point labels
113  void calcPointLabels() const;
114 
115  //- Calculate patch point-edge addressing
116  void calcPointEdges() const;
117 
118  //- Initialise the calculation of the patch geometry
119  virtual void initGeometry()
120  {}
121 
122  //- Calculate the patch geometry
123  virtual void calcGeometry()
124  {}
125 
126  //- Initialise the patches for moving points
127  virtual void initMovePoints(const pointField&)
128  {}
129 
130  //- Correct patch after moving points
131  virtual void movePoints(const pointField&);
132 
133  //- Initialise the update of the patch topology
134  virtual void initUpdateMesh()
135  {}
136 
137  //- Update of the patch topology
138  virtual void updateMesh()
139  {}
140 
141 
142 public:
143 
145 
146  //- Runtime type information
147  TypeName("patch");
148 
149  // Declare run-time constructor selection tables
150 
152  (
153  autoPtr,
154  faPatch,
155  dictionary,
156  (
157  const word& name,
158  const dictionary& dict,
159  const label index,
160  const faBoundaryMesh& bm
161  ),
162  (name, dict, index, bm)
163  );
164 
165 
166  // Constructors
167 
168  //- Construct from components
169  faPatch
170  (
171  const word& name,
172  const labelList& edgeLabels,
173  const label index,
174  const faBoundaryMesh& bm,
175  const label ngbPolyPatchIndex
176  );
177 
178  //- Construct from dictionary
179  faPatch
180  (
181  const word& name,
182  const dictionary& dict,
183  const label index,
184  const faBoundaryMesh& bm
185  );
186 
187  //- Construct as copy, resetting the boundary mesh
188  faPatch(const faPatch&, const faBoundaryMesh&);
189 
190  //- Construct and return a clone, resetting the edge list
191  //- and boundary mesh
193  (
194  const faBoundaryMesh& bm,
195  const labelList& edgeLabels,
196  const label index,
197  const label ngbPolyPatchIndex
198  ) const
199  {
200  return
203  }
204 
205 
206  // Selectors
207 
208  //- Return a pointer to a new patch created
209  //- on freestore from dictionary
210  static autoPtr<faPatch> New
211  (
212  const word& name,
213  const dictionary& dict,
214  const label index,
215  const faBoundaryMesh& bm
216  );
217 
218 
219  //- Destructor
220  virtual ~faPatch();
221 
222 
223  // Member Functions
224 
225  //- Return the list of edges
226  const labelList& edgeLabels() const noexcept
227  {
228  return static_cast<const labelList&>(*this);
229  }
230 
231  //- Define new list of edges
232  void edgeLabels(const UList<label>& newEdgeLabels);
233 
234  //- Number of patch points
235  label nPoints() const
236  {
237  return pointLabels().size();
238  }
239 
240  //- Number of edge labels (boundary edges) addressed by this patch
241  label nEdges() const noexcept
242  {
243  return labelList::size();
244  }
245 
246  //- The neighbour polyPatch index
247  label ngbPolyPatchIndex() const noexcept
248  {
249  return nbrPolyPatchId_;
250  }
251 
252  //- Return boundaryMesh reference
253  const faBoundaryMesh& boundaryMesh() const noexcept;
254 
255  //- Return true if this patch is coupled
256  virtual bool coupled() const
257  {
258  return false;
259  }
260 
261  //- Patch start in edge list
262  label start() const;
263 
264  //- Patch size is the number of edge labels
265  virtual label size() const
266  {
267  return labelList::size();
268  }
269 
270  //- Return label of edge in patch from global edge label
271  inline label whichEdge(const label l) const
272  {
273  return l - start();
274  }
275 
276  //- Slice list to patch
277  template<class T>
278  typename List<T>::subList patchSlice(const List<T>& l) const
279  {
280  return typename List<T>::subList(l, size(), start());
281  }
282 
283 
284  //- Write
285  virtual void write(Ostream&) const;
286 
287 
288  // Topological information
289 
290  //- List of proc/face for the boundary edge neighbours
291  //- in locally reordered edge numbering.
293 
294  //- Boundary edge neighbour processors
295  //- (does not include own proc)
296  labelList boundaryProcs() const;
297 
298  //- List of proc/size for the boundary edge neighbour processors
299  //- (does not include own proc)
301 
302 
303  // Access functions for geometrical data
304 
305  //- Return patch point labels
306  const labelList& pointLabels() const;
307 
308  //- Return patch point-edge addressing
309  const labelListList& pointEdges() const;
310 
311  //- Return normals of neighbour polyPatch faces
312  // Same as faMesh::haloFaceNormals()
314 
315  //- Return normals of neighbour polyPatch joined points
317 
318  //- Return edge-face addressing
319  const labelUList& edgeFaces() const;
320 
321  //- Return edge centres
322  const vectorField& edgeCentres() const;
323 
324  //- Return edge length vectors
325  const vectorField& edgeLengths() const;
326 
327  //- Return edge length magnitudes
328  const scalarField& magEdgeLengths() const;
329 
330  //- Return edge normals
332 
333  //- Return neighbour face centres
335 
336  //- Return cell-centre to face-centre vector
337  // except for coupled patches for which the cell-centre
338  // to coupled-cell-centre vector is returned
339  virtual tmp<vectorField> delta() const;
340 
341 
342  // Access functions for demand driven data
343 
344  //- Make patch weighting factors
345  virtual void makeWeights(scalarField&) const;
346 
347  //- Return patch weighting factors
348  const scalarField& weights() const;
349 
350  //- Make patch edge - neighbour face distances
351  virtual void makeDeltaCoeffs(scalarField&) const;
352 
353  void makeCorrectionVectors(vectorField&) const;
354 
355  //- Return patch edge - neighbour face distances
356  const scalarField& deltaCoeffs() const;
357 
358 
359  // Topological changes
360 
361  //- Reset the list of edges (use with caution)
362  void resetEdges(const UList<label>& newEdges);
363 
364  //- Reset the list of edges (use with caution)
365  void resetEdges(labelList&& newEdges);
366 
367 
368  // Evaluation
369 
370  //- Return given internal field next to patch as patch field
371  template<class Type>
373 
374  //- Return given internal field next to patch as patch field
375  // providing addressing
376  template<class Type>
378  (
379  const UList<Type>& f,
380  const labelUList& edgeFaces
381  ) const;
382 
383  //- Return the corresponding patchField of the named field
384  template<class GeometricField, class Type>
385  const typename GeometricField::Patch& patchField
386  (
387  const GeometricField&
388  ) const;
389 
390  //- Lookup and return the patchField of the named field from the
391  //- local objectRegistry.
392  // N.B. The dummy pointer arguments are used if this function is
393  // instantiated within a templated function to avoid a bug in gcc.
394  // See inletOutletFvPatchField.C and outletInletFvPatchField.C
395  template<class GeometricField, class Type>
397  (
398  const word& name,
399  const GeometricField* = nullptr,
400  const Type* = nullptr
401  ) const;
402 
403 
404  // Ostream Operator
405 
406  friend Ostream& operator<<(Ostream&, const faPatch&);
407 };
408 
409 
410 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
411 
412 } // End namespace Foam
413 
414 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
415 
416 #ifdef NoRepository
417  #include "faPatchTemplates.C"
418 #endif
419 
420 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
421 
422 #endif
423 
424 // ************************************************************************* //
Foam::autoPtr::New
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
Foam::faPatch::edgeFaceCentres
tmp< vectorField > edgeFaceCentres() const
Return neighbour face centres.
Definition: faPatch.C:403
Foam::faPatch::pointEdges
const labelListList & pointEdges() const
Return patch point-edge addressing.
Definition: faPatch.C:213
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
typeInfo.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::faPatch::movePoints
virtual void movePoints(const pointField &)
Correct patch after moving points.
Definition: faPatch.C:463
Foam::faPatch::resetEdges
void resetEdges(const UList< label > &newEdges)
Reset the list of edges (use with caution)
Definition: faPatch.C:467
Foam::faPatch::deltaCoeffs
const scalarField & deltaCoeffs() const
Return patch edge - neighbour face distances.
Definition: faPatch.C:445
Foam::faPatch::makeWeights
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: faPatch.C:451
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:54
Foam::faPatch::calcGeometry
virtual void calcGeometry()
Calculate the patch geometry.
Definition: faPatch.H:122
Foam::faPatch::calcPointLabels
void calcPointLabels() const
Calculate patch point labels.
Definition: faPatch.C:224
Foam::faPatch::New
static autoPtr< faPatch > New(const word &name, const dictionary &dict, const label index, const faBoundaryMesh &bm)
Definition: faPatchNew.C:35
Foam::faPatch::nPoints
label nPoints() const
Number of patch points.
Definition: faPatch.H:234
Foam::faPatch::patchInternalField
tmp< Field< Type > > patchInternalField(const UList< Type > &) const
Return given internal field next to patch as patch field.
Foam::faPatch::boundaryMesh
const faBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
Definition: faPatch.C:120
Foam::faPatch::delta
virtual tmp< vectorField > delta() const
Return cell-centre to face-centre vector.
Definition: faPatch.C:423
faPatchFieldsFwd.H
Foam::faPatch::weights
const scalarField & weights() const
Return patch weighting factors.
Definition: faPatch.C:457
Foam::faPatch::initUpdateMesh
virtual void initUpdateMesh()
Initialise the update of the patch topology.
Definition: faPatch.H:133
Foam::faPatch::edgeLabels
const labelList & edgeLabels() const noexcept
Return the list of edges.
Definition: faPatch.H:225
Foam::faPatch::ngbPolyPatchFaceNormals
tmp< vectorField > ngbPolyPatchFaceNormals() const
Return normals of neighbour polyPatch faces.
Definition: faPatch.C:312
Foam::faPatch::edgeFaces
const labelUList & edgeFaces() const
Return edge-face addressing.
Definition: faPatch.C:358
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::faBoundaryMesh
Finite area boundary mesh.
Definition: faBoundaryMesh.H:65
Foam::faPatch::initMovePoints
virtual void initMovePoints(const pointField &)
Initialise the patches for moving points.
Definition: faPatch.H:126
Foam::patchIdentifier
Identifies a patch by name and index, with optional physical type and group information.
Definition: patchIdentifier.H:55
Foam::faPatch::boundaryProcs
labelList boundaryProcs() const
Definition: faPatch.C:152
labelList.H
Foam::Field< vector >
Foam::faPatch::makeDeltaCoeffs
virtual void makeDeltaCoeffs(scalarField &) const
Make patch edge - neighbour face distances.
Definition: faPatch.C:429
Foam::faPatch::TypeName
TypeName("patch")
Runtime type information.
Foam::faPatch::edgeCentres
const vectorField & edgeCentres() const
Return edge centres.
Definition: faPatch.C:372
Foam::faPatch::nEdges
label nEdges() const noexcept
Number of edge labels (boundary edges) addressed by this patch.
Definition: faPatch.H:240
Foam::faPatch::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, faPatch, dictionary,(const word &name, const dictionary &dict, const label index, const faBoundaryMesh &bm),(name, dict, index, bm))
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::List::subList
SubList< T > subList
Declare type of subList.
Definition: List.H:112
Foam::faPatch::patchField
const GeometricField::Patch & patchField(const GeometricField &) const
Return the corresponding patchField of the named field.
Definition: faPatchTemplates.C:64
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::faPatch::patchSlice
List< T >::subList patchSlice(const List< T > &l) const
Slice list to patch.
Definition: faPatch.H:277
Foam::faPatch::boundaryProcSizes
List< labelPair > boundaryProcSizes() const
Definition: faPatch.C:172
Foam::faPatch::makeCorrectionVectors
void makeCorrectionVectors(vectorField &) const
Definition: faPatch.C:435
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::patchIdentifier::index
label index() const noexcept
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:147
Foam::faPatch::start
label start() const
Patch start in edge list.
Definition: faPatch.C:126
Foam::faPatch::coupled
virtual bool coupled() const
Return true if this patch is coupled.
Definition: faPatch.H:255
Foam::faPatch::updateMesh
virtual void updateMesh()
Update of the patch topology.
Definition: faPatch.H:137
Foam::faPatch::~faPatch
virtual ~faPatch()
Destructor.
Definition: faPatch.C:112
Foam::faPatch::boundaryConnections
List< labelPair > boundaryConnections() const
Definition: faPatch.C:132
pointField.H
Foam::faPatch::pointLabels
const labelList & pointLabels() const
Return patch point labels.
Definition: faPatch.C:202
patchIdentifier.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::faPatch::magEdgeLengths
const scalarField & magEdgeLengths() const
Return edge length magnitudes.
Definition: faPatch.C:384
Foam::faPatch::operator<<
friend Ostream & operator<<(Ostream &, const faPatch &)
f
labelList f(nPoints)
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::faPatch::write
virtual void write(Ostream &) const
Write.
Definition: faPatch.C:481
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::UList< label >
Foam::faPatch::edgeNormals
tmp< vectorField > edgeNormals() const
Return edge normals.
Definition: faPatch.C:390
Foam::patchIdentifier::name
const word & name() const noexcept
The patch name.
Definition: patchIdentifier.H:135
Foam::faPatch::initGeometry
virtual void initGeometry()
Initialise the calculation of the patch geometry.
Definition: faPatch.H:118
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::List::clone
autoPtr< List< T > > clone() const
Clone.
Definition: ListI.H:100
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::GeometricField::Patch
PatchField< Type > Patch
Definition: GeometricField.H:111
Foam::faPatch::ngbPolyPatchPointNormals
tmp< vectorField > ngbPolyPatchPointNormals() const
Return normals of neighbour polyPatch joined points.
Definition: faPatch.C:323
Foam::faPatch
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:69
faPatchTemplates.C
Foam::faPatch::edgeLengths
const vectorField & edgeLengths() const
Return edge length vectors.
Definition: faPatch.C:378
Foam::faPatch::BoundaryMesh
faBoundaryMesh BoundaryMesh
Definition: faPatch.H:143
Foam::faPatch::calcPointEdges
void calcPointEdges() const
Calculate patch point-edge addressing.
Definition: faPatch.C:281
Foam::faPatch::lookupPatchField
const GeometricField::Patch & lookupPatchField(const word &name, const GeometricField *=nullptr, const Type *=nullptr) const
Definition: faPatchFaMeshTemplates.C:35
Foam::faPatch::ngbPolyPatchIndex
label ngbPolyPatchIndex() const noexcept
The neighbour polyPatch index.
Definition: faPatch.H:246
Foam::faPatch::whichEdge
label whichEdge(const label l) const
Return label of edge in patch from global edge label.
Definition: faPatch.H:270
autoPtr.H
Foam::faPatch::size
virtual label size() const
Patch size is the number of edge labels.
Definition: faPatch.H:264